@nanahoshi/mona-ui 0.34.0 → 0.36.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 (87) 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 +3 -3
  8. package/docs/api/i18n.md +71 -5
  9. package/docs/api/locales.md +14 -14
  10. package/docs/api/masked-text-box.md +137 -0
  11. package/docs/api/multi-select.md +3 -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/masked-textbox.md +334 -0
  17. package/docs/multi-select.md +120 -0
  18. package/docs/separator.md +147 -0
  19. package/docs/sidebar-menus.md +1 -1
  20. package/docs/toolbar.md +327 -0
  21. package/fesm2022/nanahoshi-mona-ui-alert.mjs +422 -0
  22. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +182 -3
  23. package/fesm2022/nanahoshi-mona-ui-badge.mjs +273 -0
  24. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +20 -1
  25. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +54 -15
  26. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +13 -1
  27. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +13 -1
  28. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +13 -1
  29. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +13 -1
  30. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +13 -1
  31. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +13 -1
  32. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +13 -1
  33. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +13 -1
  34. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +13 -1
  35. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +13 -1
  36. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +13 -1
  37. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +13 -1
  38. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +13 -1
  39. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +13 -1
  40. package/fesm2022/nanahoshi-mona-ui-masked-text-box.mjs +1302 -0
  41. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +112 -3
  42. package/fesm2022/nanahoshi-mona-ui-separator.mjs +165 -0
  43. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +3 -3
  44. package/fesm2022/nanahoshi-mona-ui-toolbar.mjs +536 -0
  45. package/i18n/catalogs/en-US.messages.json +19 -1
  46. package/llms.txt +13 -3
  47. package/locales/ar-sa/ar-sa.messages.json +19 -1
  48. package/locales/de-de/de-de.messages.json +19 -1
  49. package/locales/es-es/es-es.messages.json +19 -1
  50. package/locales/fr-fr/fr-fr.messages.json +19 -1
  51. package/locales/id-id/id-id.messages.json +19 -1
  52. package/locales/it-it/it-it.messages.json +19 -1
  53. package/locales/ja-jp/ja-jp.messages.json +19 -1
  54. package/locales/ko-kr/ko-kr.messages.json +19 -1
  55. package/locales/pl-pl/pl-pl.messages.json +19 -1
  56. package/locales/pt-br/pt-br.messages.json +19 -1
  57. package/locales/ru-ru/ru-ru.messages.json +19 -1
  58. package/locales/tr-tr/tr-tr.messages.json +19 -1
  59. package/locales/zh-cn/zh-cn.messages.json +19 -1
  60. package/locales/zh-tw/zh-tw.messages.json +19 -1
  61. package/masked-text-box/package.json +4 -0
  62. package/package.json +21 -1
  63. package/separator/package.json +4 -0
  64. package/toolbar/package.json +4 -0
  65. package/types/nanahoshi-mona-ui-alert.d.ts +144 -0
  66. package/types/nanahoshi-mona-ui-avatar.d.ts +66 -0
  67. package/types/nanahoshi-mona-ui-badge.d.ts +82 -0
  68. package/types/nanahoshi-mona-ui-i18n.d.ts +44 -0
  69. package/types/nanahoshi-mona-ui-internal-list.d.ts +12 -0
  70. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +18 -0
  71. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +18 -0
  72. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +18 -0
  73. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +18 -0
  74. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +18 -0
  75. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +18 -0
  76. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +18 -0
  77. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +18 -0
  78. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +18 -0
  79. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +18 -0
  80. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +18 -0
  81. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +18 -0
  82. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +18 -0
  83. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +18 -0
  84. package/types/nanahoshi-mona-ui-masked-text-box.d.ts +391 -0
  85. package/types/nanahoshi-mona-ui-multi-select.d.ts +38 -0
  86. package/types/nanahoshi-mona-ui-separator.d.ts +66 -0
  87. package/types/nanahoshi-mona-ui-toolbar.d.ts +183 -0
@@ -0,0 +1,137 @@
1
+ # `@nanahoshi/mona-ui/masked-text-box`
2
+
3
+ Everything `@nanahoshi/mona-ui/masked-text-box` exports.
4
+
5
+ **Guides:** [Masked Text Box](../masked-textbox.md)
6
+
7
+ ## `MaskedTextBoxComponent`
8
+
9
+ Component.
10
+
11
+ A text box that takes a value in a fixed format, such as a phone number or a postal code. Each character goes into
12
+ a slot of the mask, and the mask's literals, such as the parentheses and dash of `(000) 000-0000`, are filled in as
13
+ you type. The rest of the mask shows after what's typed, so the format is in view.
14
+
15
+ **Selector:** `mona-masked-text-box`
16
+ **Implements:** `FormValueControl<string>`
17
+
18
+ ### Inputs
19
+
20
+ | Name | Type | Default | Description |
21
+ | --- | --- | --- | --- |
22
+ | `aria-describedby` | `string` | `""` | Id of an element that describes the inner input, such as a hint that gives the format. |
23
+ | `aria-label` | `string` | `""` | Accessible name of the inner input. Prefer a visible label, linked through `inputId` or `aria-labelledby`. |
24
+ | `aria-labelledby` | `string` | `""` | Id of the element that labels the inner input. |
25
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
26
+ | `clearButton` | `boolean` | `false` | Displays a clear button that empties the value. The button is hidden while the value is empty or the box is disabled or read-only. |
27
+ | `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. |
28
+ | `includeLiterals` | `boolean` | `false` | Whether the value includes the mask's literals: `(555) 123-4567` instead of `5551234567`. |
29
+ | `inputAttributes` | `AttributeConfig` | `{}` | Additional HTML attributes applied directly to the inner `<input>` element, such as `autocomplete`. An `inputmode` here replaces the one the mask picks. |
30
+ | `inputClass` | `string \| string[]` | `""` | Additional CSS classes applied to the inner `<input>` element. |
31
+ | `inputId` | `string` | `generated` | Id of the inner `<input>` element. Point a `<label for>` or `<mona-label for>` at it to label the box. A unique id is generated when it isn't set. |
32
+ | `inputStyle` | `string \| Partial<CSSStyleDeclaration> \| null` | `null` | Inline styles applied to the inner `<input>` element. Accepts a style string or a `CSSStyleDeclaration` partial. |
33
+ | `invalid` | `boolean` | `false` | Marks the box as invalid. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. Once touched, the box also shows as invalid while it's partly filled. |
34
+ | `mask` | `string` | `""` | The format, one character per slot or literal. `0` is a digit, `9` an optional digit, `#` an optional digit, `+` or `-`, `L` a letter, `?` an optional letter, `A` a letter or digit, `a` an optional letter or digit, `&` any character but a space, and `C` an optional one. Anything else is a literal, and so is a character after a backslash, such as `\0`. |
35
+ | `name` | `string` | `""` | Name of the inner input, used by browsers and password managers for autofill. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
36
+ | `placeholder` | `string` | `""` | Text shown while the box is empty and doesn't have focus, in place of the mask. |
37
+ | `prompt` | `string` | `"_"` | The character shown in an empty slot. |
38
+ | `readonly` | `boolean` | `false` | Prevents value changes while preserving the component's visual state. |
39
+ | `required` | `boolean` | `false` | Marks the box as required. Triggers the invalid state when the value is empty and the field has been touched. |
40
+ | `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Border-radius preset applied to the component. |
41
+ | `rules` | `MaskRules` | `{}` | Mask characters of your own, each mapped to a pattern one character must match, such as `{ H: /[0-9a-f]/i }`. They can replace the built-in ones, and their slots are required. |
42
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the component's dimensions. |
43
+ | `touched` | `boolean` | `false` | Sets the touched state of the box. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
44
+ | `value` (two-way) | `string` | `""` | Two-way bindable value: the characters typed into the slots, up to the last one filled, with a space for an empty slot before it. `includeLiterals` adds the mask's literals. A value that doesn't line up with the mask, such as `555-123-4567` for `(000) 000-0000`, is fitted into it and written back as it reads. |
45
+
46
+ ### Outputs
47
+
48
+ | Name | Type | Description |
49
+ | --- | --- | --- |
50
+ | `inputBlur` | `FocusEvent` | Emitted when the inner input loses focus, including when focus moves to the clear button or to content in the prefix or suffix templates. |
51
+ | `inputFocus` | `FocusEvent` | Emitted when the inner input gains focus. |
52
+ | `touch` | `void` | Emitted when focus leaves the box, including its clear button and prefix and suffix content. Form directives (`[formField]`, `ngModel`, `formControl`) listen to this to mark the field as touched. |
53
+ | `valueChange` | `string` | Emitted when `value` changes. |
54
+
55
+ ### Methods
56
+
57
+ | Signature | Description |
58
+ | --- | --- |
59
+ | `focus(options?: FocusOptions): void` | Focuses the inner input and puts the caret at the first empty slot, where typing picks up. |
60
+
61
+ ## `MaskedTextBoxPrefixTemplateDirective`
62
+
63
+ Directive.
64
+
65
+ Marks an `<ng-template>` as content before the masked text box's input, such as an icon or a country code. Several
66
+ render in source order.
67
+
68
+ **Selector:** `ng-template[monaMaskedTextBoxPrefixTemplate]`
69
+
70
+ ## `MaskedTextBoxSuffixTemplateDirective`
71
+
72
+ Directive.
73
+
74
+ Marks an `<ng-template>` as content after the masked text box's input and its clear button, such as a unit or a
75
+ button. Several render in source order.
76
+
77
+ **Selector:** `ng-template[monaMaskedTextBoxSuffixTemplate]`
78
+
79
+ ## `formatMaskedValue`
80
+
81
+ Function.
82
+
83
+ Formats a value for display with its mask's literals, such as `"5551234567"` as `"(555) 123-4567"` for the mask
84
+ `"(000) 000-0000"`. It reads the value as a masked text box with the same options would, and stops after the last
85
+ character the value has. An empty slot before it shows as a space.
86
+
87
+ ```typescript
88
+ function formatMaskedValue(value: string, mask: string, options: MaskOptions = {}): string;
89
+ ```
90
+
91
+ ## `isMaskComplete`
92
+
93
+ Function.
94
+
95
+ Whether a value fills every required slot of a mask, for a validator. An empty value doesn't, so let an optional
96
+ field's validator pass `""` first.
97
+
98
+ ```typescript
99
+ function isMaskComplete(value: string, mask: string, options: MaskOptions = {}): boolean;
100
+ ```
101
+
102
+ ## `MASKED_TEXT_BOX_DEFAULT_MESSAGES`
103
+
104
+ Constant.
105
+
106
+ ```typescript
107
+ const MASKED_TEXT_BOX_DEFAULT_MESSAGES: MonaMaskedTextBoxMessages;
108
+ ```
109
+
110
+ ## `MaskOptions`
111
+
112
+ Interface.
113
+
114
+ How a value is read against a mask, for `isMaskComplete` and `formatMaskedValue`. Pass what the masked
115
+ text box is given.
116
+
117
+ ### Properties
118
+
119
+ | Name | Type | Description |
120
+ | --- | --- | --- |
121
+ | `includeLiterals?` (read-only) | `boolean` | Whether the value includes the mask's literal characters, as the masked text box's `includeLiterals`. |
122
+ | `rules?` (read-only) | `MaskRules` | Custom mask characters, as the masked text box's `rules`. |
123
+
124
+ **Used by:** [`formatMaskedValue`](masked-text-box.md#formatmaskedvalue), [`isMaskComplete`](masked-text-box.md#ismaskcomplete)
125
+
126
+ ## `MaskRules`
127
+
128
+ Type alias.
129
+
130
+ Mask characters of your own, each mapped to a pattern that one character must match, such as `{ H: /[0-9a-f]/i }`
131
+ for a hexadecimal digit. A slot made by a custom rule is required. A rule can replace a built-in one, such as `0`.
132
+
133
+ ```typescript
134
+ type MaskRules = Readonly<Record<string, RegExp>>;
135
+ ```
136
+
137
+ **Used by:** [`MaskedTextBoxComponent`](masked-text-box.md#maskedtextboxcomponent), [`MaskOptions`](masked-text-box.md#maskoptions)
@@ -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. |
@@ -35,6 +36,7 @@ Component.
35
36
  | `required` | `boolean` | `false` | Sets the required state of the multi select component. |
36
37
  | `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Sets the border radius of the multi select component. |
37
38
  | `showClearButton` | `boolean` | `false` | Renders a button that clears all selected items when at least one item is selected. |
39
+ | `showSelectAll` | `boolean` | `false` | Starts the list with a "Select all" option, which selects every enabled item the filter leaves, or deselects them when they're all selected. Its checkbox shows when only some are. |
38
40
  | `size` | `"large" \| "medium" \| "small"` | `"medium"` | The size of the multi select component. |
39
41
  | `textField` | `DropdownFieldSelectorType<TData, string>` | `null` | Sets the text field of the multi select component. It can be null, string, or a function that takes an item and returns a string. If null, the item itself will be used as the text representation. |
40
42
  | `touched` | `boolean` | `false` | Sets the touched state of the multi select. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
@@ -51,6 +53,7 @@ Component.
51
53
  | `open` | `PreventableEvent<Event>` | Emits when the popup is about to open. This event is preventable. |
52
54
  | `opened` | `void` | Emits after the popup is opened. |
53
55
  | `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. |
56
+ | `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
57
  | `valueChange` | `Iterable<TValue>` | Emitted when `value` changes. |
55
58
 
56
59
  ### 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)