@nldd/design-system 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/NOTICES.md +18 -1
  2. package/README.md +32 -24
  3. package/custom-elements.json +4390 -1037
  4. package/dist/components/actions/button/button.d.ts +6 -1
  5. package/dist/components/actions/button/button.d.ts.map +1 -1
  6. package/dist/components/actions/button/button.i18n.d.ts +1 -0
  7. package/dist/components/actions/button/button.i18n.d.ts.map +1 -1
  8. package/dist/components/actions/button/button.i18n.js +1 -0
  9. package/dist/components/actions/button/button.i18n.js.map +1 -1
  10. package/dist/components/actions/button/button.js +7 -0
  11. package/dist/components/actions/button/button.js.map +1 -1
  12. package/dist/components/actions/button/button.template.d.ts.map +1 -1
  13. package/dist/components/actions/button/button.template.js +5 -2
  14. package/dist/components/actions/button/button.template.js.map +1 -1
  15. package/dist/components/actions/button-group/button-group.d.ts +22 -7
  16. package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
  17. package/dist/components/actions/button-group/button-group.js +38 -19
  18. package/dist/components/actions/button-group/button-group.js.map +1 -1
  19. package/dist/components/actions/button-group/button-group.styles.d.ts.map +1 -1
  20. package/dist/components/actions/button-group/button-group.styles.js +43 -18
  21. package/dist/components/actions/button-group/button-group.styles.js.map +1 -1
  22. package/dist/components/actions/button-group/button-group.template.js +1 -1
  23. package/dist/components/actions/button-group/button-group.template.js.map +1 -1
  24. package/dist/components/actions/icon-button/icon-button.d.ts +8 -1
  25. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  26. package/dist/components/actions/icon-button/icon-button.i18n.d.ts +1 -0
  27. package/dist/components/actions/icon-button/icon-button.i18n.d.ts.map +1 -1
  28. package/dist/components/actions/icon-button/icon-button.i18n.js +1 -0
  29. package/dist/components/actions/icon-button/icon-button.i18n.js.map +1 -1
  30. package/dist/components/actions/icon-button/icon-button.js +9 -0
  31. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  32. package/dist/components/actions/icon-button/icon-button.template.d.ts.map +1 -1
  33. package/dist/components/actions/icon-button/icon-button.template.js +5 -2
  34. package/dist/components/actions/icon-button/icon-button.template.js.map +1 -1
  35. package/dist/components/actions/menu/menu-divider.d.ts +14 -0
  36. package/dist/components/actions/menu/menu-divider.d.ts.map +1 -0
  37. package/dist/components/actions/menu/menu-divider.js +33 -0
  38. package/dist/components/actions/menu/menu-divider.js.map +1 -0
  39. package/dist/components/actions/menu/menu-group.d.ts +35 -0
  40. package/dist/components/actions/menu/menu-group.d.ts.map +1 -0
  41. package/dist/components/actions/menu/menu-group.js +69 -0
  42. package/dist/components/actions/menu/menu-group.js.map +1 -0
  43. package/dist/components/actions/menu/menu-item.d.ts +86 -0
  44. package/dist/components/actions/menu/menu-item.d.ts.map +1 -0
  45. package/dist/components/actions/menu/menu-item.js +279 -0
  46. package/dist/components/actions/menu/menu-item.js.map +1 -0
  47. package/dist/components/actions/menu/menu.chain.d.ts +40 -0
  48. package/dist/components/actions/menu/menu.chain.d.ts.map +1 -0
  49. package/dist/components/actions/menu/menu.chain.js +150 -0
  50. package/dist/components/actions/menu/menu.chain.js.map +1 -0
  51. package/dist/components/actions/menu/menu.d.ts +68 -269
  52. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  53. package/dist/components/actions/menu/menu.js +147 -984
  54. package/dist/components/actions/menu/menu.js.map +1 -1
  55. package/dist/components/actions/menu/menu.pointer.d.ts +61 -0
  56. package/dist/components/actions/menu/menu.pointer.d.ts.map +1 -0
  57. package/dist/components/actions/menu/menu.pointer.js +143 -0
  58. package/dist/components/actions/menu/menu.pointer.js.map +1 -0
  59. package/dist/components/actions/menu/menu.safe-triangle.d.ts +79 -0
  60. package/dist/components/actions/menu/menu.safe-triangle.d.ts.map +1 -0
  61. package/dist/components/actions/menu/menu.safe-triangle.js +198 -0
  62. package/dist/components/actions/menu/menu.safe-triangle.js.map +1 -0
  63. package/dist/components/actions/menu/menu.template.d.ts.map +1 -1
  64. package/dist/components/actions/menu/menu.template.js +5 -4
  65. package/dist/components/actions/menu/menu.template.js.map +1 -1
  66. package/dist/components/actions/toolbar/toolbar-item.d.ts +46 -0
  67. package/dist/components/actions/toolbar/toolbar-item.d.ts.map +1 -0
  68. package/dist/components/actions/toolbar/toolbar-item.js +113 -0
  69. package/dist/components/actions/toolbar/toolbar-item.js.map +1 -0
  70. package/dist/components/actions/toolbar/toolbar-item.template.d.ts +3 -0
  71. package/dist/components/actions/toolbar/toolbar-item.template.d.ts.map +1 -0
  72. package/dist/components/actions/toolbar/toolbar-item.template.js +12 -0
  73. package/dist/components/actions/toolbar/toolbar-item.template.js.map +1 -0
  74. package/dist/components/actions/toolbar/toolbar-title.d.ts +43 -0
  75. package/dist/components/actions/toolbar/toolbar-title.d.ts.map +1 -0
  76. package/dist/components/actions/toolbar/toolbar-title.js +111 -0
  77. package/dist/components/actions/toolbar/toolbar-title.js.map +1 -0
  78. package/dist/components/actions/toolbar/toolbar-title.template.d.ts +3 -0
  79. package/dist/components/actions/toolbar/toolbar-title.template.d.ts.map +1 -0
  80. package/dist/components/actions/toolbar/toolbar-title.template.js +33 -0
  81. package/dist/components/actions/toolbar/toolbar-title.template.js.map +1 -0
  82. package/dist/components/actions/toolbar/toolbar.d.ts +16 -111
  83. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  84. package/dist/components/actions/toolbar/toolbar.js +50 -423
  85. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  86. package/dist/components/actions/toolbar/toolbar.layout.d.ts +40 -0
  87. package/dist/components/actions/toolbar/toolbar.layout.d.ts.map +1 -0
  88. package/dist/components/actions/toolbar/toolbar.layout.js +76 -0
  89. package/dist/components/actions/toolbar/toolbar.layout.js.map +1 -0
  90. package/dist/components/actions/toolbar/toolbar.overflow-menu.d.ts +52 -0
  91. package/dist/components/actions/toolbar/toolbar.overflow-menu.d.ts.map +1 -0
  92. package/dist/components/actions/toolbar/toolbar.overflow-menu.js +105 -0
  93. package/dist/components/actions/toolbar/toolbar.overflow-menu.js.map +1 -0
  94. package/dist/components/actions/toolbar/toolbar.template.d.ts +1 -4
  95. package/dist/components/actions/toolbar/toolbar.template.d.ts.map +1 -1
  96. package/dist/components/actions/toolbar/toolbar.template.js +0 -41
  97. package/dist/components/actions/toolbar/toolbar.template.js.map +1 -1
  98. package/dist/components/{breakpoints-Bpf2MgjM.js → breakpoints-Bti55RWY.js} +1 -2
  99. package/dist/components/components.js +4651 -2302
  100. package/dist/components/content/avatar-group/avatar-group.styles.d.ts.map +1 -1
  101. package/dist/components/content/avatar-group/avatar-group.styles.js +12 -1
  102. package/dist/components/content/avatar-group/avatar-group.styles.js.map +1 -1
  103. package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
  104. package/dist/components/content/code-viewer/code-viewer.styles.js +2 -1
  105. package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
  106. package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
  107. package/dist/components/content/icon/icon-aliases.js +21 -5
  108. package/dist/components/content/icon/icon-aliases.js.map +1 -1
  109. package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
  110. package/dist/components/content/icon/icon-gallery-status.js +10 -0
  111. package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
  112. package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
  113. package/dist/components/content/icon/icon-registry.js +10 -3
  114. package/dist/components/content/icon/icon-registry.js.map +1 -1
  115. package/dist/components/content/text/text.d.ts +1 -1
  116. package/dist/components/content/text/text.js +1 -1
  117. package/dist/components/content/text/text.styles.d.ts.map +1 -1
  118. package/dist/components/content/text/text.styles.js +104 -1
  119. package/dist/components/content/text/text.styles.js.map +1 -1
  120. package/dist/components/content/token/token.styles.d.ts.map +1 -1
  121. package/dist/components/content/token/token.styles.js +2 -1
  122. package/dist/components/content/token/token.styles.js.map +1 -1
  123. package/dist/components/content/tooltip/tooltip.styles.js +7 -7
  124. package/dist/components/{decorate-CO88j7Lc.js → decorate-Cz9-peTN.js} +1 -2
  125. package/dist/components/{dist-B5E3q-ea.js → dist-B9YBOGFW.js} +4 -6
  126. package/dist/components/{dist-BWlUmyq3.js → dist-BFZM0YsR.js} +57 -36
  127. package/dist/components/{dist-BFw_yEMS.js → dist-BNkeFjc3.js} +5 -7
  128. package/dist/components/{dist-Co-tsc9S.js → dist-BaLc58I_.js} +7 -9
  129. package/dist/components/{dist-BOVSVPSz.js → dist-Bm3708s5.js} +3 -4
  130. package/dist/components/{dist-IPm8ilWf.js → dist-CJ9uLG0u.js} +5 -17
  131. package/dist/components/{dist-Dz28se9B.js → dist-CJm4tkNC.js} +4 -6
  132. package/dist/components/{dist-CC8oiVtm.js → dist-CSC1dG3L.js} +2 -3
  133. package/dist/components/{dist-BPB3rWnd.js → dist-DHhnz3Gv.js} +3 -4
  134. package/dist/components/{dist-Dn9pjiud.js → dist-DgjvHvsN.js} +6 -8
  135. package/dist/components/{dist-COKR0tYU.js → dist-PeUX4vPq.js} +3 -6
  136. package/dist/components/{dist-D_9ZyZ5v.js → dist-YYLChwRq.js} +5 -7
  137. package/dist/components/{dist-BNLAXAyO.js → dist-m70B83qb.js} +4 -6
  138. package/dist/components/forms/form-field/form-field.d.ts +9 -5
  139. package/dist/components/forms/form-field/form-field.d.ts.map +1 -1
  140. package/dist/components/forms/form-field/form-field.js +17 -6
  141. package/dist/components/forms/form-field/form-field.js.map +1 -1
  142. package/dist/components/{gherkin-uCVRxsGf.js → gherkin-DzYbEwDO.js} +1 -2
  143. package/dist/components/{icon-BJHKWhY5.js → icon-DRpTWSIg.js} +33 -20
  144. package/dist/components/{icon-button-DhBIq6lN.js → icon-button-DUEmWlBD.js} +41 -51
  145. package/dist/components/index.d.ts +2 -0
  146. package/dist/components/index.d.ts.map +1 -1
  147. package/dist/components/index.js +2 -0
  148. package/dist/components/index.js.map +1 -1
  149. package/dist/components/{input-modality-DhTeUxKi.js → input-modality-CiPLYYMN.js} +1 -2
  150. package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
  151. package/dist/components/inputs/code-editor/code-editor.styles.js +6 -1
  152. package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
  153. package/dist/components/inputs/combo-box/combo-box.styles.d.ts.map +1 -1
  154. package/dist/components/inputs/combo-box/combo-box.styles.js +1 -0
  155. package/dist/components/inputs/combo-box/combo-box.styles.js.map +1 -1
  156. package/dist/components/inputs/date-field/date-field.d.ts +41 -28
  157. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
  158. package/dist/components/inputs/date-field/date-field.dates.d.ts +60 -0
  159. package/dist/components/inputs/date-field/date-field.dates.d.ts.map +1 -0
  160. package/dist/components/inputs/date-field/date-field.dates.js +106 -0
  161. package/dist/components/inputs/date-field/date-field.dates.js.map +1 -0
  162. package/dist/components/inputs/date-field/date-field.i18n.d.ts +4 -0
  163. package/dist/components/inputs/date-field/date-field.i18n.d.ts.map +1 -1
  164. package/dist/components/inputs/date-field/date-field.i18n.js +6 -0
  165. package/dist/components/inputs/date-field/date-field.i18n.js.map +1 -1
  166. package/dist/components/inputs/date-field/date-field.js +110 -142
  167. package/dist/components/inputs/date-field/date-field.js.map +1 -1
  168. package/dist/components/inputs/date-field/date-field.styles.d.ts.map +1 -1
  169. package/dist/components/inputs/date-field/date-field.styles.js +1 -0
  170. package/dist/components/inputs/date-field/date-field.styles.js.map +1 -1
  171. package/dist/components/inputs/date-field/date-field.template.d.ts.map +1 -1
  172. package/dist/components/inputs/date-field/date-field.template.js +21 -17
  173. package/dist/components/inputs/date-field/date-field.template.js.map +1 -1
  174. package/dist/components/inputs/file-field/file-field.d.ts +12 -0
  175. package/dist/components/inputs/file-field/file-field.d.ts.map +1 -1
  176. package/dist/components/inputs/file-field/file-field.i18n.d.ts +1 -0
  177. package/dist/components/inputs/file-field/file-field.i18n.d.ts.map +1 -1
  178. package/dist/components/inputs/file-field/file-field.i18n.js +1 -0
  179. package/dist/components/inputs/file-field/file-field.i18n.js.map +1 -1
  180. package/dist/components/inputs/file-field/file-field.js +28 -9
  181. package/dist/components/inputs/file-field/file-field.js.map +1 -1
  182. package/dist/components/inputs/file-field/file-field.styles.d.ts.map +1 -1
  183. package/dist/components/inputs/file-field/file-field.styles.js +91 -8
  184. package/dist/components/inputs/file-field/file-field.styles.js.map +1 -1
  185. package/dist/components/inputs/file-field/file-field.template.d.ts +1 -0
  186. package/dist/components/inputs/file-field/file-field.template.d.ts.map +1 -1
  187. package/dist/components/inputs/file-field/file-field.template.js +51 -21
  188. package/dist/components/inputs/file-field/file-field.template.js.map +1 -1
  189. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.d.ts.map +1 -1
  190. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.js +1 -0
  191. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.js.map +1 -1
  192. package/dist/components/inputs/password-field/password-field.styles.d.ts.map +1 -1
  193. package/dist/components/inputs/password-field/password-field.styles.js +1 -0
  194. package/dist/components/inputs/password-field/password-field.styles.js.map +1 -1
  195. package/dist/components/inputs/search-field/search-field.d.ts +1 -1
  196. package/dist/components/inputs/search-field/search-field.js +1 -1
  197. package/dist/components/inputs/search-field/search-field.styles.d.ts.map +1 -1
  198. package/dist/components/inputs/search-field/search-field.styles.js +1 -0
  199. package/dist/components/inputs/search-field/search-field.styles.js.map +1 -1
  200. package/dist/components/inputs/segmented-control/segmented-control.d.ts +6 -3
  201. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  202. package/dist/components/inputs/segmented-control/segmented-control.js +8 -10
  203. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  204. package/dist/components/inputs/slider/slider.d.ts +161 -0
  205. package/dist/components/inputs/slider/slider.d.ts.map +1 -0
  206. package/dist/components/inputs/slider/slider.i18n.d.ts +6 -0
  207. package/dist/components/inputs/slider/slider.i18n.d.ts.map +1 -0
  208. package/dist/components/inputs/slider/slider.i18n.js +5 -0
  209. package/dist/components/inputs/slider/slider.i18n.js.map +1 -0
  210. package/dist/components/inputs/slider/slider.js +436 -0
  211. package/dist/components/inputs/slider/slider.js.map +1 -0
  212. package/dist/components/inputs/slider/slider.styles.d.ts +2 -0
  213. package/dist/components/inputs/slider/slider.styles.d.ts.map +1 -0
  214. package/dist/components/inputs/slider/slider.styles.js +360 -0
  215. package/dist/components/inputs/slider/slider.styles.js.map +1 -0
  216. package/dist/components/inputs/slider/slider.template.d.ts +5 -0
  217. package/dist/components/inputs/slider/slider.template.d.ts.map +1 -0
  218. package/dist/components/inputs/slider/slider.template.js +99 -0
  219. package/dist/components/inputs/slider/slider.template.js.map +1 -0
  220. package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -1
  221. package/dist/components/inputs/text-editor/text-editor.selection.js +35 -9
  222. package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -1
  223. package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
  224. package/dist/components/inputs/text-editor/text-editor.styles.js +17 -0
  225. package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
  226. package/dist/components/inputs/text-editor/text-editor.tasks.d.ts.map +1 -1
  227. package/dist/components/inputs/text-editor/text-editor.tasks.js +5 -1
  228. package/dist/components/inputs/text-editor/text-editor.tasks.js.map +1 -1
  229. package/dist/components/inputs/text-field/text-field.styles.d.ts.map +1 -1
  230. package/dist/components/inputs/text-field/text-field.styles.js +1 -0
  231. package/dist/components/inputs/text-field/text-field.styles.js.map +1 -1
  232. package/dist/components/inputs/time-field/time-field.d.ts +26 -40
  233. package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
  234. package/dist/components/inputs/time-field/time-field.i18n.d.ts +3 -0
  235. package/dist/components/inputs/time-field/time-field.i18n.d.ts.map +1 -1
  236. package/dist/components/inputs/time-field/time-field.i18n.js +5 -0
  237. package/dist/components/inputs/time-field/time-field.i18n.js.map +1 -1
  238. package/dist/components/inputs/time-field/time-field.js +68 -162
  239. package/dist/components/inputs/time-field/time-field.js.map +1 -1
  240. package/dist/components/inputs/time-field/time-field.styles.d.ts.map +1 -1
  241. package/dist/components/inputs/time-field/time-field.styles.js +1 -0
  242. package/dist/components/inputs/time-field/time-field.styles.js.map +1 -1
  243. package/dist/components/inputs/time-field/time-field.times.d.ts +74 -0
  244. package/dist/components/inputs/time-field/time-field.times.d.ts.map +1 -0
  245. package/dist/components/inputs/time-field/time-field.times.js +154 -0
  246. package/dist/components/inputs/time-field/time-field.times.js.map +1 -0
  247. package/dist/components/layout/card/card.d.ts +6 -1
  248. package/dist/components/layout/card/card.d.ts.map +1 -1
  249. package/dist/components/layout/card/card.i18n.d.ts +1 -0
  250. package/dist/components/layout/card/card.i18n.d.ts.map +1 -1
  251. package/dist/components/layout/card/card.i18n.js +1 -0
  252. package/dist/components/layout/card/card.i18n.js.map +1 -1
  253. package/dist/components/layout/card/card.js +7 -0
  254. package/dist/components/layout/card/card.js.map +1 -1
  255. package/dist/components/layout/card/card.template.d.ts.map +1 -1
  256. package/dist/components/layout/card/card.template.js +5 -2
  257. package/dist/components/layout/card/card.template.js.map +1 -1
  258. package/dist/components/layout/page/page.d.ts +3 -0
  259. package/dist/components/layout/page/page.d.ts.map +1 -1
  260. package/dist/components/layout/page/page.js +20 -3
  261. package/dist/components/layout/page/page.js.map +1 -1
  262. package/dist/components/layout/page/page.styles.d.ts.map +1 -1
  263. package/dist/components/layout/page/page.styles.js +25 -2
  264. package/dist/components/layout/page/page.styles.js.map +1 -1
  265. package/dist/components/layout/page/page.template.js +1 -1
  266. package/dist/components/layout/page/page.template.js.map +1 -1
  267. package/dist/components/layout/sheet/sheet.d.ts +5 -0
  268. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  269. package/dist/components/layout/sheet/sheet.js +14 -6
  270. package/dist/components/layout/sheet/sheet.js.map +1 -1
  271. package/dist/components/layout/sheet/sheet.template.d.ts.map +1 -1
  272. package/dist/components/layout/sheet/sheet.template.js +1 -0
  273. package/dist/components/layout/sheet/sheet.template.js.map +1 -1
  274. package/dist/components/layout/task-board/task-board-column.d.ts +80 -0
  275. package/dist/components/layout/task-board/task-board-column.d.ts.map +1 -0
  276. package/dist/components/layout/task-board/task-board-column.js +207 -0
  277. package/dist/components/layout/task-board/task-board-column.js.map +1 -0
  278. package/dist/components/layout/task-board/task-board-column.template.d.ts +3 -0
  279. package/dist/components/layout/task-board/task-board-column.template.d.ts.map +1 -0
  280. package/dist/components/layout/task-board/task-board-column.template.js +45 -0
  281. package/dist/components/layout/task-board/task-board-column.template.js.map +1 -0
  282. package/dist/components/layout/task-board/task-board.d.ts +169 -0
  283. package/dist/components/layout/task-board/task-board.d.ts.map +1 -0
  284. package/dist/components/layout/task-board/task-board.i18n.d.ts +11 -0
  285. package/dist/components/layout/task-board/task-board.i18n.d.ts.map +1 -0
  286. package/dist/components/layout/task-board/task-board.i18n.js +10 -0
  287. package/dist/components/layout/task-board/task-board.i18n.js.map +1 -0
  288. package/dist/components/layout/task-board/task-board.js +701 -0
  289. package/dist/components/layout/task-board/task-board.js.map +1 -0
  290. package/dist/components/layout/task-board/task-board.styles.d.ts +3 -0
  291. package/dist/components/layout/task-board/task-board.styles.d.ts.map +1 -0
  292. package/dist/components/layout/task-board/task-board.styles.js +259 -0
  293. package/dist/components/layout/task-board/task-board.styles.js.map +1 -0
  294. package/dist/components/layout/task-board/task-board.template.d.ts +3 -0
  295. package/dist/components/layout/task-board/task-board.template.d.ts.map +1 -0
  296. package/dist/components/layout/task-board/task-board.template.js +25 -0
  297. package/dist/components/layout/task-board/task-board.template.js.map +1 -0
  298. package/dist/components/lists-and-tables/list-item/list-item.d.ts +6 -1
  299. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  300. package/dist/components/lists-and-tables/list-item/list-item.i18n.d.ts +1 -0
  301. package/dist/components/lists-and-tables/list-item/list-item.i18n.d.ts.map +1 -1
  302. package/dist/components/lists-and-tables/list-item/list-item.i18n.js +1 -0
  303. package/dist/components/lists-and-tables/list-item/list-item.i18n.js.map +1 -1
  304. package/dist/components/lists-and-tables/list-item/list-item.js +12 -3
  305. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  306. package/dist/components/lists-and-tables/list-item/list-item.template.d.ts +1 -1
  307. package/dist/components/lists-and-tables/list-item/list-item.template.d.ts.map +1 -1
  308. package/dist/components/lists-and-tables/list-item/list-item.template.js +2 -1
  309. package/dist/components/lists-and-tables/list-item/list-item.template.js.map +1 -1
  310. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts +6 -1
  311. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts.map +1 -1
  312. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.d.ts +1 -0
  313. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.d.ts.map +1 -1
  314. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.js +1 -0
  315. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.js.map +1 -1
  316. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js +12 -3
  317. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js.map +1 -1
  318. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.d.ts +1 -1
  319. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.d.ts.map +1 -1
  320. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.js +2 -1
  321. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.js.map +1 -1
  322. package/dist/components/navigation/link/link.d.ts +11 -1
  323. package/dist/components/navigation/link/link.d.ts.map +1 -1
  324. package/dist/components/navigation/link/link.i18n.d.ts +1 -0
  325. package/dist/components/navigation/link/link.i18n.d.ts.map +1 -1
  326. package/dist/components/navigation/link/link.i18n.js +1 -0
  327. package/dist/components/navigation/link/link.i18n.js.map +1 -1
  328. package/dist/components/navigation/link/link.js +27 -1
  329. package/dist/components/navigation/link/link.js.map +1 -1
  330. package/dist/components/navigation/link/link.template.d.ts +1 -0
  331. package/dist/components/navigation/link/link.template.d.ts.map +1 -1
  332. package/dist/components/navigation/link/link.template.js +21 -16
  333. package/dist/components/navigation/link/link.template.js.map +1 -1
  334. package/dist/components/navigation/tab-bar/tab-bar.d.ts +1 -0
  335. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  336. package/dist/components/navigation/tab-bar/tab-bar.js +9 -0
  337. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  338. package/dist/components/navigation/tab-bar/tab-bar.template.js +1 -1
  339. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +9 -24
  340. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
  341. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +29 -223
  342. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  343. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.d.ts +48 -0
  344. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.d.ts.map +1 -0
  345. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js +220 -0
  346. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js.map +1 -0
  347. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.d.ts.map +1 -1
  348. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js +22 -2
  349. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js.map +1 -1
  350. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.template.d.ts.map +1 -1
  351. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.template.js +4 -0
  352. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.template.js.map +1 -1
  353. package/dist/components/{reflect-non-default-OLaK60rT.js → reflect-non-default-B9wQcnne.js} +1 -2
  354. package/dist/components/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
  355. package/dist/components/{shadow-resets-CPa58rmc.js → shadow-resets-BwOyyZFH.js} +1 -2
  356. package/dist/components/{shell-C61GCsJA.js → shell-Dh5IwHd-.js} +1 -2
  357. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts +10 -1
  358. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts.map +1 -1
  359. package/dist/components/status-and-feedback/step-bar/step-bar.js +22 -1
  360. package/dist/components/status-and-feedback/step-bar/step-bar.js.map +1 -1
  361. package/dist/components/status-and-feedback/step-bar/step-bar.template.d.ts.map +1 -1
  362. package/dist/components/status-and-feedback/step-bar/step-bar.template.js +2 -0
  363. package/dist/components/status-and-feedback/step-bar/step-bar.template.js.map +1 -1
  364. package/dist/components/{toml-C2HBbPgG.js → toml-D0Pix_8Q.js} +1 -2
  365. package/dist/components/{visibility-mixin-djNSG5ZN.js → visibility-mixin-C-K7ho5Q.js} +4 -6
  366. package/dist/components/{with-translations-C6QfP6_S.js → with-translations-DRuOq3QK.js} +14 -10
  367. package/dist/css/{global-system-font.css → global-open-font.css} +2 -0
  368. package/dist/css/global.css +1 -0
  369. package/dist/css/inter-font.css +47 -0
  370. package/dist/css/jetbrains-mono-font.css +22 -0
  371. package/dist/css/rijksoverheid-fonts.css +4 -21
  372. package/dist/css/themes/bruin.css +1 -0
  373. package/dist/css/themes/donkerblauw.css +1 -0
  374. package/dist/css/themes/donkerbruin.css +1 -0
  375. package/dist/css/themes/donkergeel.css +1 -0
  376. package/dist/css/themes/donkergroen.css +1 -0
  377. package/dist/css/themes/geel.css +1 -0
  378. package/dist/css/themes/groen.css +1 -0
  379. package/dist/css/themes/hemelblauw.css +1 -0
  380. package/dist/css/themes/lichtblauw.css +1 -0
  381. package/dist/css/themes/mintgroen.css +1 -0
  382. package/dist/css/themes/mosgroen.css +1 -0
  383. package/dist/css/themes/oranje.css +1 -0
  384. package/dist/css/themes/paars.css +1 -0
  385. package/dist/css/themes/robijnrood.css +1 -0
  386. package/dist/css/themes/rood.css +1 -0
  387. package/dist/css/themes/roze.css +1 -0
  388. package/dist/css/themes/violet.css +1 -0
  389. package/dist/css/themes.css +17 -0
  390. package/dist/css/tokens.css +1 -0
  391. package/dist/css/variables.css +27 -5
  392. package/dist/fonts/Inter-Latin-Italic[wght].woff2 +0 -0
  393. package/dist/fonts/Inter-LatinExt-Italic[wght].woff2 +0 -0
  394. package/dist/fonts/Inter-LatinExt[wght].woff2 +0 -0
  395. package/dist/fonts/Inter-Latin[wght].woff2 +0 -0
  396. package/dist/nldd.min.js +1902 -842
  397. package/dist/translations/en-US.d.ts.map +1 -1
  398. package/dist/translations/en-US.js +23 -0
  399. package/dist/translations/en-US.js.map +1 -1
  400. package/dist/translations/fy.d.ts.map +1 -1
  401. package/dist/translations/fy.js +13 -0
  402. package/dist/translations/fy.js.map +1 -1
  403. package/dist/translations/nl.generated.d.ts +23 -0
  404. package/dist/translations/nl.generated.d.ts.map +1 -1
  405. package/dist/translations/nl.generated.js +4 -0
  406. package/dist/translations/nl.generated.js.map +1 -1
  407. package/dist/translations/pap-AW.d.ts.map +1 -1
  408. package/dist/translations/pap-AW.js +13 -0
  409. package/dist/translations/pap-AW.js.map +1 -1
  410. package/dist/translations/pap-CW.d.ts.map +1 -1
  411. package/dist/translations/pap-CW.js +13 -0
  412. package/dist/translations/pap-CW.js.map +1 -1
  413. package/dist/types/vue.d.ts +164 -24
  414. package/dist/utilities/form-associated-mixin.d.ts +7 -0
  415. package/dist/utilities/form-associated-mixin.d.ts.map +1 -1
  416. package/dist/utilities/form-associated-mixin.js +13 -1
  417. package/dist/utilities/form-associated-mixin.js.map +1 -1
  418. package/dist/utilities/link-hint.d.ts +11 -0
  419. package/dist/utilities/link-hint.d.ts.map +1 -1
  420. package/dist/utilities/link-hint.js +15 -0
  421. package/dist/utilities/link-hint.js.map +1 -1
  422. package/dist/utilities/tab-order.d.ts +11 -0
  423. package/dist/utilities/tab-order.d.ts.map +1 -0
  424. package/dist/utilities/tab-order.js +55 -0
  425. package/dist/utilities/tab-order.js.map +1 -0
  426. package/package.json +13 -4
@@ -8,8 +8,8 @@ import { LitElement } from 'lit';
8
8
  import { property, state } from 'lit/decorators.js';
9
9
  import { computePosition, flip, shift, offset, size, autoUpdate } from '@floating-ui/dom';
10
10
  import { reflectNonDefault } from '../../../utilities/reflect-non-default.js';
11
- import { menuStyles, menuItemStyles, menuDividerStyles, menuGroupStyles } from './menu.styles.js';
12
- import { menuTemplate, menuItemTemplate, menuDividerTemplate, menuGroupTemplate } from './menu.template.js';
11
+ import { menuStyles } from './menu.styles.js';
12
+ import { menuTemplate } from './menu.template.js';
13
13
  import { nlddMenuTranslations } from './menu.i18n.js';
14
14
  import '../../lists-and-tables/cells/icon-cell/icon-cell.js';
15
15
  import '../../lists-and-tables/cells/spacer-cell/spacer-cell.js';
@@ -20,355 +20,13 @@ import '../../status-and-feedback/inline-dialog/inline-dialog.js';
20
20
  import { isKeyboardMode, isTouchMode } from '../../../utilities/input-modality.js';
21
21
  import { queryBreakpoints } from '../../../assets/styles/breakpoints.js';
22
22
  import { translate } from '../../../utilities/translations.js';
23
- import { carryContext, releaseContext } from '../../../utilities/carried-context.js';
24
- /** Makes `host` a list item while its menu is a navigation menu, and takes
25
- * that back when it is not. A `listitem` the consumer set by hand on an item
26
- * goes too when the variant changes back; nothing else uses that role here. */
27
- function syncListItemRole(host, variant) {
28
- if (variant === 'navigation')
29
- host.setAttribute('role', 'listitem');
30
- else if (host.getAttribute('role') === 'listitem')
31
- host.removeAttribute('role');
32
- }
33
- // # nldd-menu-divider
34
- /**
35
- * A horizontal rule between groups of items in an `nldd-menu`.
36
- *
37
- * @element nldd-menu-divider
38
- */
39
- export class NLDDMenuDivider extends LitElement {
40
- constructor() {
41
- super(...arguments);
42
- /** @internal The variant of the menu around it, set by that nldd-menu. */
43
- this.menuVariant = null;
44
- }
45
- render() {
46
- return menuDividerTemplate(this.menuVariant);
47
- }
48
- }
49
- NLDDMenuDivider.styles = menuDividerStyles;
50
- __decorate([
51
- state()
52
- ], NLDDMenuDivider.prototype, "menuVariant", void 0);
53
- if (!customElements.get('nldd-menu-divider')) {
54
- customElements.define('nldd-menu-divider', NLDDMenuDivider);
55
- }
56
- // # nldd-menu-group
57
- /**
58
- * A labeled group of menu items inside an nldd-menu. Wraps its slotted
59
- * items in `role="group"` with `aria-labelledby` pointing to the group's
60
- * `text`, providing native ARIA group semantics that a flat title element
61
- * can't deliver.
62
- *
63
- * The group renders an automatic divider above itself, except when it's
64
- * the first child of the menu — so consumers don't need to manage
65
- * separator placement around groups themselves. Spacing above the title
66
- * is intentionally larger than below, to bind the title visually to the
67
- * items it labels.
68
- *
69
- * Use the wrapper for grouping with a title; for ungrouped flat menus or
70
- * a divider without a title, the existing `nldd-menu-item` +
71
- * `nldd-menu-divider` flat structure keeps working unchanged.
72
- *
73
- * @element nldd-menu-group
74
- *
75
- * @attr {string} text - Group title text shown above the items.
76
- *
77
- * @slot - nldd-menu-item children (the items belonging to this group).
78
- */
79
- export class NLDDMenuGroup extends LitElement {
80
- constructor() {
81
- super(...arguments);
82
- this.text = '';
83
- this._titleId = `nldd-menu-group-title-${NLDDMenuGroup._idCounter++}`;
84
- /** @internal The variant of the menu around it, set by that nldd-menu. */
85
- this.menuVariant = null;
86
- }
87
- updated(changed) {
88
- // In a navigation menu the group is a list item that holds a list of
89
- // its own, named by the title: a list may only own list items.
90
- if (changed.has('menuVariant'))
91
- syncListItemRole(this, this.menuVariant);
92
- }
93
- render() {
94
- return menuGroupTemplate(this);
95
- }
96
- }
97
- NLDDMenuGroup.styles = menuGroupStyles;
98
- // SSR caveat: this counter is per module instance, not per render. If
99
- // the component ever runs in a context where modules reload between
100
- // server and client (SSR hydration, Vite HMR with fresh module state),
101
- // IDs will mismatch and aria-labelledby refs will break. Browser-only
102
- // today; revisit if hydration is added.
103
- NLDDMenuGroup._idCounter = 0;
104
- __decorate([
105
- property({ reflect: true, converter: reflectNonDefault('') })
106
- ], NLDDMenuGroup.prototype, "text", void 0);
107
- __decorate([
108
- state()
109
- ], NLDDMenuGroup.prototype, "menuVariant", void 0);
110
- if (!customElements.get('nldd-menu-group')) {
111
- customElements.define('nldd-menu-group', NLDDMenuGroup);
112
- }
113
- // # nldd-menu-item
114
- /**
115
- * A single item within an nldd-menu.
116
- *
117
- * @element nldd-menu-item
118
- *
119
- * @attr {boolean} destructive - Marks the item as destructive (red text; red highlight bg). Use for irreversible actions like "Delete". Color is the only built-in signal, so per WCAG 1.4.1 the item's own label must convey the destructive nature (e.g. "Verwijder") — don't rely on the red alone. Confirming the action (e.g. a follow-up dialog) is the consumer's responsibility.
120
- * @attr {string} text - Display text. Supports **bold** markdown syntax.
121
- * @attr {string} details - Secondary label shown on the right side.
122
- * @attr {string} icon - Icon name rendered before the text.
123
- * @attr {string} shortcut - Keyboard shortcut hint shown on the right, e.g. 'Cmd+E'. Display only (rendered via nldd-keyboard-shortcut) — it does not bind the key; wire up the handling in your app. Hidden on touch-only devices, where it isn't invokable.
124
- * @attr {string} shortcut-mac / shortcut-windows / shortcut-linux - Per-OS overrides for `shortcut`, picked by detected OS (falls back to `shortcut`).
125
- * @attr {string} href - Optional link target. A plain button item with an href renders as an `<a>` so it is a real link (middle-click, open in new tab, copy link). Ignored for submenu openers, checkbox/radio items, and while disabled.
126
- * @attr {string} type - Item type: 'button' | 'checkbox' | 'radio'. Default: 'button'. One checkbox or radio item gives every item in its menu the check-mark column, so the text of the whole menu starts at one line, as in a native menu. Submenus decide for themselves.
127
- * @attr {boolean} selected - Selected state for checkbox and radio types.
128
- * @attr {boolean} disabled - Disabled state.
129
- * @attr {string} value - A value of the item's own, read off the item in a `select` handler. The default filter matches on it as well as on `text` and `aliases`. Not a form value: this component is not form-associated.
130
- * @attr {string} aliases - Space-separated alternative search terms.
131
- * @attr {string} query - Query substring to bold-highlight in text. Set by menu's filter(); also settable by consumers.
132
- * @attr {string} query-mark-mode - 'match' | 'predictive' (default: 'predictive'). See text-cell for details.
133
- *
134
- * @fires select - Fired when the item is clicked and not disabled.
135
- */
136
- export class NLDDMenuItem extends LitElement {
137
- constructor() {
138
- super(...arguments);
139
- this.destructive = false;
140
- this.text = '';
141
- this.details = '';
142
- this.icon = '';
143
- this.shortcut = '';
144
- this.shortcutMac = '';
145
- this.shortcutWindows = '';
146
- this.shortcutLinux = '';
147
- this.href = '';
148
- this.type = 'button';
149
- this.selected = false;
150
- this.disabled = false;
151
- this.value = '';
152
- this.aliases = '';
153
- this.query = '';
154
- this.queryMarkMode = 'predictive';
155
- /**
156
- * Which menu owns this item, set by that nldd-menu. Not part of the public API.
157
- *
158
- * `null` until one claims it, and an unclaimed item carries no menu role.
159
- * A menu role is a promise about what is around you, so an item cannot make
160
- * it on its own. `nldd-toolbar-item` holds exactly such an item: the
161
- * declaration of what belongs in the overflow menu, which the toolbar clones
162
- * into the real menu when it collapses. The clone is claimed there and the
163
- * declaration stays what it is.
164
- */
165
- this.menuVariant = null;
166
- /** Whether this item keeps the check-mark column free without being
167
- * checkable, because another item in its menu is. Set by that nldd-menu.
168
- * Not part of the public API. */
169
- this.checkColumn = false;
170
- /** Tracks whether this item's submenu (if any) is currently open. Set by
171
- * the parent nldd-menu via the `submenu-open`/`submenu-close` lifecycle. */
172
- this._submenuOpen = false;
173
- /** Cached reference to the direct child `<nldd-menu>` (this item's
174
- * submenu). Resolved once at firstUpdated; mutating the children after
175
- * mount is not supported in v1. */
176
- this._cachedSubmenuEl = null;
177
- this._submenuMutationObserver = null;
178
- }
179
- connectedCallback() {
180
- super.connectedCallback();
181
- if (!this.id) {
182
- this.id = `nldd-menu-item-${NLDDMenuItem._idCounter++}`;
183
- }
184
- this.addEventListener('focusin', (e) => {
185
- // Only react when focus actually lands on our own shadow content
186
- // (the .menu__item button). focusin is composed and bubbles, so it
187
- // also fires here when focus moves into a slotted descendant —
188
- // notably when a child submenu's .menu element gets focused on
189
- // open. Without this guard the parent's _handleMenuItemFocused
190
- // re-highlights the opener after we just cleared it.
191
- const realTarget = e.composedPath()[0];
192
- if (!realTarget || !this.shadowRoot?.contains(realTarget))
193
- return;
194
- this.setAttribute('data-focused', '');
195
- this.dispatchEvent(new CustomEvent('menu-item-focused', {
196
- bubbles: true,
197
- composed: true,
198
- }));
199
- });
200
- this.addEventListener('focusout', (e) => {
201
- // Mirror the focusin guard so a slotted descendant losing focus
202
- // doesn't strip data-focused from the opener while it's still
203
- // keyboard-focused itself.
204
- const realTarget = e.composedPath()[0];
205
- if (!realTarget || !this.shadowRoot?.contains(realTarget))
206
- return;
207
- this.removeAttribute('data-focused');
208
- });
209
- }
210
- focus(options) {
211
- const focusable = this.shadowRoot?.querySelector('button, a');
212
- focusable?.focus(options);
213
- }
214
- get _submenuEl() {
215
- return this._cachedSubmenuEl;
216
- }
217
- get _hasSubmenu() {
218
- return this._cachedSubmenuEl !== null;
219
- }
220
- willUpdate() {
221
- if (this.hasUpdated)
222
- return;
223
- // Before the first render, off the light DOM, so the chevron and the ARIA
224
- // attributes are right the first time. Resolving it in `firstUpdated` asks
225
- // for a second render from inside the first.
226
- this._cachedSubmenuEl = this.querySelector(':scope > nldd-menu');
227
- }
228
- updated(changedProperties) {
229
- // In a navigation menu the item is a list item, and the link inside it
230
- // is just a link.
231
- if (changedProperties.has('menuVariant'))
232
- syncListItemRole(this, this.menuVariant);
233
- // An item that becomes checkable, or stops being so, changes whether its
234
- // menu reserves the check-mark column, also while the menu is open.
235
- if (changedProperties.has('type') && changedProperties.get('type') !== undefined && this.menuVariant) {
236
- this.closest('nldd-menu')?._claimItems();
237
- }
238
- }
239
- firstUpdated() {
240
- // Submenu attachment is one-shot in v1 — a nldd-menu added after this
241
- // point would silently miss aria-controls, the chevron indicator, the
242
- // hover-open lifecycle, and the close-state sync. Watch for late
243
- // additions and warn so consumers don't chase the symptom.
244
- this._submenuMutationObserver = new MutationObserver(() => {
245
- const current = this.querySelector(':scope > nldd-menu');
246
- if (current && current !== this._cachedSubmenuEl) {
247
- console.warn('[nldd-menu-item] A nldd-menu child was added after mount. '
248
- + 'Submenu attachment is resolved once at firstUpdated in v1, '
249
- + 'so this menu will not be treated as a submenu. Define the '
250
- + 'nldd-menu child before the item is connected to the DOM.');
251
- }
252
- });
253
- this._submenuMutationObserver.observe(this, { childList: true });
254
- }
255
- disconnectedCallback() {
256
- super.disconnectedCallback();
257
- this._submenuMutationObserver?.disconnect();
258
- this._submenuMutationObserver = null;
259
- }
260
- _handleClick(event) {
261
- if (this.disabled)
262
- return;
263
- // Submenu items don't fire `select` — they open their submenu instead.
264
- // Item is either an action OR a submenu opener, not both.
265
- if (this._hasSubmenu) {
266
- // The button is wired to the submenu via the popoverTargetElement
267
- // IDL property (set in the template). That marks it as the
268
- // submenu's invoker so the browser excludes the opener from
269
- // popover light-dismiss — clicking the opener no longer closes
270
- // the submenu underneath it. The flip side: the browser would
271
- // also auto-show the popover with its default positioning,
272
- // which races our anchor + placement set in `_handleSubmenuOpen`.
273
- // preventDefault stops the browser action and lets our flow
274
- // own positioning.
275
- //
276
- // We use the IDL property rather than the `popovertarget`
277
- // attribute because the button lives in this menu-item's shadow
278
- // root while the submenu is a light-DOM child — attribute-based
279
- // ID resolution is tree-scoped and would silently fail to find
280
- // the cross-tree target. The IDL property takes a direct element
281
- // reference and works across shadow boundaries.
282
- event?.preventDefault();
283
- // Click on an already-open opener: keep the submenu visible and
284
- // the opener visually "active" (aria-expanded + :hover). A second
285
- // click should not toggle it closed — that conflicts with the
286
- // hover-open semantics of cascade mode.
287
- if (this._submenuOpen)
288
- return;
289
- this.dispatchEvent(new CustomEvent('submenu-open', {
290
- detail: { submenu: this._submenuEl, item: this },
291
- bubbles: true,
292
- composed: false,
293
- }));
294
- return;
295
- }
296
- this.dispatchEvent(new CustomEvent('select', {
297
- bubbles: true,
298
- composed: true,
299
- }));
300
- this.closest('nldd-menu')?.hidePopover?.();
301
- }
302
- /** Programmatically select this item. */
303
- select() {
304
- this._handleClick();
305
- }
306
- render() {
307
- return menuItemTemplate.call(this, this.menuVariant);
308
- }
309
- }
310
- NLDDMenuItem.styles = menuItemStyles;
311
- NLDDMenuItem._idCounter = 0;
312
- __decorate([
313
- property({ type: Boolean, reflect: true })
314
- ], NLDDMenuItem.prototype, "destructive", void 0);
315
- __decorate([
316
- property({ reflect: true, converter: reflectNonDefault('') })
317
- ], NLDDMenuItem.prototype, "text", void 0);
318
- __decorate([
319
- property({ reflect: true, converter: reflectNonDefault('') })
320
- ], NLDDMenuItem.prototype, "details", void 0);
321
- __decorate([
322
- property({ type: String, reflect: true })
323
- ], NLDDMenuItem.prototype, "icon", void 0);
324
- __decorate([
325
- property({ reflect: true, converter: reflectNonDefault('') })
326
- ], NLDDMenuItem.prototype, "shortcut", void 0);
327
- __decorate([
328
- property({ reflect: true, attribute: 'shortcut-mac', converter: reflectNonDefault('') })
329
- ], NLDDMenuItem.prototype, "shortcutMac", void 0);
330
- __decorate([
331
- property({ reflect: true, attribute: 'shortcut-windows', converter: reflectNonDefault('') })
332
- ], NLDDMenuItem.prototype, "shortcutWindows", void 0);
333
- __decorate([
334
- property({ reflect: true, attribute: 'shortcut-linux', converter: reflectNonDefault('') })
335
- ], NLDDMenuItem.prototype, "shortcutLinux", void 0);
336
- __decorate([
337
- property({ type: String, reflect: true })
338
- ], NLDDMenuItem.prototype, "href", void 0);
339
- __decorate([
340
- property({ type: String, reflect: true })
341
- ], NLDDMenuItem.prototype, "type", void 0);
342
- __decorate([
343
- property({ type: Boolean, reflect: true })
344
- ], NLDDMenuItem.prototype, "selected", void 0);
345
- __decorate([
346
- property({ type: Boolean, reflect: true })
347
- ], NLDDMenuItem.prototype, "disabled", void 0);
348
- __decorate([
349
- property({ type: String, reflect: true })
350
- ], NLDDMenuItem.prototype, "value", void 0);
351
- __decorate([
352
- property({ reflect: true, converter: reflectNonDefault('') })
353
- ], NLDDMenuItem.prototype, "aliases", void 0);
354
- __decorate([
355
- property({ reflect: true, converter: reflectNonDefault('') })
356
- ], NLDDMenuItem.prototype, "query", void 0);
357
- __decorate([
358
- property({ reflect: true, attribute: 'query-mark-mode', converter: reflectNonDefault('predictive') })
359
- ], NLDDMenuItem.prototype, "queryMarkMode", void 0);
360
- __decorate([
361
- state()
362
- ], NLDDMenuItem.prototype, "menuVariant", void 0);
363
- __decorate([
364
- state()
365
- ], NLDDMenuItem.prototype, "checkColumn", void 0);
366
- __decorate([
367
- state()
368
- ], NLDDMenuItem.prototype, "_submenuOpen", void 0);
369
- if (!customElements.get('nldd-menu-item')) {
370
- customElements.define('nldd-menu-item', NLDDMenuItem);
371
- }
23
+ import { MenuPointerController } from './menu.pointer.js';
24
+ import { SubmenuLevel } from './menu.chain.js';
25
+ import { SafeTriangleController, rectContainsPoint } from './menu.safe-triangle.js';
26
+ import { nextTabbableAfter } from '../../../utilities/tab-order.js';
27
+ export { NLDDMenuItem } from './menu-item.js';
28
+ export { NLDDMenuGroup } from './menu-group.js';
29
+ export { NLDDMenuDivider } from './menu-divider.js';
372
30
  // # nldd-menu
373
31
  const defaultFilterFn = (query, item) => {
374
32
  const q = query.toLowerCase();
@@ -377,6 +35,22 @@ const defaultFilterFn = (query, item) => {
377
35
  const aliasesMatch = item.aliases !== '' && item.aliases.split(' ').some(s => s.toLowerCase().includes(q));
378
36
  return textMatch || valueMatch || aliasesMatch;
379
37
  };
38
+ /** The name of what a menu hangs off. A field that anchors its list to an
39
+ * element inside its own shadow root (nldd-token-field) has the name on its
40
+ * host, so a nameless anchor in a shadow root asks the host. The property is
41
+ * read before the attribute: nldd-form-field sets `accessibleLabel` as one. */
42
+ function nameOfAnchor(anchor) {
43
+ const name = (anchor.accessibleLabel
44
+ || anchor.getAttribute('accessible-label')
45
+ || anchor.getAttribute('aria-label')
46
+ || anchor.getAttribute('text')
47
+ || (anchor.shadowRoot ? '' : anchor.textContent)
48
+ || '').trim();
49
+ if (name)
50
+ return name;
51
+ const root = anchor.getRootNode();
52
+ return root instanceof ShadowRoot ? nameOfAnchor(root.host) : '';
53
+ }
380
54
  /**
381
55
  * A floating menu component using the Popover API.
382
56
  * Positioned relative to an anchor element using Floating UI.
@@ -391,6 +65,7 @@ const defaultFilterFn = (query, item) => {
391
65
  *
392
66
  * @attr {'menu'|'listbox'|'navigation'} variant - What the menu is (default 'menu'). `menu` is a menu of actions: `role="menu"` with menu items, for things you do. `listbox` is the popup of a combobox: `role="listbox"` with options, focus stays in the field. `navigation` is a submenu in a site navigation: a list of links (`role="list"`, each item a list item around a real link), because a screen reader treats a menu as an application and reads a list of links as what it is. Every item takes an `href`. Tab reaches each link, the arrow keys, Home and End move between them, Escape closes and returns focus to the trigger, and the menu closes when focus leaves it. The trigger says `aria-expanded` and promises no menu. Checkbox and radio items, shortcuts and `filter()` belong to actions and warn in development here. A submenu of a navigation menu is a navigation menu too. The variant sets `role="listitem"` on its items and groups, and takes it off again when it changes back, also where you had set that role yourself.
393
67
  * @attr {string} width - Explicit width, pinned exactly. Without it the menu sizes to its content between a minimum and a viewport-aware maximum (min(100vw - inset, 640px)).
68
+ * @attr {string} accessible-label - Name of the menu or listbox for assistive technology, on the element that has the role. Without it the menu takes the name of its anchor (the `accessible-label`, `aria-label`, `text` or text of the button or field it hangs off), and a submenu the text of the item that opens it, so a listbox under a search field is "Zoeken" rather than nameless (WCAG 4.1.2). The list of an nldd-combo-box or nldd-token-field takes the name of the field.
394
69
  * @attr {string} anchor - ID of the anchor element. Positions the menu against it AND makes it a toggle: the menu listens on document click and opens/closes itself when the click lands on the anchor. Use this for a menu hung off a button. For a menu you open yourself (a type-ahead under a text field, say), set the `anchorElement` property instead — same positioning, no toggle.
395
70
  * @attr {string} placement - Floating UI placement. Default: 'bottom-start'.
396
71
  * @attr {number} max-items - Maximum number of visible items before scrolling. Sets --_menu-max-items internally. Default: 0 (no limit).
@@ -427,6 +102,7 @@ export class NLDDMenu extends LitElement {
427
102
  * nldd-token-field do: their input must stay an input, not a menu button.
428
103
  */
429
104
  this.anchorElement = null;
105
+ this.accessibleLabel = '';
430
106
  this.placement = 'bottom-start';
431
107
  /**
432
108
  * @internal Distance in px between the anchor and the menu, along the placement
@@ -471,34 +147,30 @@ export class NLDDMenu extends LitElement {
471
147
  * template (a separate module) reads them via `this`. */
472
148
  this._hasHeader = false;
473
149
  this._hasFooter = false;
474
- /** Currently open child submenu (a direct descendant nldd-menu opened
475
- * by one of this menu's items). null when no submenu is open. */
150
+ // — Submenu chain ——
151
+ // The open submenus are levels: see menu.chain.ts. These fields are what
152
+ // the levels and the rest of the menu read.
153
+ /** The submenu open from one of this menu's own items, and that item.
154
+ * null while none is open. @internal */
476
155
  this._activeSubmenu = null;
156
+ /** @internal */
477
157
  this._activeSubmenuOpener = null;
478
- /** Cleanup closure for the currently open child submenu. Invoked by the
479
- * submenu's `toggle→closed` event, but also callable directly from a
480
- * chain-close walk so the upper levels can be torn down without waiting
481
- * for stale toggle events that will never fire (e.g. a hidden drill-in
482
- * parent whose popover state is already 'closed'). */
483
- this._activeSubmenuCleanup = null;
158
+ /** The level of that submenu. @internal */
159
+ this._activeLevel = null;
484
160
  /** Signal that this menu is hiding itself to make room for a deeper drill-in
485
161
  * level — its parent's onToggle should skip the normal close cleanup
486
162
  * (re-parent + re-show) so the chain stays in deeper-level state. */
487
163
  this._drillInHidingForDeeper = false;
488
- /** Root-owned registry of every submenu currently open in this chain,
489
- * in open order. Lives on the root menu only; submenus reach it via
490
- * `_chainRoot`. Drives `_collapseChain()` so collapsing the whole
491
- * stack never depends on `_activeSubmenu`/`_parentMenu` threading
492
- * (which real interaction can leave stale). @internal */
164
+ /** Root-owned registry of every level open in this chain, in open order.
165
+ * Lives on the root only; submenus reach it via `_chainRoot`. Drives
166
+ * `_collapseChain()`, so collapsing the whole stack never depends on
167
+ * `_activeSubmenu`/`_parentMenu`, which real interaction can leave
168
+ * stale. @internal */
493
169
  this._openChain = [];
494
170
  /** Back-reference to the chain's root, set on every submenu when it
495
171
  * opens. Lets `_collapseChain()` find the registry without walking
496
172
  * the (possibly stale) parent links. null on the root. @internal */
497
173
  this._chainRoot = null;
498
- /** Force-teardown for this submenu (detach toggle listener, hide,
499
- * restore DOM, reset state — no parent re-show). Set when the submenu
500
- * opens; called by `_collapseChain()`. @internal */
501
- this._collapseSelf = null;
502
174
  /** When this menu is itself a submenu, points to the parent menu that
503
175
  * opened it. Set by the parent's _handleSubmenuOpen. null on the root.
504
176
  * @internal */
@@ -622,29 +294,12 @@ export class NLDDMenu extends LitElement {
622
294
  this.showPopover();
623
295
  }
624
296
  };
625
- // — Safe triangle (cascade only) ——————————————————————————————————————
626
- //
627
- // While a cascade submenu is open, a global mousemove listener tracks
628
- // the cursor against a "safe triangle" (Mayank/ishadeed pattern). The
629
- // triangle's apex is captured once on the first mousemove after submenu
630
- // open; the base is the submenu's two near corners (top + bottom of the
631
- // edge facing the parent — left edge if submenu is right of cursor,
632
- // right edge if floating-ui flipped it to the other side). The wedge
633
- // stays fixed until the cursor enters the submenu, so the user has a
634
- // predictable, stable area to traverse without losing the submenu.
635
- // While the cursor is inside the triangle, peer items don't activate.
636
- //
637
- // We deliberately do NOT auto-close on hover-out: moving the cursor to
638
- // empty space outside every menu leaves the chain open. The native
639
- // popover light-dismiss takes care of click-outside, which is the only
640
- // gesture that should collapse the chain.
297
+ // — Hover and the safe triangle (cascade only) ——————————————————————————
298
+ // See menu.safe-triangle.ts for the wedge that keeps a submenu open on a
299
+ // diagonal route to it.
641
300
  this._hoverOpenTimer = null;
642
- this._safeTriangleListener = null;
643
- this._safeTriangleStallTimer = null;
644
- this._lastCursorPos = null;
645
- this._safeTriangleApex = null;
646
- this._safeTriangleSubmenu = null;
647
- this._movingTowardSubmenu = false;
301
+ /** @internal */
302
+ this._safeTriangle = new SafeTriangleController(this);
648
303
  this._handleMenuItemMouseenter = (event) => {
649
304
  // Touch suppress: synthesised mouseenter from touch (e.g. lifting
650
305
  // after a scroll gesture on a long menu) shouldn't paint a highlight.
@@ -655,6 +310,18 @@ export class NLDDMenu extends LitElement {
655
310
  return;
656
311
  this._activateItem(item);
657
312
  };
313
+ /** Padding, dividers, header and footer are still inside the menu, so
314
+ * mouseleave doesn't fire there: drop the highlight once the pointer is over
315
+ * none of the items. */
316
+ this._handleMouseover = (event) => {
317
+ if (isTouchMode() || this.variant === 'listbox')
318
+ return;
319
+ if (this._activeSubmenu || this._safeTriangle.movingToward)
320
+ return;
321
+ if (event.composedPath().some((node) => node instanceof Element && node.localName === 'nldd-menu-item'))
322
+ return;
323
+ this._clearHighlight();
324
+ };
658
325
  this._handleMouseleave = () => {
659
326
  if (this.variant !== 'listbox')
660
327
  this._clearHighlight();
@@ -663,8 +330,6 @@ export class NLDDMenu extends LitElement {
663
330
  // open. Click-outside (popover light-dismiss) is the only gesture
664
331
  // that collapses the chain.
665
332
  };
666
- // — Debug overlay ————————————————————————————————————————————————————
667
- this._safeTriangleOverlay = null;
668
333
  this._handleMenuItemFocused = (event) => {
669
334
  const item = event.target.closest('nldd-menu-item');
670
335
  if (!item || item.disabled || item.hasAttribute('hidden'))
@@ -678,9 +343,7 @@ export class NLDDMenu extends LitElement {
678
343
  };
679
344
  /**
680
345
  * Open a submenu in response to one of this menu's items dispatching
681
- * `submenu-open`. Branches on drill-in vs cascade mode for anchor +
682
- * placement, but the lifecycle (popover.show, listen for close, clear
683
- * state on hide) is the same for both modes.
346
+ * `submenu-open`, as a new level of the chain (menu.chain.ts).
684
347
  */
685
348
  this._handleSubmenuOpen = (event) => {
686
349
  // Only handle events from items that are direct children of this menu.
@@ -697,180 +360,7 @@ export class NLDDMenu extends LitElement {
697
360
  // the next close.
698
361
  if (this._activeSubmenu === submenu)
699
362
  return;
700
- // Close any other submenu that's already open in this menu before
701
- // opening a new one — only one peer submenu visible at a time.
702
- if (this._activeSubmenu && this._activeSubmenu !== submenu) {
703
- this._activeSubmenu.hidePopover?.();
704
- }
705
- submenu._parentMenu = this;
706
- submenu._parentItem = item;
707
- // Register this submenu in the root's open-chain so `_collapseChain()`
708
- // can tear the whole stack down without relying on parent links being
709
- // intact at collapse time. Captured here, while links are fresh.
710
- const chainRoot = this._rootMenu;
711
- submenu._chainRoot = chainRoot;
712
- if (!chainRoot._openChain.includes(submenu))
713
- chainRoot._openChain.push(submenu);
714
- if (this._drillInMode) {
715
- // Drill-in: anchor to the root's anchor so all submenus open at the
716
- // same screen position — visually stacks. Inherit root placement
717
- // for consistent direction. Back button rendered in template.
718
- const root = this._rootMenu;
719
- submenu.anchorElement = root._getAnchorEl();
720
- submenu.placement = root.placement;
721
- }
722
- else {
723
- // Cascade: anchor to the parent item, open beside it.
724
- submenu.anchorElement = item;
725
- submenu.placement = 'right-start';
726
- }
727
- this._activeSubmenu = submenu;
728
- this._activeSubmenuOpener = item;
729
- item._submenuOpen = true;
730
- // Clear [highlighted] on the opener — the "logically current" item is
731
- // now in the submenu, not on the opener. The opener still shows visibly
732
- // active via .menu__item[aria-expanded="true"] (lighter neutral); CSS
733
- // :hover upgrades it to accent if the cursor returns to it.
734
- item.removeAttribute('highlighted');
735
- // Listen once for the submenu's close so we can clear state, ARIA and
736
- // any leftover safe-triangle plumbing from the cascade open path.
737
- const wasDrillIn = this._drillInMode;
738
- // Shared teardown — runs from `toggle→closed` in the normal flow, and
739
- // invoked directly from a select-chain-close walk for hidden ancestors
740
- // whose toggle event will never fire (they were already closed when
741
- // the deeper level took over the screen). `skipReshow` lets the chain
742
- // walk suppress the parent-restore step so the whole stack collapses.
743
- const cleanup = (skipReshow) => {
744
- submenu.removeEventListener('toggle', onToggle);
745
- if (this._activeSubmenu === submenu) {
746
- this._activeSubmenu = null;
747
- this._activeSubmenuOpener = null;
748
- this._activeSubmenuCleanup = null;
749
- }
750
- submenu._parentMenu = null;
751
- submenu._parentItem = null;
752
- // Deregister from the root's open-chain registry.
753
- const ci = chainRoot._openChain.indexOf(submenu);
754
- if (ci !== -1)
755
- chainRoot._openChain.splice(ci, 1);
756
- submenu._collapseSelf = null;
757
- submenu._chainRoot = null;
758
- item._submenuOpen = false;
759
- // Drill-in: restore the submenu to its original DOM position and
760
- // re-show the parent so the user returns to the previous view.
761
- // Captured at open-time so a viewport flip during navigation
762
- // doesn't leave the chain in an inconsistent state.
763
- if (wasDrillIn) {
764
- releaseContext(submenu);
765
- if (drillInOriginalParent && drillInOriginalParent.isConnected) {
766
- drillInOriginalParent.insertBefore(submenu, drillInNextSibling);
767
- }
768
- else {
769
- // Original parent was removed from the DOM while the
770
- // submenu was reparented to <body> (SPA navigation,
771
- // story teardown, etc.). There's nowhere to restore it
772
- // to — drop the orphaned node instead of leaking a
773
- // detached-but-connected element in <body> forever.
774
- submenu.remove();
775
- }
776
- if (!skipReshow && this.isConnected && !this.matches(':popover-open')) {
777
- this.showPopover?.();
778
- }
779
- // One level back (back button / ArrowLeft / Esc) — announce the
780
- // destination view on the now-visible parent. `skipReshow` is a
781
- // collapse-the-whole-chain teardown (select / outside-tap /
782
- // resize): that's a dismiss, not a back-nav, so it stays silent.
783
- if (!skipReshow && this.isConnected) {
784
- const dest = this._parentItem?.text;
785
- this._announce(dest
786
- ? this._t('components.menu.submenu-back-action', { title: dest })
787
- : this._t('components.menu.back-action'));
788
- }
789
- }
790
- // Drop any safe-triangle "in transit" highlight on the opener —
791
- // without this, an opener whose submenu was closed via stall-
792
- // dismissal or programmatic hidePopover keeps the bold accent
793
- // even though the close should also drop the visual signal.
794
- // Skip when the item is currently focused — keyboard close
795
- // (ArrowLeft) sync-focuses the opener before this async toggle
796
- // fires, and that focus already set [highlighted] via the
797
- // menu-item-focused chain; stripping it here would leave the
798
- // opener visibly unhighlighted despite being focused.
799
- if (!item.hasAttribute('data-focused')) {
800
- item.removeAttribute('highlighted');
801
- }
802
- this._stopSafeTriangle();
803
- // Counterpart to `submenu-open` — consumers tracking submenu state
804
- // via declarative event listeners (rather than reaching into our
805
- // internals) get a clean close signal here.
806
- this.dispatchEvent(new CustomEvent('submenu-close', {
807
- detail: { submenu, item },
808
- bubbles: true,
809
- composed: false,
810
- }));
811
- };
812
- const onToggle = (e) => {
813
- const tg = e;
814
- if (tg.newState !== 'closed')
815
- return;
816
- // Submenu is hiding to make room for a deeper drill — leave the
817
- // chain state alone, keep the listener around for the eventual
818
- // real close.
819
- if (submenu._drillInHidingForDeeper) {
820
- submenu._drillInHidingForDeeper = false;
821
- return;
822
- }
823
- // A real toggle-close = one level back: tear down and re-show
824
- // the parent. Collapsing the whole chain doesn't come through
825
- // here — `_collapseChain()` drives `_collapseSelf` directly.
826
- cleanup(false);
827
- };
828
- submenu.addEventListener('toggle', onToggle);
829
- this._activeSubmenuCleanup = cleanup;
830
- // Force-teardown used by `_collapseChain()`: detach the toggle
831
- // listener (so this hide doesn't also run the back-nav onToggle),
832
- // hide, then run the shared cleanup with no parent re-show.
833
- submenu._collapseSelf = () => {
834
- submenu.removeEventListener('toggle', onToggle);
835
- submenu.hidePopover?.();
836
- cleanup(true);
837
- };
838
- // Drill-in: re-parent the submenu to <body> before show so it isn't
839
- // a popover-stack descendant of the parent — that lets us close the
840
- // parent without cascading the submenu closed. Original placement is
841
- // restored when the submenu closes.
842
- let drillInOriginalParent = null;
843
- let drillInNextSibling = null;
844
- if (wasDrillIn) {
845
- drillInOriginalParent = submenu.parentElement;
846
- drillInNextSibling = submenu.nextSibling;
847
- carryContext(submenu, drillInOriginalParent);
848
- document.body.appendChild(submenu);
849
- }
850
- submenu.showPopover?.();
851
- if (wasDrillIn) {
852
- // View just swapped to the submenu — announce the level we
853
- // entered (the opener's label is this view's title, same string
854
- // the back button shows). Fires on the now-visible submenu.
855
- submenu._announce(submenu._t('components.menu.submenu-title', { title: item.text }));
856
- // Signal to our own parent's onToggle (if any) that this hide is
857
- // "intentional, making room for a deeper drill" — skip the normal
858
- // close cleanup that would re-parent us back and re-open them.
859
- this._drillInHidingForDeeper = true;
860
- this.hidePopover?.();
861
- }
862
- // Start the safe-triangle tracker for cascade-mode submenus only.
863
- // Drill-in mode replaces the parent view, so there's no "moving toward"
864
- // path between two visible menus to protect.
865
- if (!wasDrillIn) {
866
- // Wait one frame so the submenu's getBoundingClientRect reflects its
867
- // final position (computePosition runs in the toggle handler).
868
- requestAnimationFrame(() => {
869
- if (this._activeSubmenu === submenu) {
870
- this._startSafeTriangle(submenu);
871
- }
872
- });
873
- }
363
+ new SubmenuLevel(this, item, submenu, this._drillInMode).open();
874
364
  };
875
365
  /** Close this submenu when the back button is clicked, returning to the
876
366
  * parent view (which is still open as a popover behind this one in
@@ -886,34 +376,11 @@ export class NLDDMenu extends LitElement {
886
376
  this._handleBackMouseenter = () => {
887
377
  this._clearHighlight();
888
378
  };
889
- this._touchStartX = 0;
890
- this._touchStartY = 0;
891
- /** @internal */
892
- this._handleMenuTouchStart = (event) => {
893
- const t = event.touches[0];
894
- if (!t)
895
- return;
896
- this._touchStartX = t.clientX;
897
- this._touchStartY = t.clientY;
898
- this.removeAttribute('scroll-active');
899
- };
900
- /** @internal */
901
- this._handleMenuTouchMove = (event) => {
902
- if (this.hasAttribute('scroll-active'))
903
- return;
904
- const t = event.touches[0];
905
- if (!t)
906
- return;
907
- const dx = t.clientX - this._touchStartX;
908
- const dy = t.clientY - this._touchStartY;
909
- if (Math.hypot(dx, dy) > NLDDMenu._TOUCH_SCROLL_THRESHOLD_PX) {
910
- this.setAttribute('scroll-active', '');
911
- }
912
- };
379
+ // — Pointer gestures ————————————————————————————————————————————————————
380
+ // Press-drag-release, no press flash while scrolling, and a tap beside a
381
+ // drill-in chain: see menu.pointer.ts.
913
382
  /** @internal */
914
- this._handleMenuTouchEnd = () => {
915
- this.removeAttribute('scroll-active');
916
- };
383
+ this._pointer = new MenuPointerController(this);
917
384
  /** Close the menu on a window resize. Floating-UI's autoUpdate keeps
918
385
  * the position in sync with scrolls (where users genuinely expect the
919
386
  * menu to follow the anchor), but a full window resize is a layout-
@@ -932,8 +399,8 @@ export class NLDDMenu extends LitElement {
932
399
  * selecting an item, clicking the anchor, clicking/tapping outside, or
933
400
  * a viewport resize.
934
401
  *
935
- * Driven by the root's `_openChain` registry and each submenu's
936
- * `_collapseSelf`, so it never depends on `_activeSubmenu` /
402
+ * Driven by the root's `_openChain` registry of levels, so it never
403
+ * depends on `_activeSubmenu` /
937
404
  * `_parentMenu` threading being intact at collapse time — real
938
405
  * interaction can leave those stale, which was the source of the
939
406
  * recurring "anchor click doesn't close after the 2nd navigation"
@@ -947,7 +414,7 @@ export class NLDDMenu extends LitElement {
947
414
  const chain = root._openChain;
948
415
  root._openChain = [];
949
416
  for (let i = chain.length - 1; i >= 0; i--)
950
- chain[i]._collapseSelf?.();
417
+ chain[i].collapse();
951
418
  if (root._isOpen)
952
419
  root.hidePopover?.();
953
420
  };
@@ -978,43 +445,6 @@ export class NLDDMenu extends LitElement {
978
445
  * tap (pointerup without crossing the scroll threshold); a scroll
979
446
  * leaves the chain untouched, matching root-menu behavior.
980
447
  */
981
- this._dragStartItem = null;
982
- /**
983
- * Native HTML `<select>` lets you press on one option, drag to another,
984
- * and release to pick the one under the pointer. Standard click events
985
- * don't fire across different elements, so we replicate it manually:
986
- * remember the pointerdown'd item, listen for the matching pointerup,
987
- * and if the release lands on a different non-disabled item, fire its
988
- * `select` directly. The original button's click handler still owns the
989
- * single-click no-drag path.
990
- */
991
- this._handleItemPointerdown = (event) => {
992
- if (event.button !== 0)
993
- return;
994
- const item = event.target?.closest('nldd-menu-item');
995
- if (!item || item.disabled)
996
- return;
997
- this._dragStartItem = item;
998
- document.addEventListener('pointerup', this._handleDragRelease, { capture: true, once: true });
999
- };
1000
- this._handleDragRelease = (event) => {
1001
- const startItem = this._dragStartItem;
1002
- this._dragStartItem = null;
1003
- if (!startItem)
1004
- return;
1005
- // If the menu closed between pointerdown and pointerup (light-dismiss,
1006
- // keyboard shortcut), bail — elementFromPoint could otherwise resolve
1007
- // to an item in a different, newly-opened menu and fire its select.
1008
- if (!this._isOpen)
1009
- return;
1010
- const releaseItem = this._menuItemFromPoint(event.clientX, event.clientY);
1011
- if (!releaseItem || releaseItem === startItem || releaseItem.disabled)
1012
- return;
1013
- // Different item — fire its select. Browser won't dispatch click here
1014
- // because pointerdown and pointerup landed on different targets, so
1015
- // there's no double-fire to suppress.
1016
- releaseItem._handleClick();
1017
- };
1018
448
  this._handleDocumentPointerdown = (event) => {
1019
449
  if (!this._isOpen)
1020
450
  return;
@@ -1056,42 +486,19 @@ export class NLDDMenu extends LitElement {
1056
486
  // the chain doesn't collapse it (consistent with the root menu,
1057
487
  // which stays open while scrolling outside).
1058
488
  if (event.pointerType === 'touch') {
1059
- this._outsideTapStartX = event.clientX;
1060
- this._outsideTapStartY = event.clientY;
1061
- this._teardownOutsideTap();
1062
- this._outsideTapTracking = true;
1063
- document.addEventListener('pointermove', this._outsideTapMove, true);
1064
- document.addEventListener('pointerup', this._outsideTapEnd, true);
1065
- document.addEventListener('pointercancel', this._outsideTapCancel, true);
489
+ this._pointer.trackOutsideTap(event, () => {
490
+ (this._chainRoot ?? this)._collapsedByPointerGesture = true;
491
+ this._collapseChain();
492
+ });
1066
493
  return;
1067
494
  }
1068
495
  (this._chainRoot ?? this)._collapsedByPointerGesture = true;
1069
496
  this._collapseChain();
1070
497
  };
1071
- this._outsideTapStartX = 0;
1072
- this._outsideTapStartY = 0;
1073
- this._outsideTapTracking = false;
1074
- this._outsideTapMove = (e) => {
1075
- const dx = e.clientX - this._outsideTapStartX;
1076
- const dy = e.clientY - this._outsideTapStartY;
1077
- if (Math.hypot(dx, dy) > NLDDMenu._TOUCH_SCROLL_THRESHOLD_PX) {
1078
- // Became a scroll — leave the chain open.
1079
- this._teardownOutsideTap();
1080
- }
1081
- };
1082
- this._outsideTapEnd = () => {
1083
- const wasTap = this._outsideTapTracking;
1084
- this._teardownOutsideTap();
1085
- if (wasTap) {
1086
- (this._chainRoot ?? this)._collapsedByPointerGesture = true;
1087
- this._collapseChain();
1088
- }
1089
- };
1090
- this._outsideTapCancel = () => {
1091
- this._teardownOutsideTap();
1092
- };
1093
498
  // — Private handlers ——————————————————————————————————————————————————————
1094
499
  this._handleKeydown = (event) => {
500
+ if (event.key === 'Tab' && this._tabOut(event))
501
+ return;
1095
502
  // Only a navigation menu closes on a Tab out; see _handleFocusOut.
1096
503
  if (event.key === 'Tab' && this.variant === 'navigation') {
1097
504
  this._tabbing = true;
@@ -1278,7 +685,7 @@ export class NLDDMenu extends LitElement {
1278
685
  this._cleanupAutoUpdate = null;
1279
686
  window.removeEventListener('resize', this._handleWindowResize);
1280
687
  document.removeEventListener('pointerdown', this._handleDocumentPointerdown, true);
1281
- this._teardownOutsideTap();
688
+ this._pointer.stopOutsideTap();
1282
689
  this._clearHighlight();
1283
690
  return;
1284
691
  }
@@ -1317,6 +724,7 @@ export class NLDDMenu extends LitElement {
1317
724
  };
1318
725
  }
1319
726
  // — i18n ——————————————————————————————————————————————————————————————————
727
+ /** @internal */
1320
728
  _t(key, vars) {
1321
729
  return translate(this.translations, nlddMenuTranslations, key, vars);
1322
730
  }
@@ -1344,6 +752,7 @@ export class NLDDMenu extends LitElement {
1344
752
  * announces only the level you land on); once flushed, the same text may
1345
753
  * be announced again for a later genuine transition (e.g. re-entering a
1346
754
  * submenu after going back).
755
+ * @internal
1347
756
  */
1348
757
  _announce(message) {
1349
758
  if (!message)
@@ -1410,7 +819,18 @@ export class NLDDMenu extends LitElement {
1410
819
  this._syncAnchorPopupState(this._isOpen);
1411
820
  }
1412
821
  }
822
+ /** @internal The name of the element with the menu or listbox role: its
823
+ * own, else the name of what it hangs off. */
824
+ get _listLabel() {
825
+ if (this.accessibleLabel)
826
+ return this.accessibleLabel;
827
+ if (this._parentItem?.text)
828
+ return this._parentItem.text;
829
+ const anchor = this._getAnchorEl();
830
+ return anchor ? nameOfAnchor(anchor) : '';
831
+ }
1413
832
  // — Anchor ————————————————————————————————————————————————————————————————
833
+ /** @internal */
1414
834
  _getAnchorEl() {
1415
835
  if (this.anchorElement)
1416
836
  return this.anchorElement;
@@ -1467,6 +887,27 @@ export class NLDDMenu extends LitElement {
1467
887
  anchor.popoverTargetAction = isOpen ? 'hide' : 'show';
1468
888
  }
1469
889
  }
890
+ /** @internal For the safe triangle: the item whose submenu is open. */
891
+ get safeTriangleOpener() {
892
+ return this._activeSubmenuOpener;
893
+ }
894
+ /** @internal For the safe triangle. */
895
+ highlightOpener() {
896
+ if (this._activeSubmenuOpener)
897
+ this._setHighlight(this._activeSubmenuOpener);
898
+ }
899
+ /** @internal For the safe triangle: whether a point is in `submenu` or a
900
+ * submenu below it, so a cursor that went on into a deeper submenu still
901
+ * reads as arrived rather than re-pinning a stale apex. */
902
+ isPointInSubmenus(p, submenu) {
903
+ let menu = submenu;
904
+ while (menu) {
905
+ if (rectContainsPoint(menu.getBoundingClientRect(), p))
906
+ return true;
907
+ menu = menu._activeSubmenu;
908
+ }
909
+ return false;
910
+ }
1470
911
  /**
1471
912
  * Item-activation logic shared between the native `mouseenter` capture
1472
913
  * handler and the safe-triangle recovery paths (sideways exit, direction
@@ -1490,7 +931,7 @@ export class NLDDMenu extends LitElement {
1490
931
  // submenu, peer items don't get highlighted and don't schedule
1491
932
  // hover-opens. Without this, the highlight flickers across every item
1492
933
  // the cursor brushes past on its diagonal route to the submenu.
1493
- if (this._movingTowardSubmenu && item !== this._activeSubmenuOpener)
934
+ if (this._safeTriangle.movingToward && item !== this._activeSubmenuOpener)
1494
935
  return;
1495
936
  this._setHighlight(item);
1496
937
  if (this._drillInMode)
@@ -1513,274 +954,22 @@ export class NLDDMenu extends LitElement {
1513
954
  }, 150);
1514
955
  }
1515
956
  }
1516
- /** Resolve the menu-item under a viewport point and activate it via
1517
- * `_activateItem`. Used by safe-triangle recovery paths whose natural
1518
- * mouseenter has already fired (and bailed) — they need to re-trigger
1519
- * activation without synthesizing a MouseEvent. */
1520
- _activateItemAt(p) {
957
+ /** @internal Resolve the menu-item under a viewport point and activate it
958
+ * via `_activateItem`. Used by the safe triangle, whose natural mouseenter
959
+ * has already fired (and bailed): it re-triggers activation without
960
+ * synthesizing a MouseEvent. */
961
+ activateItemAt(p) {
1521
962
  const el = document.elementFromPoint(p.x, p.y);
1522
963
  const item = el?.closest('nldd-menu-item');
1523
964
  if (item)
1524
965
  this._activateItem(item);
1525
966
  }
1526
- /** Start the global mouse tracker that powers the safe triangle. Called
1527
- * by _handleSubmenuOpen when a submenu opens in cascade mode. The
1528
- * listener is a thin orchestrator over the named phase methods below. */
1529
- _startSafeTriangle(submenu) {
1530
- this._stopSafeTriangle();
1531
- this._lastCursorPos = null;
1532
- this._safeTriangleApex = null;
1533
- this._safeTriangleSubmenu = submenu;
1534
- this._movingTowardSubmenu = false;
1535
- this._safeTriangleListener = (e) => {
1536
- const p = { x: e.clientX, y: e.clientY };
1537
- const r = submenu.getBoundingClientRect();
1538
- // 1. In submenu (or any nested submenu) — arrived, clean up.
1539
- if (NLDDMenu._isPointInMenuTree(p, submenu)) {
1540
- this._safeTriangleArrived(p);
1541
- return;
1542
- }
1543
- const openerRect = this._activeSubmenuOpener?.getBoundingClientRect();
1544
- const cursorOnOpener = NLDDMenu._rectContainsPoint(openerRect, p);
1545
- const lastOnOpener = NLDDMenu._rectContainsPoint(openerRect, this._lastCursorPos);
1546
- // 2. Returned to opener — drop apex so the next exit can re-pin
1547
- // a fresh wedge. Overlay stays drawn until next render.
1548
- if (this._safeTriangleApex !== null && cursorOnOpener) {
1549
- this._safeTriangleApex = null;
1550
- }
1551
- const wasMoving = this._movingTowardSubmenu;
1552
- if (this._safeTriangleApex === null) {
1553
- // 3a. Still on opener — wait for an exit direction.
1554
- if (cursorOnOpener) {
1555
- this._safeTriangleWaitOnOpener(p, r, openerRect);
1556
- return;
1557
- }
1558
- // 3b. Crossed top/bottom edge of opener — pin apex.
1559
- if (openerRect && lastOnOpener && (p.y > openerRect.bottom || p.y < openerRect.top)) {
1560
- this._safeTrianglePinApex(p, openerRect);
1561
- }
1562
- else {
1563
- // 3c. Exited sideways — no protection. Drop the apex and
1564
- // activate whatever item is under the cursor so peers
1565
- // take over immediately.
1566
- this._safeTriangleSidewaysExit(p, wasMoving);
1567
- }
1568
- }
1569
- else {
1570
- // 4. Apex pinned — test whether cursor is inside the wedge.
1571
- this._safeTrianglePolygonTest(p, r);
1572
- }
1573
- this._lastCursorPos = p;
1574
- // 5. Common per-frame work: highlight, recovery, stall timer.
1575
- this._safeTriangleSyncOpenerHighlight();
1576
- this._safeTriangleDirectionReversalRecovery(p, wasMoving);
1577
- this._safeTriangleScheduleStall();
1578
- };
1579
- window.addEventListener('mousemove', this._safeTriangleListener);
1580
- }
1581
- // — Safe-triangle phase methods ————————————————————————————————————————
1582
- /** Cursor entered the submenu (or any nested submenu) — clean up triangle
1583
- * state but leave the window mousemove listener alive. The listener still
1584
- * needs to fire while the cursor is inside the submenu so we can detect a
1585
- * return trip to the opener and re-pin a fresh apex for another exit. */
1586
- _safeTriangleArrived(p) {
1587
- this._movingTowardSubmenu = false;
1588
- this._lastCursorPos = p;
1589
- this._safeTriangleApex = null;
1590
- this._activeSubmenuOpener?.removeAttribute('highlighted');
1591
- this._removeSafeTriangleOverlay();
1592
- }
1593
- /** Cursor still on the opener — wait for an exit direction. Sets the
1594
- * "in transit" flag (so brief peer pass-throughs don't activate) and
1595
- * renders a live debug preview that follows the cursor. */
1596
- _safeTriangleWaitOnOpener(p, r, openerRect) {
1597
- this._movingTowardSubmenu = true;
1598
- this._lastCursorPos = p;
1599
- // Set opener highlight up front so the bold accent is already on
1600
- // while the cursor is still on the opener — avoids a visible "pop"
1601
- // when the cursor first crosses the bottom edge.
1602
- if (this._activeSubmenuOpener
1603
- && !this._activeSubmenuOpener.hasAttribute('highlighted')) {
1604
- this._setHighlight(this._activeSubmenuOpener);
1605
- }
1606
- if (this.debugSafeTriangle && openerRect) {
1607
- const nearX = p.x < r.left ? r.left : r.right;
1608
- this._renderSafeTriangleOverlay([
1609
- { x: p.x - NLDDMenu._SAFE_TRIANGLE_APEX_X_OFFSET, y: p.y },
1610
- { x: nearX, y: r.top },
1611
- { x: nearX, y: r.bottom },
1612
- ]);
1613
- }
1614
- }
1615
- /** Cursor crossed the opener's top or bottom edge — pin apex there.
1616
- * x is clamped to the opener's range so the wedge starts at the visual
1617
- * edge regardless of how far past the edge this mousemove sample is, then
1618
- * shifted by _SAFE_TRIANGLE_APEX_X_OFFSET to widen the wedge at the
1619
- * cursor side (the 4px headroom that makes brief diagonal wobble forgive). */
1620
- _safeTrianglePinApex(p, openerRect) {
1621
- const apexX = Math.max(openerRect.left, Math.min(openerRect.right, p.x))
1622
- - NLDDMenu._SAFE_TRIANGLE_APEX_X_OFFSET;
1623
- const apexY = p.y > openerRect.bottom ? openerRect.bottom : openerRect.top;
1624
- this._safeTriangleApex = { x: apexX, y: apexY };
1625
- this._movingTowardSubmenu = true;
1626
- }
1627
- /** Cursor exited the opener sideways (left/right) or with no opener
1628
- * history — no triangle protection. Drop the flag and the overlay,
1629
- * and synthesize mouseenter on the element under the cursor so peers
1630
- * activate immediately (the natural mouseenter fired with flag=true
1631
- * during the on-opener phase and got bailed). */
1632
- _safeTriangleSidewaysExit(p, wasMoving) {
1633
- this._movingTowardSubmenu = false;
1634
- this._lastCursorPos = p;
1635
- this._removeSafeTriangleOverlay();
1636
- if (wasMoving)
1637
- this._activateItemAt(p);
1638
- }
1639
- /** Apex pinned — test whether the current cursor position is inside the
1640
- * wedge. Picks the submenu edge facing the cursor (left for right-start,
1641
- * right when floating-ui flipped it). */
1642
- _safeTrianglePolygonTest(p, r) {
1643
- const nearX = p.x < r.left ? r.left : r.right;
1644
- const apex = this._safeTriangleApex;
1645
- // Single-point apex (no jitter band): the apex is already offset left
1646
- // of the actual crossing point by _SAFE_TRIANGLE_APEX_X_OFFSET, so the
1647
- // cursor sits comfortably inside the wedge near the opener edge — no
1648
- // degenerate cases where a 1px jitter pops the cursor out at the apex.
1649
- const wedge = [
1650
- apex,
1651
- { x: nearX, y: r.top },
1652
- { x: nearX, y: r.bottom },
1653
- ];
1654
- this._movingTowardSubmenu = NLDDMenu._pointInPolygon(p, wedge);
1655
- if (this.debugSafeTriangle) {
1656
- this._renderSafeTriangleOverlay(wedge);
1657
- }
1658
- }
1659
- /** Sync opener highlight with the in-transit flag. Uses _setHighlight so
1660
- * any peer that briefly got highlighted (e.g. via the synthetic
1661
- * mouseenter on a wedge-edge wobble) is cleared. Skip when the opener
1662
- * already has the attribute to avoid DOM churn each frame. */
1663
- _safeTriangleSyncOpenerHighlight() {
1664
- if (this._activeSubmenuOpener && this._movingTowardSubmenu
1665
- && !this._activeSubmenuOpener.hasAttribute('highlighted')) {
1666
- this._setHighlight(this._activeSubmenuOpener);
1667
- }
1668
- }
1669
- /** When the in-transit flag flips true → false, the cursor may already
1670
- * be sitting on a peer item whose natural mouseenter fired (and bailed)
1671
- * earlier. mouseenter won't re-fire until the cursor leaves and re-
1672
- * enters, so synthesize one here to activate the peer immediately. */
1673
- _safeTriangleDirectionReversalRecovery(p, wasMoving) {
1674
- if (!wasMoving || this._movingTowardSubmenu)
1675
- return;
1676
- this._activateItemAt(p);
1677
- }
1678
- /** Re-arm the stall-dismissal timer. If the cursor sits motionless
1679
- * inside the safe triangle long enough, drop the protection so the
1680
- * element under the cursor can become interactive without nudging. */
1681
- _safeTriangleScheduleStall() {
1682
- if (this._safeTriangleStallTimer !== null) {
1683
- clearTimeout(this._safeTriangleStallTimer);
1684
- this._safeTriangleStallTimer = null;
1685
- }
1686
- if (!this._movingTowardSubmenu)
1687
- return;
1688
- this._safeTriangleStallTimer = window.setTimeout(() => {
1689
- this._safeTriangleStallTimer = null;
1690
- this._movingTowardSubmenu = false;
1691
- this._safeTriangleApex = null;
1692
- if (this._lastCursorPos)
1693
- this._activateItemAt(this._lastCursorPos);
1694
- }, NLDDMenu._SAFE_TRIANGLE_STALL_DISMISS_MS);
1695
- }
1696
- /** True when the rect contains the point (inclusive). Returns false for
1697
- * a missing rect or point — convenient for the optional-chained call
1698
- * sites in the safe-triangle logic. */
1699
- static _rectContainsPoint(rect, point) {
1700
- return !!rect && !!point
1701
- && point.x >= rect.left && point.x <= rect.right
1702
- && point.y >= rect.top && point.y <= rect.bottom;
1703
- }
1704
- _stopSafeTriangle() {
1705
- if (this._safeTriangleListener !== null) {
1706
- window.removeEventListener('mousemove', this._safeTriangleListener);
1707
- this._safeTriangleListener = null;
1708
- }
1709
- if (this._safeTriangleStallTimer !== null) {
1710
- clearTimeout(this._safeTriangleStallTimer);
1711
- this._safeTriangleStallTimer = null;
1712
- }
1713
- this._lastCursorPos = null;
1714
- this._safeTriangleApex = null;
1715
- this._safeTriangleSubmenu = null;
1716
- this._movingTowardSubmenu = false;
1717
- this._removeSafeTriangleOverlay();
1718
- }
1719
- _renderSafeTriangleOverlay(vertices) {
1720
- const NS = 'http://www.w3.org/2000/svg';
1721
- if (this._safeTriangleOverlay === null) {
1722
- const wrapper = document.createElement('div');
1723
- wrapper.setAttribute('popover', 'manual');
1724
- wrapper.setAttribute('aria-hidden', 'true');
1725
- wrapper.style.cssText = 'position:fixed;inset:0;width:100vw;height:100vh;pointer-events:none;border:0;padding:0;margin:0;background:transparent;overflow:visible;';
1726
- const svg = document.createElementNS(NS, 'svg');
1727
- svg.setAttribute('width', '100%');
1728
- svg.setAttribute('height', '100%');
1729
- const polygon = document.createElementNS(NS, 'polygon');
1730
- polygon.setAttribute('fill', 'rgba(255, 0, 128, 0.15)');
1731
- polygon.setAttribute('stroke', 'rgba(255, 0, 128, 0.85)');
1732
- polygon.setAttribute('stroke-width', '1');
1733
- svg.appendChild(polygon);
1734
- wrapper.appendChild(svg);
1735
- document.body.appendChild(wrapper);
1736
- wrapper.showPopover();
1737
- this._safeTriangleOverlay = wrapper;
1738
- }
1739
- const polygon = this._safeTriangleOverlay.querySelector('polygon');
1740
- polygon.setAttribute('points', vertices.map(v => `${v.x},${v.y}`).join(' '));
1741
- }
1742
- _removeSafeTriangleOverlay() {
1743
- this._safeTriangleOverlay?.hidePopover?.();
1744
- this._safeTriangleOverlay?.remove();
1745
- this._safeTriangleOverlay = null;
1746
- }
1747
967
  _cancelHoverOpen() {
1748
968
  if (this._hoverOpenTimer !== null) {
1749
969
  clearTimeout(this._hoverOpenTimer);
1750
970
  this._hoverOpenTimer = null;
1751
971
  }
1752
972
  }
1753
- /** Recursively checks whether a point sits inside the given menu OR any of
1754
- * its descendant submenus. Used by the safe-triangle "arrived" check so a
1755
- * cursor that has continued past the immediate submenu into a deeper
1756
- * nested submenu still reads as "in the safe area" — without the recursive
1757
- * walk we'd treat the deeper hover as an exit and re-pin a stale apex. */
1758
- static _isPointInMenuTree(p, menu) {
1759
- const r = menu.getBoundingClientRect();
1760
- if (p.x >= r.left && p.x <= r.right && p.y >= r.top && p.y <= r.bottom)
1761
- return true;
1762
- if (menu._activeSubmenu)
1763
- return NLDDMenu._isPointInMenuTree(p, menu._activeSubmenu);
1764
- return false;
1765
- }
1766
- /** Convex point-in-polygon test via consistent edge-cross-product sign.
1767
- * Vertices must be ordered (clockwise or counter-clockwise). */
1768
- static _pointInPolygon(p, vertices) {
1769
- let hasNeg = false;
1770
- let hasPos = false;
1771
- for (let i = 0; i < vertices.length; i++) {
1772
- const a = vertices[i];
1773
- const b = vertices[(i + 1) % vertices.length];
1774
- const cross = (p.x - b.x) * (a.y - b.y) - (a.x - b.x) * (p.y - b.y);
1775
- if (cross < 0)
1776
- hasNeg = true;
1777
- if (cross > 0)
1778
- hasPos = true;
1779
- if (hasNeg && hasPos)
1780
- return false;
1781
- }
1782
- return true;
1783
- }
1784
973
  static _getDrillInModeQuery() {
1785
974
  if (NLDDMenu._drillInModeQuery === null) {
1786
975
  // Use the shared breakpoint constant so the JS-side threshold can't
@@ -1806,37 +995,9 @@ export class NLDDMenu extends LitElement {
1806
995
  get _isSubmenu() {
1807
996
  return this._parentMenu !== null;
1808
997
  }
1809
- /**
1810
- * Resolves the menu-item under the pointer, piercing shadow boundaries.
1811
- * `document.elementFromPoint` stops at the outermost shadow host, so a menu
1812
- * nested inside another component's shadow DOM (e.g. nldd-split-button)
1813
- * resolves the release target to that host and never finds the item — which
1814
- * silently disables press-drag-release there. Descending the shadow roots
1815
- * restores it and is a no-op for light-DOM menus.
1816
- */
1817
- _menuItemFromPoint(x, y) {
1818
- let root = document;
1819
- // Depth guard: a backstop against pathologically deep shadow nesting;
1820
- // real menus are at most a few roots deep.
1821
- const MAX_PIERCE_DEPTH = 20;
1822
- for (let depth = 0; depth < MAX_PIERCE_DEPTH; depth++) {
1823
- const el = root.elementFromPoint(x, y);
1824
- if (!el)
1825
- return null;
1826
- const item = el.closest('nldd-menu-item');
1827
- if (item)
1828
- return item;
1829
- if (!el.shadowRoot)
1830
- return null;
1831
- root = el.shadowRoot;
1832
- }
1833
- return null;
1834
- }
1835
- _teardownOutsideTap() {
1836
- this._outsideTapTracking = false;
1837
- document.removeEventListener('pointermove', this._outsideTapMove, true);
1838
- document.removeEventListener('pointerup', this._outsideTapEnd, true);
1839
- document.removeEventListener('pointercancel', this._outsideTapCancel, true);
998
+ /** @internal For the pointer gestures. */
999
+ get _isMenuOpen() {
1000
+ return this._isOpen;
1840
1001
  }
1841
1002
  connectedCallback() {
1842
1003
  super.connectedCallback();
@@ -1852,11 +1013,11 @@ export class NLDDMenu extends LitElement {
1852
1013
  this.addEventListener('keydown', this._handleKeydown);
1853
1014
  this.addEventListener('focusout', this._handleFocusOut);
1854
1015
  this.addEventListener('mouseenter', this._handleMenuItemMouseenter, true);
1016
+ this.addEventListener('mouseover', this._handleMouseover);
1855
1017
  this.addEventListener('mouseleave', this._handleMouseleave);
1856
1018
  this.addEventListener('menu-item-focused', this._handleMenuItemFocused);
1857
1019
  this.addEventListener('submenu-open', this._handleSubmenuOpen);
1858
1020
  this.addEventListener('select', this._collapseChain);
1859
- this.addEventListener('pointerdown', this._handleItemPointerdown);
1860
1021
  document.addEventListener('click', this._handleDocumentClick);
1861
1022
  }
1862
1023
  willUpdate() {
@@ -1899,21 +1060,20 @@ export class NLDDMenu extends LitElement {
1899
1060
  clearTimeout(this._tabbingTimer);
1900
1061
  this._tabbing = false;
1901
1062
  this.removeEventListener('mouseenter', this._handleMenuItemMouseenter, true);
1063
+ this.removeEventListener('mouseover', this._handleMouseover);
1902
1064
  this.removeEventListener('mouseleave', this._handleMouseleave);
1903
1065
  this.removeEventListener('menu-item-focused', this._handleMenuItemFocused);
1904
1066
  this.removeEventListener('submenu-open', this._handleSubmenuOpen);
1905
1067
  this.removeEventListener('select', this._collapseChain);
1906
- this.removeEventListener('pointerdown', this._handleItemPointerdown);
1907
1068
  document.removeEventListener('click', this._handleDocumentClick);
1908
- document.removeEventListener('pointerup', this._handleDragRelease, true);
1909
1069
  // Defensive: the pointerdown + resize listeners are added on open
1910
1070
  // and removed on close, but if the menu is torn down mid-open we'd
1911
1071
  // otherwise leak the global listeners.
1912
1072
  document.removeEventListener('pointerdown', this._handleDocumentPointerdown, true);
1913
- this._teardownOutsideTap();
1073
+ this._pointer.stopOutsideTap();
1914
1074
  window.removeEventListener('resize', this._handleWindowResize);
1915
1075
  this._cancelHoverOpen();
1916
- this._stopSafeTriangle();
1076
+ this._safeTriangle.stop();
1917
1077
  if (this._typeaheadTimer !== null) {
1918
1078
  clearTimeout(this._typeaheadTimer);
1919
1079
  this._typeaheadTimer = null;
@@ -2176,6 +1336,30 @@ export class NLDDMenu extends LitElement {
2176
1336
  top: `${y}px`,
2177
1337
  });
2178
1338
  }
1339
+ /**
1340
+ * Tab past the last item, or Shift+Tab before the first, of a menu that
1341
+ * hangs off a control. The menu lives in the top layer, often in `<body>`,
1342
+ * so left to the browser that Tab goes on from the end of the document and
1343
+ * skips everything after the control. It closes the menu and goes on from
1344
+ * the control instead: to what follows it, or back to it. A submenu leaves
1345
+ * Tab to its root menu, which sees no focused item of its own and lets the
1346
+ * browser move between the items.
1347
+ */
1348
+ _tabOut(event) {
1349
+ const anchor = this._getAnchorEl();
1350
+ if (!anchor || this._isSubmenu || !this.matches(':popover-open'))
1351
+ return false;
1352
+ const items = this._getVisibleItems();
1353
+ const index = items.findIndex((item) => item.matches(':focus-within'));
1354
+ if (index === -1 || index !== (event.shiftKey ? 0 : items.length - 1))
1355
+ return false;
1356
+ event.preventDefault();
1357
+ event.stopPropagation();
1358
+ const next = event.shiftKey ? anchor : nextTabbableAfter(anchor, this);
1359
+ this.hidePopover();
1360
+ (next ?? anchor).focus();
1361
+ return true;
1362
+ }
2179
1363
  /**
2180
1364
  * Whether focus went to the control that opens this menu. Closing here
2181
1365
  * would hand the click that follows a closed menu, and it would open it
@@ -2239,19 +1423,6 @@ export class NLDDMenu extends LitElement {
2239
1423
  }
2240
1424
  }
2241
1425
  NLDDMenu.styles = menuStyles;
2242
- /** When the cursor sits motionless inside the safe triangle for this
2243
- * long, dismiss the triangle and let whatever item is under the cursor
2244
- * become interactive. Without this, a paused cursor would stay
2245
- * "protected" indefinitely and the user couldn't peer-hover. */
2246
- NLDDMenu._SAFE_TRIANGLE_STALL_DISMISS_MS = 500;
2247
- /** Pull the wedge apex this many pixels away from the submenu edge (i.e.
2248
- * to the left when the submenu is on the right). Widens the wedge near
2249
- * the cursor so brief diagonal wobble doesn't pop the cursor out at the
2250
- * apex, and avoids the degenerate single-line wedge when the cursor
2251
- * crossed the opener edge exactly at the same x as the near submenu
2252
- * corner. The shift is always negative — the standard placement is
2253
- * submenu-right, so "left" is the intuitive forgive direction. */
2254
- NLDDMenu._SAFE_TRIANGLE_APEX_X_OFFSET = 4;
2255
1426
  /**
2256
1427
  * Drill-in mode is the touch-friendly rendering: a submenu replaces its
2257
1428
  * parent's view by anchoring to the root anchor (so visually it stacks
@@ -2267,17 +1438,6 @@ NLDDMenu._SAFE_TRIANGLE_APEX_X_OFFSET = 4;
2267
1438
  * is wasteful.
2268
1439
  */
2269
1440
  NLDDMenu._drillInModeQuery = null;
2270
- // — Touch-scroll press-flash suppression ————————————————————————————————
2271
- //
2272
- // On touch, pressing an item sets :active and the synthetic sticky
2273
- // :hover lands on it, so `.menu__item:active:hover` flashes. If the
2274
- // gesture becomes an internal scroll (cramped menu), :active lingers
2275
- // until the browser recognizes the pan and the highlight stays for
2276
- // the whole scroll. We detect a scroll from the touch delta and set
2277
- // `scroll-active` on the host; the styles neutralise the press flash
2278
- // while it's set. A pure tap never moves past the threshold, so its
2279
- // brief press feedback is preserved.
2280
- NLDDMenu._TOUCH_SCROLL_THRESHOLD_PX = 8;
2281
1441
  // — Lifecycle callbacks ————————————————————————————————————————————————————
2282
1442
  NLDDMenu._menuIdCounter = 0;
2283
1443
  /** Reset the typeahead buffer after this much idle time. 500ms is the
@@ -2297,6 +1457,9 @@ __decorate([
2297
1457
  __decorate([
2298
1458
  property({ attribute: false })
2299
1459
  ], NLDDMenu.prototype, "anchorElement", void 0);
1460
+ __decorate([
1461
+ property({ attribute: 'accessible-label' })
1462
+ ], NLDDMenu.prototype, "accessibleLabel", void 0);
2300
1463
  __decorate([
2301
1464
  property({ reflect: true, converter: reflectNonDefault('bottom-start') })
2302
1465
  ], NLDDMenu.prototype, "placement", void 0);