@nldd/design-system 0.13.0 → 0.13.1

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 (303) hide show
  1. package/custom-elements.json +3066 -753
  2. package/dist/components/actions/button/button.d.ts +6 -1
  3. package/dist/components/actions/button/button.d.ts.map +1 -1
  4. package/dist/components/actions/button/button.i18n.d.ts +1 -0
  5. package/dist/components/actions/button/button.i18n.d.ts.map +1 -1
  6. package/dist/components/actions/button/button.i18n.js +1 -0
  7. package/dist/components/actions/button/button.i18n.js.map +1 -1
  8. package/dist/components/actions/button/button.js +7 -0
  9. package/dist/components/actions/button/button.js.map +1 -1
  10. package/dist/components/actions/button/button.template.d.ts.map +1 -1
  11. package/dist/components/actions/button/button.template.js +5 -2
  12. package/dist/components/actions/button/button.template.js.map +1 -1
  13. package/dist/components/actions/icon-button/icon-button.d.ts +8 -1
  14. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  15. package/dist/components/actions/icon-button/icon-button.i18n.d.ts +1 -0
  16. package/dist/components/actions/icon-button/icon-button.i18n.d.ts.map +1 -1
  17. package/dist/components/actions/icon-button/icon-button.i18n.js +1 -0
  18. package/dist/components/actions/icon-button/icon-button.i18n.js.map +1 -1
  19. package/dist/components/actions/icon-button/icon-button.js +9 -0
  20. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  21. package/dist/components/actions/icon-button/icon-button.template.d.ts.map +1 -1
  22. package/dist/components/actions/icon-button/icon-button.template.js +5 -2
  23. package/dist/components/actions/icon-button/icon-button.template.js.map +1 -1
  24. package/dist/components/actions/menu/menu-divider.d.ts +14 -0
  25. package/dist/components/actions/menu/menu-divider.d.ts.map +1 -0
  26. package/dist/components/actions/menu/menu-divider.js +33 -0
  27. package/dist/components/actions/menu/menu-divider.js.map +1 -0
  28. package/dist/components/actions/menu/menu-group.d.ts +35 -0
  29. package/dist/components/actions/menu/menu-group.d.ts.map +1 -0
  30. package/dist/components/actions/menu/menu-group.js +69 -0
  31. package/dist/components/actions/menu/menu-group.js.map +1 -0
  32. package/dist/components/actions/menu/menu-item.d.ts +86 -0
  33. package/dist/components/actions/menu/menu-item.d.ts.map +1 -0
  34. package/dist/components/actions/menu/menu-item.js +279 -0
  35. package/dist/components/actions/menu/menu-item.js.map +1 -0
  36. package/dist/components/actions/menu/menu.chain.d.ts +40 -0
  37. package/dist/components/actions/menu/menu.chain.d.ts.map +1 -0
  38. package/dist/components/actions/menu/menu.chain.js +150 -0
  39. package/dist/components/actions/menu/menu.chain.js.map +1 -0
  40. package/dist/components/actions/menu/menu.d.ts +54 -269
  41. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  42. package/dist/components/actions/menu/menu.js +106 -984
  43. package/dist/components/actions/menu/menu.js.map +1 -1
  44. package/dist/components/actions/menu/menu.pointer.d.ts +61 -0
  45. package/dist/components/actions/menu/menu.pointer.d.ts.map +1 -0
  46. package/dist/components/actions/menu/menu.pointer.js +143 -0
  47. package/dist/components/actions/menu/menu.pointer.js.map +1 -0
  48. package/dist/components/actions/menu/menu.safe-triangle.d.ts +79 -0
  49. package/dist/components/actions/menu/menu.safe-triangle.d.ts.map +1 -0
  50. package/dist/components/actions/menu/menu.safe-triangle.js +198 -0
  51. package/dist/components/actions/menu/menu.safe-triangle.js.map +1 -0
  52. package/dist/components/actions/menu/menu.template.d.ts.map +1 -1
  53. package/dist/components/actions/menu/menu.template.js +5 -4
  54. package/dist/components/actions/menu/menu.template.js.map +1 -1
  55. package/dist/components/actions/toolbar/toolbar-item.d.ts +46 -0
  56. package/dist/components/actions/toolbar/toolbar-item.d.ts.map +1 -0
  57. package/dist/components/actions/toolbar/toolbar-item.js +113 -0
  58. package/dist/components/actions/toolbar/toolbar-item.js.map +1 -0
  59. package/dist/components/actions/toolbar/toolbar-item.template.d.ts +3 -0
  60. package/dist/components/actions/toolbar/toolbar-item.template.d.ts.map +1 -0
  61. package/dist/components/actions/toolbar/toolbar-item.template.js +12 -0
  62. package/dist/components/actions/toolbar/toolbar-item.template.js.map +1 -0
  63. package/dist/components/actions/toolbar/toolbar-title.d.ts +43 -0
  64. package/dist/components/actions/toolbar/toolbar-title.d.ts.map +1 -0
  65. package/dist/components/actions/toolbar/toolbar-title.js +111 -0
  66. package/dist/components/actions/toolbar/toolbar-title.js.map +1 -0
  67. package/dist/components/actions/toolbar/toolbar-title.template.d.ts +3 -0
  68. package/dist/components/actions/toolbar/toolbar-title.template.d.ts.map +1 -0
  69. package/dist/components/actions/toolbar/toolbar-title.template.js +33 -0
  70. package/dist/components/actions/toolbar/toolbar-title.template.js.map +1 -0
  71. package/dist/components/actions/toolbar/toolbar.d.ts +16 -111
  72. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  73. package/dist/components/actions/toolbar/toolbar.js +50 -423
  74. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  75. package/dist/components/actions/toolbar/toolbar.layout.d.ts +40 -0
  76. package/dist/components/actions/toolbar/toolbar.layout.d.ts.map +1 -0
  77. package/dist/components/actions/toolbar/toolbar.layout.js +76 -0
  78. package/dist/components/actions/toolbar/toolbar.layout.js.map +1 -0
  79. package/dist/components/actions/toolbar/toolbar.overflow-menu.d.ts +52 -0
  80. package/dist/components/actions/toolbar/toolbar.overflow-menu.d.ts.map +1 -0
  81. package/dist/components/actions/toolbar/toolbar.overflow-menu.js +105 -0
  82. package/dist/components/actions/toolbar/toolbar.overflow-menu.js.map +1 -0
  83. package/dist/components/actions/toolbar/toolbar.template.d.ts +1 -4
  84. package/dist/components/actions/toolbar/toolbar.template.d.ts.map +1 -1
  85. package/dist/components/actions/toolbar/toolbar.template.js +0 -41
  86. package/dist/components/actions/toolbar/toolbar.template.js.map +1 -1
  87. package/dist/components/{breakpoints-Bpf2MgjM.js → breakpoints-Bti55RWY.js} +1 -2
  88. package/dist/components/components.js +2170 -2156
  89. package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
  90. package/dist/components/content/code-viewer/code-viewer.styles.js +2 -1
  91. package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
  92. package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
  93. package/dist/components/content/icon/icon-aliases.js +11 -0
  94. package/dist/components/content/icon/icon-aliases.js.map +1 -1
  95. package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
  96. package/dist/components/content/icon/icon-gallery-status.js +6 -0
  97. package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
  98. package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
  99. package/dist/components/content/icon/icon-registry.js +6 -1
  100. package/dist/components/content/icon/icon-registry.js.map +1 -1
  101. package/dist/components/{decorate-CO88j7Lc.js → decorate-Cz9-peTN.js} +1 -2
  102. package/dist/components/{dist-B5E3q-ea.js → dist-B9YBOGFW.js} +4 -6
  103. package/dist/components/{dist-BWlUmyq3.js → dist-BFZM0YsR.js} +57 -36
  104. package/dist/components/{dist-BFw_yEMS.js → dist-BNkeFjc3.js} +5 -7
  105. package/dist/components/{dist-Co-tsc9S.js → dist-BaLc58I_.js} +7 -9
  106. package/dist/components/{dist-BOVSVPSz.js → dist-Bm3708s5.js} +3 -4
  107. package/dist/components/{dist-IPm8ilWf.js → dist-CJ9uLG0u.js} +5 -17
  108. package/dist/components/{dist-Dz28se9B.js → dist-CJm4tkNC.js} +4 -6
  109. package/dist/components/{dist-CC8oiVtm.js → dist-CSC1dG3L.js} +2 -3
  110. package/dist/components/{dist-BPB3rWnd.js → dist-DHhnz3Gv.js} +3 -4
  111. package/dist/components/{dist-Dn9pjiud.js → dist-DgjvHvsN.js} +6 -8
  112. package/dist/components/{dist-COKR0tYU.js → dist-PeUX4vPq.js} +3 -6
  113. package/dist/components/{dist-D_9ZyZ5v.js → dist-YYLChwRq.js} +5 -7
  114. package/dist/components/{dist-BNLAXAyO.js → dist-m70B83qb.js} +4 -6
  115. package/dist/components/{gherkin-uCVRxsGf.js → gherkin-DzYbEwDO.js} +1 -2
  116. package/dist/components/{icon-BJHKWhY5.js → icon-DZ1UXCzO.js} +21 -14
  117. package/dist/components/{icon-button-DhBIq6lN.js → icon-button-984CwkU1.js} +34 -44
  118. package/dist/components/{input-modality-DhTeUxKi.js → input-modality-CiPLYYMN.js} +1 -2
  119. package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
  120. package/dist/components/inputs/code-editor/code-editor.styles.js +6 -1
  121. package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
  122. package/dist/components/inputs/combo-box/combo-box.styles.d.ts.map +1 -1
  123. package/dist/components/inputs/combo-box/combo-box.styles.js +1 -0
  124. package/dist/components/inputs/combo-box/combo-box.styles.js.map +1 -1
  125. package/dist/components/inputs/date-field/date-field.d.ts +41 -28
  126. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
  127. package/dist/components/inputs/date-field/date-field.dates.d.ts +60 -0
  128. package/dist/components/inputs/date-field/date-field.dates.d.ts.map +1 -0
  129. package/dist/components/inputs/date-field/date-field.dates.js +106 -0
  130. package/dist/components/inputs/date-field/date-field.dates.js.map +1 -0
  131. package/dist/components/inputs/date-field/date-field.i18n.d.ts +4 -0
  132. package/dist/components/inputs/date-field/date-field.i18n.d.ts.map +1 -1
  133. package/dist/components/inputs/date-field/date-field.i18n.js +6 -0
  134. package/dist/components/inputs/date-field/date-field.i18n.js.map +1 -1
  135. package/dist/components/inputs/date-field/date-field.js +110 -142
  136. package/dist/components/inputs/date-field/date-field.js.map +1 -1
  137. package/dist/components/inputs/date-field/date-field.styles.d.ts.map +1 -1
  138. package/dist/components/inputs/date-field/date-field.styles.js +1 -0
  139. package/dist/components/inputs/date-field/date-field.styles.js.map +1 -1
  140. package/dist/components/inputs/date-field/date-field.template.d.ts.map +1 -1
  141. package/dist/components/inputs/date-field/date-field.template.js +21 -17
  142. package/dist/components/inputs/date-field/date-field.template.js.map +1 -1
  143. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.d.ts.map +1 -1
  144. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.js +1 -0
  145. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.js.map +1 -1
  146. package/dist/components/inputs/password-field/password-field.styles.d.ts.map +1 -1
  147. package/dist/components/inputs/password-field/password-field.styles.js +1 -0
  148. package/dist/components/inputs/password-field/password-field.styles.js.map +1 -1
  149. package/dist/components/inputs/search-field/search-field.d.ts +1 -1
  150. package/dist/components/inputs/search-field/search-field.js +1 -1
  151. package/dist/components/inputs/search-field/search-field.styles.d.ts.map +1 -1
  152. package/dist/components/inputs/search-field/search-field.styles.js +1 -0
  153. package/dist/components/inputs/search-field/search-field.styles.js.map +1 -1
  154. package/dist/components/inputs/segmented-control/segmented-control.d.ts +6 -3
  155. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  156. package/dist/components/inputs/segmented-control/segmented-control.js +8 -10
  157. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  158. package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -1
  159. package/dist/components/inputs/text-editor/text-editor.selection.js +35 -9
  160. package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -1
  161. package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
  162. package/dist/components/inputs/text-editor/text-editor.styles.js +17 -0
  163. package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
  164. package/dist/components/inputs/text-editor/text-editor.tasks.d.ts.map +1 -1
  165. package/dist/components/inputs/text-editor/text-editor.tasks.js +5 -1
  166. package/dist/components/inputs/text-editor/text-editor.tasks.js.map +1 -1
  167. package/dist/components/inputs/text-field/text-field.styles.d.ts.map +1 -1
  168. package/dist/components/inputs/text-field/text-field.styles.js +1 -0
  169. package/dist/components/inputs/text-field/text-field.styles.js.map +1 -1
  170. package/dist/components/inputs/time-field/time-field.d.ts +26 -40
  171. package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
  172. package/dist/components/inputs/time-field/time-field.i18n.d.ts +3 -0
  173. package/dist/components/inputs/time-field/time-field.i18n.d.ts.map +1 -1
  174. package/dist/components/inputs/time-field/time-field.i18n.js +5 -0
  175. package/dist/components/inputs/time-field/time-field.i18n.js.map +1 -1
  176. package/dist/components/inputs/time-field/time-field.js +68 -162
  177. package/dist/components/inputs/time-field/time-field.js.map +1 -1
  178. package/dist/components/inputs/time-field/time-field.styles.d.ts.map +1 -1
  179. package/dist/components/inputs/time-field/time-field.styles.js +1 -0
  180. package/dist/components/inputs/time-field/time-field.styles.js.map +1 -1
  181. package/dist/components/inputs/time-field/time-field.times.d.ts +74 -0
  182. package/dist/components/inputs/time-field/time-field.times.d.ts.map +1 -0
  183. package/dist/components/inputs/time-field/time-field.times.js +154 -0
  184. package/dist/components/inputs/time-field/time-field.times.js.map +1 -0
  185. package/dist/components/layout/card/card.d.ts +6 -1
  186. package/dist/components/layout/card/card.d.ts.map +1 -1
  187. package/dist/components/layout/card/card.i18n.d.ts +1 -0
  188. package/dist/components/layout/card/card.i18n.d.ts.map +1 -1
  189. package/dist/components/layout/card/card.i18n.js +1 -0
  190. package/dist/components/layout/card/card.i18n.js.map +1 -1
  191. package/dist/components/layout/card/card.js +7 -0
  192. package/dist/components/layout/card/card.js.map +1 -1
  193. package/dist/components/layout/card/card.template.d.ts.map +1 -1
  194. package/dist/components/layout/card/card.template.js +5 -2
  195. package/dist/components/layout/card/card.template.js.map +1 -1
  196. package/dist/components/layout/page/page.d.ts +3 -0
  197. package/dist/components/layout/page/page.d.ts.map +1 -1
  198. package/dist/components/layout/page/page.js +20 -3
  199. package/dist/components/layout/page/page.js.map +1 -1
  200. package/dist/components/layout/page/page.styles.d.ts.map +1 -1
  201. package/dist/components/layout/page/page.styles.js +25 -2
  202. package/dist/components/layout/page/page.styles.js.map +1 -1
  203. package/dist/components/layout/page/page.template.js +1 -1
  204. package/dist/components/layout/page/page.template.js.map +1 -1
  205. package/dist/components/layout/sheet/sheet.d.ts +5 -0
  206. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  207. package/dist/components/layout/sheet/sheet.js +14 -6
  208. package/dist/components/layout/sheet/sheet.js.map +1 -1
  209. package/dist/components/layout/sheet/sheet.template.d.ts.map +1 -1
  210. package/dist/components/layout/sheet/sheet.template.js +1 -0
  211. package/dist/components/layout/sheet/sheet.template.js.map +1 -1
  212. package/dist/components/lists-and-tables/list-item/list-item.d.ts +6 -1
  213. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  214. package/dist/components/lists-and-tables/list-item/list-item.i18n.d.ts +1 -0
  215. package/dist/components/lists-and-tables/list-item/list-item.i18n.d.ts.map +1 -1
  216. package/dist/components/lists-and-tables/list-item/list-item.i18n.js +1 -0
  217. package/dist/components/lists-and-tables/list-item/list-item.i18n.js.map +1 -1
  218. package/dist/components/lists-and-tables/list-item/list-item.js +12 -3
  219. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  220. package/dist/components/lists-and-tables/list-item/list-item.template.d.ts +1 -1
  221. package/dist/components/lists-and-tables/list-item/list-item.template.d.ts.map +1 -1
  222. package/dist/components/lists-and-tables/list-item/list-item.template.js +2 -1
  223. package/dist/components/lists-and-tables/list-item/list-item.template.js.map +1 -1
  224. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts +6 -1
  225. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts.map +1 -1
  226. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.d.ts +1 -0
  227. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.d.ts.map +1 -1
  228. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.js +1 -0
  229. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.i18n.js.map +1 -1
  230. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js +12 -3
  231. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js.map +1 -1
  232. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.d.ts +1 -1
  233. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.d.ts.map +1 -1
  234. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.js +2 -1
  235. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.template.js.map +1 -1
  236. package/dist/components/navigation/link/link.d.ts +6 -1
  237. package/dist/components/navigation/link/link.d.ts.map +1 -1
  238. package/dist/components/navigation/link/link.i18n.d.ts +1 -0
  239. package/dist/components/navigation/link/link.i18n.d.ts.map +1 -1
  240. package/dist/components/navigation/link/link.i18n.js +1 -0
  241. package/dist/components/navigation/link/link.i18n.js.map +1 -1
  242. package/dist/components/navigation/link/link.js +7 -0
  243. package/dist/components/navigation/link/link.js.map +1 -1
  244. package/dist/components/navigation/link/link.template.d.ts.map +1 -1
  245. package/dist/components/navigation/link/link.template.js +5 -2
  246. package/dist/components/navigation/link/link.template.js.map +1 -1
  247. package/dist/components/navigation/tab-bar/tab-bar.d.ts +1 -0
  248. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  249. package/dist/components/navigation/tab-bar/tab-bar.js +9 -0
  250. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  251. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +9 -24
  252. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
  253. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +29 -223
  254. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  255. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.d.ts +48 -0
  256. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.d.ts.map +1 -0
  257. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js +220 -0
  258. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.menu-sheet.js.map +1 -0
  259. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.d.ts.map +1 -1
  260. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js +22 -2
  261. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js.map +1 -1
  262. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.template.d.ts.map +1 -1
  263. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.template.js +4 -0
  264. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.template.js.map +1 -1
  265. package/dist/components/{reflect-non-default-OLaK60rT.js → reflect-non-default-B9wQcnne.js} +1 -2
  266. package/dist/components/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
  267. package/dist/components/{shadow-resets-CPa58rmc.js → shadow-resets-BwOyyZFH.js} +1 -2
  268. package/dist/components/{shell-C61GCsJA.js → shell-Dh5IwHd-.js} +1 -2
  269. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts +10 -1
  270. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts.map +1 -1
  271. package/dist/components/status-and-feedback/step-bar/step-bar.js +22 -1
  272. package/dist/components/status-and-feedback/step-bar/step-bar.js.map +1 -1
  273. package/dist/components/status-and-feedback/step-bar/step-bar.template.d.ts.map +1 -1
  274. package/dist/components/status-and-feedback/step-bar/step-bar.template.js +2 -0
  275. package/dist/components/status-and-feedback/step-bar/step-bar.template.js.map +1 -1
  276. package/dist/components/{toml-C2HBbPgG.js → toml-D0Pix_8Q.js} +1 -2
  277. package/dist/components/{visibility-mixin-djNSG5ZN.js → visibility-mixin-C-K7ho5Q.js} +4 -6
  278. package/dist/components/{with-translations-C6QfP6_S.js → with-translations-DRuOq3QK.js} +14 -10
  279. package/dist/nldd.min.js +846 -747
  280. package/dist/translations/en-US.d.ts.map +1 -1
  281. package/dist/translations/en-US.js +13 -0
  282. package/dist/translations/en-US.js.map +1 -1
  283. package/dist/translations/fy.d.ts.map +1 -1
  284. package/dist/translations/fy.js +13 -0
  285. package/dist/translations/fy.js.map +1 -1
  286. package/dist/translations/nl.generated.d.ts +13 -0
  287. package/dist/translations/nl.generated.d.ts.map +1 -1
  288. package/dist/translations/pap-AW.d.ts.map +1 -1
  289. package/dist/translations/pap-AW.js +13 -0
  290. package/dist/translations/pap-AW.js.map +1 -1
  291. package/dist/translations/pap-CW.d.ts.map +1 -1
  292. package/dist/translations/pap-CW.js +13 -0
  293. package/dist/translations/pap-CW.js.map +1 -1
  294. package/dist/types/vue.d.ts +57 -21
  295. package/dist/utilities/form-associated-mixin.d.ts +7 -0
  296. package/dist/utilities/form-associated-mixin.d.ts.map +1 -1
  297. package/dist/utilities/form-associated-mixin.js +13 -1
  298. package/dist/utilities/form-associated-mixin.js.map +1 -1
  299. package/dist/utilities/link-hint.d.ts +11 -0
  300. package/dist/utilities/link-hint.d.ts.map +1 -1
  301. package/dist/utilities/link-hint.js +15 -0
  302. package/dist/utilities/link-hint.js.map +1 -1
  303. package/package.json +2 -2
@@ -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,12 @@ 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
+ export { NLDDMenuItem } from './menu-item.js';
27
+ export { NLDDMenuGroup } from './menu-group.js';
28
+ export { NLDDMenuDivider } from './menu-divider.js';
372
29
  // # nldd-menu
373
30
  const defaultFilterFn = (query, item) => {
374
31
  const q = query.toLowerCase();
@@ -377,6 +34,22 @@ const defaultFilterFn = (query, item) => {
377
34
  const aliasesMatch = item.aliases !== '' && item.aliases.split(' ').some(s => s.toLowerCase().includes(q));
378
35
  return textMatch || valueMatch || aliasesMatch;
379
36
  };
37
+ /** The name of what a menu hangs off. A field that anchors its list to an
38
+ * element inside its own shadow root (nldd-token-field) has the name on its
39
+ * host, so a nameless anchor in a shadow root asks the host. The property is
40
+ * read before the attribute: nldd-form-field sets `accessibleLabel` as one. */
41
+ function nameOfAnchor(anchor) {
42
+ const name = (anchor.accessibleLabel
43
+ || anchor.getAttribute('accessible-label')
44
+ || anchor.getAttribute('aria-label')
45
+ || anchor.getAttribute('text')
46
+ || (anchor.shadowRoot ? '' : anchor.textContent)
47
+ || '').trim();
48
+ if (name)
49
+ return name;
50
+ const root = anchor.getRootNode();
51
+ return root instanceof ShadowRoot ? nameOfAnchor(root.host) : '';
52
+ }
380
53
  /**
381
54
  * A floating menu component using the Popover API.
382
55
  * Positioned relative to an anchor element using Floating UI.
@@ -391,6 +64,7 @@ const defaultFilterFn = (query, item) => {
391
64
  *
392
65
  * @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
66
  * @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)).
67
+ * @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
68
  * @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
69
  * @attr {string} placement - Floating UI placement. Default: 'bottom-start'.
396
70
  * @attr {number} max-items - Maximum number of visible items before scrolling. Sets --_menu-max-items internally. Default: 0 (no limit).
@@ -427,6 +101,7 @@ export class NLDDMenu extends LitElement {
427
101
  * nldd-token-field do: their input must stay an input, not a menu button.
428
102
  */
429
103
  this.anchorElement = null;
104
+ this.accessibleLabel = '';
430
105
  this.placement = 'bottom-start';
431
106
  /**
432
107
  * @internal Distance in px between the anchor and the menu, along the placement
@@ -471,34 +146,30 @@ export class NLDDMenu extends LitElement {
471
146
  * template (a separate module) reads them via `this`. */
472
147
  this._hasHeader = false;
473
148
  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. */
149
+ // — Submenu chain ——
150
+ // The open submenus are levels: see menu.chain.ts. These fields are what
151
+ // the levels and the rest of the menu read.
152
+ /** The submenu open from one of this menu's own items, and that item.
153
+ * null while none is open. @internal */
476
154
  this._activeSubmenu = null;
155
+ /** @internal */
477
156
  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;
157
+ /** The level of that submenu. @internal */
158
+ this._activeLevel = null;
484
159
  /** Signal that this menu is hiding itself to make room for a deeper drill-in
485
160
  * level — its parent's onToggle should skip the normal close cleanup
486
161
  * (re-parent + re-show) so the chain stays in deeper-level state. */
487
162
  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 */
163
+ /** Root-owned registry of every level open in this chain, in open order.
164
+ * Lives on the root only; submenus reach it via `_chainRoot`. Drives
165
+ * `_collapseChain()`, so collapsing the whole stack never depends on
166
+ * `_activeSubmenu`/`_parentMenu`, which real interaction can leave
167
+ * stale. @internal */
493
168
  this._openChain = [];
494
169
  /** Back-reference to the chain's root, set on every submenu when it
495
170
  * opens. Lets `_collapseChain()` find the registry without walking
496
171
  * the (possibly stale) parent links. null on the root. @internal */
497
172
  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
173
  /** When this menu is itself a submenu, points to the parent menu that
503
174
  * opened it. Set by the parent's _handleSubmenuOpen. null on the root.
504
175
  * @internal */
@@ -622,29 +293,12 @@ export class NLDDMenu extends LitElement {
622
293
  this.showPopover();
623
294
  }
624
295
  };
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.
296
+ // — Hover and the safe triangle (cascade only) ——————————————————————————
297
+ // See menu.safe-triangle.ts for the wedge that keeps a submenu open on a
298
+ // diagonal route to it.
641
299
  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;
300
+ /** @internal */
301
+ this._safeTriangle = new SafeTriangleController(this);
648
302
  this._handleMenuItemMouseenter = (event) => {
649
303
  // Touch suppress: synthesised mouseenter from touch (e.g. lifting
650
304
  // after a scroll gesture on a long menu) shouldn't paint a highlight.
@@ -663,8 +317,6 @@ export class NLDDMenu extends LitElement {
663
317
  // open. Click-outside (popover light-dismiss) is the only gesture
664
318
  // that collapses the chain.
665
319
  };
666
- // — Debug overlay ————————————————————————————————————————————————————
667
- this._safeTriangleOverlay = null;
668
320
  this._handleMenuItemFocused = (event) => {
669
321
  const item = event.target.closest('nldd-menu-item');
670
322
  if (!item || item.disabled || item.hasAttribute('hidden'))
@@ -678,9 +330,7 @@ export class NLDDMenu extends LitElement {
678
330
  };
679
331
  /**
680
332
  * 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.
333
+ * `submenu-open`, as a new level of the chain (menu.chain.ts).
684
334
  */
685
335
  this._handleSubmenuOpen = (event) => {
686
336
  // Only handle events from items that are direct children of this menu.
@@ -697,180 +347,7 @@ export class NLDDMenu extends LitElement {
697
347
  // the next close.
698
348
  if (this._activeSubmenu === submenu)
699
349
  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
- }
350
+ new SubmenuLevel(this, item, submenu, this._drillInMode).open();
874
351
  };
875
352
  /** Close this submenu when the back button is clicked, returning to the
876
353
  * parent view (which is still open as a popover behind this one in
@@ -886,34 +363,11 @@ export class NLDDMenu extends LitElement {
886
363
  this._handleBackMouseenter = () => {
887
364
  this._clearHighlight();
888
365
  };
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
- };
366
+ // — Pointer gestures ————————————————————————————————————————————————————
367
+ // Press-drag-release, no press flash while scrolling, and a tap beside a
368
+ // drill-in chain: see menu.pointer.ts.
900
369
  /** @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
- };
913
- /** @internal */
914
- this._handleMenuTouchEnd = () => {
915
- this.removeAttribute('scroll-active');
916
- };
370
+ this._pointer = new MenuPointerController(this);
917
371
  /** Close the menu on a window resize. Floating-UI's autoUpdate keeps
918
372
  * the position in sync with scrolls (where users genuinely expect the
919
373
  * menu to follow the anchor), but a full window resize is a layout-
@@ -932,8 +386,8 @@ export class NLDDMenu extends LitElement {
932
386
  * selecting an item, clicking the anchor, clicking/tapping outside, or
933
387
  * a viewport resize.
934
388
  *
935
- * Driven by the root's `_openChain` registry and each submenu's
936
- * `_collapseSelf`, so it never depends on `_activeSubmenu` /
389
+ * Driven by the root's `_openChain` registry of levels, so it never
390
+ * depends on `_activeSubmenu` /
937
391
  * `_parentMenu` threading being intact at collapse time — real
938
392
  * interaction can leave those stale, which was the source of the
939
393
  * recurring "anchor click doesn't close after the 2nd navigation"
@@ -947,7 +401,7 @@ export class NLDDMenu extends LitElement {
947
401
  const chain = root._openChain;
948
402
  root._openChain = [];
949
403
  for (let i = chain.length - 1; i >= 0; i--)
950
- chain[i]._collapseSelf?.();
404
+ chain[i].collapse();
951
405
  if (root._isOpen)
952
406
  root.hidePopover?.();
953
407
  };
@@ -978,43 +432,6 @@ export class NLDDMenu extends LitElement {
978
432
  * tap (pointerup without crossing the scroll threshold); a scroll
979
433
  * leaves the chain untouched, matching root-menu behavior.
980
434
  */
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
435
  this._handleDocumentPointerdown = (event) => {
1019
436
  if (!this._isOpen)
1020
437
  return;
@@ -1056,40 +473,15 @@ export class NLDDMenu extends LitElement {
1056
473
  // the chain doesn't collapse it (consistent with the root menu,
1057
474
  // which stays open while scrolling outside).
1058
475
  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);
476
+ this._pointer.trackOutsideTap(event, () => {
477
+ (this._chainRoot ?? this)._collapsedByPointerGesture = true;
478
+ this._collapseChain();
479
+ });
1066
480
  return;
1067
481
  }
1068
482
  (this._chainRoot ?? this)._collapsedByPointerGesture = true;
1069
483
  this._collapseChain();
1070
484
  };
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
485
  // — Private handlers ——————————————————————————————————————————————————————
1094
486
  this._handleKeydown = (event) => {
1095
487
  // Only a navigation menu closes on a Tab out; see _handleFocusOut.
@@ -1278,7 +670,7 @@ export class NLDDMenu extends LitElement {
1278
670
  this._cleanupAutoUpdate = null;
1279
671
  window.removeEventListener('resize', this._handleWindowResize);
1280
672
  document.removeEventListener('pointerdown', this._handleDocumentPointerdown, true);
1281
- this._teardownOutsideTap();
673
+ this._pointer.stopOutsideTap();
1282
674
  this._clearHighlight();
1283
675
  return;
1284
676
  }
@@ -1317,6 +709,7 @@ export class NLDDMenu extends LitElement {
1317
709
  };
1318
710
  }
1319
711
  // — i18n ——————————————————————————————————————————————————————————————————
712
+ /** @internal */
1320
713
  _t(key, vars) {
1321
714
  return translate(this.translations, nlddMenuTranslations, key, vars);
1322
715
  }
@@ -1344,6 +737,7 @@ export class NLDDMenu extends LitElement {
1344
737
  * announces only the level you land on); once flushed, the same text may
1345
738
  * be announced again for a later genuine transition (e.g. re-entering a
1346
739
  * submenu after going back).
740
+ * @internal
1347
741
  */
1348
742
  _announce(message) {
1349
743
  if (!message)
@@ -1410,7 +804,18 @@ export class NLDDMenu extends LitElement {
1410
804
  this._syncAnchorPopupState(this._isOpen);
1411
805
  }
1412
806
  }
807
+ /** @internal The name of the element with the menu or listbox role: its
808
+ * own, else the name of what it hangs off. */
809
+ get _listLabel() {
810
+ if (this.accessibleLabel)
811
+ return this.accessibleLabel;
812
+ if (this._parentItem?.text)
813
+ return this._parentItem.text;
814
+ const anchor = this._getAnchorEl();
815
+ return anchor ? nameOfAnchor(anchor) : '';
816
+ }
1413
817
  // — Anchor ————————————————————————————————————————————————————————————————
818
+ /** @internal */
1414
819
  _getAnchorEl() {
1415
820
  if (this.anchorElement)
1416
821
  return this.anchorElement;
@@ -1467,6 +872,27 @@ export class NLDDMenu extends LitElement {
1467
872
  anchor.popoverTargetAction = isOpen ? 'hide' : 'show';
1468
873
  }
1469
874
  }
875
+ /** @internal For the safe triangle: the item whose submenu is open. */
876
+ get safeTriangleOpener() {
877
+ return this._activeSubmenuOpener;
878
+ }
879
+ /** @internal For the safe triangle. */
880
+ highlightOpener() {
881
+ if (this._activeSubmenuOpener)
882
+ this._setHighlight(this._activeSubmenuOpener);
883
+ }
884
+ /** @internal For the safe triangle: whether a point is in `submenu` or a
885
+ * submenu below it, so a cursor that went on into a deeper submenu still
886
+ * reads as arrived rather than re-pinning a stale apex. */
887
+ isPointInSubmenus(p, submenu) {
888
+ let menu = submenu;
889
+ while (menu) {
890
+ if (rectContainsPoint(menu.getBoundingClientRect(), p))
891
+ return true;
892
+ menu = menu._activeSubmenu;
893
+ }
894
+ return false;
895
+ }
1470
896
  /**
1471
897
  * Item-activation logic shared between the native `mouseenter` capture
1472
898
  * handler and the safe-triangle recovery paths (sideways exit, direction
@@ -1490,7 +916,7 @@ export class NLDDMenu extends LitElement {
1490
916
  // submenu, peer items don't get highlighted and don't schedule
1491
917
  // hover-opens. Without this, the highlight flickers across every item
1492
918
  // the cursor brushes past on its diagonal route to the submenu.
1493
- if (this._movingTowardSubmenu && item !== this._activeSubmenuOpener)
919
+ if (this._safeTriangle.movingToward && item !== this._activeSubmenuOpener)
1494
920
  return;
1495
921
  this._setHighlight(item);
1496
922
  if (this._drillInMode)
@@ -1513,274 +939,22 @@ export class NLDDMenu extends LitElement {
1513
939
  }, 150);
1514
940
  }
1515
941
  }
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) {
942
+ /** @internal Resolve the menu-item under a viewport point and activate it
943
+ * via `_activateItem`. Used by the safe triangle, whose natural mouseenter
944
+ * has already fired (and bailed): it re-triggers activation without
945
+ * synthesizing a MouseEvent. */
946
+ activateItemAt(p) {
1521
947
  const el = document.elementFromPoint(p.x, p.y);
1522
948
  const item = el?.closest('nldd-menu-item');
1523
949
  if (item)
1524
950
  this._activateItem(item);
1525
951
  }
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
952
  _cancelHoverOpen() {
1748
953
  if (this._hoverOpenTimer !== null) {
1749
954
  clearTimeout(this._hoverOpenTimer);
1750
955
  this._hoverOpenTimer = null;
1751
956
  }
1752
957
  }
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
958
  static _getDrillInModeQuery() {
1785
959
  if (NLDDMenu._drillInModeQuery === null) {
1786
960
  // Use the shared breakpoint constant so the JS-side threshold can't
@@ -1806,37 +980,9 @@ export class NLDDMenu extends LitElement {
1806
980
  get _isSubmenu() {
1807
981
  return this._parentMenu !== null;
1808
982
  }
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);
983
+ /** @internal For the pointer gestures. */
984
+ get _isMenuOpen() {
985
+ return this._isOpen;
1840
986
  }
1841
987
  connectedCallback() {
1842
988
  super.connectedCallback();
@@ -1856,7 +1002,6 @@ export class NLDDMenu extends LitElement {
1856
1002
  this.addEventListener('menu-item-focused', this._handleMenuItemFocused);
1857
1003
  this.addEventListener('submenu-open', this._handleSubmenuOpen);
1858
1004
  this.addEventListener('select', this._collapseChain);
1859
- this.addEventListener('pointerdown', this._handleItemPointerdown);
1860
1005
  document.addEventListener('click', this._handleDocumentClick);
1861
1006
  }
1862
1007
  willUpdate() {
@@ -1903,17 +1048,15 @@ export class NLDDMenu extends LitElement {
1903
1048
  this.removeEventListener('menu-item-focused', this._handleMenuItemFocused);
1904
1049
  this.removeEventListener('submenu-open', this._handleSubmenuOpen);
1905
1050
  this.removeEventListener('select', this._collapseChain);
1906
- this.removeEventListener('pointerdown', this._handleItemPointerdown);
1907
1051
  document.removeEventListener('click', this._handleDocumentClick);
1908
- document.removeEventListener('pointerup', this._handleDragRelease, true);
1909
1052
  // Defensive: the pointerdown + resize listeners are added on open
1910
1053
  // and removed on close, but if the menu is torn down mid-open we'd
1911
1054
  // otherwise leak the global listeners.
1912
1055
  document.removeEventListener('pointerdown', this._handleDocumentPointerdown, true);
1913
- this._teardownOutsideTap();
1056
+ this._pointer.stopOutsideTap();
1914
1057
  window.removeEventListener('resize', this._handleWindowResize);
1915
1058
  this._cancelHoverOpen();
1916
- this._stopSafeTriangle();
1059
+ this._safeTriangle.stop();
1917
1060
  if (this._typeaheadTimer !== null) {
1918
1061
  clearTimeout(this._typeaheadTimer);
1919
1062
  this._typeaheadTimer = null;
@@ -2239,19 +1382,6 @@ export class NLDDMenu extends LitElement {
2239
1382
  }
2240
1383
  }
2241
1384
  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
1385
  /**
2256
1386
  * Drill-in mode is the touch-friendly rendering: a submenu replaces its
2257
1387
  * parent's view by anchoring to the root anchor (so visually it stacks
@@ -2267,17 +1397,6 @@ NLDDMenu._SAFE_TRIANGLE_APEX_X_OFFSET = 4;
2267
1397
  * is wasteful.
2268
1398
  */
2269
1399
  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
1400
  // — Lifecycle callbacks ————————————————————————————————————————————————————
2282
1401
  NLDDMenu._menuIdCounter = 0;
2283
1402
  /** Reset the typeahead buffer after this much idle time. 500ms is the
@@ -2297,6 +1416,9 @@ __decorate([
2297
1416
  __decorate([
2298
1417
  property({ attribute: false })
2299
1418
  ], NLDDMenu.prototype, "anchorElement", void 0);
1419
+ __decorate([
1420
+ property({ attribute: 'accessible-label' })
1421
+ ], NLDDMenu.prototype, "accessibleLabel", void 0);
2300
1422
  __decorate([
2301
1423
  property({ reflect: true, converter: reflectNonDefault('bottom-start') })
2302
1424
  ], NLDDMenu.prototype, "placement", void 0);