@material/web 1.0.0-pre.14 → 1.0.0-pre.15

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 (258) hide show
  1. package/README.md +5 -5
  2. package/all.d.ts +4 -8
  3. package/all.js +4 -8
  4. package/all.js.map +1 -1
  5. package/button/{_tonal-button.scss → _filled-tonal-button.scss} +1 -1
  6. package/button/{tonal-button.d.ts → filled-tonal-button.d.ts} +3 -3
  7. package/button/{tonal-button.js → filled-tonal-button.js} +9 -9
  8. package/button/filled-tonal-button.js.map +1 -0
  9. package/button/internal/{_tonal-button.scss → _filled-tonal-button.scss} +7 -7
  10. package/button/internal/_shared.scss +12 -7
  11. package/button/internal/_touch-target.scss +5 -1
  12. package/button/internal/button.d.ts +6 -10
  13. package/button/internal/button.js +10 -43
  14. package/button/internal/button.js.map +1 -1
  15. package/button/internal/elevated-styles.css.js +1 -1
  16. package/button/internal/elevated-styles.css.js.map +1 -1
  17. package/button/internal/filled-styles.css.js +1 -1
  18. package/button/internal/filled-styles.css.js.map +1 -1
  19. package/button/internal/{tonal-button.d.ts → filled-tonal-button.d.ts} +2 -2
  20. package/button/internal/{tonal-button.js → filled-tonal-button.js} +3 -3
  21. package/button/internal/filled-tonal-button.js.map +1 -0
  22. package/button/internal/filled-tonal-styles.css.js +9 -0
  23. package/button/internal/filled-tonal-styles.css.js.map +1 -0
  24. package/button/internal/{tonal-styles.scss → filled-tonal-styles.scss} +2 -2
  25. package/button/internal/outlined-styles.css.js +1 -1
  26. package/button/internal/outlined-styles.css.js.map +1 -1
  27. package/button/internal/shared-styles.css.js +1 -1
  28. package/button/internal/shared-styles.css.js.map +1 -1
  29. package/button/internal/text-styles.css.js +1 -1
  30. package/button/internal/text-styles.css.js.map +1 -1
  31. package/checkbox/internal/_checkbox.scss +22 -78
  32. package/checkbox/internal/checkbox-styles.css.js +1 -1
  33. package/checkbox/internal/checkbox-styles.css.js.map +1 -1
  34. package/checkbox/internal/checkbox.d.ts +77 -6
  35. package/checkbox/internal/checkbox.js +123 -14
  36. package/checkbox/internal/checkbox.js.map +1 -1
  37. package/chips/internal/_shared.scss +8 -0
  38. package/chips/internal/chip-set.js +1 -3
  39. package/chips/internal/chip-set.js.map +1 -1
  40. package/chips/internal/chip.js +1 -3
  41. package/chips/internal/chip.js.map +1 -1
  42. package/chips/internal/filter-chip.d.ts +1 -0
  43. package/chips/internal/filter-chip.js +12 -6
  44. package/chips/internal/filter-chip.js.map +1 -1
  45. package/chips/internal/shared-styles.css.js +1 -1
  46. package/chips/internal/shared-styles.css.js.map +1 -1
  47. package/common.d.ts +2 -6
  48. package/common.js +2 -6
  49. package/common.js.map +1 -1
  50. package/dialog/harness.d.ts +1 -6
  51. package/dialog/harness.js +2 -43
  52. package/dialog/harness.js.map +1 -1
  53. package/dialog/internal/_dialog.scss +165 -281
  54. package/dialog/internal/animations.d.ts +47 -0
  55. package/dialog/internal/animations.js +117 -0
  56. package/dialog/internal/animations.js.map +1 -0
  57. package/dialog/internal/dialog-styles.css.js +1 -1
  58. package/dialog/internal/dialog-styles.css.js.map +1 -1
  59. package/dialog/internal/dialog.d.ts +76 -169
  60. package/dialog/internal/dialog.js +251 -475
  61. package/dialog/internal/dialog.js.map +1 -1
  62. package/fab/internal/_fab.scss +4 -0
  63. package/fab/internal/_shared.scss +12 -0
  64. package/fab/internal/fab-styles.css.js +1 -1
  65. package/fab/internal/fab-styles.css.js.map +1 -1
  66. package/fab/internal/shared-styles.css.js +1 -1
  67. package/fab/internal/shared-styles.css.js.map +1 -1
  68. package/fab/internal/shared.d.ts +0 -4
  69. package/fab/internal/shared.js +3 -13
  70. package/fab/internal/shared.js.map +1 -1
  71. package/focus/internal/_focus-ring.scss +52 -48
  72. package/focus/internal/focus-ring-styles.css.js +1 -1
  73. package/focus/internal/focus-ring-styles.css.js.map +1 -1
  74. package/focus/internal/focus-ring.d.ts +2 -1
  75. package/focus/internal/focus-ring.js +10 -0
  76. package/focus/internal/focus-ring.js.map +1 -1
  77. package/icon/internal/_icon.scss +18 -17
  78. package/icon/internal/icon-styles.css.js +1 -1
  79. package/icon/internal/icon-styles.css.js.map +1 -1
  80. package/icon/internal/icon.d.ts +1 -0
  81. package/icon/internal/icon.js +9 -0
  82. package/icon/internal/icon.js.map +1 -1
  83. package/iconbutton/{_standard-icon-button.scss → _icon-button.scss} +1 -1
  84. package/iconbutton/{standard-icon-button.d.ts → icon-button.d.ts} +2 -2
  85. package/iconbutton/{standard-icon-button.js → icon-button.js} +7 -7
  86. package/iconbutton/icon-button.js.map +1 -0
  87. package/iconbutton/internal/_filled-icon-button.scss +8 -6
  88. package/iconbutton/internal/_filled-tonal-icon-button.scss +8 -6
  89. package/iconbutton/internal/{_standard-icon-button.scss → _icon-button.scss} +8 -8
  90. package/iconbutton/internal/_outlined-icon-button.scss +14 -14
  91. package/iconbutton/internal/_shared.scss +6 -9
  92. package/iconbutton/internal/filled-styles.css.js +1 -1
  93. package/iconbutton/internal/filled-styles.css.js.map +1 -1
  94. package/iconbutton/internal/filled-tonal-styles.css.js +1 -1
  95. package/iconbutton/internal/filled-tonal-styles.css.js.map +1 -1
  96. package/iconbutton/internal/icon-button.d.ts +10 -1
  97. package/iconbutton/internal/icon-button.js +17 -2
  98. package/iconbutton/internal/icon-button.js.map +1 -1
  99. package/iconbutton/internal/outlined-styles.css.js +1 -1
  100. package/iconbutton/internal/outlined-styles.css.js.map +1 -1
  101. package/iconbutton/internal/shared-styles.css.js +1 -1
  102. package/iconbutton/internal/shared-styles.css.js.map +1 -1
  103. package/iconbutton/internal/standard-styles.css.js +1 -1
  104. package/iconbutton/internal/standard-styles.css.js.map +1 -1
  105. package/iconbutton/internal/standard-styles.scss +2 -2
  106. package/internal/aria/delegate.d.ts +1 -1
  107. package/internal/aria/delegate.js +1 -1
  108. package/internal/aria/delegate.js.map +1 -1
  109. package/internal/controller/element-internals.d.ts +35 -0
  110. package/internal/controller/element-internals.js +24 -0
  111. package/internal/controller/element-internals.js.map +1 -0
  112. package/internal/controller/form-submitter.d.ts +60 -0
  113. package/internal/controller/form-submitter.js +69 -0
  114. package/internal/controller/form-submitter.js.map +1 -0
  115. package/labs/navigationbar/internal/navigation-bar.js +1 -3
  116. package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
  117. package/labs/navigationdrawer/internal/navigation-drawer-modal.js +1 -3
  118. package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
  119. package/labs/navigationdrawer/internal/navigation-drawer.js +1 -3
  120. package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
  121. package/labs/navigationtab/internal/navigation-tab.js +1 -3
  122. package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
  123. package/labs/segmentedbutton/internal/outlined-styles.css.js +1 -1
  124. package/labs/segmentedbutton/internal/outlined-styles.css.js.map +1 -1
  125. package/labs/segmentedbutton/internal/segmented-button.js +1 -3
  126. package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
  127. package/labs/segmentedbuttonset/internal/outlined-styles.css.js +1 -1
  128. package/labs/segmentedbuttonset/internal/outlined-styles.css.js.map +1 -1
  129. package/labs/segmentedbuttonset/internal/segmented-button-set.js +1 -3
  130. package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
  131. package/list/internal/list.d.ts +2 -2
  132. package/list/internal/list.js +1 -3
  133. package/list/internal/list.js.map +1 -1
  134. package/list/internal/listitem/_list-item.scss +20 -54
  135. package/list/internal/listitem/list-item-styles.css.js +1 -1
  136. package/list/internal/listitem/list-item-styles.css.js.map +1 -1
  137. package/list/internal/listitem/list-item.d.ts +15 -3
  138. package/list/internal/listitem/list-item.js +43 -10
  139. package/list/internal/listitem/list-item.js.map +1 -1
  140. package/menu/internal/menu.js +3 -4
  141. package/menu/internal/menu.js.map +1 -1
  142. package/menu/internal/menuitem/_menu-item.scss +1 -1
  143. package/menu/internal/menuitem/forced-colors-styles.css.js +1 -1
  144. package/menu/internal/menuitem/forced-colors-styles.css.js.map +1 -1
  145. package/menu/internal/menuitem/forced-colors-styles.scss +1 -1
  146. package/menu/internal/menuitem/menu-item-styles.css.js +1 -1
  147. package/menu/internal/menuitem/menu-item-styles.css.js.map +1 -1
  148. package/menu/internal/menuitem/menu-item.d.ts +9 -0
  149. package/menu/internal/menuitem/menu-item.js +18 -4
  150. package/menu/internal/menuitem/menu-item.js.map +1 -1
  151. package/menu/internal/shared.d.ts +45 -38
  152. package/menu/internal/shared.js +29 -40
  153. package/menu/internal/shared.js.map +1 -1
  154. package/menu/internal/submenuitem/sub-menu-item.d.ts +22 -12
  155. package/menu/internal/submenuitem/sub-menu-item.js +39 -24
  156. package/menu/internal/submenuitem/sub-menu-item.js.map +1 -1
  157. package/menu/menu-item.d.ts +1 -1
  158. package/menu/menu-item.js +0 -1
  159. package/menu/menu-item.js.map +1 -1
  160. package/menu/menu.d.ts +1 -1
  161. package/menu/menu.js +0 -1
  162. package/menu/menu.js.map +1 -1
  163. package/menu/sub-menu-item.d.ts +1 -1
  164. package/menu/sub-menu-item.js +0 -1
  165. package/menu/sub-menu-item.js.map +1 -1
  166. package/package.json +1 -3
  167. package/progress/internal/progress.js +1 -3
  168. package/progress/internal/progress.js.map +1 -1
  169. package/radio/internal/_radio.scss +38 -24
  170. package/radio/internal/forced-colors-styles.css.js +1 -1
  171. package/radio/internal/forced-colors-styles.css.js.map +1 -1
  172. package/radio/internal/forced-colors-styles.scss +4 -4
  173. package/radio/internal/radio-styles.css.js +1 -1
  174. package/radio/internal/radio-styles.css.js.map +1 -1
  175. package/radio/internal/radio.js +7 -6
  176. package/radio/internal/radio.js.map +1 -1
  177. package/select/internal/_filled-select.scss +2 -2
  178. package/select/internal/_outlined-select.scss +2 -2
  179. package/select/internal/_shared.scss +30 -0
  180. package/select/internal/filled-select-styles.css.js +1 -1
  181. package/select/internal/filled-select-styles.css.js.map +1 -1
  182. package/select/internal/outlined-select-styles.css.js +1 -1
  183. package/select/internal/outlined-select-styles.css.js.map +1 -1
  184. package/select/internal/select.d.ts +0 -5
  185. package/select/internal/select.js +11 -16
  186. package/select/internal/select.js.map +1 -1
  187. package/select/internal/selectoption/select-option.d.ts +5 -6
  188. package/select/internal/selectoption/select-option.js +8 -9
  189. package/select/internal/selectoption/select-option.js.map +1 -1
  190. package/select/internal/shared-styles.css.js +1 -1
  191. package/select/internal/shared-styles.css.js.map +1 -1
  192. package/select/internal/shared.d.ts +5 -9
  193. package/select/internal/shared.js +13 -11
  194. package/select/internal/shared.js.map +1 -1
  195. package/slider/internal/slider.js +1 -3
  196. package/slider/internal/slider.js.map +1 -1
  197. package/switch/internal/_handle.scss +12 -12
  198. package/switch/internal/_icon.scss +8 -8
  199. package/switch/internal/_track.scss +10 -10
  200. package/switch/internal/forced-colors-styles.css.js +1 -1
  201. package/switch/internal/forced-colors-styles.css.js.map +1 -1
  202. package/switch/internal/forced-colors-styles.scss +12 -12
  203. package/switch/internal/switch-styles.css.js +1 -1
  204. package/switch/internal/switch-styles.css.js.map +1 -1
  205. package/switch/internal/switch.js +1 -3
  206. package/switch/internal/switch.js.map +1 -1
  207. package/tabs/internal/_tab.scss +1 -1
  208. package/tabs/internal/_tabs.scss +1 -0
  209. package/tabs/internal/tab.d.ts +3 -9
  210. package/tabs/internal/tab.js +4 -7
  211. package/tabs/internal/tab.js.map +1 -1
  212. package/tabs/internal/tabs.d.ts +1 -4
  213. package/tabs/internal/tabs.js +5 -10
  214. package/tabs/internal/tabs.js.map +1 -1
  215. package/textfield/harness.js +4 -0
  216. package/textfield/harness.js.map +1 -1
  217. package/textfield/internal/text-field.js +1 -4
  218. package/textfield/internal/text-field.js.map +1 -1
  219. package/tokens/_index.scss +1 -0
  220. package/tokens/_md-comp-checkbox.scss +16 -16
  221. package/tokens/_md-comp-dialog.scss +2 -1
  222. package/tokens/_md-comp-elevated-button.scss +14 -12
  223. package/tokens/_md-comp-filled-button.scss +14 -12
  224. package/tokens/_md-comp-filled-icon-button.scss +23 -8
  225. package/tokens/_md-comp-filled-select.scss +19 -1
  226. package/tokens/_md-comp-filled-tonal-button.scss +14 -12
  227. package/tokens/_md-comp-filled-tonal-icon-button.scss +23 -8
  228. package/tokens/_md-comp-icon-button.scss +24 -11
  229. package/tokens/_md-comp-icon.scss +32 -0
  230. package/tokens/_md-comp-outlined-button.scss +14 -12
  231. package/tokens/_md-comp-outlined-icon-button.scss +26 -12
  232. package/tokens/_md-comp-outlined-segmented-button.scss +2 -2
  233. package/tokens/_md-comp-radio-button.scss +20 -9
  234. package/tokens/_md-comp-switch.scss +66 -32
  235. package/tokens/_md-comp-text-button.scss +14 -12
  236. package/button/internal/tonal-button.js.map +0 -1
  237. package/button/internal/tonal-styles.css.js +0 -9
  238. package/button/internal/tonal-styles.css.js.map +0 -1
  239. package/button/tonal-button.js.map +0 -1
  240. package/dialog/internal/_tokens.scss +0 -66
  241. package/icon/internal/_md-comp-icon.scss +0 -18
  242. package/iconbutton/standard-icon-button.js.map +0 -1
  243. package/list/internal/listitemlink/list-item-link-only.d.ts +0 -23
  244. package/list/internal/listitemlink/list-item-link-only.js +0 -36
  245. package/list/internal/listitemlink/list-item-link-only.js.map +0 -1
  246. package/list/internal/listitemlink/list-item-link.d.ts +0 -18
  247. package/list/internal/listitemlink/list-item-link.js +0 -42
  248. package/list/internal/listitemlink/list-item-link.js.map +0 -1
  249. package/list/list-item-link.d.ts +0 -53
  250. package/list/list-item-link.js +0 -57
  251. package/list/list-item-link.js.map +0 -1
  252. package/menu/internal/menuitemlink/menu-item-link.d.ts +0 -23
  253. package/menu/internal/menuitemlink/menu-item-link.js +0 -49
  254. package/menu/internal/menuitemlink/menu-item-link.js.map +0 -1
  255. package/menu/menu-item-link.d.ts +0 -33
  256. package/menu/menu-item-link.js +0 -38
  257. package/menu/menu-item-link.js.map +0 -1
  258. /package/button/internal/{tonal-styles.css.d.ts → filled-tonal-styles.css.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"forced-colors-styles.css.js","sourceRoot":"","sources":["forced-colors-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`@media(forced-colors: active){.list-item{position:relative}:host([selected]) .list-item:not(:has(.focus-ring[visible]))::before{content:\"\";position:absolute;inset:0;box-sizing:border-box;border-radius:inherit;pointer-events:none;border:3px double CanvasText}}/*# sourceMappingURL=forced-colors-styles.css.map */\n`;\n "]}
1
+ {"version":3,"file":"forced-colors-styles.css.js","sourceRoot":"","sources":["forced-colors-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`@media(forced-colors: active){.list-item{position:relative}:host([selected]) .list-item:not(.has-focus-ring)::before{content:\"\";position:absolute;inset:0;box-sizing:border-box;border-radius:inherit;pointer-events:none;border:3px double CanvasText}}/*# sourceMappingURL=forced-colors-styles.css.map */\n`;\n "]}
@@ -10,7 +10,7 @@
10
10
 
11
11
  // Show double border only when selected, and the current list item does not
12
12
  // have a focus ring on it.
13
- :host([selected]) .list-item:not(:has(.focus-ring[visible]))::before {
13
+ :host([selected]) .list-item:not(.has-focus-ring)::before {
14
14
  content: '';
15
15
  position: absolute;
16
16
  inset: 0;
@@ -4,6 +4,6 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { css } from 'lit';
7
- 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 */
7
+ 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)}.submenu-hover{--md-ripple-hover-opacity: 0}/*# sourceMappingURL=menu-item-styles.css.map */
8
8
  `;
9
9
  //# sourceMappingURL=menu-item-styles.css.js.map
@@ -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-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 "]}
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)}.submenu-hover{--md-ripple-hover-opacity: 0}/*# sourceMappingURL=menu-item-styles.css.map */\n`;\n "]}
@@ -18,11 +18,20 @@ export declare class MenuItemEl extends ListItemEl implements MenuItem {
18
18
  * Keeps the menu open if clicked or keyboard selected.
19
19
  */
20
20
  keepOpen: boolean;
21
+ protected hasFocusRing: boolean;
21
22
  /**
22
23
  * Used for overriding e.g. sub-menu-item.
23
24
  */
24
25
  protected keepOpenOnClick: boolean;
25
26
  readonly type: ListItemRole;
26
27
  protected onClick(): void;
28
+ protected getRenderClasses(): {
29
+ 'has-focus-ring': boolean;
30
+ 'with-one-line': boolean;
31
+ 'with-two-line': boolean;
32
+ 'with-three-line': boolean;
33
+ disabled: boolean;
34
+ };
35
+ protected onFocusRingVisibilityChanged(e: Event): void;
27
36
  protected onKeydown(event: KeyboardEvent): void;
28
37
  }
@@ -4,9 +4,9 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { __decorate } from "tslib";
7
- import { property } from 'lit/decorators.js';
7
+ import { property, state } from 'lit/decorators.js';
8
8
  import { ListItemEl } from '../../../list/internal/listitem/list-item.js';
9
- import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey } from '../shared.js';
9
+ import { CLOSE_REASON, createDefaultCloseMenuEvent, isClosableKey } from '../shared.js';
10
10
  /**
11
11
  * @fires close-menu {CloseMenuEvent}
12
12
  */
@@ -21,6 +21,7 @@ export class MenuItemEl extends ListItemEl {
21
21
  * Keeps the menu open if clicked or keyboard selected.
22
22
  */
23
23
  this.keepOpen = false;
24
+ this.hasFocusRing = false;
24
25
  /**
25
26
  * Used for overriding e.g. sub-menu-item.
26
27
  */
@@ -30,7 +31,17 @@ export class MenuItemEl extends ListItemEl {
30
31
  onClick() {
31
32
  if (this.keepOpen || this.keepOpenOnClick)
32
33
  return;
33
- this.dispatchEvent(new DefaultCloseMenuEvent(this, { kind: CLOSE_REASON.CLICK_SELECTION }));
34
+ this.dispatchEvent(createDefaultCloseMenuEvent(this, { kind: CLOSE_REASON.CLICK_SELECTION }));
35
+ }
36
+ getRenderClasses() {
37
+ return {
38
+ ...super.getRenderClasses(),
39
+ 'has-focus-ring': this.hasFocusRing,
40
+ };
41
+ }
42
+ onFocusRingVisibilityChanged(e) {
43
+ const focusRing = e.target;
44
+ this.hasFocusRing = focusRing.visible;
34
45
  }
35
46
  onKeydown(event) {
36
47
  if (this.keepOpen)
@@ -38,7 +49,7 @@ export class MenuItemEl extends ListItemEl {
38
49
  const keyCode = event.code;
39
50
  if (!event.defaultPrevented && isClosableKey(keyCode)) {
40
51
  event.preventDefault();
41
- this.dispatchEvent(new DefaultCloseMenuEvent(this, { kind: CLOSE_REASON.KEYDOWN, key: keyCode }));
52
+ this.dispatchEvent(createDefaultCloseMenuEvent(this, { kind: CLOSE_REASON.KEYDOWN, key: keyCode }));
42
53
  }
43
54
  }
44
55
  }
@@ -48,4 +59,7 @@ __decorate([
48
59
  __decorate([
49
60
  property({ type: Boolean, attribute: 'keep-open' })
50
61
  ], MenuItemEl.prototype, "keepOpen", void 0);
62
+ __decorate([
63
+ state()
64
+ ], MenuItemEl.prototype, "hasFocusRing", void 0);
51
65
  //# 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,mBA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2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {property} from 'lit/decorators.js';\n\nimport {ListItemEl, ListItemRole} from '../../../list/internal/listitem/list-item.js';\nimport {CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, MenuItem} from '../shared.js';\n\nexport {ListItemRole} from '../../../list/internal/listitem/list-item.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 override readonly type: ListItemRole = '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(event: KeyboardEvent) {\n if (this.keepOpen) return;\n const keyCode = event.code;\n\n if (!event.defaultPrevented && isClosableKey(keyCode)) {\n event.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,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,UAAU,EAAe,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAC,YAAY,EAAE,2BAA2B,EAAE,aAAa,EAAW,MAAM,cAAc,CAAC;AAIhG;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAA1C;;QACE;;WAEG;QAEH,eAAU,GAAG,IAAI,CA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,EAAE,WAAW,EAAC,CAAC;4CAAkB;AAE3D;IAAR,KAAK,EAAE;gDAAgC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {property, state} from 'lit/decorators.js';\n\nimport type {MdFocusRing} from '../../../focus/md-focus-ring.js';\nimport {ListItemEl, ListItemRole} from '../../../list/internal/listitem/list-item.js';\nimport {CLOSE_REASON, createDefaultCloseMenuEvent, isClosableKey, MenuItem} from '../shared.js';\n\nexport {ListItemRole} from '../../../list/internal/listitem/list-item.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 @state() protected hasFocusRing = false;\n\n /**\n * Used for overriding e.g. sub-menu-item.\n */\n protected keepOpenOnClick = false;\n\n override readonly type: ListItemRole = 'menuitem';\n\n protected override onClick() {\n if (this.keepOpen || this.keepOpenOnClick) return;\n\n this.dispatchEvent(createDefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.CLICK_SELECTION}));\n }\n\n protected override getRenderClasses() {\n return {\n ...super.getRenderClasses(),\n 'has-focus-ring': this.hasFocusRing,\n };\n }\n\n protected override onFocusRingVisibilityChanged(e: Event) {\n const focusRing = e.target as MdFocusRing;\n this.hasFocusRing = focusRing.visible;\n }\n\n protected override onKeydown(event: KeyboardEvent) {\n if (this.keepOpen) return;\n const keyCode = event.code;\n\n if (!event.defaultPrevented && isClosableKey(keyCode)) {\n event.preventDefault();\n this.dispatchEvent(createDefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.KEYDOWN, key: keyCode}));\n }\n }\n}\n"]}
@@ -63,58 +63,65 @@ export interface KeydownReason extends Reason {
63
63
  */
64
64
  export type DefaultReasons = ClickReason | KeydownReason;
65
65
  /**
66
- * The event that closes any parent menus. It is recommended to subclass and
67
- * dispatch this event rather than creating your own `close-menu` event.
66
+ * Creates an event that closes any parent menus.
68
67
  */
69
- export declare class CloseMenuEvent<T extends Reason = DefaultReasons> extends Event {
68
+ export declare function createCloseMenuEvent<T extends Reason = DefaultReasons>(initiator: MenuItem, reason: T): CustomEvent<{
70
69
  initiator: MenuItem;
71
- readonly reason: T;
72
- readonly itemPath: MenuItem[];
73
- constructor(initiator: MenuItem, reason: T);
74
- }
70
+ itemPath: MenuItem[];
71
+ reason: T;
72
+ }>;
75
73
  /**
76
- * The event that signals to the menu that it should stay open on the focusout
77
- * event.
74
+ * Creates an event that signals to the menu that it should stay open on the
75
+ * focusout event.
78
76
  */
79
- export declare class StayOpenOnFocusoutEvent extends Event {
80
- constructor();
81
- }
77
+ export declare function createStayOpenOnFocusoutEvent(): Event;
82
78
  /**
83
- * The event that signals to the menu that it should close open on the focusout
84
- * event.
79
+ * Creates an event that signals to the menu that it should close open on the
80
+ * focusout event.
85
81
  */
86
- export declare class CloseOnFocusoutEvent extends Event {
87
- constructor();
88
- }
82
+ export declare function createCloseOnFocusoutEvent(): Event;
89
83
  /**
90
- * The default close menu event used by md-menu. To create your own `close-menu`
91
- * event, you should subclass the `CloseMenuEvent` instead.
84
+ * Creates a default close menu event used by md-menu.
92
85
  */
93
- export declare const DefaultCloseMenuEvent: {
94
- new (initiator: MenuItem, reason: DefaultReasons): CloseMenuEvent<DefaultReasons>;
95
- readonly AT_TARGET: number;
96
- readonly BUBBLING_PHASE: number;
97
- readonly CAPTURING_PHASE: number;
98
- readonly NONE: number;
99
- };
86
+ export declare const createDefaultCloseMenuEvent: (initiator: MenuItem, reason: DefaultReasons) => CustomEvent<{
87
+ initiator: MenuItem;
88
+ itemPath: MenuItem[];
89
+ reason: DefaultReasons;
90
+ }>;
100
91
  /**
101
- * The event that requests the parent md-menu to deactivate all other items.
92
+ * The type of the default close menu event used by md-menu.
102
93
  */
103
- export declare class DeactivateItemsEvent extends Event {
104
- constructor();
105
- }
94
+ export type CloseMenuEvent<T extends Reason = DefaultReasons> = ReturnType<typeof createCloseMenuEvent<T>>;
106
95
  /**
107
- * Requests the typeahead functionality of containing menu be deactivated.
96
+ * Creates an event that requests the parent md-menu to deactivate all other
97
+ * items.
108
98
  */
109
- export declare class DeactivateTypeaheadEvent extends Event {
110
- constructor();
111
- }
99
+ export declare function createDeactivateItemsEvent(): Event;
112
100
  /**
113
- * Requests the typeahead functionality of containing menu be activated.
101
+ * The type of the event that requests the parent md-menu to deactivate all
102
+ * other items.
114
103
  */
115
- export declare class ActivateTypeaheadEvent extends Event {
116
- constructor();
117
- }
104
+ export type DeactivateItemsEvent = ReturnType<typeof createDeactivateItemsEvent>;
105
+ /**
106
+ * Creates an event that requests the typeahead functionality of containing menu
107
+ * be deactivated.
108
+ */
109
+ export declare function createDeactivateTypeaheadEvent(): Event;
110
+ /**
111
+ * The type of the event that requests the typeahead functionality of containing
112
+ * menu be deactivated.
113
+ */
114
+ export type DeactivateTypeaheadEvent = ReturnType<typeof createDeactivateTypeaheadEvent>;
115
+ /**
116
+ * Creates an event that requests the typeahead functionality of containing menu
117
+ * be activated.
118
+ */
119
+ export declare function createActivateTypeaheadEvent(): Event;
120
+ /**
121
+ * The type of the event that requests the typeahead functionality of containing
122
+ * menu be activated.
123
+ */
124
+ export type ActivateTypeaheadEvent = ReturnType<typeof createActivateTypeaheadEvent>;
118
125
  /**
119
126
  * Keys that are used to navigate menus.
120
127
  */
@@ -4,64 +4,53 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  /**
7
- * The event that closes any parent menus. It is recommended to subclass and
8
- * dispatch this event rather than creating your own `close-menu` event.
7
+ * Creates an event that closes any parent menus.
9
8
  */
10
- export class CloseMenuEvent extends Event {
11
- constructor(initiator, reason) {
12
- super('close-menu', { bubbles: true, composed: true });
13
- this.initiator = initiator;
14
- this.reason = reason;
15
- this.itemPath = [initiator];
16
- }
9
+ export function createCloseMenuEvent(initiator, reason) {
10
+ return new CustomEvent('close-menu', {
11
+ bubbles: true,
12
+ composed: true,
13
+ detail: { initiator, reason, itemPath: [initiator] }
14
+ });
17
15
  }
18
16
  /**
19
- * The event that signals to the menu that it should stay open on the focusout
20
- * event.
17
+ * Creates an event that signals to the menu that it should stay open on the
18
+ * focusout event.
21
19
  */
22
- export class StayOpenOnFocusoutEvent extends Event {
23
- constructor() {
24
- super('stay-open-on-focusout', { bubbles: true, composed: true });
25
- }
20
+ export function createStayOpenOnFocusoutEvent() {
21
+ return new Event('stay-open-on-focusout', { bubbles: true, composed: true });
26
22
  }
27
23
  /**
28
- * The event that signals to the menu that it should close open on the focusout
29
- * event.
24
+ * Creates an event that signals to the menu that it should close open on the
25
+ * focusout event.
30
26
  */
31
- export class CloseOnFocusoutEvent extends Event {
32
- constructor() {
33
- super('close-on-focusout', { bubbles: true, composed: true });
34
- }
27
+ export function createCloseOnFocusoutEvent() {
28
+ return new Event('close-on-focusout', { bubbles: true, composed: true });
35
29
  }
36
30
  /**
37
- * The default close menu event used by md-menu. To create your own `close-menu`
38
- * event, you should subclass the `CloseMenuEvent` instead.
31
+ * Creates a default close menu event used by md-menu.
39
32
  */
40
- // tslint:disable-next-line
41
- export const DefaultCloseMenuEvent = (CloseMenuEvent);
33
+ export const createDefaultCloseMenuEvent = (createCloseMenuEvent);
42
34
  /**
43
- * The event that requests the parent md-menu to deactivate all other items.
35
+ * Creates an event that requests the parent md-menu to deactivate all other
36
+ * items.
44
37
  */
45
- export class DeactivateItemsEvent extends Event {
46
- constructor() {
47
- super('deactivate-items', { bubbles: true, composed: true });
48
- }
38
+ export function createDeactivateItemsEvent() {
39
+ return new Event('deactivate-items', { bubbles: true, composed: true });
49
40
  }
50
41
  /**
51
- * Requests the typeahead functionality of containing menu be deactivated.
42
+ * Creates an event that requests the typeahead functionality of containing menu
43
+ * be deactivated.
52
44
  */
53
- export class DeactivateTypeaheadEvent extends Event {
54
- constructor() {
55
- super('deactivate-typeahead', { bubbles: true, composed: true });
56
- }
45
+ export function createDeactivateTypeaheadEvent() {
46
+ return new Event('deactivate-typeahead', { bubbles: true, composed: true });
57
47
  }
58
48
  /**
59
- * Requests the typeahead functionality of containing menu be activated.
49
+ * Creates an event that requests the typeahead functionality of containing menu
50
+ * be activated.
60
51
  */
61
- export class ActivateTypeaheadEvent extends Event {
62
- constructor() {
63
- super('activate-typeahead', { bubbles: true, composed: true });
64
- }
52
+ export function createActivateTypeaheadEvent() {
53
+ return new Event('activate-typeahead', { bubbles: true, composed: true });
65
54
  }
66
55
  /**
67
56
  * Keys that are used to navigate menus.
@@ -1 +1 @@
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,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD;QACE,KAAK,CAAC,uBAAuB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAClE,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,mBAAmB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAED;;;GAGG;AACH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,qBAAqB,GAAG,C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,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAE1C,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAC9B,MAAmB,EAAE,SAAsB;IAC7C,sEAAsE;IACtE,4DAA4D;IAC5D,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,aAAa,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAC1E,IAAI,YAAY,GAAkB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,CAAC,EAAS,EAAE,EAAE;QAC7B,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/internal/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 event that signals to the menu that it should stay open on the focusout\n * event.\n */\nexport class StayOpenOnFocusoutEvent extends Event {\n constructor() {\n super('stay-open-on-focusout', {bubbles: true, composed: true});\n }\n}\n\n/**\n * The event that signals to the menu that it should close open on the focusout\n * event.\n */\nexport class CloseOnFocusoutEvent extends Event {\n constructor() {\n super('close-on-focusout', {bubbles: true, composed: true});\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"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoEH;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAChC,SAAmB,EAAE,MAAS;IAChC,OAAO,IAAI,WAAW,CACsC,YAAY,EAAE;QACxE,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAC;KACnD,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,KAAK,CAAC,mBAAmB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAA,oBAAoC,CAAA,CAAC;AAShF;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,KAAK,CAAC,kBAAkB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAA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AAK,KAAK,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAC9B,MAAmB,EAAE,SAAsB;IAC7C,sEAAsE;IACtE,4DAA4D;IAC5D,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,aAAa,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAC1E,IAAI,YAAY,GAAkB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,CAAC,EAAS,EAAE,EAAE;QAC7B,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/internal/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 * Creates an event that closes any parent menus.\n */\nexport function createCloseMenuEvent<T extends Reason = DefaultReasons>(\n initiator: MenuItem, reason: T) {\n return new CustomEvent<\n {initiator: MenuItem, itemPath: MenuItem[], reason: T}>('close-menu', {\n bubbles: true,\n composed: true,\n detail: {initiator, reason, itemPath: [initiator]}\n });\n}\n\n/**\n * Creates an event that signals to the menu that it should stay open on the\n * focusout event.\n */\nexport function createStayOpenOnFocusoutEvent() {\n return new Event('stay-open-on-focusout', {bubbles: true, composed: true});\n}\n\n/**\n * Creates an event that signals to the menu that it should close open on the\n * focusout event.\n */\nexport function createCloseOnFocusoutEvent() {\n return new Event('close-on-focusout', {bubbles: true, composed: true});\n}\n\n/**\n * Creates a default close menu event used by md-menu.\n */\nexport const createDefaultCloseMenuEvent = createCloseMenuEvent<DefaultReasons>;\n\n/**\n * The type of the default close menu event used by md-menu.\n */\n// tslint:disable-next-line\nexport type CloseMenuEvent<T extends Reason = DefaultReasons> =\n ReturnType<typeof createCloseMenuEvent<T>>;\n\n/**\n * Creates an event that requests the parent md-menu to deactivate all other\n * items.\n */\nexport function createDeactivateItemsEvent() {\n return new Event('deactivate-items', {bubbles: true, composed: true});\n}\n\n/**\n * The type of the event that requests the parent md-menu to deactivate all\n * other items.\n */\nexport type DeactivateItemsEvent =\n ReturnType<typeof createDeactivateItemsEvent>;\n\n\n/**\n * Creates an event that requests the typeahead functionality of containing menu\n * be deactivated.\n */\nexport function createDeactivateTypeaheadEvent() {\n return new Event('deactivate-typeahead', {bubbles: true, composed: true});\n}\n\n/**\n * The type of the event that requests the typeahead functionality of containing\n * menu be deactivated.\n */\nexport type DeactivateTypeaheadEvent =\n ReturnType<typeof createDeactivateTypeaheadEvent>;\n\n/**\n * Creates an event that requests the typeahead functionality of containing menu\n * be activated.\n */\nexport function createActivateTypeaheadEvent() {\n return new Event('activate-typeahead', {bubbles: true, composed: true});\n}\n\n/**\n * The type of the event that requests the typeahead functionality of containing\n * menu be activated.\n */\nexport type ActivateTypeaheadEvent =\n ReturnType<typeof createActivateTypeaheadEvent>;\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"]}
@@ -6,18 +6,17 @@
6
6
  import { Corner } from '../menu.js';
7
7
  import { MenuItemEl } from '../menuitem/menu-item.js';
8
8
  /**
9
- * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to
10
- * deselect other items when a submenu opens
11
- * @fires deactivate-typeahead {DeactivateItemsEvent} Requests the parent menu
12
- * to deactivate the typeahead functionality when a submenu opens
13
- * @fires activate-typeahead {DeactivateItemsEvent} Requests the parent menu to
14
- * activate the typeahead functionality when a submenu closes
15
- * @fires stay-open-on-focusout {StayOpenOnFocusoutEvent} Requests the parent
16
- * menu to stay open when focusout event is fired or has a `null`
17
- * `relatedTarget` when submenu is opened.
18
- * @fires close-on-focusout {CloseOnFocusoutEvent} Requests the parent
19
- * menu to close when focusout event is fired or has a `null`
20
- * `relatedTarget` When submenu is closed.
9
+ * @fires deactivate-items Requests the parent menu to deselect other items when
10
+ * a submenu opens
11
+ * @fires deactivate-typeahead Requests the parent menu to deactivate the
12
+ * typeahead functionality when a submenu opens
13
+ * @fires activate-typeahead Requests the parent menu to activate the typeahead
14
+ * functionality when a submenu closes
15
+ * @fires stay-open-on-focusout Requests the parent menu to stay open when
16
+ * focusout event is fired or has a `null` `relatedTarget` when submenu is
17
+ * opened.
18
+ * @fires close-on-focusout Requests the parent menu to close when focusout
19
+ * event is fired or has a `null` `relatedTarget` When submenu is closed.
21
20
  */
22
21
  export declare class SubMenuItem extends MenuItemEl {
23
22
  /**
@@ -40,6 +39,7 @@ export declare class SubMenuItem extends MenuItemEl {
40
39
  * Sets the item in the selected visual state when a submenu is opened.
41
40
  */
42
41
  selected: boolean;
42
+ protected submenuHover: boolean;
43
43
  private readonly menus;
44
44
  protected keepOpenOnClick: boolean;
45
45
  private previousOpenTimeout;
@@ -54,6 +54,14 @@ export declare class SubMenuItem extends MenuItemEl {
54
54
  */
55
55
  protected onPointerleave: () => void;
56
56
  protected onClick(): void;
57
+ protected getRenderClasses(): {
58
+ 'submenu-hover': boolean;
59
+ 'has-focus-ring': boolean;
60
+ 'with-one-line': boolean;
61
+ 'with-two-line': boolean;
62
+ 'with-three-line': boolean;
63
+ disabled: boolean;
64
+ };
57
65
  /**
58
66
  * On item keydown handles opening the submenu.
59
67
  */
@@ -96,4 +104,6 @@ export declare class SubMenuItem extends MenuItemEl {
96
104
  * @return Whether or not the key code should close the submenu.
97
105
  */
98
106
  private isSubmenuCloseKey;
107
+ private onSubmenuPointerEnter;
108
+ private onSubmenuPointerLeave;
99
109
  }
@@ -5,26 +5,25 @@
5
5
  */
6
6
  import { __decorate } from "tslib";
7
7
  import { html } from 'lit';
8
- import { property, queryAssignedElements } from 'lit/decorators.js';
8
+ import { property, queryAssignedElements, state } from 'lit/decorators.js';
9
9
  import { List } from '../../../list/internal/list.js';
10
10
  import { MenuItemEl } from '../menuitem/menu-item.js';
11
- import { ActivateTypeaheadEvent, CLOSE_REASON, CloseOnFocusoutEvent, DeactivateItemsEvent, DeactivateTypeaheadEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY, StayOpenOnFocusoutEvent } from '../shared.js';
11
+ import { CLOSE_REASON, createActivateTypeaheadEvent, createCloseOnFocusoutEvent, createDeactivateItemsEvent, createDeactivateTypeaheadEvent, createStayOpenOnFocusoutEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY } from '../shared.js';
12
12
  function stopPropagation(event) {
13
13
  event.stopPropagation();
14
14
  }
15
15
  /**
16
- * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to
17
- * deselect other items when a submenu opens
18
- * @fires deactivate-typeahead {DeactivateItemsEvent} Requests the parent menu
19
- * to deactivate the typeahead functionality when a submenu opens
20
- * @fires activate-typeahead {DeactivateItemsEvent} Requests the parent menu to
21
- * activate the typeahead functionality when a submenu closes
22
- * @fires stay-open-on-focusout {StayOpenOnFocusoutEvent} Requests the parent
23
- * menu to stay open when focusout event is fired or has a `null`
24
- * `relatedTarget` when submenu is opened.
25
- * @fires close-on-focusout {CloseOnFocusoutEvent} Requests the parent
26
- * menu to close when focusout event is fired or has a `null`
27
- * `relatedTarget` When submenu is closed.
16
+ * @fires deactivate-items Requests the parent menu to deselect other items when
17
+ * a submenu opens
18
+ * @fires deactivate-typeahead Requests the parent menu to deactivate the
19
+ * typeahead functionality when a submenu opens
20
+ * @fires activate-typeahead Requests the parent menu to activate the typeahead
21
+ * functionality when a submenu closes
22
+ * @fires stay-open-on-focusout Requests the parent menu to stay open when
23
+ * focusout event is fired or has a `null` `relatedTarget` when submenu is
24
+ * opened.
25
+ * @fires close-on-focusout Requests the parent menu to close when focusout
26
+ * event is fired or has a `null` `relatedTarget` When submenu is closed.
28
27
  */
29
28
  export class SubMenuItem extends MenuItemEl {
30
29
  constructor() {
@@ -49,6 +48,7 @@ export class SubMenuItem extends MenuItemEl {
49
48
  * Sets the item in the selected visual state when a submenu is opened.
50
49
  */
51
50
  this.selected = false;
51
+ this.submenuHover = false;
52
52
  this.keepOpenOnClick = true;
53
53
  this.previousOpenTimeout = 0;
54
54
  this.previousCloseTimeout = 0;
@@ -95,6 +95,9 @@ export class SubMenuItem extends MenuItemEl {
95
95
  onClick() {
96
96
  this.show();
97
97
  }
98
+ getRenderClasses() {
99
+ return { ...super.getRenderClasses(), 'submenu-hover': this.submenuHover };
100
+ }
98
101
  /**
99
102
  * On item keydown handles opening the submenu.
100
103
  */
@@ -132,6 +135,8 @@ export class SubMenuItem extends MenuItemEl {
132
135
  renderSubMenu() {
133
136
  return html `<span class="submenu"><slot
134
137
  name="submenu"
138
+ @pointerenter=${this.onSubmenuPointerEnter}
139
+ @pointerleave=${this.onSubmenuPointerLeave}
135
140
  @pointerdown=${stopPropagation}
136
141
  @click=${stopPropagation}
137
142
  @keydown=${this.onSubMenuKeydown}
@@ -139,14 +144,15 @@ export class SubMenuItem extends MenuItemEl {
139
144
  ></slot></span>`;
140
145
  }
141
146
  onCloseSubmenu(event) {
142
- event.itemPath.push(this);
147
+ const { itemPath, reason } = event.detail;
148
+ itemPath.push(this);
143
149
  // Restore focusout behavior
144
- this.dispatchEvent(new CloseOnFocusoutEvent());
145
- this.dispatchEvent(new ActivateTypeaheadEvent());
150
+ this.dispatchEvent(createCloseOnFocusoutEvent());
151
+ this.dispatchEvent(createActivateTypeaheadEvent());
146
152
  // Escape should only close one menu not all of the menus unlike space or
147
153
  // click selection which should close all menus.
148
- if (event.reason.kind === CLOSE_REASON.KEYDOWN &&
149
- event.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {
154
+ if (reason.kind === CLOSE_REASON.KEYDOWN &&
155
+ reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {
150
156
  event.stopPropagation();
151
157
  this.active = true;
152
158
  this.selected = false;
@@ -200,12 +206,12 @@ export class SubMenuItem extends MenuItemEl {
200
206
  // has a submenuitem hovered which opens a third submenut. Then if you hover
201
207
  // on yet another middle menu-item (not submenuitem) then focusout Event's
202
208
  // relatedTarget will be `null` thus, causing all the menus to close
203
- this.dispatchEvent(new StayOpenOnFocusoutEvent());
209
+ this.dispatchEvent(createStayOpenOnFocusoutEvent());
204
210
  menu.show();
205
211
  // Deactivate other items. This can be the case if the user has tabbed
206
212
  // around the menu and then mouses over an md-sub-menu.
207
- this.dispatchEvent(new DeactivateItemsEvent());
208
- this.dispatchEvent(new DeactivateTypeaheadEvent());
213
+ this.dispatchEvent(createDeactivateItemsEvent());
214
+ this.dispatchEvent(createDeactivateTypeaheadEvent());
209
215
  this.selected = true;
210
216
  // This is the case of mouse hovering when already opened via keyboard or
211
217
  // vice versa
@@ -225,11 +231,11 @@ export class SubMenuItem extends MenuItemEl {
225
231
  const menu = this.submenuEl;
226
232
  if (!menu || !menu.open)
227
233
  return;
228
- this.dispatchEvent(new ActivateTypeaheadEvent());
234
+ this.dispatchEvent(createActivateTypeaheadEvent());
229
235
  menu.quick = true;
230
236
  menu.close();
231
237
  // Restore focusout behavior.
232
- this.dispatchEvent(new CloseOnFocusoutEvent());
238
+ this.dispatchEvent(createCloseOnFocusoutEvent());
233
239
  this.active = false;
234
240
  this.selected = false;
235
241
  menu.addEventListener('closed', onClosed, { once: true });
@@ -271,6 +277,12 @@ export class SubMenuItem extends MenuItemEl {
271
277
  return false;
272
278
  }
273
279
  }
280
+ onSubmenuPointerEnter() {
281
+ this.submenuHover = true;
282
+ }
283
+ onSubmenuPointerLeave() {
284
+ this.submenuHover = false;
285
+ }
274
286
  }
275
287
  __decorate([
276
288
  property({ attribute: 'anchor-corner' })
@@ -287,6 +299,9 @@ __decorate([
287
299
  __decorate([
288
300
  property({ type: Boolean, reflect: true })
289
301
  ], SubMenuItem.prototype, "selected", void 0);
302
+ __decorate([
303
+ state()
304
+ ], SubMenuItem.prototype, "submenuHover", void 0);
290
305
  __decorate([
291
306
  queryAssignedElements({ slot: 'submenu', flatten: true })
292
307
  ], SubMenuItem.prototype, "menus", void 0);