@nldd/design-system 0.8.98 → 0.8.100

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 (185) hide show
  1. package/custom-elements.json +320 -58
  2. package/dist/components/actions/button/button.d.ts +2 -2
  3. package/dist/components/actions/button/button.js +2 -2
  4. package/dist/components/actions/icon-button/icon-button.d.ts +2 -2
  5. package/dist/components/actions/icon-button/icon-button.js +2 -2
  6. package/dist/components/actions/menu/menu.d.ts +48 -5
  7. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  8. package/dist/components/actions/menu/menu.js +138 -8
  9. package/dist/components/actions/menu/menu.js.map +1 -1
  10. package/dist/components/actions/menu/menu.template.d.ts +4 -3
  11. package/dist/components/actions/menu/menu.template.d.ts.map +1 -1
  12. package/dist/components/actions/menu/menu.template.js +10 -5
  13. package/dist/components/actions/menu/menu.template.js.map +1 -1
  14. package/dist/components/actions/split-button/split-button.d.ts +1 -1
  15. package/dist/components/actions/split-button/split-button.js +1 -1
  16. package/dist/components/actions/toolbar/toolbar.d.ts +14 -3
  17. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  18. package/dist/components/actions/toolbar/toolbar.js +45 -7
  19. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  20. package/dist/components/actions/toolbar/toolbar.styles.d.ts.map +1 -1
  21. package/dist/components/actions/toolbar/toolbar.styles.js +15 -1
  22. package/dist/components/actions/toolbar/toolbar.styles.js.map +1 -1
  23. package/dist/components/components.js +1495 -289
  24. package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
  25. package/dist/components/content/code-viewer/code-viewer.styles.js +11 -7
  26. package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
  27. package/dist/components/content/text/text.d.ts +1 -1
  28. package/dist/components/content/text/text.js +1 -1
  29. package/dist/components/content/text/text.styles.d.ts.map +1 -1
  30. package/dist/components/content/text/text.styles.js +55 -0
  31. package/dist/components/content/text/text.styles.js.map +1 -1
  32. package/dist/components/content/title/title.d.ts +16 -1
  33. package/dist/components/content/title/title.d.ts.map +1 -1
  34. package/dist/components/content/title/title.js +109 -0
  35. package/dist/components/content/title/title.js.map +1 -1
  36. package/dist/components/content/title/title.styles.d.ts.map +1 -1
  37. package/dist/components/content/title/title.styles.js +39 -0
  38. package/dist/components/content/title/title.styles.js.map +1 -1
  39. package/dist/components/content/token/token.d.ts +1 -1
  40. package/dist/components/content/token/token.js +1 -1
  41. package/dist/components/content/visually-hidden/visually-hidden.d.ts +35 -0
  42. package/dist/components/content/visually-hidden/visually-hidden.d.ts.map +1 -0
  43. package/dist/components/content/visually-hidden/visually-hidden.js +45 -0
  44. package/dist/components/content/visually-hidden/visually-hidden.js.map +1 -0
  45. package/dist/components/content/visually-hidden/visually-hidden.styles.d.ts +2 -0
  46. package/dist/components/content/visually-hidden/visually-hidden.styles.d.ts.map +1 -0
  47. package/dist/components/content/visually-hidden/visually-hidden.styles.js +27 -0
  48. package/dist/components/content/visually-hidden/visually-hidden.styles.js.map +1 -0
  49. package/dist/components/content/visually-hidden/visually-hidden.template.d.ts +3 -0
  50. package/dist/components/content/visually-hidden/visually-hidden.template.d.ts.map +1 -0
  51. package/dist/components/content/visually-hidden/visually-hidden.template.js +7 -0
  52. package/dist/components/content/visually-hidden/visually-hidden.template.js.map +1 -0
  53. package/dist/components/{icon-button-CJIikwyu.js → icon-button-BtU8DX64.js} +2 -2
  54. package/dist/components/index.d.ts +1 -0
  55. package/dist/components/index.d.ts.map +1 -1
  56. package/dist/components/index.js +1 -0
  57. package/dist/components/index.js.map +1 -1
  58. package/dist/components/inputs/dropdown/dropdown.d.ts +6 -0
  59. package/dist/components/inputs/dropdown/dropdown.d.ts.map +1 -1
  60. package/dist/components/inputs/dropdown/dropdown.js +6 -0
  61. package/dist/components/inputs/dropdown/dropdown.js.map +1 -1
  62. package/dist/components/layout/card/card.d.ts +12 -1
  63. package/dist/components/layout/card/card.d.ts.map +1 -1
  64. package/dist/components/layout/card/card.js +29 -2
  65. package/dist/components/layout/card/card.js.map +1 -1
  66. package/dist/components/layout/card/card.styles.js +2 -2
  67. package/dist/components/layout/collection/collection.d.ts +16 -5
  68. package/dist/components/layout/collection/collection.d.ts.map +1 -1
  69. package/dist/components/layout/collection/collection.js +44 -10
  70. package/dist/components/layout/collection/collection.js.map +1 -1
  71. package/dist/components/layout/collection/collection.styles.d.ts.map +1 -1
  72. package/dist/components/layout/collection/collection.styles.js +7 -6
  73. package/dist/components/layout/collection/collection.styles.js.map +1 -1
  74. package/dist/components/layout/container/container.d.ts +1 -1
  75. package/dist/components/layout/container/container.js +1 -1
  76. package/dist/components/layout/container/container.styles.d.ts.map +1 -1
  77. package/dist/components/layout/container/container.styles.js +4 -0
  78. package/dist/components/layout/container/container.styles.js.map +1 -1
  79. package/dist/components/layout/page-sections/hero/hero-corner.d.ts +20 -0
  80. package/dist/components/layout/page-sections/hero/hero-corner.d.ts.map +1 -0
  81. package/dist/components/layout/page-sections/hero/hero-corner.js +103 -0
  82. package/dist/components/layout/page-sections/hero/hero-corner.js.map +1 -0
  83. package/dist/components/layout/page-sections/hero/hero-corner.styles.d.ts +2 -0
  84. package/dist/components/layout/page-sections/hero/hero-corner.styles.d.ts.map +1 -0
  85. package/dist/components/layout/page-sections/hero/hero-corner.styles.js +132 -0
  86. package/dist/components/layout/page-sections/hero/hero-corner.styles.js.map +1 -0
  87. package/dist/components/layout/page-sections/hero/hero.d.ts +9 -5
  88. package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
  89. package/dist/components/layout/page-sections/hero/hero.js +15 -6
  90. package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
  91. package/dist/components/layout/popover/popover.styles.d.ts.map +1 -1
  92. package/dist/components/layout/popover/popover.styles.js +4 -0
  93. package/dist/components/layout/popover/popover.styles.js.map +1 -1
  94. package/dist/components/layout/window/window.d.ts +1 -1
  95. package/dist/components/layout/window/window.js +1 -1
  96. package/dist/components/lists-and-tables/table/table.d.ts +8 -5
  97. package/dist/components/lists-and-tables/table/table.d.ts.map +1 -1
  98. package/dist/components/lists-and-tables/table/table.js +19 -10
  99. package/dist/components/lists-and-tables/table/table.js.map +1 -1
  100. package/dist/components/lists-and-tables/table/table.styles.d.ts.map +1 -1
  101. package/dist/components/lists-and-tables/table/table.styles.js +4 -0
  102. package/dist/components/lists-and-tables/table/table.styles.js.map +1 -1
  103. package/dist/components/lists-and-tables/table/table.template.d.ts.map +1 -1
  104. package/dist/components/lists-and-tables/table/table.template.js +5 -1
  105. package/dist/components/lists-and-tables/table/table.template.js.map +1 -1
  106. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts +44 -1
  107. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
  108. package/dist/components/navigation/document-tab-bar/document-tab-bar.js +132 -3
  109. package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
  110. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.d.ts.map +1 -1
  111. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js +21 -2
  112. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js.map +1 -1
  113. package/dist/components/navigation/document-tab-bar/document-tab-bar.template.js +1 -1
  114. package/dist/components/navigation/document-tab-bar/document-tab-bar.template.js.map +1 -1
  115. package/dist/components/navigation/link/link.d.ts +1 -1
  116. package/dist/components/navigation/link/link.js +1 -1
  117. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts +8 -2
  118. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
  119. package/dist/components/navigation/menu-bar-item/menu-bar-item.js +20 -2
  120. package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
  121. package/dist/components/navigation/menu-bar-item/menu-bar-item.template.d.ts.map +1 -1
  122. package/dist/components/navigation/menu-bar-item/menu-bar-item.template.js +8 -1
  123. package/dist/components/navigation/menu-bar-item/menu-bar-item.template.js.map +1 -1
  124. package/dist/components/navigation/pagination/pagination.d.ts +1 -1
  125. package/dist/components/navigation/pagination/pagination.js +1 -1
  126. package/dist/components/navigation/skip-link/skip-link.d.ts +12 -5
  127. package/dist/components/navigation/skip-link/skip-link.d.ts.map +1 -1
  128. package/dist/components/navigation/skip-link/skip-link.js +12 -5
  129. package/dist/components/navigation/skip-link/skip-link.js.map +1 -1
  130. package/dist/components/navigation/tab-bar/tab-bar.d.ts +71 -2
  131. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  132. package/dist/components/navigation/tab-bar/tab-bar.i18n.d.ts +5 -0
  133. package/dist/components/navigation/tab-bar/tab-bar.i18n.d.ts.map +1 -0
  134. package/dist/components/navigation/tab-bar/tab-bar.i18n.js +4 -0
  135. package/dist/components/navigation/tab-bar/tab-bar.i18n.js.map +1 -0
  136. package/dist/components/navigation/tab-bar/tab-bar.js +214 -23
  137. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  138. package/dist/components/navigation/tab-bar/tab-bar.styles.d.ts.map +1 -1
  139. package/dist/components/navigation/tab-bar/tab-bar.styles.js +68 -3
  140. package/dist/components/navigation/tab-bar/tab-bar.styles.js.map +1 -1
  141. package/dist/components/navigation/tab-bar/tab-bar.template.d.ts.map +1 -1
  142. package/dist/components/navigation/tab-bar/tab-bar.template.js +36 -5
  143. package/dist/components/navigation/tab-bar/tab-bar.template.js.map +1 -1
  144. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +7 -0
  145. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
  146. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +16 -0
  147. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  148. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.d.ts.map +1 -1
  149. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js +13 -3
  150. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.styles.js.map +1 -1
  151. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts +11 -1
  152. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts.map +1 -1
  153. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +21 -1
  154. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js.map +1 -1
  155. package/dist/components/status-and-feedback/notification/notification.d.ts +62 -1
  156. package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
  157. package/dist/components/status-and-feedback/notification/notification.js +86 -2
  158. package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
  159. package/dist/components/status-and-feedback/notification/notifications-area.d.ts +6 -0
  160. package/dist/components/status-and-feedback/notification/notifications-area.d.ts.map +1 -1
  161. package/dist/components/status-and-feedback/notification/notifications-area.js +16 -0
  162. package/dist/components/status-and-feedback/notification/notifications-area.js.map +1 -1
  163. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts +1 -1
  164. package/dist/components/status-and-feedback/step-bar/step-bar.js +1 -1
  165. package/dist/css/rich-text.css +1 -1
  166. package/dist/css/variables.css +1 -0
  167. package/dist/nldd.min.js +1038 -637
  168. package/dist/translations/en-US.d.ts.map +1 -1
  169. package/dist/translations/en-US.js +1 -0
  170. package/dist/translations/en-US.js.map +1 -1
  171. package/dist/translations/fy.d.ts.map +1 -1
  172. package/dist/translations/fy.js +1 -0
  173. package/dist/translations/fy.js.map +1 -1
  174. package/dist/translations/nl.generated.d.ts +1 -0
  175. package/dist/translations/nl.generated.d.ts.map +1 -1
  176. package/dist/translations/nl.generated.js +2 -0
  177. package/dist/translations/nl.generated.js.map +1 -1
  178. package/dist/translations/pap-AW.d.ts.map +1 -1
  179. package/dist/translations/pap-AW.js +1 -0
  180. package/dist/translations/pap-AW.js.map +1 -1
  181. package/dist/translations/pap-CW.d.ts.map +1 -1
  182. package/dist/translations/pap-CW.js +1 -0
  183. package/dist/translations/pap-CW.js.map +1 -1
  184. package/dist/types/vue.d.ts +66 -36
  185. package/package.json +6 -2
@@ -5,9 +5,9 @@
5
5
  * @attr {string} appearance - Visual style, color included: 'primary' | 'secondary' | 'destructive' | 'accent-filled' | 'accent-transparent' | 'neutral-tinted' | 'neutral-base' | 'neutral-transparent' | 'critical-tinted' | 'critical-transparent' | 'inherit-filled' | 'inherit-tinted'. The inherit appearances derive their colors from currentColor, for buttons on colored surfaces; inherit-filled uses the surface color (--context-parent-background-color) as the label color, with a white/black contrast flip as a fallback.
6
6
  * @attr {string} size - Button size: 'xs' | 'sm' | 'md' | 'lg' (default: 'md'). 'lg' uses larger text and 24px start/end icons.
7
7
  * @attr {string} horizontal-alignment - Horizontal alignment of the button content: 'left' | 'center' | 'right' (default: unset, centered). Most visible with width="full" or a fixed width.
8
- * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden content, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled). The content stays laid out, so the button keeps its width.
8
+ * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden content, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled). The content stays laid out, so the button keeps its width. Meant for an action that has to wait for the server, such as sending an application. For most actions, show the result right away and confirm in the background, as the design guidelines describe.
9
9
  * @attr {string} loading-text - What the screen reader announces while `loading` is on, for a button that does more than load: "Aan het bewaren". Leave it out and the activity indicator says its translated "Laden".
10
- * @attr {boolean} disabled - Disabled state
10
+ * @attr {boolean} disabled - Disabled state. Avoid it: let the action run and say afterwards what is missing; the design guidelines say why.
11
11
  * @attr {string} type - Button type for form submission: 'button' | 'submit' | 'reset' (ignored when href is set)
12
12
  * @attr {string} popovertarget - ID of a popover element this button invokes; forwarded to the inner button. Use the popoverTargetElement property instead when the popover lives in another tree.
13
13
  * @attr {boolean} expandable - Whether the button has a icon to indicate it opens a menu or popover
@@ -5,9 +5,9 @@
5
5
  * @attr {string} appearance - Visual style, color included: 'primary' | 'secondary' | 'destructive' | 'accent-filled' | 'accent-transparent' | 'neutral-tinted' | 'neutral-base' | 'neutral-transparent' | 'critical-tinted' | 'critical-transparent' | 'inherit-filled' | 'inherit-tinted'. The inherit appearances derive their colors from currentColor, for buttons on colored surfaces; inherit-filled uses the surface color (--context-parent-background-color) as the label color, with a white/black contrast flip as a fallback.
6
6
  * @attr {string} size - Button size: 'xs' | 'sm' | 'md' | 'lg' (default: 'md'). 'lg' uses larger text and 24px start/end icons.
7
7
  * @attr {string} horizontal-alignment - Horizontal alignment of the button content: 'left' | 'center' | 'right' (default: unset, centered). Most visible with width="full" or a fixed width.
8
- * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden content, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled). The content stays laid out, so the button keeps its width.
8
+ * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden content, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled). The content stays laid out, so the button keeps its width. Meant for an action that has to wait for the server, such as sending an application. For most actions, show the result right away and confirm in the background, as the design guidelines describe.
9
9
  * @attr {string} loading-text - What the screen reader announces while `loading` is on, for a button that does more than load: "Aan het bewaren". Leave it out and the activity indicator says its translated "Laden".
10
- * @attr {boolean} disabled - Disabled state
10
+ * @attr {boolean} disabled - Disabled state. Avoid it: let the action run and say afterwards what is missing; the design guidelines say why.
11
11
  * @attr {string} type - Button type for form submission: 'button' | 'submit' | 'reset' (ignored when href is set)
12
12
  * @attr {string} popovertarget - ID of a popover element this button invokes; forwarded to the inner button. Use the popoverTargetElement property instead when the popover lives in another tree.
13
13
  * @attr {boolean} expandable - Whether the button has a icon to indicate it opens a menu or popover
@@ -6,9 +6,9 @@
6
6
  * @attr {string} size - Button size: 'xs' | 'sm' | 'md' | 'lg' (default: 'md')
7
7
  * @attr {boolean} hide-lg-text - In lg size, hides the text label and enlarges the icon by one step (28px)
8
8
  * @attr {boolean} no-highlight-border - Removes the per-appearance highlight border (e.g. when a control group draws a single border instead).
9
- * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden icon, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled).
9
+ * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden icon, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled). Meant for an action that has to wait for the server, such as sending an application. For most actions, show the result right away and confirm in the background, as the design guidelines describe.
10
10
  * @attr {string} loading-text - What the screen reader announces while `loading` is on, for a button that does more than load: "Aan het bewaren". Leave it out and the activity indicator says its translated "Laden".
11
- * @attr {boolean} disabled - Disabled state
11
+ * @attr {boolean} disabled - Disabled state. Avoid it: let the action run and say afterwards what is missing; the design guidelines say why.
12
12
  * @attr {boolean} no-tab - Takes the button out of the tab order (tabindex="-1"), for a control owned by a roving container (an nldd-token in nldd-token-field, a button in a row of an nldd-list) that manages focus itself. Still mouse- and script-focusable.
13
13
  * @attr {string} type - Button type for form submission: 'button' | 'submit' | 'reset' (ignored when href is set)
14
14
  * @attr {boolean} expandable - Whether the button opens a menu or popover and shows chevron next to the icon
@@ -12,9 +12,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
12
12
  * @attr {string} size - Button size: 'xs' | 'sm' | 'md' | 'lg' (default: 'md')
13
13
  * @attr {boolean} hide-lg-text - In lg size, hides the text label and enlarges the icon by one step (28px)
14
14
  * @attr {boolean} no-highlight-border - Removes the per-appearance highlight border (e.g. when a control group draws a single border instead).
15
- * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden icon, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled).
15
+ * @attr {boolean} loading - Loading state (default: false). Shows an activity indicator over the visually hidden icon, sets aria-busy on the inner control and blocks activation, without dropping the button from the tab order (unlike disabled). Meant for an action that has to wait for the server, such as sending an application. For most actions, show the result right away and confirm in the background, as the design guidelines describe.
16
16
  * @attr {string} loading-text - What the screen reader announces while `loading` is on, for a button that does more than load: "Aan het bewaren". Leave it out and the activity indicator says its translated "Laden".
17
- * @attr {boolean} disabled - Disabled state
17
+ * @attr {boolean} disabled - Disabled state. Avoid it: let the action run and say afterwards what is missing; the design guidelines say why.
18
18
  * @attr {boolean} no-tab - Takes the button out of the tab order (tabindex="-1"), for a control owned by a roving container (an nldd-token in nldd-token-field, a button in a row of an nldd-list) that manages focus itself. Still mouse- and script-focusable.
19
19
  * @attr {string} type - Button type for form submission: 'button' | 'submit' | 'reset' (ignored when href is set)
20
20
  * @attr {boolean} expandable - Whether the button opens a menu or popover and shows chevron next to the icon
@@ -1,4 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
+ import { type MenuVariant } from './menu.template.js';
2
3
  import type { NLDDMenuTranslations } from './menu.i18n.js';
3
4
  import type { QueryMarkMode } from '../../../utilities/render-marked.js';
4
5
  import '../../lists-and-tables/cells/icon-cell/icon-cell.js';
@@ -14,6 +15,8 @@ import '../../status-and-feedback/inline-dialog/inline-dialog.js';
14
15
  */
15
16
  export declare class NLDDMenuDivider extends LitElement {
16
17
  static styles: import("lit").CSSResult;
18
+ /** @internal The variant of the menu around it, set by that nldd-menu. */
19
+ menuVariant: MenuVariant | null;
17
20
  render(): import("lit-html").TemplateResult<1>;
18
21
  }
19
22
  /**
@@ -43,6 +46,9 @@ export declare class NLDDMenuGroup extends LitElement {
43
46
  text: string;
44
47
  private static _idCounter;
45
48
  readonly _titleId: string;
49
+ /** @internal The variant of the menu around it, set by that nldd-menu. */
50
+ menuVariant: MenuVariant | null;
51
+ updated(changed: Map<string, unknown>): void;
46
52
  render(): import("lit-html").TemplateResult<1>;
47
53
  }
48
54
  /**
@@ -95,7 +101,7 @@ export declare class NLDDMenuItem extends LitElement {
95
101
  * into the real menu when it collapses. The clone is claimed there and the
96
102
  * declaration stays what it is.
97
103
  */
98
- menuVariant: 'menu' | 'listbox' | null;
104
+ menuVariant: MenuVariant | null;
99
105
  /** Whether this item keeps the check-mark column free without being
100
106
  * checkable, because another item in its menu is. Set by that nldd-menu.
101
107
  * Not part of the public API. */
@@ -134,6 +140,7 @@ export declare class NLDDMenuItem extends LitElement {
134
140
  *
135
141
  * @element nldd-menu
136
142
  *
143
+ * @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.
137
144
  * @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)).
138
145
  * @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.
139
146
  * @attr {string} placement - Floating UI placement. Default: 'bottom-start'.
@@ -151,11 +158,10 @@ export declare class NLDDMenuItem extends LitElement {
151
158
  export declare class NLDDMenu extends LitElement {
152
159
  static styles: import("lit").CSSResult;
153
160
  /**
154
- * Render variant. Use 'listbox' when the menu serves as a combobox popup —
155
- * this switches role to "listbox" and item roles to "option" per ARIA spec.
156
- * Default: 'menu'.
161
+ * What the menu is, which sets its roles and part of its keyboard. See the
162
+ * `variant` attribute in the docblock above.
157
163
  */
158
- variant: 'menu' | 'listbox';
164
+ variant: MenuVariant;
159
165
  /**
160
166
  * Explicit width, pinned exactly (sets --_menu-width and clamps min/max to it).
161
167
  * Leave unset to let the menu size to its content between a minimum and a
@@ -172,6 +178,15 @@ export declare class NLDDMenu extends LitElement {
172
178
  */
173
179
  anchorElement: Element | null;
174
180
  placement: string;
181
+ /**
182
+ * @internal Distance in px between the anchor and the menu, along the placement
183
+ * side; negative pulls the menu in. Set by a component that hangs a menu
184
+ * off itself and draws its own edge inside its box, such as
185
+ * nldd-menu-bar-item, whose indicator stops short of the item. Not an
186
+ * attribute: the anchor knows that inset, the consumer does not. Set it on
187
+ * every open: the menu puts it back to 0 when it closes.
188
+ */
189
+ anchorOffset: number;
175
190
  /**
176
191
  * Maximum number of visible items before the menu scrolls.
177
192
  * Sets --_menu-max-items internally. Default: 0 (no limit).
@@ -333,6 +348,9 @@ export declare class NLDDMenu extends LitElement {
333
348
  * update that never arrived.
334
349
  */
335
350
  private _resyncAnchorFromPopoverState;
351
+ /** The popup type this menu gave its anchor, so a later variant can take
352
+ * it back without touching one the consumer chose. */
353
+ private _seededPopupType;
336
354
  private _syncAnchorPopupState;
337
355
  private _handleDocumentClick;
338
356
  private _hoverOpenTimer;
@@ -622,6 +640,27 @@ export declare class NLDDMenu extends LitElement {
622
640
  /** Recalculate position and size relative to the anchor element. */
623
641
  reposition(): Promise<void>;
624
642
  private _handleKeydown;
643
+ /**
644
+ * A navigation menu closes when focus leaves it, the way a disclosure in a
645
+ * site navigation does: Tab past the last link and the menu is gone, with
646
+ * nothing left open over the page. An action menu keeps its own rules.
647
+ *
648
+ * Only when focus goes somewhere, or when Tab took it. Without a target it
649
+ * is the window losing focus or a press on something that takes none, and
650
+ * light dismiss covers those. Tab past the last link of the page has no
651
+ * target either, though, and that one does leave the menu.
652
+ */
653
+ private _handleFocusOut;
654
+ /**
655
+ * Whether focus went to the control that opens this menu. Closing here
656
+ * would hand the click that follows a closed menu, and it would open it
657
+ * again; the toggle on the anchor does the closing. The node arrives
658
+ * retargeted, so an anchor inside a shadow root shows up as its host.
659
+ */
660
+ private _isAnchor;
661
+ /** True from a Tab keydown until the focus change it causes has happened. */
662
+ private _tabbing;
663
+ private _tabbingTimer?;
625
664
  private _typeaheadBuffer;
626
665
  private _typeaheadTimer;
627
666
  /** Reset the typeahead buffer after this much idle time. 500ms is the
@@ -659,6 +698,10 @@ export declare class NLDDMenu extends LitElement {
659
698
  * place. A submenu's items are its own and are left to it.
660
699
  */
661
700
  _claimItems: () => void;
701
+ private _warnedActionsInNavigation;
702
+ private _warnedFilterInNavigation;
703
+ /** Checkable items and shortcuts belong to actions, not to a list of links. */
704
+ private _warnOnActionsInNavigation;
662
705
  private _handleBeforeToggle;
663
706
  private _handleToggle;
664
707
  render(): import("lit-html").TemplateResult<1>;
@@ -1 +1 @@
1
- {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/menu/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAOjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,qDAAqD,CAAC;AAC7D,OAAO,yDAAyD,CAAC;AACjE,OAAO,qDAAqD,CAAC;AAC7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,sDAAsD,CAAC;AAC9D,OAAO,0DAA0D,CAAC;AAQlE;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC9C,OAAgB,MAAM,0BAAqB;IAElC,MAAM;CAGf;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAC5C,OAAgB,MAAM,0BAAmB;IAGzC,IAAI,SAAM;IAOV,OAAO,CAAC,MAAM,CAAC,UAAU,CAAK;IAC9B,QAAQ,CAAC,QAAQ,SAAyD;IAEjE,MAAM;CAGf;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC3C,OAAgB,MAAM,0BAAkB;IAGxC,WAAW,UAAS;IAGpB,IAAI,SAAM;IAGV,OAAO,SAAM;IAGb,IAAI,SAAM;IAGV,QAAQ,SAAM;IAGd,WAAW,SAAM;IAGjB,eAAe,SAAM;IAGrB,aAAa,SAAM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AAgB,CAAM;IAC9B,OAAO,CAAC,eAAe,CAAuB;IAC9C;;;uBAGmB;IACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAO;IAElD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;;;;;;;;;;;;;;OAgBG;IACI,WAAW,QAAO,IAAI,CAkB3B;IAEF,OAAO,CAAC,0BAA0B,CAAS;IAC3C,OAAO,CAAC,yBAAyB,CAAS;IAE1C,+EAA+E;IAC/E,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,mBAAmB,CAEzB;IAEF,OAAO,CAAC,aAAa,CA2DnB;IAEO,MAAM;CAGf;AAMD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,WAAW,EAAE,QAAQ,CAAC;QACtB,gBAAgB,EAAE,YAAY,CAAC;QAC/B,mBAAmB,EAAE,eAAe,CAAC;QACrC,iBAAiB,EAAE,aAAa,CAAC;KACjC;CACD"}
@@ -20,6 +20,15 @@ import '../../status-and-feedback/inline-dialog/inline-dialog.js';
20
20
  import { isKeyboardMode, isTouchMode } from '../../../utilities/input-modality.js';
21
21
  import { breakpoints } from '../../../assets/styles/breakpoints.js';
22
22
  import { translate } from '../../../utilities/translations.js';
23
+ /** Makes `host` a list item while its menu is a navigation menu, and takes
24
+ * that back when it is not. A `listitem` the consumer set by hand on an item
25
+ * goes too when the variant changes back; nothing else uses that role here. */
26
+ function syncListItemRole(host, variant) {
27
+ if (variant === 'navigation')
28
+ host.setAttribute('role', 'listitem');
29
+ else if (host.getAttribute('role') === 'listitem')
30
+ host.removeAttribute('role');
31
+ }
23
32
  // # nldd-menu-divider
24
33
  /**
25
34
  * A horizontal rule between groups of items in an `nldd-menu`.
@@ -27,11 +36,19 @@ import { translate } from '../../../utilities/translations.js';
27
36
  * @element nldd-menu-divider
28
37
  */
29
38
  export class NLDDMenuDivider extends LitElement {
39
+ constructor() {
40
+ super(...arguments);
41
+ /** @internal The variant of the menu around it, set by that nldd-menu. */
42
+ this.menuVariant = null;
43
+ }
30
44
  render() {
31
- return menuDividerTemplate();
45
+ return menuDividerTemplate(this.menuVariant);
32
46
  }
33
47
  }
34
48
  NLDDMenuDivider.styles = menuDividerStyles;
49
+ __decorate([
50
+ state()
51
+ ], NLDDMenuDivider.prototype, "menuVariant", void 0);
35
52
  if (!customElements.get('nldd-menu-divider')) {
36
53
  customElements.define('nldd-menu-divider', NLDDMenuDivider);
37
54
  }
@@ -63,6 +80,14 @@ export class NLDDMenuGroup extends LitElement {
63
80
  super(...arguments);
64
81
  this.text = '';
65
82
  this._titleId = `nldd-menu-group-title-${NLDDMenuGroup._idCounter++}`;
83
+ /** @internal The variant of the menu around it, set by that nldd-menu. */
84
+ this.menuVariant = null;
85
+ }
86
+ updated(changed) {
87
+ // In a navigation menu the group is a list item that holds a list of
88
+ // its own, named by the title: a list may only own list items.
89
+ if (changed.has('menuVariant'))
90
+ syncListItemRole(this, this.menuVariant);
66
91
  }
67
92
  render() {
68
93
  return menuGroupTemplate(this);
@@ -78,6 +103,9 @@ NLDDMenuGroup._idCounter = 0;
78
103
  __decorate([
79
104
  property({ reflect: true, converter: reflectNonDefault('') })
80
105
  ], NLDDMenuGroup.prototype, "text", void 0);
106
+ __decorate([
107
+ state()
108
+ ], NLDDMenuGroup.prototype, "menuVariant", void 0);
81
109
  if (!customElements.get('nldd-menu-group')) {
82
110
  customElements.define('nldd-menu-group', NLDDMenuGroup);
83
111
  }
@@ -197,6 +225,10 @@ export class NLDDMenuItem extends LitElement {
197
225
  this._cachedSubmenuEl = this.querySelector(':scope > nldd-menu');
198
226
  }
199
227
  updated(changedProperties) {
228
+ // In a navigation menu the item is a list item, and the link inside it
229
+ // is just a link.
230
+ if (changedProperties.has('menuVariant'))
231
+ syncListItemRole(this, this.menuVariant);
200
232
  // An item that becomes checkable, or stops being so, changes whether its
201
233
  // menu reserves the check-mark column, also while the menu is open.
202
234
  if (changedProperties.has('type') && changedProperties.get('type') !== undefined && this.menuVariant) {
@@ -356,6 +388,7 @@ const defaultFilterFn = (query, item) => {
356
388
  *
357
389
  * @element nldd-menu
358
390
  *
391
+ * @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.
359
392
  * @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)).
360
393
  * @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.
361
394
  * @attr {string} placement - Floating UI placement. Default: 'bottom-start'.
@@ -374,9 +407,8 @@ export class NLDDMenu extends LitElement {
374
407
  constructor() {
375
408
  super(...arguments);
376
409
  /**
377
- * Render variant. Use 'listbox' when the menu serves as a combobox popup —
378
- * this switches role to "listbox" and item roles to "option" per ARIA spec.
379
- * Default: 'menu'.
410
+ * What the menu is, which sets its roles and part of its keyboard. See the
411
+ * `variant` attribute in the docblock above.
380
412
  */
381
413
  this.variant = 'menu';
382
414
  /**
@@ -395,6 +427,15 @@ export class NLDDMenu extends LitElement {
395
427
  */
396
428
  this.anchorElement = null;
397
429
  this.placement = 'bottom-start';
430
+ /**
431
+ * @internal Distance in px between the anchor and the menu, along the placement
432
+ * side; negative pulls the menu in. Set by a component that hangs a menu
433
+ * off itself and draws its own edge inside its box, such as
434
+ * nldd-menu-bar-item, whose indicator stops short of the item. Not an
435
+ * attribute: the anchor knows that inset, the consumer does not. Set it on
436
+ * every open: the menu puts it back to 0 when it closes.
437
+ */
438
+ this.anchorOffset = 0;
398
439
  /**
399
440
  * Maximum number of visible items before the menu scrolls.
400
441
  * Sets --_menu-max-items internally. Default: 0 (no limit).
@@ -538,6 +579,9 @@ export class NLDDMenu extends LitElement {
538
579
  this._isOpen = reallyOpen;
539
580
  this._syncAnchorPopupState(reallyOpen);
540
581
  };
582
+ /** The popup type this menu gave its anchor, so a later variant can take
583
+ * it back without touching one the consumer chose. */
584
+ this._seededPopupType = null;
541
585
  // — Event handlers ————————————————————————————————————————————————————————
542
586
  this._handleDocumentClick = (event) => {
543
587
  if (this.anchorElement)
@@ -1045,6 +1089,12 @@ export class NLDDMenu extends LitElement {
1045
1089
  };
1046
1090
  // — Private handlers ——————————————————————————————————————————————————————
1047
1091
  this._handleKeydown = (event) => {
1092
+ // Only a navigation menu closes on a Tab out; see _handleFocusOut.
1093
+ if (event.key === 'Tab' && this.variant === 'navigation') {
1094
+ this._tabbing = true;
1095
+ clearTimeout(this._tabbingTimer);
1096
+ this._tabbingTimer = setTimeout(() => { this._tabbing = false; });
1097
+ }
1048
1098
  const items = this._getVisibleItems();
1049
1099
  if (items.length === 0)
1050
1100
  return;
@@ -1128,12 +1178,36 @@ export class NLDDMenu extends LitElement {
1128
1178
  // Typeahead (ARIA APG menu pattern): typing a single printable
1129
1179
  // character jumps to the next item whose visible text starts
1130
1180
  // with it. Repeated presses cycle through matches.
1131
- if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
1181
+ // Not in a navigation menu: there the letter keys are the screen
1182
+ // reader's, for moving through links and headings.
1183
+ if (this.variant !== 'navigation' && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
1132
1184
  this._handleTypeahead(event, items, index);
1133
1185
  }
1134
1186
  }
1135
1187
  }
1136
1188
  };
1189
+ /**
1190
+ * A navigation menu closes when focus leaves it, the way a disclosure in a
1191
+ * site navigation does: Tab past the last link and the menu is gone, with
1192
+ * nothing left open over the page. An action menu keeps its own rules.
1193
+ *
1194
+ * Only when focus goes somewhere, or when Tab took it. Without a target it
1195
+ * is the window losing focus or a press on something that takes none, and
1196
+ * light dismiss covers those. Tab past the last link of the page has no
1197
+ * target either, though, and that one does leave the menu.
1198
+ */
1199
+ this._handleFocusOut = (event) => {
1200
+ if (this.variant !== 'navigation')
1201
+ return;
1202
+ if (!this.matches(':popover-open'))
1203
+ return;
1204
+ const next = event.relatedTarget;
1205
+ if (next ? this.contains(next) || this._isAnchor(next) : !this._tabbing)
1206
+ return;
1207
+ this.hidePopover();
1208
+ };
1209
+ /** True from a Tab keydown until the focus change it causes has happened. */
1210
+ this._tabbing = false;
1137
1211
  this._typeaheadBuffer = '';
1138
1212
  this._typeaheadTimer = null;
1139
1213
  // A popover paints at its default position the instant it opens, before our async
@@ -1158,16 +1232,26 @@ export class NLDDMenu extends LitElement {
1158
1232
  * place. A submenu's items are its own and are left to it.
1159
1233
  */
1160
1234
  this._claimItems = () => {
1235
+ // A submenu of a navigation menu is navigation too. Set before the
1236
+ // items are claimed, so they get one answer and not two.
1237
+ if (this.variant === 'navigation') {
1238
+ Array.from(this.querySelectorAll('nldd-menu')).forEach(menu => { menu.variant = 'navigation'; });
1239
+ }
1161
1240
  const items = Array.from(this.querySelectorAll('nldd-menu-item'));
1162
1241
  items.forEach(item => {
1163
1242
  item.menuVariant = this.variant;
1164
1243
  });
1244
+ Array.from(this.querySelectorAll('nldd-menu-divider, nldd-menu-group'))
1245
+ .forEach(part => { part.menuVariant = this.variant; });
1246
+ this._warnOnActionsInNavigation(items);
1165
1247
  const own = items.filter(item => item.closest('nldd-menu') === this);
1166
1248
  const checkColumn = this.variant === 'menu' && own.some(item => item.type !== 'button');
1167
1249
  own.forEach(item => {
1168
1250
  item.checkColumn = checkColumn;
1169
1251
  });
1170
1252
  };
1253
+ this._warnedActionsInNavigation = false;
1254
+ this._warnedFilterInNavigation = false;
1171
1255
  this._handleBeforeToggle = (event) => {
1172
1256
  if (event.newState === 'open')
1173
1257
  this.removeAttribute('positioned');
@@ -1184,6 +1268,9 @@ export class NLDDMenu extends LitElement {
1184
1268
  // already chosen a value, so screen readers announce the role.
1185
1269
  this._syncAnchorPopupState(this._isOpen);
1186
1270
  if (toggleEvent.newState !== 'open') {
1271
+ // The offset belongs to the anchor that opened the menu, which sets
1272
+ // it again on every open; another anchor starts from 0.
1273
+ this.anchorOffset = 0;
1187
1274
  this._cleanupAutoUpdate?.();
1188
1275
  this._cleanupAutoUpdate = null;
1189
1276
  window.removeEventListener('resize', this._handleWindowResize);
@@ -1277,6 +1364,8 @@ export class NLDDMenu extends LitElement {
1277
1364
  }
1278
1365
  // — Lifecycle ——————————————————————————————————————————————————————————————
1279
1366
  updated(changedProperties) {
1367
+ if (changedProperties.has('anchorOffset') && this._isOpen)
1368
+ void this.reposition();
1280
1369
  if (changedProperties.has('width')) {
1281
1370
  if (this.width) {
1282
1371
  // An explicit width pins the menu to exactly that size — clamp the
@@ -1303,6 +1392,8 @@ export class NLDDMenu extends LitElement {
1303
1392
  }
1304
1393
  if (changedProperties.has('variant')) {
1305
1394
  this._claimItems();
1395
+ if (changedProperties.get('variant') !== undefined)
1396
+ this._syncAnchorPopupState(this._isOpen);
1306
1397
  }
1307
1398
  // A new anchor arrives closed and unlabeled — seed it right away rather
1308
1399
  // than at its first open. Covers the popup slot (where the invoking
@@ -1360,8 +1451,14 @@ export class NLDDMenu extends LitElement {
1360
1451
  // of identical "more" buttons hearing plain "button" — exactly the
1361
1452
  // moment the type matters most, since nothing has been opened yet.
1362
1453
  // nldd-popover already works this way.
1363
- if ('popupType' in anchor && !anchor.popupType) {
1364
- anchor.popupType = this.variant === 'listbox' ? 'listbox' : 'menu';
1454
+ // A navigation menu is a disclosure: the trigger says expanded or not,
1455
+ // and promises no menu.
1456
+ // One this menu seeded follows the variant when it changes; one the
1457
+ // consumer set is left alone.
1458
+ if ('popupType' in anchor && (!anchor.popupType || anchor.popupType === this._seededPopupType)) {
1459
+ const wanted = this.variant === 'navigation' ? '' : this.variant === 'listbox' ? 'listbox' : 'menu';
1460
+ anchor.popupType = wanted;
1461
+ this._seededPopupType = wanted || null;
1365
1462
  }
1366
1463
  if ('popoverTargetAction' in anchor) {
1367
1464
  anchor.popoverTargetAction = isOpen ? 'hide' : 'show';
@@ -1750,6 +1847,7 @@ export class NLDDMenu extends LitElement {
1750
1847
  this.addEventListener('beforetoggle', this._handleBeforeToggle);
1751
1848
  this.addEventListener('toggle', this._handleToggle);
1752
1849
  this.addEventListener('keydown', this._handleKeydown);
1850
+ this.addEventListener('focusout', this._handleFocusOut);
1753
1851
  this.addEventListener('mouseenter', this._handleMenuItemMouseenter, true);
1754
1852
  this.addEventListener('mouseleave', this._handleMouseleave);
1755
1853
  this.addEventListener('menu-item-focused', this._handleMenuItemFocused);
@@ -1794,6 +1892,9 @@ export class NLDDMenu extends LitElement {
1794
1892
  this._previousAnchorForResync?.removeEventListener('pointerdown', this._resyncAnchorFromPopoverState, true);
1795
1893
  this._previousAnchorForResync = null;
1796
1894
  this.removeEventListener('keydown', this._handleKeydown);
1895
+ this.removeEventListener('focusout', this._handleFocusOut);
1896
+ clearTimeout(this._tabbingTimer);
1897
+ this._tabbing = false;
1797
1898
  this.removeEventListener('mouseenter', this._handleMenuItemMouseenter, true);
1798
1899
  this.removeEventListener('mouseleave', this._handleMouseleave);
1799
1900
  this.removeEventListener('menu-item-focused', this._handleMenuItemFocused);
@@ -1935,6 +2036,10 @@ export class NLDDMenu extends LitElement {
1935
2036
  * keystroke. Text without the query in it is shown as it is.
1936
2037
  */
1937
2038
  filter(query, { hide = true } = {}) {
2039
+ if (import.meta.env?.DEV && this.variant === 'navigation' && !this._warnedFilterInNavigation) {
2040
+ this._warnedFilterInNavigation = true;
2041
+ console.warn('nldd-menu: filter() belongs to a menu of actions or options. A navigation menu is a short list of links and is not filtered.');
2042
+ }
1938
2043
  const allItems = Array.from(this.querySelectorAll('nldd-menu-item'));
1939
2044
  allItems.forEach(item => {
1940
2045
  const matches = !hide || !query || this.filterFn(query, item);
@@ -2052,7 +2157,7 @@ export class NLDDMenu extends LitElement {
2052
2157
  const { x, y } = await computePosition(anchorEl, this, {
2053
2158
  placement: effectivePlacement,
2054
2159
  middleware: [
2055
- offset({ mainAxis: 0, alignmentAxis: -submenuPadding }),
2160
+ offset({ mainAxis: this.anchorOffset, alignmentAxis: -submenuPadding }),
2056
2161
  ...(drillIn ? [] : [flip({ padding: viewportMargin })]),
2057
2162
  shift({ padding: viewportMargin }),
2058
2163
  size({
@@ -2068,6 +2173,18 @@ export class NLDDMenu extends LitElement {
2068
2173
  top: `${y}px`,
2069
2174
  });
2070
2175
  }
2176
+ /**
2177
+ * Whether focus went to the control that opens this menu. Closing here
2178
+ * would hand the click that follows a closed menu, and it would open it
2179
+ * again; the toggle on the anchor does the closing. The node arrives
2180
+ * retargeted, so an anchor inside a shadow root shows up as its host.
2181
+ */
2182
+ _isAnchor(node) {
2183
+ const anchor = this._getAnchorEl();
2184
+ if (!anchor)
2185
+ return false;
2186
+ return node === anchor || anchor.contains(node) || anchor.getRootNode().host === node;
2187
+ }
2071
2188
  /**
2072
2189
  * ARIA APG typeahead: characters typed within 500ms accumulate into a
2073
2190
  * buffer; the menu jumps to the first item whose text starts with the
@@ -2104,6 +2221,16 @@ export class NLDDMenu extends LitElement {
2104
2221
  }
2105
2222
  }
2106
2223
  }
2224
+ /** Checkable items and shortcuts belong to actions, not to a list of links. */
2225
+ _warnOnActionsInNavigation(items) {
2226
+ if (!import.meta.env?.DEV || this.variant !== 'navigation' || this._warnedActionsInNavigation)
2227
+ return;
2228
+ const stray = items.find(item => item.type !== 'button' || item.shortcut);
2229
+ if (!stray)
2230
+ return;
2231
+ this._warnedActionsInNavigation = true;
2232
+ console.warn('nldd-menu: variant="navigation" is a list of links. A checkbox or radio item, or a shortcut, belongs to an action menu and has no role to live in here. Use the default variant for actions.', stray);
2233
+ }
2107
2234
  render() {
2108
2235
  return menuTemplate.call(this, this._isEmpty, this.variant);
2109
2236
  }
@@ -2170,6 +2297,9 @@ __decorate([
2170
2297
  __decorate([
2171
2298
  property({ reflect: true, converter: reflectNonDefault('bottom-start') })
2172
2299
  ], NLDDMenu.prototype, "placement", void 0);
2300
+ __decorate([
2301
+ property({ attribute: false })
2302
+ ], NLDDMenu.prototype, "anchorOffset", void 0);
2173
2303
  __decorate([
2174
2304
  property({ type: Number, attribute: 'max-items' })
2175
2305
  ], NLDDMenu.prototype, "maxItems", void 0);