@nanahoshi/mona-ui 0.34.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 (80) 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/i18n.md +45 -0
  9. package/docs/api/locales.md +14 -14
  10. package/docs/api/multi-select.md +2 -0
  11. package/docs/api/separator.md +23 -0
  12. package/docs/api/toolbar.md +81 -0
  13. package/docs/avatar.md +108 -6
  14. package/docs/badge.md +181 -0
  15. package/docs/multi-select.md +54 -0
  16. package/docs/separator.md +147 -0
  17. package/docs/sidebar-menus.md +1 -1
  18. package/docs/toolbar.md +327 -0
  19. package/fesm2022/nanahoshi-mona-ui-alert.mjs +422 -0
  20. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +182 -3
  21. package/fesm2022/nanahoshi-mona-ui-badge.mjs +273 -0
  22. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  23. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +3 -0
  24. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +3 -0
  25. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +3 -0
  26. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +3 -0
  27. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +3 -0
  28. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +3 -0
  29. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +3 -0
  30. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +3 -0
  31. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +3 -0
  32. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +3 -0
  33. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +3 -0
  34. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +3 -0
  35. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +3 -0
  36. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +3 -0
  37. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +83 -2
  38. package/fesm2022/nanahoshi-mona-ui-separator.mjs +165 -0
  39. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +3 -3
  40. package/fesm2022/nanahoshi-mona-ui-toolbar.mjs +536 -0
  41. package/i18n/catalogs/en-US.messages.json +9 -0
  42. package/llms.txt +11 -3
  43. package/locales/ar-sa/ar-sa.messages.json +9 -0
  44. package/locales/de-de/de-de.messages.json +9 -0
  45. package/locales/es-es/es-es.messages.json +9 -0
  46. package/locales/fr-fr/fr-fr.messages.json +9 -0
  47. package/locales/id-id/id-id.messages.json +9 -0
  48. package/locales/it-it/it-it.messages.json +9 -0
  49. package/locales/ja-jp/ja-jp.messages.json +9 -0
  50. package/locales/ko-kr/ko-kr.messages.json +9 -0
  51. package/locales/pl-pl/pl-pl.messages.json +9 -0
  52. package/locales/pt-br/pt-br.messages.json +9 -0
  53. package/locales/ru-ru/ru-ru.messages.json +9 -0
  54. package/locales/tr-tr/tr-tr.messages.json +9 -0
  55. package/locales/zh-cn/zh-cn.messages.json +9 -0
  56. package/locales/zh-tw/zh-tw.messages.json +9 -0
  57. package/package.json +17 -1
  58. package/separator/package.json +4 -0
  59. package/toolbar/package.json +4 -0
  60. package/types/nanahoshi-mona-ui-alert.d.ts +144 -0
  61. package/types/nanahoshi-mona-ui-avatar.d.ts +66 -0
  62. package/types/nanahoshi-mona-ui-badge.d.ts +82 -0
  63. package/types/nanahoshi-mona-ui-i18n.d.ts +24 -0
  64. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +9 -0
  65. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +9 -0
  66. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +9 -0
  67. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +9 -0
  68. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +9 -0
  69. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +9 -0
  70. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +9 -0
  71. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +9 -0
  72. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +9 -0
  73. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +9 -0
  74. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +9 -0
  75. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +9 -0
  76. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +9 -0
  77. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +9 -0
  78. package/types/nanahoshi-mona-ui-multi-select.d.ts +27 -0
  79. package/types/nanahoshi-mona-ui-separator.d.ts +66 -0
  80. 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)
@@ -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)