@nanahoshi/mona-ui 0.29.0 → 0.31.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/docs/api/button-group.md +1 -0
- package/docs/api/color-gradient.md +1 -0
- package/docs/api/color-palette.md +1 -0
- package/docs/api/color-picker.md +1 -0
- package/docs/api/form-field.md +88 -0
- package/docs/api/i18n.md +44 -0
- package/docs/api/locales.md +14 -14
- package/docs/api/qr-code.md +287 -0
- package/docs/api/segmented.md +1 -0
- package/docs/api/switch.md +1 -0
- package/docs/dropdown-list.md +1 -1
- package/docs/form-field.md +425 -0
- package/docs/forms.md +12 -4
- package/docs/label.md +4 -5
- package/docs/numeric-textbox.md +1 -1
- package/docs/qr-code.md +377 -0
- package/docs/radio-button.md +2 -1
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +15 -4
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +25 -1
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +29 -3
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +25 -1
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +31 -3
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +15 -4
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +15 -4
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +15 -4
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +19 -7
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +24 -4
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-form-field.mjs +666 -0
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +27 -2
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +28 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +24 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +24 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +19 -7
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +14 -5
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +6 -3
- package/fesm2022/nanahoshi-mona-ui-qr-code.mjs +1671 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +15 -9
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +6 -3
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +25 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +25 -1
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +6 -3
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +15 -4
- package/form-field/package.json +4 -0
- package/i18n/catalogs/en-US.messages.json +16 -0
- package/llms.txt +5 -1
- package/locales/ar-sa/ar-sa.messages.json +16 -0
- package/locales/de-de/de-de.messages.json +16 -0
- package/locales/es-es/es-es.messages.json +16 -0
- package/locales/fr-fr/fr-fr.messages.json +16 -0
- package/locales/id-id/id-id.messages.json +16 -0
- package/locales/it-it/it-it.messages.json +16 -0
- package/locales/ja-jp/ja-jp.messages.json +16 -0
- package/locales/ko-kr/ko-kr.messages.json +16 -0
- package/locales/pl-pl/pl-pl.messages.json +16 -0
- package/locales/pt-br/pt-br.messages.json +16 -0
- package/locales/ru-ru/ru-ru.messages.json +16 -0
- package/locales/tr-tr/tr-tr.messages.json +16 -0
- package/locales/zh-cn/zh-cn.messages.json +16 -0
- package/locales/zh-tw/zh-tw.messages.json +16 -0
- package/package.json +9 -1
- package/qr-code/package.json +4 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +2 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +11 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +11 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +11 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +11 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +2 -0
- package/types/nanahoshi-mona-ui-form-field.d.ts +173 -0
- package/types/nanahoshi-mona-ui-i18n.d.ts +33 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +39 -4
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +16 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +2 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-qr-code.d.ts +322 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +2 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +1 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +11 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +1 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +11 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -0
package/docs/qr-code.md
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# QR Code
|
|
2
|
+
|
|
3
|
+
> Encodes text or a URL as a scannable QR code, with logo overlays and PNG, SVG and PDF export.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/qr-code`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-qr-code`
|
|
8
|
+
|
|
9
|
+
`QrCodeComponent` encodes text, such as a URL, a Wi-Fi login or payment data, as a QR code drawn in SVG. It picks the smallest code and the densest modes for the value, can draw a logo or the Swiss cross over the center, and exports the code as a PNG, SVG or PDF file.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
A QR code lets someone carry a value from a screen or a printout to their phone by pointing the camera at it. Use it for what's tedious to type: a link, a Wi-Fi login, a ticket or a payment.
|
|
14
|
+
|
|
15
|
+
**Use `QrCodeComponent` when you need to:**
|
|
16
|
+
|
|
17
|
+
- Hand a link or a short text to a phone, on screen or on paper
|
|
18
|
+
- Print codes in labels, tickets or invoices, from an exported PNG, SVG or PDF
|
|
19
|
+
- Brand a code with a logo, or draw the Swiss cross of a Swiss QR-bill
|
|
20
|
+
|
|
21
|
+
**Show the value as text as well when:**
|
|
22
|
+
|
|
23
|
+
- Someone may not be able to scan, such as a screen reader user or someone on the device the code opens on. A link next to the code serves both.
|
|
24
|
+
|
|
25
|
+
## Import & Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { QrCodeComponent } from "@nanahoshi/mona-ui/qr-code";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Add `QrCodeComponent` to your standalone component's `imports` array, and give the code a `value` and a name that says what it's for:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<mona-qr-code value="https://nanahoshi.dev/mona-ui" aria-label="QR code for the Mona UI docs" />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Logo overlay
|
|
40
|
+
|
|
41
|
+
`overlay` draws an image over the center, sized by `size` as a share of the code's width, 0.2 by default. The image keeps its aspect ratio. The modules beneath it are cleared rather than covered, so error correction has to make up for them: use `errorCorrection="H"`, which recovers the most. With an overlay, the code is at least version 2, since version 1 has no room for one.
|
|
42
|
+
|
|
43
|
+
`logo-example.component.ts`
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { Component } from "@angular/core";
|
|
47
|
+
import { QrCodeComponent, type QrCodeOverlay } from "@nanahoshi/mona-ui/qr-code";
|
|
48
|
+
|
|
49
|
+
const LOGO_SVG =
|
|
50
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#4338ca"/>` +
|
|
51
|
+
`<path d="M32 10 37.6 26.4 54 32 37.6 37.6 32 54 26.4 37.6 10 32 26.4 26.4Z" fill="#fff"/></svg>`;
|
|
52
|
+
|
|
53
|
+
@Component({
|
|
54
|
+
selector: "app-qr-code-logo-example",
|
|
55
|
+
imports: [QrCodeComponent],
|
|
56
|
+
templateUrl: "./logo-example.component.html"
|
|
57
|
+
})
|
|
58
|
+
export class QrCodeLogoExampleComponent {
|
|
59
|
+
protected readonly logo: QrCodeOverlay = {
|
|
60
|
+
size: 0.22,
|
|
61
|
+
src: `data:image/svg+xml,${encodeURIComponent(LOGO_SVG)}`,
|
|
62
|
+
type: "image"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`logo-example.component.html`
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<mona-qr-code
|
|
71
|
+
aria-label="QR code for the Mona UI docs"
|
|
72
|
+
errorCorrection="H"
|
|
73
|
+
value="https://nanahoshi.dev/mona-ui"
|
|
74
|
+
[overlay]="logo" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
In development, the component warns when the overlay hides more of some error correction block than it can recover. The check counts every codeword under the cleared square as lost, so a code it warns about may still scan, but one it accepts has the correction to spare. Test the codes you print with the readers your users have.
|
|
78
|
+
|
|
79
|
+
### Swiss QR code
|
|
80
|
+
|
|
81
|
+
`{ type: "swiss" }` draws the Swiss cross of a Swiss QR-bill, at 7/46 of the code as the standard sets. The payment data is the `value`, one field a line, as the Swiss Implementation Guidelines lay it out. The component draws the code and the cross; it doesn't check the fields. The standard asks for error correction `"M"`, the default.
|
|
82
|
+
|
|
83
|
+
`swiss-example.component.ts`
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { Component } from "@angular/core";
|
|
87
|
+
import { QrCodeComponent, type QrCodeOverlay } from "@nanahoshi/mona-ui/qr-code";
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A Swiss QR-bill's payment data, one field a line, as the Swiss Implementation Guidelines lay it out. The creditor,
|
|
91
|
+
* account and invoice are made up.
|
|
92
|
+
*/
|
|
93
|
+
const PAYMENT = [
|
|
94
|
+
"SPC",
|
|
95
|
+
"0200",
|
|
96
|
+
"1",
|
|
97
|
+
"CH5604835012345678009",
|
|
98
|
+
"S",
|
|
99
|
+
"Example Ltd",
|
|
100
|
+
"Bundesplatz",
|
|
101
|
+
"3",
|
|
102
|
+
"3003",
|
|
103
|
+
"Bern",
|
|
104
|
+
"CH",
|
|
105
|
+
...Array<string>(7).fill(""),
|
|
106
|
+
"120.00",
|
|
107
|
+
"CHF",
|
|
108
|
+
...Array<string>(7).fill(""),
|
|
109
|
+
"NON",
|
|
110
|
+
"",
|
|
111
|
+
"Invoice 2026-114",
|
|
112
|
+
"EPD"
|
|
113
|
+
].join("\n");
|
|
114
|
+
|
|
115
|
+
@Component({
|
|
116
|
+
selector: "app-qr-code-swiss-example",
|
|
117
|
+
imports: [QrCodeComponent],
|
|
118
|
+
templateUrl: "./swiss-example.component.html"
|
|
119
|
+
})
|
|
120
|
+
export class QrCodeSwissExampleComponent {
|
|
121
|
+
protected readonly payment = PAYMENT;
|
|
122
|
+
protected readonly swissCross: QrCodeOverlay = { type: "swiss" };
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`swiss-example.component.html`
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<mona-qr-code
|
|
130
|
+
aria-label="Swiss QR code for invoice 2026-114"
|
|
131
|
+
errorCorrection="M"
|
|
132
|
+
[overlay]="swissCross"
|
|
133
|
+
[value]="payment" />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Export
|
|
137
|
+
|
|
138
|
+
`exportQrCode()` resolves to a `Blob` of a PNG image, an SVG document or a PDF page, and `downloadQrCode()` saves one as a file. Get the component through a template reference with `#qrCode="monaQrCode"`, or with `viewChild(QrCodeComponent)`.
|
|
139
|
+
|
|
140
|
+
`export-example.component.ts`
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { Component, signal } from "@angular/core";
|
|
144
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
145
|
+
import { QrCodeComponent, QrCodeExportError, type QrCodeExportFormat } from "@nanahoshi/mona-ui/qr-code";
|
|
146
|
+
|
|
147
|
+
@Component({
|
|
148
|
+
selector: "app-qr-code-export-example",
|
|
149
|
+
imports: [ButtonDirective, QrCodeComponent],
|
|
150
|
+
templateUrl: "./export-example.component.html"
|
|
151
|
+
})
|
|
152
|
+
export class QrCodeExportExampleComponent {
|
|
153
|
+
protected readonly formats: readonly QrCodeExportFormat[] = ["png", "svg", "pdf"];
|
|
154
|
+
protected readonly status = signal("");
|
|
155
|
+
|
|
156
|
+
protected async download(qrCode: QrCodeComponent, format: QrCodeExportFormat): Promise<void> {
|
|
157
|
+
try {
|
|
158
|
+
const { blob } = await qrCode.downloadQrCode({ fileName: "guest-wifi", format, size: 512 });
|
|
159
|
+
this.status.set(`Saved guest-wifi.${format}, ${Math.ceil(blob.size / 1024)} KB.`);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
this.status.set(error instanceof QrCodeExportError ? error.message : "The export failed.");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`export-example.component.html`
|
|
168
|
+
|
|
169
|
+
```html
|
|
170
|
+
<div class="flex flex-col items-start gap-3">
|
|
171
|
+
<mona-qr-code
|
|
172
|
+
#qrCode="monaQrCode"
|
|
173
|
+
aria-label="QR code that joins the guest Wi-Fi"
|
|
174
|
+
value="WIFI:T:WPA;S:Guest;P:welcome-2026;;" />
|
|
175
|
+
<div class="flex gap-2">
|
|
176
|
+
@for (format of formats; track format) {
|
|
177
|
+
<button monaButton type="button" (click)="download(qrCode, format)">
|
|
178
|
+
Download {{ format.toUpperCase() }}
|
|
179
|
+
</button>
|
|
180
|
+
}
|
|
181
|
+
</div>
|
|
182
|
+
<p aria-live="polite" class="text-sm text-muted-foreground">{{ status() }}</p>
|
|
183
|
+
</div>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
| Format | What it is | Notes |
|
|
187
|
+
|--------|------------|-------|
|
|
188
|
+
| `"svg"` | A standalone vector document | Sharp at any size, for print and design tools. The overlay image is embedded as a data URL, and the accessible name becomes its `<title>`. |
|
|
189
|
+
| `"png"` | A raster image `size` pixels wide | Every module is a whole number of pixels, and what's left over widens the quiet zone, so the edges stay sharp. It needs at least one pixel per module. |
|
|
190
|
+
| `"pdf"` | One page, `size` CSS pixels wide | Needs the `jspdf` package, which isn't installed with Mona UI. The modules are vector shapes; an overlay image is embedded as a PNG. |
|
|
191
|
+
|
|
192
|
+
`size` defaults to the code's rendered width. Colors are resolved to what they paint, so `var()` and `currentColor` export as the color you see. An overlay image from another origin has to allow reading with CORS, or the export rejects. Every failure is a `QrCodeExportError` whose `code` says why, such as `"not-ready"` when there's no code to export or `"invalid-size"` for a PNG too small for its modules.
|
|
193
|
+
|
|
194
|
+
## Appearance & Styling
|
|
195
|
+
|
|
196
|
+
`appearance-example.component.ts`
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { Component } from "@angular/core";
|
|
200
|
+
import { QrCodeComponent } from "@nanahoshi/mona-ui/qr-code";
|
|
201
|
+
|
|
202
|
+
@Component({
|
|
203
|
+
selector: "app-qr-code-appearance-example",
|
|
204
|
+
imports: [QrCodeComponent],
|
|
205
|
+
templateUrl: "./appearance-example.component.html"
|
|
206
|
+
})
|
|
207
|
+
export class QrCodeAppearanceExampleComponent {
|
|
208
|
+
protected readonly link = "https://nanahoshi.dev/mona-ui";
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`appearance-example.component.html`
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<div class="flex flex-wrap items-end gap-6">
|
|
216
|
+
<mona-qr-code aria-label="QR code for the Mona UI docs" [size]="96" [value]="link" />
|
|
217
|
+
<mona-qr-code aria-label="QR code for the Mona UI docs" color="#1e3a8a" background="#eff6ff" [value]="link" />
|
|
218
|
+
<div class="w-40 rounded-lg bg-white p-3 shadow-sm">
|
|
219
|
+
<mona-qr-code
|
|
220
|
+
aria-label="QR code for the Mona UI docs"
|
|
221
|
+
background="transparent"
|
|
222
|
+
size="100%"
|
|
223
|
+
[quietZone]="0"
|
|
224
|
+
[value]="link" />
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Size
|
|
230
|
+
|
|
231
|
+
`size` sets the width and height, quiet zone included. A number is pixels, and a string is any CSS length, such as `"100%"` to fill a container. The host stays square, and it never grows wider than its container, so a fixed size shrinks on a narrow screen instead of overflowing.
|
|
232
|
+
|
|
233
|
+
### Colors
|
|
234
|
+
|
|
235
|
+
`color` paints the dark modules and `background` the light ones and the quiet zone. Both take any CSS color, including theme tokens such as `var(--color-foreground)`.
|
|
236
|
+
|
|
237
|
+
The defaults are black on white in every theme, because readers need dark modules on a light background with strong contrast between them. A light-on-dark code only reads on some readers. `background="transparent"` lets the page show through, which suits a light card but not a dark one.
|
|
238
|
+
|
|
239
|
+
### Quiet zone
|
|
240
|
+
|
|
241
|
+
`quietZone` is the light border around the code, in modules. Readers look for 4, the default. Reduce it only where the surroundings are light anyway, such as on a white card with its own padding.
|
|
242
|
+
|
|
243
|
+
### Custom class
|
|
244
|
+
|
|
245
|
+
Merge Tailwind or custom classes onto the host with `class`, such as `class="rounded-md shadow-sm"`.
|
|
246
|
+
|
|
247
|
+
## Behavior
|
|
248
|
+
|
|
249
|
+
### Encoding and capacity
|
|
250
|
+
|
|
251
|
+
The component chooses the smallest of the 40 QR code versions that holds the value, from 21 modules a side to 177. It splits the value into numeric, alphanumeric and byte segments where switching modes saves space, so a long run of digits, like an order number, takes less room than the same count of letters.
|
|
252
|
+
|
|
253
|
+
| `encoding` | Stores | Notes |
|
|
254
|
+
|------------|--------|-------|
|
|
255
|
+
| `"utf-8"` | Any text | The default. Text with characters outside ASCII starts with an ECI header that tells readers it's UTF-8. ASCII needs no header. |
|
|
256
|
+
| `"iso-8859-1"` | Latin-1 only | What readers assume when there's no header. Some older readers don't support ECI; others read every value as UTF-8, so non-ASCII Latin-1 text can come out garbled there. |
|
|
257
|
+
|
|
258
|
+
A version 40 code holds up to 2,953 bytes, 4,296 alphanumeric characters or 7,089 digits at error correction `"L"`, and less at higher levels. A value it can't hold, or a character the encoding can't store, draws nothing. `error` then says why, and a warning is logged in development.
|
|
259
|
+
|
|
260
|
+
### Error correction
|
|
261
|
+
|
|
262
|
+
| `errorCorrection` | Recovers about | Use it for |
|
|
263
|
+
|-------------------|----------------|------------|
|
|
264
|
+
| `"L"` | 7% | The most data in the smallest code, shown clean on a screen |
|
|
265
|
+
| `"M"` | 15% | Most codes. The default. |
|
|
266
|
+
| `"Q"` | 25% | Codes that get worn or dirty, such as on packaging |
|
|
267
|
+
| `"H"` | 30% | Codes with a logo overlay |
|
|
268
|
+
|
|
269
|
+
A higher level holds less, so the same value needs a larger code.
|
|
270
|
+
|
|
271
|
+
### Rendering
|
|
272
|
+
|
|
273
|
+
The code is SVG: a rectangle for the background and one path for every dark module, drawn with `crispEdges` so modules meet without hairlines. It stays sharp at any zoom and in print, costs a handful of elements whatever the code's size, and scales with its box without being redrawn. There's no canvas mode; the PNG export draws to a canvas when you need a raster image.
|
|
274
|
+
|
|
275
|
+
### Forced colors
|
|
276
|
+
|
|
277
|
+
The component opts out of forced colors with `forced-color-adjust: none`, because a code the system recolors may not scan. It keeps the colors you set, which is why the default background is white rather than transparent.
|
|
278
|
+
|
|
279
|
+
## Forms Integration
|
|
280
|
+
|
|
281
|
+
The component displays a value rather than editing one, so it isn't a form control. To check a field before its value reaches the code, use `validateQrCodeValue()`, with the same `encoding` and `errorCorrection` as the component. It returns why the value can't be encoded, or `null`, without drawing anything, so it can run on every keystroke in a signal form's `validate()`.
|
|
282
|
+
|
|
283
|
+
`validation-example.component.ts`
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import { Component, signal } from "@angular/core";
|
|
287
|
+
import { form, FormField, validate } from "@angular/forms/signals";
|
|
288
|
+
import { LabelComponent } from "@nanahoshi/mona-ui/label";
|
|
289
|
+
import { QrCodeComponent, validateQrCodeValue } from "@nanahoshi/mona-ui/qr-code";
|
|
290
|
+
import { TextBoxComponent } from "@nanahoshi/mona-ui/text-box";
|
|
291
|
+
|
|
292
|
+
@Component({
|
|
293
|
+
selector: "app-qr-code-validation-example",
|
|
294
|
+
imports: [FormField, LabelComponent, QrCodeComponent, TextBoxComponent],
|
|
295
|
+
templateUrl: "./validation-example.component.html"
|
|
296
|
+
})
|
|
297
|
+
export class QrCodeValidationExampleComponent {
|
|
298
|
+
readonly #model = signal({ label: "Café Zürich, table 12" });
|
|
299
|
+
// The label printer's scanner reads Latin-1 only, so the codes are stored without a UTF-8 header.
|
|
300
|
+
protected readonly shelf = form(this.#model, path => {
|
|
301
|
+
validate(path.label, ({ value }) => {
|
|
302
|
+
const error = validateQrCodeValue(value(), { encoding: "iso-8859-1" });
|
|
303
|
+
switch (error?.code) {
|
|
304
|
+
case "unsupported-character":
|
|
305
|
+
return { kind: "qrCode", message: `The scanner can't read "${error.character}". Remove it.` };
|
|
306
|
+
case "too-long":
|
|
307
|
+
return { kind: "qrCode", message: "This is too long for a QR code. Shorten it." };
|
|
308
|
+
default:
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
`validation-example.component.html`
|
|
317
|
+
|
|
318
|
+
```html
|
|
319
|
+
<div class="flex max-w-sm flex-col items-start gap-3">
|
|
320
|
+
<mona-label text="Label text">
|
|
321
|
+
<mona-text-box aria-describedby="qr-code-label-error" [formField]="shelf.label" />
|
|
322
|
+
</mona-label>
|
|
323
|
+
<p aria-live="polite" class="text-sm text-error" id="qr-code-label-error">
|
|
324
|
+
@for (error of shelf.label().errors(); track error.kind) {
|
|
325
|
+
{{ error.message }}
|
|
326
|
+
}
|
|
327
|
+
</p>
|
|
328
|
+
@if (shelf.label().valid()) {
|
|
329
|
+
<mona-qr-code
|
|
330
|
+
encoding="iso-8859-1"
|
|
331
|
+
[aria-label]="'QR code for ' + shelf.label().value()"
|
|
332
|
+
[value]="shelf.label().value()" />
|
|
333
|
+
}
|
|
334
|
+
</div>
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Accessibility
|
|
338
|
+
|
|
339
|
+
The host has `role="img"` while there's a code to show, named by `aria-label`, or by the localized "QR code" when it's empty. The SVG inside is hidden from assistive technology. With nothing to show, the host has neither, so an empty box isn't announced as an image.
|
|
340
|
+
|
|
341
|
+
Consumer responsibilities:
|
|
342
|
+
|
|
343
|
+
- Set `aria-label` to say what scanning the code does, such as "QR code for the event page". "QR code" alone doesn't say where it leads.
|
|
344
|
+
- Show what the code holds as text or a link nearby, for those who can't scan it.
|
|
345
|
+
- Keep strong contrast between `color` and `background`; readers need it more than people do.
|
|
346
|
+
|
|
347
|
+
## API
|
|
348
|
+
|
|
349
|
+
Everything below is imported from `@nanahoshi/mona-ui/qr-code`. Each name links to its reference page, with every input, output, property and method.
|
|
350
|
+
|
|
351
|
+
| Name | Kind | Description |
|
|
352
|
+
| --- | --- | --- |
|
|
353
|
+
| [`QrCodeComponent`](api/qr-code.md#qrcodecomponent) | Component | Draws a value as a QR code in SVG, and exports it as a PNG, SVG or PDF file. |
|
|
354
|
+
| [`QrCodeExportError`](api/qr-code.md#qrcodeexporterror) | Class | The error a QR code export rejects with. |
|
|
355
|
+
| [`validateQrCodeValue`](api/qr-code.md#validateqrcodevalue) | Function | Checks whether a QR code can hold a value with the given settings, without drawing it: every character has to fit the encoding, and the whole value the largest code. |
|
|
356
|
+
|
|
357
|
+
### Types
|
|
358
|
+
|
|
359
|
+
| Type | Kind | Description |
|
|
360
|
+
| --- | --- | --- |
|
|
361
|
+
| [`QR_CODE_DEFAULT_MESSAGES`](api/qr-code.md#qr-code-default-messages) | Constant | |
|
|
362
|
+
| [`QrCodeDownloadOptions`](api/qr-code.md#qrcodedownloadoptions) | Interface | What to export a QR code as, and the name of the file to save. |
|
|
363
|
+
| [`QrCodeExportOptions`](api/qr-code.md#qrcodeexportoptions) | Interface | What to export a QR code as. |
|
|
364
|
+
| [`QrCodeExportResult`](api/qr-code.md#qrcodeexportresult) | Interface | An exported QR code. |
|
|
365
|
+
| [`QrCodeImageOverlay`](api/qr-code.md#qrcodeimageoverlay) | Interface | An image, such as a logo, drawn over the center of the code. |
|
|
366
|
+
| [`QrCodeSwissOverlay`](api/qr-code.md#qrcodeswissoverlay) | Interface | The Swiss cross of a Swiss QR code, the code on a Swiss QR-bill, drawn over the center at the size the standard sets. |
|
|
367
|
+
| [`QrCodeTooLongError`](api/qr-code.md#qrcodetoolongerror) | Interface | A value too long for the largest QR code (version 40) at the chosen error correction level. |
|
|
368
|
+
| [`QrCodeUnsupportedCharacterError`](api/qr-code.md#qrcodeunsupportedcharactererror) | Interface | A character the chosen encoding can't store, such as `€` in `"iso-8859-1"`. |
|
|
369
|
+
| [`QrCodeValidationOptions`](api/qr-code.md#qrcodevalidationoptions) | Interface | The settings a value is checked against, matching the component's inputs of the same names. |
|
|
370
|
+
| [`QrCodeEncoding`](api/qr-code.md#qrcodeencoding) | Type alias | The character set a QR code stores text in. - `"utf-8"`: any text. |
|
|
371
|
+
| [`QrCodeErrorCorrection`](api/qr-code.md#qrcodeerrorcorrection) | Type alias | How much of the code can be damaged or hidden and still read: about 7% at `"L"`, 15% at `"M"`, 25% at `"Q"` and 30% at `"H"`. |
|
|
372
|
+
| [`QrCodeExportErrorCode`](api/qr-code.md#qrcodeexporterrorcode) | Type alias | Why a QR code export failed. - `"not-ready"`: there's no code to export, because the value is empty or can't be encoded. - `"unsupported-environment"`: the export ran outside a browser, such as during server-side rendering. - `"invalid-size"`: the size isn't a positive number, or a PNG of that size can't give each module a pixel. - `"resource-load-failed"`: the overlay image didn't load, or another origin didn't allow reading it. - `"png-rasterization-failed"`: the browser couldn't draw the PNG. - `"pdf-generation-failed"`: `jspdf` isn't installed, or failed to write the page. |
|
|
373
|
+
| [`QrCodeExportFormat`](api/qr-code.md#qrcodeexportformat) | Type alias | The file a QR code exports to: a `"png"` image, an `"svg"` document or a `"pdf"` page. |
|
|
374
|
+
| [`QrCodeOverlay`](api/qr-code.md#qrcodeoverlay) | Type alias | What to draw over the center of the code. |
|
|
375
|
+
| [`QrCodeValueError`](api/qr-code.md#qrcodevalueerror) | Type alias | Why a value can't be stored in a QR code. |
|
|
376
|
+
|
|
377
|
+
**Related types:** [`MonaQrCodeMessages`](api/i18n.md#monaqrcodemessages)
|
package/docs/radio-button.md
CHANGED
|
@@ -297,7 +297,8 @@ The directive applies styles directly to the `<input>` element's `class` attribu
|
|
|
297
297
|
|
|
298
298
|
### Radio groups
|
|
299
299
|
|
|
300
|
-
- **Name:** a group needs an accessible name from `aria-label`, `aria-labelledby` or a `mona-
|
|
300
|
+
- **Name:** a group needs an accessible name from `aria-label`, `aria-labelledby`, a `mona-label` or a `mona-form-field`. It warns in development when it has none. Inside a `mona-label` with `text`, a click on the caption focuses the selected radio button, or the first enabled one.
|
|
301
|
+
- **Layout:** a vertical group fills its container's width and lines its radio buttons up at the start, each as wide as its label. A horizontal group wraps its radio buttons onto new rows.
|
|
301
302
|
- **Invalid:** `aria-invalid` is on the group, once `touched` and `invalid` are both `true`. The radio buttons only paint it.
|
|
302
303
|
- **Touched:** `touch` emits on selection and when focus leaves the group. Moving focus between its radio buttons doesn't count.
|
|
303
304
|
- **Disabled, read-only and required:** each applies to every radio button in the group. A radio button's own `disabled`, `readonly` and `required` still work next to it.
|
|
@@ -2,7 +2,7 @@ import { NgTemplateOutlet } from "@angular/common";
|
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
import { Component, DestroyRef, ElementRef, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, forwardRef, inject, input, linkedSignal, model, output, untracked, viewChild } from "@angular/core";
|
|
4
4
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
5
|
-
import { createElementControlId, injectEffectiveDisabled, rxTimeout, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
|
|
5
|
+
import { FIELD_ASSOCIATION_BOUNDARY, createElementControlId, injectEffectiveDisabled, injectLabelAssociation, rxTimeout, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
|
|
6
6
|
import { FilterChangeEvent } from "@nanahoshi/mona-ui/common";
|
|
7
7
|
import { IndicatorIconComponent } from "@nanahoshi/mona-ui/internal/indicator-icon";
|
|
8
8
|
import { ListComponent, ListFooterTemplateDirective, ListGroupHeaderTemplateDirective, ListHeaderTemplateDirective, ListItemTemplateDirective, ListNoDataTemplateDirective, ListService } from "@nanahoshi/mona-ui/internal/list";
|
|
@@ -81,6 +81,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
|
|
|
81
81
|
#dropdownService;
|
|
82
82
|
#hostElementRef;
|
|
83
83
|
#i18n;
|
|
84
|
+
#label;
|
|
84
85
|
#listService;
|
|
85
86
|
#popupRef;
|
|
86
87
|
constructor() {
|
|
@@ -88,6 +89,12 @@ var AutoCompleteComponent = class AutoCompleteComponent {
|
|
|
88
89
|
this.#dropdownService = inject(DropdownService);
|
|
89
90
|
this.#hostElementRef = inject(ElementRef);
|
|
90
91
|
this.#i18n = inject(MonaI18nService);
|
|
92
|
+
this.#label = injectLabelAssociation({
|
|
93
|
+
ariaDescribedBy: () => this.ariaDescribedBy(),
|
|
94
|
+
ariaLabel: () => this.ariaLabel(),
|
|
95
|
+
ariaLabelledBy: () => this.ariaLabelledBy(),
|
|
96
|
+
focus: () => this.focus()
|
|
97
|
+
});
|
|
91
98
|
this.#listService = inject(ListService);
|
|
92
99
|
this.#popupRef = this.#dropdownService.popupRef;
|
|
93
100
|
this.activeDescendant = computed(() => {
|
|
@@ -118,6 +125,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
|
|
|
118
125
|
return twMerge(variantClass, userClass);
|
|
119
126
|
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
120
127
|
this.clearButtonVisible = computed(() => this.showClearButton() && !!this.autoCompleteValue() && !this.loading() && !this.effectiveDisabled() && !this.readonly(), ...ngDevMode ? [{ debugName: "clearButtonVisible" }] : /* istanbul ignore next */ []);
|
|
128
|
+
this.describedBy = this.#label.describedBy;
|
|
121
129
|
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
122
130
|
this.expanded = computed(() => this.#popupRef() !== null, ...ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []);
|
|
123
131
|
this.footerTemplate = contentChild(DropdownFooterTemplateDirective, {
|
|
@@ -142,6 +150,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
|
|
|
142
150
|
...ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {},
|
|
143
151
|
read: TemplateRef
|
|
144
152
|
});
|
|
153
|
+
this.labelledBy = this.#label.labelledBy;
|
|
145
154
|
this.listId = createElementControlId();
|
|
146
155
|
this.listPopupClass = computed(() => {
|
|
147
156
|
const rounded = this.rounded();
|
|
@@ -685,7 +694,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
|
|
|
685
694
|
{ directive: i1.DropdownLiveRegionDirective }
|
|
686
695
|
],
|
|
687
696
|
ngImport: i0,
|
|
688
|
-
template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<input\n monaTextBox\n role=\"combobox\"\n [class]=\"inputClass()\"\n [disabled]=\"effectiveDisabled()\"\n [id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [required]=\"required()\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [value]=\"autoCompleteValue()\"\n [attr.aria-activedescendant]=\"activeDescendant()\"\n [attr.aria-autocomplete]=\"'list'\"\n [attr.aria-busy]=\"loading()\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-describedby]=\"
|
|
697
|
+
template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<input\n monaTextBox\n role=\"combobox\"\n [class]=\"inputClass()\"\n [disabled]=\"effectiveDisabled()\"\n [id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [required]=\"required()\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [value]=\"autoCompleteValue()\"\n [attr.aria-activedescendant]=\"activeDescendant()\"\n [attr.aria-autocomplete]=\"'list'\"\n [attr.aria-busy]=\"loading()\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-haspopup]=\"'listbox'\"\n [attr.aria-invalid]=\"invalidState() || undefined\"\n [attr.aria-label]=\"ariaLabel() || undefined\"\n [attr.aria-labelledby]=\"labelledBy()\"\n (input)=\"onInput(textInput.value)\"\n #textInput />\n\n@if (clearButtonVisible()) {\n <mona-indicator-icon\n preset=\"clear\"\n [interactive]=\"true\"\n [label]=\"messages().clear\"\n (activate)=\"onValueClear($event)\"></mona-indicator-icon>\n}\n\n@if (loading()) {\n <mona-indicator-icon preset=\"loading\" [size]=\"12\"></mona-indicator-icon>\n}\n\n@if (suffixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"suffixTemplate()\"></ng-container>\n </span>\n}\n\n<ng-template #popupTemplate>\n <div [class]=\"listPopupClass()\" (pointerdown)=\"onPopupPointerDown($event)\">\n <mona-list (itemSelect)=\"onItemSelect($event)\" [focusOnMount]=\"false\" [size]=\"size()\" [listId]=\"listId\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n </mona-list>\n </div>\n</ng-template>\n",
|
|
689
698
|
dependencies: [
|
|
690
699
|
{
|
|
691
700
|
kind: "directive",
|
|
@@ -773,7 +782,8 @@ var AutoCompleteComponent = class AutoCompleteComponent {
|
|
|
773
782
|
],
|
|
774
783
|
outputs: ["activate"]
|
|
775
784
|
}
|
|
776
|
-
]
|
|
785
|
+
],
|
|
786
|
+
viewProviders: [...FIELD_ASSOCIATION_BOUNDARY]
|
|
777
787
|
});
|
|
778
788
|
}
|
|
779
789
|
};
|
|
@@ -816,6 +826,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
816
826
|
ListItemTemplateDirective,
|
|
817
827
|
IndicatorIconComponent
|
|
818
828
|
],
|
|
829
|
+
viewProviders: [...FIELD_ASSOCIATION_BOUNDARY],
|
|
819
830
|
host: {
|
|
820
831
|
"[attr.aria-describedby]": "null",
|
|
821
832
|
"[attr.aria-label]": "null",
|
|
@@ -827,7 +838,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
827
838
|
"[class]": "baseClass()",
|
|
828
839
|
"(focusout)": "onFocusOut($event)"
|
|
829
840
|
},
|
|
830
|
-
template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<input\n monaTextBox\n role=\"combobox\"\n [class]=\"inputClass()\"\n [disabled]=\"effectiveDisabled()\"\n [id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [required]=\"required()\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [value]=\"autoCompleteValue()\"\n [attr.aria-activedescendant]=\"activeDescendant()\"\n [attr.aria-autocomplete]=\"'list'\"\n [attr.aria-busy]=\"loading()\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-describedby]=\"
|
|
841
|
+
template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<input\n monaTextBox\n role=\"combobox\"\n [class]=\"inputClass()\"\n [disabled]=\"effectiveDisabled()\"\n [id]=\"inputId()\"\n [placeholder]=\"placeholder()\"\n [readonly]=\"readonly()\"\n [required]=\"required()\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [value]=\"autoCompleteValue()\"\n [attr.aria-activedescendant]=\"activeDescendant()\"\n [attr.aria-autocomplete]=\"'list'\"\n [attr.aria-busy]=\"loading()\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-haspopup]=\"'listbox'\"\n [attr.aria-invalid]=\"invalidState() || undefined\"\n [attr.aria-label]=\"ariaLabel() || undefined\"\n [attr.aria-labelledby]=\"labelledBy()\"\n (input)=\"onInput(textInput.value)\"\n #textInput />\n\n@if (clearButtonVisible()) {\n <mona-indicator-icon\n preset=\"clear\"\n [interactive]=\"true\"\n [label]=\"messages().clear\"\n (activate)=\"onValueClear($event)\"></mona-indicator-icon>\n}\n\n@if (loading()) {\n <mona-indicator-icon preset=\"loading\" [size]=\"12\"></mona-indicator-icon>\n}\n\n@if (suffixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"suffixTemplate()\"></ng-container>\n </span>\n}\n\n<ng-template #popupTemplate>\n <div [class]=\"listPopupClass()\" (pointerdown)=\"onPopupPointerDown($event)\">\n <mona-list (itemSelect)=\"onItemSelect($event)\" [focusOnMount]=\"false\" [size]=\"size()\" [listId]=\"listId\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n </mona-list>\n </div>\n</ng-template>\n"
|
|
831
842
|
}]
|
|
832
843
|
}],
|
|
833
844
|
ctorParameters: () => [],
|
|
@@ -97,8 +97,10 @@ var ButtonGroupComponent = class ButtonGroupComponent {
|
|
|
97
97
|
this.#i18n = inject(MonaI18nService);
|
|
98
98
|
this.#label = injectLabelAssociation({
|
|
99
99
|
activate: () => this.focus(),
|
|
100
|
+
ariaDescribedBy: () => this.ariaDescribedBy(),
|
|
100
101
|
ariaLabel: () => this.ariaLabel(),
|
|
101
|
-
ariaLabelledBy: () => this.ariaLabelledBy()
|
|
102
|
+
ariaLabelledBy: () => this.ariaLabelledBy(),
|
|
103
|
+
focus: () => this.focus()
|
|
102
104
|
});
|
|
103
105
|
this.#lastSelected = [];
|
|
104
106
|
this.baseClass = computed(() => {
|
|
@@ -115,6 +117,7 @@ var ButtonGroupComponent = class ButtonGroupComponent {
|
|
|
115
117
|
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
116
118
|
this.buttons = contentChildren(ButtonDirective, ...ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []);
|
|
117
119
|
this.components = contentChildren(BUTTON_GROUP_MEMBER, ...ngDevMode ? [{ debugName: "components" }] : /* istanbul ignore next */ []);
|
|
120
|
+
this.describedBy = this.#label.describedBy;
|
|
118
121
|
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
119
122
|
this.invalidState = computed(() => this.touched() && this.invalid(), ...ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []);
|
|
120
123
|
this.labelledBy = this.#label.labelledBy;
|
|
@@ -124,6 +127,10 @@ var ButtonGroupComponent = class ButtonGroupComponent {
|
|
|
124
127
|
...ngDevMode ? { debugName: "allowEmpty" } : /* istanbul ignore next */ {},
|
|
125
128
|
transform: booleanAttribute
|
|
126
129
|
});
|
|
130
|
+
this.ariaDescribedBy = input("", {
|
|
131
|
+
...ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {},
|
|
132
|
+
alias: "aria-describedby"
|
|
133
|
+
});
|
|
127
134
|
this.ariaLabel = input(void 0, {
|
|
128
135
|
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
129
136
|
alias: "aria-label"
|
|
@@ -288,6 +295,13 @@ var ButtonGroupComponent = class ButtonGroupComponent {
|
|
|
288
295
|
isRequired: false,
|
|
289
296
|
transformFunction: null
|
|
290
297
|
},
|
|
298
|
+
ariaDescribedBy: {
|
|
299
|
+
classPropertyName: "ariaDescribedBy",
|
|
300
|
+
publicName: "aria-describedby",
|
|
301
|
+
isSignal: true,
|
|
302
|
+
isRequired: false,
|
|
303
|
+
transformFunction: null
|
|
304
|
+
},
|
|
291
305
|
ariaLabel: {
|
|
292
306
|
classPropertyName: "ariaLabel",
|
|
293
307
|
publicName: "aria-label",
|
|
@@ -383,6 +397,7 @@ var ButtonGroupComponent = class ButtonGroupComponent {
|
|
|
383
397
|
listeners: { "focusout": "onFocusOut($event)" },
|
|
384
398
|
properties: {
|
|
385
399
|
"attr.aria-invalid": "invalidState() ? 'true' : null",
|
|
400
|
+
"attr.aria-describedby": "describedBy()",
|
|
386
401
|
"attr.aria-label": "labelledBy() ? null : ariaLabel() || messages().buttonGroup",
|
|
387
402
|
"attr.aria-labelledby": "labelledBy()",
|
|
388
403
|
"attr.data-invalid": "invalidState() || null",
|
|
@@ -417,6 +432,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
417
432
|
providers: [ButtonService],
|
|
418
433
|
host: {
|
|
419
434
|
"[attr.aria-invalid]": "invalidState() ? 'true' : null",
|
|
435
|
+
"[attr.aria-describedby]": "describedBy()",
|
|
420
436
|
"[attr.aria-label]": "labelledBy() ? null : ariaLabel() || messages().buttonGroup",
|
|
421
437
|
"[attr.aria-labelledby]": "labelledBy()",
|
|
422
438
|
"[attr.data-invalid]": "invalidState() || null",
|
|
@@ -446,6 +462,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
446
462
|
required: false
|
|
447
463
|
}]
|
|
448
464
|
}],
|
|
465
|
+
ariaDescribedBy: [{
|
|
466
|
+
type: i0.Input,
|
|
467
|
+
args: [{
|
|
468
|
+
isSignal: true,
|
|
469
|
+
alias: "aria-describedby",
|
|
470
|
+
required: false
|
|
471
|
+
}]
|
|
472
|
+
}],
|
|
449
473
|
ariaLabel: [{
|
|
450
474
|
type: i0.Input,
|
|
451
475
|
args: [{
|
|
@@ -106,8 +106,10 @@ const checkboxDirectiveThemeVariants = cva(`
|
|
|
106
106
|
var CheckBoxComponent = class CheckBoxComponent {
|
|
107
107
|
constructor() {
|
|
108
108
|
this.#label = injectLabelAssociation({
|
|
109
|
+
ariaDescribedBy: () => this.ariaDescribedBy(),
|
|
109
110
|
ariaLabel: () => this.ariaLabel(),
|
|
110
111
|
ariaLabelledBy: () => this.ariaLabelledBy(),
|
|
112
|
+
focus: () => this.focus(),
|
|
111
113
|
wrapped: false
|
|
112
114
|
});
|
|
113
115
|
this.checkBoxClasses = computed(() => {
|
|
@@ -123,6 +125,7 @@ var CheckBoxComponent = class CheckBoxComponent {
|
|
|
123
125
|
const variantClasses = checkboxContainerLabelThemeVariants({ labelSize });
|
|
124
126
|
return twMerge(variantClasses, classes);
|
|
125
127
|
}, ...ngDevMode ? [{ debugName: "containerLabelClasses" }] : /* istanbul ignore next */ []);
|
|
128
|
+
this.describedBy = this.#label.describedBy;
|
|
126
129
|
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
127
130
|
this.indeterminateState = linkedSignal(() => this.indeterminate(), ...ngDevMode ? [{ debugName: "indeterminateState" }] : /* istanbul ignore next */ []);
|
|
128
131
|
this.inputRef = viewChild.required("checkBox", ...ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []);
|
|
@@ -382,7 +385,7 @@ var CheckBoxComponent = class CheckBoxComponent {
|
|
|
382
385
|
isSignal: true
|
|
383
386
|
}],
|
|
384
387
|
ngImport: i0,
|
|
385
|
-
template: "<label\n [class]=\"containerLabelClasses()\"\n [attr.data-disabled]=\"effectiveDisabled()\"\n [attr.data-readonly]=\"readonly() || null\">\n @if (labelPosition() === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n\n <input\n type=\"checkbox\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"effectiveDisabled()\"\n [indeterminate]=\"indeterminateState()\"\n [required]=\"required()\"\n [checked]=\"checked()\"\n [tabindex]=\"effectiveDisabled() ? -1 : tabIndex()\"\n [class]=\"checkBoxClasses()\"\n [attr.aria-checked]=\"indeterminateState() ? 'mixed' : null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || label() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-describedby]=\"
|
|
388
|
+
template: "<label\n [class]=\"containerLabelClasses()\"\n [attr.data-disabled]=\"effectiveDisabled()\"\n [attr.data-readonly]=\"readonly() || null\">\n @if (labelPosition() === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n\n <input\n type=\"checkbox\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"effectiveDisabled()\"\n [indeterminate]=\"indeterminateState()\"\n [required]=\"required()\"\n [checked]=\"checked()\"\n [tabindex]=\"effectiveDisabled() ? -1 : tabIndex()\"\n [class]=\"checkBoxClasses()\"\n [attr.aria-checked]=\"indeterminateState() ? 'mixed' : null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || label() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-readonly]=\"readonly() ? 'true' : null\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"inputFocus.emit($event)\"\n #checkBox />\n\n <span [class]=\"checkMarkClasses()\" [attr.data-invalid]=\"invalidState() || null\" aria-hidden=\"true\">\n @if (checked() && !indeterminateState()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-check stroke-primary-foreground forced-colors:stroke-[CanvasText]\">\n <path d=\"M18 6 9 17l-5-5\" />\n </svg>\n }\n </span>\n @if (labelPosition() === \"after\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n</label>\n\n<ng-template #labelTemplate>\n @if (label()) {\n <span>{{ label() }}</span>\n } @else {\n <ng-content></ng-content>\n }\n</ng-template>\n",
|
|
386
389
|
dependencies: [{
|
|
387
390
|
kind: "directive",
|
|
388
391
|
type: NgTemplateOutlet,
|
|
@@ -416,7 +419,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
416
419
|
"[attr.data-disabled]": "effectiveDisabled()",
|
|
417
420
|
"[attr.data-indeterminate]": "indeterminateState()"
|
|
418
421
|
},
|
|
419
|
-
template: "<label\n [class]=\"containerLabelClasses()\"\n [attr.data-disabled]=\"effectiveDisabled()\"\n [attr.data-readonly]=\"readonly() || null\">\n @if (labelPosition() === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n\n <input\n type=\"checkbox\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"effectiveDisabled()\"\n [indeterminate]=\"indeterminateState()\"\n [required]=\"required()\"\n [checked]=\"checked()\"\n [tabindex]=\"effectiveDisabled() ? -1 : tabIndex()\"\n [class]=\"checkBoxClasses()\"\n [attr.aria-checked]=\"indeterminateState() ? 'mixed' : null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || label() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-describedby]=\"
|
|
422
|
+
template: "<label\n [class]=\"containerLabelClasses()\"\n [attr.data-disabled]=\"effectiveDisabled()\"\n [attr.data-readonly]=\"readonly() || null\">\n @if (labelPosition() === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n\n <input\n type=\"checkbox\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"effectiveDisabled()\"\n [indeterminate]=\"indeterminateState()\"\n [required]=\"required()\"\n [checked]=\"checked()\"\n [tabindex]=\"effectiveDisabled() ? -1 : tabIndex()\"\n [class]=\"checkBoxClasses()\"\n [attr.aria-checked]=\"indeterminateState() ? 'mixed' : null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || label() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-readonly]=\"readonly() ? 'true' : null\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"inputFocus.emit($event)\"\n #checkBox />\n\n <span [class]=\"checkMarkClasses()\" [attr.data-invalid]=\"invalidState() || null\" aria-hidden=\"true\">\n @if (checked() && !indeterminateState()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-check stroke-primary-foreground forced-colors:stroke-[CanvasText]\">\n <path d=\"M18 6 9 17l-5-5\" />\n </svg>\n }\n </span>\n @if (labelPosition() === \"after\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n }\n</label>\n\n<ng-template #labelTemplate>\n @if (label()) {\n <span>{{ label() }}</span>\n } @else {\n <ng-content></ng-content>\n }\n</ng-template>\n"
|
|
420
423
|
}]
|
|
421
424
|
}],
|
|
422
425
|
propDecorators: {
|