@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
package/docs/command.md
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
# Command Menu
|
|
2
|
+
|
|
3
|
+
> A searchable list of actions or options, operated from one input, inline or in a dialog.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/command`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-command`
|
|
8
|
+
|
|
9
|
+
`CommandComponent` is a searchable list of actions or options, operated from one input. Use it inline, in a popover, or in a `CommandDialogComponent` opened with a shortcut.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Use the command menu when people should reach something by typing its name: an application's actions, a search across pages, or a picker with many options. It runs nothing by itself. Choosing an item emits an event, and your code decides what happens and whether the menu closes.
|
|
14
|
+
|
|
15
|
+
**Use a closely related Mona UI component instead when:**
|
|
16
|
+
|
|
17
|
+
- The choice is a form value: use `ComboBoxComponent` or `AutoCompleteComponent`, which work with forms.
|
|
18
|
+
- There are only a few actions, and no need to search: use `PopupMenuComponent`.
|
|
19
|
+
|
|
20
|
+
## Import & Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import {
|
|
24
|
+
CommandComponent,
|
|
25
|
+
CommandEmptyComponent,
|
|
26
|
+
CommandInputComponent,
|
|
27
|
+
CommandItemComponent,
|
|
28
|
+
CommandListComponent
|
|
29
|
+
} from "@nanahoshi/mona-ui/command";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<mona-command (itemSelect)="run($event.value)">
|
|
34
|
+
<mona-command-input />
|
|
35
|
+
<mona-command-list>
|
|
36
|
+
<mona-command-empty />
|
|
37
|
+
<mona-command-item value="New file">New file</mona-command-item>
|
|
38
|
+
<mona-command-item value="Open file" [keywords]="['load']">Open file</mona-command-item>
|
|
39
|
+
</mona-command-list>
|
|
40
|
+
</mona-command>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Anatomy
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<mona-command>
|
|
47
|
+
<mona-command-header>A strip for filters or a title</mona-command-header>
|
|
48
|
+
<mona-command-input />
|
|
49
|
+
<mona-command-list>
|
|
50
|
+
<mona-command-empty />
|
|
51
|
+
<mona-command-loading />
|
|
52
|
+
<mona-command-group heading="Files">
|
|
53
|
+
<mona-command-item value="New file">
|
|
54
|
+
<mona-command-highlight text="New file" />
|
|
55
|
+
<mona-command-shortcut keys="mod+n" />
|
|
56
|
+
</mona-command-item>
|
|
57
|
+
</mona-command-group>
|
|
58
|
+
<mona-command-separator />
|
|
59
|
+
</mona-command-list>
|
|
60
|
+
<mona-command-footer>A strip for key hints</mona-command-footer>
|
|
61
|
+
</mona-command>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Place `mona-command-empty` and `mona-command-loading` directly inside `mona-command-list`, which keeps them out of the listbox. Items can come from any depth, including your own components, as long as they're inside the `mona-command`.
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
### An action palette in a dialog
|
|
69
|
+
|
|
70
|
+
`mona-command-dialog` renders its template while it's open. Set `shortcut` to open and close it from anywhere on the page. No key is bound unless you set one. `mod` is Command on Apple devices and Ctrl elsewhere.
|
|
71
|
+
|
|
72
|
+
`dialog-example.component.ts`
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { Component, signal } from "@angular/core";
|
|
76
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
77
|
+
import {
|
|
78
|
+
CommandComponent,
|
|
79
|
+
CommandDialogComponent,
|
|
80
|
+
CommandDialogContentDirective,
|
|
81
|
+
CommandEmptyComponent,
|
|
82
|
+
CommandHighlightComponent,
|
|
83
|
+
CommandInputComponent,
|
|
84
|
+
CommandItemComponent,
|
|
85
|
+
CommandListComponent,
|
|
86
|
+
CommandShortcutComponent
|
|
87
|
+
} from "@nanahoshi/mona-ui/command";
|
|
88
|
+
|
|
89
|
+
@Component({
|
|
90
|
+
selector: "app-command-dialog-example",
|
|
91
|
+
imports: [
|
|
92
|
+
ButtonDirective,
|
|
93
|
+
CommandComponent,
|
|
94
|
+
CommandDialogComponent,
|
|
95
|
+
CommandDialogContentDirective,
|
|
96
|
+
CommandEmptyComponent,
|
|
97
|
+
CommandHighlightComponent,
|
|
98
|
+
CommandInputComponent,
|
|
99
|
+
CommandItemComponent,
|
|
100
|
+
CommandListComponent,
|
|
101
|
+
CommandShortcutComponent
|
|
102
|
+
],
|
|
103
|
+
templateUrl: "./dialog-example.component.html"
|
|
104
|
+
})
|
|
105
|
+
export class CommandDialogExampleComponent {
|
|
106
|
+
protected readonly actions = ["Go to settings", "Invite a teammate", "Sign out"];
|
|
107
|
+
protected readonly lastAction = signal("none");
|
|
108
|
+
protected readonly open = signal(false);
|
|
109
|
+
|
|
110
|
+
protected run(action: string): void {
|
|
111
|
+
this.lastAction.set(action);
|
|
112
|
+
this.open.set(false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`dialog-example.component.html`
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
121
|
+
<button monaButton type="button" (click)="open.set(true)">
|
|
122
|
+
Open command menu
|
|
123
|
+
<mona-command-shortcut class="ms-2" keys="mod+j" />
|
|
124
|
+
</button>
|
|
125
|
+
<span aria-live="polite" class="text-sm">Last action: {{ lastAction() }}</span>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<mona-command-dialog shortcut="mod+j" [(open)]="open">
|
|
129
|
+
<ng-template monaCommandDialogContent>
|
|
130
|
+
<mona-command (itemSelect)="run($event.value)">
|
|
131
|
+
<mona-command-input />
|
|
132
|
+
<mona-command-list>
|
|
133
|
+
<mona-command-empty />
|
|
134
|
+
@for (action of actions; track action) {
|
|
135
|
+
<mona-command-item [value]="action">
|
|
136
|
+
<mona-command-highlight [text]="action" />
|
|
137
|
+
</mona-command-item>
|
|
138
|
+
}
|
|
139
|
+
</mona-command-list>
|
|
140
|
+
</mona-command>
|
|
141
|
+
</ng-template>
|
|
142
|
+
</mona-command-dialog>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`mona-command-shortcut` only shows the keys. Binding them to the action is up to you.
|
|
146
|
+
|
|
147
|
+
### A picker in a popover
|
|
148
|
+
|
|
149
|
+
`picker-example.component.ts`
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { Component, signal } from "@angular/core";
|
|
153
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
154
|
+
import {
|
|
155
|
+
CommandComponent,
|
|
156
|
+
CommandEmptyComponent,
|
|
157
|
+
CommandHighlightComponent,
|
|
158
|
+
CommandInputComponent,
|
|
159
|
+
CommandItemComponent,
|
|
160
|
+
CommandListComponent
|
|
161
|
+
} from "@nanahoshi/mona-ui/command";
|
|
162
|
+
import { PopoverComponent } from "@nanahoshi/mona-ui/popover";
|
|
163
|
+
|
|
164
|
+
@Component({
|
|
165
|
+
selector: "app-command-picker-example",
|
|
166
|
+
imports: [
|
|
167
|
+
ButtonDirective,
|
|
168
|
+
CommandComponent,
|
|
169
|
+
CommandEmptyComponent,
|
|
170
|
+
CommandHighlightComponent,
|
|
171
|
+
CommandInputComponent,
|
|
172
|
+
CommandItemComponent,
|
|
173
|
+
CommandListComponent,
|
|
174
|
+
PopoverComponent
|
|
175
|
+
],
|
|
176
|
+
templateUrl: "./picker-example.component.html"
|
|
177
|
+
})
|
|
178
|
+
export class CommandPickerExampleComponent {
|
|
179
|
+
protected readonly assignee = signal("nobody");
|
|
180
|
+
protected readonly people = ["Ada Lovelace", "Grace Hopper", "José Martí", "Katherine Johnson", "Linus Torvalds"];
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`picker-example.component.html`
|
|
185
|
+
|
|
186
|
+
```html
|
|
187
|
+
<button #assign monaButton type="button">Assign to: {{ assignee() }}</button>
|
|
188
|
+
|
|
189
|
+
<mona-popover #popover="monaPopover" position="bottom" [target]="assign">
|
|
190
|
+
<mona-command class="w-64 border-0" (itemSelect)="assignee.set($event.value); popover.close()">
|
|
191
|
+
<mona-command-input aria-label="Find a person" placeholder="Find a person…" />
|
|
192
|
+
<mona-command-list>
|
|
193
|
+
<mona-command-empty />
|
|
194
|
+
@for (person of people; track person) {
|
|
195
|
+
<mona-command-item [value]="person">
|
|
196
|
+
<mona-command-highlight [text]="person" />
|
|
197
|
+
</mona-command-item>
|
|
198
|
+
}
|
|
199
|
+
</mona-command-list>
|
|
200
|
+
</mona-command>
|
|
201
|
+
</mona-popover>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Results from a server
|
|
205
|
+
|
|
206
|
+
With `filterMode="manual"` every item you render shows, because your results are already narrowed down. Angular's `resource` keeps only the answer to the latest query, so a slow, older response never replaces a newer one. Set `loading` from it to show `mona-command-loading` and hold back the empty state.
|
|
207
|
+
|
|
208
|
+
`server-example.component.ts`
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { Component, resource, signal } from "@angular/core";
|
|
212
|
+
import {
|
|
213
|
+
CommandComponent,
|
|
214
|
+
CommandEmptyComponent,
|
|
215
|
+
CommandFooterComponent,
|
|
216
|
+
CommandHighlightComponent,
|
|
217
|
+
CommandInputComponent,
|
|
218
|
+
CommandItemComponent,
|
|
219
|
+
CommandListComponent,
|
|
220
|
+
CommandLoadingComponent
|
|
221
|
+
} from "@nanahoshi/mona-ui/command";
|
|
222
|
+
|
|
223
|
+
const CITIES = ["Ankara", "Berlin", "Buenos Aires", "Cairo", "Kyoto", "Lagos", "Lima", "Oslo", "Seoul", "Toronto"];
|
|
224
|
+
|
|
225
|
+
/** Stands in for a server: it answers slowly, and more slowly for short queries, so answers can arrive out of order. */
|
|
226
|
+
const searchCities = (query: string, abortSignal: AbortSignal): Promise<string[]> =>
|
|
227
|
+
new Promise(resolve => {
|
|
228
|
+
const timer = setTimeout(
|
|
229
|
+
() => resolve(CITIES.filter(city => city.toLowerCase().includes(query.toLowerCase()))),
|
|
230
|
+
1200 / Math.max(query.length, 1) + 200
|
|
231
|
+
);
|
|
232
|
+
abortSignal.addEventListener("abort", () => {
|
|
233
|
+
clearTimeout(timer);
|
|
234
|
+
resolve([]);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
@Component({
|
|
239
|
+
selector: "app-command-server-example",
|
|
240
|
+
imports: [
|
|
241
|
+
CommandComponent,
|
|
242
|
+
CommandEmptyComponent,
|
|
243
|
+
CommandFooterComponent,
|
|
244
|
+
CommandHighlightComponent,
|
|
245
|
+
CommandInputComponent,
|
|
246
|
+
CommandItemComponent,
|
|
247
|
+
CommandListComponent,
|
|
248
|
+
CommandLoadingComponent
|
|
249
|
+
],
|
|
250
|
+
templateUrl: "./server-example.component.html"
|
|
251
|
+
})
|
|
252
|
+
export class CommandServerExampleComponent {
|
|
253
|
+
protected readonly chosen = signal("none");
|
|
254
|
+
protected readonly query = signal("");
|
|
255
|
+
protected readonly results = resource({
|
|
256
|
+
defaultValue: [],
|
|
257
|
+
loader: ({ abortSignal, params }) => searchCities(params, abortSignal),
|
|
258
|
+
params: () => this.query()
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`server-example.component.html`
|
|
264
|
+
|
|
265
|
+
```html
|
|
266
|
+
<mona-command
|
|
267
|
+
class="max-w-md"
|
|
268
|
+
filterMode="manual"
|
|
269
|
+
[loading]="results.isLoading()"
|
|
270
|
+
[(query)]="query"
|
|
271
|
+
(itemSelect)="chosen.set($event.value)">
|
|
272
|
+
<mona-command-input aria-label="Search cities" placeholder="Search cities…" />
|
|
273
|
+
<mona-command-list>
|
|
274
|
+
<mona-command-loading />
|
|
275
|
+
<mona-command-empty />
|
|
276
|
+
@for (result of results.value(); track result) {
|
|
277
|
+
<mona-command-item [value]="result">
|
|
278
|
+
<mona-command-highlight [text]="result" />
|
|
279
|
+
</mona-command-item>
|
|
280
|
+
}
|
|
281
|
+
</mona-command-list>
|
|
282
|
+
<mona-command-footer>
|
|
283
|
+
<span aria-live="polite">Chosen: {{ chosen() }}</span>
|
|
284
|
+
</mona-command-footer>
|
|
285
|
+
</mona-command>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Telling a modified choice apart
|
|
289
|
+
|
|
290
|
+
The select event carries the original click or key press, so Ctrl+Enter can do something different from Enter.
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
protected open(event: CommandSelectEvent): void {
|
|
294
|
+
const newTab = event.originalEvent.ctrlKey || event.originalEvent.metaKey;
|
|
295
|
+
this.navigate(event.value, newTab);
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### A custom filter
|
|
300
|
+
|
|
301
|
+
By default an item stays when every word of the query appears in its `value` or `keywords`, ignoring case and accents. The list keeps your order. Pass `filter` to change what counts as a match.
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
protected readonly startsWith: CommandFilter = (query, item) =>
|
|
305
|
+
item.value.toLowerCase().startsWith(query.toLowerCase());
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Appearance & Styling
|
|
309
|
+
|
|
310
|
+
Classes on `mona-command` and its parts add to their own, so `class="border-0"` removes the outer border inside a popover. The root takes a `rounded` input.
|
|
311
|
+
|
|
312
|
+
## Theming
|
|
313
|
+
|
|
314
|
+
| Variable | What it sets | Default |
|
|
315
|
+
|---|---|---|
|
|
316
|
+
| `--mona-command-background` | The background of the menu | `--color-surface` |
|
|
317
|
+
| `--mona-command-item-active-background` | The background of the active item | `--color-hover` |
|
|
318
|
+
| `--mona-command-list-max-height` | How tall the list gets before it scrolls | `20rem` |
|
|
319
|
+
|
|
320
|
+
## Behavior
|
|
321
|
+
|
|
322
|
+
- Focus stays in the input. The arrow keys move the active item, and Enter chooses it.
|
|
323
|
+
- The first result is active, so Enter always has something to choose while there are results. A new query goes back to the first result. New results for the same query keep the active item if it's still among them.
|
|
324
|
+
- Disabled items show, but the arrow keys skip them.
|
|
325
|
+
- Home and End stay with the input, where they move the caret.
|
|
326
|
+
- While an input method composes text, Enter and the arrow keys belong to it.
|
|
327
|
+
- A group hides when none of its items show. A separator hides while the component filters.
|
|
328
|
+
- `mona-command-dialog` closes on Escape and on a click outside. It creates its content each time it opens, so the query starts empty, unless you keep it in your own signal with `[(query)]`.
|
|
329
|
+
|
|
330
|
+
## Accessibility
|
|
331
|
+
|
|
332
|
+
- The input is a `combobox` that controls a `listbox`, and it points at the active item with `aria-activedescendant`.
|
|
333
|
+
- The number of results is announced through a polite live region after each search. The announcement waits while `loading` is on.
|
|
334
|
+
- The default labels come from the `command` messages, and `aria-label` on `mona-command-input`, `mona-command-list` and `mona-command-dialog` replaces them. Name an input for what it searches.
|
|
335
|
+
- `mona-command-dialog` is modal: the rest of the page is inert, focus moves to the input, and focus returns to where it was when the dialog closes.
|
|
336
|
+
- The active item uses the system highlight color in forced colors.
|
|
337
|
+
- The spoken key names in `mona-command-shortcut` are in English. Give the item an `aria-label` where that matters.
|
|
338
|
+
|
|
339
|
+
## API
|
|
340
|
+
|
|
341
|
+
Everything below is imported from `@nanahoshi/mona-ui/command`.
|
|
342
|
+
|
|
343
|
+
### `CommandComponent`
|
|
344
|
+
|
|
345
|
+
A searchable list of actions or options, operated from one input. It works inline, in a popover, or in a
|
|
346
|
+
`mona-command-dialog`. It only runs what the consumer asks for: choosing an item emits an event, and nothing closes
|
|
347
|
+
or navigates by itself.
|
|
348
|
+
|
|
349
|
+
**Selector:** `mona-command`
|
|
350
|
+
|
|
351
|
+
#### Inputs
|
|
352
|
+
|
|
353
|
+
| Name | Type | Default | Description |
|
|
354
|
+
| --- | --- | --- | --- |
|
|
355
|
+
| `filter` | `CommandFilter` | `defaultCommandFilter` | What counts as a match while `filterMode` is `"auto"`. |
|
|
356
|
+
| `filterMode` | `CommandFilterMode` | `"auto"` | Whether the component filters the items, or the consumer supplies only the matching ones. |
|
|
357
|
+
| `loading` | `boolean` | `false` | Whether results are on their way. Shows `mona-command-loading` and holds back the empty state. |
|
|
358
|
+
| `loop` | `boolean` | `true` | Whether the arrow keys wrap around at the ends of the list. |
|
|
359
|
+
| `query` (two-way) | `string` | `""` | The text in the input. |
|
|
360
|
+
| `rounded` | `"large" \| "medium" \| "none" \| "small"` | `"medium"` | The corner radius. |
|
|
361
|
+
|
|
362
|
+
#### Outputs
|
|
363
|
+
|
|
364
|
+
| Name | Type | Description |
|
|
365
|
+
| --- | --- | --- |
|
|
366
|
+
| `itemSelect` | `CommandSelectEvent` | Emits when any item is chosen, with the pointer or with Enter. |
|
|
367
|
+
| `queryChange` | `string` | Emitted when `query` changes. |
|
|
368
|
+
|
|
369
|
+
#### Methods
|
|
370
|
+
|
|
371
|
+
| Signature | Description |
|
|
372
|
+
| --- | --- |
|
|
373
|
+
| `focus(): void` | Moves focus to the input. |
|
|
374
|
+
|
|
375
|
+
### `CommandDialogComponent`
|
|
376
|
+
|
|
377
|
+
A modal for a `mona-command`. It stays near the top of the page instead of centering, so the input doesn't jump as
|
|
378
|
+
results come and go, and the `mona-command` inside is created each time it opens, so it starts with an empty query.
|
|
379
|
+
|
|
380
|
+
**Selector:** `mona-command-dialog`
|
|
381
|
+
|
|
382
|
+
#### Inputs
|
|
383
|
+
|
|
384
|
+
| Name | Type | Default | Description |
|
|
385
|
+
| --- | --- | --- | --- |
|
|
386
|
+
| `aria-label` | `string \| undefined` | `undefined` | The accessible name of the dialog. |
|
|
387
|
+
| `open` (two-way) | `boolean` | `false` | Whether the dialog is open. |
|
|
388
|
+
| `shortcut` | `string \| null` | `null` | A key combination that opens and closes the dialog from anywhere on the page, such as `mod+k`. `mod` is Command on Apple devices and Ctrl elsewhere. Nothing is bound unless this is set. |
|
|
389
|
+
| `width` | `number \| string` | `"36rem"` | The dialog's width. It never gets wider than the viewport. |
|
|
390
|
+
|
|
391
|
+
#### Outputs
|
|
392
|
+
|
|
393
|
+
| Name | Type | Description |
|
|
394
|
+
| --- | --- | --- |
|
|
395
|
+
| `openChange` | `boolean` | Emitted when `open` changes. |
|
|
396
|
+
|
|
397
|
+
### `CommandItemComponent`
|
|
398
|
+
|
|
399
|
+
One action or option in a `mona-command`. What it shows is its content; what it's found by is its value.
|
|
400
|
+
|
|
401
|
+
**Selector:** `mona-command-item`
|
|
402
|
+
|
|
403
|
+
#### Inputs
|
|
404
|
+
|
|
405
|
+
| Name | Type | Default | Description |
|
|
406
|
+
| --- | --- | --- | --- |
|
|
407
|
+
| `disabled` | `boolean` | `false` | Whether the item shows but can't be chosen. |
|
|
408
|
+
| `keywords` | `readonly string[]` | `[]` | Other words the item should be found by, such as synonyms. |
|
|
409
|
+
| `value` (required) | `string` | — | What the item is found by, and what the select event carries. |
|
|
410
|
+
|
|
411
|
+
#### Outputs
|
|
412
|
+
|
|
413
|
+
| Name | Type | Description |
|
|
414
|
+
| --- | --- | --- |
|
|
415
|
+
| `itemSelect` | `CommandSelectEvent` | Emits when this item is chosen, with the pointer or with Enter. |
|
|
416
|
+
|
|
417
|
+
### `CommandInputComponent`
|
|
418
|
+
|
|
419
|
+
The search field of a `mona-command`. Focus stays here while the arrow keys move through the list, so typing always
|
|
420
|
+
continues the search.
|
|
421
|
+
|
|
422
|
+
**Selector:** `mona-command-input`
|
|
423
|
+
|
|
424
|
+
#### Inputs
|
|
425
|
+
|
|
426
|
+
| Name | Type | Default | Description |
|
|
427
|
+
| --- | --- | --- | --- |
|
|
428
|
+
| `aria-label` | `string \| undefined` | `undefined` | The accessible name of the field. |
|
|
429
|
+
| `placeholder` | `string` | — | The text shown while the field is empty. |
|
|
430
|
+
|
|
431
|
+
### `CommandGroupComponent`
|
|
432
|
+
|
|
433
|
+
A titled set of items. It hides itself while none of its items show.
|
|
434
|
+
|
|
435
|
+
**Selector:** `mona-command-group`
|
|
436
|
+
|
|
437
|
+
#### Inputs
|
|
438
|
+
|
|
439
|
+
| Name | Type | Default | Description |
|
|
440
|
+
| --- | --- | --- | --- |
|
|
441
|
+
| `heading` | `string` | — | The title above the group's items. |
|
|
442
|
+
|
|
443
|
+
### `CommandHighlightComponent`
|
|
444
|
+
|
|
445
|
+
Shows a text with the parts the query matches marked. Marks the query's words, however the item was matched.
|
|
446
|
+
|
|
447
|
+
**Selector:** `mona-command-highlight`
|
|
448
|
+
|
|
449
|
+
#### Inputs
|
|
450
|
+
|
|
451
|
+
| Name | Type | Default | Description |
|
|
452
|
+
| --- | --- | --- | --- |
|
|
453
|
+
| `text` (required) | `string` | — | The text to show. |
|
|
454
|
+
|
|
455
|
+
### `CommandListComponent`
|
|
456
|
+
|
|
457
|
+
Holds the items of a `mona-command`, and scrolls them. The empty and loading states sit outside the listbox, which
|
|
458
|
+
may only contain options and groups.
|
|
459
|
+
|
|
460
|
+
**Selector:** `mona-command-list`
|
|
461
|
+
|
|
462
|
+
#### Inputs
|
|
463
|
+
|
|
464
|
+
| Name | Type | Default | Description |
|
|
465
|
+
| --- | --- | --- | --- |
|
|
466
|
+
| `aria-label` | `string \| undefined` | `undefined` | The accessible name of the list. |
|
|
467
|
+
|
|
468
|
+
### `CommandShortcutComponent`
|
|
469
|
+
|
|
470
|
+
Shows an item's shortcut the way the platform writes it. It's only a hint: binding the keys stays with the consumer,
|
|
471
|
+
who knows what they do.
|
|
472
|
+
|
|
473
|
+
**Selector:** `mona-command-shortcut`
|
|
474
|
+
|
|
475
|
+
#### Inputs
|
|
476
|
+
|
|
477
|
+
| Name | Type | Default | Description |
|
|
478
|
+
| --- | --- | --- | --- |
|
|
479
|
+
| `keys` (required) | `string` | — | The keys, joined with `+`, such as `mod+k`. `mod` is Command on Apple devices and Ctrl elsewhere. |
|
|
480
|
+
|
|
481
|
+
### `CommandEmptyComponent`
|
|
482
|
+
|
|
483
|
+
Shows while a query has no results. Its content replaces the default message.
|
|
484
|
+
|
|
485
|
+
**Selector:** `mona-command-empty`
|
|
486
|
+
|
|
487
|
+
### `CommandFooterComponent`
|
|
488
|
+
|
|
489
|
+
A strip below the list, for key hints or links.
|
|
490
|
+
|
|
491
|
+
**Selector:** `mona-command-footer`
|
|
492
|
+
|
|
493
|
+
### `CommandHeaderComponent`
|
|
494
|
+
|
|
495
|
+
A strip above or below the input, for filters or a title.
|
|
496
|
+
|
|
497
|
+
**Selector:** `mona-command-header`
|
|
498
|
+
|
|
499
|
+
### `CommandLoadingComponent`
|
|
500
|
+
|
|
501
|
+
Shows while the `mona-command` is `loading`. Its content replaces the default message.
|
|
502
|
+
|
|
503
|
+
**Selector:** `mona-command-loading`
|
|
504
|
+
|
|
505
|
+
### `CommandSeparatorComponent`
|
|
506
|
+
|
|
507
|
+
A line between items. It's only visual, because a listbox can't contain a separator role. It hides while the
|
|
508
|
+
component filters, when it would divide nothing.
|
|
509
|
+
|
|
510
|
+
**Selector:** `mona-command-separator`
|
|
511
|
+
|
|
512
|
+
### `CommandDialogContentDirective`
|
|
513
|
+
|
|
514
|
+
Marks the template a `mona-command-dialog` renders while it's open.
|
|
515
|
+
|
|
516
|
+
**Selector:** `ng-template[monaCommandDialogContent]`
|
|
517
|
+
|
|
518
|
+
### Types
|
|
519
|
+
|
|
520
|
+
#### `COMMAND_DEFAULT_MESSAGES`
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
const COMMAND_DEFAULT_MESSAGES: MonaCommandMessages;
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
#### `defaultCommandFilter`
|
|
527
|
+
|
|
528
|
+
The default filter: an item stays when every word of the query appears in its value or keywords, ignoring case and
|
|
529
|
+
accents.
|
|
530
|
+
|
|
531
|
+
```typescript
|
|
532
|
+
const defaultCommandFilter: CommandFilter;
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
#### `CommandFilterItem`
|
|
536
|
+
|
|
537
|
+
What a filter sees of an item.
|
|
538
|
+
|
|
539
|
+
| Name | Type | Description |
|
|
540
|
+
| --- | --- | --- |
|
|
541
|
+
| `keywords` (read-only) | `readonly string[]` | Other words the item should be found by. |
|
|
542
|
+
| `value` (read-only) | `string` | The item's value. |
|
|
543
|
+
|
|
544
|
+
#### `CommandSelectEvent`
|
|
545
|
+
|
|
546
|
+
Emitted when an item is chosen, with the pointer or with Enter.
|
|
547
|
+
|
|
548
|
+
| Name | Type | Description |
|
|
549
|
+
| --- | --- | --- |
|
|
550
|
+
| `originalEvent` (read-only) | `KeyboardEvent \| MouseEvent` | The click or key press that chose the item, to tell apart a modified one, such as Ctrl+Enter. |
|
|
551
|
+
| `value` (read-only) | `string` | The value of the chosen item. |
|
|
552
|
+
|
|
553
|
+
#### `CommandFilter`
|
|
554
|
+
|
|
555
|
+
Decides whether an item stays in the list for a query. It's only called while the query isn't empty.
|
|
556
|
+
|
|
557
|
+
```typescript
|
|
558
|
+
type CommandFilter = (query: string, item: CommandFilterItem) => boolean;
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
#### `CommandFilterMode`
|
|
562
|
+
|
|
563
|
+
Who decides which items show. `"auto"` filters them on the client. `"manual"` shows every item, for results the
|
|
564
|
+
consumer already narrowed down, such as a server's.
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
type CommandFilterMode = "auto" | "manual";
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
#### `MonaCommandMessages`
|
|
571
|
+
|
|
572
|
+
From `@nanahoshi/mona-ui/i18n`.
|
|
573
|
+
|
|
574
|
+
| Name | Type |
|
|
575
|
+
| --- | --- |
|
|
576
|
+
| `dialogLabel` (read-only) | `string` |
|
|
577
|
+
| `inputLabel` (read-only) | `string` |
|
|
578
|
+
| `listLabel` (read-only) | `string` |
|
|
579
|
+
| `loading` (read-only) | `string` |
|
|
580
|
+
| `noResults` (read-only) | `string` |
|
|
581
|
+
| `placeholder` (read-only) | `string` |
|
|
582
|
+
| `resultsAvailable` (read-only) | `(count: number) => string` |
|