@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
@@ -16,6 +16,7 @@ Component.
16
16
 
17
17
  | Name | Type | Default | Description |
18
18
  | --- | --- | --- | --- |
19
+ | `allowCustomValue` | `boolean` | `false` | Lets people add values that aren't in `data`: Enter in the popup's filter box, on text that matches no item, emits `valueAdd` with the text, and an item whose text it matches is selected instead. Needs `monaDropDownFilterable`, whose filter box is where the text is typed. |
19
20
  | `aria-describedby` | `string` | `""` | ID of an element that describes the multi select, such as help text or an error message. |
20
21
  | `aria-label` | `string` | `""` | Accessible name for the multi select. Describe what it represents. Falls back to `placeholder` when neither this nor `aria-labelledby` is set. |
21
22
  | `aria-labelledby` | `string` | `""` | Sets the aria-labelledby attribute of the multi select component. |
@@ -51,6 +52,7 @@ Component.
51
52
  | `open` | `PreventableEvent<Event>` | Emits when the popup is about to open. This event is preventable. |
52
53
  | `opened` | `void` | Emits after the popup is opened. |
53
54
  | `touch` | `void` | Emitted when focus leaves the multi select. Moving between it, its chips, its clear button and its popup doesn't count. The `FormField` directive listens to this to mark the field as touched. |
55
+ | `valueAdd` | `string` | Emitted with the trimmed text when Enter is pressed in the filter box on text that matches no item. Only emitted when `allowCustomValue` is true. Add an item for it to `data` and to `value`; the filter box is cleared for the next one. |
54
56
  | `valueChange` | `Iterable<TValue>` | Emitted when `value` changes. |
55
57
 
56
58
  ### Methods
@@ -0,0 +1,23 @@
1
+ # `@nanahoshi/mona-ui/separator`
2
+
3
+ Everything `@nanahoshi/mona-ui/separator` exports.
4
+
5
+ **Guides:** [Separator](../separator.md)
6
+
7
+ ## `SeparatorComponent`
8
+
9
+ Component.
10
+
11
+ A thin line between groups of content, across a column or down a row, with an optional label in its middle. Like an
12
+ `<hr>`, it's a separator for assistive technology unless it's marked decorative.
13
+
14
+ **Selector:** `mona-separator`
15
+
16
+ ### Inputs
17
+
18
+ | Name | Type | Default | Description |
19
+ | --- | --- | --- | --- |
20
+ | `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`, such as a margin. |
21
+ | `decorative` | `boolean` | `false` | Marks the line as only visual, so assistive technology skips it. Use it where the line repeats a boundary the content already makes, such as between cards. |
22
+ | `label` | `string` | `""` | Text in the middle of a horizontal line, such as "or" between two ways to sign in. It's read as text, and the line stays out of the way, as if it were decorative. |
23
+ | `orientation` | `NonNullable<"horizontal" \| "vertical" \| null \| undefined>` | `"horizontal"` | Whether the line runs across (`horizontal`, between stacked content) or down (`vertical`, between items in a row). A vertical line stretches to the row's height. A labelled line is always horizontal. |
@@ -0,0 +1,81 @@
1
+ # `@nanahoshi/mona-ui/toolbar`
2
+
3
+ Everything `@nanahoshi/mona-ui/toolbar` exports.
4
+
5
+ **Guides:** [Toolbar](../toolbar.md)
6
+
7
+ ## `ToolbarComponent`
8
+
9
+ Component.
10
+
11
+ A row of controls, such as formatting buttons, that's one Tab stop: the arrow keys move between its controls. Items
12
+ marked `monaToolbarItem` that don't fit move into a More menu at the end, last ones first, and come back as the row
13
+ widens.
14
+
15
+ **Selector:** `mona-toolbar`
16
+
17
+ ### Inputs
18
+
19
+ | Name | Type | Default | Description |
20
+ | --- | --- | --- | --- |
21
+ | `aria-label` | `string` | `""` | Accessible name of the toolbar, such as "Formatting". A toolbar needs a name, from this or `aria-labelledby`, since assistive technology announces it on the way in. |
22
+ | `aria-labelledby` | `string` | `""` | ID of the element whose text names the toolbar, such as a visible heading. |
23
+ | `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
24
+ | `moreLabel` | `string` | `""` | Name of the More button, in place of the localized "More". |
25
+ | `overflow` | `ToolbarOverflow` | `"menu"` | What happens to items that don't fit: `menu` moves the `monaToolbarItem`s into a More menu at the end, last ones first, and `wrap` puts the controls on more rows. |
26
+ | `size` | `NonNullable<"small" \| "medium" \| "large" \| null \| undefined>` | `"medium"` | The space between controls and the size of the More button. Match it to the controls' size. |
27
+
28
+ ## `ToolbarItemDirective`
29
+
30
+ Directive.
31
+
32
+ Marks a control directly inside `<mona-toolbar>` as one that moves into the toolbar's More menu when
33
+ there's no room for it, last ones first. In the menu it's an item with the control's text, disabled with it and
34
+ checked while it's pressed, and choosing it clicks the control.
35
+
36
+ **Selector:** `[monaToolbarItem]`
37
+
38
+ ### Inputs
39
+
40
+ | Name | Type | Default | Description |
41
+ | --- | --- | --- | --- |
42
+ | `monaToolbarItem` | `"" \| ToolbarItemOverflow \| null \| undefined` | `"auto"` | Whether the item can move into the More menu: `auto` when there's no room for it, `never` to keep it in the toolbar, such as a search box. |
43
+ | `overflowText` | `string` | `""` | The item's text in the More menu. Without it, the menu uses the control's `aria-label`, then its text. |
44
+
45
+ ### Outputs
46
+
47
+ | Name | Type | Description |
48
+ | --- | --- | --- |
49
+ | `overflowActivate` | `PreventableEvent<Event>` | Emitted when the item is chosen from the More menu. Unless it's prevented, the toolbar then clicks the control, which suits a button. Handle it for a control a click doesn't operate, or keep that control in the toolbar with `overflow="never"`. |
50
+
51
+ ## `TOOLBAR_DEFAULT_MESSAGES`
52
+
53
+ Constant.
54
+
55
+ ```typescript
56
+ const TOOLBAR_DEFAULT_MESSAGES: MonaToolbarMessages;
57
+ ```
58
+
59
+ ## `ToolbarItemOverflow`
60
+
61
+ Type alias.
62
+
63
+ Whether a toolbar item moves into the More menu when there's no room for it (`auto`) or stays (`never`).
64
+
65
+ ```typescript
66
+ type ToolbarItemOverflow = "auto" | "never";
67
+ ```
68
+
69
+ **Used by:** [`ToolbarItemDirective`](toolbar.md#toolbaritemdirective)
70
+
71
+ ## `ToolbarOverflow`
72
+
73
+ Type alias.
74
+
75
+ What a toolbar does with items that don't fit: moves them into a More menu, or wraps them onto more rows.
76
+
77
+ ```typescript
78
+ type ToolbarOverflow = "menu" | "wrap";
79
+ ```
80
+
81
+ **Used by:** [`ToolbarComponent`](toolbar.md#toolbarcomponent)
package/docs/avatar.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Avatar
2
2
 
3
- > Shows a person or entity as an image, text label or projected content.
3
+ > Shows a person or entity as an image, text label or projected content, alone or stacked in a group.
4
4
 
5
5
  Entry point: `@nanahoshi/mona-ui/avatar`
6
6
 
7
- **Selector:** `mona-avatar`
7
+ **Selectors:** `mona-avatar`, `mona-avatar-group`
8
8
 
9
- `AvatarComponent` renders a configurable avatar supporting three exclusive display modes — image, text label, or projected content — with full control over size, shape, and border.
9
+ `AvatarComponent` renders a configurable avatar supporting three exclusive display modes — image, text label, or projected content — with full control over size, shape, and border. `AvatarGroupComponent` stacks avatars in an overlapping row and counts the ones past its `max`.
10
10
 
11
11
  ## Overview
12
12
 
@@ -18,16 +18,18 @@ Entry point: `@nanahoshi/mona-ui/avatar`
18
18
  - Show initials-based fallback content when a user has no profile image, or when the image fails to load
19
19
  - Represent a team or entity with a consistent, bordered shape
20
20
  - Project a custom icon into a fixed-size, bordered slot
21
+ - Show the people on a project or in a conversation as a stack, with `mona-avatar-group`
21
22
 
22
23
  **Do not use when:**
23
24
 
24
25
  - The avatar needs to be interactive — wrap it in a `<button>` or `<a>` yourself; the component provides no built-in interaction
25
- - You need a stacked avatar group — compose individual `<mona-avatar>` elements manually; there is no built-in group component
26
26
 
27
27
  ## Import & Quick Start
28
28
 
29
29
  ```typescript
30
30
  import { AvatarComponent } from "@nanahoshi/mona-ui/avatar";
31
+ // Only for a stack of avatars:
32
+ import { AvatarGroupComponent } from "@nanahoshi/mona-ui/avatar";
31
33
  ```
32
34
 
33
35
  Add `AvatarComponent` to your standalone component's `imports` array.
@@ -128,6 +130,95 @@ export class AvatarIconExampleComponent {}
128
130
  </div>
129
131
  ```
130
132
 
133
+ ### Avatar group
134
+
135
+ `mona-avatar-group` overlaps its avatars, each pulled back by a quarter of its width, with a ring in the page's background color between them. With `max`, the avatars after the first `max` collapse into one item that counts them, "+2" here, in the avatars' size and shape. The hidden members aren't reachable from the group, so link to the full list nearby.
136
+
137
+ `group-example.component.ts`
138
+
139
+ ```typescript
140
+ import { Component } from "@angular/core";
141
+ import { AvatarComponent, AvatarGroupComponent } from "@nanahoshi/mona-ui/avatar";
142
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
143
+
144
+ interface Member {
145
+ /** A theme color, which the avatar fills with. */
146
+ readonly background: string;
147
+ /** The text color the theme pairs with that color. */
148
+ readonly foreground: string;
149
+ readonly initials: string;
150
+ readonly name: string;
151
+ }
152
+
153
+ @Component({
154
+ selector: "app-avatar-group-example",
155
+ imports: [AvatarComponent, AvatarGroupComponent, ButtonDirective],
156
+ templateUrl: "./group-example.component.html"
157
+ })
158
+ export class AvatarGroupExampleComponent {
159
+ protected readonly members: readonly Member[] = [
160
+ {
161
+ background: "var(--color-primary)",
162
+ foreground: "var(--color-primary-foreground)",
163
+ initials: "JS",
164
+ name: "Jane Smith"
165
+ },
166
+ {
167
+ background: "var(--color-info)",
168
+ foreground: "var(--color-info-foreground)",
169
+ initials: "AK",
170
+ name: "Arjun Kumar"
171
+ },
172
+ {
173
+ background: "var(--color-success)",
174
+ foreground: "var(--color-success-foreground)",
175
+ initials: "ML",
176
+ name: "Mei Lin"
177
+ },
178
+ {
179
+ background: "var(--color-warning)",
180
+ foreground: "var(--color-warning-foreground)",
181
+ initials: "TO",
182
+ name: "Tunde Okafor"
183
+ },
184
+ {
185
+ background: "var(--color-error)",
186
+ foreground: "var(--color-error-foreground)",
187
+ initials: "SR",
188
+ name: "Sofia Rossi"
189
+ },
190
+ {
191
+ background: "var(--color-secondary)",
192
+ foreground: "var(--color-secondary-foreground)",
193
+ initials: "LB",
194
+ name: "Lukas Bauer"
195
+ }
196
+ ];
197
+ }
198
+ ```
199
+
200
+ `group-example.component.html`
201
+
202
+ ```html
203
+ <div class="flex items-center gap-3">
204
+ <mona-avatar-group aria-label="Project members" [max]="4">
205
+ @for (member of members; track member.name) {
206
+ <mona-avatar
207
+ borderRadius="50%"
208
+ labelFontSize="0.75rem"
209
+ [aria-label]="member.name"
210
+ [backgroundColor]="member.background"
211
+ [borderWidth]="0"
212
+ [height]="36"
213
+ [label]="member.initials"
214
+ [labelColor]="member.foreground"
215
+ [width]="36" />
216
+ }
217
+ </mona-avatar-group>
218
+ <button monaButton type="button" look="link" size="small">See all {{ members.length }} members</button>
219
+ </div>
220
+ ```
221
+
131
222
  ## Appearance & Styling
132
223
 
133
224
  ### Size
@@ -191,10 +282,21 @@ The avatar has no built-in keyboard behavior and no interactive role. Accessibil
191
282
 
192
283
  If the avatar is purely decorative and already described by adjacent visible text, you may omit both `alt` and `aria-label`. Whether this is appropriate depends on context.
193
284
 
285
+ **Avatar group:** the group has `role="group"`, named by its `aria-label`, such as "Project members", so a screen reader reads the avatars inside it as one set. Name each avatar as above. The count past `max` has `role="img"` and a name such as "2 more", in the current locale; avatars past `max` are hidden from everyone, assistive technology included. The ring between avatars is a shadow, which forced colors don't draw, so give the avatars a border if their edges need to stay apart there.
286
+
194
287
  ## API
195
288
 
196
289
  Everything below is imported from `@nanahoshi/mona-ui/avatar`. Each name links to its reference page, with every input, output, property and method.
197
290
 
198
- | Name | Kind |
291
+ | Name | Kind | Description |
292
+ | --- | --- | --- |
293
+ | [`AvatarComponent`](api/avatar.md#avatarcomponent) | Component | |
294
+ | [`AvatarGroupComponent`](api/avatar.md#avatargroupcomponent) | Component | Stacks `mona-avatar`s in an overlapping row, such as the members of a project. |
295
+
296
+ ### Types
297
+
298
+ | Type | Kind |
199
299
  | --- | --- |
200
- | [`AvatarComponent`](api/avatar.md#avatarcomponent) | Component |
300
+ | [`AVATAR_DEFAULT_MESSAGES`](api/avatar.md#avatar-default-messages) | Constant |
301
+
302
+ **Related types:** [`ClassInputType`](api/common.md#classinputtype), [`MonaAvatarMessages`](api/i18n.md#monaavatarmessages)
package/docs/badge.md ADDED
@@ -0,0 +1,181 @@
1
+ # Badge
2
+
3
+ > A small filled or outlined label for a count or a status.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/badge`
6
+
7
+ **Selector:** `[monaBadge]`
8
+
9
+ `BadgeDirective` turns an element into a small label for a count or a status, such as `12` beside Inbox or `Failed` beside a deployment, filled, tinted or outlined in a color that says what it means.
10
+
11
+ ## Overview
12
+
13
+ Use a badge to show a short value that belongs to something next to it: how many unread messages a folder holds, or what state a deployment is in. It's text with a shape, so it reads as part of the element around it.
14
+
15
+ **Use a badge when you need to:**
16
+
17
+ - Count items, such as unread messages or open issues, beside the thing they belong to
18
+ - Show a status in a list or a table, such as `Live`, `Draft` or `Failed`
19
+ - Mark something as new, beta or deprecated
20
+
21
+ **Use something else when:**
22
+
23
+ - People can select or remove it: use a [Chip](chip.md)
24
+ - The message needs a sentence and maybe an action: use an [Alert](alert.md)
25
+ - It's a row count in a side navigation: `[monaSidebarMenuBadge]` in the [Sidebar](sidebar-menus.md) is a badge that hides on the icon rail
26
+
27
+ ## Import & Quick Start
28
+
29
+ ```typescript
30
+ import { BadgeDirective } from "@nanahoshi/mona-ui/badge";
31
+ ```
32
+
33
+ Add `BadgeDirective` to the `imports` array of a standalone component, and put `monaBadge` on an inline element:
34
+
35
+ ```html
36
+ <span monaBadge look="success" fill="subtle">Live</span>
37
+ ```
38
+
39
+ ## Examples
40
+
41
+ ### Status in a list
42
+
43
+ A `subtle` fill is quiet enough to repeat down a list. Each status says what it means in words, so the color only backs it up.
44
+
45
+ `status-example.component.ts`
46
+
47
+ ```typescript
48
+ import { Component } from "@angular/core";
49
+ import { BadgeDirective, type BadgeVariantProps } from "@nanahoshi/mona-ui/badge";
50
+
51
+ interface Deployment {
52
+ readonly environment: string;
53
+ readonly look: BadgeVariantProps["look"];
54
+ readonly status: string;
55
+ }
56
+
57
+ @Component({
58
+ selector: "app-badge-status-example",
59
+ imports: [BadgeDirective],
60
+ templateUrl: "./status-example.component.html"
61
+ })
62
+ export class BadgeStatusExampleComponent {
63
+ protected readonly deployments: readonly Deployment[] = [
64
+ { environment: "Production", look: "success", status: "Live" },
65
+ { environment: "Staging", look: "info", status: "Deploying" },
66
+ { environment: "Preview", look: "warning", status: "Needs review" },
67
+ { environment: "Nightly", look: "error", status: "Failed" },
68
+ { environment: "Archive", look: "secondary", status: "Stopped" }
69
+ ];
70
+ }
71
+ ```
72
+
73
+ `status-example.component.html`
74
+
75
+ ```html
76
+ <ul class="flex max-w-sm flex-col divide-y divide-border rounded-md border border-border">
77
+ @for (deployment of deployments; track deployment.environment) {
78
+ <li class="flex items-center justify-between gap-4 px-4 py-3">
79
+ <span class="text-sm font-medium">{{ deployment.environment }}</span>
80
+ <span monaBadge fill="subtle" rounded="full" [look]="deployment.look">{{ deployment.status }}</span>
81
+ </li>
82
+ }
83
+ </ul>
84
+ ```
85
+
86
+ ### Counts
87
+
88
+ A count beside a label reads as one phrase, "Inbox 12", which doesn't say what the 12 is. Add the missing word as visually hidden text inside the badge, so a screen reader hears "Inbox 12 unread". Remove the badge when the count is zero, rather than showing `0`.
89
+
90
+ `counts-example.component.ts`
91
+
92
+ ```typescript
93
+ import { Component, signal } from "@angular/core";
94
+ import { BadgeDirective } from "@nanahoshi/mona-ui/badge";
95
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
96
+
97
+ @Component({
98
+ selector: "app-badge-counts-example",
99
+ imports: [BadgeDirective, ButtonDirective],
100
+ templateUrl: "./counts-example.component.html"
101
+ })
102
+ export class BadgeCountsExampleComponent {
103
+ protected readonly unread = signal(12);
104
+
105
+ protected markAllRead(): void {
106
+ this.unread.set(0);
107
+ }
108
+ }
109
+ ```
110
+
111
+ `counts-example.component.html`
112
+
113
+ ```html
114
+ <div class="flex flex-wrap items-center gap-3">
115
+ <button monaButton type="button">
116
+ Inbox
117
+ @if (unread() > 0) {
118
+ <span monaBadge look="primary" rounded="full">
119
+ {{ unread() }}
120
+ <span class="sr-only">unread</span>
121
+ </span>
122
+ }
123
+ </button>
124
+ <button monaButton type="button" look="ghost" [disabled]="unread() === 0" (click)="markAllRead()">
125
+ Mark all as read
126
+ </button>
127
+ </div>
128
+ ```
129
+
130
+ ## Appearance & Styling
131
+
132
+ ### Fills
133
+
134
+ | `fill` | Appearance |
135
+ |-----------|-----------------------------------------------|
136
+ | `solid` | Filled with the look's color (default) |
137
+ | `subtle` | A light tint of the look's color, darker text |
138
+ | `outline` | Only a border in the look's color |
139
+
140
+ ### Looks
141
+
142
+ `look` is the color role: `secondary` (default), `primary`, `success`, `warning`, `error` and `info`. A `solid` badge uses the role's color and foreground, as a button of that look does, and a `subtle` one uses its tint and the darker text the theme pairs with it.
143
+
144
+ ### Sizes and shapes
145
+
146
+ | `size` | Height | Text |
147
+ |----------|--------|-----------|
148
+ | `small` | 16px | 10px |
149
+ | `medium` | 20px | 12px (default) |
150
+ | `large` | 24px | 14px |
151
+
152
+ `rounded` takes `none`, `small`, `medium` (default), `large` and `full`. `full` makes a pill, and a circle for a single digit. An icon inside a badge is sized with it.
153
+
154
+ ### Custom classes
155
+
156
+ Classes passed via `class` are merged with the badge's own through `tailwind-merge`, so `class="ms-auto"` pushes a badge to the end of a row, and `class="rounded-none"` replaces the preset.
157
+
158
+ ### Forced colors
159
+
160
+ A badge's fill doesn't paint in forced colors, so it keeps a border in the text color there, and the badge still reads as a shape.
161
+
162
+ ## Accessibility
163
+
164
+ The directive adds no role, name or state, so the badge's text is read in place, as part of what's around it:
165
+
166
+ - **Say what a count counts.** Add visually hidden text, such as `<span class="sr-only">unread</span>`, or name the parent control so it includes the count.
167
+ - **Say the status in words.** Color and shape back the text up; they don't replace it.
168
+ - **Announce changes yourself.** A badge isn't a live region. If a count changing matters while someone is working, announce it, for example with a polite live region.
169
+ - **Keep it out of interactive roles.** A badge isn't focusable and has no keyboard interaction. To make it act, put it inside a button or link, or use a [Chip](chip.md).
170
+
171
+ ## API
172
+
173
+ Everything below is imported from `@nanahoshi/mona-ui/badge`. Each name links to its reference page, with every input, output, property and method.
174
+
175
+ | Name | Kind | Description |
176
+ | --- | --- | --- |
177
+ | [`BadgeDirective`](api/badge.md#badgedirective) | Directive | A short count or status, such as `12` or `Draft`, drawn as a small filled or outlined label. |
178
+
179
+ ### Types
180
+
181
+ **Related types:** [`ClassInputType`](api/common.md#classinputtype)
@@ -1,12 +1,12 @@
1
1
  # Columns
2
2
 
3
- > Resize, reorder, lock and hide columns, by pointer, keyboard or the column chooser.
3
+ > Group, resize, reorder, lock and hide columns, by pointer, keyboard or the column chooser.
4
4
 
5
5
  Entry point: `@nanahoshi/mona-ui/grid`
6
6
 
7
7
  **Selectors:** `mona-grid[monaGridResizable]`, `mona-grid[monaGridReorderable]`
8
8
 
9
- `monaGridResizable` adds a drag handle between column headers, and `monaGridReorderable` lets people drag headers into a new order. A column's own inputs set its width, lock it to one side while the grid scrolls sideways, or hide it, and the toolbar's Columns button lets people choose which columns they see.
9
+ `monaGridResizable` adds a drag handle between column headers, and `monaGridReorderable` lets people drag headers into a new order. A column's own inputs set its width, lock it to one side while the grid scrolls sideways, or hide it, `mona-grid-column-group` puts a header over a set of columns, and the toolbar's Columns button lets people choose which columns they see.
10
10
 
11
11
  ## Overview
12
12
 
@@ -17,6 +17,7 @@ Entry point: `@nanahoshi/mona-ui/grid`
17
17
  | Reordering | `monaGridReorderable` | `columnReorder` (cancelable) |
18
18
  | Locking | `locked` and `lockedPosition` on a column or the command column | — |
19
19
  | Hiding | `hidden` on a column; the Columns button in the toolbar | — |
20
+ | Grouping | `mona-grid-column-group` around columns, nested for more header rows | — |
20
21
 
21
22
  People's changes to widths, order and visibility live in the grid, not in your column definitions. To keep them across visits, add `monaGridStatePersistence`, see [State & Export](grid-state-export.md).
22
23
 
@@ -27,13 +28,23 @@ People's changes to widths, order and visibility live in the grid, not in your c
27
28
  ## Import & Quick Start
28
29
 
29
30
  ```typescript
30
- import { GridColumnComponent, GridComponent, GridReorderableDirective, GridResizableDirective } from "@nanahoshi/mona-ui/grid";
31
+ import {
32
+ GridColumnComponent,
33
+ GridColumnGroupComponent,
34
+ GridComponent,
35
+ GridReorderableDirective,
36
+ GridResizableDirective
37
+ } from "@nanahoshi/mona-ui/grid";
31
38
  ```
32
39
 
33
40
  ```html
34
41
  <mona-grid aria-label="Orders" [data]="orders()" monaGridResizable monaGridReorderable>
35
42
  <mona-grid-column field="orderId" title="Order ID" [locked]="true" [width]="110"></mona-grid-column>
36
43
  <mona-grid-column field="customer" title="Customer" [minWidth]="160"></mona-grid-column>
44
+ <mona-grid-column-group title="Shipping">
45
+ <mona-grid-column field="shipCity" title="City"></mona-grid-column>
46
+ <mona-grid-column field="shipCountry" title="Country"></mona-grid-column>
47
+ </mona-grid-column-group>
37
48
  </mona-grid>
38
49
  ```
39
50
 
@@ -125,6 +136,80 @@ export class GridLockedColumnsExampleComponent {
125
136
 
126
137
  The Shipment column is locked to the start and the Status column to the end, so both stay in view while the others scroll sideways. Containers starts hidden; the toolbar's Columns button shows it. `columnReorder` is prevented for the Shipment column, so it can't move.
127
138
 
139
+ ### Column Groups
140
+
141
+ `column-groups-example.component.ts`
142
+
143
+ ```typescript
144
+ import { Component } from "@angular/core";
145
+ import {
146
+ GridColumnComponent,
147
+ GridColumnGroupComponent,
148
+ GridComponent,
149
+ GridReorderableDirective,
150
+ GridResizableDirective,
151
+ GridToolbarTemplateDirective
152
+ } from "@nanahoshi/mona-ui/grid";
153
+
154
+ @Component({
155
+ selector: "app-grid-columns-column-groups-example",
156
+ imports: [
157
+ GridColumnComponent,
158
+ GridColumnGroupComponent,
159
+ GridComponent,
160
+ GridReorderableDirective,
161
+ GridResizableDirective,
162
+ GridToolbarTemplateDirective
163
+ ],
164
+ templateUrl: "./column-groups-example.component.html"
165
+ })
166
+ export class GridColumnGroupsExampleComponent {
167
+ protected readonly flights = Array.from({ length: 8 }, (_, index) => ({
168
+ aircraft: ["Airbus A320", "Boeing 737-800", "Embraer 190"][index % 3],
169
+ arrives: `${String(9 + index).padStart(2, "0")}:${index % 2 === 0 ? "10" : "40"}`,
170
+ departs: `${String(7 + index).padStart(2, "0")}:${index % 2 === 0 ? "05" : "35"}`,
171
+ flight: `MN ${410 + index * 7}`,
172
+ from: ["Oslo Gardermoen", "Lisbon Humberto Delgado", "Dublin", "Tallinn"][index % 4],
173
+ seats: [180, 189, 100][index % 3],
174
+ to: ["Rotterdam The Hague", "Hamburg", "Antwerp", "Gdańsk Lech Wałęsa"][(index + 1) % 4]
175
+ }));
176
+ }
177
+ ```
178
+
179
+ `column-groups-example.component.html`
180
+
181
+ ```html
182
+ <mona-grid
183
+ aria-label="Departures"
184
+ class="w-full"
185
+ rowKey="flight"
186
+ [data]="flights"
187
+ [pageSize]="5"
188
+ monaGridReorderable
189
+ monaGridResizable>
190
+ <ng-template monaGridToolbarTemplate>
191
+ <span class="text-sm font-medium">Departures</span>
192
+ </ng-template>
193
+ <mona-grid-column field="flight" title="Flight" [locked]="true" [width]="100" />
194
+ <mona-grid-column-group title="Route">
195
+ <mona-grid-column-group title="Departure">
196
+ <mona-grid-column field="from" title="Airport" [width]="190" />
197
+ <mona-grid-column field="departs" title="Time" [width]="90" />
198
+ </mona-grid-column-group>
199
+ <mona-grid-column-group title="Arrival">
200
+ <mona-grid-column field="to" title="Airport" [width]="190" />
201
+ <mona-grid-column field="arrives" title="Time" [width]="90" />
202
+ </mona-grid-column-group>
203
+ </mona-grid-column-group>
204
+ <mona-grid-column-group title="Aircraft">
205
+ <mona-grid-column field="aircraft" title="Type" [width]="150" />
206
+ <mona-grid-column field="seats" title="Seats" type="number" [width]="90" />
207
+ </mona-grid-column-group>
208
+ </mona-grid>
209
+ ```
210
+
211
+ Route holds two nested groups, so the header has two rows of group titles above the column titles. Move a column with its header or `Ctrl+Shift+ArrowRight`: a Time column only swaps with its Airport, and Departure and Arrival move past each other as wholes. The Columns button lists each column with its groups, such as `Route / Departure / Airport`.
212
+
128
213
  ### Column Widths
129
214
 
130
215
  `width` fixes a column's width in pixels. Columns without one get theirs from the grid's `resizeMethod`:
@@ -159,6 +244,16 @@ A drag stops at the column's `minWidth` and `maxWidth`, and `Escape` during a dr
159
244
 
160
245
  Dropping on the start half of a header puts the column before it, the end half after it; `Escape` cancels the drag.
161
246
 
247
+ ### Column groups
248
+
249
+ Each `mona-grid-column-group` adds a header over the columns inside it, and nested groups add a header row per level. A column outside a group at some level shows its title in the bottom row, with the space above it left empty.
250
+
251
+ - **Order.** A group's columns always sit together, where its first column is. A column moves only among its group's columns and nested groups, and a nested group moves past it as a whole; a column outside the group can't be dropped into it. A saved state that splits a group is put back together.
252
+ - **Width.** A group's header is as wide as its visible columns. Resizing a column widens or narrows its groups too; a group's header has no resize handle of its own.
253
+ - **Hiding.** Hiding a column narrows its groups, and a group with no visible column leaves the header. When the deepest group has no visible column left, its header row goes.
254
+ - **Locking.** A locked column moves to its side of the grid, so its group's header splits there, with the title over each part. Lock every column of a group to keep it whole. While the grid scrolls sideways, a group's title stays in view beside the locked columns as long as part of the group does.
255
+ - **Export.** `exportCsv` writes the column titles only, and `exportExcel` writes the groups as merged header cells, see [State & Export](grid-state-export.md).
256
+
162
257
  ### Locking
163
258
 
164
259
  A locked column stays on its `lockedPosition` side, `"left"` (default) or `"right"`, which are the start and end of the grid, so they swap in right-to-left layouts. The command column takes `locked` and `lockedPosition` too. The selection checkbox column is always locked at the start.
@@ -169,7 +264,9 @@ With a `monaGridToolbarTemplate`, the toolbar shows a Columns button (the `colum
169
264
 
170
265
  ## Accessibility
171
266
 
172
- Every column needs a `title`: it names the header, the resize handle and the Columns popup's checkbox. Moving a column from the keyboard is announced through a polite live region (the `columnMoved` message).
267
+ Every column needs a `title`: it names the header, the resize handle and the Columns popup's checkbox. Give every `mona-grid-column-group` a `title` too: it names the group's header. Moving a column from the keyboard is announced through a polite live region (the `columnMoved` message).
268
+
269
+ Group headers are column headers that span their columns, so a screen reader can read a cell's group with its column. `ArrowUp` and `ArrowDown` reach a group's header from any column under it and come back to the same column.
173
270
 
174
271
  ### Keyboard
175
272
 
@@ -179,7 +276,8 @@ Every column needs a `title`: it names the header, the resize handle and the Col
179
276
  | `ArrowLeft` / `ArrowRight` | On a resize handle, narrows/widens the column by 10px (mirrored in right-to-left layouts). |
180
277
  | `Home` / `End` | On a resize handle, sets the column to its narrowest/widest width. |
181
278
  | `Enter` | On a resize handle, fits the column to its content. |
182
- | `Ctrl+Shift+ArrowLeft` / `Ctrl+Shift+ArrowRight` | With `monaGridReorderable`, moves the focused header's column one place (mirrored in right-to-left layouts) and announces it. `Cmd` too. |
279
+ | `Ctrl+Shift+ArrowLeft` / `Ctrl+Shift+ArrowRight` | With `monaGridReorderable`, moves the focused header's column one place within its column group, past a nested group as a whole (mirrored in right-to-left layouts), and announces it. `Cmd` too. |
280
+ | `ArrowUp` / `ArrowDown` | Between a column's header and the headers of the groups over it. |
183
281
 
184
282
  The rest of the grid's keys are on [Grid Overview](grid.md#keyboard).
185
283
 
@@ -192,25 +290,31 @@ The rest of the grid's keys are on [Grid Overview](grid.md#keyboard).
192
290
  | `aria-label` | On the column resize handle | `"Resize {column}"` (`resizeColumn` message) |
193
291
  | `aria-valuenow` | On the column resize handle | The column width in pixels, with `aria-valuemin`/`aria-valuemax` |
194
292
  | `aria-keyshortcuts` | On a header of a reorderable grid | The keys that move it |
293
+ | `role` | On a column group's header | `"columnheader"`, with `scope="colgroup"` |
294
+ | `aria-colspan` | On a column group's header | The number of columns it spans |
295
+ | `aria-colindex` | On a column group's header | Its first column's position |
296
+ | `aria-hidden` | On the space over a column outside a group | `"true"` |
195
297
 
196
298
  ## API
197
299
 
198
300
  Everything below is imported from `@nanahoshi/mona-ui/grid`. Each name links to its reference page, with every input, output, property and method.
199
301
 
200
- | Name | Kind |
201
- | --- | --- |
202
- | [`GridReorderableDirective`](api/grid.md#gridreorderabledirective) | Directive |
203
- | [`GridResizableDirective`](api/grid.md#gridresizabledirective) | Directive |
204
- | [`ColumnReorderEvent`](api/grid.md#columnreorderevent) | Class |
302
+ | Name | Kind | Description |
303
+ | --- | --- | --- |
304
+ | [`GridColumnGroupComponent`](api/grid.md#gridcolumngroupcomponent) | Component | Puts a header over the `mona-grid-column`s and `mona-grid-command-column`s inside it. |
305
+ | [`GridReorderableDirective`](api/grid.md#gridreorderabledirective) | Directive | |
306
+ | [`GridResizableDirective`](api/grid.md#gridresizabledirective) | Directive | |
307
+ | [`ColumnReorderEvent`](api/grid.md#columnreorderevent) | Class | |
205
308
 
206
309
  ### Types
207
310
 
208
- | Type | Kind |
209
- | --- | --- |
210
- | [`ColumnResizeEvent`](api/grid.md#columnresizeevent) | Interface |
211
- | [`ReorderableOptions`](api/grid.md#reorderableoptions) | Interface |
212
- | [`ResizableOptions`](api/grid.md#resizableoptions) | Interface |
213
- | [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition) | Type alias |
214
- | [`ResizeMethod`](api/grid.md#resizemethod) | Type alias |
311
+ | Type | Kind | Description |
312
+ | --- | --- | --- |
313
+ | [`ColumnGroup`](api/grid.md#columngroup) | Interface | A `mona-grid-column-group`: a header over the columns inside it. |
314
+ | [`ColumnResizeEvent`](api/grid.md#columnresizeevent) | Interface | |
315
+ | [`ReorderableOptions`](api/grid.md#reorderableoptions) | Interface | |
316
+ | [`ResizableOptions`](api/grid.md#resizableoptions) | Interface | |
317
+ | [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition) | Type alias | |
318
+ | [`ResizeMethod`](api/grid.md#resizemethod) | Type alias | |
215
319
 
216
320
  **Related types:** [`Column`](api/grid.md#column), [`PreventableEvent`](api/common.md#preventableevent)