@nanahoshi/mona-ui 0.25.0 → 0.26.0
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.
- package/README.md +2 -0
- package/command/package.json +4 -0
- package/docs/auto-complete.md +733 -0
- package/docs/avatar.md +220 -0
- package/docs/breadcrumb.md +320 -0
- package/docs/button-group.md +392 -0
- package/docs/button.md +256 -0
- package/docs/calendar.md +515 -0
- package/docs/card.md +292 -0
- package/docs/chart.md +4058 -0
- package/docs/checkbox.md +374 -0
- package/docs/chip.md +339 -0
- package/docs/circular-progress-bar.md +287 -0
- package/docs/collapsible.md +308 -0
- package/docs/color-gradient.md +336 -0
- package/docs/color-palette.md +317 -0
- package/docs/color-picker.md +387 -0
- package/docs/combo-box.md +764 -0
- package/docs/command.md +582 -0
- package/docs/contextmenu.md +530 -0
- package/docs/date-picker.md +251 -0
- package/docs/datetime-picker.md +284 -0
- package/docs/decimal-textbox.md +260 -0
- package/docs/dialog.md +822 -0
- package/docs/dropdown-button.md +507 -0
- package/docs/dropdown-list.md +779 -0
- package/docs/editor.md +374 -0
- package/docs/expansion-panel.md +348 -0
- package/docs/fieldset.md +217 -0
- package/docs/forms.md +162 -0
- package/docs/grid.md +2053 -0
- package/docs/input.md +197 -0
- package/docs/installation.md +54 -0
- package/docs/introduction.md +46 -0
- package/docs/label.md +340 -0
- package/docs/list-box.md +637 -0
- package/docs/list-view.md +584 -0
- package/docs/menubar.md +559 -0
- package/docs/multi-select.md +765 -0
- package/docs/notification.md +460 -0
- package/docs/numeric-textbox.md +301 -0
- package/docs/otp-input.md +539 -0
- package/docs/pager.md +513 -0
- package/docs/placeholder.md +176 -0
- package/docs/popover.md +423 -0
- package/docs/popup-menu.md +658 -0
- package/docs/popup.md +617 -0
- package/docs/progress-bar.md +368 -0
- package/docs/radio-button.md +451 -0
- package/docs/range-slider.md +367 -0
- package/docs/rating.md +518 -0
- package/docs/scroll-view.md +375 -0
- package/docs/segmented.md +434 -0
- package/docs/sheet.md +348 -0
- package/docs/sidebar.md +1126 -0
- package/docs/skeleton.md +181 -0
- package/docs/slider.md +423 -0
- package/docs/spinner.md +370 -0
- package/docs/split-button.md +522 -0
- package/docs/splitter.md +342 -0
- package/docs/stepper.md +539 -0
- package/docs/switch.md +340 -0
- package/docs/tabs.md +542 -0
- package/docs/textarea.md +196 -0
- package/docs/textbox.md +332 -0
- package/docs/theming.md +403 -0
- package/docs/time-picker.md +254 -0
- package/docs/tooltip-directive.md +340 -0
- package/docs/tooltip.md +321 -0
- package/docs/tree-view.md +1018 -0
- package/docs/window.md +663 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-button.mjs +14 -2
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +108 -22
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +7 -3
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +8 -3
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +10 -7
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +53 -21
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
- package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
- package/i18n/catalogs/en-US.messages.json +10 -0
- package/internal/popup-menu/package.json +4 -0
- package/llms.txt +123 -0
- package/locales/ar-sa/ar-sa.messages.json +10 -0
- package/locales/de-de/de-de.messages.json +10 -0
- package/locales/es-es/es-es.messages.json +10 -0
- package/locales/fr-fr/fr-fr.messages.json +10 -0
- package/locales/id-id/id-id.messages.json +10 -0
- package/locales/it-it/it-it.messages.json +10 -0
- package/locales/ja-jp/ja-jp.messages.json +10 -0
- package/locales/ko-kr/ko-kr.messages.json +10 -0
- package/locales/pt-br/pt-br.messages.json +10 -0
- package/locales/ru-ru/ru-ru.messages.json +10 -0
- package/locales/tr-tr/tr-tr.messages.json +10 -0
- package/locales/zh-cn/zh-cn.messages.json +10 -0
- package/locales/zh-tw/zh-tw.messages.json +10 -0
- package/package.json +9 -1
- package/styles.css +12 -2
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
- package/types/nanahoshi-mona-ui-button.d.ts +12 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
- package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-command.d.ts +253 -0
- package/types/nanahoshi-mona-ui-common.d.ts +17 -1
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
- package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
- package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
- package/types/nanahoshi-mona-ui-label.d.ts +1 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
- package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
- package/types/nanahoshi-mona-ui-list.d.ts +1 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
- package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
- package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
- package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
- package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
- package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
- package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
- package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
- package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
- package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
- package/types/nanahoshi-mona-ui-window.d.ts +66 -1
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
# Popup Menu
|
|
2
|
+
|
|
3
|
+
> Opens a menu from an element you already have, such as an icon button or a row action.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/popup-menu`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-popup-menu`
|
|
8
|
+
|
|
9
|
+
`PopupMenuComponent` opens a menu from an element you already have, such as an icon button, an avatar or a table row action. The other Mona UI menus are built on it.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Use `PopupMenuComponent` when the element that opens the menu is yours: it doesn't render a trigger, it attaches to one.
|
|
14
|
+
|
|
15
|
+
**Use a closely related Mona UI component instead when:**
|
|
16
|
+
|
|
17
|
+
- You just want a button with a menu: use `DropdownButtonComponent`, or `SplitButtonComponent` if one action is the main one. Both set up the button's ARIA for you.
|
|
18
|
+
- The menu opens on right-click: use `ContextMenuComponent`, which also handles the `ContextMenu` key and `Shift+F10`.
|
|
19
|
+
- You need a persistent application menu bar: use `MenubarComponent`.
|
|
20
|
+
|
|
21
|
+
## Import & Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { PopupMenuComponent, PopupMenuItemComponent } from "@nanahoshi/mona-ui/popup-menu";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Add the components you need to your standalone component's `imports` array. Pass the element that opens the menu as `target`.
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<button #actions monaButton type="button" aria-label="Row actions" aria-haspopup="menu">
|
|
31
|
+
<svg lucideEllipsis [size]="16" aria-hidden="true"></svg>
|
|
32
|
+
</button>
|
|
33
|
+
|
|
34
|
+
<mona-popup-menu [target]="actions" (menuClick)="onAction($event)">
|
|
35
|
+
<mona-popup-menu-item label="Edit" value="edit"></mona-popup-menu-item>
|
|
36
|
+
<mona-popup-menu-item label="Delete" value="delete"></mona-popup-menu-item>
|
|
37
|
+
</mona-popup-menu>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import type { PopupMenuItemClickEvent } from "@nanahoshi/mona-ui/popup-menu";
|
|
42
|
+
|
|
43
|
+
protected onAction(event: PopupMenuItemClickEvent): void {
|
|
44
|
+
console.log(event.value);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Anatomy
|
|
49
|
+
|
|
50
|
+
Items are projected directly inside `<mona-popup-menu>`.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
mona-popup-menu
|
|
54
|
+
├── mona-popup-menu-item — an action; items projected inside it make a submenu
|
|
55
|
+
├── mona-popup-menu-group — consecutive items under a title
|
|
56
|
+
│ └── mona-popup-menu-item
|
|
57
|
+
├── mona-popup-menu-separator — a divider
|
|
58
|
+
├── mona-popup-menu-checkbox-item — an on/off setting
|
|
59
|
+
└── mona-popup-menu-radio-group — one choice among several
|
|
60
|
+
└── mona-popup-menu-radio-item
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Template directives
|
|
64
|
+
|
|
65
|
+
A template placed directly inside `<mona-popup-menu>` applies to every matching item. One placed inside an item applies to that item only.
|
|
66
|
+
|
|
67
|
+
| Directive | Applies to | `$implicit` |
|
|
68
|
+
|--------------------------------|------------|---------------------|
|
|
69
|
+
| `monaPopupMenuGroupTemplate` | Menu | The group's title |
|
|
70
|
+
| `monaPopupMenuIconTemplate` | Menu, item | The menu item |
|
|
71
|
+
| `monaPopupMenuShortcutTemplate`| Menu, item | The menu item |
|
|
72
|
+
| `monaPopupMenuTextTemplate` | Menu, item | The menu item |
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
### Submenus, groups and separators
|
|
77
|
+
|
|
78
|
+
Items projected inside an item make a submenu. Since the target is your own button, the example sets its `aria-haspopup` and `aria-expanded`, and follows the menu's `open` and `close` events.
|
|
79
|
+
|
|
80
|
+
`submenus-example.component.ts`
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { Component, signal } from "@angular/core";
|
|
84
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
85
|
+
import {
|
|
86
|
+
PopupMenuComponent,
|
|
87
|
+
PopupMenuGroupComponent,
|
|
88
|
+
PopupMenuItemComponent,
|
|
89
|
+
PopupMenuSeparatorComponent
|
|
90
|
+
} from "@nanahoshi/mona-ui/popup-menu";
|
|
91
|
+
|
|
92
|
+
@Component({
|
|
93
|
+
selector: "app-popup-menu-submenus-example",
|
|
94
|
+
imports: [
|
|
95
|
+
ButtonDirective,
|
|
96
|
+
PopupMenuComponent,
|
|
97
|
+
PopupMenuGroupComponent,
|
|
98
|
+
PopupMenuItemComponent,
|
|
99
|
+
PopupMenuSeparatorComponent
|
|
100
|
+
],
|
|
101
|
+
templateUrl: "./submenus-example.component.html"
|
|
102
|
+
})
|
|
103
|
+
export class PopupMenuSubmenusExampleComponent {
|
|
104
|
+
protected readonly lastAction = signal("none");
|
|
105
|
+
protected readonly open = signal(false);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`submenus-example.component.html`
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
113
|
+
<button #more monaButton aria-haspopup="menu" type="button" [attr.aria-expanded]="open()">File actions</button>
|
|
114
|
+
<span aria-live="polite" class="text-sm">Last action: {{ lastAction() }}</span>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<mona-popup-menu
|
|
118
|
+
aria-label="File actions"
|
|
119
|
+
[target]="more"
|
|
120
|
+
(close)="open.set(false)"
|
|
121
|
+
(menuClick)="lastAction.set($event.label)"
|
|
122
|
+
(open)="open.set(true)">
|
|
123
|
+
<mona-popup-menu-group title="File">
|
|
124
|
+
<mona-popup-menu-item label="Rename" />
|
|
125
|
+
<mona-popup-menu-item label="Share">
|
|
126
|
+
<mona-popup-menu-item label="Copy link" />
|
|
127
|
+
<mona-popup-menu-item label="Email" />
|
|
128
|
+
</mona-popup-menu-item>
|
|
129
|
+
</mona-popup-menu-group>
|
|
130
|
+
<mona-popup-menu-separator />
|
|
131
|
+
<mona-popup-menu-item label="Delete" [disabled]="true" />
|
|
132
|
+
</mona-popup-menu>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Checkbox and radio items
|
|
136
|
+
|
|
137
|
+
`checkable-example.component.ts`
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { Component, signal } from "@angular/core";
|
|
141
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
142
|
+
import {
|
|
143
|
+
PopupMenuCheckboxItemComponent,
|
|
144
|
+
PopupMenuComponent,
|
|
145
|
+
PopupMenuRadioGroupComponent,
|
|
146
|
+
PopupMenuRadioItemComponent,
|
|
147
|
+
PopupMenuSeparatorComponent
|
|
148
|
+
} from "@nanahoshi/mona-ui/popup-menu";
|
|
149
|
+
|
|
150
|
+
@Component({
|
|
151
|
+
selector: "app-popup-menu-checkable-example",
|
|
152
|
+
imports: [
|
|
153
|
+
ButtonDirective,
|
|
154
|
+
PopupMenuCheckboxItemComponent,
|
|
155
|
+
PopupMenuComponent,
|
|
156
|
+
PopupMenuRadioGroupComponent,
|
|
157
|
+
PopupMenuRadioItemComponent,
|
|
158
|
+
PopupMenuSeparatorComponent
|
|
159
|
+
],
|
|
160
|
+
templateUrl: "./checkable-example.component.html"
|
|
161
|
+
})
|
|
162
|
+
export class PopupMenuCheckableExampleComponent {
|
|
163
|
+
protected readonly open = signal(false);
|
|
164
|
+
protected readonly showHidden = signal(false);
|
|
165
|
+
protected readonly sort = signal("name");
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`checkable-example.component.html`
|
|
170
|
+
|
|
171
|
+
```html
|
|
172
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
173
|
+
<button #view monaButton aria-haspopup="menu" type="button" [attr.aria-expanded]="open()">View options</button>
|
|
174
|
+
<span class="text-sm">Hidden files: {{ showHidden() ? "shown" : "not shown" }}. Sorted by {{ sort() }}.</span>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<mona-popup-menu aria-label="View options" [target]="view" (close)="open.set(false)" (open)="open.set(true)">
|
|
178
|
+
<mona-popup-menu-checkbox-item label="Show hidden files" [(checked)]="showHidden" />
|
|
179
|
+
<mona-popup-menu-separator />
|
|
180
|
+
<mona-popup-menu-radio-group title="Sort by" [(value)]="sort">
|
|
181
|
+
<mona-popup-menu-radio-item label="Name" value="name" />
|
|
182
|
+
<mona-popup-menu-radio-item label="Date" value="date" />
|
|
183
|
+
<mona-popup-menu-radio-item label="Size" value="size" />
|
|
184
|
+
</mona-popup-menu-radio-group>
|
|
185
|
+
</mona-popup-menu>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Items from data
|
|
189
|
+
|
|
190
|
+
`items` takes plain `MenuItem` objects, and replaces any projected items when it isn't empty. Give each item a `value`, and read it from the click event.
|
|
191
|
+
|
|
192
|
+
`data-example.component.ts`
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { Component, signal } from "@angular/core";
|
|
196
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
197
|
+
import type { MenuItem, PopupMenuItemClickEvent } from "@nanahoshi/mona-ui/popup-menu";
|
|
198
|
+
import { PopupMenuComponent } from "@nanahoshi/mona-ui/popup-menu";
|
|
199
|
+
|
|
200
|
+
@Component({
|
|
201
|
+
selector: "app-popup-menu-data-example",
|
|
202
|
+
imports: [ButtonDirective, PopupMenuComponent],
|
|
203
|
+
templateUrl: "./data-example.component.html"
|
|
204
|
+
})
|
|
205
|
+
export class PopupMenuDataExampleComponent {
|
|
206
|
+
protected readonly items: MenuItem[] = [
|
|
207
|
+
{ label: "Edit", value: "edit" },
|
|
208
|
+
{
|
|
209
|
+
label: "Share",
|
|
210
|
+
items: [
|
|
211
|
+
{ label: "Copy link", value: "copy-link" },
|
|
212
|
+
{ label: "Email", value: "email" }
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{ label: "", separator: true },
|
|
216
|
+
{ label: "Archive", value: "archive" }
|
|
217
|
+
];
|
|
218
|
+
protected readonly lastValue = signal("none");
|
|
219
|
+
protected readonly open = signal(false);
|
|
220
|
+
|
|
221
|
+
protected onAction(event: PopupMenuItemClickEvent): void {
|
|
222
|
+
this.lastValue.set(String(event.value));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`data-example.component.html`
|
|
228
|
+
|
|
229
|
+
```html
|
|
230
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
231
|
+
<button #actions monaButton aria-haspopup="menu" type="button" [attr.aria-expanded]="open()">Actions</button>
|
|
232
|
+
<span aria-live="polite" class="text-sm">Last value: {{ lastValue() }}</span>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<mona-popup-menu
|
|
236
|
+
aria-label="Actions"
|
|
237
|
+
[items]="items"
|
|
238
|
+
[target]="actions"
|
|
239
|
+
(close)="open.set(false)"
|
|
240
|
+
(menuClick)="onAction($event)"
|
|
241
|
+
(open)="open.set(true)" />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Icons and shortcuts
|
|
245
|
+
|
|
246
|
+
Icons are decorative here, so they get `aria-hidden="true"`. The shortcut text only shows the keys; binding them is up to you.
|
|
247
|
+
|
|
248
|
+
`icons-example.component.ts`
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { Component, signal } from "@angular/core";
|
|
252
|
+
import { LucideCopy, LucideFolderOpen, LucideSave } from "@lucide/angular";
|
|
253
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
254
|
+
import {
|
|
255
|
+
PopupMenuComponent,
|
|
256
|
+
PopupMenuIconTemplateDirective,
|
|
257
|
+
PopupMenuItemComponent,
|
|
258
|
+
PopupMenuShortcutTemplateDirective
|
|
259
|
+
} from "@nanahoshi/mona-ui/popup-menu";
|
|
260
|
+
|
|
261
|
+
@Component({
|
|
262
|
+
selector: "app-popup-menu-icons-example",
|
|
263
|
+
imports: [
|
|
264
|
+
ButtonDirective,
|
|
265
|
+
LucideCopy,
|
|
266
|
+
LucideFolderOpen,
|
|
267
|
+
LucideSave,
|
|
268
|
+
PopupMenuComponent,
|
|
269
|
+
PopupMenuIconTemplateDirective,
|
|
270
|
+
PopupMenuItemComponent,
|
|
271
|
+
PopupMenuShortcutTemplateDirective
|
|
272
|
+
],
|
|
273
|
+
templateUrl: "./icons-example.component.html"
|
|
274
|
+
})
|
|
275
|
+
export class PopupMenuIconsExampleComponent {
|
|
276
|
+
protected readonly open = signal(false);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
`icons-example.component.html`
|
|
281
|
+
|
|
282
|
+
```html
|
|
283
|
+
<button #file monaButton aria-haspopup="menu" type="button" [attr.aria-expanded]="open()">File</button>
|
|
284
|
+
|
|
285
|
+
<mona-popup-menu aria-label="File" [target]="file" (close)="open.set(false)" (open)="open.set(true)">
|
|
286
|
+
<mona-popup-menu-item label="Open">
|
|
287
|
+
<ng-template monaPopupMenuIconTemplate>
|
|
288
|
+
<svg lucideFolderOpen aria-hidden="true" [size]="14"></svg>
|
|
289
|
+
</ng-template>
|
|
290
|
+
<ng-template monaPopupMenuShortcutTemplate>
|
|
291
|
+
<span class="text-xs">Ctrl + O</span>
|
|
292
|
+
</ng-template>
|
|
293
|
+
</mona-popup-menu-item>
|
|
294
|
+
<mona-popup-menu-item label="Save">
|
|
295
|
+
<ng-template monaPopupMenuIconTemplate>
|
|
296
|
+
<svg lucideSave aria-hidden="true" [size]="14"></svg>
|
|
297
|
+
</ng-template>
|
|
298
|
+
<ng-template monaPopupMenuShortcutTemplate>
|
|
299
|
+
<span class="text-xs">Ctrl + S</span>
|
|
300
|
+
</ng-template>
|
|
301
|
+
</mona-popup-menu-item>
|
|
302
|
+
<mona-popup-menu-item label="Duplicate">
|
|
303
|
+
<ng-template monaPopupMenuIconTemplate>
|
|
304
|
+
<svg lucideCopy aria-hidden="true" [size]="14"></svg>
|
|
305
|
+
</ng-template>
|
|
306
|
+
</mona-popup-menu-item>
|
|
307
|
+
</mona-popup-menu>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Opening it from code
|
|
311
|
+
|
|
312
|
+
Set `trigger` to `"none"` when the target shouldn't open the menu by itself, and call `openMenu()` when it should open. The target still decides where it appears.
|
|
313
|
+
|
|
314
|
+
```html
|
|
315
|
+
<div #row>{{ name() }}</div>
|
|
316
|
+
<mona-popup-menu #rowMenu trigger="none" [target]="row">
|
|
317
|
+
<mona-popup-menu-item label="Edit"></mona-popup-menu-item>
|
|
318
|
+
</mona-popup-menu>
|
|
319
|
+
<button monaButton type="button" (click)="rowMenu.openMenu()">Show actions</button>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Positioning against another element
|
|
323
|
+
|
|
324
|
+
`anchor` positions the menu against a different element from the one that opens it. The connection points choose which corner of each attaches to the other.
|
|
325
|
+
|
|
326
|
+
```html
|
|
327
|
+
<div #toolbar class="flex">
|
|
328
|
+
<button #overflow monaButton type="button" aria-label="More" aria-haspopup="menu">…</button>
|
|
329
|
+
</div>
|
|
330
|
+
<mona-popup-menu
|
|
331
|
+
anchorConnectionPoint="bottomleft"
|
|
332
|
+
popupConnectionPoint="topleft"
|
|
333
|
+
[anchor]="toolbar"
|
|
334
|
+
[offset]="{ horizontal: 0, vertical: 2 }"
|
|
335
|
+
[target]="overflow">
|
|
336
|
+
<mona-popup-menu-item label="Export"></mona-popup-menu-item>
|
|
337
|
+
</mona-popup-menu>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Appearance & Styling
|
|
341
|
+
|
|
342
|
+
`size` and `rounded` apply to the menu and its submenus, and so do `width` and `minWidth`, which take a number of pixels or a CSS length. `class` adds classes to the menu's popup.
|
|
343
|
+
|
|
344
|
+
```html
|
|
345
|
+
<mona-popup-menu class="max-h-80" rounded="large" size="small" [minWidth]="200" [target]="actions">
|
|
346
|
+
<mona-popup-menu-item label="Edit"></mona-popup-menu-item>
|
|
347
|
+
</mona-popup-menu>
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Behavior
|
|
351
|
+
|
|
352
|
+
- **Toggling:** with `trigger="click"`, clicking the target while the menu is open closes it.
|
|
353
|
+
- **Closing:** the menu closes when an item is activated, on `Escape`, on a click outside, and on scroll.
|
|
354
|
+
- **Keeping it open:** call `preventDefault()` on the `menuClick` event to keep the menu open and leave a checkbox or radio item as it was. Prevented on the item, the menu's own `menuClick` isn't emitted. Calling it on the `close` event stops that close.
|
|
355
|
+
- **Checkable data items:** a `MenuItem` with `checkable` holds its state inside the menu. Read the new state from the event's `checked`, and keep it in your items if they can be replaced.
|
|
356
|
+
- **Disabled items** stay in the arrow-key order, so screen reader users learn they exist, but they can't be activated.
|
|
357
|
+
- **Target element:** `target` must be an element in the DOM, passed as a template reference or an `ElementRef`.
|
|
358
|
+
|
|
359
|
+
## Accessibility
|
|
360
|
+
|
|
361
|
+
Inside the menu, the keyboard works the same as in every Mona UI menu:
|
|
362
|
+
|
|
363
|
+
| Key | Action |
|
|
364
|
+
|-----------------------------------|------------------------------------------------------------------------|
|
|
365
|
+
| `ArrowDown` / `ArrowUp` | The next or previous item, wrapping around. |
|
|
366
|
+
| `Home` / `End` | The first or last item. |
|
|
367
|
+
| `ArrowRight` (`ArrowLeft` in RTL) | Opens the highlighted item's submenu. |
|
|
368
|
+
| `ArrowLeft` (`ArrowRight` in RTL) | Closes the submenu, back to its parent item. |
|
|
369
|
+
| `Enter` / `Space` | Activates the item, or opens its submenu. |
|
|
370
|
+
| `Escape` | Closes the open submenu, or the menu. |
|
|
371
|
+
| `Tab` | Closes every open menu, and focus moves on from where the menu opened. |
|
|
372
|
+
| A letter, digit, `-` or `_` | Jumps to the next item whose label starts with what was typed. |
|
|
373
|
+
|
|
374
|
+
When the menu closes, focus returns to where it was when the menu opened, or to the target if it can take focus.
|
|
375
|
+
|
|
376
|
+
**What you provide:** unlike `DropdownButtonComponent`, this component doesn't change your target element, so its ARIA is yours to set.
|
|
377
|
+
|
|
378
|
+
- Use a focusable element as the target, ideally a native `<button>`, so `Enter` and `Space` can open the menu.
|
|
379
|
+
- Give the target `aria-haspopup="menu"`, `aria-expanded`, and `aria-controls` while the menu is open.
|
|
380
|
+
- Name the menu with `aria-label` or `aria-labelledby`. Without either, the menu is named by the target if it has an `id`.
|
|
381
|
+
- To open with a highlighted item as a dropdown button does, call `openMenuViaKeyboard()` from your key handler.
|
|
382
|
+
|
|
383
|
+
```html
|
|
384
|
+
<button
|
|
385
|
+
#actions
|
|
386
|
+
id="row-actions"
|
|
387
|
+
monaButton
|
|
388
|
+
type="button"
|
|
389
|
+
aria-haspopup="menu"
|
|
390
|
+
[attr.aria-controls]="menuOpen() ? 'row-actions-menu' : null"
|
|
391
|
+
[attr.aria-expanded]="menuOpen()"
|
|
392
|
+
(keydown.arrowdown)="$event.preventDefault(); menu.openMenuViaKeyboard()"
|
|
393
|
+
(keydown.arrowup)="$event.preventDefault(); menu.openMenuViaKeyboard(false, 'last')">
|
|
394
|
+
Actions
|
|
395
|
+
</button>
|
|
396
|
+
|
|
397
|
+
<mona-popup-menu
|
|
398
|
+
#menu
|
|
399
|
+
id="row-actions-menu"
|
|
400
|
+
[target]="actions"
|
|
401
|
+
(close)="menuOpen.set(false)"
|
|
402
|
+
(open)="menuOpen.set(true)">
|
|
403
|
+
<mona-popup-menu-item label="Edit"></mona-popup-menu-item>
|
|
404
|
+
</mona-popup-menu>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## API
|
|
408
|
+
|
|
409
|
+
Everything below is imported from `@nanahoshi/mona-ui/popup-menu`.
|
|
410
|
+
|
|
411
|
+
### `PopupMenuComponent`
|
|
412
|
+
|
|
413
|
+
**Selector:** `mona-popup-menu`
|
|
414
|
+
|
|
415
|
+
#### Inputs
|
|
416
|
+
|
|
417
|
+
| Name | Type | Default | Description |
|
|
418
|
+
| --- | --- | --- | --- |
|
|
419
|
+
| `anchor` | `ElementRef<HTMLElement> \| Element` | — | The element to position the menu against, when it isn't the `target`. Ignored when `openAtPointer` is set. |
|
|
420
|
+
| `anchorConnectionPoint` | `ConnectionPoint \| null` | — | The point on the anchor that the menu attaches to. Ignored when `openAtPointer` is set. |
|
|
421
|
+
| `aria-label` | `string` | `""` | The accessible name of the root menu. Takes precedence over `aria-labelledby`. |
|
|
422
|
+
| `aria-labelledby` | `string` | `""` | The ids of the elements that name the root menu. When neither this nor `aria-label` is set, the menu is named by the target element if it has an id. |
|
|
423
|
+
| `class` | `ClassInputType` | `undefined` | Extra classes for the menu's popup. |
|
|
424
|
+
| `id` | `string` | `""` | The id of the popup menu's root element. |
|
|
425
|
+
| `items` | `Iterable<PopupMenuItem \| MenuItem>` | `[]` | The items to render in the popup menu. If provided, it will override the menu items defined by projected menu item components. |
|
|
426
|
+
| `minWidth` | `string \| number` | — | Sets the minimum width of the popup menu. This will be applied to the root menu and all submenus. |
|
|
427
|
+
| `offset` | `PopupOffset` | — | The distance between the menu and its anchor. |
|
|
428
|
+
| `openAtPointer` | `boolean` | `false` | Opens the menu where the pointer is, instead of against the `anchor` or `target`. Opened from the keyboard, it opens at the center of the target. |
|
|
429
|
+
| `popupConnectionPoint` | `ConnectionPoint \| null` | — | The point on the menu that attaches to the anchor. Ignored when `openAtPointer` is set. |
|
|
430
|
+
| `rounded` | `"large" \| "medium" \| "none" \| "small"` | `"medium"` | Sets the border radius of the popup menu. This will be applied to the root menu and all submenus. |
|
|
431
|
+
| `size` | `"large" \| "medium" \| "small"` | `"medium"` | Sets the size of the popup menu. This will be applied to the root menu and all submenus. |
|
|
432
|
+
| `target` (required) | `ElementRef<HTMLElement> \| Element` | — | The element that opens the menu. The menu is positioned against it unless `anchor` is set. |
|
|
433
|
+
| `trigger` | `PopupMenuTrigger` | `"click"` | What opens the menu: a click on the target, a right-click on it, or `"none"` to open it only through `openMenu()`. |
|
|
434
|
+
| `width` | `string \| number` | — | Sets the width of the popup menu. This will be applied to the root menu and all submenus. |
|
|
435
|
+
|
|
436
|
+
#### Outputs
|
|
437
|
+
|
|
438
|
+
| Name | Type | Description |
|
|
439
|
+
| --- | --- | --- |
|
|
440
|
+
| `close` | `PopupMenuCloseEvent` | The event that is emitted when the popup menu is closed. |
|
|
441
|
+
| `menuClick` | `PopupMenuItemClickEvent` | The event that is emitted when a menu item is clicked. |
|
|
442
|
+
| `navigate` | `PopupMenuNavigationEvent` | Emitted when an arrow key moves through the menu, or tries to leave it. |
|
|
443
|
+
| `open` | `void` | The event that is emitted when the popup menu is opened. |
|
|
444
|
+
|
|
445
|
+
#### Methods
|
|
446
|
+
|
|
447
|
+
| Signature | Description |
|
|
448
|
+
| --- | --- |
|
|
449
|
+
| `clearFocusRestoration(): void` | Keeps focus where it is when the open menu closes, instead of returning it to the element that had it before the menu opened. Used when another menu takes over, as in a menubar. |
|
|
450
|
+
| `closeMenu(): void` | Closes the menu. Focus returns to the element that had it before the menu opened, unless focus has already moved elsewhere. |
|
|
451
|
+
| `openMenu(viaContextMenuKey: boolean = false): void` | Opens the menu, as if the target had been clicked. |
|
|
452
|
+
| `openMenuViaKeyboard(viaContextMenuKey: boolean = false, focus: PopupMenuInitialFocus = "first"): void` | Opens the menu as the keyboard does, with its first (or last) item highlighted. |
|
|
453
|
+
| `setRestoreFocusForKeyboard(): void` | **Deprecated.** Focus now returns to the element that had it before the menu opened after every close. |
|
|
454
|
+
|
|
455
|
+
### `PopupMenuCheckboxItemComponent`
|
|
456
|
+
|
|
457
|
+
**Selector:** `mona-popup-menu-checkbox-item`
|
|
458
|
+
|
|
459
|
+
#### Inputs
|
|
460
|
+
|
|
461
|
+
| Name | Type | Default | Description |
|
|
462
|
+
| --- | --- | --- | --- |
|
|
463
|
+
| `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. |
|
|
464
|
+
| `disabled` | `boolean` | `false` | Sets the disabled state of the menu item. |
|
|
465
|
+
| `label` | `string` | `""` | The text of the menu item. |
|
|
466
|
+
| `value` | `unknown` | — | A value that identifies the item. It's the `value` of the item's `menuClick` events. |
|
|
467
|
+
|
|
468
|
+
#### Outputs
|
|
469
|
+
|
|
470
|
+
| Name | Type | Description |
|
|
471
|
+
| --- | --- | --- |
|
|
472
|
+
| `checkedChange` | `boolean` | Emitted when `checked` changes. |
|
|
473
|
+
| `menuClick` | `PopupMenuItemClickEvent` | The click event of the menu item. Emits when the menu item is selected by keyboard or mouse. |
|
|
474
|
+
|
|
475
|
+
### `PopupMenuItemComponent`
|
|
476
|
+
|
|
477
|
+
**Selector:** `mona-popup-menu-item`
|
|
478
|
+
|
|
479
|
+
#### Inputs
|
|
480
|
+
|
|
481
|
+
| Name | Type | Default | Description |
|
|
482
|
+
| --- | --- | --- | --- |
|
|
483
|
+
| `disabled` | `boolean` | `false` | Sets the disabled state of the menu item. |
|
|
484
|
+
| `label` | `string` | `""` | The text of the menu item. |
|
|
485
|
+
| `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. |
|
|
486
|
+
|
|
487
|
+
#### Outputs
|
|
488
|
+
|
|
489
|
+
| Name | Type | Description |
|
|
490
|
+
| --- | --- | --- |
|
|
491
|
+
| `menuClick` | `PopupMenuItemClickEvent` | The click event of the menu item. Emits when the menu item is selected by keyboard or mouse. |
|
|
492
|
+
|
|
493
|
+
### `PopupMenuRadioItemComponent`
|
|
494
|
+
|
|
495
|
+
**Selector:** `mona-popup-menu-radio-item`
|
|
496
|
+
|
|
497
|
+
#### Inputs
|
|
498
|
+
|
|
499
|
+
| Name | Type | Default | Description |
|
|
500
|
+
| --- | --- | --- | --- |
|
|
501
|
+
| `disabled` | `boolean` | `false` | Sets the disabled state of the menu item. |
|
|
502
|
+
| `label` | `string` | `""` | The text of the menu item. |
|
|
503
|
+
| `value` (required) | `string` | — | The value of the radio item. |
|
|
504
|
+
|
|
505
|
+
#### Outputs
|
|
506
|
+
|
|
507
|
+
| Name | Type | Description |
|
|
508
|
+
| --- | --- | --- |
|
|
509
|
+
| `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. |
|
|
510
|
+
|
|
511
|
+
### `PopupMenuRadioGroupComponent`
|
|
512
|
+
|
|
513
|
+
**Selector:** `mona-popup-menu-radio-group`
|
|
514
|
+
|
|
515
|
+
#### Inputs
|
|
516
|
+
|
|
517
|
+
| Name | Type | Default | Description |
|
|
518
|
+
| --- | --- | --- | --- |
|
|
519
|
+
| `title` | `string` | `""` | The title of the radio group. |
|
|
520
|
+
| `value` (two-way) | `string` | `""` | The value of the selected radio item. |
|
|
521
|
+
|
|
522
|
+
#### Outputs
|
|
523
|
+
|
|
524
|
+
| Name | Type | Description |
|
|
525
|
+
| --- | --- | --- |
|
|
526
|
+
| `valueChange` | `string` | Emitted when `value` changes. |
|
|
527
|
+
|
|
528
|
+
### `PopupMenuGroupComponent`
|
|
529
|
+
|
|
530
|
+
**Selector:** `mona-popup-menu-group`
|
|
531
|
+
|
|
532
|
+
#### Inputs
|
|
533
|
+
|
|
534
|
+
| Name | Type | Default | Description |
|
|
535
|
+
| --- | --- | --- | --- |
|
|
536
|
+
| `title` | `string` | — | Sets the title of the menu group. |
|
|
537
|
+
|
|
538
|
+
### `PopupMenuSeparatorComponent`
|
|
539
|
+
|
|
540
|
+
**Selector:** `mona-popup-menu-separator`
|
|
541
|
+
|
|
542
|
+
### `PopupMenuGroupTemplateDirective`
|
|
543
|
+
|
|
544
|
+
**Selector:** `ng-template[monaPopupMenuGroupTemplate]`
|
|
545
|
+
|
|
546
|
+
### `PopupMenuIconTemplateDirective`
|
|
547
|
+
|
|
548
|
+
**Selector:** `ng-template[monaPopupMenuIconTemplate]`
|
|
549
|
+
|
|
550
|
+
### `PopupMenuShortcutTemplateDirective`
|
|
551
|
+
|
|
552
|
+
**Selector:** `ng-template[monaPopupMenuShortcutTemplate]`
|
|
553
|
+
|
|
554
|
+
### `PopupMenuTextTemplateDirective`
|
|
555
|
+
|
|
556
|
+
**Selector:** `ng-template[monaPopupMenuTextTemplate]`
|
|
557
|
+
|
|
558
|
+
### `PopupMenuCloseEvent`
|
|
559
|
+
|
|
560
|
+
**Extends:** `PreventableEvent`
|
|
561
|
+
|
|
562
|
+
### `PopupMenuItemClickEvent`
|
|
563
|
+
|
|
564
|
+
Emitted when a menu item is activated by a click, Enter or Space. Preventing it keeps the menu open and leaves a
|
|
565
|
+
checkbox or radio item's state unchanged.
|
|
566
|
+
|
|
567
|
+
**Extends:** `PreventableEvent`
|
|
568
|
+
|
|
569
|
+
#### Properties
|
|
570
|
+
|
|
571
|
+
| Name | Type | Description |
|
|
572
|
+
| --- | --- | --- |
|
|
573
|
+
| `checked` (read-only) | `boolean \| undefined` | For a checkbox or radio item, the state the item has once the click is applied (if it isn't prevented). `undefined` for other items. |
|
|
574
|
+
| `label` (read-only) | `string` | The item's label. |
|
|
575
|
+
| `value` (read-only) | `unknown` | The item's `value`: the `value` input of the item component, or the `value` of a `MenuItem`. |
|
|
576
|
+
|
|
577
|
+
### Types
|
|
578
|
+
|
|
579
|
+
#### `MenuItem`
|
|
580
|
+
|
|
581
|
+
| Name | Type | Description |
|
|
582
|
+
| --- | --- | --- |
|
|
583
|
+
| `checkable?` | `boolean` | Whether the item is a checkbox item. Its `checked` state toggles when it's activated, unless `menuClick` is prevented. The state lives in the menu: read the new state from the event's `checked` and keep it in your items if they can be replaced. |
|
|
584
|
+
| `checked?` | `boolean` | The item's initial checked state. |
|
|
585
|
+
| `disabled?` | `boolean` | Keeps the item from being activated. |
|
|
586
|
+
| `group?` | `string` | The title of the group the item belongs to. Consecutive items with the same group form one group. |
|
|
587
|
+
| `items?` | `MenuItem[]` | The items of its submenu. |
|
|
588
|
+
| `label` | `string` | Required. The item's text. |
|
|
589
|
+
| `separator?` | `boolean` | Renders the item as a divider. |
|
|
590
|
+
| `value?` | `unknown` | A value that identifies the item in `menuClick` (the event's `value`). |
|
|
591
|
+
|
|
592
|
+
#### `PopupMenuItem`
|
|
593
|
+
|
|
594
|
+
| Name | Type | Description |
|
|
595
|
+
| --- | --- | --- |
|
|
596
|
+
| `checkable?` | `boolean` | Whether the item is a checkbox item. |
|
|
597
|
+
| `checked?` | `Signal<boolean>` | The checked state of a checkbox item. |
|
|
598
|
+
| `disabled` | `boolean` | Whether the item can't be activated. |
|
|
599
|
+
| `group` | `string \| symbol` | The group the item belongs to. Consecutive items with the same key form a group. A string key, or a symbol with a description, is the group's title. |
|
|
600
|
+
| `items` | `PopupMenuItem[]` | The items of the item's submenu. Empty when it has none. |
|
|
601
|
+
| `label` | `string` | The item's text. |
|
|
602
|
+
| `radio?` | `boolean` | Whether the item is a radio item in a radio group. |
|
|
603
|
+
| `selected?` | `Signal<boolean>` | Whether a radio item is the selected item of its radio group. |
|
|
604
|
+
| `separator?` | `boolean` | Whether the item is a divider. |
|
|
605
|
+
| `value?` | `Signal<unknown>` | The item's value: the `value` input of the item component, or the `value` of a `MenuItem`. |
|
|
606
|
+
|
|
607
|
+
#### `PopupMenuNavigationEvent`
|
|
608
|
+
|
|
609
|
+
| Name | Type |
|
|
610
|
+
| --- | --- |
|
|
611
|
+
| `direction` | `"up" \| "down" \| "left" \| "right"` |
|
|
612
|
+
| `item` | `PopupMenuItem \| null` |
|
|
613
|
+
| `level` | `number` |
|
|
614
|
+
|
|
615
|
+
#### `PopupMenuInitialFocus`
|
|
616
|
+
|
|
617
|
+
The item a menu opened from the keyboard highlights first.
|
|
618
|
+
|
|
619
|
+
```typescript
|
|
620
|
+
type PopupMenuInitialFocus = "first" | "last";
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
#### `PopupMenuTrigger`
|
|
624
|
+
|
|
625
|
+
What opens a popup menu: a click on the target, a right-click on it, or `"none"` to open it only through
|
|
626
|
+
`openMenu()`.
|
|
627
|
+
|
|
628
|
+
```typescript
|
|
629
|
+
type PopupMenuTrigger = "click" | "contextmenu" | "none";
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
#### `ClassInputType`
|
|
633
|
+
|
|
634
|
+
From `@nanahoshi/mona-ui/common`.
|
|
635
|
+
|
|
636
|
+
```typescript
|
|
637
|
+
type ClassInputType = string | string[] | Record<string, unknown> | null | undefined;
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
#### `PreventableEvent`
|
|
641
|
+
|
|
642
|
+
From `@nanahoshi/mona-ui/common`.
|
|
643
|
+
|
|
644
|
+
**Type parameters:** `E extends Event = Event`
|
|
645
|
+
|
|
646
|
+
| Name | Type | Description |
|
|
647
|
+
| --- | --- | --- |
|
|
648
|
+
| `originalEvent` (read-only) | `E \| undefined` | The DOM event that caused this one, when there is one. |
|
|
649
|
+
| `type` (read-only) | `string \| undefined` | A name for the kind of event, when the component that emits it sets one. |
|
|
650
|
+
|
|
651
|
+
**Methods**
|
|
652
|
+
|
|
653
|
+
| Signature | Description |
|
|
654
|
+
| --- | --- |
|
|
655
|
+
| `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
|
|
656
|
+
| `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |
|
|
657
|
+
|
|
658
|
+
**Documented elsewhere:** [`ConnectionPoint`](popup.md), [`PopupOffset`](popup.md)
|