@nanahoshi/mona-ui 0.25.1 → 0.26.1

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 (233) hide show
  1. package/README.md +2 -0
  2. package/chart/README.md +2 -2
  3. package/command/package.json +4 -0
  4. package/docs/auto-complete.md +733 -0
  5. package/docs/avatar.md +220 -0
  6. package/docs/breadcrumb.md +320 -0
  7. package/docs/button-group.md +392 -0
  8. package/docs/button.md +256 -0
  9. package/docs/calendar.md +515 -0
  10. package/docs/card.md +292 -0
  11. package/docs/chart-bar.md +714 -0
  12. package/docs/chart-financial.md +567 -0
  13. package/docs/chart-funnel.md +546 -0
  14. package/docs/chart-heatmap.md +535 -0
  15. package/docs/chart-line-area.md +462 -0
  16. package/docs/chart-pie.md +645 -0
  17. package/docs/chart-radar.md +518 -0
  18. package/docs/chart-radial.md +658 -0
  19. package/docs/chart-scatter.md +479 -0
  20. package/docs/chart-treemap.md +651 -0
  21. package/docs/chart.md +2465 -0
  22. package/docs/checkbox.md +374 -0
  23. package/docs/chip.md +339 -0
  24. package/docs/circular-progress-bar.md +287 -0
  25. package/docs/collapsible.md +308 -0
  26. package/docs/color-gradient.md +336 -0
  27. package/docs/color-palette.md +317 -0
  28. package/docs/color-picker.md +387 -0
  29. package/docs/combo-box.md +764 -0
  30. package/docs/command.md +582 -0
  31. package/docs/contextmenu.md +530 -0
  32. package/docs/date-picker.md +251 -0
  33. package/docs/datetime-picker.md +284 -0
  34. package/docs/decimal-textbox.md +260 -0
  35. package/docs/dialog.md +822 -0
  36. package/docs/dropdown-button.md +507 -0
  37. package/docs/dropdown-list.md +779 -0
  38. package/docs/editor.md +374 -0
  39. package/docs/expansion-panel.md +348 -0
  40. package/docs/fieldset.md +217 -0
  41. package/docs/forms.md +162 -0
  42. package/docs/grid.md +2053 -0
  43. package/docs/input.md +197 -0
  44. package/docs/installation.md +54 -0
  45. package/docs/introduction.md +46 -0
  46. package/docs/label.md +340 -0
  47. package/docs/list-box.md +637 -0
  48. package/docs/list-view.md +584 -0
  49. package/docs/menubar.md +559 -0
  50. package/docs/multi-select.md +765 -0
  51. package/docs/notification.md +460 -0
  52. package/docs/numeric-textbox.md +301 -0
  53. package/docs/otp-input.md +539 -0
  54. package/docs/pager.md +513 -0
  55. package/docs/placeholder.md +176 -0
  56. package/docs/popover.md +423 -0
  57. package/docs/popup-menu.md +658 -0
  58. package/docs/popup.md +617 -0
  59. package/docs/progress-bar.md +368 -0
  60. package/docs/radio-button.md +451 -0
  61. package/docs/range-slider.md +367 -0
  62. package/docs/rating.md +518 -0
  63. package/docs/scroll-view.md +375 -0
  64. package/docs/segmented.md +434 -0
  65. package/docs/sheet.md +348 -0
  66. package/docs/sidebar.md +1126 -0
  67. package/docs/skeleton.md +181 -0
  68. package/docs/slider.md +423 -0
  69. package/docs/spinner.md +370 -0
  70. package/docs/split-button.md +522 -0
  71. package/docs/splitter.md +342 -0
  72. package/docs/stepper.md +539 -0
  73. package/docs/switch.md +340 -0
  74. package/docs/tabs.md +542 -0
  75. package/docs/textarea.md +196 -0
  76. package/docs/textbox.md +332 -0
  77. package/docs/theming.md +403 -0
  78. package/docs/time-picker.md +254 -0
  79. package/docs/tooltip-directive.md +340 -0
  80. package/docs/tooltip.md +321 -0
  81. package/docs/tree-view.md +1018 -0
  82. package/docs/window.md +663 -0
  83. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  84. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
  85. package/fesm2022/nanahoshi-mona-ui-button.mjs +12 -0
  86. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
  87. package/fesm2022/nanahoshi-mona-ui-chart.mjs +212 -66
  88. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
  89. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
  90. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
  91. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  92. package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
  93. package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
  94. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
  95. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
  96. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
  97. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
  98. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
  99. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
  100. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
  101. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
  102. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
  103. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
  104. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
  105. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
  106. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
  107. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
  108. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  109. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  110. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
  111. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
  112. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
  113. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
  114. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
  115. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
  116. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
  117. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
  118. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
  119. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
  120. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
  121. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
  122. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
  123. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
  124. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
  125. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
  126. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
  127. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
  128. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
  129. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
  130. package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
  131. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
  132. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
  133. package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
  134. package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
  135. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
  136. package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
  137. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
  138. package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
  139. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
  140. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
  141. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
  142. package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
  143. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
  144. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
  145. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
  146. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
  147. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
  148. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
  149. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
  150. package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
  151. package/i18n/catalogs/en-US.messages.json +10 -0
  152. package/internal/popup-menu/package.json +4 -0
  153. package/llms.txt +133 -0
  154. package/locales/ar-sa/ar-sa.messages.json +10 -0
  155. package/locales/de-de/de-de.messages.json +10 -0
  156. package/locales/es-es/es-es.messages.json +10 -0
  157. package/locales/fr-fr/fr-fr.messages.json +10 -0
  158. package/locales/id-id/id-id.messages.json +10 -0
  159. package/locales/it-it/it-it.messages.json +10 -0
  160. package/locales/ja-jp/ja-jp.messages.json +10 -0
  161. package/locales/ko-kr/ko-kr.messages.json +10 -0
  162. package/locales/pt-br/pt-br.messages.json +10 -0
  163. package/locales/ru-ru/ru-ru.messages.json +10 -0
  164. package/locales/tr-tr/tr-tr.messages.json +10 -0
  165. package/locales/zh-cn/zh-cn.messages.json +10 -0
  166. package/locales/zh-tw/zh-tw.messages.json +10 -0
  167. package/package.json +9 -1
  168. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
  169. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
  170. package/types/nanahoshi-mona-ui-button.d.ts +12 -0
  171. package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
  172. package/types/nanahoshi-mona-ui-chart.d.ts +250 -20
  173. package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
  174. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
  175. package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
  176. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
  177. package/types/nanahoshi-mona-ui-command.d.ts +253 -0
  178. package/types/nanahoshi-mona-ui-common.d.ts +17 -1
  179. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
  180. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
  181. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
  182. package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
  183. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
  184. package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
  185. package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
  186. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
  187. package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
  188. package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
  189. package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
  190. package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
  191. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
  192. package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
  193. package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
  194. package/types/nanahoshi-mona-ui-label.d.ts +1 -0
  195. package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
  196. package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
  197. package/types/nanahoshi-mona-ui-list.d.ts +1 -1
  198. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
  199. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
  200. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
  201. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
  202. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
  203. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
  204. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
  205. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
  206. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
  207. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
  208. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
  209. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
  210. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
  211. package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
  212. package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
  213. package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
  214. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
  215. package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
  216. package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
  217. package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
  218. package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
  219. package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
  220. package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
  221. package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
  222. package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
  223. package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
  224. package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
  225. package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
  226. package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
  227. package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
  228. package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
  229. package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
  230. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
  231. package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
  232. package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
  233. package/types/nanahoshi-mona-ui-window.d.ts +66 -1
package/docs/rating.md ADDED
@@ -0,0 +1,518 @@
1
+ # Rating
2
+
3
+ > Choose a value from a visual scale of icons, in whole or half steps.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/rating`
6
+
7
+ **Selector:** `mona-rating`
8
+
9
+ `RatingComponent` lets users choose a numeric value from a configurable visual scale of preset icons, with support for whole or half values, a configurable selected color, continuous or single-item selection, keyboard navigation, and custom templates.
10
+
11
+ ## Overview
12
+
13
+ `RatingComponent` lets users choose a numeric value from a visual scale of items. The component renders a focusable `role="slider"` control; preset icons or custom item visuals are decorative layers driven by the accessible value. Selected and hovered visuals use the primary theme color unless `color` is set.
14
+
15
+ ### Intentional Exclusions
16
+
17
+ The component intentionally does not support:
18
+
19
+ - `ControlValueAccessor`
20
+ - Drag-to-rate interaction
21
+ - Arbitrary minimum/maximum values
22
+ - Custom step values other than `1` and `0.5`
23
+ - Vertical orientation
24
+ - A clear/reset button (use `clearable` or `Home`)
25
+ - Per-item disabled states
26
+
27
+ ## Import & Quick Start
28
+
29
+ **Import path:**
30
+
31
+ ```typescript
32
+ import {
33
+ RatingComponent,
34
+ RatingItemTemplateDirective,
35
+ RatingSelectedItemTemplateDirective,
36
+ RatingHoveredItemTemplateDirective,
37
+ type RatingIconName
38
+ } from "@nanahoshi/mona-ui/rating";
39
+ ```
40
+
41
+ ### Value Model
42
+
43
+ `value` is a two-way model (`model<number>`). The canonical range is `0` through `itemsCount`:
44
+
45
+ - `0` — no rating selected.
46
+ - `1` — the first item.
47
+ - `itemsCount` — the maximum rating.
48
+ - With `precision="half"`, half values such as `0.5` and `3.5` are valid.
49
+
50
+ ```html
51
+ <mona-rating aria-label="Product rating" [(value)]="rating"></mona-rating>
52
+ ```
53
+
54
+ External values that are out of range, non-finite, or incompatible with the active precision are normalized for rendering but are **never rewritten on the model** — the model changes only when the user interacts with the control. `Home` restores `0`.
55
+
56
+ ## Anatomy
57
+
58
+ ### Templates
59
+
60
+ Templates override the default preset visual for their state and may be mixed freely — each state independently falls back to the selected preset:
61
+
62
+ | Directive | Overrides | Rendered when |
63
+ | -------------------------------- | -------------------------- | ------------------------------------------------ |
64
+ | `monaRatingItemTemplate` | The unselected preset icon | Every item's base layer |
65
+ | `monaRatingSelectedItemTemplate` | The filled preset overlay | The visible value comes from the committed value |
66
+ | `monaRatingHoveredItemTemplate` | The filled preset overlay | The visible value comes from pointer preview |
67
+
68
+ ```html
69
+ <mona-rating aria-label="Satisfaction" precision="half" [(value)]="value">
70
+ <ng-template monaRatingItemTemplate let-index="index">
71
+ <span class="rating-face rating-face-empty">{{ index + 1 }}</span>
72
+ </ng-template>
73
+
74
+ <ng-template monaRatingSelectedItemTemplate let-index="index" let-fill="fill">
75
+ <span class="rating-face rating-face-selected">{{ index + 1 }}</span>
76
+ </ng-template>
77
+
78
+ <ng-template monaRatingHoveredItemTemplate let-index="index" let-fill="fill">
79
+ <span class="rating-face rating-face-hovered">{{ index + 1 }}</span>
80
+ </ng-template>
81
+ </mona-rating>
82
+ ```
83
+
84
+ #### Template Context
85
+
86
+ Every template receives a `RatingItemTemplateContext`:
87
+
88
+ | Property | Type | Description |
89
+ | --------------------- | --------- | ------------------------------------------------- |
90
+ | `$implicit` / `index` | `number` | Zero-based item index. |
91
+ | `itemValue` | `number` | One-based value represented by this item. |
92
+ | `fill` | `number` | Visible fill amount between `0` and `1`. |
93
+ | `selected` | `boolean` | The visible state comes from the committed value. |
94
+ | `hovered` | `boolean` | The visible state comes from pointer preview. |
95
+
96
+ The component owns overlay width, overflow clipping, continuous vs. single behavior, and RTL clipping direction. Templates only define the visual contents of each layer — they never implement half clipping themselves.
97
+
98
+ ## Examples
99
+
100
+ ### Clearing
101
+
102
+ The keyboard can always clear a rating with `Home`. Set `clearable` so a click on the current value clears it too, which gives pointer and touch users a way to undo one.
103
+
104
+ `clearable-example.component.ts`
105
+
106
+ ```typescript
107
+ import { Component, signal } from "@angular/core";
108
+ import { RatingComponent } from "@nanahoshi/mona-ui/rating";
109
+
110
+ @Component({
111
+ selector: "app-rating-clearable-example",
112
+ imports: [RatingComponent],
113
+ templateUrl: "./clearable-example.component.html"
114
+ })
115
+ export class RatingClearableExampleComponent {
116
+ protected readonly rating = signal(3);
117
+ }
118
+ ```
119
+
120
+ `clearable-example.component.html`
121
+
122
+ ```html
123
+ <div class="flex flex-col items-start gap-2">
124
+ <mona-rating label="Product rating" [clearable]="true" [(value)]="rating" />
125
+ <span class="text-sm">Rating: {{ rating() }}</span>
126
+ </div>
127
+ ```
128
+
129
+ ### Half values
130
+
131
+ With `precision="half"`, each item has two halves, and the keyboard moves by `0.5`.
132
+
133
+ `half-example.component.ts`
134
+
135
+ ```typescript
136
+ import { Component, signal } from "@angular/core";
137
+ import { RatingComponent } from "@nanahoshi/mona-ui/rating";
138
+
139
+ @Component({
140
+ selector: "app-rating-half-example",
141
+ imports: [RatingComponent],
142
+ templateUrl: "./half-example.component.html"
143
+ })
144
+ export class RatingHalfExampleComponent {
145
+ protected readonly rating = signal(3.5);
146
+ }
147
+ ```
148
+
149
+ `half-example.component.html`
150
+
151
+ ```html
152
+ <div class="flex flex-col items-start gap-2">
153
+ <mona-rating label="Hotel rating" precision="half" [(value)]="rating" />
154
+ <span class="text-sm">Rating: {{ rating() }} out of 5</span>
155
+ </div>
156
+ ```
157
+
158
+ ### Icons
159
+
160
+ `icon` picks a built-in shape and `color` its fill. For any other visual, provide the item templates.
161
+
162
+ `icons-example.component.ts`
163
+
164
+ ```typescript
165
+ import { Component, signal } from "@angular/core";
166
+ import { LucideThumbsUp } from "@lucide/angular";
167
+ import {
168
+ RatingComponent,
169
+ RatingHoveredItemTemplateDirective,
170
+ RatingItemTemplateDirective,
171
+ RatingSelectedItemTemplateDirective
172
+ } from "@nanahoshi/mona-ui/rating";
173
+
174
+ @Component({
175
+ selector: "app-rating-icons-example",
176
+ imports: [
177
+ LucideThumbsUp,
178
+ RatingComponent,
179
+ RatingHoveredItemTemplateDirective,
180
+ RatingItemTemplateDirective,
181
+ RatingSelectedItemTemplateDirective
182
+ ],
183
+ templateUrl: "./icons-example.component.html"
184
+ })
185
+ export class RatingIconsExampleComponent {
186
+ protected readonly favorite = signal(4);
187
+ protected readonly helpful = signal(2);
188
+ }
189
+ ```
190
+
191
+ `icons-example.component.html`
192
+
193
+ ```html
194
+ <div class="flex flex-col items-start gap-4">
195
+ <mona-rating color="#e11d48" icon="heart" label="Favorite level" [(value)]="favorite" />
196
+
197
+ <mona-rating label="Helpful" [(value)]="helpful">
198
+ <ng-template monaRatingItemTemplate>
199
+ <svg lucideThumbsUp class="text-muted-foreground h-full w-full" fill="none"></svg>
200
+ </ng-template>
201
+ <ng-template monaRatingSelectedItemTemplate>
202
+ <svg lucideThumbsUp class="h-full w-full text-sky-600" fill="currentColor"></svg>
203
+ </ng-template>
204
+ <ng-template monaRatingHoveredItemTemplate>
205
+ <svg lucideThumbsUp class="h-full w-full text-sky-400" fill="currentColor"></svg>
206
+ </ng-template>
207
+ </mona-rating>
208
+ </div>
209
+ ```
210
+
211
+ ### Requiring a rating in a form
212
+
213
+ The `min` rule rejects an unrated value of `0`.
214
+
215
+ `forms-example.component.ts`
216
+
217
+ ```typescript
218
+ import { Component, signal } from "@angular/core";
219
+ import { form, FormField, min } from "@angular/forms/signals";
220
+ import { RatingComponent } from "@nanahoshi/mona-ui/rating";
221
+
222
+ @Component({
223
+ selector: "app-rating-forms-example",
224
+ imports: [FormField, RatingComponent],
225
+ templateUrl: "./forms-example.component.html"
226
+ })
227
+ export class RatingFormsExampleComponent {
228
+ readonly #model = signal({ rating: 0 });
229
+ protected readonly review = form(this.#model, path => {
230
+ min(path.rating, 1);
231
+ });
232
+ }
233
+ ```
234
+
235
+ `forms-example.component.html`
236
+
237
+ ```html
238
+ <div class="flex flex-col items-start gap-2">
239
+ <mona-rating aria-describedby="review-rating-error" label="Your rating" [formField]="review.rating" />
240
+ <p id="review-rating-error" aria-live="polite" class="text-error text-sm">
241
+ @if (review.rating().touched() && review.rating().invalid()) {
242
+ Choose at least one star.
243
+ }
244
+ </p>
245
+ </div>
246
+ ```
247
+
248
+ ## Appearance & Styling
249
+
250
+ The host `class` input is merged with the component's classes through `tailwind-merge`, so compatible Tailwind utilities override the theme defaults.
251
+
252
+ ### Icon Presets and Custom Visuals
253
+
254
+ Use `icon` to select one built-in shape. The default base icon stays outlined, while committed and pointer-preview values use the same shape filled with the rating color. It defaults to the primary theme color; set `color` to any CSS color value to override it.
255
+
256
+ The available icon values are `star`, `heart`, `circle`, `diamond`, and `flame`. Set `color` to `null`, `undefined`, or an empty string to restore the primary theme color.
257
+
258
+ For any other icon or visual, use the item templates. Provide all three templates to replace every default layer; omitted templates continue to use the selected preset. [Icons](#icons) shows both.
259
+
260
+ ## Behavior
261
+
262
+ ### Selection Behavior
263
+
264
+ With `selection="continuous"` (default), every item at or below the selected value fills; one boundary item may fill partially:
265
+
266
+ | Value | Precision | Visual result |
267
+ | ----: | --------- | ------------------------------------------ |
268
+ | `0` | item | No items filled |
269
+ | `3` | item | First three items filled |
270
+ | `3.5` | half | First three items full, fourth half-filled |
271
+
272
+ With `selection="single"`, only the item representing the value fills:
273
+
274
+ | Value | Precision | Visual result |
275
+ | ----: | --------- | -------------------------------- |
276
+ | `3` | item | Only the third item filled |
277
+ | `3.5` | half | Only the fourth item half-filled |
278
+
279
+ ### Precision Behavior
280
+
281
+ - `precision="item"` — pointer interaction anywhere inside an item selects the whole item; the keyboard step is `1`.
282
+ - `precision="half"` — each item is divided into two pointer regions (first half selects `itemValue - 0.5`, second half selects `itemValue`); the keyboard step is `0.5`.
283
+
284
+ In RTL, the first _visual_ half (the right side) maps to the lower value. The pointer follows the computed CSS `direction`, so a `direction` set by style alone counts.
285
+
286
+ ### Disabled vs. Read-Only
287
+
288
+ - `disabled` — no pointer or keyboard interaction, not focusable (`tabindex="-1"`), `aria-disabled="true"`, disabled colors, and an unavailable cursor.
289
+ - `readonly` — no pointer or keyboard interaction but remains focusable, `aria-readonly="true"`, normal colors, no interactive cursor.
290
+
291
+ When both are `true`, disabled behavior takes precedence.
292
+
293
+ ### Programmatic Focus
294
+
295
+ ```typescript
296
+ readonly rating = viewChild(RatingComponent);
297
+
298
+ this.rating()?.focus();
299
+ ```
300
+
301
+ ## Forms Integration
302
+
303
+ `mona-rating` implements `FormValueControl<number>` and works with the `FormField` directive of Angular Signal Forms, as in [Requiring a rating in a form](#requiring-a-rating-in-a-form).
304
+
305
+ The `FormField` directive writes `disabled`, `invalid`, `readonly`, `required`, and `touched` state automatically. Don't set those on the same element, because Angular rejects the template. Error styling (`aria-invalid`, `data-invalid`, error ring) appears only when the field is both invalid and touched, or `required` and touched with a rating of `0`.
306
+
307
+ **Requiring a rating:** `required` and the signal forms `required` rule don't do the same thing. The `required` input shows the invalid state at `0` once touched. The `required` rule doesn't treat the number `0` as empty, so it won't fail the form by itself. To reject an unrated value, use `min(path, 1)`, or `min(path, 0.5)` with `precision="half"`.
308
+
309
+ The rating has no `name` input, because it has no native input.
310
+
311
+ `RatingComponent` doesn't implement `ControlValueAccessor`. `[(ngModel)]` binds to its `value` model through Angular's support for custom controls. Prefer `[formField]`.
312
+
313
+ ## Accessibility
314
+
315
+ ### Accessibility Attributes
316
+
317
+ The rating control is a focusable `role="slider"` element and **requires an accessible name**. Provide at least one of `label` (a visible label rendered next to the items), `aria-label`, or `aria-labelledby`, wrap it in a `mona-label` with `text`, or bind a label to it with `[for]="ref"`. Without one of these, assistive technology cannot announce the control, and it warns in development. A click on a wrapping label's caption focuses the control.
318
+
319
+ The inner control exposes:
320
+
321
+ | Attribute | Value |
322
+ | -------------------------------------------------- | ------------------------------------------------------------------------- |
323
+ | `role` | `"slider"` |
324
+ | `tabindex` | `tabindex` (or `-1` when disabled) |
325
+ | `aria-valuemin` | `0` |
326
+ | `aria-valuemax` | `itemsCount` |
327
+ | `aria-valuenow` | The normalized value |
328
+ | `aria-valuetext` | `"Not rated"`, `"3.5 out of 5"`, etc., or a custom `ariaValueText` result |
329
+ | `aria-label` / `aria-labelledby` | The resolved accessible name |
330
+ | `aria-describedby` | Forwarded from the input |
331
+ | `aria-disabled` / `aria-readonly` / `aria-invalid` | Reflecting the current state |
332
+
333
+ All item icons and templates are wrapped in `aria-hidden="true"` containers so screen readers announce the slider value, not the individual stars.
334
+
335
+ ### Keyboard Navigation
336
+
337
+ | Key | Action |
338
+ | ------------------------- | ------------------------------------- |
339
+ | `ArrowRight` / `ArrowUp` | Increase by the active precision step |
340
+ | `ArrowLeft` / `ArrowDown` | Decrease by the active precision step |
341
+ | `PageUp` | Increase by `1` |
342
+ | `PageDown` | Decrease by `1` |
343
+ | `Home` | Set value to `0` |
344
+ | `End` | Set value to `itemsCount` |
345
+
346
+ In RTL, `ArrowLeft` increases and `ArrowRight` decreases. Handled keys call `preventDefault`; unrecognized keys are ignored.
347
+
348
+ ## API
349
+
350
+ Everything below is imported from `@nanahoshi/mona-ui/rating`.
351
+
352
+ ### `RatingComponent`
353
+
354
+ **Selector:** `mona-rating`
355
+ **Implements:** `FormValueControl<number>`
356
+
357
+ #### Inputs
358
+
359
+ | Name | Type | Default | Description |
360
+ | --- | --- | --- | --- |
361
+ | `aria-describedby` | `string \| null` | `null` | Associates help text or an error description with the focusable rating control. |
362
+ | `aria-label` | `string \| null` | `null` | Explicit accessible name for the rating control. Provide `aria-label`, `aria-labelledby`, or `label` so assistive technology can announce the control. |
363
+ | `aria-labelledby` | `string \| null` | `null` | IDs of external elements providing the accessible name for the rating control. |
364
+ | `ariaValueText` | `((value: number, maximum: number) => string) \| null` | `null` | Custom screen-reader value announcement. Receives the normalized value and the item count and returns the string to expose through `aria-valuetext`. |
365
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
366
+ | `clearable` | `boolean` | `false` | Lets a click on the current value clear the rating, so pointer and touch users can undo one. The keyboard can always clear it with Home. |
367
+ | `color` | `string \| null` | `undefined` | CSS color for selected and hovered rating visuals. Empty, `null`, and `undefined` values use the primary theme color. |
368
+ | `disabled` | `boolean` | `false` | Disables pointer and keyboard interaction and removes the control from the tab sequence. When bound to a signal form field via `[formField]`, this is written by the signal forms `Field` directive. |
369
+ | `icon` | `RatingIconName` | `"star"` | Built-in icon used for the default rating visuals. Choose `star`, `heart`, `circle`, `diamond`, or `flame`; use item templates to supply a custom icon. |
370
+ | `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 `Field` directive. |
371
+ | `itemsCount` | `number` | `5` | Number of rating items. Fractional values are floored and values below one are raised to one. |
372
+ | `label` | `string \| null` | `null` | Optional visible label rendered before or after the rating items. When no explicit `aria-label` or `aria-labelledby` is supplied, the label provides the accessible name. |
373
+ | `labelPosition` | `RatingLabelPosition` | `"after"` | Places the visible label before or after the item group. |
374
+ | `precision` | `RatingPrecision` | `"item"` | Selection granularity of the rating. |
375
+ | `readonly` | `boolean` | `false` | Prevents value changes while preserving focusability and normal visual emphasis. |
376
+ | `required` | `boolean` | `false` | Shows the invalid state while the rating is `0` and the control is touched. The `required` rule of signal forms doesn't treat `0` as empty, so it won't fail the form by itself: use `min(path, 1)` to reject an unrated value. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
377
+ | `selection` | `RatingSelectionMode` | `"continuous"` | Controls cumulative or single-item filling. |
378
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the icon dimensions, item hitboxes, spacing, and label typography. |
379
+ | `tabindex` | `string \| number` | `0` | Tab index applied to the focusable rating control when not disabled. Accepts a numeric string and converts it to a number. |
380
+ | `touched` | `boolean` | `false` | Marks the component as touched. When bound to a signal form field via `[formField]`, this is written by the signal forms `Field` directive. |
381
+ | `value` (two-way) | `number` | `0` | Current rating value. `0` represents an unrated state. Values are normalized for rendering but are not rewritten until the user interacts with the component. |
382
+
383
+ #### Outputs
384
+
385
+ | Name | Type | Description |
386
+ | --- | --- | --- |
387
+ | `touch` | `void` | Emitted when the control loses focus or a pointer commits a rating, marking the field as touched. |
388
+ | `valueChange` | `number` | Emitted when `value` changes. |
389
+
390
+ #### Methods
391
+
392
+ | Signature | Description |
393
+ | --- | --- |
394
+ | `blur(): void` | Blurs the inner slider control if focused. |
395
+ | `focus(options?: FocusOptions): void` | Focuses the inner slider control. Does nothing while disabled. |
396
+
397
+ ### `RatingHoveredItemTemplateDirective`
398
+
399
+ Renders the pointer-preview visual for rating items. Overrides the default preset
400
+ overlay whenever the visible state comes from pointer preview.
401
+
402
+ **Selector:** `ng-template[monaRatingHoveredItemTemplate]`
403
+
404
+ #### Template context
405
+
406
+ | Name | Type | Description |
407
+ | --- | --- | --- |
408
+ | `$implicit` | `number` | Zero-based item index. |
409
+ | `fill` | `number` | Visible fill amount between 0 and 1. |
410
+ | `hovered` | `boolean` | Whether the visible state comes from pointer preview. |
411
+ | `index` | `number` | Zero-based item index. |
412
+ | `itemValue` | `number` | One-based value represented by this item. |
413
+ | `selected` | `boolean` | Whether the visible state comes from the committed value. |
414
+
415
+ ### `RatingItemTemplateDirective`
416
+
417
+ Renders the default (unselected) visual for every rating item. Overrides the
418
+ default preset icon for the base layer of each item.
419
+
420
+ **Selector:** `ng-template[monaRatingItemTemplate]`
421
+
422
+ #### Template context
423
+
424
+ | Name | Type | Description |
425
+ | --- | --- | --- |
426
+ | `$implicit` | `number` | Zero-based item index. |
427
+ | `fill` | `number` | Visible fill amount between 0 and 1. |
428
+ | `hovered` | `boolean` | Whether the visible state comes from pointer preview. |
429
+ | `index` | `number` | Zero-based item index. |
430
+ | `itemValue` | `number` | One-based value represented by this item. |
431
+ | `selected` | `boolean` | Whether the visible state comes from the committed value. |
432
+
433
+ ### `RatingSelectedItemTemplateDirective`
434
+
435
+ Renders the committed selected visual for rating items. Overrides the default
436
+ preset overlay whenever the visible state comes from the committed value.
437
+
438
+ **Selector:** `ng-template[monaRatingSelectedItemTemplate]`
439
+
440
+ #### Template context
441
+
442
+ | Name | Type | Description |
443
+ | --- | --- | --- |
444
+ | `$implicit` | `number` | Zero-based item index. |
445
+ | `fill` | `number` | Visible fill amount between 0 and 1. |
446
+ | `hovered` | `boolean` | Whether the visible state comes from pointer preview. |
447
+ | `index` | `number` | Zero-based item index. |
448
+ | `itemValue` | `number` | One-based value represented by this item. |
449
+ | `selected` | `boolean` | Whether the visible state comes from the committed value. |
450
+
451
+ ### Types
452
+
453
+ #### `RATING_DEFAULT_MESSAGES`
454
+
455
+ ```typescript
456
+ const RATING_DEFAULT_MESSAGES: MonaRatingMessages;
457
+ ```
458
+
459
+ #### `RatingItemTemplateContext`
460
+
461
+ Rendering context passed to the default, selected, and hovered item templates.
462
+
463
+ | Name | Type | Description |
464
+ | --- | --- | --- |
465
+ | `$implicit` (read-only) | `number` | Zero-based item index. |
466
+ | `fill` (read-only) | `number` | Visible fill amount between 0 and 1. |
467
+ | `hovered` (read-only) | `boolean` | Whether the visible state comes from pointer preview. |
468
+ | `index` (read-only) | `number` | Zero-based item index. |
469
+ | `itemValue` (read-only) | `number` | One-based value represented by this item. |
470
+ | `selected` (read-only) | `boolean` | Whether the visible state comes from the committed value. |
471
+
472
+ #### `RatingIconName`
473
+
474
+ Built-in icon names available for the default rating visuals.
475
+
476
+ ```typescript
477
+ type RatingIconName = "circle" | "diamond" | "flame" | "heart" | "star";
478
+ ```
479
+
480
+ #### `RatingLabelPosition`
481
+
482
+ Position of the visible label relative to the rating items.
483
+
484
+ ```typescript
485
+ type RatingLabelPosition = "before" | "after";
486
+ ```
487
+
488
+ #### `RatingPrecision`
489
+
490
+ Selection granularity of the rating. `"item"` selects whole items, `"half"` selects
491
+ half-item increments.
492
+
493
+ ```typescript
494
+ type RatingPrecision = "item" | "half";
495
+ ```
496
+
497
+ #### `RatingSelectionMode`
498
+
499
+ How the selected value is visualized across the items. `"continuous"` fills every
500
+ item up to the selected value, `"single"` fills only the item representing the selected value.
501
+
502
+ ```typescript
503
+ type RatingSelectionMode = "continuous" | "single";
504
+ ```
505
+
506
+ #### `MonaRatingMessages`
507
+
508
+ From `@nanahoshi/mona-ui/i18n`.
509
+
510
+ | Name | Type |
511
+ | --- | --- |
512
+ | `notRated` (read-only) | `string` |
513
+
514
+ **Methods**
515
+
516
+ | Signature |
517
+ | --- |
518
+ | `valueText(value: number, max: number): string` |