@nanahoshi/mona-ui 0.25.1 → 0.26.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 (233) hide show
  1. package/README.md +2 -0
  2. package/chart/README.md +2 -2
  3. package/command/package.json +4 -0
  4. package/docs/auto-complete.md +733 -0
  5. package/docs/avatar.md +220 -0
  6. package/docs/breadcrumb.md +320 -0
  7. package/docs/button-group.md +392 -0
  8. package/docs/button.md +256 -0
  9. package/docs/calendar.md +515 -0
  10. package/docs/card.md +292 -0
  11. package/docs/chart-bar.md +714 -0
  12. package/docs/chart-financial.md +567 -0
  13. package/docs/chart-funnel.md +546 -0
  14. package/docs/chart-heatmap.md +535 -0
  15. package/docs/chart-line-area.md +462 -0
  16. package/docs/chart-pie.md +645 -0
  17. package/docs/chart-radar.md +518 -0
  18. package/docs/chart-radial.md +658 -0
  19. package/docs/chart-scatter.md +479 -0
  20. package/docs/chart-treemap.md +651 -0
  21. package/docs/chart.md +2465 -0
  22. package/docs/checkbox.md +374 -0
  23. package/docs/chip.md +339 -0
  24. package/docs/circular-progress-bar.md +287 -0
  25. package/docs/collapsible.md +308 -0
  26. package/docs/color-gradient.md +336 -0
  27. package/docs/color-palette.md +317 -0
  28. package/docs/color-picker.md +387 -0
  29. package/docs/combo-box.md +764 -0
  30. package/docs/command.md +582 -0
  31. package/docs/contextmenu.md +530 -0
  32. package/docs/date-picker.md +251 -0
  33. package/docs/datetime-picker.md +284 -0
  34. package/docs/decimal-textbox.md +260 -0
  35. package/docs/dialog.md +822 -0
  36. package/docs/dropdown-button.md +507 -0
  37. package/docs/dropdown-list.md +779 -0
  38. package/docs/editor.md +374 -0
  39. package/docs/expansion-panel.md +348 -0
  40. package/docs/fieldset.md +217 -0
  41. package/docs/forms.md +162 -0
  42. package/docs/grid.md +2053 -0
  43. package/docs/input.md +197 -0
  44. package/docs/installation.md +54 -0
  45. package/docs/introduction.md +46 -0
  46. package/docs/label.md +340 -0
  47. package/docs/list-box.md +637 -0
  48. package/docs/list-view.md +584 -0
  49. package/docs/menubar.md +559 -0
  50. package/docs/multi-select.md +765 -0
  51. package/docs/notification.md +460 -0
  52. package/docs/numeric-textbox.md +301 -0
  53. package/docs/otp-input.md +539 -0
  54. package/docs/pager.md +513 -0
  55. package/docs/placeholder.md +176 -0
  56. package/docs/popover.md +423 -0
  57. package/docs/popup-menu.md +658 -0
  58. package/docs/popup.md +617 -0
  59. package/docs/progress-bar.md +368 -0
  60. package/docs/radio-button.md +451 -0
  61. package/docs/range-slider.md +367 -0
  62. package/docs/rating.md +518 -0
  63. package/docs/scroll-view.md +375 -0
  64. package/docs/segmented.md +434 -0
  65. package/docs/sheet.md +348 -0
  66. package/docs/sidebar.md +1126 -0
  67. package/docs/skeleton.md +181 -0
  68. package/docs/slider.md +423 -0
  69. package/docs/spinner.md +370 -0
  70. package/docs/split-button.md +522 -0
  71. package/docs/splitter.md +342 -0
  72. package/docs/stepper.md +539 -0
  73. package/docs/switch.md +340 -0
  74. package/docs/tabs.md +542 -0
  75. package/docs/textarea.md +196 -0
  76. package/docs/textbox.md +332 -0
  77. package/docs/theming.md +403 -0
  78. package/docs/time-picker.md +254 -0
  79. package/docs/tooltip-directive.md +340 -0
  80. package/docs/tooltip.md +321 -0
  81. package/docs/tree-view.md +1018 -0
  82. package/docs/window.md +663 -0
  83. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  84. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
  85. package/fesm2022/nanahoshi-mona-ui-button.mjs +12 -0
  86. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
  87. package/fesm2022/nanahoshi-mona-ui-chart.mjs +212 -66
  88. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
  89. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
  90. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
  91. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  92. package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
  93. package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
  94. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
  95. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
  96. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
  97. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
  98. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
  99. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
  100. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
  101. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
  102. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
  103. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
  104. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
  105. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
  106. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
  107. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
  108. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  109. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  110. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
  111. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
  112. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
  113. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
  114. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
  115. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
  116. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
  117. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
  118. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
  119. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
  120. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
  121. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
  122. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
  123. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
  124. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
  125. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
  126. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
  127. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
  128. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
  129. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
  130. package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
  131. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
  132. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
  133. package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
  134. package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
  135. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
  136. package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
  137. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
  138. package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
  139. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
  140. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
  141. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
  142. package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
  143. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
  144. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
  145. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
  146. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
  147. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
  148. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
  149. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
  150. package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
  151. package/i18n/catalogs/en-US.messages.json +10 -0
  152. package/internal/popup-menu/package.json +4 -0
  153. package/llms.txt +133 -0
  154. package/locales/ar-sa/ar-sa.messages.json +10 -0
  155. package/locales/de-de/de-de.messages.json +10 -0
  156. package/locales/es-es/es-es.messages.json +10 -0
  157. package/locales/fr-fr/fr-fr.messages.json +10 -0
  158. package/locales/id-id/id-id.messages.json +10 -0
  159. package/locales/it-it/it-it.messages.json +10 -0
  160. package/locales/ja-jp/ja-jp.messages.json +10 -0
  161. package/locales/ko-kr/ko-kr.messages.json +10 -0
  162. package/locales/pt-br/pt-br.messages.json +10 -0
  163. package/locales/ru-ru/ru-ru.messages.json +10 -0
  164. package/locales/tr-tr/tr-tr.messages.json +10 -0
  165. package/locales/zh-cn/zh-cn.messages.json +10 -0
  166. package/locales/zh-tw/zh-tw.messages.json +10 -0
  167. package/package.json +9 -1
  168. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
  169. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
  170. package/types/nanahoshi-mona-ui-button.d.ts +12 -0
  171. package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
  172. package/types/nanahoshi-mona-ui-chart.d.ts +250 -20
  173. package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
  174. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
  175. package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
  176. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
  177. package/types/nanahoshi-mona-ui-command.d.ts +253 -0
  178. package/types/nanahoshi-mona-ui-common.d.ts +17 -1
  179. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
  180. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
  181. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
  182. package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
  183. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
  184. package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
  185. package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
  186. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
  187. package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
  188. package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
  189. package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
  190. package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
  191. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
  192. package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
  193. package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
  194. package/types/nanahoshi-mona-ui-label.d.ts +1 -0
  195. package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
  196. package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
  197. package/types/nanahoshi-mona-ui-list.d.ts +1 -1
  198. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
  199. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
  200. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
  201. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
  202. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
  203. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
  204. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
  205. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
  206. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
  207. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
  208. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
  209. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
  210. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
  211. package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
  212. package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
  213. package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
  214. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
  215. package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
  216. package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
  217. package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
  218. package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
  219. package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
  220. package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
  221. package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
  222. package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
  223. package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
  224. package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
  225. package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
  226. package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
  227. package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
  228. package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
  229. package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
  230. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
  231. package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
  232. package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
  233. package/types/nanahoshi-mona-ui-window.d.ts +66 -1
@@ -0,0 +1,530 @@
1
+ # Context Menu
2
+
3
+ > A popup menu attached to an element, opened by right-click or keyboard.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/contextmenu`
6
+
7
+ **Selectors:** `mona-contextmenu` · `mona-contextmenu-item` · `mona-contextmenu-checkbox-item` · `mona-contextmenu-radio-group` · `mona-contextmenu-radio-item` · `mona-contextmenu-group` · `mona-contextmenu-separator`
8
+
9
+ `ContextMenuComponent` attaches a popup menu, built from content-projected menu item components, to a target element and opens it on right-click or a keyboard shortcut.
10
+
11
+ ## Overview
12
+
13
+ `ContextMenuComponent` (`mona-contextmenu`) binds a popup menu to a `target` element. The menu opens at the pointer position when the consumer right-clicks the target, or at the target's center when the consumer presses the `ContextMenu` key (or `Shift+F10`) while the target has focus.
14
+
15
+ Menu content is built from content-projected items — `mona-contextmenu-item`, `mona-contextmenu-checkbox-item`, `mona-contextmenu-radio-group`/`mona-contextmenu-radio-item`, `mona-contextmenu-group`, and `mona-contextmenu-separator` — nested inside `<mona-contextmenu>`. Nesting items inside another item creates a submenu.
16
+
17
+ **Use `ContextMenuComponent` when you need to:**
18
+
19
+ - Offer secondary, selection-dependent actions on right-click (e.g. a file row, a canvas element, a table cell)
20
+ - Provide the same action set via a keyboard shortcut without a dedicated trigger button
21
+
22
+ **Use a closely related Mona UI component instead when:**
23
+
24
+ - The menu must always be visible as a horizontal bar of top-level items — use `MenubarComponent`.
25
+ - The menu should open from a dedicated button click rather than a right-click or keyboard shortcut — use `DropdownButtonComponent`.
26
+ - You need a lower-level popup menu with a configurable trigger event, anchor element, or open/close outputs — use `PopupMenuComponent` directly. `ContextMenuComponent` wraps it with the trigger fixed to `"contextmenu"` and pointer-relative positioning, and does not expose `PopupMenuComponent`'s `open`/`close`/`navigate` outputs or its `anchor`/`offset`/`openAtPointer` inputs.
27
+
28
+ ## Import & Quick Start
29
+
30
+ ```typescript
31
+ import { ContextMenuComponent, ContextMenuItemComponent, ContextMenuSeparatorComponent } from "@nanahoshi/mona-ui/contextmenu";
32
+ ```
33
+
34
+ Add the components you need to your standalone component's `imports` array.
35
+
36
+ **Minimal example:**
37
+
38
+ ```html
39
+ <button #target type="button">Right-click me</button>
40
+ <mona-contextmenu [target]="target" (menuClick)="onMenuClick($event)">
41
+ <mona-contextmenu-item label="Copy"></mona-contextmenu-item>
42
+ <mona-contextmenu-item label="Paste" [disabled]="true"></mona-contextmenu-item>
43
+ <mona-contextmenu-separator></mona-contextmenu-separator>
44
+ <mona-contextmenu-item label="Delete"></mona-contextmenu-item>
45
+ </mona-contextmenu>
46
+ ```
47
+
48
+ ```typescript
49
+ import type { MenuItemClickEvent } from "@nanahoshi/mona-ui/menubar";
50
+
51
+ protected onMenuClick(event: MenuItemClickEvent): void { /* ... */ }
52
+ ```
53
+
54
+ `target` accepts a template reference (as above), an `ElementRef<HTMLElement>`, or a plain `HTMLElement`.
55
+
56
+ ## Anatomy
57
+
58
+ ### Content projection
59
+
60
+ ```
61
+ mona-contextmenu
62
+ ├── mona-contextmenu-item — a clickable item; project more items inside it for a submenu
63
+ ├── mona-contextmenu-checkbox-item — a toggle item
64
+ ├── mona-contextmenu-radio-group — mutually exclusive choices
65
+ │ └── mona-contextmenu-radio-item
66
+ ├── mona-contextmenu-group — a titled section of items
67
+ │ └── mona-contextmenu-item
68
+ └── mona-contextmenu-separator — a horizontal divider
69
+ ```
70
+
71
+ Alternatively, pass an `items` collection directly (see the API section) instead of projecting components. When `items` is non-empty, it takes precedence over projected content.
72
+
73
+ ### Template directives
74
+
75
+ Each directive can be placed directly inside `<mona-contextmenu>` to apply to every matching item, or nested inside a specific `mona-contextmenu-item`/`mona-contextmenu-group` to override it for that item or group only.
76
+
77
+ | Directive attribute | Scope | Template context |
78
+ |-----------------------------------|----------------|-----------------------------------------------------------------------------------|
79
+ | `monaContextMenuGroupTemplate` | Global / Group | `$implicit: string` — the group title |
80
+ | `monaContextMenuIconTemplate` | Global / Item | `$implicit` — the menu item (`label`, `disabled`, …); see API for the type caveat |
81
+ | `monaContextMenuShortcutTemplate` | Global / Item | `$implicit` — the menu item, as above |
82
+ | `monaContextMenuTextTemplate` | Global / Item | `$implicit` — the menu item, as above |
83
+
84
+ **Custom group header:**
85
+
86
+ ```html
87
+ <mona-contextmenu [target]="target">
88
+ <mona-contextmenu-group title="System Actions">
89
+ <mona-contextmenu-item label="Properties"></mona-contextmenu-item>
90
+ <ng-template monaContextMenuGroupTemplate let-title>
91
+ <span class="font-semibold text-primary">{{ title }}</span>
92
+ </ng-template>
93
+ </mona-contextmenu-group>
94
+ </mona-contextmenu>
95
+ ```
96
+
97
+ **Custom text for one item:**
98
+
99
+ ```html
100
+ <mona-contextmenu [target]="target">
101
+ <mona-contextmenu-item label="Delete">
102
+ <ng-template monaContextMenuTextTemplate let-item>
103
+ <span class="text-destructive">{{ item.label }}</span>
104
+ </ng-template>
105
+ </mona-contextmenu-item>
106
+ </mona-contextmenu>
107
+ ```
108
+
109
+ When a `monaContextMenuTextTemplate` is provided without setting `label`, the projected template content is what consumers see and is also what assistive technology reads as the item's accessible name (see Accessibility below).
110
+
111
+ ## Examples
112
+
113
+ ### Submenus, groups and separators
114
+
115
+ Projecting items inside `mona-contextmenu-item` turns it into a submenu trigger; it renders a chevron instead of a shortcut area and no longer emits `menuClick` itself.
116
+
117
+ `basic-example.component.ts`
118
+
119
+ ```typescript
120
+ import { Component, signal } from "@angular/core";
121
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
122
+ import {
123
+ ContextMenuComponent,
124
+ ContextMenuGroupComponent,
125
+ ContextMenuItemComponent,
126
+ ContextMenuSeparatorComponent
127
+ } from "@nanahoshi/mona-ui/contextmenu";
128
+
129
+ @Component({
130
+ selector: "app-contextmenu-basic-example",
131
+ imports: [
132
+ ButtonDirective,
133
+ ContextMenuComponent,
134
+ ContextMenuGroupComponent,
135
+ ContextMenuItemComponent,
136
+ ContextMenuSeparatorComponent
137
+ ],
138
+ templateUrl: "./basic-example.component.html"
139
+ })
140
+ export class ContextMenuBasicExampleComponent {
141
+ protected readonly lastAction = signal("none");
142
+ }
143
+ ```
144
+
145
+ `basic-example.component.html`
146
+
147
+ ```html
148
+ <p class="mb-2 text-sm">Right-click the file, or focus it and press Shift+F10.</p>
149
+ <div class="flex flex-wrap items-center gap-3">
150
+ <button #file monaButton type="button">report-q3.pdf</button>
151
+ <span aria-live="polite" class="text-sm">Last action: {{ lastAction() }}</span>
152
+ </div>
153
+
154
+ <mona-contextmenu aria-label="File actions" [target]="file" (menuClick)="lastAction.set($event.label)">
155
+ <mona-contextmenu-item label="Open" />
156
+ <mona-contextmenu-item label="Open with">
157
+ <mona-contextmenu-item label="Viewer" />
158
+ <mona-contextmenu-item label="Editor" />
159
+ </mona-contextmenu-item>
160
+ <mona-contextmenu-separator />
161
+ <mona-contextmenu-group title="Share">
162
+ <mona-contextmenu-item label="Copy link" />
163
+ <mona-contextmenu-item label="Email" />
164
+ </mona-contextmenu-group>
165
+ <mona-contextmenu-separator />
166
+ <mona-contextmenu-item label="Rename" [disabled]="true" />
167
+ <mona-contextmenu-item label="Delete" />
168
+ </mona-contextmenu>
169
+ ```
170
+
171
+ ### Checkbox and radio items
172
+
173
+ `checked` on a checkbox item and `value` on a radio group are two-way bindable.
174
+
175
+ `checkable-example.component.ts`
176
+
177
+ ```typescript
178
+ import { Component, signal } from "@angular/core";
179
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
180
+ import {
181
+ ContextMenuCheckboxItemComponent,
182
+ ContextMenuComponent,
183
+ ContextMenuRadioGroupComponent,
184
+ ContextMenuRadioItemComponent,
185
+ ContextMenuSeparatorComponent
186
+ } from "@nanahoshi/mona-ui/contextmenu";
187
+
188
+ @Component({
189
+ selector: "app-contextmenu-checkable-example",
190
+ imports: [
191
+ ButtonDirective,
192
+ ContextMenuCheckboxItemComponent,
193
+ ContextMenuComponent,
194
+ ContextMenuRadioGroupComponent,
195
+ ContextMenuRadioItemComponent,
196
+ ContextMenuSeparatorComponent
197
+ ],
198
+ templateUrl: "./checkable-example.component.html"
199
+ })
200
+ export class ContextMenuCheckableExampleComponent {
201
+ protected readonly previewPane = signal(true);
202
+ protected readonly sortField = signal("name");
203
+ }
204
+ ```
205
+
206
+ `checkable-example.component.html`
207
+
208
+ ```html
209
+ <div class="flex flex-wrap items-center gap-3">
210
+ <button #folder monaButton type="button">Documents</button>
211
+ <span class="text-sm">Preview pane: {{ previewPane() ? "on" : "off" }}. Sorted by {{ sortField() }}.</span>
212
+ </div>
213
+
214
+ <mona-contextmenu aria-label="View options" [target]="folder">
215
+ <mona-contextmenu-checkbox-item label="Preview pane" [(checked)]="previewPane" />
216
+ <mona-contextmenu-separator />
217
+ <mona-contextmenu-radio-group title="Sort by" [(value)]="sortField">
218
+ <mona-contextmenu-radio-item label="Name" value="name" />
219
+ <mona-contextmenu-radio-item label="Date modified" value="date modified" />
220
+ <mona-contextmenu-radio-item label="Size" value="size" />
221
+ </mona-contextmenu-radio-group>
222
+ </mona-contextmenu>
223
+ ```
224
+
225
+ ### Icons and shortcuts
226
+
227
+ `icons-example.component.ts`
228
+
229
+ ```typescript
230
+ import { Component, signal } from "@angular/core";
231
+ import { LucideClipboardPaste, LucideCopy, LucideScissors } from "@lucide/angular";
232
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
233
+ import {
234
+ ContextMenuComponent,
235
+ ContextMenuIconTemplateDirective,
236
+ ContextMenuItemComponent,
237
+ ContextMenuShortcutTemplateDirective
238
+ } from "@nanahoshi/mona-ui/contextmenu";
239
+
240
+ @Component({
241
+ selector: "app-contextmenu-icons-example",
242
+ imports: [
243
+ ButtonDirective,
244
+ ContextMenuComponent,
245
+ ContextMenuIconTemplateDirective,
246
+ ContextMenuItemComponent,
247
+ ContextMenuShortcutTemplateDirective,
248
+ LucideClipboardPaste,
249
+ LucideCopy,
250
+ LucideScissors
251
+ ],
252
+ templateUrl: "./icons-example.component.html"
253
+ })
254
+ export class ContextMenuIconsExampleComponent {
255
+ protected readonly lastAction = signal("none");
256
+ }
257
+ ```
258
+
259
+ `icons-example.component.html`
260
+
261
+ ```html
262
+ <div class="flex flex-wrap items-center gap-3">
263
+ <button #file monaButton type="button">notes.txt</button>
264
+ <span aria-live="polite" class="text-sm">Last action: {{ lastAction() }}</span>
265
+ </div>
266
+
267
+ <mona-contextmenu aria-label="Edit" [target]="file" (menuClick)="lastAction.set($event.label)">
268
+ <mona-contextmenu-item label="Cut">
269
+ <ng-template monaContextMenuIconTemplate>
270
+ <svg lucideScissors aria-hidden="true" [size]="14"></svg>
271
+ </ng-template>
272
+ <ng-template monaContextMenuShortcutTemplate>
273
+ <span class="text-xs">Ctrl + X</span>
274
+ </ng-template>
275
+ </mona-contextmenu-item>
276
+ <mona-contextmenu-item label="Copy">
277
+ <ng-template monaContextMenuIconTemplate>
278
+ <svg lucideCopy aria-hidden="true" [size]="14"></svg>
279
+ </ng-template>
280
+ <ng-template monaContextMenuShortcutTemplate>
281
+ <span class="text-xs">Ctrl + C</span>
282
+ </ng-template>
283
+ </mona-contextmenu-item>
284
+ <mona-contextmenu-item label="Paste">
285
+ <ng-template monaContextMenuIconTemplate>
286
+ <svg lucideClipboardPaste aria-hidden="true" [size]="14"></svg>
287
+ </ng-template>
288
+ <ng-template monaContextMenuShortcutTemplate>
289
+ <span class="text-xs">Ctrl + V</span>
290
+ </ng-template>
291
+ </mona-contextmenu-item>
292
+ </mona-contextmenu>
293
+ ```
294
+
295
+ ### Sizing and rounding
296
+
297
+ ```html
298
+ <mona-contextmenu [target]="target" size="small" rounded="large" [minWidth]="180">
299
+ <mona-contextmenu-item label="Copy"></mona-contextmenu-item>
300
+ <mona-contextmenu-item label="Paste"></mona-contextmenu-item>
301
+ </mona-contextmenu>
302
+ ```
303
+
304
+ `size`, `rounded`, `minWidth`, and `width` apply to the root menu and every submenu.
305
+
306
+ ## Behavior
307
+
308
+ **Positioning is fixed.** The menu opens at the pointer position for a real right-click, or at the target's center when opened via keyboard. `ContextMenuComponent` does not expose a way to anchor the menu elsewhere or to use a different trigger event; use `PopupMenuComponent` directly for that.
309
+
310
+ **`items` takes precedence over projected content.** When the `items` input is a non-empty iterable, it is rendered instead of any projected `mona-contextmenu-item` (and related) components.
311
+
312
+ **Keep the menu open after a click.** Calling `event.preventDefault()` in a `(menuClick)` handler — on `<mona-contextmenu>` itself or on an individual item — prevents the menu from closing after that selection.
313
+
314
+ **Identifying the item.** The click event's `value` is the item's `value` input, so handlers don't need to compare label text (which changes with translation). `label` is the item's label, and for checkbox and radio items `checked` is the state the item has once the click is applied.
315
+
316
+ **Suppressing checkbox/radio state changes.** Calling `event.preventDefault()` on a `mona-contextmenu-checkbox-item`'s or `mona-contextmenu-radio-item`'s `menuClick` event suppresses the resulting `checkedChange` emission (checkbox item) or selection update (radio group). Use this to confirm or validate a change before it applies.
317
+
318
+ **No open/close output.** `ContextMenuComponent` only exposes `menuClick`. It does not re-emit `PopupMenuComponent`'s `open`/`close`/`navigate` events. If your use case needs to react to the menu opening or closing, use `PopupMenuComponent` directly.
319
+
320
+ **`aria-label` names the menu.** The context menu passes it to the menu it opens. When it's empty, the menu is labelled by the target, if the target has an `id`.
321
+
322
+ **The target can change.** Binding a different element to `target` moves the right-click, the keyboard shortcuts and the ARIA attributes to it. The old target gets its own attributes back, and so does the target when the context menu is destroyed.
323
+
324
+ **Closing.** Besides Escape, choosing an item and clicking outside, the menu closes when the page scrolls and when the window loses focus, as a native context menu does.
325
+
326
+ ## Accessibility
327
+
328
+ ### Keyboard navigation
329
+
330
+ | Key | Action |
331
+ |-----------------------------------|-------------------------------------------------------------------------------------------------------------|
332
+ | Right-click | Opens the menu at the pointer position |
333
+ | `ContextMenu` key, or `Shift+F10` | Opens the menu at the target's center, while the target has focus |
334
+ | `ArrowDown` | Highlights the next item, wrapping to the first. Disabled items are highlighted too, but can't be activated |
335
+ | `ArrowUp` | Highlights the previous item, wrapping to the last |
336
+ | `ArrowRight` | Opens the highlighted item's submenu, if it has nested items |
337
+ | `ArrowLeft` | Closes the current submenu and returns to the parent level |
338
+ | `Home` | Highlights the first item |
339
+ | `End` | Highlights the last item |
340
+ | `Enter` / `Space` | Activates the highlighted item, or opens its submenu if it has nested items |
341
+ | `Escape` | Closes the open submenu |
342
+ | `Tab` | Closes the menu and its submenus; focus moves on from the target |
343
+ | Letter, digit, `-`, or `_` | Jumps to (cycles through) items whose label starts with the typed text |
344
+
345
+ ### ARIA
346
+
347
+ **Target element** (the element bound to `target`), only when its role allows these attributes: a button, a link, or an element with `role` `button`, `gridcell`, `link`, `menuitem`, `tab` or `treeitem`. On any other target (a `div`, a section, a table row) they would be invalid, so they're left off; the menu is still found through the `ContextMenu` key and `Shift+F10`.
348
+
349
+ | Attribute | When present | Value |
350
+ |-----------------|-------------------------|------------------------------------------------------|
351
+ | `aria-haspopup` | Always (on those roles) | `"menu"` |
352
+ | `aria-controls` | While the menu is open | The menu's ID |
353
+ | `aria-expanded` | Always (on those roles) | `"true"` while the menu is open, otherwise `"false"` |
354
+
355
+ **Menu container** (`role="menu"`):
356
+
357
+ | Attribute | When present | Value |
358
+ |-------------------------|-------------------------------------------------------|------------------------------------------------------|
359
+ | `role` | Always | `"menu"` |
360
+ | `aria-orientation` | Always | `"vertical"` |
361
+ | `aria-activedescendant` | While an item is highlighted via keyboard or pointer | The highlighted item's ID |
362
+ | `aria-labelledby` | Root menu, when the target has an `id`; every submenu | The target's ID; for a submenu, its parent item's ID |
363
+
364
+ **Item** (`role="menuitem"`, `"menuitemcheckbox"` or `"menuitemradio"`):
365
+
366
+ | Attribute | When present | Value |
367
+ |-----------------|--------------------------------------|------------------------------------------------------------------------------------------|
368
+ | `role` | Always | `"menuitem"`; `"menuitemcheckbox"` for checkbox items, `"menuitemradio"` for radio items |
369
+ | `aria-checked` | Checkbox and radio items | `"true"` while checked or selected, otherwise `"false"` |
370
+ | `aria-disabled` | Always | Reflects the item's `disabled` input |
371
+ | `aria-haspopup` | When the item has nested items | `"menu"` |
372
+ | `aria-expanded` | When the item has nested items | `"true"` while its submenu is open, otherwise `"false"` |
373
+ | `aria-controls` | While the item's submenu is open | The submenu's ID |
374
+ | `aria-label` | When the item's `label` is non-empty | The item's `label` text |
375
+
376
+ **Group** (`role="group"`): wraps a titled group's header and its items, with `aria-labelledby` pointing at the header. **Separator:** `role="separator"`.
377
+
378
+ **Focus behavior:** focus stays on the `role="menu"` container rather than moving to individual items; the highlighted item is communicated through `aria-activedescendant`. When the menu closes (Escape, choosing an item, or a click outside that doesn't move focus elsewhere), focus returns to the element that had it when the menu opened, or to the target if it can take focus. `Tab` closes every open menu and moves focus on from there, and focus that leaves the menus for another element closes them too. A submenu opened by the pointer leaves focus in its parent menu; one opened from the keyboard takes focus and highlights its first item.
379
+
380
+ **Consumer responsibilities:**
381
+
382
+ - Provide an accessible name for the `target` element itself (visible text, or its own `aria-label`) — `ContextMenuComponent` does not add one. Its `aria-label` input names the menu, not the target.
383
+ - When an item uses a `monaContextMenuTextTemplate` and the item's `label` is left empty, no `aria-label` fallback is applied; ensure the projected template content alone communicates the item (it is read as the item's accessible name via its text content).
384
+
385
+ ## API
386
+
387
+ Everything below is imported from `@nanahoshi/mona-ui/contextmenu`.
388
+
389
+ ### `ContextMenuComponent`
390
+
391
+ **Selector:** `mona-contextmenu`
392
+
393
+ #### Inputs
394
+
395
+ | Name | Type | Default | Description |
396
+ | --- | --- | --- | --- |
397
+ | `aria-label` | `string` | `""` | Accessible name for the menu. When empty, the menu is named by the target if it has an `id`. |
398
+ | `items` | `Iterable<PopupMenuItem>` | `[]` | The menu items to render. When provided, these take precedence over content-projected `mona-contextmenu-item` (and related) components. |
399
+ | `minWidth` | `string \| number` | — | Sets the minimum width of the context menu. This will be applied to the root menu and all submenus. |
400
+ | `rounded` | `"large" \| "medium" \| "none" \| "small"` | `"medium"` | Sets the rounded state of the context menu. |
401
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Sets the size of the context menu. |
402
+ | `target` (required) | `ElementRef<HTMLElement> \| HTMLElement` | — | The target element that will be used to trigger the context menu. It can change: the menu, its keyboard shortcuts and its ARIA attributes follow. `aria-haspopup`, `aria-expanded` and `aria-controls` are set only on targets whose role allows them (button, link, gridcell, menuitem, tab, treeitem), and are put back when the target changes or the menu is destroyed. |
403
+ | `width` | `string \| number` | — | Sets the width of the context menu. This will be applied to the root menu and all submenus. |
404
+
405
+ #### Outputs
406
+
407
+ | Name | Type | Description |
408
+ | --- | --- | --- |
409
+ | `menuClick` | `PopupMenuItemClickEvent` | Emits when a menu item is clicked. |
410
+
411
+ ### `ContextMenuCheckboxItemComponent`
412
+
413
+ **Selector:** `mona-contextmenu-checkbox-item`
414
+ **Extends:** `PopupMenuCheckboxItemComponent`
415
+
416
+ #### Inputs
417
+
418
+ | Name | Type | Default | Description |
419
+ | --- | --- | --- | --- |
420
+ | `checked` (two-way) | `boolean` | `false` | The checked state of the menu item. Activating the item toggles it (unless its `menuClick` is prevented) and emits `checkedChange`, so it works with or without a two-way binding. |
421
+ | `disabled` | `boolean` | `false` | Sets the disabled state of the menu item. |
422
+ | `label` | `string` | `""` | The text of the menu item. |
423
+ | `value` | `unknown` | — | A value that identifies the item. It's the `value` of the item's `menuClick` events. |
424
+
425
+ #### Outputs
426
+
427
+ | Name | Type | Description |
428
+ | --- | --- | --- |
429
+ | `checkedChange` | `boolean` | Emitted when `checked` changes. |
430
+ | `menuClick` | `PopupMenuItemClickEvent` | The click event of the menu item. Emits when the menu item is selected by keyboard or mouse. |
431
+
432
+ ### `ContextMenuItemComponent`
433
+
434
+ **Selector:** `mona-contextmenu-item`
435
+ **Extends:** `PopupMenuItemComponent`
436
+
437
+ #### Inputs
438
+
439
+ | Name | Type | Default | Description |
440
+ | --- | --- | --- | --- |
441
+ | `disabled` | `boolean` | `false` | Sets the disabled state of the menu item. |
442
+ | `label` | `string` | `""` | The text of the menu item. |
443
+ | `value` | `unknown` | — | A value that identifies the item. It's the `value` of the item's `menuClick` events, so handlers don't depend on the label's text. |
444
+
445
+ #### Outputs
446
+
447
+ | Name | Type | Description |
448
+ | --- | --- | --- |
449
+ | `menuClick` | `PopupMenuItemClickEvent` | The click event of the menu item. Emits when the menu item is selected by keyboard or mouse. |
450
+
451
+ ### `ContextMenuRadioItemComponent`
452
+
453
+ **Selector:** `mona-contextmenu-radio-item`
454
+ **Extends:** `PopupMenuRadioItemComponent`
455
+
456
+ #### Inputs
457
+
458
+ | Name | Type | Default | Description |
459
+ | --- | --- | --- | --- |
460
+ | `disabled` | `boolean` | `false` | Sets the disabled state of the menu item. |
461
+ | `label` | `string` | `""` | The text of the menu item. |
462
+ | `value` (required) | `string` | — | The value of the radio item. |
463
+
464
+ #### Outputs
465
+
466
+ | Name | Type | Description |
467
+ | --- | --- | --- |
468
+ | `menuClick` | `PopupMenuItemClickEvent` | The click event of the menu item. Emits when the menu item is selected by keyboard or mouse, before the radio group selects it. Preventing it keeps the group's value and the menu open. |
469
+
470
+ ### `ContextMenuRadioGroupComponent`
471
+
472
+ **Selector:** `mona-contextmenu-radio-group`
473
+ **Extends:** `PopupMenuRadioGroupComponent`
474
+
475
+ #### Inputs
476
+
477
+ | Name | Type | Default | Description |
478
+ | --- | --- | --- | --- |
479
+ | `title` | `string` | `""` | The title of the radio group. |
480
+ | `value` (two-way) | `string` | `""` | The value of the selected radio item. |
481
+
482
+ #### Outputs
483
+
484
+ | Name | Type | Description |
485
+ | --- | --- | --- |
486
+ | `valueChange` | `string` | Emitted when `value` changes. |
487
+
488
+ ### `ContextMenuGroupComponent`
489
+
490
+ **Selector:** `mona-contextmenu-group`
491
+ **Extends:** `PopupMenuGroupComponent`
492
+
493
+ #### Inputs
494
+
495
+ | Name | Type | Default | Description |
496
+ | --- | --- | --- | --- |
497
+ | `title` | `string` | — | Sets the title of the menu group. |
498
+
499
+ ### `ContextMenuSeparatorComponent`
500
+
501
+ Renders a horizontal visual divider between items.
502
+
503
+ **Selector:** `mona-contextmenu-separator`
504
+ **Extends:** `PopupMenuSeparatorComponent`
505
+
506
+ ### `ContextMenuGroupTemplateDirective`
507
+
508
+ Customizes a group header's content.
509
+
510
+ **Selector:** `ng-template[monaContextMenuGroupTemplate]`
511
+ **Extends:** `PopupMenuGroupTemplateDirective`
512
+
513
+ ### `ContextMenuIconTemplateDirective`
514
+
515
+ **Selector:** `ng-template[monaContextMenuIconTemplate]`
516
+ **Extends:** `PopupMenuIconTemplateDirective`
517
+
518
+ ### `ContextMenuShortcutTemplateDirective`
519
+
520
+ **Selector:** `ng-template[monaContextMenuShortcutTemplate]`
521
+ **Extends:** `PopupMenuShortcutTemplateDirective`
522
+
523
+ ### `ContextMenuTextTemplateDirective`
524
+
525
+ **Selector:** `ng-template[monaContextMenuTextTemplate]`
526
+ **Extends:** `PopupMenuTextTemplateDirective`
527
+
528
+ ### Types
529
+
530
+ **Documented elsewhere:** [`PopupMenuCheckboxItemComponent`](popup-menu.md), [`PopupMenuGroupComponent`](popup-menu.md), [`PopupMenuGroupTemplateDirective`](popup-menu.md), [`PopupMenuIconTemplateDirective`](popup-menu.md), [`PopupMenuItem`](popup-menu.md), [`PopupMenuItemClickEvent`](popup-menu.md), [`PopupMenuItemComponent`](popup-menu.md), [`PopupMenuRadioGroupComponent`](popup-menu.md), [`PopupMenuRadioItemComponent`](popup-menu.md), [`PopupMenuSeparatorComponent`](popup-menu.md), [`PopupMenuShortcutTemplateDirective`](popup-menu.md), [`PopupMenuTextTemplateDirective`](popup-menu.md)