@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.
- package/README.md +2 -0
- package/chart/README.md +2 -2
- 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-bar.md +714 -0
- package/docs/chart-financial.md +567 -0
- package/docs/chart-funnel.md +546 -0
- package/docs/chart-heatmap.md +535 -0
- package/docs/chart-line-area.md +462 -0
- package/docs/chart-pie.md +645 -0
- package/docs/chart-radar.md +518 -0
- package/docs/chart-radial.md +658 -0
- package/docs/chart-scatter.md +479 -0
- package/docs/chart-treemap.md +651 -0
- package/docs/chart.md +2465 -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 +212 -66
- 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 +133 -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 +250 -20
- 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
package/docs/forms.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Forms
|
|
2
|
+
|
|
3
|
+
> Connect Mona UI controls to Angular signal forms.
|
|
4
|
+
|
|
5
|
+
This guide covers what the form controls have in common: binding them to a form, naming them, and the states they share. Each control's own page has its inputs and limits.
|
|
6
|
+
|
|
7
|
+
The controls covered here are check box, radio button and radio group, switch, text area, text box, OTP input, rating, slider and range slider, segmented, color palette, color picker and color gradient.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Binding to a Form
|
|
12
|
+
|
|
13
|
+
The controls implement Angular's `FormValueControl` or `FormCheckboxControl`, so `[formField]` from `@angular/forms/signals` reads and writes their value and hands them their state.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Component, signal } from "@angular/core";
|
|
17
|
+
import { form, FormField, required } from "@angular/forms/signals";
|
|
18
|
+
import { LabelComponent } from "@nanahoshi/mona-ui/label";
|
|
19
|
+
import { SwitchComponent } from "@nanahoshi/mona-ui/switch";
|
|
20
|
+
import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
|
|
21
|
+
|
|
22
|
+
@Component({
|
|
23
|
+
selector: "app-profile",
|
|
24
|
+
imports: [FormField, LabelComponent, SwitchComponent, TextBoxComponent],
|
|
25
|
+
template: `
|
|
26
|
+
<mona-label text="Name">
|
|
27
|
+
<mona-text-box [formField]="profile.name"></mona-text-box>
|
|
28
|
+
</mona-label>
|
|
29
|
+
<mona-label text="Send me updates">
|
|
30
|
+
<mona-switch [formField]="profile.updates"></mona-switch>
|
|
31
|
+
</mona-label>
|
|
32
|
+
`
|
|
33
|
+
})
|
|
34
|
+
export class ProfileComponent {
|
|
35
|
+
protected readonly model = signal({ name: "", updates: false });
|
|
36
|
+
protected readonly profile = form(this.model, path => {
|
|
37
|
+
required(path.name);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Without a form, use the control's two-way binding: `[(value)]`, or `[(checked)]` on a check box or switch.
|
|
43
|
+
|
|
44
|
+
`[ngModel]`, `[formControl]` and `formControlName` work too. These controls have no `ControlValueAccessor`, but Angular binds their `value` or `checked` and their `touch` directly when there isn't one. Prefer `[formField]`, which also hands them `disabled`, `readonly`, `required` and validation state.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 2. Naming a Control
|
|
49
|
+
|
|
50
|
+
Every control needs a name that assistive technology can read. There are four ways to give one.
|
|
51
|
+
|
|
52
|
+
**Wrap it in a label.** The label's `text` names the control, and a click on it reaches the control. Only `text` can do this, because text projected next to the control can't be referenced without pulling in the control's own content. A wrapped control with no `text` warns in development.
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<mona-label text="Volume">
|
|
56
|
+
<mona-slider [(value)]="volume"></mona-slider>
|
|
57
|
+
</mona-label>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Point a label at it with `[for]` and a reference.** Use this when the label and the control can't be nested.
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<mona-label text="Volume" [for]="volumeSlider"></mona-label>
|
|
64
|
+
<mona-slider #volumeSlider [(value)]="volume"></mona-slider>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Point a label at a native input with `for` and an id.** A string only works for an element that has that id and can be labelled. On a component's host it can't work, so it warns in development. Use `[for]` with a reference, or `inputId` where the control has one.
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<mona-label text="Email" for="email"></mona-label> <mona-text-box inputId="email" [(value)]="email"></mona-text-box>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Name it directly.** Use `aria-label` when there's no visible label, or `aria-labelledby` for one you've written yourself.
|
|
74
|
+
|
|
75
|
+
If more than one applies, an explicit `aria-labelledby` wins, and then `aria-label`, which turns off any label.
|
|
76
|
+
|
|
77
|
+
### Which control takes what
|
|
78
|
+
|
|
79
|
+
| Control | Wrap in `mona-label` | `[for]="ref"` | `aria-label`, `aria-labelledby` | `inputId` | Its own `label` |
|
|
80
|
+
| ------------------------------------------------ | ------------------------- | ------------- | ------------------------------- | --------- | --------------- |
|
|
81
|
+
| `mona-check-box` | No | Yes | Yes | Yes | Yes |
|
|
82
|
+
| `mona-radio-button` | No | Yes | Yes | Yes | Yes |
|
|
83
|
+
| `mona-radio-group` | Yes | Yes | Yes | No | No |
|
|
84
|
+
| `mona-switch` | Yes | Yes | Yes | No | No |
|
|
85
|
+
| `mona-text-box` | Yes | Yes | Yes | Yes | No |
|
|
86
|
+
| `mona-otp-input` | Yes | Yes | Yes | Yes | No |
|
|
87
|
+
| `mona-rating` | Yes | Yes | Yes | No | Yes |
|
|
88
|
+
| `mona-slider` | Yes | Yes | Yes | No | No |
|
|
89
|
+
| `mona-range-slider` | Yes | Yes | Yes | No | No |
|
|
90
|
+
| `mona-segmented` | Yes | Yes | Yes | No | No |
|
|
91
|
+
| `mona-color-palette` | Yes | Yes | Yes | No | No |
|
|
92
|
+
| `mona-color-picker` | Yes | Yes | Yes | No | No |
|
|
93
|
+
| `mona-color-gradient` | Yes | Yes | Yes | No | No |
|
|
94
|
+
| `mona-numeric-text-box`, `mona-decimal-text-box` | Yes, named by the browser | Focus only | Yes | Yes | No |
|
|
95
|
+
| `mona-date-picker` | Yes | Focus only | Yes | Yes | No |
|
|
96
|
+
| `mona-dropdown-list` | No | Focus only | Yes | No | No |
|
|
97
|
+
|
|
98
|
+
A check box and a radio button render their own `<label>`, and its text has to stay their name, so a wrapping `mona-label` doesn't name them. Use their `label` input, or `[for]` from outside.
|
|
99
|
+
|
|
100
|
+
A text area is a directive on a native `<textarea>`, so a label's `for` and an `id` work as they do for any native element.
|
|
101
|
+
|
|
102
|
+
"Focus only" means `[for]` makes a click on the label focus the control, but doesn't name it. Name those controls with `inputId` and a string `for`, by wrapping them where the table says yes, or with `aria-labelledby` pointing at the label's `id`. A dropdown list has no native input, so `aria-labelledby` or `aria-label` is the only way to name it. The other dropdowns and pickers have their own pages; see each one for how to name it.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 3. Shared States
|
|
107
|
+
|
|
108
|
+
| State | What it does |
|
|
109
|
+
| ---------- | ---------------------------------------------------------------------------------------------- |
|
|
110
|
+
| `disabled` | Removes the control from the tab order and stops changes. |
|
|
111
|
+
| `readonly` | The control keeps focus and shows its value, but the value can't change. |
|
|
112
|
+
| `required` | Tells assistive technology and validation, where the control's role allows it. |
|
|
113
|
+
| `invalid` | Shows an error once `touched` is also true, so a field isn't red before anyone has reached it. |
|
|
114
|
+
| `touched` | Set by a form when the control is left. `(touch)` reports that moment. |
|
|
115
|
+
|
|
116
|
+
`[formField]` sets all of these from the form. Set by hand, they work without one.
|
|
117
|
+
|
|
118
|
+
`touch` fires when focus leaves the control, so moving between a group's own parts doesn't count as leaving.
|
|
119
|
+
|
|
120
|
+
Some controls can't offer everything:
|
|
121
|
+
|
|
122
|
+
- **Range slider:** no `required`, because `aria-required` isn't allowed on role `slider`. Its value also can't take `min` and `max` from a form rule, since those are typed for a single number.
|
|
123
|
+
- **Switch, rating, sliders, color picker and color gradient:** no `name`, since they have no native input to give it to.
|
|
124
|
+
- **Check box and radio button directives:** `input[monaCheckbox]` and `input[monaRadioButton]` have no `readonly`, because native check boxes and radios ignore it.
|
|
125
|
+
- **Rating:** `required` shows the error state at `0` once touched, but the signal forms `required` rule doesn't treat `0` as empty. To fail the form, use `min(path, 1)`.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 4. Disabling a Section
|
|
130
|
+
|
|
131
|
+
`mona-fieldset` with `disabled` disables the controls inside it. Native controls follow the browser's rule, and the controls above follow through a shared token, which also reaches text box, dropdowns and date pickers.
|
|
132
|
+
|
|
133
|
+
Three things it doesn't do:
|
|
134
|
+
|
|
135
|
+
- Controls in the fieldset's first legend stay enabled for the native rule, but not for the token, which doesn't exempt them.
|
|
136
|
+
- The token doesn't reach through a plain native `<fieldset disabled>`. Only `mona-fieldset` provides it.
|
|
137
|
+
- The fields stay enabled in the form model, so a disabled section is still validated and submitted. Use the form's `disabled()` rule to change that.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 5. Focusing the First Invalid Field
|
|
142
|
+
|
|
143
|
+
Each control has a public `focus()`, so `field().focusBoundControl()` from signal forms moves focus to it.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 6. Radio Groups
|
|
148
|
+
|
|
149
|
+
Use `mona-radio-group`. It gives the radios a shared name, a shared value, arrow keys and one Tab stop, and it holds `required` and the group's name.
|
|
150
|
+
|
|
151
|
+
```html
|
|
152
|
+
<mona-label text="Delivery">
|
|
153
|
+
<mona-radio-group [formField]="order.delivery">
|
|
154
|
+
<mona-radio-button radioValue="standard" label="Standard"></mona-radio-button>
|
|
155
|
+
<mona-radio-button radioValue="express" label="Express"></mona-radio-button>
|
|
156
|
+
</mona-radio-group>
|
|
157
|
+
</mona-label>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
A radio with its own `[formField]` inside a group isn't supported, since the group's value wins. Standalone radios still work without a group, as long as they share a `name` and a value.
|
|
161
|
+
|
|
162
|
+
To choose among a few options with a button look, use `mona-segmented`. `mona-button-group` is a toggle group, not a radio group: it has `aria-pressed` and Tab, not arrow keys.
|