@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,539 @@
1
+ # OTP Input
2
+
3
+ > A segmented input for one-time passwords and verification codes.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/otp-input`
6
+
7
+ The Mona UI **OTP Input** (`mona-otp-input`) component provides a segmented, accessible interface for capturing one-time passwords, verification codes, PINs, and multi-factor authentication tokens.
8
+
9
+ Built on top of a single real native `<input>` element with styled visual presentation slots, the component delivers keyboard navigation, mobile keyboard optimization, one-time-code autofill, clipboard paste sanitization, and seamless integration with Angular Signal Forms.
10
+
11
+ ### Key Features
12
+
13
+ - **Single Accessible Control**: Implements accessible verification input semantics without fragmenting focus across multiple DOM inputs.
14
+ - **Multiple Input Types**: Supports numeric (`number`), alphanumeric (`text`), and masked (`password`) inputs.
15
+ - **Custom Character Patterns**: Allows regex character filtering for specialized token formats (e.g. hex tokens).
16
+ - **Flexible Grouping & Separators**: Supports uniform group counts, unequal grouping arrays, string separators, and projected separator templates.
17
+ - **Visual Styles**: Offers spaced (`spacing="true"`) or joined (`spacing="false"`) slot appearances with customizable sizes and corner rounding.
18
+ - **Angular Signal Forms**: Implements `FormValueControl<string>` for binding to signal form fields with automatic validation, disabled, readonly, and touched propagation.
19
+ - **Autofill & Mobile Ready**: Defaults to `autocomplete="one-time-code"` with numeric keypad hints on mobile devices.
20
+
21
+ ## Overview
22
+
23
+ The `OtpInputComponent` (`mona-otp-input`) is designed for entering fixed-length verification codes and one-time passwords.
24
+
25
+ ## Import & Quick Start
26
+
27
+ Import the component and optional separator directive from `@nanahoshi/mona-ui/otp-input`:
28
+
29
+ ```typescript
30
+ import {
31
+ OtpInputComponent,
32
+ OtpInputSeparatorTemplateDirective
33
+ } from "@nanahoshi/mona-ui/otp-input";
34
+ ```
35
+
36
+ Bind to a signal or model property using two-way `[(value)]`:
37
+
38
+ ```html
39
+ <mona-otp-input
40
+ type="number"
41
+ [length]="6"
42
+ [(value)]="verificationCode">
43
+ </mona-otp-input>
44
+ ```
45
+
46
+ ### Value Model
47
+
48
+ The `value` property is a contiguous string (e.g. `"123456"`).
49
+ - It never contains grouping separators or sentinel space characters.
50
+ - Leading zeroes (such as `"004219"`) are preserved and never coerced to numeric quantities.
51
+ - Its maximum length is bounded by the configured `length`.
52
+
53
+ ## Examples
54
+
55
+ ### Grouped slots
56
+
57
+ `groupLength` splits the slots into groups, and `separator` shows between them. The value never contains the separator.
58
+
59
+ `grouped-example.component.ts`
60
+
61
+ ```typescript
62
+ import { Component, signal } from "@angular/core";
63
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
64
+ import { OtpInputComponent } from "@nanahoshi/mona-ui/otp-input";
65
+
66
+ @Component({
67
+ selector: "app-otp-input-grouped-example",
68
+ imports: [LabelComponent, OtpInputComponent],
69
+ templateUrl: "./grouped-example.component.html"
70
+ })
71
+ export class OtpInputGroupedExampleComponent {
72
+ protected readonly code = signal("");
73
+ }
74
+ ```
75
+
76
+ `grouped-example.component.html`
77
+
78
+ ```html
79
+ <div class="flex flex-col items-start gap-2">
80
+ <mona-label text="Verification code">
81
+ <mona-otp-input separator="-" type="number" [groupLength]="3" [length]="6" [(value)]="code" />
82
+ </mona-label>
83
+ <span class="text-sm">Value: "{{ code() }}"</span>
84
+ </div>
85
+ ```
86
+
87
+ ### Masked PIN
88
+
89
+ `type="password"` shows each character as a bullet. Here `characterPattern` limits the PIN to digits.
90
+
91
+ `masked-example.component.ts`
92
+
93
+ ```typescript
94
+ import { Component, signal } from "@angular/core";
95
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
96
+ import { OtpInputComponent } from "@nanahoshi/mona-ui/otp-input";
97
+
98
+ @Component({
99
+ selector: "app-otp-input-masked-example",
100
+ imports: [LabelComponent, OtpInputComponent],
101
+ templateUrl: "./masked-example.component.html"
102
+ })
103
+ export class OtpInputMaskedExampleComponent {
104
+ protected readonly digit = /^[0-9]$/;
105
+ protected readonly pin = signal("");
106
+ }
107
+ ```
108
+
109
+ `masked-example.component.html`
110
+
111
+ ```html
112
+ <mona-label text="PIN">
113
+ <mona-otp-input placeholder="○" type="password" [characterPattern]="digit" [length]="4" [(value)]="pin" />
114
+ </mona-label>
115
+ ```
116
+
117
+ ### Verifying on completion
118
+
119
+ `complete` emits the code when the last slot is filled, so it can be checked without a submit button.
120
+
121
+ `complete-example.component.ts`
122
+
123
+ ```typescript
124
+ import { Component, signal } from "@angular/core";
125
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
126
+ import { OtpInputComponent } from "@nanahoshi/mona-ui/otp-input";
127
+
128
+ type VerificationStatus = "checking" | "idle" | "verified" | "wrong";
129
+
130
+ @Component({
131
+ selector: "app-otp-input-complete-example",
132
+ imports: [LabelComponent, OtpInputComponent],
133
+ templateUrl: "./complete-example.component.html"
134
+ })
135
+ export class OtpInputCompleteExampleComponent {
136
+ protected readonly code = signal("");
137
+ protected readonly status = signal<VerificationStatus>("idle");
138
+
139
+ /** Stands in for a server that accepts 123456. A wrong code is cleared, so typing the next one completes again. */
140
+ protected verify(code: string): void {
141
+ this.status.set("checking");
142
+ setTimeout(() => {
143
+ const verified = code === "123456";
144
+ this.status.set(verified ? "verified" : "wrong");
145
+ if (!verified) {
146
+ this.code.set("");
147
+ }
148
+ }, 800);
149
+ }
150
+ }
151
+ ```
152
+
153
+ `complete-example.component.html`
154
+
155
+ ```html
156
+ <div class="flex flex-col items-start gap-2">
157
+ <mona-label text="Code from your authenticator app">
158
+ <mona-otp-input
159
+ type="number"
160
+ [length]="6"
161
+ [readonly]="status() === 'checking'"
162
+ [(value)]="code"
163
+ (complete)="verify($event)" />
164
+ </mona-label>
165
+ <span aria-live="polite" class="text-sm">
166
+ @switch (status()) {
167
+ @case ("checking") { Checking… }
168
+ @case ("verified") { Verified. }
169
+ @case ("wrong") { That code is wrong. Try 123456. }
170
+ @default { Enter all six digits to verify. }
171
+ }
172
+ </span>
173
+ </div>
174
+ ```
175
+
176
+ ### Signal forms
177
+
178
+ `forms-example.component.ts`
179
+
180
+ ```typescript
181
+ import { Component, signal } from "@angular/core";
182
+ import { form, FormField, pattern, required } from "@angular/forms/signals";
183
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
184
+ import { OtpInputComponent } from "@nanahoshi/mona-ui/otp-input";
185
+
186
+ @Component({
187
+ selector: "app-otp-input-forms-example",
188
+ imports: [FormField, LabelComponent, OtpInputComponent],
189
+ templateUrl: "./forms-example.component.html"
190
+ })
191
+ export class OtpInputFormsExampleComponent {
192
+ readonly #model = signal({ code: "" });
193
+ protected readonly login = form(this.#model, path => {
194
+ required(path.code);
195
+ pattern(path.code, /^\d{6}$/);
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="Sign-in code">
205
+ <mona-otp-input aria-describedby="sign-in-code-error" type="number" [formField]="login.code" [length]="6" />
206
+ </mona-label>
207
+ <p id="sign-in-code-error" aria-live="polite" class="text-error text-sm">
208
+ @if (login.code().touched() && login.code().invalid()) {
209
+ Enter the six-digit code.
210
+ }
211
+ </p>
212
+ </div>
213
+ ```
214
+
215
+ ### Length
216
+
217
+ The `length` input sets the expected code length and determines the number of visual slots rendered:
218
+
219
+ ```html
220
+ <mona-otp-input [length]="4"></mona-otp-input>
221
+
222
+ <mona-otp-input [length]="6"></mona-otp-input>
223
+ ```
224
+
225
+ If `length` is reduced at runtime, any existing value is truncated to fit the new length.
226
+
227
+ ### Input Types
228
+
229
+ Three input types are supported:
230
+
231
+ #### 1. Numeric (`type="number"`)
232
+
233
+ Accepts digits `0-9` and requests a numeric virtual keyboard on mobile devices using `inputmode="numeric"`.
234
+
235
+ ```html
236
+ <mona-otp-input type="number" [length]="6"></mona-otp-input>
237
+ ```
238
+
239
+ #### 2. Alphanumeric (`type="text"`)
240
+
241
+ Accepts letters (`a-z`, `A-Z`) and digits (`0-9`), preserving input casing.
242
+
243
+ ```html
244
+ <mona-otp-input type="text" [length]="6"></mona-otp-input>
245
+ ```
246
+
247
+ #### 3. Password / Masked (`type="password"`)
248
+
249
+ Accepts alphanumeric characters while masking the visual presentation slots with a bullet glyph (`•`). The actual string value remains accessible in the underlying model. See [Masked PIN](#masked-pin).
250
+
251
+ #### Other digit forms
252
+
253
+ A character the rules reject is converted before it's rejected, so fullwidth digits and digits from other scripts, such as Eastern Arabic or Devanagari, count as the digits `0-9` they are. Conversion runs only for a rejected character, so a `characterPattern` can still accept the original.
254
+
255
+ ### Allowed Character Pattern (`characterPattern`)
256
+
257
+ Provide a `characterPattern` regular expression (`RegExp | null`) to customize per-character keystroke validation:
258
+
259
+ ```typescript
260
+ protected readonly hexadecimalCharacter = /^[A-F0-9]$/;
261
+ ```
262
+
263
+ ```html
264
+ <mona-otp-input
265
+ type="text"
266
+ [length]="6"
267
+ [characterPattern]="hexadecimalCharacter">
268
+ </mona-otp-input>
269
+ ```
270
+
271
+ `characterPattern` is evaluated against each individual candidate character and restricts which characters may be entered. When set, it replaces the rule that comes from `type`.
272
+
273
+ ### Placeholder
274
+
275
+ Display a placeholder character in unoccupied slots:
276
+
277
+ ```html
278
+ <mona-otp-input placeholder="○" [length]="6"></mona-otp-input>
279
+ ```
280
+
281
+ ### Grouping & Separators
282
+
283
+ Visual slots can be grouped into segments with string or template separators:
284
+
285
+ #### Uniform Grouping
286
+
287
+ A number in `groupLength` makes groups of that size, as in [Grouped slots](#grouped-slots).
288
+
289
+ #### Unequal Grouping Arrays
290
+
291
+ ```typescript
292
+ protected readonly customGroups = [2, 4];
293
+ ```
294
+
295
+ ```html
296
+ <mona-otp-input
297
+ [length]="6"
298
+ [groupLength]="customGroups"
299
+ separator="/">
300
+ </mona-otp-input>
301
+ ```
302
+
303
+ #### Custom Separator Template
304
+
305
+ Use the `monaOtpInputSeparatorTemplate` directive to render custom markup between groups:
306
+
307
+ ```html
308
+ <mona-otp-input [length]="6" [groupLength]="3">
309
+ <ng-template monaOtpInputSeparatorTemplate let-groupIndex="groupIndex">
310
+ <span class="px-1 text-muted-foreground font-bold">•</span>
311
+ </ng-template>
312
+ </mona-otp-input>
313
+ ```
314
+
315
+ ## Appearance & Styling
316
+
317
+ ### Size
318
+
319
+ Adjust slot dimensions with `size` (`"small"`, `"medium"`, `"large"`):
320
+
321
+ ```html
322
+ <mona-otp-input size="small"></mona-otp-input>
323
+ <mona-otp-input size="medium"></mona-otp-input>
324
+ <mona-otp-input size="large"></mona-otp-input>
325
+ ```
326
+
327
+ ### Rounded
328
+
329
+ Configure corner radius via `rounded` (`"none"`, `"small"`, `"medium"`, `"large"`, `"full"`):
330
+
331
+ ```html
332
+ <mona-otp-input rounded="full"></mona-otp-input>
333
+ ```
334
+
335
+ ### Slot classes
336
+
337
+ `slotClass` adds classes to each slot and `separatorClass` to each separator. The native input sits on top of the slots to take the pointer, so a hover style in `slotClass` doesn't apply.
338
+
339
+ ### Adjacent vs Spaced Slots
340
+
341
+ Set `[spacing]="false"` to join visual slots into a segmented appearance:
342
+
343
+ ```html
344
+ <mona-otp-input [spacing]="false" [length]="4" rounded="medium"></mona-otp-input>
345
+ ```
346
+
347
+ When joined, outer edges retain corner rounding while interior slot borders collapse cleanly without seams.
348
+
349
+ ## Behavior
350
+
351
+ ### State Properties
352
+
353
+ - `disabled`: Disables user input, focus, and pointer interaction while applying disabled theme styling.
354
+ - `readonly`: Keeps the control focusable and selectable while preventing modifications to the value, including paste. The caret isn't drawn in the slots.
355
+ - `required`: Marks the control as required. When incomplete and touched, the control enters the visual error state. Note that Angular Signal Forms `required()` enforces non-empty strings; if form-level validity requires an exact code length, use appropriate length validators in your form schema.
356
+ - `invalid`: Reports validation state. Visual error styling is displayed when the control is both `invalid` and `touched` (or `required` + `touched` + incomplete).
357
+ - `touched`: Indicates whether the control has been interacted with. Error styling is only displayed when touched.
358
+
359
+ ### Native Input Attributes (`inputAttributes`)
360
+
361
+ The `inputAttributes` input allows forwarding custom HTML attributes to the underlying native `<input>` element:
362
+
363
+ ```html
364
+ <mona-otp-input
365
+ [inputAttributes]="{
366
+ 'data-testid': 'otp-field',
367
+ 'aria-describedby': 'otp-help-text'
368
+ }">
369
+ </mona-otp-input>
370
+ ```
371
+
372
+ Use the `inputId` and `name` inputs for the id and name of the native input. An `id` or `name` in `inputAttributes` only applies while the matching input isn't set.
373
+
374
+ #### Attribute Categories
375
+
376
+ - **Protected structural & control attributes**: Attributes that control component mechanics and structure (`value`, `type`, `disabled`, `readonly`, `required`, `maxlength`, `aria-invalid`, `aria-required`, `aria-hidden`, `role`, `class`, `style`) cannot be overridden via `inputAttributes`. Comparison is case-insensitive.
377
+ - **Component-managed overrides**: `autocomplete`, `inputmode`, `aria-label`, and `aria-labelledby` can be passed in `inputAttributes` to override component defaults. If omitted in subsequent updates, component defaults are automatically restored.
378
+ - **Forwarded custom attributes**: Generic attributes such as `aria-describedby` and `data-*` are forwarded directly and cleanly removed from the DOM if omitted in subsequent updates.
379
+
380
+ ### Clipboard Paste & Autofill
381
+
382
+ - **Paste**: Pasted strings with delimiters or spaces (e.g. `"12-34-56"`) are sanitized before being inserted. Overlong values are bounded by `length`. A full code replaces what's there, wherever the caret is. A shorter one is inserted at the caret.
383
+ - **Autofill**: By default, `autocomplete="one-time-code"` is set on the native input, enabling mobile operating systems (iOS and Android) and browsers to suggest incoming SMS verification codes.
384
+ - **Multi-character input**: SMS autofill, replacement text, and virtual keyboard suggestions are supported without character-by-character blocking.
385
+
386
+ ### Completion
387
+
388
+ `complete` emits the code when user input fills the last slot.
389
+
390
+ It also emits when a paste or multi-character insertion puts a different full code over a complete one, so auto-submit sees the new code. Correcting a complete code one character at a time doesn't emit it, so auto-submit doesn't run on every correction. Pasting the same code again doesn't emit it either, and neither does setting `value` from code.
391
+
392
+ ### Programmatic Focus
393
+
394
+ Focus a specific slot index, pass standard browser `FocusOptions`, or focus the next unfilled slot using the component's `focus` method:
395
+
396
+ ```typescript
397
+ // Focus next incomplete slot
398
+ otpComponent.focus();
399
+
400
+ // Focus specific slot index
401
+ otpComponent.focus(2);
402
+
403
+ // Focus with browser FocusOptions
404
+ otpComponent.focus({ preventScroll: true });
405
+
406
+ // Blur input
407
+ otpComponent.blur();
408
+ ```
409
+
410
+ ### Right-to-Left (RTL) Layout
411
+
412
+ `OtpInputComponent` explicitly enforces `dir="ltr"` on its host element. When used inside an RTL page or container, the OTP token and slot sequence always maintain left-to-right ordering to eliminate ambiguity during verification code entry.
413
+
414
+ ### Security Notes
415
+
416
+ - OTP Input is a client-side entry interface. Verification tokens must always be validated securely on the server.
417
+ - Masked mode (`type="password"`) visually masks characters in the DOM, but does not encrypt the underlying Angular model value.
418
+ - Never log user-entered OTP codes in console logs or telemetry.
419
+
420
+ ## Forms Integration
421
+
422
+ `OtpInputComponent` implements `FormValueControl<string>`, enabling full integration with Angular Signal Forms, as in [Signal forms](#signal-forms).
423
+
424
+ The `FormField` directive automatically synchronizes value, disabled, name, readonly, required, invalid, and touched state. Don't set those on the same element, because Angular rejects the template. Signal Forms evaluates field-level `pattern(...)` validators over the complete string value and updates form field validity, while character filtering is configured separately via `characterPattern`.
425
+
426
+ `OtpInputComponent` doesn't implement `ControlValueAccessor`. `[(ngModel)]` binds to its `value` model through Angular's support for custom controls. Prefer `[formField]`.
427
+
428
+ ## Accessibility
429
+
430
+ - The component exposes **one accessible `<input>` control** to screen readers, preventing repetitive slot-by-slot field announcements.
431
+ - Presentation slots and separators are marked with `aria-hidden="true"`.
432
+ - Name the control with a `mona-label` with `text` around it, a `mona-label` or `label[monaLabel]` with `[for]="ref"`, a `for` pointing at `inputId`, the `aria-label` or `aria-labelledby` inputs, or the same attributes in `inputAttributes`.
433
+ - With none of those, it gets the generic localized name "Verification code". A native `<label>` is detected once, after the first render, so a label added later keeps the generic name until something else sets one.
434
+ - Decorative fake caret animation respects user reduced-motion preferences (`motion-reduce:animate-none`).
435
+
436
+ ## API
437
+
438
+ Everything below is imported from `@nanahoshi/mona-ui/otp-input`.
439
+
440
+ ### `OtpInputComponent`
441
+
442
+ **Selector:** `mona-otp-input`
443
+ **Implements:** `FormValueControl<string>`
444
+
445
+ #### Inputs
446
+
447
+ | Name | Type | Default | Description |
448
+ | --- | --- | --- | --- |
449
+ | `aria-describedby` | `string \| null` | `null` | Id of an element that describes the inner `<input>`, such as an error message. |
450
+ | `aria-label` | `string \| null` | `null` | Accessible name for the inner `<input>` element. A `<label>` or `mona-label` names it too, and the generic "Verification code" name only applies when there is neither. |
451
+ | `aria-labelledby` | `string \| null` | `null` | Id of the element that labels the inner `<input>`. |
452
+ | `characterPattern` | `RegExp \| null` | `null` | Regular expression used to determine whether each individual OTP character is allowed. |
453
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
454
+ | `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
455
+ | `groupLength` | `number \| number[] \| null` | `null` | Configures slot grouping lengths. Accepts a uniform number or an array of group sizes. |
456
+ | `inputAttributes` | `AttributeConfig` | `{}` | Additional HTML attributes applied directly to the inner `<input>` element. |
457
+ | `inputId` | `string` | `generated` | Id of the inner `<input>` element. Point a `<label for>` or `<mona-label for>` at it to label the control. A unique id is generated when it isn't set. |
458
+ | `invalid` | `boolean` | `false` | Marks the OTP input as invalid. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
459
+ | `length` | `number` | `4` | Sets the total number of characters accepted by the OTP input and the number of visual slots. |
460
+ | `name` | `string` | `""` | Name of the native input, used in native form submission and by browsers for autofill. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
461
+ | `placeholder` | `string` | `""` | Hint character displayed in empty visual slots. |
462
+ | `readonly` | `boolean` | `false` | Prevents value changes while preserving the component's focusability and visual state. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
463
+ | `required` | `boolean` | `false` | Marks the OTP input as required. Triggers invalid state when touched and incomplete. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
464
+ | `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Border-radius preset applied to the OTP slots. |
465
+ | `separator` | `string` | `""` | Text character or string displayed between visual slot groups. |
466
+ | `separatorClass` | `string \| string[]` | `""` | Additional CSS classes applied to separator elements. |
467
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the dimensions and font size of the OTP slots. |
468
+ | `slotClass` | `string \| string[]` | `""` | Additional CSS classes applied to each visual slot element. |
469
+ | `spacing` | `boolean` | `true` | Determines whether visual slots within a group have spacing between them or are joined together. |
470
+ | `tabindex` | `string \| number` | `0` | Tab index of the inner `<input>`. |
471
+ | `touched` | `boolean` | `false` | Sets the touched state of the OTP input. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
472
+ | `type` | `OtpInputType` | `"text"` | Sets the type of the OTP input ("text", "number", or "password"). |
473
+ | `value` (two-way) | `string` | `""` | Two-way bindable current value of the OTP input. |
474
+
475
+ #### Outputs
476
+
477
+ | Name | Type | Description |
478
+ | --- | --- | --- |
479
+ | `complete` | `string` | Emitted when a user interaction completes the verification code. Pasting a different full code over a complete one emits again, so auto-submit sees the new code. Correcting a complete code one character at a time doesn't. |
480
+ | `inputBlur` | `FocusEvent` | Emitted when the inner input loses focus. |
481
+ | `inputFocus` | `FocusEvent` | Emitted when the inner input gains focus. |
482
+ | `touch` | `void` | Emitted when the inner input loses focus. The `FormField` directive listens to this to mark the field as touched. |
483
+ | `valueChange` | `string` | Emitted when `value` changes. |
484
+
485
+ #### Methods
486
+
487
+ | Signature | Description |
488
+ | --- | --- |
489
+ | `blur(): void` | Removes focus from the input. |
490
+
491
+ ### `OtpInputSeparatorTemplateDirective`
492
+
493
+ **Selector:** `ng-template[monaOtpInputSeparatorTemplate]`
494
+
495
+ #### Template context
496
+
497
+ | Name | Type |
498
+ | --- | --- |
499
+ | `$implicit` | `number` |
500
+ | `groupIndex` | `number` |
501
+
502
+ ### Types
503
+
504
+ #### `OTP_INPUT_DEFAULT_MESSAGES`
505
+
506
+ ```typescript
507
+ const OTP_INPUT_DEFAULT_MESSAGES: MonaOtpInputMessages;
508
+ ```
509
+
510
+ #### `OtpInputSeparatorContext`
511
+
512
+ | Name | Type |
513
+ | --- | --- |
514
+ | `$implicit` | `number` |
515
+ | `groupIndex` | `number` |
516
+
517
+ #### `OtpInputType`
518
+
519
+ ```typescript
520
+ type OtpInputType = "text" | "number" | "password";
521
+ ```
522
+
523
+ #### `AttributeConfig`
524
+
525
+ From `@nanahoshi/mona-ui/common`.
526
+
527
+ HTML attributes by name, to apply to an element.
528
+
529
+ ```typescript
530
+ type AttributeConfig = Record<string, unknown>;
531
+ ```
532
+
533
+ #### `MonaOtpInputMessages`
534
+
535
+ From `@nanahoshi/mona-ui/i18n`.
536
+
537
+ | Name | Type |
538
+ | --- | --- |
539
+ | `verificationCode` (read-only) | `string` |