@nanahoshi/mona-ui 0.33.0 → 0.35.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.
Files changed (92) hide show
  1. package/alert/package.json +4 -0
  2. package/badge/package.json +4 -0
  3. package/docs/alert.md +219 -0
  4. package/docs/api/alert.md +78 -0
  5. package/docs/api/avatar.md +25 -0
  6. package/docs/api/badge.md +24 -0
  7. package/docs/api/common.md +2 -2
  8. package/docs/api/grid.md +46 -13
  9. package/docs/api/i18n.md +45 -0
  10. package/docs/api/locales.md +14 -14
  11. package/docs/api/multi-select.md +2 -0
  12. package/docs/api/separator.md +23 -0
  13. package/docs/api/toolbar.md +81 -0
  14. package/docs/avatar.md +108 -6
  15. package/docs/badge.md +181 -0
  16. package/docs/grid-columns.md +121 -17
  17. package/docs/grid-state-export.md +24 -7
  18. package/docs/grid.md +1 -1
  19. package/docs/multi-select.md +54 -0
  20. package/docs/separator.md +147 -0
  21. package/docs/sidebar-menus.md +1 -1
  22. package/docs/toolbar.md +327 -0
  23. package/fesm2022/nanahoshi-mona-ui-alert.mjs +422 -0
  24. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +182 -3
  25. package/fesm2022/nanahoshi-mona-ui-badge.mjs +273 -0
  26. package/fesm2022/{nanahoshi-mona-ui-grid-grid-colgroup.component-C62HvK-w.mjs → nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs} +2 -2
  27. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-BpsJwMkQ.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs} +8 -3
  28. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BVpGUjA7.mjs → nanahoshi-mona-ui-grid-grid-list.component-S2iCn8TV.mjs} +10 -6
  29. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-D0T8kfdm.mjs → nanahoshi-mona-ui-grid-grid-row.component-BUJvgihp.mjs} +21 -6
  30. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-5D2BjGx4.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-Wndy-_Bt.mjs} +5 -5
  31. package/fesm2022/{nanahoshi-mona-ui-grid-grid.styles-62LTuPhD.mjs → nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs} +228 -16
  32. package/fesm2022/nanahoshi-mona-ui-grid.mjs +422 -29
  33. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  34. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +3 -0
  35. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +3 -0
  36. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +3 -0
  37. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +3 -0
  38. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +3 -0
  39. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +3 -0
  40. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +3 -0
  41. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +3 -0
  42. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +3 -0
  43. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +3 -0
  44. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +3 -0
  45. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +3 -0
  46. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +3 -0
  47. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +3 -0
  48. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +83 -2
  49. package/fesm2022/nanahoshi-mona-ui-separator.mjs +165 -0
  50. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +3 -3
  51. package/fesm2022/nanahoshi-mona-ui-toolbar.mjs +536 -0
  52. package/i18n/catalogs/en-US.messages.json +9 -0
  53. package/llms.txt +14 -6
  54. package/locales/ar-sa/ar-sa.messages.json +9 -0
  55. package/locales/de-de/de-de.messages.json +9 -0
  56. package/locales/es-es/es-es.messages.json +9 -0
  57. package/locales/fr-fr/fr-fr.messages.json +9 -0
  58. package/locales/id-id/id-id.messages.json +9 -0
  59. package/locales/it-it/it-it.messages.json +9 -0
  60. package/locales/ja-jp/ja-jp.messages.json +9 -0
  61. package/locales/ko-kr/ko-kr.messages.json +9 -0
  62. package/locales/pl-pl/pl-pl.messages.json +9 -0
  63. package/locales/pt-br/pt-br.messages.json +9 -0
  64. package/locales/ru-ru/ru-ru.messages.json +9 -0
  65. package/locales/tr-tr/tr-tr.messages.json +9 -0
  66. package/locales/zh-cn/zh-cn.messages.json +9 -0
  67. package/locales/zh-tw/zh-tw.messages.json +9 -0
  68. package/package.json +17 -1
  69. package/separator/package.json +4 -0
  70. package/toolbar/package.json +4 -0
  71. package/types/nanahoshi-mona-ui-alert.d.ts +144 -0
  72. package/types/nanahoshi-mona-ui-avatar.d.ts +66 -0
  73. package/types/nanahoshi-mona-ui-badge.d.ts +82 -0
  74. package/types/nanahoshi-mona-ui-grid.d.ts +142 -64
  75. package/types/nanahoshi-mona-ui-i18n.d.ts +24 -0
  76. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +9 -0
  77. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +9 -0
  78. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +9 -0
  79. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +9 -0
  80. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +9 -0
  81. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +9 -0
  82. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +9 -0
  83. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +9 -0
  84. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +9 -0
  85. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +9 -0
  86. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +9 -0
  87. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +9 -0
  88. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +9 -0
  89. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +9 -0
  90. package/types/nanahoshi-mona-ui-multi-select.d.ts +27 -0
  91. package/types/nanahoshi-mona-ui-separator.d.ts +66 -0
  92. package/types/nanahoshi-mona-ui-toolbar.d.ts +183 -0
@@ -1,26 +1,26 @@
1
1
  # State & Export
2
2
 
3
- > Save and restore the grid's columns, sort, filter, groups and page size, and export rows as CSV.
3
+ > Save and restore the grid's columns, sort, filter, groups and page size, and export rows as CSV or Excel.
4
4
 
5
5
  Entry point: `@nanahoshi/mona-ui/grid`
6
6
 
7
7
  **Selectors:** `mona-grid[monaGridStatePersistence]`, `mona-grid[monaGridExport]`
8
8
 
9
- `monaGridStatePersistence` captures what people changed (column order, widths and visibility, sort, filter, groups and page size) as a plain `GridState` object you can store and give back later. `monaGridExport` writes the rows of the current view to a CSV file.
9
+ `monaGridStatePersistence` captures what people changed (column order, widths and visibility, sort, filter, groups and page size) as a plain `GridState` object you can store and give back later. `monaGridExport` writes the rows of the current view to a CSV file or an Excel workbook.
10
10
 
11
11
  ## Overview
12
12
 
13
13
  | Directive | State you bind | Methods |
14
14
  | :--- | :--- | :--- |
15
15
  | `monaGridStatePersistence` | `[(state)]`: `GridState \| null` | `captureState()`, `loadState(state)` |
16
- | `monaGridExport` | — | `exportCsv(filename?)` |
16
+ | `monaGridExport` | — | `exportCsv(filename?)`, `exportExcel(filename?)` |
17
17
 
18
18
  A `GridState` is JSON-safe, so it can go to `localStorage`, a user profile on your server, or a URL. The grid doesn't store it anywhere itself.
19
19
 
20
20
  **Use something else when:**
21
21
 
22
22
  - You need one value back, such as the sort. Bind that feature's own model (`[(sort)]`, `[(filter)]`, `[(group)]`, `[(pageSize)]`) instead.
23
- - The export needs every record from a server, or a format other than CSV. Produce it in your application from your data.
23
+ - The export needs every record from a server, or a format other than CSV and Excel, such as PDF. Produce it in your application from your data.
24
24
 
25
25
  ## Import & Quick Start
26
26
 
@@ -34,6 +34,7 @@ protected readonly state = signal<GridState | null>(null);
34
34
 
35
35
  ```html
36
36
  <button monaButton type="button" (click)="gridExport.exportCsv('orders.csv')">Export as CSV</button>
37
+ <button monaButton type="button" (click)="gridExport.exportExcel('orders.xlsx')">Export as Excel</button>
37
38
  <mona-grid
38
39
  #gridExport="monaGridExport"
39
40
  aria-label="Orders"
@@ -92,7 +93,8 @@ export class GridSavedStateExampleComponent {
92
93
  protected readonly orders = Array.from({ length: 24 }, (_, index) => ({
93
94
  orderId: 10248 + index,
94
95
  customer: ["Ernst Handel", "Hanari Carnes", "=Island Trading", "Folk och fä HB"][index % 4],
95
- freight: 12.5 + ((index * 17) % 60)
96
+ freight: 12.5 + ((index * 17) % 60),
97
+ orderDate: new Date(2024, 6, 4 + index * 3)
96
98
  }));
97
99
  /** Restored on the next visit: sort, column order, widths, visibility and page size. */
98
100
  protected readonly state = signal<GridState | null>(readSavedState());
@@ -128,14 +130,16 @@ export class GridSavedStateExampleComponent {
128
130
  [(state)]="state">
129
131
  <ng-template monaGridToolbarTemplate>
130
132
  <button monaButton type="button" (click)="gridExport.exportCsv('orders.csv')">Export as CSV</button>
133
+ <button monaButton type="button" (click)="gridExport.exportExcel('orders.xlsx')">Export as Excel</button>
131
134
  </ng-template>
132
135
  <mona-grid-column field="orderId" title="Order" type="number" />
133
136
  <mona-grid-column field="customer" title="Customer" />
134
137
  <mona-grid-column field="freight" title="Freight" type="number" />
138
+ <mona-grid-column field="orderDate" title="Order Date" type="date" />
135
139
  </mona-grid>
136
140
  ```
137
141
 
138
- The example reads a saved state when it starts and writes every new one to `localStorage`. Sort a column, change the page size or move a column, then reload the page: the grid comes back the same. The toolbar's Export button downloads the rows as `orders.csv`; the customer `=Island Trading` is written as `'=Island Trading`, so a spreadsheet doesn't run it as a formula.
142
+ The example reads a saved state when it starts and writes every new one to `localStorage`. Sort a column, change the page size or move a column, then reload the page: the grid comes back the same. The toolbar's buttons download the rows as `orders.csv` and `orders.xlsx`. In the CSV file the customer `=Island Trading` is written as `'=Island Trading`, so a spreadsheet doesn't run it as a formula; the workbook holds it as text, so it needs no quote. The Order Date column is a real date in the workbook, shown in your spreadsheet's date format.
139
143
 
140
144
  ### Applying a State from Code
141
145
 
@@ -176,9 +180,22 @@ The `state` model updates after each change people make, and a column resize is
176
180
 
177
181
  `exportCsv(filename?)` exports the visible columns of every row in the current view: filtered and sorted, all pages. With server binding it exports only the loaded page. Dates are written as the local calendar date (`YYYY-MM-DD`), and text starting with `=`, `+`, `-`, `@`, a tab or a carriage return is prefixed with `'` so spreadsheets don't run it as a formula. The column titles form the header row. Formatters and cell templates aren't used: the file has the raw values.
178
182
 
183
+ `exportExcel(filename?)` writes the same rows and columns to an `.xlsx` workbook with one sheet, named after the file (`export.xlsx` without a name), and returns a promise that resolves once the download starts.
184
+
185
+ | In the grid | In the workbook |
186
+ | :--- | :--- |
187
+ | A `number`, `boolean` or `date` column's values | Numbers, `TRUE`/`FALSE` and dates, which sort and add up there. Dates use the spreadsheet's short date format, by the local calendar day. A value of another type is written as text. |
188
+ | Text | Text, as it is: a cell's text is never run as a formula, so nothing is prefixed. Empty values leave the cell empty. |
189
+ | Column groups | Merged header cells above the column titles, in bold; a column outside a group has its title merged down to the titles' row. |
190
+ | The header and left-locked columns | Frozen, so they stay in view while the sheet scrolls. |
191
+ | Column widths | The columns' widths. |
192
+ | A right-to-left layout | A right-to-left sheet. |
193
+
194
+ Footers, aggregates and row groups aren't exported, in either format. The workbook is built in the browser, without a dependency, and compressed where the browser supports `CompressionStream`.
195
+
179
196
  ## Accessibility
180
197
 
181
- Neither directive adds roles or keys. Put the export command where people expect it, such as a button in the toolbar, and give it a visible label that says it downloads a file. A restored layout changes the column order and the sort that assistive technology reads, so restore it when the page loads rather than while someone is working in the grid.
198
+ Neither directive adds roles or keys. Put the export commands where people expect them, such as buttons in the toolbar, and give each a visible label that says what it downloads, such as "Export as Excel". A restored layout changes the column order and the sort that assistive technology reads, so restore it when the page loads rather than while someone is working in the grid.
182
199
 
183
200
  ### Keyboard
184
201
 
package/docs/grid.md CHANGED
@@ -310,4 +310,4 @@ Everything below is imported from `@nanahoshi/mona-ui/grid`. Each name links to
310
310
  | [`ColumnFormatFunction`](api/grid.md#columnformatfunction) | Type alias | Formats a cell's value for display. |
311
311
  | [`ColumnKind`](api/grid.md#columnkind) | Type alias | |
312
312
 
313
- **Related types:** [`AggregateFunction`](api/grid.md#aggregatefunction), [`ColumnSortComparator`](api/grid.md#columnsortcomparator), [`DataType`](api/common.md#datatype), [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition), [`GridDataState`](api/grid.md#griddatastate), [`GridEditSession`](api/grid.md#grideditsession), [`GridKeySelector`](api/grid.md#gridkeyselector), [`GridRowClass`](api/grid.md#gridrowclass), [`PageChangeEvent`](api/pager.md#pagechangeevent), [`ResizeMethod`](api/grid.md#resizemethod), [`SortDirection`](api/query.md#sortdirection)
313
+ **Related types:** [`AggregateFunction`](api/grid.md#aggregatefunction), [`ColumnGroup`](api/grid.md#columngroup), [`ColumnSortComparator`](api/grid.md#columnsortcomparator), [`DataType`](api/common.md#datatype), [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition), [`GridDataState`](api/grid.md#griddatastate), [`GridEditSession`](api/grid.md#grideditsession), [`GridKeySelector`](api/grid.md#gridkeyselector), [`GridRowClass`](api/grid.md#gridrowclass), [`PageChangeEvent`](api/pager.md#pagechangeevent), [`ResizeMethod`](api/grid.md#resizemethod), [`SortDirection`](api/query.md#sortdirection)
@@ -285,6 +285,55 @@ export class MultiSelectFormsExampleComponent {
285
285
  </div>
286
286
  ```
287
287
 
288
+ ### Adding values that aren't listed
289
+
290
+ With `allowCustomValue` and `monaDropDownFilterable`, the popup's filter box doubles as a tag input. Enter on text that no option matches emits `valueAdd` with the trimmed text: add it to `data` and to `value`, and it shows as a tag. Text that names an option, in any case, selects that option instead. Either way the filter box is cleared for the next one. Say how it works near the field, as the hint here does, since nothing in the popup does.
291
+
292
+ `custom-values-example.component.ts`
293
+
294
+ ```typescript
295
+ import { Component, signal } from "@angular/core";
296
+ import { DropdownFilterableDirective } from "@nanahoshi/mona-ui/dropdowns";
297
+ import { LabelDirective } from "@nanahoshi/mona-ui/label";
298
+ import { MultiSelectComponent } from "@nanahoshi/mona-ui/multi-select";
299
+
300
+ @Component({
301
+ selector: "app-multi-select-custom-values-example",
302
+ imports: [DropdownFilterableDirective, LabelDirective, MultiSelectComponent],
303
+ templateUrl: "./custom-values-example.component.html"
304
+ })
305
+ export class MultiSelectCustomValuesExampleComponent {
306
+ protected readonly skills = signal(["Angular", "CSS", "Go", "Rust", "TypeScript"]);
307
+ protected readonly value = signal<string[]>(["Angular", "TypeScript"]);
308
+
309
+ protected add(skill: string): void {
310
+ this.skills.update(skills => [...skills, skill]);
311
+ this.value.update(value => [...value, skill]);
312
+ }
313
+ }
314
+ ```
315
+
316
+ `custom-values-example.component.html`
317
+
318
+ ```html
319
+ <div class="flex max-w-sm flex-col gap-1">
320
+ <label id="multi-select-custom-label" monaLabel [for]="skillList">Skills</label>
321
+ <mona-multi-select
322
+ #skillList
323
+ aria-labelledby="multi-select-custom-label"
324
+ aria-describedby="multi-select-custom-hint"
325
+ filterPlaceholder="Find or add a skill"
326
+ monaDropDownFilterable
327
+ [allowCustomValue]="true"
328
+ [data]="skills()"
329
+ [(value)]="value"
330
+ (valueAdd)="add($event)" />
331
+ <span id="multi-select-custom-hint" class="text-sm text-muted-foreground">
332
+ Type a skill that isn't listed and press Enter to add it.
333
+ </span>
334
+ </div>
335
+ ```
336
+
288
337
  ### Closing the popup after each selection
289
338
 
290
339
  Set `autoClose` to `true` to close the popup after each selection instead of keeping it open.
@@ -342,6 +391,10 @@ Set `autoClose` to `true` to close the popup after each selection instead of kee
342
391
 
343
392
  `placeholder` shows while nothing is selected. It also names the control when neither `aria-label` nor `aria-labelledby` is set.
344
393
 
394
+ ### Enter in the filter box
395
+
396
+ With nothing highlighted, such as when the filter matches no option, Enter in the filter box does nothing, and leaves the selection as it is. With `allowCustomValue`, it adds the typed text, unless an option was reached with the arrow keys since the text last changed: then it toggles that option, as it would without custom values. `allowCustomValue` without `monaDropDownFilterable` has nowhere to type, and warns in development.
397
+
345
398
  ### `showClearButton` clears every selection
346
399
 
347
400
  `showClearButton` renders a single clear button that removes all selected items at once, not one at a time.
@@ -369,6 +422,7 @@ Set `autoClose` to `true` to close the popup after each selection instead of kee
369
422
  | `Alt+ArrowDown` | Open the popup. |
370
423
  | `Alt+ArrowUp` | Close the popup. |
371
424
  | `Enter` | Open the popup when closed. When open, toggles the highlighted option's selected state; closes the popup afterward only if `autoClose` is `true`. |
425
+ | `Enter` in the filter box | Toggles the option highlighted with the arrow keys. With `allowCustomValue`, adds the typed text instead, or selects the option it names. |
372
426
  | `Space` | Toggle the popup open or closed. |
373
427
  | `Backspace` | Remove the most recently selected tag. |
374
428
  | `Escape` / `Tab` | Close the popup. |
@@ -0,0 +1,147 @@
1
+ # Separator
2
+
3
+ > A thin line between groups of content, across or down, with an optional label.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/separator`
6
+
7
+ **Selector:** `mona-separator`
8
+
9
+ `SeparatorComponent` draws a thin line between groups of content, across a column or down a row, with an optional label such as "or" in its middle. Like an `<hr>`, it's a separator for assistive technology unless it's marked decorative.
10
+
11
+ ## Overview
12
+
13
+ Use a separator to divide content that belongs together from content that doesn't: the header of a panel from its body, or two ways to sign in. In a row, a vertical one divides items such as a date and a reading time.
14
+
15
+ **Use a separator when you need to:**
16
+
17
+ - Divide a panel, a card or a form into parts without a heading for each
18
+ - Offer two alternatives, with "or" between them
19
+ - Separate items in a row of metadata or links
20
+
21
+ **Use something else when:**
22
+
23
+ - The parts deserve names: use headings, which also help people navigate
24
+ - The line divides items in a menu: menus have their own separator items, such as `mona-dropdown-button-separator`
25
+ - The groups are in a toolbar: a separator works there too, and a toolbar item moves it into its More menu with the items around it
26
+
27
+ ## Import & Quick Start
28
+
29
+ ```typescript
30
+ import { SeparatorComponent } from "@nanahoshi/mona-ui/separator";
31
+ ```
32
+
33
+ ```html
34
+ <mona-separator class="my-4" />
35
+ <mona-separator label="or" />
36
+ <mona-separator orientation="vertical" />
37
+ ```
38
+
39
+ ## Examples
40
+
41
+ ### Two ways to sign in
42
+
43
+ A labelled separator reads its label as text, "or", and the lines around it stay out of the way.
44
+
45
+ `sign-in-example.component.ts`
46
+
47
+ ```typescript
48
+ import { Component } from "@angular/core";
49
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
50
+ import { SeparatorComponent } from "@nanahoshi/mona-ui/separator";
51
+ import { TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
52
+
53
+ @Component({
54
+ selector: "app-separator-sign-in-example",
55
+ imports: [ButtonDirective, SeparatorComponent, TextBoxDirective],
56
+ templateUrl: "./sign-in-example.component.html"
57
+ })
58
+ export class SeparatorSignInExampleComponent {}
59
+ ```
60
+
61
+ `sign-in-example.component.html`
62
+
63
+ ```html
64
+ <section aria-labelledby="sign-in-heading" class="flex max-w-xs flex-col gap-4 rounded-lg border border-border p-6">
65
+ <h3 id="sign-in-heading" class="text-base font-semibold">Sign in</h3>
66
+ <button monaButton type="button" class="w-full">Continue with a passkey</button>
67
+ <mona-separator label="or" />
68
+ <label class="flex flex-col gap-1 text-sm font-medium">
69
+ Email
70
+ <input monaTextBox type="email" autocomplete="email" />
71
+ </label>
72
+ <button monaButton type="button" look="primary" class="w-full">Email me a link</button>
73
+ </section>
74
+ ```
75
+
76
+ ### Across and down
77
+
78
+ The horizontal separator between the heading and the details is announced, since it marks where the details start. The vertical ones only space out items that already read apart, so they're `decorative`.
79
+
80
+ `inline-example.component.ts`
81
+
82
+ ```typescript
83
+ import { Component } from "@angular/core";
84
+ import { SeparatorComponent } from "@nanahoshi/mona-ui/separator";
85
+
86
+ @Component({
87
+ selector: "app-separator-inline-example",
88
+ imports: [SeparatorComponent],
89
+ templateUrl: "./inline-example.component.html"
90
+ })
91
+ export class SeparatorInlineExampleComponent {}
92
+ ```
93
+
94
+ `inline-example.component.html`
95
+
96
+ ```html
97
+ <article class="flex max-w-md flex-col gap-3">
98
+ <div>
99
+ <h3 class="text-base font-semibold">Release notes</h3>
100
+ <p class="text-sm text-muted-foreground">What changed in version 4.2.</p>
101
+ </div>
102
+ <mona-separator />
103
+ <div class="flex h-5 items-center gap-3 text-sm">
104
+ <span>18 November</span>
105
+ <mona-separator orientation="vertical" [decorative]="true" />
106
+ <span>5 min read</span>
107
+ <mona-separator orientation="vertical" [decorative]="true" />
108
+ <span>Platform team</span>
109
+ </div>
110
+ </article>
111
+ ```
112
+
113
+ ## Appearance & Styling
114
+
115
+ | `orientation` | Line | Size |
116
+ |---------------|------|------|
117
+ | `horizontal` (default) | Across its container | 1px tall, full width |
118
+ | `vertical` | Down its row | 1px wide, the row's height. Give the row a height, or items that set one. |
119
+
120
+ The line is drawn in the theme's border color. A labelled separator is always horizontal, with the label in small muted text between two lines.
121
+
122
+ The separator has no margin of its own. Add one with `class`, such as `class="my-4"`, which is merged with its own classes through `tailwind-merge`; `class="bg-primary"` recolors the line.
123
+
124
+ In forced colors, where backgrounds don't paint, the line takes the text color.
125
+
126
+ ## Accessibility
127
+
128
+ | Separator | Role | Notes |
129
+ |-----------|------|-------|
130
+ | Horizontal | `separator` | Horizontal is the role's default, so it has no `aria-orientation` |
131
+ | Vertical | `separator` | With `aria-orientation="vertical"` |
132
+ | `decorative` | None | Skipped by assistive technology |
133
+ | With a `label` | None | The label is read as text; a separator's role would hide it |
134
+
135
+ Mark a separator `decorative` when it repeats a boundary the content already makes, such as between cards with their own borders, or between items that a screen reader reads apart anyway. A separator isn't focusable and has no keyboard interaction.
136
+
137
+ ## API
138
+
139
+ Everything below is imported from `@nanahoshi/mona-ui/separator`. Each name links to its reference page, with every input, output, property and method.
140
+
141
+ | Name | Kind | Description |
142
+ | --- | --- | --- |
143
+ | [`SeparatorComponent`](api/separator.md#separatorcomponent) | Component | A thin line between groups of content, across a column or down a row, with an optional label in its middle. |
144
+
145
+ ### Types
146
+
147
+ **Related types:** [`ClassInputType`](api/common.md#classinputtype)
@@ -23,7 +23,7 @@ A sidebar's content is groups of rows. Every part below is a directive on your o
23
23
  | `[monaSidebarMenuItem]` | `li` | One row; owns the highlight and `active` |
24
24
  | `[monaSidebarMenuButton]` | `a` / `button` | The row's control; takes `tooltip`, `size`, `disabled`, `closeOnSelect` |
25
25
  | `[monaSidebarMenuAction]` | `button` | A trailing control inside the row; needs an `aria-label` |
26
- | `[monaSidebarMenuBadge]` | any | A trailing count or status; stands down on the rail |
26
+ | `[monaSidebarMenuBadge]` | any | A trailing count or status, shaped like a [Badge](badge.md); stands down on the rail |
27
27
  | `[monaSidebarMenuSub]` | `ul` | An indented submenu inside a collapsible item |
28
28
  | `[monaSidebarInput]` | `input` | A text input sized for the sidebar; stands down on the rail |
29
29
  | `mona-sidebar-menu-skeleton` | element | A loading placeholder row |
@@ -0,0 +1,327 @@
1
+ # Toolbar
2
+
3
+ > A row of controls that is one Tab stop, moving what doesn't fit into a More menu.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/toolbar`
6
+
7
+ **Selectors:** `mona-toolbar`, `[monaToolbarItem]`
8
+
9
+ `ToolbarComponent` groups a row of controls, such as formatting buttons, into one Tab stop that the arrow keys move through. Items marked `monaToolbarItem` that don't fit move into a More menu at the end of the row, and come back as it widens.
10
+
11
+ ## Overview
12
+
13
+ Use a toolbar for a set of controls that act on the same thing, such as the text in an editor or the rows of a table. Grouping them saves keyboard users a Tab press per control: Tab enters and leaves the toolbar, and the arrow keys move inside it.
14
+
15
+ **Use a toolbar when you need to:**
16
+
17
+ - Offer formatting or editing commands above a document or an editor
18
+ - Put actions for a table or a selection in one row
19
+ - Keep a row of commands usable at every width, by moving what doesn't fit into a menu
20
+
21
+ **Use something else when:**
22
+
23
+ - The controls choose one value: use a [Segmented](segmented.md) control or radio buttons
24
+ - The buttons are one control with a shared look: use a [Button Group](button-group.md), which can sit inside a toolbar
25
+ - The row navigates between pages: use links, or the [Menubar](menubar.md) for an application menu
26
+
27
+ ## Import & Quick Start
28
+
29
+ ```typescript
30
+ import { ToolbarComponent, ToolbarItemDirective } from "@nanahoshi/mona-ui/toolbar";
31
+ ```
32
+
33
+ ```html
34
+ <mona-toolbar aria-label="Formatting">
35
+ <button monaButton monaToolbarItem type="button" aria-label="Bold" [iconOnly]="true" [toggleable]="true">
36
+ <svg lucideBold [size]="16"></svg>
37
+ </button>
38
+ <button monaButton monaToolbarItem type="button">Insert table</button>
39
+ </mona-toolbar>
40
+ ```
41
+
42
+ ## Anatomy
43
+
44
+ | Part | What it is |
45
+ |------|------------|
46
+ | `mona-toolbar` | The row, with `role="toolbar"` and one Tab stop over every control in it |
47
+ | `monaToolbarItem` | Marks a control directly inside the toolbar as one that can move into the More menu |
48
+ | More button | Appears at the end when items are hidden, and opens a menu of them |
49
+ | `mona-separator` | Divides groups of controls. Marked `monaToolbarItem`, it moves with them and becomes a divider in the menu |
50
+
51
+ A control without `monaToolbarItem` always stays in the row, and still joins the Tab stop and the arrow keys.
52
+
53
+ ## Examples
54
+
55
+ ### Formatting toolbar
56
+
57
+ Drag the box's corner to narrow it. Items move into the More menu from the end, and a divider that would be left at the end goes with them. In the menu, Bold and the other toggles are checkbox items that show whether they're on, and choosing one clicks its button, so the button's own handlers run.
58
+
59
+ `editor-example.component.ts`
60
+
61
+ ```typescript
62
+ import { Component, signal } from "@angular/core";
63
+ import {
64
+ LucideBold,
65
+ LucideItalic,
66
+ LucideLink,
67
+ LucideRedo2,
68
+ LucideRemoveFormatting,
69
+ LucideStrikethrough,
70
+ LucideUnderline,
71
+ LucideUndo2
72
+ } from "@lucide/angular";
73
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
74
+ import { SeparatorComponent } from "@nanahoshi/mona-ui/separator";
75
+ import { ToolbarComponent, ToolbarItemDirective } from "@nanahoshi/mona-ui/toolbar";
76
+
77
+ @Component({
78
+ selector: "app-toolbar-editor-example",
79
+ imports: [
80
+ ButtonDirective,
81
+ LucideBold,
82
+ LucideItalic,
83
+ LucideLink,
84
+ LucideRedo2,
85
+ LucideRemoveFormatting,
86
+ LucideStrikethrough,
87
+ LucideUnderline,
88
+ LucideUndo2,
89
+ SeparatorComponent,
90
+ ToolbarComponent,
91
+ ToolbarItemDirective
92
+ ],
93
+ templateUrl: "./editor-example.component.html"
94
+ })
95
+ export class ToolbarEditorExampleComponent {
96
+ protected readonly bold = signal(false);
97
+ protected readonly italic = signal(false);
98
+ protected readonly lastAction = signal("");
99
+ protected readonly strikethrough = signal(false);
100
+ protected readonly underline = signal(false);
101
+
102
+ protected clearFormatting(): void {
103
+ this.bold.set(false);
104
+ this.italic.set(false);
105
+ this.strikethrough.set(false);
106
+ this.underline.set(false);
107
+ this.lastAction.set("Formatting cleared.");
108
+ }
109
+ }
110
+ ```
111
+
112
+ `editor-example.component.html`
113
+
114
+ ```html
115
+ <div class="flex flex-col gap-3">
116
+ <div class="w-[28rem] min-w-24 max-w-full resize-x overflow-hidden rounded-md border border-border p-1">
117
+ <mona-toolbar aria-label="Formatting" size="small">
118
+ <button
119
+ monaButton
120
+ monaToolbarItem
121
+ type="button"
122
+ size="small"
123
+ look="ghost"
124
+ aria-label="Undo"
125
+ [iconOnly]="true"
126
+ (click)="lastAction.set('Undone.')">
127
+ <svg lucideUndo2 [size]="16"></svg>
128
+ </button>
129
+ <button
130
+ monaButton
131
+ monaToolbarItem
132
+ type="button"
133
+ size="small"
134
+ look="ghost"
135
+ aria-label="Redo"
136
+ [iconOnly]="true"
137
+ (click)="lastAction.set('Redone.')">
138
+ <svg lucideRedo2 [size]="16"></svg>
139
+ </button>
140
+ <mona-separator monaToolbarItem orientation="vertical" class="h-5" />
141
+ <button
142
+ monaButton
143
+ monaToolbarItem
144
+ type="button"
145
+ size="small"
146
+ look="ghost"
147
+ aria-label="Bold"
148
+ [iconOnly]="true"
149
+ [toggleable]="true"
150
+ [(selected)]="bold">
151
+ <svg lucideBold [size]="16"></svg>
152
+ </button>
153
+ <button
154
+ monaButton
155
+ monaToolbarItem
156
+ type="button"
157
+ size="small"
158
+ look="ghost"
159
+ aria-label="Italic"
160
+ [iconOnly]="true"
161
+ [toggleable]="true"
162
+ [(selected)]="italic">
163
+ <svg lucideItalic [size]="16"></svg>
164
+ </button>
165
+ <button
166
+ monaButton
167
+ monaToolbarItem
168
+ type="button"
169
+ size="small"
170
+ look="ghost"
171
+ aria-label="Underline"
172
+ [iconOnly]="true"
173
+ [toggleable]="true"
174
+ [(selected)]="underline">
175
+ <svg lucideUnderline [size]="16"></svg>
176
+ </button>
177
+ <button
178
+ monaButton
179
+ monaToolbarItem
180
+ type="button"
181
+ size="small"
182
+ look="ghost"
183
+ aria-label="Strikethrough"
184
+ [iconOnly]="true"
185
+ [toggleable]="true"
186
+ [(selected)]="strikethrough">
187
+ <svg lucideStrikethrough [size]="16"></svg>
188
+ </button>
189
+ <mona-separator monaToolbarItem orientation="vertical" class="h-5" />
190
+ <button
191
+ monaButton
192
+ monaToolbarItem
193
+ type="button"
194
+ size="small"
195
+ look="ghost"
196
+ overflowText="Insert link…"
197
+ (click)="lastAction.set('Link dialog opened.')">
198
+ <svg lucideLink [size]="16"></svg>
199
+ Link
200
+ </button>
201
+ <button monaButton monaToolbarItem type="button" size="small" look="ghost" (click)="clearFormatting()">
202
+ <svg lucideRemoveFormatting [size]="16"></svg>
203
+ Clear formatting
204
+ </button>
205
+ </mona-toolbar>
206
+ </div>
207
+ <p class="text-sm">
208
+ Bold {{ bold() ? "on" : "off" }}, italic {{ italic() ? "on" : "off" }}, underline
209
+ {{ underline() ? "on" : "off" }}, strikethrough {{ strikethrough() ? "on" : "off" }}. {{ lastAction() }}
210
+ </p>
211
+ </div>
212
+ ```
213
+
214
+ ### Wrapping instead
215
+
216
+ With `overflow="wrap"`, the controls flow onto more rows and nothing is hidden, which suits a few filters that should all stay visible. The search box sits outside the toolbar, since a text field keeps its arrow keys.
217
+
218
+ `wrap-example.component.ts`
219
+
220
+ ```typescript
221
+ import { Component, signal } from "@angular/core";
222
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
223
+ import { TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
224
+ import { ToolbarComponent } from "@nanahoshi/mona-ui/toolbar";
225
+
226
+ @Component({
227
+ selector: "app-toolbar-wrap-example",
228
+ imports: [ButtonDirective, TextBoxDirective, ToolbarComponent],
229
+ templateUrl: "./wrap-example.component.html"
230
+ })
231
+ export class ToolbarWrapExampleComponent {
232
+ protected readonly filters = ["Open", "Assigned to me", "Due this week", "High priority"] as const;
233
+ protected readonly selected = signal<ReadonlySet<string>>(new Set(["Open"]));
234
+
235
+ protected toggle(filter: string, on: boolean): void {
236
+ this.selected.update(selected => {
237
+ const next = new Set(selected);
238
+ if (on) {
239
+ next.add(filter);
240
+ } else {
241
+ next.delete(filter);
242
+ }
243
+ return next;
244
+ });
245
+ }
246
+ }
247
+ ```
248
+
249
+ `wrap-example.component.html`
250
+
251
+ ```html
252
+ <div class="flex max-w-md flex-col gap-3">
253
+ <input monaTextBox type="search" aria-label="Search tasks" placeholder="Search tasks" />
254
+ <mona-toolbar aria-label="Task filters" overflow="wrap" class="gap-2">
255
+ @for (filter of filters; track filter) {
256
+ <button
257
+ monaButton
258
+ type="button"
259
+ size="small"
260
+ look="outline"
261
+ [toggleable]="true"
262
+ [selected]="selected().has(filter)"
263
+ (selectedChange)="toggle(filter, $event)">
264
+ {{ filter }}
265
+ </button>
266
+ }
267
+ </mona-toolbar>
268
+ <p class="text-sm">{{ selected().size }} filters on.</p>
269
+ </div>
270
+ ```
271
+
272
+ ## Appearance & Styling
273
+
274
+ The toolbar is a flex row as wide as its container, with no border or background of its own. Add them with `class`, which is merged through `tailwind-merge`. `size` sets the gap between controls (`small` 2px, `medium` 4px, `large` 6px) and the More button's size; match it to the controls' size.
275
+
276
+ Controls keep their width rather than shrinking. Use `class="ms-auto"` on a control to push it, and those after it, to the end of the row.
277
+
278
+ ## Behavior
279
+
280
+ ### What moves into the menu
281
+
282
+ When the row is too narrow, the `monaToolbarItem`s move into the menu from the last one back, until the rest fit beside the More button. Items come back as the row widens. The toolbar measures again whenever it or one of its items changes size.
283
+
284
+ - `monaToolbarItem="never"` keeps a control in the row, such as a search box or a control a menu item can't stand in for.
285
+ - In the menu, an item takes its text from `overflowText`, then the control's `aria-label`, then its text. It's disabled while the control is disabled, and it's a checkbox item, checked while the control's `aria-pressed` is `true`.
286
+ - Choosing an item emits the item's `overflowActivate`, then clicks the control unless the event is prevented. A button needs nothing more. For a control a click doesn't operate, handle `overflowActivate`, or keep it in the row.
287
+ - The menu is read from the hidden controls each time it opens, so their text and states are current.
288
+
289
+ If focus is on a control as it moves into the menu, focus moves to the More button.
290
+
291
+ ### Wrapping
292
+
293
+ `overflow="wrap"` lets the row wrap, shows no More button and hides nothing.
294
+
295
+ ## Accessibility
296
+
297
+ The toolbar has `role="toolbar"` and needs a name, from `aria-label` or `aria-labelledby`, which assistive technology reads on the way in. It warns in development without one.
298
+
299
+ | Key | Action |
300
+ |-----|--------|
301
+ | `Tab` | Moves into the toolbar, to the control last focused in it, and out of it |
302
+ | `ArrowRight` / `ArrowLeft` | Moves to the next or previous control, wrapping at the ends (mirrored in right-to-left layouts) |
303
+ | `Home` / `End` | Moves to the first or last control |
304
+ | `Enter`, `Space` | Activates the focused control; on the More button, opens the menu |
305
+
306
+ Disabled and hidden controls are skipped. A text field, slider or other control that uses Left and Right itself keeps those keys, so put it last in the toolbar, or outside it, and keyboard users can still reach every control.
307
+
308
+ The More button is named "More" in the current locale (`moreLabel` replaces it), has `aria-haspopup="menu"`, and says whether its menu is open with `aria-expanded`. The menu is named by the button and returns focus to it when it closes.
309
+
310
+ ## API
311
+
312
+ Everything below is imported from `@nanahoshi/mona-ui/toolbar`. Each name links to its reference page, with every input, output, property and method.
313
+
314
+ | Name | Kind | Description |
315
+ | --- | --- | --- |
316
+ | [`ToolbarComponent`](api/toolbar.md#toolbarcomponent) | Component | A row of controls, such as formatting buttons, that's one Tab stop: the arrow keys move between its controls. |
317
+ | [`ToolbarItemDirective`](api/toolbar.md#toolbaritemdirective) | Directive | Marks a control directly inside `<mona-toolbar>` as one that moves into the toolbar's More menu when there's no room for it, last ones first. |
318
+
319
+ ### Types
320
+
321
+ | Type | Kind | Description |
322
+ | --- | --- | --- |
323
+ | [`TOOLBAR_DEFAULT_MESSAGES`](api/toolbar.md#toolbar-default-messages) | Constant | |
324
+ | [`ToolbarItemOverflow`](api/toolbar.md#toolbaritemoverflow) | Type alias | Whether a toolbar item moves into the More menu when there's no room for it (`auto`) or stays (`never`). |
325
+ | [`ToolbarOverflow`](api/toolbar.md#toolbaroverflow) | Type alias | What a toolbar does with items that don't fit: moves them into a More menu, or wraps them onto more rows. |
326
+
327
+ **Related types:** [`ClassInputType`](api/common.md#classinputtype), [`MonaToolbarMessages`](api/i18n.md#monatoolbarmessages), [`PreventableEvent`](api/common.md#preventableevent)