@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,196 @@
1
+ # Text Area
2
+
3
+ > Styles a native textarea element and keeps its browser behavior.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/text-area`
6
+
7
+ **Selector:** `textarea[monaTextArea]`
8
+
9
+ `TextAreaDirective` applies Mona UI styling to a native `<textarea>` element while preserving all native browser behavior — including resizing, keyboard access, and form submission.
10
+
11
+ ## Overview
12
+
13
+ Apply `monaTextArea` directly to a `<textarea>` element. The directive adds a consistent border, background, focus ring, and validation state visuals without wrapping the element or altering its native behavior.
14
+
15
+ Use `TextAreaDirective` when you need a styled multi-line input and want full control over the `<textarea>`'s attributes, dimensions, and form binding.
16
+
17
+ ## Import & Quick Start
18
+
19
+ ```typescript
20
+ import { TextAreaDirective } from "@nanahoshi/mona-ui/text-area";
21
+ ```
22
+
23
+ Add the imported symbol to your standalone component's `imports` array.
24
+
25
+ **Basic usage:**
26
+
27
+ ```html
28
+ <textarea monaTextArea rows="4" placeholder="Enter description..."></textarea>
29
+ ```
30
+
31
+ ## Examples
32
+
33
+ ### Labels and size
34
+
35
+ The directive doesn't constrain dimensions. Apply CSS or Tailwind utilities directly on the element. For a read-only text area, use the native `readonly` attribute, or the signal forms `readonly` rule with `[formField]`. The directive has no input for it. A read-only text area only changes its cursor. It looks otherwise the same, and stays focusable and selectable.
36
+
37
+ `basic-example.component.ts`
38
+
39
+ ```typescript
40
+ import { Component } from "@angular/core";
41
+ import { TextAreaDirective } from "@nanahoshi/mona-ui/text-area";
42
+
43
+ @Component({
44
+ selector: "app-textarea-basic-example",
45
+ imports: [TextAreaDirective],
46
+ templateUrl: "./basic-example.component.html"
47
+ })
48
+ export class TextareaBasicExampleComponent {
49
+ protected readonly terms = "Payment is due within 30 days of the invoice date.";
50
+ }
51
+ ```
52
+
53
+ `basic-example.component.html`
54
+
55
+ ```html
56
+ <div class="flex max-w-md flex-col gap-4">
57
+ <div class="flex flex-col gap-1">
58
+ <label class="text-sm font-medium" for="textarea-description">Description</label>
59
+ <textarea
60
+ monaTextArea
61
+ class="h-32 w-full resize-y"
62
+ id="textarea-description"
63
+ placeholder="What does this release change?"
64
+ rows="4"></textarea>
65
+ </div>
66
+ <div class="flex flex-col gap-1">
67
+ <label class="text-sm font-medium" for="textarea-terms">Terms</label>
68
+ <textarea monaTextArea class="w-full resize-none" id="textarea-terms" readonly rows="2" [value]="terms"></textarea>
69
+ </div>
70
+ </div>
71
+ ```
72
+
73
+ ### Signal forms
74
+
75
+ `TextAreaDirective` works with Angular signal forms. Bind `[formField]` to a signal form field, and the `FormField` directive writes `invalid` and `touched` into the directive.
76
+
77
+ `forms-example.component.ts`
78
+
79
+ ```typescript
80
+ import { Component, signal } from "@angular/core";
81
+ import { form, FormField, maxLength, required } from "@angular/forms/signals";
82
+ import { TextAreaDirective } from "@nanahoshi/mona-ui/text-area";
83
+
84
+ @Component({
85
+ selector: "app-textarea-forms-example",
86
+ imports: [FormField, TextAreaDirective],
87
+ templateUrl: "./forms-example.component.html"
88
+ })
89
+ export class TextareaFormsExampleComponent {
90
+ readonly #model = signal({ feedback: "" });
91
+ protected readonly maxFeedbackLength = 140;
92
+ protected readonly review = form(this.#model, path => {
93
+ required(path.feedback, { message: "Tell us what you think." });
94
+ maxLength(path.feedback, this.maxFeedbackLength, {
95
+ message: `Keep it to ${this.maxFeedbackLength} characters.`
96
+ });
97
+ });
98
+ }
99
+ ```
100
+
101
+ `forms-example.component.html`
102
+
103
+ ```html
104
+ <div class="flex max-w-md flex-col gap-1">
105
+ <label class="text-sm font-medium" for="textarea-feedback">Feedback</label>
106
+ <textarea
107
+ monaTextArea
108
+ aria-describedby="textarea-feedback-count textarea-feedback-error"
109
+ class="w-full"
110
+ id="textarea-feedback"
111
+ rows="4"
112
+ [formField]="review.feedback"></textarea>
113
+ <p class="text-sm" id="textarea-feedback-count">
114
+ {{ review.feedback().value().length }} of {{ maxFeedbackLength }} characters
115
+ </p>
116
+ <p aria-live="polite" class="text-sm text-error" id="textarea-feedback-error">
117
+ @if (review.feedback().touched()) {
118
+ @for (error of review.feedback().errors(); track error.kind) {
119
+ {{ error.message }}
120
+ }
121
+ }
122
+ </p>
123
+ </div>
124
+ ```
125
+
126
+ ## Appearance & Styling
127
+
128
+ ### `rounded` presets
129
+
130
+ | `rounded` | Shape |
131
+ |-----------|-----------------------------|
132
+ | `none` | No rounding |
133
+ | `small` | Slight rounding |
134
+ | `medium` | Moderate rounding (default) |
135
+ | `large` | Strong rounding |
136
+
137
+ ### Visual states
138
+
139
+ | State | Appearance |
140
+ |-----------|------------------------------------------------------|
141
+ | Default | Mona UI themed border and background |
142
+ | Focused | Focus border and ring |
143
+ | Disabled | Disabled colors; pointer interaction removed |
144
+ | Read-only | Default cursor, otherwise unchanged |
145
+ | Invalid | Error-colored border and ring |
146
+
147
+ The invalid state activates when both `invalid` and `touched` are `true`. When using `[formField]`, `FormField` writes these automatically. Without signal forms, set `invalid` and `touched` manually (e.g. from a `FormControl`'s status).
148
+
149
+ ### Custom classes
150
+
151
+ Pass additional CSS classes via the `class` attribute. Classes are merged using `tailwind-merge`:
152
+
153
+ ```html
154
+ <textarea monaTextArea class="w-full h-48 resize-y" rows="6"></textarea>
155
+ ```
156
+
157
+ ## Accessibility
158
+
159
+ The directive sets `aria-invalid="true"` on the host element when both `invalid` and `touched` are `true`.
160
+
161
+ The directive does not manage an accessible name. Associate a label using one of these patterns:
162
+
163
+ ```html
164
+ <label>
165
+ Notes
166
+ <textarea monaTextArea rows="4"></textarea>
167
+ </label>
168
+
169
+ <label for="notes-field">Notes</label>
170
+ <textarea id="notes-field" monaTextArea rows="4"></textarea>
171
+ ```
172
+
173
+ | Attribute | When present | Value |
174
+ |----------------|----------------------------------------------|----------|
175
+ | `aria-invalid` | When both `invalid` and `touched` are `true` | `"true"` |
176
+
177
+ **Consumer responsibilities:**
178
+
179
+ - Provide an accessible name via a `<label>` element (`for`/`id` association or wrapping), `aria-label`, or `aria-labelledby` on the `<textarea>`.
180
+
181
+ ## API
182
+
183
+ Everything below is imported from `@nanahoshi/mona-ui/text-area`.
184
+
185
+ ### `TextAreaDirective`
186
+
187
+ **Selector:** `textarea[monaTextArea]`
188
+
189
+ #### Inputs
190
+
191
+ | Name | Type | Default | Description |
192
+ | --- | --- | --- | --- |
193
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
194
+ | `invalid` | `boolean` | `false` | Marks the textarea as invalid, triggering error border and ring styling. |
195
+ | `rounded` | `"large" \| "medium" \| "none" \| "small"` | `"medium"` | Sets the border radius of the textarea. |
196
+ | `touched` | `boolean` | `false` | Marks the textarea as touched. Error styling is only shown when both `invalid` and `touched` are `true`. |
@@ -0,0 +1,332 @@
1
+ # Text Box
2
+
3
+ > A text input with prefix and suffix slots and an optional clear button.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/text-box`
6
+
7
+ **Selector:** `mona-text-box`
8
+
9
+ `TextBoxComponent` is a styled text input wrapper that provides optional prefix and suffix content slots, an optional clear button, signal forms integration via `[formField]`, and pass-through of arbitrary attributes to the inner `<input>`.
10
+
11
+ ## Overview
12
+
13
+ `TextBoxComponent` wraps a native `<input>` in a styled container element. It provides prefix and suffix content slots (for icons, unit labels, or embedded controls), an optional clear button, and a two-way bindable `value` model.
14
+
15
+ Choose `TextBoxComponent` over `TextBoxDirective` when you need:
16
+
17
+ - An optional clear button that resets the value
18
+ - Prefix or suffix content rendered inside the input boundary
19
+ - Signal forms integration via `[formField]`
20
+ - A `readonly` or `disabled` state managed through Angular inputs
21
+
22
+ For a plain styled `<input>` without a wrapper element, use `TextBoxDirective` (`input[monaTextBox]`) instead.
23
+
24
+ > **Forms.** `TextBoxComponent` implements `FormValueControl<string>` from `@angular/forms/signals`, so use `[formField]` with signal forms. It has no `ControlValueAccessor`, but `[(ngModel)]`, `[formControl]` and `formControlName` work too, because Angular binds a control's `value` and `touch` directly when it has no accessor.
25
+
26
+ ## Import & Quick Start
27
+
28
+ ```typescript
29
+ import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
30
+ // For template slots:
31
+ import { TextBoxPrefixTemplateDirective, TextBoxSuffixTemplateDirective } from "@nanahoshi/mona-ui/text-box";
32
+ ```
33
+
34
+ Add the imported symbols to your standalone component's `imports` array.
35
+
36
+ **Basic usage:**
37
+
38
+ ```html
39
+ <mona-text-box placeholder="Search..."></mona-text-box>
40
+ ```
41
+
42
+ **With required validation (standalone):**
43
+
44
+ ```html
45
+ <mona-text-box [(value)]="name" [required]="true" [touched]="wasTouched"></mona-text-box>
46
+ ```
47
+
48
+ The invalid state activates when `required` is `true`, the value is empty, and `touched` is `true`.
49
+
50
+ ## Examples
51
+
52
+ ### Prefix and suffix
53
+
54
+ Put `ng-template` slots inside the component. A prefix renders at the start of the input boundary, and a suffix at the end, after the optional clear button. Multiple prefix and suffix templates render in source order.
55
+
56
+ `slots-example.component.ts`
57
+
58
+ ```typescript
59
+ import { Component, signal } from "@angular/core";
60
+ import { LucideSearch } from "@lucide/angular";
61
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
62
+ import {
63
+ TextBoxComponent,
64
+ TextBoxPrefixTemplateDirective,
65
+ TextBoxSuffixTemplateDirective
66
+ } from "@nanahoshi/mona-ui/text-box";
67
+
68
+ @Component({
69
+ selector: "app-textbox-slots-example",
70
+ imports: [LabelComponent, LucideSearch, TextBoxComponent, TextBoxPrefixTemplateDirective, TextBoxSuffixTemplateDirective],
71
+ templateUrl: "./slots-example.component.html"
72
+ })
73
+ export class TextboxSlotsExampleComponent {
74
+ protected readonly query = signal("");
75
+ protected readonly username = signal("ada");
76
+ }
77
+ ```
78
+
79
+ `slots-example.component.html`
80
+
81
+ ```html
82
+ <div class="flex max-w-sm flex-col gap-3">
83
+ <mona-label text="Search products">
84
+ <mona-text-box placeholder="Name or SKU" type="search" [(value)]="query">
85
+ <ng-template monaTextBoxPrefixTemplate>
86
+ <svg lucideSearch aria-hidden="true" class="ps-1" [size]="16"></svg>
87
+ </ng-template>
88
+ </mona-text-box>
89
+ </mona-label>
90
+ <mona-label text="Email">
91
+ <mona-text-box [(value)]="username">
92
+ <ng-template monaTextBoxSuffixTemplate>
93
+ <span class="pe-2 text-sm">&#64;example.com</span>
94
+ </ng-template>
95
+ </mona-text-box>
96
+ </mona-label>
97
+ </div>
98
+ ```
99
+
100
+ ### Clear button
101
+
102
+ `clear-button-example.component.ts`
103
+
104
+ ```typescript
105
+ import { Component, signal } from "@angular/core";
106
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
107
+ import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
108
+
109
+ @Component({
110
+ selector: "app-textbox-clear-button-example",
111
+ imports: [LabelComponent, TextBoxComponent],
112
+ templateUrl: "./clear-button-example.component.html"
113
+ })
114
+ export class TextboxClearButtonExampleComponent {
115
+ protected readonly city = signal("Lisbon");
116
+ }
117
+ ```
118
+
119
+ `clear-button-example.component.html`
120
+
121
+ ```html
122
+ <div class="flex max-w-sm flex-col gap-2">
123
+ <mona-label text="City" [for]="cityBox" />
124
+ <mona-text-box #cityBox placeholder="Where to?" [clearButton]="true" [(value)]="city" />
125
+ <p class="text-sm">Value: "{{ city() }}"</p>
126
+ </div>
127
+ ```
128
+
129
+ ### Signal forms
130
+
131
+ `TextBoxComponent` implements `FormValueControl<string>` and connects to a signal form field via `[formField]`. The `FormField` directive writes `value`, `invalid`, `touched`, `disabled`, `readonly`, and `required` into the component.
132
+
133
+ `forms-example.component.ts`
134
+
135
+ ```typescript
136
+ import { Component, signal } from "@angular/core";
137
+ import { email, form, FormField, required } from "@angular/forms/signals";
138
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
139
+ import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
140
+
141
+ @Component({
142
+ selector: "app-textbox-forms-example",
143
+ imports: [FormField, LabelComponent, TextBoxComponent],
144
+ templateUrl: "./forms-example.component.html"
145
+ })
146
+ export class TextboxFormsExampleComponent {
147
+ readonly #model = signal({ email: "", name: "" });
148
+ protected readonly contact = form(this.#model, path => {
149
+ required(path.name, { message: "Enter your name." });
150
+ required(path.email, { message: "Enter your email address." });
151
+ email(path.email, { message: "Enter an email address like name@example.com." });
152
+ });
153
+ }
154
+ ```
155
+
156
+ `forms-example.component.html`
157
+
158
+ ```html
159
+ <div class="flex max-w-sm flex-col gap-3">
160
+ <mona-label text="Name">
161
+ <mona-text-box aria-describedby="textbox-name-error" [formField]="contact.name" />
162
+ </mona-label>
163
+ <p aria-live="polite" class="text-sm text-error" id="textbox-name-error">
164
+ @if (contact.name().touched()) {
165
+ @for (error of contact.name().errors(); track error.kind) {
166
+ {{ error.message }}
167
+ }
168
+ }
169
+ </p>
170
+ <mona-label text="Email">
171
+ <mona-text-box aria-describedby="textbox-email-error" type="email" [formField]="contact.email" />
172
+ </mona-label>
173
+ <p aria-live="polite" class="text-sm text-error" id="textbox-email-error">
174
+ @if (contact.email().touched()) {
175
+ @for (error of contact.email().errors(); track error.kind) {
176
+ {{ error.message }}
177
+ }
178
+ }
179
+ </p>
180
+ </div>
181
+ ```
182
+
183
+ ## Appearance & Styling
184
+
185
+ ### `rounded` presets
186
+
187
+ | `rounded` | Shape |
188
+ |-----------|------------------------------------------|
189
+ | `none` | No rounding |
190
+ | `small` | Slight rounding |
191
+ | `medium` | Moderate rounding (default) |
192
+ | `large` | Strong rounding |
193
+ | `full` | Pill shape; horizontal padding increased |
194
+
195
+ ### `size` presets
196
+
197
+ | `size` | Height | Font size |
198
+ |----------|--------|-----------------|
199
+ | `small` | 32px | Extra-small |
200
+ | `medium` | 36px | Small (default) |
201
+ | `large` | 40px | Medium |
202
+
203
+ ### Visual states
204
+
205
+ | State | Appearance |
206
+ |----------|---------------------------------------------------------------------------|
207
+ | Default | Mona UI themed border and background |
208
+ | Focused | Visible focus ring using the primary color |
209
+ | Disabled | Reduced visual emphasis; pointer interaction removed |
210
+ | Readonly | Value not editable; visual state preserved; inner input remains focusable |
211
+ | Invalid | Error-colored border and ring when the text box is in an invalid state |
212
+
213
+ The invalid state activates when `required` is `true` and the value is empty and `touched` is `true`, or when `invalid` is set to `true` directly (e.g., by the signal forms `FormField` directive).
214
+
215
+ ### Custom classes
216
+
217
+ Use `class` to extend the outer container, `inputClass` to target only the inner `<input>`, and `inputStyle` for inline styles on the inner `<input>`:
218
+
219
+ ```html
220
+ <mona-text-box class="w-full" [inputClass]="'text-right'" [inputStyle]="{ fontFamily: 'monospace' }">
221
+ </mona-text-box>
222
+ ```
223
+
224
+ ## Accessibility
225
+
226
+ `TextBoxComponent` sets `aria-invalid="true"` on the inner `<input>` when the text box is in an invalid state.
227
+
228
+ Name the text box with `aria-label` or `aria-labelledby` on `mona-text-box`. Both go to the inner `<input>`, and the host keeps neither. The placeholder is not a name.
229
+
230
+ ```html
231
+ <mona-text-box aria-label="Search products"></mona-text-box>
232
+ ```
233
+
234
+ Or point a label at the inner input through `inputId`:
235
+
236
+ ```html
237
+ <label for="search">Search products</label>
238
+ <mona-text-box inputId="search"></mona-text-box>
239
+ ```
240
+
241
+ | Attribute | When present | Value |
242
+ |----------------|---------------------------------------|----------|
243
+ | `aria-invalid` | When the text box is in invalid state | `"true"` |
244
+
245
+ **Consumer responsibilities:**
246
+
247
+ - Provide an accessible name: `aria-label`, `aria-labelledby`, or a `<label for>` that matches `inputId`.
248
+
249
+ ## API
250
+
251
+ Everything below is imported from `@nanahoshi/mona-ui/text-box`.
252
+
253
+ ### `TextBoxComponent`
254
+
255
+ **Selector:** `mona-text-box`
256
+ **Implements:** `FormValueControl<string>`
257
+
258
+ #### Inputs
259
+
260
+ | Name | Type | Default | Description |
261
+ | --- | --- | --- | --- |
262
+ | `aria-describedby` | `string` | `""` | Id of an element that describes the inner input, such as a hint or an error message. |
263
+ | `aria-label` | `string` | `""` | Accessible name of the inner input. Prefer a visible label, linked through `inputId` or `aria-labelledby`; the placeholder is not a label. |
264
+ | `aria-labelledby` | `string` | `""` | Id of the element that labels the inner input. |
265
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
266
+ | `clearButton` | `boolean` | `false` | Displays a clear button that resets the value to empty. The button is hidden while the value is empty or the text box is disabled or read-only. |
267
+ | `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. |
268
+ | `inputAttributes` | `AttributeConfig` | `{}` | Additional HTML attributes applied directly to the inner `<input>` element. |
269
+ | `inputClass` | `string \| string[]` | `""` | Additional CSS classes applied to the inner `<input>` element. |
270
+ | `inputId` | `string` | `generated` | Id of the inner `<input>` element. Point a `<label for>` or `<mona-label for>` at it to label the text box. A unique id is generated when it isn't set. |
271
+ | `inputStyle` | `string \| Partial<CSSStyleDeclaration> \| null` | `null` | Inline styles applied to the inner `<input>` element. Accepts a style string or a `CSSStyleDeclaration` partial. |
272
+ | `invalid` | `boolean` | `false` | Marks the text box as invalid. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
273
+ | `maxLength` | `number \| undefined` | `undefined` | Maximum number of characters, set as `maxlength` on the inner input. When bound to a signal form field via `[formField]`, this is written from the field's `maxLength` rule. |
274
+ | `minLength` | `number \| undefined` | `undefined` | Minimum number of characters, set as `minlength` on the inner input. When bound to a signal form field via `[formField]`, this is written from the field's `minLength` rule. |
275
+ | `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. |
276
+ | `placeholder` | `string` | `""` | Placeholder text shown when no value has been entered. |
277
+ | `readonly` | `boolean` | `false` | Prevents value changes while preserving the component's visual state. |
278
+ | `required` | `boolean` | `false` | Marks the text box as required. Triggers the invalid state when the value is empty and the field has been touched. |
279
+ | `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Border-radius preset applied to the component. |
280
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the component's dimensions. |
281
+ | `touched` | `boolean` | `false` | Sets the touched state of the text box. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
282
+ | `type` | `InputType` | `"text"` | Sets the `type` attribute of the inner `<input>` element. |
283
+ | `value` (two-way) | `string` | `""` | Two-way bindable current value of the text box. |
284
+
285
+ #### Outputs
286
+
287
+ | Name | Type | Description |
288
+ | --- | --- | --- |
289
+ | `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. |
290
+ | `inputFocus` | `FocusEvent` | Emitted when the inner input gains focus. |
291
+ | `touch` | `void` | Emitted when focus leaves the text box, including its clear button and prefix and suffix content. Form directives (`[formField]`, `ngModel`, `formControl`) listen to this to mark the field as touched. |
292
+ | `valueChange` | `string` | Emitted when `value` changes. |
293
+
294
+ #### Methods
295
+
296
+ | Signature | Description |
297
+ | --- | --- |
298
+ | `focus(options?: FocusOptions): void` | Focuses the inner input and places the caret after the value, so the end of a long value is in view. |
299
+
300
+ ### `TextBoxPrefixTemplateDirective`
301
+
302
+ Marks an `<ng-template>` as a prefix slot. The template is rendered inside the container's left side. Multiple prefix
303
+ templates are supported and render in source order.
304
+
305
+ **Selector:** `ng-template[monaTextBoxPrefixTemplate]`
306
+
307
+ ### `TextBoxSuffixTemplateDirective`
308
+
309
+ Marks an `<ng-template>` as a suffix slot. The template is rendered inside the container's right side, after the
310
+ optional clear button. Multiple suffix templates are supported and render in source order.
311
+
312
+ **Selector:** `ng-template[monaTextBoxSuffixTemplate]`
313
+
314
+ ### Types
315
+
316
+ #### `TEXT_BOX_DEFAULT_MESSAGES`
317
+
318
+ ```typescript
319
+ const TEXT_BOX_DEFAULT_MESSAGES: { clear: string; };
320
+ ```
321
+
322
+ #### `AttributeConfig`
323
+
324
+ From `@nanahoshi/mona-ui/common`.
325
+
326
+ HTML attributes by name, to apply to an element.
327
+
328
+ ```typescript
329
+ type AttributeConfig = Record<string, unknown>;
330
+ ```
331
+
332
+ **Documented elsewhere:** [`InputType`](input.md)