@nanahoshi/mona-ui 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/command/package.json +4 -0
- package/docs/auto-complete.md +733 -0
- package/docs/avatar.md +220 -0
- package/docs/breadcrumb.md +320 -0
- package/docs/button-group.md +392 -0
- package/docs/button.md +256 -0
- package/docs/calendar.md +515 -0
- package/docs/card.md +292 -0
- package/docs/chart.md +4058 -0
- package/docs/checkbox.md +374 -0
- package/docs/chip.md +339 -0
- package/docs/circular-progress-bar.md +287 -0
- package/docs/collapsible.md +308 -0
- package/docs/color-gradient.md +336 -0
- package/docs/color-palette.md +317 -0
- package/docs/color-picker.md +387 -0
- package/docs/combo-box.md +764 -0
- package/docs/command.md +582 -0
- package/docs/contextmenu.md +530 -0
- package/docs/date-picker.md +251 -0
- package/docs/datetime-picker.md +284 -0
- package/docs/decimal-textbox.md +260 -0
- package/docs/dialog.md +822 -0
- package/docs/dropdown-button.md +507 -0
- package/docs/dropdown-list.md +779 -0
- package/docs/editor.md +374 -0
- package/docs/expansion-panel.md +348 -0
- package/docs/fieldset.md +217 -0
- package/docs/forms.md +162 -0
- package/docs/grid.md +2053 -0
- package/docs/input.md +197 -0
- package/docs/installation.md +54 -0
- package/docs/introduction.md +46 -0
- package/docs/label.md +340 -0
- package/docs/list-box.md +637 -0
- package/docs/list-view.md +584 -0
- package/docs/menubar.md +559 -0
- package/docs/multi-select.md +765 -0
- package/docs/notification.md +460 -0
- package/docs/numeric-textbox.md +301 -0
- package/docs/otp-input.md +539 -0
- package/docs/pager.md +513 -0
- package/docs/placeholder.md +176 -0
- package/docs/popover.md +423 -0
- package/docs/popup-menu.md +658 -0
- package/docs/popup.md +617 -0
- package/docs/progress-bar.md +368 -0
- package/docs/radio-button.md +451 -0
- package/docs/range-slider.md +367 -0
- package/docs/rating.md +518 -0
- package/docs/scroll-view.md +375 -0
- package/docs/segmented.md +434 -0
- package/docs/sheet.md +348 -0
- package/docs/sidebar.md +1126 -0
- package/docs/skeleton.md +181 -0
- package/docs/slider.md +423 -0
- package/docs/spinner.md +370 -0
- package/docs/split-button.md +522 -0
- package/docs/splitter.md +342 -0
- package/docs/stepper.md +539 -0
- package/docs/switch.md +340 -0
- package/docs/tabs.md +542 -0
- package/docs/textarea.md +196 -0
- package/docs/textbox.md +332 -0
- package/docs/theming.md +403 -0
- package/docs/time-picker.md +254 -0
- package/docs/tooltip-directive.md +340 -0
- package/docs/tooltip.md +321 -0
- package/docs/tree-view.md +1018 -0
- package/docs/window.md +663 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-button.mjs +14 -2
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +108 -22
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +7 -3
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +8 -3
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +10 -7
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +53 -21
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
- package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
- package/i18n/catalogs/en-US.messages.json +10 -0
- package/internal/popup-menu/package.json +4 -0
- package/llms.txt +123 -0
- package/locales/ar-sa/ar-sa.messages.json +10 -0
- package/locales/de-de/de-de.messages.json +10 -0
- package/locales/es-es/es-es.messages.json +10 -0
- package/locales/fr-fr/fr-fr.messages.json +10 -0
- package/locales/id-id/id-id.messages.json +10 -0
- package/locales/it-it/it-it.messages.json +10 -0
- package/locales/ja-jp/ja-jp.messages.json +10 -0
- package/locales/ko-kr/ko-kr.messages.json +10 -0
- package/locales/pt-br/pt-br.messages.json +10 -0
- package/locales/ru-ru/ru-ru.messages.json +10 -0
- package/locales/tr-tr/tr-tr.messages.json +10 -0
- package/locales/zh-cn/zh-cn.messages.json +10 -0
- package/locales/zh-tw/zh-tw.messages.json +10 -0
- package/package.json +9 -1
- package/styles.css +12 -2
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
- package/types/nanahoshi-mona-ui-button.d.ts +12 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
- package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-command.d.ts +253 -0
- package/types/nanahoshi-mona-ui-common.d.ts +17 -1
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
- package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
- package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
- package/types/nanahoshi-mona-ui-label.d.ts +1 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
- package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
- package/types/nanahoshi-mona-ui-list.d.ts +1 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
- package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
- package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
- package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
- package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
- package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
- package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
- package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
- package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
- package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
- package/types/nanahoshi-mona-ui-window.d.ts +66 -1
package/docs/input.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Input
|
|
2
|
+
|
|
3
|
+
> Styles a native input element and keeps its browser behavior.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/text-box`
|
|
6
|
+
|
|
7
|
+
**Selector:** `input[monaTextBox]`
|
|
8
|
+
|
|
9
|
+
`TextBoxDirective` applies Mona UI input styles to a native `<input>` element, preserving all native browser behavior, form semantics, and keyboard interaction.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`TextBoxDirective` styles a native `<input>` element using Mona UI theme tokens. Because it applies directly to the native element, all browser defaults — keyboard interaction, form submission, `type`, `required`, `disabled` — remain fully intact.
|
|
14
|
+
|
|
15
|
+
**Use `TextBoxDirective` when:**
|
|
16
|
+
|
|
17
|
+
- You need to compose the input inside your own `<label>` or form layout
|
|
18
|
+
- You are already providing a native `<input>` and need Mona UI styling without extra wrapper markup
|
|
19
|
+
- You need native input types beyond `text | email | password` (e.g., `number`, `date`, `file`)
|
|
20
|
+
- You need attributes available natively on `<input>` (`autocomplete`, `min`, `max`, `pattern`, etc.)
|
|
21
|
+
|
|
22
|
+
**Use `TextBoxComponent` (`mona-text-box`) instead when:**
|
|
23
|
+
|
|
24
|
+
- You want a ready-made wrapper with prefix/suffix templates or a clear button
|
|
25
|
+
- You need `disabled`, `readonly`, or `placeholder` managed through Angular inputs
|
|
26
|
+
- You prefer Angular forms integration with a managed `value` model
|
|
27
|
+
|
|
28
|
+
## Import & Quick Start
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Add `TextBoxDirective` to your standalone component's `imports` array.
|
|
35
|
+
|
|
36
|
+
**Minimal usage:**
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<label for="name">Name</label>
|
|
40
|
+
<input id="name" type="text" monaTextBox />
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Always pair `monaTextBox` with an accessible label — either a `<label for>`, or `aria-label` / `aria-labelledby` on the `<input>` itself. The directive does not add any label mechanism.
|
|
44
|
+
|
|
45
|
+
**With Angular forms:**
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<label for="email">Email</label>
|
|
49
|
+
<input id="email" type="email" monaTextBox [(ngModel)]="email" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
### Native input types
|
|
55
|
+
|
|
56
|
+
The directive keeps the native element, so any input type and native attribute such as `autocomplete`, `min` or `disabled` works as usual.
|
|
57
|
+
|
|
58
|
+
`types-example.component.ts`
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Component } from "@angular/core";
|
|
62
|
+
import { TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
|
|
63
|
+
|
|
64
|
+
@Component({
|
|
65
|
+
selector: "app-input-types-example",
|
|
66
|
+
imports: [TextBoxDirective],
|
|
67
|
+
templateUrl: "./types-example.component.html"
|
|
68
|
+
})
|
|
69
|
+
export class InputTypesExampleComponent {}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`types-example.component.html`
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<div class="grid max-w-sm gap-3">
|
|
76
|
+
<div class="flex flex-col gap-1">
|
|
77
|
+
<label class="text-sm font-medium" for="input-email">Email</label>
|
|
78
|
+
<input monaTextBox autocomplete="email" id="input-email" type="email" />
|
|
79
|
+
</div>
|
|
80
|
+
<div class="flex flex-col gap-1">
|
|
81
|
+
<label class="text-sm font-medium" for="input-guests">Guests</label>
|
|
82
|
+
<input monaTextBox id="input-guests" max="8" min="1" type="number" value="2" />
|
|
83
|
+
</div>
|
|
84
|
+
<div class="flex flex-col gap-1">
|
|
85
|
+
<label class="text-sm font-medium" for="input-arrival">Arrival</label>
|
|
86
|
+
<input monaTextBox id="input-arrival" type="date" />
|
|
87
|
+
</div>
|
|
88
|
+
<div class="flex flex-col gap-1">
|
|
89
|
+
<label class="text-sm font-medium" for="input-code">Discount code</label>
|
|
90
|
+
<input monaTextBox disabled id="input-code" type="text" value="SPRING25" />
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Sizes and rounding
|
|
96
|
+
|
|
97
|
+
Bind `size` with brackets, as in `[size]="'large'"`. A plain `size="large"` attribute also stays on the native `<input>`, where `size` means its width in characters.
|
|
98
|
+
|
|
99
|
+
`sizes-example.component.ts`
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { Component } from "@angular/core";
|
|
103
|
+
import { TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
|
|
104
|
+
|
|
105
|
+
@Component({
|
|
106
|
+
selector: "app-input-sizes-example",
|
|
107
|
+
imports: [TextBoxDirective],
|
|
108
|
+
templateUrl: "./sizes-example.component.html"
|
|
109
|
+
})
|
|
110
|
+
export class InputSizesExampleComponent {}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`sizes-example.component.html`
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<div class="flex max-w-sm flex-col gap-3">
|
|
117
|
+
<input monaTextBox aria-label="Small" placeholder="Small" type="text" [size]="'small'" />
|
|
118
|
+
<input monaTextBox aria-label="Medium" placeholder="Medium" type="text" />
|
|
119
|
+
<input monaTextBox aria-label="Large" placeholder="Large" type="text" [size]="'large'" />
|
|
120
|
+
<input monaTextBox aria-label="Fully rounded" placeholder="Fully rounded" type="text" [rounded]="'full'" />
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Appearance & Styling
|
|
125
|
+
|
|
126
|
+
### `rounded` presets
|
|
127
|
+
|
|
128
|
+
| `rounded` | Shape |
|
|
129
|
+
|-----------|------------------------------------------|
|
|
130
|
+
| `none` | No rounding |
|
|
131
|
+
| `small` | Slight rounding |
|
|
132
|
+
| `medium` | Moderate rounding (default) |
|
|
133
|
+
| `large` | Strong rounding |
|
|
134
|
+
| `full` | Pill shape; horizontal padding increased |
|
|
135
|
+
|
|
136
|
+
### `size` presets
|
|
137
|
+
|
|
138
|
+
| `size` | Height | Font size |
|
|
139
|
+
|----------|--------|-----------------|
|
|
140
|
+
| `small` | 32px | Extra-small |
|
|
141
|
+
| `medium` | 36px | Small (default) |
|
|
142
|
+
| `large` | 40px | Medium |
|
|
143
|
+
|
|
144
|
+
### Visual states
|
|
145
|
+
|
|
146
|
+
| State | Appearance |
|
|
147
|
+
|-----------------|--------------------------------------------------------------------------------------------|
|
|
148
|
+
| Default | Mona UI themed border and background |
|
|
149
|
+
| Focused | Focus ring visible for keyboard-initiated focus |
|
|
150
|
+
| Disabled | Reduced visual emphasis; pointer interaction removed. Use the native `disabled` attribute. |
|
|
151
|
+
| Invalid | Error-colored border when both `invalid` and `touched` are `true` |
|
|
152
|
+
|
|
153
|
+
### Custom classes
|
|
154
|
+
|
|
155
|
+
Use the `class` input to extend styles. Classes are merged predictably, so Tailwind utility conflicts resolve in favor of the consumer's classes:
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<input type="text" monaTextBox class="w-full" />
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Accessibility
|
|
162
|
+
|
|
163
|
+
The directive applies to a native `<input>` element, so browser keyboard interaction, tab order, and form semantics are preserved by default.
|
|
164
|
+
|
|
165
|
+
The directive does not add an accessible name. The consumer must provide one using one of the following:
|
|
166
|
+
|
|
167
|
+
- A `<label for="id">` element linked to the input via `id`
|
|
168
|
+
- An `aria-label` attribute directly on the `<input>` element
|
|
169
|
+
- An `aria-labelledby` attribute pointing to an external label element
|
|
170
|
+
|
|
171
|
+
The focus ring appears only for keyboard-initiated focus, matching browser `focus-visible` behavior.
|
|
172
|
+
|
|
173
|
+
## API
|
|
174
|
+
|
|
175
|
+
Everything below is imported from `@nanahoshi/mona-ui/text-box`.
|
|
176
|
+
|
|
177
|
+
### `TextBoxDirective`
|
|
178
|
+
|
|
179
|
+
**Selector:** `input[monaTextBox]`
|
|
180
|
+
|
|
181
|
+
#### Inputs
|
|
182
|
+
|
|
183
|
+
| Name | Type | Default | Description |
|
|
184
|
+
| --- | --- | --- | --- |
|
|
185
|
+
| `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
186
|
+
| `invalid` | `boolean` | `false` | Marks the input as invalid, triggering error border and ring styling. |
|
|
187
|
+
| `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Border-radius preset applied to the component. |
|
|
188
|
+
| `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the component's dimensions. |
|
|
189
|
+
| `touched` | `boolean` | `false` | Marks the input as touched. Error styling is only shown when both `invalid` and `touched` are `true`. |
|
|
190
|
+
|
|
191
|
+
### Types
|
|
192
|
+
|
|
193
|
+
#### `InputType`
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
type InputType = "email" | "password" | "search" | "tel" | "text" | "url";
|
|
197
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
> Install the package, set up its styles and choose a theme.
|
|
4
|
+
|
|
5
|
+
To install Mona UI, run the following command in your terminal:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nanahoshi/mona-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Mona UI is styled with Tailwind CSS 4, so the application needs it too. See [Tailwind's Angular guide](https://tailwindcss.com/docs/installation/framework-guides/angular) if it isn't set up yet.
|
|
12
|
+
|
|
13
|
+
## Set Up Styles
|
|
14
|
+
|
|
15
|
+
In your main stylesheet, import the package's styles after Tailwind:
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
@import "tailwindcss";
|
|
19
|
+
@import "@nanahoshi/mona-ui/styles.css";
|
|
20
|
+
|
|
21
|
+
body {
|
|
22
|
+
background-color: var(--color-canvas);
|
|
23
|
+
color: var(--color-foreground);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That tells Tailwind to scan the package for the classes its components use, and declares the theme tokens those classes name. The `body` rule is yours to change, and it's there so the page follows the theme.
|
|
28
|
+
|
|
29
|
+
The rich text editor needs two more:
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
@import "remixicon/fonts/remixicon.css";
|
|
33
|
+
@plugin "@tailwindcss/typography";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Choose a Theme
|
|
37
|
+
|
|
38
|
+
Mona Light works with no further setup. To use another theme, follow the system's setting, remember a choice or add your own colors, see [Theming](theming.md).
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { provideThemeOptions } from "@nanahoshi/mona-ui/theme";
|
|
42
|
+
|
|
43
|
+
bootstrapApplication(AppComponent, {
|
|
44
|
+
providers: [provideThemeOptions({ initialTheme: { name: "mona", variant: "system" } })]
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Using an AI Coding Assistant
|
|
49
|
+
|
|
50
|
+
The documentation is also available as markdown, for coding agents. Point an agent at `/llms.txt`, which lists every page with a link to its markdown, or at `node_modules/@nanahoshi/mona-ui/llms.txt`, which matches the installed version.
|
|
51
|
+
|
|
52
|
+
## Build Forms
|
|
53
|
+
|
|
54
|
+
The form controls work with Angular's signal forms through `[formField]`. See [Forms](forms.md) for how to name them, and what each one supports.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
> What Mona UI is, what it includes and how it is built.
|
|
4
|
+
|
|
5
|
+
Welcome to **Mona UI**! A modern, high-performance, and accessible UI component library built for Angular and styled with Tailwind CSS.
|
|
6
|
+
|
|
7
|
+
## What is Mona UI?
|
|
8
|
+
|
|
9
|
+
**Mona UI** is a lightweight, responsive UI component library built from the ground up for modern Angular. It provides pixel-perfect, production-ready components designed to accelerate web development without sacrificing architectural flexibility, performance, or accessibility.
|
|
10
|
+
|
|
11
|
+
Unlike traditional component libraries that carry legacy patterns or bulky runtimes, Mona UI embraces Angular's modern reactivity model—leveraging Signals, Standalone Components, and fine-grained reactivity by default.
|
|
12
|
+
|
|
13
|
+
## Key Features
|
|
14
|
+
|
|
15
|
+
- **Signal-First Reactivity**: Built natively with Angular Signals (`input()`, `output()`, `model()`, and `computed()`) for fine-grained reactivity, predictable data flow, and optimal performance.
|
|
16
|
+
- **55+ Modular Components**: Comprehensive suite covering form controls, rich data presentation (Data Grid, Charts, TreeView), overlays (Dialog, Window, Popover, Sheet), navigation, and editors.
|
|
17
|
+
- **Accessible by Default**: Designed to adhere to WAI-ARIA authoring practices, featuring complete keyboard navigation, dynamic ARIA attributes, and zero axe violations.
|
|
18
|
+
- **Tailwind CSS & Semantic Tokens**: Styled with Tailwind CSS v4 and structured around semantic design tokens for effortless light, dark, and brand theming.
|
|
19
|
+
- **Comprehensive i18n & RTL**: Zero-configuration English defaults with typed runtime locale switching and native right-to-left (RTL) layout support using CSS Logical Properties.
|
|
20
|
+
- **Strictly Typed**: Authored in strict TypeScript, providing comprehensive type inference and autocomplete for a seamless developer experience.
|
|
21
|
+
|
|
22
|
+
## Quick Example
|
|
23
|
+
|
|
24
|
+
Mona UI components integrate naturally into modern Angular standalone components:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { Component, signal } from "@angular/core";
|
|
28
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
29
|
+
|
|
30
|
+
@Component({
|
|
31
|
+
selector: "app-example",
|
|
32
|
+
imports: [ButtonDirective],
|
|
33
|
+
template: `
|
|
34
|
+
<button monaButton look="primary" (click)="count.update(c => c + 1)">
|
|
35
|
+
Clicked {{ count() }} times
|
|
36
|
+
</button>
|
|
37
|
+
`
|
|
38
|
+
})
|
|
39
|
+
export class ExampleComponent {
|
|
40
|
+
protected readonly count = signal(0);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Tech Stack
|
|
45
|
+
|
|
46
|
+
We keep our core dependencies lean and modern, built on the latest web and Angular standards:
|
package/docs/label.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
> Styled, accessible labels associated with form controls.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/label`
|
|
6
|
+
|
|
7
|
+
**Selectors:** `mona-label`, `label[monaLabel]`
|
|
8
|
+
|
|
9
|
+
`LabelComponent` and `LabelDirective` provide styled, accessible labels for individual form controls. Both support the native `for`/`id` association and a `[for]` binding to a control reference. `LabelComponent` also names a control you wrap in it.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`LabelComponent` renders a styled native `<label>` element with an optional caption and optional-field text, wrapping any projected control. `LabelDirective` applies the same typography and colors directly to a native `<label>` you write yourself, without managing its content.
|
|
14
|
+
|
|
15
|
+
### Out of scope
|
|
16
|
+
|
|
17
|
+
- Floating labels (`FloatingLabel`).
|
|
18
|
+
- Form-field containers, hint/help/validation/error-message components.
|
|
19
|
+
- Automatically reading a control's `required` state or rendering a required asterisk.
|
|
20
|
+
- Automatically generating IDs for controls, or naming custom components that don't support it.
|
|
21
|
+
|
|
22
|
+
A label that animates into a placeholder position is a separate feature that isn't implemented yet. `LabelComponent` and `LabelDirective` only render static, always-visible captions.
|
|
23
|
+
|
|
24
|
+
## Import & Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import {
|
|
28
|
+
LabelComponent,
|
|
29
|
+
LabelDirective,
|
|
30
|
+
type LabelTarget
|
|
31
|
+
} from "@nanahoshi/mona-ui/label";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### `LabelComponent` vs `LabelDirective`
|
|
35
|
+
|
|
36
|
+
Use `LabelComponent` (`mona-label`) when you want Mona UI's standard label layout, a caption placed above a projected control, and optional-field text:
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<mona-label text="Email address">
|
|
40
|
+
<mona-text-box [(value)]="email"></mona-text-box>
|
|
41
|
+
</mona-label>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use `LabelDirective` (`label[monaLabel]`) when you want a plain native `<label>` element with full control over its markup, styled with Mona UI typography and colors:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<label monaLabel [for]="textBox">Email address</label>
|
|
48
|
+
<mona-text-box #textBox></mona-text-box>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The directive is opt-in. It only activates on a `<label>` that carries the `monaLabel` attribute, so importing it never changes the behavior of ordinary native labels elsewhere in your app.
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
### Wrapping a control
|
|
56
|
+
|
|
57
|
+
Wrapping is the preferred way. The `text` input names the wrapped control, and a click on the caption reaches it.
|
|
58
|
+
|
|
59
|
+
`wrapping-example.component.ts`
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Component, signal } from "@angular/core";
|
|
63
|
+
import { LabelComponent } from "@nanahoshi/mona-ui/label";
|
|
64
|
+
import { SwitchComponent } from "@nanahoshi/mona-ui/switch";
|
|
65
|
+
import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
|
|
66
|
+
|
|
67
|
+
@Component({
|
|
68
|
+
selector: "app-label-wrapping-example",
|
|
69
|
+
imports: [LabelComponent, SwitchComponent, TextBoxComponent],
|
|
70
|
+
templateUrl: "./wrapping-example.component.html"
|
|
71
|
+
})
|
|
72
|
+
export class LabelWrappingExampleComponent {
|
|
73
|
+
protected readonly email = signal("");
|
|
74
|
+
protected readonly updates = signal(false);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`wrapping-example.component.html`
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<div class="flex max-w-sm flex-col items-start gap-3">
|
|
82
|
+
<mona-label class="w-full" text="Email address">
|
|
83
|
+
<mona-text-box type="email" [(value)]="email" />
|
|
84
|
+
</mona-label>
|
|
85
|
+
<mona-label text="Send me product updates">
|
|
86
|
+
<mona-switch [(checked)]="updates" />
|
|
87
|
+
</mona-label>
|
|
88
|
+
</div>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Pointing at a control
|
|
92
|
+
|
|
93
|
+
Use `for` when the label and the control can't be nested. A string `for` works for a native input with that `id`. For a component, bind `[for]` to a template reference. `label[monaLabel]` takes `for` the same way.
|
|
94
|
+
|
|
95
|
+
`for-example.component.ts`
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { Component, signal } from "@angular/core";
|
|
99
|
+
import { LabelComponent, LabelDirective } from "@nanahoshi/mona-ui/label";
|
|
100
|
+
import { SwitchComponent } from "@nanahoshi/mona-ui/switch";
|
|
101
|
+
import { TextBoxComponent, TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
|
|
102
|
+
|
|
103
|
+
@Component({
|
|
104
|
+
selector: "app-label-for-example",
|
|
105
|
+
imports: [LabelComponent, LabelDirective, SwitchComponent, TextBoxComponent, TextBoxDirective],
|
|
106
|
+
templateUrl: "./for-example.component.html"
|
|
107
|
+
})
|
|
108
|
+
export class LabelForExampleComponent {
|
|
109
|
+
protected readonly city = signal("");
|
|
110
|
+
protected readonly darkMode = signal(false);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`for-example.component.html`
|
|
115
|
+
|
|
116
|
+
```html
|
|
117
|
+
<div class="grid max-w-md grid-cols-[auto_1fr] items-center gap-x-4 gap-y-3">
|
|
118
|
+
<mona-label for="label-phone" text="Phone" />
|
|
119
|
+
<input monaTextBox autocomplete="tel" id="label-phone" type="tel" />
|
|
120
|
+
|
|
121
|
+
<mona-label text="City" [for]="cityBox" />
|
|
122
|
+
<mona-text-box #cityBox [(value)]="city" />
|
|
123
|
+
|
|
124
|
+
<label monaLabel [for]="darkModeSwitch">Dark mode</label>
|
|
125
|
+
<mona-switch #darkModeSwitch [(checked)]="darkMode" />
|
|
126
|
+
</div>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Optional fields
|
|
130
|
+
|
|
131
|
+
`optional` adds text after the caption. It reads "Optional" unless you set `optionalText`.
|
|
132
|
+
|
|
133
|
+
`optional-example.component.ts`
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { Component } from "@angular/core";
|
|
137
|
+
import { LabelComponent } from "@nanahoshi/mona-ui/label";
|
|
138
|
+
import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
|
|
139
|
+
|
|
140
|
+
@Component({
|
|
141
|
+
selector: "app-label-optional-example",
|
|
142
|
+
imports: [LabelComponent, TextBoxComponent],
|
|
143
|
+
templateUrl: "./optional-example.component.html"
|
|
144
|
+
})
|
|
145
|
+
export class LabelOptionalExampleComponent {}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`optional-example.component.html`
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<div class="flex max-w-sm flex-col gap-3">
|
|
152
|
+
<mona-label text="Full name">
|
|
153
|
+
<mona-text-box />
|
|
154
|
+
</mona-label>
|
|
155
|
+
<mona-label optional text="Company">
|
|
156
|
+
<mona-text-box />
|
|
157
|
+
</mona-label>
|
|
158
|
+
<mona-label optional optionalText="If different" text="Billing address">
|
|
159
|
+
<mona-text-box />
|
|
160
|
+
</mona-label>
|
|
161
|
+
</div>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Both APIs can indicate that a field is optional. `LabelComponent` renders this text automatically:
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<mona-label text="Company" optional>
|
|
168
|
+
<mona-text-box></mona-text-box>
|
|
169
|
+
</mona-label>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`LabelDirective` does not manage caption content, so write the optional text directly:
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<label monaLabel for="company">
|
|
176
|
+
Company
|
|
177
|
+
<span class="text-muted-foreground">(Optional)</span>
|
|
178
|
+
</label>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Appearance & Styling
|
|
182
|
+
|
|
183
|
+
Both the component and the directive expose a `class` input merged onto the rendered `<label>` via `tailwind-merge`, so consumer Tailwind classes can override the default typography:
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<mona-label text="Email" class="text-primary"></mona-label>
|
|
187
|
+
<label monaLabel class="text-primary">Email</label>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Behavior
|
|
191
|
+
|
|
192
|
+
- It never inserts or rewrites the label's content. Write the caption, and any optional-field text, directly inside the `<label>`.
|
|
193
|
+
|
|
194
|
+
### Association Modes
|
|
195
|
+
|
|
196
|
+
A `<label>` can be connected to a form control in three ways:
|
|
197
|
+
|
|
198
|
+
1. **Wrapping:** place the control inside `<mona-label>` and set `text`.
|
|
199
|
+
2. **`[for]` with a reference:** bind `for` to the control's template reference.
|
|
200
|
+
3. **`for` with a string:** pass the id of a native input.
|
|
201
|
+
|
|
202
|
+
What works depends on the control. See [which controls take what](#which-controls-take-what).
|
|
203
|
+
|
|
204
|
+
#### Wrapping
|
|
205
|
+
|
|
206
|
+
Place the control inside `<mona-label>` and set `text`. The control takes its name from that caption.
|
|
207
|
+
|
|
208
|
+
```html
|
|
209
|
+
<mona-label text="Notifications">
|
|
210
|
+
<mona-switch [(checked)]="enabled"></mona-switch>
|
|
211
|
+
</mona-label>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**`text` is required for a wrapped control to be named.** Only the `text` input can name it: text you project next to the control can't be referenced without pulling in the control's own content. A wrapped control with no `text` and no `for` stays unnamed, and `mona-label` warns in development. The one exception is a control with a native input, which the browser also names from the whole label. Set `text` there too. When `optional` is set, the optional text is part of the caption, so it's part of the name.
|
|
215
|
+
|
|
216
|
+
A click on the caption focuses or activates the control. A click on the control itself is left to the control.
|
|
217
|
+
|
|
218
|
+
`label[monaLabel]` has no wrapping contract, only `for`. A control with no native input inside it isn't named or activated.
|
|
219
|
+
|
|
220
|
+
#### `[for]` with a reference
|
|
221
|
+
|
|
222
|
+
Bind `for` to a template reference of the control. It works on `mona-label` and on `label[monaLabel]`.
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<mona-label text="Notifications" [for]="notifications"></mona-label>
|
|
226
|
+
<mona-switch #notifications [(checked)]="enabled"></mona-switch>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
```html
|
|
230
|
+
<label monaLabel [for]="notifications">Notifications</label>
|
|
231
|
+
<mona-switch #notifications [(checked)]="enabled"></mona-switch>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Controls that support it take their name from the label, and a click activates or focuses them. Any other target with a public `focus()` method, such as a native element, only receives focus on click. It isn't named, so give it its own `aria-label` or `aria-labelledby`.
|
|
235
|
+
|
|
236
|
+
#### `for` with a string
|
|
237
|
+
|
|
238
|
+
Pass a string to `for` and the same string as the `id` of a native input. The label reflects it as a real `for` attribute; the browser handles the name, focus and click activation.
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<mona-label text="Email" for="email"></mona-label>
|
|
242
|
+
<input id="email" monaTextBox />
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<label monaLabel for="email">Email</label>
|
|
247
|
+
<input id="email" monaTextBox />
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
You own the ID. For a component that renders its own native input, point `for` at its `inputId` input.
|
|
251
|
+
|
|
252
|
+
A string `for` can't work on a component's host element, because a host such as `mona-switch` isn't something a `<label>` can control. The control stays unnamed, and the label warns in development. Use `[for]="ref"` or `inputId` instead.
|
|
253
|
+
|
|
254
|
+
### Which controls take what
|
|
255
|
+
|
|
256
|
+
| Control | Wrapped, with `text` | `[for]="ref"` | `for="id"` |
|
|
257
|
+
|------------------------------------------------------------------------------------------------------------|---------------------------------------------------|-------------------------------|-------------------------------|
|
|
258
|
+
| Native inputs: `monaTextBox`, `monaTextArea`, your own `<input>` | Named by the browser. A click focuses. | Focus only, not named | Yes, on the `id` |
|
|
259
|
+
| `mona-text-box`, `mona-otp-input` | Named. A click focuses. | Named. A click focuses. | Yes, on `inputId` |
|
|
260
|
+
| `mona-check-box`, `mona-radio-button` | Don't wrap: they render their own `<label>` | Named. A click activates. | Yes, on `inputId` |
|
|
261
|
+
| `mona-switch` | Named. A click toggles. | Named. A click toggles. | No, warns in development |
|
|
262
|
+
| `mona-slider`, `mona-range-slider`, `mona-rating`, `mona-segmented`, `mona-radio-group`, `mona-button-group`, `mona-color-palette`, `mona-color-picker`, `mona-color-gradient` | Named. A click focuses. | Named. A click focuses. | No, warns in development |
|
|
263
|
+
| `mona-numeric-text-box`, `mona-decimal-text-box`, `mona-date-picker` | Named by the browser from the inner input. A click focuses. | Focus only, not named | Yes, on `inputId` |
|
|
264
|
+
| `mona-dropdown-list` | Not connected | Focus only, not named | No: it has no native input |
|
|
265
|
+
| Other controls | Not connected, unless they hold a native input | Focus only, not named | Only on a native input's `id` |
|
|
266
|
+
|
|
267
|
+
A control that is focus only with `[for]` still needs a name. Give it `aria-labelledby` pointing at the label's `id`, as the dropdown list examples do, or use `inputId` where the control has one:
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<label id="status-label" monaLabel [for]="statusList">Status</label>
|
|
271
|
+
<mona-dropdown-list #statusList aria-labelledby="status-label" [data]="statuses"></mona-dropdown-list>
|
|
272
|
+
|
|
273
|
+
<mona-label text="Quantity" for="quantity"></mona-label>
|
|
274
|
+
<mona-numeric-text-box inputId="quantity" [(value)]="quantity"></mona-numeric-text-box>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Checkbox and radio-button compatibility
|
|
278
|
+
|
|
279
|
+
Do not wrap `CheckBoxComponent` or `RadioButtonComponent` in `<mona-label>`, and do not apply `monaLabel` to their internal markup. Both components already render their own native `<label>` around their native input, and a `<label>` must not contain another `<label>` — nesting them produces invalid HTML. Use their built-in `label` input, or `[for]` from a label outside them:
|
|
280
|
+
|
|
281
|
+
```html
|
|
282
|
+
<mona-check-box label="Remember me"></mona-check-box>
|
|
283
|
+
|
|
284
|
+
<mona-radio-button label="Option A"></mona-radio-button>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Accessibility
|
|
288
|
+
|
|
289
|
+
- Both APIs render a real native `<label>` — no ARIA `role` is added, and none is needed.
|
|
290
|
+
- A wrapped control is named by the `text` input or its own `aria-label` or `aria-labelledby`. Text projected next to it can't name it, and `mona-label` warns in development if nothing else does.
|
|
291
|
+
- A reference in `for` names the control only if the control supports it. Other targets, such as a native element reference, `mona-dropdown-list`, `mona-numeric-text-box` or `mona-date-picker`, only receive focus on click, so give them their own `aria-label` or `aria-labelledby`, or point a string `for` at their `inputId` where they have one.
|
|
292
|
+
- `LabelComponent` never reads a projected control's `required` state and never renders a required asterisk — pair it with your own validation messaging if needed.
|
|
293
|
+
- Do not wrap `CheckBoxComponent` or `RadioButtonComponent` in `<mona-label>`; both already render their own native `<label>`, and nesting `<label>` elements is invalid HTML. Use their built-in `label` input, or `[for]="ref"` from outside.
|
|
294
|
+
|
|
295
|
+
## API
|
|
296
|
+
|
|
297
|
+
Everything below is imported from `@nanahoshi/mona-ui/label`.
|
|
298
|
+
|
|
299
|
+
### `LabelComponent`
|
|
300
|
+
|
|
301
|
+
**Selector:** `mona-label`
|
|
302
|
+
|
|
303
|
+
#### Inputs
|
|
304
|
+
|
|
305
|
+
| Name | Type | Default | Description |
|
|
306
|
+
| --- | --- | --- | --- |
|
|
307
|
+
| `class` | `string` | `""` | Additional CSS classes merged onto the rendered `<label>` element via `tailwind-merge`. |
|
|
308
|
+
| `for` | `LabelTarget` | `undefined` | Associates the label with a native control ID or a target that exposes a public `focus()` method. String values are reflected as the native `for` attribute. Object targets receive focus when the label is clicked. |
|
|
309
|
+
| `optional` | `boolean` | `false` | Whether to display optional-field text next to the caption. |
|
|
310
|
+
| `optionalText` | `string` | `""` | Text displayed when `optional` is enabled. |
|
|
311
|
+
| `text` | `string` | `""` | Visible label caption text. |
|
|
312
|
+
|
|
313
|
+
### `LabelDirective`
|
|
314
|
+
|
|
315
|
+
**Selector:** `label[monaLabel]`
|
|
316
|
+
|
|
317
|
+
#### Inputs
|
|
318
|
+
|
|
319
|
+
| Name | Type | Default | Description |
|
|
320
|
+
| --- | --- | --- | --- |
|
|
321
|
+
| `class` | `string` | `""` | Additional CSS classes merged onto the native label element via `tailwind-merge`. |
|
|
322
|
+
| `for` | `LabelTarget` | `undefined` | Associates the label with a native control ID or a target that exposes a public `focus()` method. String values are reflected as the native `for` attribute. Object targets receive focus when the label is clicked. |
|
|
323
|
+
|
|
324
|
+
### Types
|
|
325
|
+
|
|
326
|
+
#### `LabelFocusable`
|
|
327
|
+
|
|
328
|
+
**Methods**
|
|
329
|
+
|
|
330
|
+
| Signature | Description |
|
|
331
|
+
| --- | --- |
|
|
332
|
+
| `activateFromLabel(): void` | Runs instead of `focus()` on a click, for a control a native label would activate. |
|
|
333
|
+
| `focus(options?: FocusOptions): void` | Moves focus to the control. The label calls it on a click when the control has no `activateFromLabel`. |
|
|
334
|
+
| `setLabelledBy(id: string \| null): void` | Receives the id of the label's text, so the control can use it for `aria-labelledby`. |
|
|
335
|
+
|
|
336
|
+
#### `LabelTarget`
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
type LabelTarget = string | LabelFocusable | null | undefined;
|
|
340
|
+
```
|