@nanahoshi/mona-ui 0.25.1 → 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 (222) 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.mjs +12 -0
  75. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
  76. package/fesm2022/nanahoshi-mona-ui-chart.mjs +86 -0
  77. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
  78. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
  79. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
  80. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  81. package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
  82. package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
  83. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
  84. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
  85. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
  86. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
  87. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
  88. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
  89. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
  90. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
  91. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
  92. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
  93. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
  94. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
  95. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
  96. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
  97. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  98. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  99. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
  100. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
  101. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
  102. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
  103. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
  104. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
  105. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
  106. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
  107. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
  108. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
  109. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
  110. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
  111. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
  112. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
  113. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
  114. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
  115. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
  116. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
  117. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
  118. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
  119. package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
  120. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
  121. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
  122. package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
  123. package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
  124. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
  125. package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
  126. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
  127. package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
  128. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
  129. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
  130. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
  131. package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
  132. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
  133. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
  134. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
  135. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
  136. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
  137. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
  138. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
  139. package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
  140. package/i18n/catalogs/en-US.messages.json +10 -0
  141. package/internal/popup-menu/package.json +4 -0
  142. package/llms.txt +123 -0
  143. package/locales/ar-sa/ar-sa.messages.json +10 -0
  144. package/locales/de-de/de-de.messages.json +10 -0
  145. package/locales/es-es/es-es.messages.json +10 -0
  146. package/locales/fr-fr/fr-fr.messages.json +10 -0
  147. package/locales/id-id/id-id.messages.json +10 -0
  148. package/locales/it-it/it-it.messages.json +10 -0
  149. package/locales/ja-jp/ja-jp.messages.json +10 -0
  150. package/locales/ko-kr/ko-kr.messages.json +10 -0
  151. package/locales/pt-br/pt-br.messages.json +10 -0
  152. package/locales/ru-ru/ru-ru.messages.json +10 -0
  153. package/locales/tr-tr/tr-tr.messages.json +10 -0
  154. package/locales/zh-cn/zh-cn.messages.json +10 -0
  155. package/locales/zh-tw/zh-tw.messages.json +10 -0
  156. package/package.json +9 -1
  157. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
  158. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
  159. package/types/nanahoshi-mona-ui-button.d.ts +12 -0
  160. package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
  161. package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
  162. package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
  163. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
  164. package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
  165. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
  166. package/types/nanahoshi-mona-ui-command.d.ts +253 -0
  167. package/types/nanahoshi-mona-ui-common.d.ts +17 -1
  168. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
  169. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
  170. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
  171. package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
  172. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
  173. package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
  174. package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
  175. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
  176. package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
  177. package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
  178. package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
  179. package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
  180. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
  181. package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
  182. package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
  183. package/types/nanahoshi-mona-ui-label.d.ts +1 -0
  184. package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
  185. package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
  186. package/types/nanahoshi-mona-ui-list.d.ts +1 -1
  187. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
  188. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
  189. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
  190. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
  191. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
  192. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
  193. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
  194. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
  195. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
  196. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
  197. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
  198. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
  199. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
  200. package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
  201. package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
  202. package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
  203. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
  204. package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
  205. package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
  206. package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
  207. package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
  208. package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
  209. package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
  210. package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
  211. package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
  212. package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
  213. package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
  214. package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
  215. package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
  216. package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
  217. package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
  218. package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
  219. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
  220. package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
  221. package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
  222. package/types/nanahoshi-mona-ui-window.d.ts +66 -1
@@ -0,0 +1,434 @@
1
+ # Segmented
2
+
3
+ > A compact set of mutually exclusive options.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/segmented`
6
+
7
+ **Selector:** `mona-segmented`
8
+
9
+ `SegmentedComponent` renders a compact set of mutually exclusive options as a native radio group. Exactly one option is selected at a time, and the control reports the selected value through a two-way `value` model.
10
+
11
+ Segmented controls are the right choice when a small set of options should share a single selection, for example `List | Grid` or `Day | Week | Month`. They are not a content-switching mechanism — use `TabsComponent` when each option reveals a separate content panel.
12
+
13
+ ## Overview
14
+
15
+ `SegmentedComponent` presents a small set of mutually exclusive options as a compact radio group and binds the consumer's selection through a two-way `value` model. It is a value-selection control, not a content-switching mechanism.
16
+
17
+ **Use Segmented when:**
18
+
19
+ - The user picks exactly one value from a small set, for example `List | Grid`, `Day | Week | Month`, or `Discover | My courses`.
20
+ - The choice changes the data displayed elsewhere, but each option does not own a separate content panel in the same widget.
21
+
22
+ **Prefer Tabs instead when:**
23
+
24
+ - Each option reveals its own content panel, for example `Account | Security | Notifications`. Use `TabsComponent` for that pattern — see [Segmented vs. Tabs](#segmented-vs-tabs).
25
+
26
+ ### Segmented vs. Tabs
27
+
28
+ | Concern | Segmented | Tabs |
29
+ |-------------------------|----------------------------------------------------------------------------|-------------------------------------------------------------------------------|
30
+ | Selection model | Exactly one value, bound via `[(value)]` | One active tab; panels switch automatically |
31
+ | Content | Options have no content; the value is read by the consumer | Each tab owns a content panel rendered inside `<mona-tabs>` |
32
+ | Semantic role | `radiogroup` with native radio inputs | `tablist` / `tab` / `tabpanel` pattern |
33
+ | Typical use | `List | Grid`, `Day | Week | Month`, `Discover | My courses` | `Account | Security | Notifications` |
34
+ | Routing | Not a routing mechanism | Not a routing mechanism |
35
+
36
+ Tabs convey "one of several content panels is active"; Segmented conveys "one of several values is selected."
37
+
38
+ ## Import & Quick Start
39
+
40
+ ```typescript
41
+ import { SegmentedComponent, SegmentedItemTemplateDirective } from "@nanahoshi/mona-ui/segmented";
42
+ import type { SegmentedOption } from "@nanahoshi/mona-ui/segmented";
43
+ ```
44
+
45
+ ```typescript
46
+ export type ViewMode = "list" | "grid";
47
+
48
+ protected readonly viewModes: SegmentedOption<ViewMode>[] = [
49
+ { label: "List", value: "list" },
50
+ { label: "Grid", value: "grid" }
51
+ ];
52
+
53
+ protected viewMode: ViewMode | null = "list";
54
+ ```
55
+
56
+ ```html
57
+ <mona-segmented
58
+ aria-label="View mode"
59
+ [options]="viewModes"
60
+ [(value)]="viewMode">
61
+ </mona-segmented>
62
+ ```
63
+
64
+ `options` is required and drives both the visible labels and the selected values. The component renders each option as a native radio input sharing one `name`, so exactly one option is selected at a time.
65
+
66
+ ### Two-way value binding
67
+
68
+ `value` is a two-way model. The consumer reads the current selection from it and writes to it to change the selection programmatically. When a programmatically supplied `value` matches no current option, no option is checked, and `value` stays as it is, so the application has to notice an option it removed.
69
+
70
+ To reject a choice, write the old value back after the current tick, for example once a confirmation resolves. A signal written and written back within one handler is the same value to Angular's binding, so the control never hears about it. Two options with the same `value` aren't supported; Angular warns about the duplicate `track` key in development.
71
+
72
+ ```html
73
+ <p>Current mode: {{ viewMode }}</p>
74
+ ```
75
+
76
+ ## Anatomy
77
+
78
+ ### Templates
79
+
80
+ Provide a `monaSegmentedItemTemplate` to replace the default label text with custom content, for example an icon paired with the label. `option.label` stays the radio's accessible name. Bind the options, as `[monaSegmentedItemTemplate]="viewModes"`, to type `let-option` from them.
81
+
82
+ | Directive | Overrides | Rendered when |
83
+ |------------------------------|---------------------------|-----------------|
84
+ | `monaSegmentedItemTemplate` | The default label text | Every option |
85
+
86
+ [With icons](#with-icons) shows one. When no template is projected, the option renders its plain `label` text, exactly as before.
87
+
88
+ #### Template Context
89
+
90
+ The template receives a `SegmentedItemTemplateContext<T>`:
91
+
92
+ | Property | Type | Description |
93
+ |-----------------------|---------------------|-----------------------------------------------------------|
94
+ | `$implicit` / `option` | `SegmentedOption<T>` | The option rendered by this item. |
95
+ | `index` | `number` | Zero-based option index. |
96
+ | `selected` | `boolean` | Whether this option is currently selected. |
97
+ | `disabled` | `boolean` | Whether this option is disabled, individually or via the group. |
98
+
99
+ The component still owns the radio input, selection, and disabled semantics; the template only supplies the visual content inside the label span.
100
+
101
+ ## Examples
102
+
103
+ ### Disabled options
104
+
105
+ `disabled` on `mona-segmented` disables every option at once. An option can also be disabled individually with its own `disabled` flag, even when the group is enabled.
106
+
107
+ `disabled-example.component.ts`
108
+
109
+ ```typescript
110
+ import { Component, signal } from "@angular/core";
111
+ import { SegmentedComponent, type SegmentedOption } from "@nanahoshi/mona-ui/segmented";
112
+
113
+ type SortOrder = "archived" | "newest" | "popular";
114
+
115
+ @Component({
116
+ selector: "app-segmented-disabled-example",
117
+ imports: [SegmentedComponent],
118
+ templateUrl: "./disabled-example.component.html"
119
+ })
120
+ export class SegmentedDisabledExampleComponent {
121
+ protected readonly sort = signal<SortOrder | null>("newest");
122
+ protected readonly sortOptions: readonly SegmentedOption<SortOrder>[] = [
123
+ { label: "Newest", value: "newest" },
124
+ { label: "Popular", value: "popular" },
125
+ { label: "Archived", value: "archived", disabled: true }
126
+ ];
127
+ }
128
+ ```
129
+
130
+ `disabled-example.component.html`
131
+
132
+ ```html
133
+ <div class="flex flex-col items-start gap-2">
134
+ <mona-segmented aria-label="Sort order" [options]="sortOptions" [(value)]="sort" />
135
+ <span class="text-sm">Sorted by: {{ sort() }}</span>
136
+ </div>
137
+ ```
138
+
139
+ ### With icons
140
+
141
+ A `monaSegmentedItemTemplate` replaces each option's label text. `option.label` stays the radio's accessible name, so the icons are hidden from assistive technology.
142
+
143
+ `with-icons-example.component.ts`
144
+
145
+ ```typescript
146
+ import { Component, signal } from "@angular/core";
147
+ import { LucideLayoutGrid, LucideList } from "@lucide/angular";
148
+ import { SegmentedComponent, SegmentedItemTemplateDirective, type SegmentedOption } from "@nanahoshi/mona-ui/segmented";
149
+
150
+ type ViewMode = "grid" | "list";
151
+
152
+ @Component({
153
+ selector: "app-segmented-with-icons-example",
154
+ imports: [LucideLayoutGrid, LucideList, SegmentedComponent, SegmentedItemTemplateDirective],
155
+ templateUrl: "./with-icons-example.component.html"
156
+ })
157
+ export class SegmentedWithIconsExampleComponent {
158
+ protected readonly viewMode = signal<ViewMode | null>("list");
159
+ protected readonly viewModes: readonly SegmentedOption<ViewMode>[] = [
160
+ { label: "List", value: "list" },
161
+ { label: "Grid", value: "grid" }
162
+ ];
163
+ }
164
+ ```
165
+
166
+ `with-icons-example.component.html`
167
+
168
+ ```html
169
+ <mona-segmented aria-label="View mode" [options]="viewModes" [(value)]="viewMode">
170
+ <ng-template let-option [monaSegmentedItemTemplate]="viewModes">
171
+ <span class="flex items-center gap-1.5">
172
+ @if (option.value === "list") {
173
+ <svg lucideList aria-hidden="true" [size]="16"></svg>
174
+ } @else {
175
+ <svg lucideLayoutGrid aria-hidden="true" [size]="16"></svg>
176
+ }
177
+ {{ option.label }}
178
+ </span>
179
+ </ng-template>
180
+ </mona-segmented>
181
+ ```
182
+
183
+ ### In a form
184
+
185
+ `forms-example.component.ts`
186
+
187
+ ```typescript
188
+ import { Component, signal } from "@angular/core";
189
+ import { form, FormField } from "@angular/forms/signals";
190
+ import { LabelComponent } from "@nanahoshi/mona-ui/label";
191
+ import { SegmentedComponent, type SegmentedOption } from "@nanahoshi/mona-ui/segmented";
192
+
193
+ type Period = "day" | "month" | "week";
194
+
195
+ interface ReportModel {
196
+ period: Period | null;
197
+ }
198
+
199
+ @Component({
200
+ selector: "app-segmented-forms-example",
201
+ imports: [FormField, LabelComponent, SegmentedComponent],
202
+ templateUrl: "./forms-example.component.html"
203
+ })
204
+ export class SegmentedFormsExampleComponent {
205
+ readonly #model = signal<ReportModel>({ period: "week" });
206
+ protected readonly periods: readonly SegmentedOption<Period>[] = [
207
+ { label: "Day", value: "day" },
208
+ { label: "Week", value: "week" },
209
+ { label: "Month", value: "month" }
210
+ ];
211
+ protected readonly report = form(this.#model);
212
+ }
213
+ ```
214
+
215
+ `forms-example.component.html`
216
+
217
+ ```html
218
+ <div class="flex flex-col items-start gap-2">
219
+ <mona-label text="Report period">
220
+ <mona-segmented [formField]="report.period" [options]="periods" />
221
+ </mona-label>
222
+ <span class="text-sm">Showing one {{ report.period().value() }} of sales.</span>
223
+ </div>
224
+ ```
225
+
226
+ ## Appearance & Styling
227
+
228
+ ### Full-width layout
229
+
230
+ The control is as wide as its options by default. Use the `class` input to give it a width, and with the default `alignment` the options share that width equally.
231
+
232
+ ```html
233
+ <mona-segmented
234
+ aria-label="Period"
235
+ class="w-full"
236
+ [options]="periods"
237
+ [(value)]="period">
238
+ </mona-segmented>
239
+ ```
240
+
241
+ ### Alignment
242
+
243
+ `alignment` controls how options are positioned within the container. `"stretch"` (the default) makes every option fill equal width — the "Full-width layout" behavior above. `"start"`, `"center"`, and `"end"` size each option to its own content instead, positioning the group within the container. `"start"`/`"end"` are logical directions that follow the current text direction, so they flip automatically in RTL layouts.
244
+
245
+ | Value | Behavior |
246
+ |------------|--------------------------------------------------------------------|
247
+ | `start` | Content-sized options, positioned at the leading edge |
248
+ | `center` | Content-sized options, centered in the container |
249
+ | `end` | Content-sized options, positioned at the trailing edge |
250
+ | `stretch` | Default. Every option fills equal width across the container |
251
+
252
+ ```html
253
+ <mona-segmented
254
+ aria-label="Period"
255
+ alignment="center"
256
+ class="w-full"
257
+ [options]="periods">
258
+ </mona-segmented>
259
+ ```
260
+
261
+ ### Sizes
262
+
263
+ `size` controls the height, horizontal padding, text size, and spacing of each option.
264
+
265
+ | Value | Use |
266
+ |----------|----------------------------------------|
267
+ | `small` | Compact toolbars and tight layouts |
268
+ | `medium` | Default; standard form controls |
269
+ | `large` | Prominent, touch-friendly controls |
270
+
271
+ ```html
272
+ <mona-segmented aria-label="Period" size="small" [options]="periods"></mona-segmented>
273
+ ```
274
+
275
+ ### Roundness
276
+
277
+ `rounded` controls the border radius of the container and its options.
278
+
279
+ | Value | Appearance |
280
+ |----------|-------------------------|
281
+ | `none` | Square corners |
282
+ | `small` | Slightly rounded |
283
+ | `medium` | Default rounded style |
284
+ | `large` | Pronounced rounding |
285
+ | `full` | Pill-shaped |
286
+
287
+ ```html
288
+ <mona-segmented
289
+ aria-label="Period"
290
+ rounded="full"
291
+ [options]="periods">
292
+ </mona-segmented>
293
+ ```
294
+
295
+ ## Forms Integration
296
+
297
+ `SegmentedComponent` implements the signal forms `FormValueControl<T | null>` interface, so it can be bound with `[formField]`, as in [In a form](#in-a-form).
298
+
299
+ When bound to a field, the `FormField` directive writes `invalid`, `touched`, `disabled`, `readonly`, `required` and `name` through the corresponding inputs and reads the selection from the `value` model.
300
+
301
+ 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.
302
+
303
+ ## Accessibility
304
+
305
+ ### ARIA
306
+
307
+ `SegmentedComponent` manages the following attributes on its host:
308
+
309
+ | Attribute | Value |
310
+ |-------------------|-----------------------------------------------------------------------------|
311
+ | `role` | `"radiogroup"` |
312
+ | `aria-label` | The value of the `aria-label` input, when provided |
313
+ | `aria-labelledby` | The value of the `aria-labelledby` input, or the id of a `mona-label` |
314
+ | `aria-disabled` | `"true"` when the group is disabled; omitted otherwise |
315
+ | `aria-invalid` | `"true"` when the control is both `touched` and `invalid`; omitted otherwise |
316
+ | `aria-readonly` | `"true"` when `readonly`; omitted otherwise |
317
+ | `aria-required` | `"true"` when `required`; omitted otherwise |
318
+
319
+ Each option renders a native `<input type="radio">` sharing the same `name`, so assistive technology announces the option label and its checked state automatically. A focused radio shows a solid outline around its option. In forced colors, which drop backgrounds, the selected option keeps a highlighted border.
320
+
321
+ Under `dir="rtl"`, options run from right to left and the arrows follow, and the indicator stays behind the selected option.
322
+
323
+ ### Accessible name
324
+
325
+ Provide either `aria-label` or `aria-labelledby`. `aria-labelledby` takes precedence when both are supplied. A `mona-label` also names it. If none is provided, the radio group has no accessible name, which axe doesn't flag, so the component warns in development.
326
+
327
+ ### Keyboard
328
+
329
+ Native radio behavior applies. Arrow keys move the selection within the group, and `Tab`/`Shift+Tab` moves focus between the group and the rest of the page. The entire group occupies a single Tab stop.
330
+
331
+ ### Consumer responsibilities
332
+
333
+ - Provide an accessible name via `aria-label` or `aria-labelledby`.
334
+ - Keep option labels concise. Long labels crowd the group and overflow its container.
335
+ - `value` may be initialized to `null`, but no option will be checked until a matching option value is selected.
336
+
337
+ ## API
338
+
339
+ Everything below is imported from `@nanahoshi/mona-ui/segmented`.
340
+
341
+ ### `SegmentedComponent`
342
+
343
+ **Selector:** `mona-segmented`
344
+ **Type parameters:** `T extends SegmentedValue = SegmentedValue`
345
+ **Implements:** `FormValueControl<T \| null>`
346
+
347
+ #### Inputs
348
+
349
+ | Name | Type | Default | Description |
350
+ | --- | --- | --- | --- |
351
+ | `alignment` | `"center" \| "end" \| "start" \| "stretch"` | `"stretch"` | Controls the alignment of the items inside the segmented component. |
352
+ | `animate` | `boolean` | `true` | Controls whether the selection indicator animates between selected options. When false, selection changes are applied immediately without transition. |
353
+ | `aria-label` | `string \| null` | `null` | Accessible name for the radio group. Provide either `aria-label` or `aria-labelledby`. |
354
+ | `aria-labelledby` | `string \| null` | `null` | ID of an external element that provides the accessible name for the radio group. |
355
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
356
+ | `disabled` | `boolean` | `false` | Disables every option in the group and prevents value changes. |
357
+ | `invalid` | `boolean` | `false` | Marks the component as invalid. Error styling requires both `invalid` and `touched` to be `true`. When bound to a signal form field via `[formField]`, this is written by the signal forms `FormField` directive. |
358
+ | `name` | `string` | `""` | The name of the radios, for a native `<form>`. Generated when empty, so two groups don't interfere. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
359
+ | `options` (required) | `readonly SegmentedOption<T>[]` | — | The list of selectable options. Exactly one option is selected at a time. |
360
+ | `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. |
361
+ | `required` | `boolean` | `false` | Marks the group as required, as `aria-required`. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
362
+ | `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"medium"` | Border-radius preset applied to the segmented container and its options. |
363
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the height, horizontal padding, text size, and spacing of each option. |
364
+ | `touched` | `boolean` | `false` | Marks the component as touched. When bound to a signal form field via `[formField]`, this is written by the signal forms `FormField` directive. |
365
+ | `value` (two-way) | `T \| null` | `null` | The currently selected value. When it matches no current option, no option is checked. A `null` value is allowed initially but cannot be restored through segmented interaction. |
366
+
367
+ #### Outputs
368
+
369
+ | Name | Type | Description |
370
+ | --- | --- | --- |
371
+ | `touch` | `void` | Emitted when the selected value changes or focus leaves the group. |
372
+ | `valueChange` | `T \| null` | Emitted when `value` changes. |
373
+
374
+ #### Methods
375
+
376
+ | Signature | Description |
377
+ | --- | --- |
378
+ | `focus(options?: FocusOptions): void` | Moves focus to the selected option, or the first enabled one. |
379
+
380
+ ### `SegmentedItemTemplateDirective`
381
+
382
+ Renders the visual content of every segmented option. Overrides the default label
383
+ text of each option. Bind the options, as `[monaSegmentedItemTemplate]="options"`, to type `let-option` from them.
384
+
385
+ **Selector:** `ng-template[monaSegmentedItemTemplate]`
386
+ **Type parameters:** `T extends SegmentedValue = SegmentedValue`
387
+
388
+ #### Inputs
389
+
390
+ | Name | Type | Default | Description |
391
+ | --- | --- | --- | --- |
392
+ | `monaSegmentedItemTemplate` | `readonly SegmentedOption<T>[] \| "" \| undefined` | `undefined` | The options, to type `let-option` from them. It changes nothing else. |
393
+
394
+ #### Template context
395
+
396
+ | Name | Type | Description |
397
+ | --- | --- | --- |
398
+ | `$implicit` | `SegmentedOption<T>` | The option rendered by this item. |
399
+ | `disabled` | `boolean` | Whether this option is disabled, either individually or via the group. |
400
+ | `index` | `number` | Zero-based option index. |
401
+ | `option` | `SegmentedOption<T>` | The option rendered by this item. |
402
+ | `selected` | `boolean` | Whether this option is currently selected. |
403
+
404
+ ### Types
405
+
406
+ #### `SegmentedItemTemplateContext`
407
+
408
+ Rendering context passed to the segmented item template.
409
+
410
+ **Type parameters:** `T extends SegmentedValue = SegmentedValue`
411
+
412
+ | Name | Type | Description |
413
+ | --- | --- | --- |
414
+ | `$implicit` (read-only) | `SegmentedOption<T>` | The option rendered by this item. |
415
+ | `disabled` (read-only) | `boolean` | Whether this option is disabled, either individually or via the group. |
416
+ | `index` (read-only) | `number` | Zero-based option index. |
417
+ | `option` (read-only) | `SegmentedOption<T>` | The option rendered by this item. |
418
+ | `selected` (read-only) | `boolean` | Whether this option is currently selected. |
419
+
420
+ #### `SegmentedOption`
421
+
422
+ **Type parameters:** `T extends SegmentedValue = SegmentedValue`
423
+
424
+ | Name | Type |
425
+ | --- | --- |
426
+ | `disabled?` (read-only) | `boolean` |
427
+ | `label` (read-only) | `string` |
428
+ | `value` (read-only) | `T` |
429
+
430
+ #### `SegmentedValue`
431
+
432
+ ```typescript
433
+ type SegmentedValue = string | number;
434
+ ```