@nanahoshi/mona-ui 0.28.0 → 0.30.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/i18n.md +13 -0
- package/docs/api/locales.md +21 -13
- package/docs/api/qr-code.md +287 -0
- package/docs/qr-code.md +377 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +9 -8
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +600 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-qr-code.mjs +1671 -0
- package/i18n/catalogs/en-US.messages.json +3 -0
- package/llms.txt +4 -2
- package/locales/ar-sa/ar-sa.messages.json +3 -0
- package/locales/de-de/de-de.messages.json +3 -0
- package/locales/es-es/es-es.messages.json +3 -0
- package/locales/fr-fr/fr-fr.messages.json +3 -0
- package/locales/id-id/id-id.messages.json +3 -0
- package/locales/it-it/it-it.messages.json +3 -0
- package/locales/ja-jp/ja-jp.messages.json +3 -0
- package/locales/ko-kr/ko-kr.messages.json +3 -0
- package/locales/pl-pl/package.json +4 -0
- package/locales/pl-pl/pl-pl.messages.json +539 -0
- package/locales/pt-br/pt-br.messages.json +3 -0
- package/locales/ru-ru/ru-ru.messages.json +3 -0
- package/locales/tr-tr/tr-tr.messages.json +3 -0
- package/locales/zh-cn/zh-cn.messages.json +3 -0
- package/locales/zh-tw/zh-tw.messages.json +3 -0
- package/package.json +9 -1
- package/qr-code/package.json +4 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +2 -2
- package/types/nanahoshi-mona-ui-i18n.d.ts +4 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +543 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +3 -0
- package/types/nanahoshi-mona-ui-locales.d.ts +2 -1
- package/types/nanahoshi-mona-ui-qr-code.d.ts +322 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { MonaQrCodeMessages } from "@nanahoshi/mona-ui/i18n";
|
|
3
|
+
/**
|
|
4
|
+
* An image, such as a logo, drawn over the center of the code.
|
|
5
|
+
*/
|
|
6
|
+
export interface QrCodeImageOverlay {
|
|
7
|
+
/**
|
|
8
|
+
* The image's width and height as a share of the code's, without the quiet zone. The image keeps its aspect ratio
|
|
9
|
+
* inside that square. Defaults to `0.2`.
|
|
10
|
+
*/
|
|
11
|
+
readonly size?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The image's URL. Exporting reads it into the file, so an image from another origin has to allow it with CORS.
|
|
14
|
+
*/
|
|
15
|
+
readonly src: string;
|
|
16
|
+
readonly type: "image";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 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.
|
|
20
|
+
*/
|
|
21
|
+
export interface QrCodeSwissOverlay {
|
|
22
|
+
readonly type: "swiss";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What to draw over the center of the code. The modules beneath it are cleared, so the overlay relies on error
|
|
26
|
+
* correction to read.
|
|
27
|
+
*/
|
|
28
|
+
export type QrCodeOverlay = QrCodeImageOverlay | QrCodeSwissOverlay;
|
|
29
|
+
/**
|
|
30
|
+
* 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%
|
|
31
|
+
* at `"H"`. A higher level holds less data at the same size.
|
|
32
|
+
*/
|
|
33
|
+
export type QrCodeErrorCorrection = "L" | "M" | "Q" | "H";
|
|
34
|
+
/** A square in the code's coordinates, which count modules from the outer edge of the quiet zone. */
|
|
35
|
+
interface QrCodeBox {
|
|
36
|
+
readonly size: number;
|
|
37
|
+
readonly x: number;
|
|
38
|
+
readonly y: number;
|
|
39
|
+
}
|
|
40
|
+
interface QrCodeImageSceneOverlay {
|
|
41
|
+
/** The square the image is fitted into. */
|
|
42
|
+
readonly box: QrCodeBox;
|
|
43
|
+
/** The cleared square behind it, on whole modules. */
|
|
44
|
+
readonly clear: QrCodeBox;
|
|
45
|
+
readonly kind: "image";
|
|
46
|
+
readonly src: string;
|
|
47
|
+
}
|
|
48
|
+
interface QrCodeSwissSceneOverlay {
|
|
49
|
+
/** The square the cross sits on, inside the light frame. */
|
|
50
|
+
readonly badge: QrCodeBox;
|
|
51
|
+
/** The light frame around the badge. */
|
|
52
|
+
readonly box: QrCodeBox;
|
|
53
|
+
/** The cleared square behind it, on whole modules. */
|
|
54
|
+
readonly clear: QrCodeBox;
|
|
55
|
+
/** The corners of the cross, clockwise. */
|
|
56
|
+
readonly cross: readonly QrCodePoint[];
|
|
57
|
+
readonly kind: "swiss";
|
|
58
|
+
}
|
|
59
|
+
type QrCodePoint = readonly [x: number, y: number];
|
|
60
|
+
type QrCodeSceneOverlay = QrCodeImageSceneOverlay | QrCodeSwissSceneOverlay;
|
|
61
|
+
/** What the component draws, and what the exports draw the same way. */
|
|
62
|
+
interface QrCodeScene {
|
|
63
|
+
/** The dark modules after the overlay's square is cleared, row by row, without the quiet zone. */
|
|
64
|
+
readonly modules: Uint8Array;
|
|
65
|
+
/** The dark modules as SVG path data, one closed rectangle per horizontal run, offset by the quiet zone. */
|
|
66
|
+
readonly modulesPath: string;
|
|
67
|
+
readonly overlay: QrCodeSceneOverlay | null;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the overlay hides more codewords of some block than error correction can recover, so the code may not
|
|
70
|
+
* read.
|
|
71
|
+
*/
|
|
72
|
+
readonly overlayExceedsCorrection: boolean;
|
|
73
|
+
readonly quietZone: number;
|
|
74
|
+
/** Modules on each side, quiet zone included: the side of the view box. */
|
|
75
|
+
readonly size: number;
|
|
76
|
+
readonly symbolSize: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The character set a QR code stores text in.
|
|
80
|
+
* - `"utf-8"`: any text. A value with characters outside ASCII starts with an ECI header that tells readers it's UTF-8.
|
|
81
|
+
* - `"iso-8859-1"`: Latin-1 only, which every reader assumes when there's no header. Other characters are an error.
|
|
82
|
+
*/
|
|
83
|
+
export type QrCodeEncoding = "utf-8" | "iso-8859-1";
|
|
84
|
+
/**
|
|
85
|
+
* The file a QR code exports to: a `"png"` image, an `"svg"` document or a `"pdf"` page.
|
|
86
|
+
*/
|
|
87
|
+
export type QrCodeExportFormat = "png" | "svg" | "pdf";
|
|
88
|
+
/**
|
|
89
|
+
* What to export a QR code as.
|
|
90
|
+
*/
|
|
91
|
+
export interface QrCodeExportOptions {
|
|
92
|
+
readonly format: QrCodeExportFormat;
|
|
93
|
+
/**
|
|
94
|
+
* The width and height, quiet zone included, in CSS pixels: the image's pixels for PNG, its `width` and `height`
|
|
95
|
+
* for SVG, and the page for PDF, at 96 pixels to the inch. Defaults to the rendered size. A PNG has at least one
|
|
96
|
+
* pixel per module, and its modules are whole pixels, with what's left over added to the quiet zone.
|
|
97
|
+
*/
|
|
98
|
+
readonly size?: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* What to export a QR code as, and the name of the file to save.
|
|
102
|
+
*/
|
|
103
|
+
export interface QrCodeDownloadOptions extends QrCodeExportOptions {
|
|
104
|
+
/** The file's name. The format's extension is added when it's missing. Defaults to `qr-code`. */
|
|
105
|
+
readonly fileName?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* An exported QR code.
|
|
109
|
+
*/
|
|
110
|
+
export interface QrCodeExportResult {
|
|
111
|
+
readonly blob: Blob;
|
|
112
|
+
readonly format: QrCodeExportFormat;
|
|
113
|
+
/** The blob's type: `image/png`, `image/svg+xml` or `application/pdf`. */
|
|
114
|
+
readonly mimeType: string;
|
|
115
|
+
/** The width and height in CSS pixels. */
|
|
116
|
+
readonly size: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A character the chosen encoding can't store, such as `€` in `"iso-8859-1"`.
|
|
120
|
+
*/
|
|
121
|
+
export interface QrCodeUnsupportedCharacterError {
|
|
122
|
+
/** The first character that can't be stored. */
|
|
123
|
+
readonly character: string;
|
|
124
|
+
readonly code: "unsupported-character";
|
|
125
|
+
/** Where that character starts in the value, in UTF-16 code units. */
|
|
126
|
+
readonly index: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A value too long for the largest QR code (version 40) at the chosen error correction level.
|
|
130
|
+
*/
|
|
131
|
+
export interface QrCodeTooLongError {
|
|
132
|
+
/** The most bits a version 40 code holds at the chosen error correction level. */
|
|
133
|
+
readonly availableBits: number;
|
|
134
|
+
readonly code: "too-long";
|
|
135
|
+
/** The bits the value needs. */
|
|
136
|
+
readonly requiredBits: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Why a value can't be stored in a QR code.
|
|
140
|
+
*/
|
|
141
|
+
export type QrCodeValueError = QrCodeUnsupportedCharacterError | QrCodeTooLongError;
|
|
142
|
+
/**
|
|
143
|
+
* Draws a value as a QR code in SVG, and exports it as a PNG, SVG or PDF file.
|
|
144
|
+
*/
|
|
145
|
+
export declare class QrCodeComponent {
|
|
146
|
+
#private;
|
|
147
|
+
protected readonly classes: import("@angular/core").Signal<string>;
|
|
148
|
+
protected readonly crossPath: import("@angular/core").Signal<string>;
|
|
149
|
+
protected readonly cssSize: import("@angular/core").Signal<string>;
|
|
150
|
+
protected readonly imageOverlay: import("@angular/core").Signal<QrCodeImageSceneOverlay | null>;
|
|
151
|
+
protected readonly label: import("@angular/core").Signal<string>;
|
|
152
|
+
protected readonly messages: import("@angular/core").Signal<import("@nanahoshi/mona-ui/i18n").MonaQrCodeMessages>;
|
|
153
|
+
protected readonly scene: import("@angular/core").Signal<QrCodeScene | null>;
|
|
154
|
+
protected readonly swissOverlay: import("@angular/core").Signal<QrCodeSwissSceneOverlay | null>;
|
|
155
|
+
protected readonly viewBox: import("@angular/core").Signal<string>;
|
|
156
|
+
/**
|
|
157
|
+
* @description Accessible name of the code. Say what scanning it does, such as "QR code for the event page". When
|
|
158
|
+
* empty, falls back to the localized "QR code". The host has `role="img"` while there's a code to show.
|
|
159
|
+
* @default ""
|
|
160
|
+
*/
|
|
161
|
+
readonly ariaLabel: import("@angular/core").InputSignal<string>;
|
|
162
|
+
/**
|
|
163
|
+
* @description Color of the light modules and the quiet zone, as any CSS color. `"transparent"` lets the page show
|
|
164
|
+
* through, which only scans on a light page.
|
|
165
|
+
* @default "#ffffff"
|
|
166
|
+
*/
|
|
167
|
+
readonly background: import("@angular/core").InputSignal<string>;
|
|
168
|
+
/**
|
|
169
|
+
* @description Color of the dark modules, as any CSS color. Readers need it much darker than `background`.
|
|
170
|
+
* @default "#000000"
|
|
171
|
+
*/
|
|
172
|
+
readonly color: import("@angular/core").InputSignal<string>;
|
|
173
|
+
/**
|
|
174
|
+
* @description Character set the text is stored in. `"utf-8"` stores any text; `"iso-8859-1"` stores Latin-1 only,
|
|
175
|
+
* without the ECI header some older readers don't support.
|
|
176
|
+
* @default "utf-8"
|
|
177
|
+
*/
|
|
178
|
+
readonly encoding: import("@angular/core").InputSignal<QrCodeEncoding>;
|
|
179
|
+
/**
|
|
180
|
+
* @description Why the value can't be encoded, or `null` when it can or is empty. While it's set, nothing is drawn.
|
|
181
|
+
* Use `validateQrCodeValue` to check a value before it reaches the component, such as in a form.
|
|
182
|
+
*/
|
|
183
|
+
readonly error: import("@angular/core").Signal<QrCodeValueError | null>;
|
|
184
|
+
/**
|
|
185
|
+
* @description How much of the code can be damaged or hidden and still read. Use `"H"` with an image overlay.
|
|
186
|
+
* A higher level needs more modules for the same value.
|
|
187
|
+
* @default "M"
|
|
188
|
+
*/
|
|
189
|
+
readonly errorCorrection: import("@angular/core").InputSignal<QrCodeErrorCorrection>;
|
|
190
|
+
/**
|
|
191
|
+
* @description An image or the Swiss cross to draw over the center. The modules beneath it are cleared, so raise
|
|
192
|
+
* `errorCorrection` to keep the code readable; a warning is logged in development when it hides too much. With an
|
|
193
|
+
* overlay, the code is version 2 at least, since version 1 has no room for one.
|
|
194
|
+
* @default null
|
|
195
|
+
*/
|
|
196
|
+
readonly overlay: import("@angular/core").InputSignal<QrCodeOverlay | null>;
|
|
197
|
+
/**
|
|
198
|
+
* @description Width of the light border around the code, in modules. Readers expect 4; a smaller one only scans
|
|
199
|
+
* when the surroundings are light.
|
|
200
|
+
* @default 4
|
|
201
|
+
*/
|
|
202
|
+
readonly quietZone: import("@angular/core").InputSignal<number>;
|
|
203
|
+
/**
|
|
204
|
+
* @description Width and height, quiet zone included. A number is pixels; a string can be any CSS length, such as
|
|
205
|
+
* `"100%"`. The code never grows wider than its container.
|
|
206
|
+
* @default 200
|
|
207
|
+
*/
|
|
208
|
+
readonly size: import("@angular/core").InputSignal<string | number>;
|
|
209
|
+
/**
|
|
210
|
+
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
211
|
+
* @default ""
|
|
212
|
+
*/
|
|
213
|
+
readonly userClass: import("@angular/core").InputSignal<string>;
|
|
214
|
+
/**
|
|
215
|
+
* @description Text to encode, such as a URL. A number is encoded as its digits. An empty value draws nothing.
|
|
216
|
+
* @default ""
|
|
217
|
+
*/
|
|
218
|
+
readonly value: import("@angular/core").InputSignal<string | number>;
|
|
219
|
+
constructor();
|
|
220
|
+
/**
|
|
221
|
+
* @description Exports the code and saves it as a file. PDF export needs the `jspdf` package, which isn't installed
|
|
222
|
+
* with Mona UI.
|
|
223
|
+
* @param options The format, the size and the file's name.
|
|
224
|
+
*/
|
|
225
|
+
downloadQrCode(options: QrCodeDownloadOptions): Promise<QrCodeExportResult>;
|
|
226
|
+
/**
|
|
227
|
+
* @description Exports the code as a PNG image, an SVG document or a PDF page, drawn the same way it's shown, with
|
|
228
|
+
* the colors resolved to what they paint. Rejects with a `QrCodeExportError`. PDF export needs the `jspdf` package,
|
|
229
|
+
* which isn't installed with Mona UI.
|
|
230
|
+
* @param options The format and the size.
|
|
231
|
+
*/
|
|
232
|
+
exportQrCode(options: QrCodeExportOptions): Promise<QrCodeExportResult>;
|
|
233
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<QrCodeComponent, never>;
|
|
234
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<QrCodeComponent, "mona-qr-code", ["monaQrCode"], {
|
|
235
|
+
"ariaLabel": {
|
|
236
|
+
"alias": "aria-label";
|
|
237
|
+
"required": false;
|
|
238
|
+
"isSignal": true;
|
|
239
|
+
};
|
|
240
|
+
"background": {
|
|
241
|
+
"alias": "background";
|
|
242
|
+
"required": false;
|
|
243
|
+
"isSignal": true;
|
|
244
|
+
};
|
|
245
|
+
"color": {
|
|
246
|
+
"alias": "color";
|
|
247
|
+
"required": false;
|
|
248
|
+
"isSignal": true;
|
|
249
|
+
};
|
|
250
|
+
"encoding": {
|
|
251
|
+
"alias": "encoding";
|
|
252
|
+
"required": false;
|
|
253
|
+
"isSignal": true;
|
|
254
|
+
};
|
|
255
|
+
"errorCorrection": {
|
|
256
|
+
"alias": "errorCorrection";
|
|
257
|
+
"required": false;
|
|
258
|
+
"isSignal": true;
|
|
259
|
+
};
|
|
260
|
+
"overlay": {
|
|
261
|
+
"alias": "overlay";
|
|
262
|
+
"required": false;
|
|
263
|
+
"isSignal": true;
|
|
264
|
+
};
|
|
265
|
+
"quietZone": {
|
|
266
|
+
"alias": "quietZone";
|
|
267
|
+
"required": false;
|
|
268
|
+
"isSignal": true;
|
|
269
|
+
};
|
|
270
|
+
"size": {
|
|
271
|
+
"alias": "size";
|
|
272
|
+
"required": false;
|
|
273
|
+
"isSignal": true;
|
|
274
|
+
};
|
|
275
|
+
"userClass": {
|
|
276
|
+
"alias": "class";
|
|
277
|
+
"required": false;
|
|
278
|
+
"isSignal": true;
|
|
279
|
+
};
|
|
280
|
+
"value": {
|
|
281
|
+
"alias": "value";
|
|
282
|
+
"required": false;
|
|
283
|
+
"isSignal": true;
|
|
284
|
+
};
|
|
285
|
+
}, {}, never, never, true, never>;
|
|
286
|
+
}
|
|
287
|
+
export declare const QR_CODE_DEFAULT_MESSAGES: MonaQrCodeMessages;
|
|
288
|
+
/**
|
|
289
|
+
* Why a QR code export failed.
|
|
290
|
+
* - `"not-ready"`: there's no code to export, because the value is empty or can't be encoded.
|
|
291
|
+
* - `"unsupported-environment"`: the export ran outside a browser, such as during server-side rendering.
|
|
292
|
+
* - `"invalid-size"`: the size isn't a positive number, or a PNG of that size can't give each module a pixel.
|
|
293
|
+
* - `"resource-load-failed"`: the overlay image didn't load, or another origin didn't allow reading it.
|
|
294
|
+
* - `"png-rasterization-failed"`: the browser couldn't draw the PNG.
|
|
295
|
+
* - `"pdf-generation-failed"`: `jspdf` isn't installed, or failed to write the page.
|
|
296
|
+
*/
|
|
297
|
+
export type QrCodeExportErrorCode = "not-ready" | "unsupported-environment" | "invalid-size" | "resource-load-failed" | "png-rasterization-failed" | "pdf-generation-failed";
|
|
298
|
+
/**
|
|
299
|
+
* The error a QR code export rejects with.
|
|
300
|
+
*/
|
|
301
|
+
export declare class QrCodeExportError extends Error {
|
|
302
|
+
readonly code: QrCodeExportErrorCode;
|
|
303
|
+
constructor(code: QrCodeExportErrorCode, message: string, options?: ErrorOptions);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The settings a value is checked against, matching the component's inputs of the same names.
|
|
307
|
+
*/
|
|
308
|
+
interface QrCodeValidationOptions {
|
|
309
|
+
/** Defaults to `"utf-8"`, as on the component. */
|
|
310
|
+
readonly encoding?: QrCodeEncoding;
|
|
311
|
+
/** Defaults to `"M"`, as on the component. */
|
|
312
|
+
readonly errorCorrection?: QrCodeErrorCorrection;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Checks whether a QR code can hold a value with the given settings, without drawing it: every character has to fit the
|
|
316
|
+
* encoding, and the whole value the largest code. An empty value is valid, since the component draws nothing for it.
|
|
317
|
+
* @param value The text the component would encode.
|
|
318
|
+
* @param options The `encoding` and `errorCorrection` the component uses.
|
|
319
|
+
* @returns Why the value can't be encoded, or `null` when it can.
|
|
320
|
+
*/
|
|
321
|
+
export declare function validateQrCodeValue(value: string | number, options?: QrCodeValidationOptions): QrCodeValueError | null;
|
|
322
|
+
export type { QrCodeValidationOptions };
|