@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.
- package/README.md +2 -0
- package/command/package.json +4 -0
- package/docs/auto-complete.md +733 -0
- package/docs/avatar.md +220 -0
- package/docs/breadcrumb.md +320 -0
- package/docs/button-group.md +392 -0
- package/docs/button.md +256 -0
- package/docs/calendar.md +515 -0
- package/docs/card.md +292 -0
- package/docs/chart.md +4058 -0
- package/docs/checkbox.md +374 -0
- package/docs/chip.md +339 -0
- package/docs/circular-progress-bar.md +287 -0
- package/docs/collapsible.md +308 -0
- package/docs/color-gradient.md +336 -0
- package/docs/color-palette.md +317 -0
- package/docs/color-picker.md +387 -0
- package/docs/combo-box.md +764 -0
- package/docs/command.md +582 -0
- package/docs/contextmenu.md +530 -0
- package/docs/date-picker.md +251 -0
- package/docs/datetime-picker.md +284 -0
- package/docs/decimal-textbox.md +260 -0
- package/docs/dialog.md +822 -0
- package/docs/dropdown-button.md +507 -0
- package/docs/dropdown-list.md +779 -0
- package/docs/editor.md +374 -0
- package/docs/expansion-panel.md +348 -0
- package/docs/fieldset.md +217 -0
- package/docs/forms.md +162 -0
- package/docs/grid.md +2053 -0
- package/docs/input.md +197 -0
- package/docs/installation.md +54 -0
- package/docs/introduction.md +46 -0
- package/docs/label.md +340 -0
- package/docs/list-box.md +637 -0
- package/docs/list-view.md +584 -0
- package/docs/menubar.md +559 -0
- package/docs/multi-select.md +765 -0
- package/docs/notification.md +460 -0
- package/docs/numeric-textbox.md +301 -0
- package/docs/otp-input.md +539 -0
- package/docs/pager.md +513 -0
- package/docs/placeholder.md +176 -0
- package/docs/popover.md +423 -0
- package/docs/popup-menu.md +658 -0
- package/docs/popup.md +617 -0
- package/docs/progress-bar.md +368 -0
- package/docs/radio-button.md +451 -0
- package/docs/range-slider.md +367 -0
- package/docs/rating.md +518 -0
- package/docs/scroll-view.md +375 -0
- package/docs/segmented.md +434 -0
- package/docs/sheet.md +348 -0
- package/docs/sidebar.md +1126 -0
- package/docs/skeleton.md +181 -0
- package/docs/slider.md +423 -0
- package/docs/spinner.md +370 -0
- package/docs/split-button.md +522 -0
- package/docs/splitter.md +342 -0
- package/docs/stepper.md +539 -0
- package/docs/switch.md +340 -0
- package/docs/tabs.md +542 -0
- package/docs/textarea.md +196 -0
- package/docs/textbox.md +332 -0
- package/docs/theming.md +403 -0
- package/docs/time-picker.md +254 -0
- package/docs/tooltip-directive.md +340 -0
- package/docs/tooltip.md +321 -0
- package/docs/tree-view.md +1018 -0
- package/docs/window.md +663 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +12 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +86 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
- package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
- package/i18n/catalogs/en-US.messages.json +10 -0
- package/internal/popup-menu/package.json +4 -0
- package/llms.txt +123 -0
- package/locales/ar-sa/ar-sa.messages.json +10 -0
- package/locales/de-de/de-de.messages.json +10 -0
- package/locales/es-es/es-es.messages.json +10 -0
- package/locales/fr-fr/fr-fr.messages.json +10 -0
- package/locales/id-id/id-id.messages.json +10 -0
- package/locales/it-it/it-it.messages.json +10 -0
- package/locales/ja-jp/ja-jp.messages.json +10 -0
- package/locales/ko-kr/ko-kr.messages.json +10 -0
- package/locales/pt-br/pt-br.messages.json +10 -0
- package/locales/ru-ru/ru-ru.messages.json +10 -0
- package/locales/tr-tr/tr-tr.messages.json +10 -0
- package/locales/zh-cn/zh-cn.messages.json +10 -0
- package/locales/zh-tw/zh-tw.messages.json +10 -0
- package/package.json +9 -1
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
- package/types/nanahoshi-mona-ui-button.d.ts +12 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
- package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-command.d.ts +253 -0
- package/types/nanahoshi-mona-ui-common.d.ts +17 -1
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
- package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
- package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
- package/types/nanahoshi-mona-ui-label.d.ts +1 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
- package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
- package/types/nanahoshi-mona-ui-list.d.ts +1 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
- package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
- package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
- package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
- package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
- package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
- package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
- package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
- package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
- package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
- package/types/nanahoshi-mona-ui-window.d.ts +66 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Color Palette
|
|
2
|
+
|
|
3
|
+
> A grid of selectable color swatches from a built-in or custom scheme.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/color-palette`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-color-palette`
|
|
8
|
+
|
|
9
|
+
`ColorPaletteComponent` renders a grid of selectable color swatches — a built-in flat, material, or websafe scheme, or a custom list of colors — with keyboard navigation and signal forms support via `FormValueControl<string | null>`.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Use `ColorPaletteComponent` when the user should choose only from a known, bounded set of colors rather than compose an arbitrary one. Use `ColorGradientComponent` when the user needs to choose a custom color. Use `ColorPickerComponent` when the palette (or gradient) editor should open from a compact dropdown-style control instead of being shown inline.
|
|
14
|
+
|
|
15
|
+
> **Forms.** `ColorPaletteComponent` implements `FormValueControl<string | null>` from `@angular/forms/signals`, so use `[formField]` with signal forms. It has no `ControlValueAccessor`, but `[(ngModel)]`, `[formControl]` and `formControlName` work too, because Angular binds a control's `value` and `touch` directly when it has no accessor.
|
|
16
|
+
|
|
17
|
+
## Import & Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ColorPaletteComponent } from "@nanahoshi/mona-ui/color-palette";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Direct value binding**
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<mona-color-palette [(value)]="color"></mona-color-palette>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
protected readonly color = signal<string | null>("#3498db");
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Signal forms**
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { signal } from "@angular/core";
|
|
37
|
+
import { FormField, form } from "@angular/forms/signals";
|
|
38
|
+
import { ColorPaletteComponent } from "@nanahoshi/mona-ui/color-palette";
|
|
39
|
+
|
|
40
|
+
protected readonly form = form(signal<{ color: string | null }>({ color: "#3498db" }));
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<mona-color-palette [formField]="form.color"></mona-color-palette>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Examples
|
|
48
|
+
|
|
49
|
+
### Built-in palettes
|
|
50
|
+
|
|
51
|
+
`built-in-example.component.ts`
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { Component, signal } from "@angular/core";
|
|
55
|
+
import { ColorPaletteComponent } from "@nanahoshi/mona-ui/color-palette";
|
|
56
|
+
|
|
57
|
+
@Component({
|
|
58
|
+
selector: "app-color-palette-built-in-example",
|
|
59
|
+
imports: [ColorPaletteComponent],
|
|
60
|
+
templateUrl: "./built-in-example.component.html"
|
|
61
|
+
})
|
|
62
|
+
export class ColorPaletteBuiltInExampleComponent {
|
|
63
|
+
protected readonly color = signal<string | null>(null);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`built-in-example.component.html`
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<div class="flex flex-col items-start gap-2">
|
|
71
|
+
<mona-color-palette aria-label="Highlight color" palette="material" [(value)]="color" />
|
|
72
|
+
<span class="text-sm">Color: {{ color() ?? "none" }}</span>
|
|
73
|
+
</div>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| `palette` value | Scheme |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `"flat"` | A flat/muted color set (the default fallback when a custom palette is empty). |
|
|
79
|
+
| `"material"` | Material Design color set. |
|
|
80
|
+
| `"websafe"` | The 216-color web-safe palette. |
|
|
81
|
+
|
|
82
|
+
### Custom palettes
|
|
83
|
+
|
|
84
|
+
Pass any iterable of CSS color strings. `columns` controls the grid width and only applies to custom palettes — built-in schemes define their own column count.
|
|
85
|
+
|
|
86
|
+
`custom-example.component.ts`
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { Component, signal } from "@angular/core";
|
|
90
|
+
import { ColorPaletteComponent } from "@nanahoshi/mona-ui/color-palette";
|
|
91
|
+
|
|
92
|
+
@Component({
|
|
93
|
+
selector: "app-color-palette-custom-example",
|
|
94
|
+
imports: [ColorPaletteComponent],
|
|
95
|
+
templateUrl: "./custom-example.component.html"
|
|
96
|
+
})
|
|
97
|
+
export class ColorPaletteCustomExampleComponent {
|
|
98
|
+
protected readonly color = signal<string | null>("#0f3460");
|
|
99
|
+
protected readonly colors = ["#1a1a2e", "#16213e", "#0f3460", "#533483", "#e94560", "#f5a25d", "#f8e9a1", "#a8d8ea"];
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`custom-example.component.html`
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<div class="flex flex-col items-start gap-2">
|
|
107
|
+
<mona-color-palette aria-label="Card color" rounded="small" [columns]="4" [palette]="colors" [tileSize]="32" [(value)]="color" />
|
|
108
|
+
<span class="text-sm">Color: {{ color() ?? "none" }}</span>
|
|
109
|
+
</div>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
An empty custom palette (`[]`) falls back to the built-in `"flat"` scheme. A `columns` value below 1 shows one column.
|
|
113
|
+
|
|
114
|
+
Hex, `rgb()` and `hsl()` colors are read from their text. Anything else, such as a color name, is read through a canvas, one for each tile, so prefer those three for a large palette.
|
|
115
|
+
|
|
116
|
+
### Named colors
|
|
117
|
+
|
|
118
|
+
Use `{ color, name }` items when the colors mean something. Assistive technology reads "Done, #15803d", and the same text shows as a tooltip. Plain strings and items can be mixed, and `value` always holds the color. `ColorPaletteItem` is imported from `@nanahoshi/mona-ui/common`.
|
|
119
|
+
|
|
120
|
+
`named-example.component.ts`
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { Component, signal } from "@angular/core";
|
|
124
|
+
import type { ColorPaletteItem } from "@nanahoshi/mona-ui/common";
|
|
125
|
+
import { ColorPaletteComponent } from "@nanahoshi/mona-ui/color-palette";
|
|
126
|
+
|
|
127
|
+
@Component({
|
|
128
|
+
selector: "app-color-palette-named-example",
|
|
129
|
+
imports: [ColorPaletteComponent],
|
|
130
|
+
templateUrl: "./named-example.component.html"
|
|
131
|
+
})
|
|
132
|
+
export class ColorPaletteNamedExampleComponent {
|
|
133
|
+
protected readonly color = signal<string | null>(null);
|
|
134
|
+
protected readonly statusColors: readonly ColorPaletteItem[] = [
|
|
135
|
+
{ color: "#15803d", name: "Done" },
|
|
136
|
+
{ color: "#1d4ed8", name: "In progress" },
|
|
137
|
+
{ color: "#b45309", name: "Blocked" },
|
|
138
|
+
{ color: "#6b7280", name: "Not started" }
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`named-example.component.html`
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<div class="flex flex-col items-start gap-2">
|
|
147
|
+
<mona-color-palette aria-label="Status color" rounded="full" [columns]="4" [palette]="statusColors" [tileSize]="32" [(value)]="color" />
|
|
148
|
+
<span class="text-sm">Color: {{ color() ?? "none" }}</span>
|
|
149
|
+
</div>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Read-only and disabled
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<mona-color-palette [(value)]="color" [readonly]="true"></mona-color-palette>
|
|
156
|
+
<mona-color-palette [(value)]="color" [disabled]="true"></mona-color-palette>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`readonly` keeps tiles focusable and keyboard-navigable but blocks selection changes. `disabled` removes tiles from the tab order and blocks all interaction.
|
|
160
|
+
|
|
161
|
+
## Appearance & Styling
|
|
162
|
+
|
|
163
|
+
### Rounded tile variants
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<mona-color-palette [(value)]="color" rounded="full"></mona-color-palette>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Supported `rounded` values are `none`, `small`, `medium`, `large`, and `full`.
|
|
170
|
+
|
|
171
|
+
## Behavior
|
|
172
|
+
|
|
173
|
+
### Value Behavior
|
|
174
|
+
|
|
175
|
+
Selecting the currently selected color deselects it, setting `value` back to `null`, unless `clearable` is `false` or the palette is required. Clicking or activating any other tile sets `value` to that tile's color string.
|
|
176
|
+
|
|
177
|
+
Two spellings of a color count as the same one when finding the selected tile, so `#abcdef`, `#ABCDEF` and `rgb(171, 205, 239)` all select the same tile. A repeated color marks only its first tile.
|
|
178
|
+
|
|
179
|
+
## Forms Integration
|
|
180
|
+
|
|
181
|
+
`ColorPaletteComponent` implements `FormValueControl<string | null>` from `@angular/forms/signals`.
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { signal } from "@angular/core";
|
|
185
|
+
import { FormField, disabled, form } from "@angular/forms/signals";
|
|
186
|
+
|
|
187
|
+
protected readonly form = form(signal<{ color: string | null }>({ color: "#3498db" }), schema => {
|
|
188
|
+
disabled(schema.color, { when: () => this.locked() });
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```html
|
|
193
|
+
<mona-color-palette [formField]="form.color"></mona-color-palette>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The `touch` output fires when focus leaves the palette or a color is selected. Moving between tiles doesn't fire it. The signal forms `FormField` directive listens to this output to mark the field as touched.
|
|
197
|
+
|
|
198
|
+
## Accessibility
|
|
199
|
+
|
|
200
|
+
The host renders `role="grid"`. Each visual row is wrapped in an element with `role="row"`, and each swatch renders `role="gridcell"` with a roving `tabindex`: only the active tile is tab-reachable, and arrow keys move both focus and the active tile. Before any tile has focus, and again after focus leaves, the active tile is the selected one, or the first.
|
|
201
|
+
|
|
202
|
+
| Attribute | Where | Value |
|
|
203
|
+
|---|---|---|
|
|
204
|
+
| `role` | Host | `"grid"` |
|
|
205
|
+
| `aria-label` | Host | The `aria-label` input, or `"Color palette"`. Absent when a label or `aria-labelledby` names the palette. |
|
|
206
|
+
| `aria-disabled` | Host | Reflects `disabled` |
|
|
207
|
+
| `aria-invalid` | Host | `"true"` once `touched` and either `invalid`, or `required` with no color. Otherwise absent. |
|
|
208
|
+
| `aria-readonly` | Host | Reflects `readonly` |
|
|
209
|
+
| `aria-required` | Host | Reflects `required` |
|
|
210
|
+
| `role` | Each tile | `"gridcell"` |
|
|
211
|
+
| `aria-label` | Each tile | `"Color " + <color value>`, or `<name>, <color value>` for a named item |
|
|
212
|
+
| `title` | Each tile | Same as `aria-label` |
|
|
213
|
+
| `aria-selected` | Each tile | `"true"` when the tile matches `value` |
|
|
214
|
+
| `aria-disabled` / `aria-readonly` | Each tile | Reflect the corresponding host inputs |
|
|
215
|
+
| `tabindex` | Each tile | `0` for the active tile, `-1` for the rest, `-1` for all tiles when `disabled` |
|
|
216
|
+
|
|
217
|
+
**Consumer responsibilities**
|
|
218
|
+
|
|
219
|
+
- Name each palette with `aria-label`, `aria-labelledby` or a `mona-label`, so screen reader users can tell them apart.
|
|
220
|
+
- Built-in palettes have no color names, so each tile reads its hex value. Use `{ color, name }` items where names matter.
|
|
221
|
+
- When using signal forms, bind through `[formField]` so the form field receives `value` and listens to `touch`.
|
|
222
|
+
|
|
223
|
+
### Keyboard Interaction
|
|
224
|
+
|
|
225
|
+
Keyboard navigation targets the currently focused tile and is disabled entirely when `disabled` is `true`.
|
|
226
|
+
|
|
227
|
+
| Key | Action |
|
|
228
|
+
|---|---|
|
|
229
|
+
| `ArrowLeft` | Move focus one tile left (stops at the first tile). |
|
|
230
|
+
| `ArrowRight` | Move focus one tile right (stops at the last tile). |
|
|
231
|
+
| `ArrowUp` | Move focus one row up. Stays put on the first row. |
|
|
232
|
+
| `ArrowDown` | Move focus one row down. Stays put when there's no tile below. |
|
|
233
|
+
| `Home` | Move focus to the start of the row. |
|
|
234
|
+
| `End` | Move focus to the end of the row. |
|
|
235
|
+
| `Ctrl+Home` | Move focus to the first tile. |
|
|
236
|
+
| `Ctrl+End` | Move focus to the last tile. |
|
|
237
|
+
| `Enter` / `Space` | Select the focused tile. Ignored when `readonly` is `true` (focus still moves normally). |
|
|
238
|
+
|
|
239
|
+
Under `dir="rtl"`, `ArrowLeft` and `ArrowRight` swap, so each moves in the direction it points.
|
|
240
|
+
|
|
241
|
+
## API
|
|
242
|
+
|
|
243
|
+
Everything below is imported from `@nanahoshi/mona-ui/color-palette`.
|
|
244
|
+
|
|
245
|
+
### `ColorPaletteComponent`
|
|
246
|
+
|
|
247
|
+
**Selector:** `mona-color-palette`
|
|
248
|
+
**Implements:** `FormValueControl<string \| null>`
|
|
249
|
+
|
|
250
|
+
#### Inputs
|
|
251
|
+
|
|
252
|
+
| Name | Type | Default | Description |
|
|
253
|
+
| --- | --- | --- | --- |
|
|
254
|
+
| `aria-label` | `string` | `""` | Accessible label for the color palette grid. |
|
|
255
|
+
| `aria-labelledby` | `string` | `""` | Id of the element that names the color palette grid. |
|
|
256
|
+
| `clearable` | `boolean` | `true` | Whether activating the selected tile clears the value. A required palette never clears. |
|
|
257
|
+
| `columns` | `number` | `10` | The number of columns in the color palette grid. Only applicable when using a custom palette. A value below 1 shows one column. |
|
|
258
|
+
| `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. |
|
|
259
|
+
| `invalid` | `boolean` | `false` | Marks the color palette as invalid. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
260
|
+
| `palette` | `PaletteType \| Iterable<string \| ColorPaletteItem>` | `[]` | The palette to display — one of the built-in `"flat"`, `"material"`, or `"websafe"` schemes, or a custom iterable of colors. A custom color is a CSS color string, or a `{ color, name }` item when it has a name of its own. An empty custom palette falls back to the flat scheme. |
|
|
261
|
+
| `readonly` | `boolean` | `false` | Prevents value changes while preserving the component's visual state. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
262
|
+
| `required` | `boolean` | `false` | Sets whether the color palette is required. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
263
|
+
| `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"none"` | Border-radius preset applied to the color palette items. |
|
|
264
|
+
| `tileSize` | `number` | `24` | The size of each tile in the color palette grid, in pixels. Below 24, tiles miss the minimum target size of WCAG 2.5.8. |
|
|
265
|
+
| `touched` | `boolean` | `false` | Sets the touched state of the color palette. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
266
|
+
| `value` (two-way) | `string \| null` | `null` | Two-way bindable current color value. |
|
|
267
|
+
|
|
268
|
+
#### Outputs
|
|
269
|
+
|
|
270
|
+
| Name | Type | Description |
|
|
271
|
+
| --- | --- | --- |
|
|
272
|
+
| `colorSelect` | `string` | Emitted with the tile's color each time a tile is activated, also when it's already selected, which doesn't change `value`. |
|
|
273
|
+
| `touch` | `void` | Emitted when focus leaves the color palette or a color is selected. The `FormField` directive listens to this to mark the field as touched. |
|
|
274
|
+
| `valueChange` | `string \| null` | Emitted when `value` changes. |
|
|
275
|
+
|
|
276
|
+
#### Methods
|
|
277
|
+
|
|
278
|
+
| Signature | Description |
|
|
279
|
+
| --- | --- |
|
|
280
|
+
| `focus(options?: FocusOptions): void` | Moves focus to the palette's active tile. |
|
|
281
|
+
|
|
282
|
+
### Types
|
|
283
|
+
|
|
284
|
+
#### `COLOR_PALETTE_DEFAULT_MESSAGES`
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
const COLOR_PALETTE_DEFAULT_MESSAGES: MonaColorPaletteMessages;
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### `ColorPaletteItem`
|
|
291
|
+
|
|
292
|
+
From `@nanahoshi/mona-ui/common`.
|
|
293
|
+
|
|
294
|
+
A swatch with a name of its own, for a palette whose colors mean something, such as brand colors.
|
|
295
|
+
|
|
296
|
+
| Name | Type | Description |
|
|
297
|
+
| --- | --- | --- |
|
|
298
|
+
| `color` (read-only) | `string` | Any CSS color. |
|
|
299
|
+
| `name?` (read-only) | `string` | What the color is called. Assistive technology reads it, and it shows as a tooltip. |
|
|
300
|
+
|
|
301
|
+
#### `MonaColorPaletteMessages`
|
|
302
|
+
|
|
303
|
+
From `@nanahoshi/mona-ui/i18n`.
|
|
304
|
+
|
|
305
|
+
| Name | Type |
|
|
306
|
+
| --- | --- |
|
|
307
|
+
| `color` (read-only) | `(color: string) => string` |
|
|
308
|
+
| `colorPalette` (read-only) | `string` |
|
|
309
|
+
| `namedColor` (read-only) | `(name: string, color: string) => string` |
|
|
310
|
+
|
|
311
|
+
#### `PaletteType`
|
|
312
|
+
|
|
313
|
+
From `@nanahoshi/mona-ui/common`.
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
type PaletteType = "flat" | "material" | "websafe";
|
|
317
|
+
```
|