@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.
Files changed (227) hide show
  1. package/README.md +2 -0
  2. package/command/package.json +4 -0
  3. package/docs/auto-complete.md +733 -0
  4. package/docs/avatar.md +220 -0
  5. package/docs/breadcrumb.md +320 -0
  6. package/docs/button-group.md +392 -0
  7. package/docs/button.md +256 -0
  8. package/docs/calendar.md +515 -0
  9. package/docs/card.md +292 -0
  10. package/docs/chart.md +4058 -0
  11. package/docs/checkbox.md +374 -0
  12. package/docs/chip.md +339 -0
  13. package/docs/circular-progress-bar.md +287 -0
  14. package/docs/collapsible.md +308 -0
  15. package/docs/color-gradient.md +336 -0
  16. package/docs/color-palette.md +317 -0
  17. package/docs/color-picker.md +387 -0
  18. package/docs/combo-box.md +764 -0
  19. package/docs/command.md +582 -0
  20. package/docs/contextmenu.md +530 -0
  21. package/docs/date-picker.md +251 -0
  22. package/docs/datetime-picker.md +284 -0
  23. package/docs/decimal-textbox.md +260 -0
  24. package/docs/dialog.md +822 -0
  25. package/docs/dropdown-button.md +507 -0
  26. package/docs/dropdown-list.md +779 -0
  27. package/docs/editor.md +374 -0
  28. package/docs/expansion-panel.md +348 -0
  29. package/docs/fieldset.md +217 -0
  30. package/docs/forms.md +162 -0
  31. package/docs/grid.md +2053 -0
  32. package/docs/input.md +197 -0
  33. package/docs/installation.md +54 -0
  34. package/docs/introduction.md +46 -0
  35. package/docs/label.md +340 -0
  36. package/docs/list-box.md +637 -0
  37. package/docs/list-view.md +584 -0
  38. package/docs/menubar.md +559 -0
  39. package/docs/multi-select.md +765 -0
  40. package/docs/notification.md +460 -0
  41. package/docs/numeric-textbox.md +301 -0
  42. package/docs/otp-input.md +539 -0
  43. package/docs/pager.md +513 -0
  44. package/docs/placeholder.md +176 -0
  45. package/docs/popover.md +423 -0
  46. package/docs/popup-menu.md +658 -0
  47. package/docs/popup.md +617 -0
  48. package/docs/progress-bar.md +368 -0
  49. package/docs/radio-button.md +451 -0
  50. package/docs/range-slider.md +367 -0
  51. package/docs/rating.md +518 -0
  52. package/docs/scroll-view.md +375 -0
  53. package/docs/segmented.md +434 -0
  54. package/docs/sheet.md +348 -0
  55. package/docs/sidebar.md +1126 -0
  56. package/docs/skeleton.md +181 -0
  57. package/docs/slider.md +423 -0
  58. package/docs/spinner.md +370 -0
  59. package/docs/split-button.md +522 -0
  60. package/docs/splitter.md +342 -0
  61. package/docs/stepper.md +539 -0
  62. package/docs/switch.md +340 -0
  63. package/docs/tabs.md +542 -0
  64. package/docs/textarea.md +196 -0
  65. package/docs/textbox.md +332 -0
  66. package/docs/theming.md +403 -0
  67. package/docs/time-picker.md +254 -0
  68. package/docs/tooltip-directive.md +340 -0
  69. package/docs/tooltip.md +321 -0
  70. package/docs/tree-view.md +1018 -0
  71. package/docs/window.md +663 -0
  72. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  73. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
  74. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +1 -1
  75. package/fesm2022/nanahoshi-mona-ui-button.mjs +14 -2
  76. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
  77. package/fesm2022/nanahoshi-mona-ui-chart.mjs +108 -22
  78. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
  79. package/fesm2022/nanahoshi-mona-ui-chip.mjs +1 -1
  80. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
  81. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
  82. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  83. package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
  84. package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
  85. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
  86. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
  87. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
  88. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
  89. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
  90. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
  91. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
  92. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
  93. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
  94. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
  95. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
  96. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
  97. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
  98. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
  99. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  100. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  101. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
  102. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
  103. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
  104. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
  105. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
  106. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
  107. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
  108. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
  109. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
  110. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
  111. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
  112. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
  113. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
  114. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
  115. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
  116. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
  117. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
  118. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
  119. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
  120. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
  121. package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
  122. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
  123. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
  124. package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
  125. package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
  126. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
  127. package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
  128. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
  129. package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
  130. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +7 -3
  131. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +2 -1
  132. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
  133. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
  134. package/fesm2022/nanahoshi-mona-ui-slider.mjs +8 -3
  135. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +10 -7
  136. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
  137. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
  138. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
  139. package/fesm2022/nanahoshi-mona-ui-theme.mjs +53 -21
  140. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
  141. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
  142. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
  143. package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
  144. package/i18n/catalogs/en-US.messages.json +10 -0
  145. package/internal/popup-menu/package.json +4 -0
  146. package/llms.txt +123 -0
  147. package/locales/ar-sa/ar-sa.messages.json +10 -0
  148. package/locales/de-de/de-de.messages.json +10 -0
  149. package/locales/es-es/es-es.messages.json +10 -0
  150. package/locales/fr-fr/fr-fr.messages.json +10 -0
  151. package/locales/id-id/id-id.messages.json +10 -0
  152. package/locales/it-it/it-it.messages.json +10 -0
  153. package/locales/ja-jp/ja-jp.messages.json +10 -0
  154. package/locales/ko-kr/ko-kr.messages.json +10 -0
  155. package/locales/pt-br/pt-br.messages.json +10 -0
  156. package/locales/ru-ru/ru-ru.messages.json +10 -0
  157. package/locales/tr-tr/tr-tr.messages.json +10 -0
  158. package/locales/zh-cn/zh-cn.messages.json +10 -0
  159. package/locales/zh-tw/zh-tw.messages.json +10 -0
  160. package/package.json +9 -1
  161. package/styles.css +12 -2
  162. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
  163. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
  164. package/types/nanahoshi-mona-ui-button.d.ts +12 -0
  165. package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
  166. package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
  167. package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
  168. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
  169. package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
  170. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
  171. package/types/nanahoshi-mona-ui-command.d.ts +253 -0
  172. package/types/nanahoshi-mona-ui-common.d.ts +17 -1
  173. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
  174. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
  175. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
  176. package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
  177. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
  178. package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
  179. package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
  180. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
  181. package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
  182. package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
  183. package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
  184. package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
  185. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
  186. package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
  187. package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
  188. package/types/nanahoshi-mona-ui-label.d.ts +1 -0
  189. package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
  190. package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
  191. package/types/nanahoshi-mona-ui-list.d.ts +1 -1
  192. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
  193. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
  194. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
  195. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
  196. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
  197. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
  198. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
  199. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
  200. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
  201. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
  202. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
  203. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
  204. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
  205. package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
  206. package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
  207. package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
  208. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
  209. package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
  210. package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
  211. package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
  212. package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
  213. package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
  214. package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
  215. package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
  216. package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
  217. package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
  218. package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
  219. package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
  220. package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
  221. package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
  222. package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
  223. package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
  224. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
  225. package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
  226. package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
  227. package/types/nanahoshi-mona-ui-window.d.ts +66 -1
@@ -0,0 +1,451 @@
1
+ # Radio Button
2
+
3
+ > Radio buttons and groups for choosing one option from several.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/radio-button`
6
+
7
+ **Component selectors:** `mona-radio-button` · `mona-radio-group`  ·  **Directive selector:** `input[type='radio'][monaRadioButton]`
8
+
9
+ `RadioButtonComponent` renders a fully styled radio button with a managed label and signal forms support. `RadioGroupComponent` holds one value for the radio buttons inside it. `RadioButtonDirective` applies the same visual style to a native `<input type="radio">` that consumers place and label themselves.
10
+
11
+ ## Overview
12
+
13
+ ### `RadioButtonComponent`
14
+
15
+ `RadioButtonComponent` renders a custom-styled radio button inside a managed `<label>` wrapper. It implements `FormValueControl` from `@angular/forms/signals`, and doesn't implement `ControlValueAccessor`. Bind it with `[formField]`, `[(value)]` or `[ngModel]`. To group radio buttons as one control, put them in a `mona-radio-group`.
16
+
17
+ It has two label modes:
18
+ - **`label` input** — text is passed as a string and rendered in a `<span>`.
19
+ - **Projected content** — any markup projected inside `<mona-radio-button>` is used when `label` is empty.
20
+
21
+ When both are absent the radio button has no accessible name, and nothing warns about it. Provide `label`, projected content, `aria-label` or `aria-labelledby`.
22
+
23
+ **Use `RadioButtonComponent` when:**
24
+
25
+ - You need a self-contained control that handles label placement, disabled state, and form binding without any extra markup
26
+ - You want `before` / `after` label positioning or label-size variants without writing custom CSS
27
+
28
+ ### `RadioGroupComponent`
29
+
30
+ `RadioGroupComponent` (`mona-radio-group`) holds one value for the `mona-radio-button` elements inside it. It has role `radiogroup`, gives the radio buttons one `name`, and takes `[formField]`, so you don't repeat those on each radio button. Radio buttons outside a group work as before.
31
+
32
+ ### `RadioButtonDirective`
33
+
34
+ `RadioButtonDirective` applies Mona UI's radio button visual style to a native `<input type="radio">`. It does **not** manage a label — the consumer is responsible for label placement, form binding, and accessibility markup. It adds no ARIA role, because the native input already has role `radio`.
35
+
36
+ **Use `RadioButtonDirective` when:**
37
+
38
+ - You need full control over layout, label markup, or DOM structure
39
+ - You are integrating into an existing form where the `<input>` and `<label>` are already structured
40
+ - You want the Mona UI visual style without the component's label management
41
+
42
+ ### Choosing Between Component and Directive
43
+
44
+ | | `RadioButtonComponent` | `RadioButtonDirective` |
45
+ |-----------------|------------------------------------------|----------------------------------------|
46
+ | Selector | `mona-radio-button` | `input[type='radio'][monaRadioButton]` |
47
+ | Label managed | Yes (`label` input + content projection) | No — consumer provides `<label>` |
48
+ | Forms | `[formField]`, `[ngModel]`, `[(value)]` | Angular's native radio support |
49
+ | Read-only | `readonly` input | Not available |
50
+ | Label position | `labelPosition` input | Consumer controls layout |
51
+ | Label size | `labelSize` input | Consumer controls font |
52
+ | DOM control | Minimal | Full |
53
+ | Accessible name | Via `label` or projected content | Via explicit `<label>` element |
54
+
55
+ ## Import & Quick Start
56
+
57
+ ### Radio button
58
+
59
+ ```typescript
60
+ import { RadioButtonComponent } from "@nanahoshi/mona-ui/radio-button";
61
+ ```
62
+
63
+ **Minimal group with `ngModel`:**
64
+
65
+ ```html
66
+ <mona-radio-button name="size" radioValue="S" label="Small"
67
+ [ngModel]="selectedSize()" (ngModelChange)="selectedSize.set($event)">
68
+ </mona-radio-button>
69
+ <mona-radio-button name="size" radioValue="M" label="Medium"
70
+ [ngModel]="selectedSize()" (ngModelChange)="selectedSize.set($event)">
71
+ </mona-radio-button>
72
+ <mona-radio-button name="size" radioValue="L" label="Large"
73
+ [ngModel]="selectedSize()" (ngModelChange)="selectedSize.set($event)">
74
+ </mona-radio-button>
75
+ ```
76
+
77
+ **With signal forms (`FormField` directive):**
78
+
79
+ ```html
80
+ <mona-radio-button radioValue="S" label="Small" [formField]="sizeField">
81
+ </mona-radio-button>
82
+ <mona-radio-button radioValue="M" label="Medium" [formField]="sizeField">
83
+ </mona-radio-button>
84
+ <mona-radio-button radioValue="L" label="Large" [formField]="sizeField">
85
+ </mona-radio-button>
86
+ ```
87
+
88
+ **Projected label** (when the label requires custom markup):
89
+
90
+ ```html
91
+ <mona-radio-button name="theme" radioValue="dark"
92
+ [ngModel]="selectedTheme()" (ngModelChange)="selectedTheme.set($event)">
93
+ <span class="font-bold text-slate-900">Dark</span>
94
+ </mona-radio-button>
95
+ ```
96
+
97
+ **Label before the circle:**
98
+
99
+ ```html
100
+ <mona-radio-button name="plan" radioValue="pro" label="Pro" labelPosition="before">
101
+ </mona-radio-button>
102
+ ```
103
+
104
+ ### Radio group
105
+
106
+ ```typescript
107
+ import { RadioButtonComponent, RadioGroupComponent } from "@nanahoshi/mona-ui/radio-button";
108
+ ```
109
+
110
+ Put `[formField]` on the group. A radio button with `[formField]` inside a group isn't supported: the group's value wins.
111
+
112
+ ### Native input directive
113
+
114
+ ```typescript
115
+ import { RadioButtonDirective } from "@nanahoshi/mona-ui/radio-button";
116
+ ```
117
+
118
+ Pair each input with a `<label>` for accessibility. The `<label>` must either wrap the input or reference it via `for`/`id`.
119
+
120
+ **With border radius:**
121
+
122
+ ```html
123
+ <label class="flex items-center gap-2">
124
+ <input type="radio" monaRadioButton [rounded]="'medium'" name="shape" value="square" />
125
+ <span>Square</span>
126
+ </label>
127
+ ```
128
+
129
+ **Reactive Forms:**
130
+
131
+ ```html
132
+ <label class="flex items-center gap-2">
133
+ <input type="radio" monaRadioButton name="tier" value="pro" [formControl]="tierControl" />
134
+ <span>Pro</span>
135
+ </label>
136
+ ```
137
+
138
+ ## Examples
139
+
140
+ ### A radio group
141
+
142
+ The group gives its radio buttons one name and one value. A `mona-label` names it through `[for]`. A disabled radio button shows, but can't be chosen.
143
+
144
+ `group-example.component.ts`
145
+
146
+ ```typescript
147
+ import { Component, signal } from "@angular/core";
148
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
149
+ import { RadioButtonComponent, RadioGroupComponent } from "@nanahoshi/mona-ui/radio-button";
150
+
151
+ @Component({
152
+ selector: "app-radio-button-group-example",
153
+ imports: [LabelComponent, RadioButtonComponent, RadioGroupComponent],
154
+ templateUrl: "./group-example.component.html"
155
+ })
156
+ export class RadioButtonGroupExampleComponent {
157
+ protected readonly shipping = signal("standard");
158
+ }
159
+ ```
160
+
161
+ `group-example.component.html`
162
+
163
+ ```html
164
+ <div class="flex flex-col items-start gap-2">
165
+ <mona-label text="Shipping" [for]="shippingGroup" />
166
+ <mona-radio-group #shippingGroup [(value)]="shipping">
167
+ <mona-radio-button label="Standard, 5 to 7 days" radioValue="standard" />
168
+ <mona-radio-button label="Express, 2 days" radioValue="express" />
169
+ <mona-radio-button label="Same day" radioValue="same-day" [disabled]="true" />
170
+ </mona-radio-group>
171
+ <p class="text-sm">Chosen: {{ shipping() }}</p>
172
+ </div>
173
+ ```
174
+
175
+ ### Signal forms
176
+
177
+ Put `[formField]` on the group, not on its radio buttons. The signal forms `required` rule fails until one is chosen.
178
+
179
+ `forms-example.component.ts`
180
+
181
+ ```typescript
182
+ import { Component, signal } from "@angular/core";
183
+ import { form, FormField, required } from "@angular/forms/signals";
184
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
185
+ import { RadioButtonComponent, RadioGroupComponent } from "@nanahoshi/mona-ui/radio-button";
186
+
187
+ @Component({
188
+ selector: "app-radio-button-forms-example",
189
+ imports: [FormField, LabelComponent, RadioButtonComponent, RadioGroupComponent],
190
+ templateUrl: "./forms-example.component.html"
191
+ })
192
+ export class RadioButtonFormsExampleComponent {
193
+ readonly #model = signal({ plan: "" });
194
+ protected readonly order = form(this.#model, path => {
195
+ required(path.plan, { message: "Choose a plan." });
196
+ });
197
+ }
198
+ ```
199
+
200
+ `forms-example.component.html`
201
+
202
+ ```html
203
+ <div class="flex flex-col items-start gap-2">
204
+ <mona-label text="Plan" [for]="planGroup" />
205
+ <mona-radio-group #planGroup aria-describedby="radio-plan-error" [formField]="order.plan">
206
+ <mona-radio-button label="Free" radioValue="free" />
207
+ <mona-radio-button label="Team" radioValue="team" />
208
+ <mona-radio-button label="Enterprise" radioValue="enterprise" />
209
+ </mona-radio-group>
210
+ <p aria-live="polite" class="text-sm text-error" id="radio-plan-error">
211
+ @if (order.plan().touched()) {
212
+ @for (error of order.plan().errors(); track error.kind) {
213
+ {{ error.message }}
214
+ }
215
+ }
216
+ </p>
217
+ <p class="text-sm">Plan: {{ order.plan().value() || "none" }}</p>
218
+ </div>
219
+ ```
220
+
221
+ ### The directive
222
+
223
+ The directive styles a native `<input type="radio">`, and the consumer provides the label and the group's `name`.
224
+
225
+ `directive-example.component.ts`
226
+
227
+ ```typescript
228
+ import { Component, signal } from "@angular/core";
229
+ import { RadioButtonDirective } from "@nanahoshi/mona-ui/radio-button";
230
+
231
+ @Component({
232
+ selector: "app-radio-button-directive-example",
233
+ imports: [RadioButtonDirective],
234
+ templateUrl: "./directive-example.component.html"
235
+ })
236
+ export class RadioButtonDirectiveExampleComponent {
237
+ protected readonly directions = ["North", "East", "South", "West"];
238
+ protected readonly selected = signal("North");
239
+ }
240
+ ```
241
+
242
+ `directive-example.component.html`
243
+
244
+ ```html
245
+ <fieldset class="flex flex-col gap-2">
246
+ <legend class="mb-1 text-sm font-medium">Direction</legend>
247
+ @for (direction of directions; track direction) {
248
+ <label class="flex items-center gap-2 text-sm">
249
+ <input
250
+ monaRadioButton
251
+ name="radio-direction"
252
+ type="radio"
253
+ [checked]="direction === selected()"
254
+ [value]="direction"
255
+ (change)="selected.set(direction)" />
256
+ {{ direction }}
257
+ </label>
258
+ }
259
+ </fieldset>
260
+ <p class="mt-3 text-sm">Heading: {{ selected() }}</p>
261
+ ```
262
+
263
+ ## Appearance & Styling
264
+
265
+ ### Component variants
266
+
267
+ | Variant | Input | Options | Default |
268
+ |---------|-------|---------|---------|
269
+ | Border radius | `rounded` | `'full'` · `'large'` · `'medium'` · `'small'` · `'none'` | `'full'` |
270
+ | Label size | `labelSize` | `'small'` · `'medium'` · `'large'` | `'medium'` |
271
+ | Label side | `labelPosition` | `'after'` · `'before'` | `'after'` |
272
+
273
+ Pass additional Tailwind classes via the `class` attribute to style the `<label>` wrapper:
274
+
275
+ ```html
276
+ <mona-radio-button name="x" radioValue="1" label="Option" class="gap-3 p-2">
277
+ </mona-radio-button>
278
+ ```
279
+
280
+ ### Directive variants
281
+
282
+ | Variant | Input | Options | Default |
283
+ |---------------|-----------|----------------------------------------------------------|----------|
284
+ | Border radius | `rounded` | `'full'` · `'large'` · `'medium'` · `'small'` · `'none'` | `'full'` |
285
+
286
+ The directive applies styles directly to the `<input>` element's `class` attribute. Additional classes can be added directly to the `<input>` element.
287
+
288
+ **Form validation state:** Set `invalid` and `touched` on the directive (e.g. from a `FormControl`'s status) to apply the error styling and `aria-invalid`.
289
+
290
+ ## Behavior
291
+
292
+ ### Read-only
293
+
294
+ `readonly` keeps the radio button focusable and cancels the selection, so clicks and arrow keys restore the previously checked radio. It's shown with `data-readonly` only, because `aria-readonly` isn't allowed on role `radio`. A `mona-radio-group` sets `aria-readonly` on the group.
295
+
296
+ **Read-only:** the directive has no `readonly` input, and the HTML `readonly` attribute has no effect on a native radio button.
297
+
298
+ ### Radio groups
299
+
300
+ - **Name:** a group needs an accessible name from `aria-label`, `aria-labelledby` or a `mona-label`. It warns in development when it has none. Inside a `mona-label` with `text`, a click on the caption focuses the selected radio button, or the first enabled one.
301
+ - **Invalid:** `aria-invalid` is on the group, once `touched` and `invalid` are both `true`. The radio buttons only paint it.
302
+ - **Touched:** `touch` emits on selection and when focus leaves the group. Moving focus between its radio buttons doesn't count.
303
+ - **Disabled, read-only and required:** each applies to every radio button in the group. A radio button's own `disabled`, `readonly` and `required` still work next to it.
304
+ - **Read-only:** selection is canceled as on a single radio button, and the group gets `aria-readonly="true"`.
305
+
306
+ ## Forms Integration
307
+
308
+ `RadioButtonComponent` implements `FormValueControl`, not `ControlValueAccessor`. `[ngModel]` works because Angular binds it to the `value` model of a custom control. Each radio button holds the group's selected value in `value`, and `radioValue` identifies which one is selected when the two match.
309
+
310
+ ```typescript
311
+ protected readonly selectedSize = signal<string>("M");
312
+ ```
313
+
314
+ ```html
315
+ <mona-radio-button name="size" radioValue="S" label="S"
316
+ [ngModel]="selectedSize()" (ngModelChange)="selectedSize.set($event)">
317
+ </mona-radio-button>
318
+ <mona-radio-button name="size" radioValue="M" label="M"
319
+ [ngModel]="selectedSize()" (ngModelChange)="selectedSize.set($event)">
320
+ </mona-radio-button>
321
+ ```
322
+
323
+ With `[formField]`, `FormField` writes `value`, `disabled`, `invalid`, `name`, `readonly`, `required` and `touched`. Don't set those on the same element, because Angular rejects the template.
324
+
325
+ A `radioValue` that isn't a primitive is still compared and written through the model, but isn't passed to the native input's `value`. A radio button without a `radioValue` can't be selected.
326
+
327
+ ## Accessibility
328
+
329
+ `mona-radio-button` renders a native `<input type="radio">` inside its own `<label>`, so each radio button has the native `radio` role and takes its name from the label text or projected content. The `aria-label`, `aria-labelledby` and `aria-describedby` inputs are set on the native input, not the host. Outside a group, the input gets `aria-invalid="true"` once `touched` and `invalid` are both `true`.
330
+
331
+ `mona-radio-group` has role `radiogroup` and sets `aria-orientation` from `orientation` (`vertical` by default). It also sets `aria-label`, `aria-labelledby`, `aria-describedby`, and `aria-disabled`, `aria-invalid`, `aria-readonly` and `aria-required` when they apply.
332
+
333
+ `RadioButtonDirective` adds no role. It sets `aria-invalid` on the native input once `invalid` and `touched` are both `true`.
334
+
335
+ ### Keyboard
336
+
337
+ The keyboard is the browser's native radio behavior. Radio buttons that share a `name` are one Tab stop, the arrow keys move the selection between them, and `Space` selects the focused one. A `mona-radio-group` gives its radio buttons one `name`, so they behave this way without setting it on each one.
338
+
339
+ ### Consumer responsibilities
340
+
341
+ - Name each radio button with `label`, projected content, `aria-label` or `aria-labelledby`.
342
+ - Name a `mona-radio-group` with `aria-label`, `aria-labelledby` or a `mona-label`.
343
+ - With the directive, pair each input with a `<label>` and give the inputs of one group the same `name`.
344
+
345
+ ### Labels from outside
346
+
347
+ `RadioButtonComponent` renders its own `<label>`, so don't wrap it in `mona-label`. To label it from outside, bind a `mona-label` or `label[monaLabel]` to it with `[for]="ref"`, or point a `for` at its `inputId`. A click on such a label selects the radio button.
348
+
349
+ ## API
350
+
351
+ Everything below is imported from `@nanahoshi/mona-ui/radio-button`.
352
+
353
+ ### `RadioButtonComponent`
354
+
355
+ **Selector:** `mona-radio-button`
356
+ **Type parameters:** `T = unknown`
357
+ **Implements:** `FormValueControl<T>`
358
+
359
+ #### Inputs
360
+
361
+ | Name | Type | Default | Description |
362
+ | --- | --- | --- | --- |
363
+ | `aria-describedby` | `string` | `""` | Id of an element that describes the radio button, such as an error message. |
364
+ | `aria-label` | `string` | `""` | Accessible name of the radio button when it has no visible label. |
365
+ | `aria-labelledby` | `string` | `""` | Id of the element that labels the radio button. |
366
+ | `class` | `string` | `""` | Additional CSS classes merged onto the label container element via `tailwind-merge`. |
367
+ | `disabled` | `boolean` | `false` | Sets the disabled state of the radio button. |
368
+ | `inputId` | `string` | `generated` | Id of the native radio input. Point a `<label for>` at it to label the radio button from outside. A unique id is generated when it isn't set. |
369
+ | `invalid` | `boolean` | `false` | Marks the radio button as invalid. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
370
+ | `label` | `string` | `""` | Text label displayed alongside the radio button. When provided, takes precedence over projected content. When empty, projected content inside `<mona-radio-button>` is used. When both are absent, name the radio button with `aria-label` or `aria-labelledby`. |
371
+ | `labelPosition` | `"before" \| "after"` | `"after"` | Position of the label relative to the radio button circle. |
372
+ | `labelSize` | `"large" \| "medium" \| "small"` | `"medium"` | Font size applied to the label text. |
373
+ | `name` | `string` | `""` | HTML `name` attribute forwarded to the native input. Radio buttons that share the same `name` form a mutually exclusive group in the browser. |
374
+ | `radioValue` | `T` | `undefined` | The identity value of this radio button within a group. Compared against `value()` to determine whether this button is selected. When this button is chosen, its `radioValue` is written to the form as the new group value. A radio button without one can't be selected. |
375
+ | `readonly` | `boolean` | `false` | Prevents value changes while the control stays focusable and readable. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
376
+ | `required` | `boolean` | `false` | Marks the radio button as required, as the native `required` attribute. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
377
+ | `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"full"` | Sets the border radius of the radio button circle and indicator. |
378
+ | `touched` | `boolean` | `false` | Marks the radio button as touched. Error styling requires both `invalid` and `touched` to be `true`. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
379
+ | `value` (two-way) | `T` | `undefined` | The currently selected value of a group of radio buttons that aren't in a `mona-radio-group`. When bound to a signal form field via `[formField]`, the `FormField` directive keeps it in sync. |
380
+
381
+ #### Outputs
382
+
383
+ | Name | Type | Description |
384
+ | --- | --- | --- |
385
+ | `inputBlur` | `FocusEvent` | Emits when the input loses focus. |
386
+ | `inputClick` | `MouseEvent` | Emits when the input is clicked. |
387
+ | `inputFocus` | `FocusEvent` | Emits when the input receives focus. |
388
+ | `touch` | `void` | Emits when the radio button loses focus or is selected. |
389
+ | `valueChange` | `T` | Emitted when `value` changes. |
390
+
391
+ #### Methods
392
+
393
+ | Signature | Description |
394
+ | --- | --- |
395
+ | `focus(options?: FocusOptions): void` | Moves focus to the native radio input. |
396
+
397
+ ### `RadioGroupComponent`
398
+
399
+ **Selector:** `mona-radio-group`
400
+ **Type parameters:** `T = unknown`
401
+ **Implements:** `FormValueControl<T>`
402
+
403
+ #### Inputs
404
+
405
+ | Name | Type | Default | Description |
406
+ | --- | --- | --- | --- |
407
+ | `aria-describedby` | `string` | `""` | Id of an element that describes the group, such as an error message. |
408
+ | `aria-label` | `string` | `""` | Accessible name of the group. A group needs a name from this, `aria-labelledby` or a `mona-label`. |
409
+ | `aria-labelledby` | `string` | `""` | Id of the element that labels the group. |
410
+ | `class` | `string` | `""` | Additional CSS classes merged onto the group via `tailwind-merge`. |
411
+ | `disabled` | `boolean` | `false` | Disables every radio button in the group. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
412
+ | `invalid` | `boolean` | `false` | Marks the group as invalid. It shows once `touched` is also true. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
413
+ | `name` | `string` | `""` | The native `name` shared by the radio buttons in the group. A unique name is generated when it isn't set. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
414
+ | `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | The direction the radio buttons are laid out and announced in. |
415
+ | `readonly` | `boolean` | `false` | Prevents value changes while the radio buttons stay focusable and readable. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
416
+ | `required` | `boolean` | `false` | Marks the group as required. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
417
+ | `touched` | `boolean` | `false` | Marks the group as touched. Error styling needs both `invalid` and `touched`. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
418
+ | `value` (two-way) | `T` | `undefined` | The `radioValue` of the selected radio button. |
419
+
420
+ #### Outputs
421
+
422
+ | Name | Type | Description |
423
+ | --- | --- | --- |
424
+ | `touch` | `void` | Emits when a radio button is selected and when focus leaves the group. |
425
+ | `valueChange` | `T` | Emitted when `value` changes. |
426
+
427
+ #### Methods
428
+
429
+ | Signature | Description |
430
+ | --- | --- |
431
+ | `focus(options?: FocusOptions): void` | Moves focus to the selected radio button, or the first enabled one. |
432
+
433
+ ### `RadioButtonDirective`
434
+
435
+ **Selector:** `input[type='radio'][monaRadioButton]`
436
+
437
+ #### Inputs
438
+
439
+ | Name | Type | Default | Description |
440
+ | --- | --- | --- | --- |
441
+ | `invalid` | `boolean` | `false` | Marks the radio button as invalid, triggering error border and ring styling. |
442
+ | `rounded` | `RadioButtonDirectiveProps["rounded"]` | `"full"` | Sets the border radius of the radio button. |
443
+ | `touched` | `boolean` | `false` | Marks the radio button as touched. Error styling is only shown when both `invalid` and `touched` are `true`. |
444
+
445
+ ### Types
446
+
447
+ #### `RadioButtonDirectiveProps`
448
+
449
+ ```typescript
450
+ type RadioButtonDirectiveProps = VariantProps<typeof radioButtonDirectiveThemeVariants>;
451
+ ```