@nanahoshi/mona-ui 0.34.0 → 0.36.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.
Files changed (87) hide show
  1. package/alert/package.json +4 -0
  2. package/badge/package.json +4 -0
  3. package/docs/alert.md +219 -0
  4. package/docs/api/alert.md +78 -0
  5. package/docs/api/avatar.md +25 -0
  6. package/docs/api/badge.md +24 -0
  7. package/docs/api/common.md +3 -3
  8. package/docs/api/i18n.md +71 -5
  9. package/docs/api/locales.md +14 -14
  10. package/docs/api/masked-text-box.md +137 -0
  11. package/docs/api/multi-select.md +3 -0
  12. package/docs/api/separator.md +23 -0
  13. package/docs/api/toolbar.md +81 -0
  14. package/docs/avatar.md +108 -6
  15. package/docs/badge.md +181 -0
  16. package/docs/masked-textbox.md +334 -0
  17. package/docs/multi-select.md +120 -0
  18. package/docs/separator.md +147 -0
  19. package/docs/sidebar-menus.md +1 -1
  20. package/docs/toolbar.md +327 -0
  21. package/fesm2022/nanahoshi-mona-ui-alert.mjs +422 -0
  22. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +182 -3
  23. package/fesm2022/nanahoshi-mona-ui-badge.mjs +273 -0
  24. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +20 -1
  25. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +54 -15
  26. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +13 -1
  27. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +13 -1
  28. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +13 -1
  29. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +13 -1
  30. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +13 -1
  31. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +13 -1
  32. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +13 -1
  33. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +13 -1
  34. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +13 -1
  35. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +13 -1
  36. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +13 -1
  37. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +13 -1
  38. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +13 -1
  39. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +13 -1
  40. package/fesm2022/nanahoshi-mona-ui-masked-text-box.mjs +1302 -0
  41. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +112 -3
  42. package/fesm2022/nanahoshi-mona-ui-separator.mjs +165 -0
  43. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +3 -3
  44. package/fesm2022/nanahoshi-mona-ui-toolbar.mjs +536 -0
  45. package/i18n/catalogs/en-US.messages.json +19 -1
  46. package/llms.txt +13 -3
  47. package/locales/ar-sa/ar-sa.messages.json +19 -1
  48. package/locales/de-de/de-de.messages.json +19 -1
  49. package/locales/es-es/es-es.messages.json +19 -1
  50. package/locales/fr-fr/fr-fr.messages.json +19 -1
  51. package/locales/id-id/id-id.messages.json +19 -1
  52. package/locales/it-it/it-it.messages.json +19 -1
  53. package/locales/ja-jp/ja-jp.messages.json +19 -1
  54. package/locales/ko-kr/ko-kr.messages.json +19 -1
  55. package/locales/pl-pl/pl-pl.messages.json +19 -1
  56. package/locales/pt-br/pt-br.messages.json +19 -1
  57. package/locales/ru-ru/ru-ru.messages.json +19 -1
  58. package/locales/tr-tr/tr-tr.messages.json +19 -1
  59. package/locales/zh-cn/zh-cn.messages.json +19 -1
  60. package/locales/zh-tw/zh-tw.messages.json +19 -1
  61. package/masked-text-box/package.json +4 -0
  62. package/package.json +21 -1
  63. package/separator/package.json +4 -0
  64. package/toolbar/package.json +4 -0
  65. package/types/nanahoshi-mona-ui-alert.d.ts +144 -0
  66. package/types/nanahoshi-mona-ui-avatar.d.ts +66 -0
  67. package/types/nanahoshi-mona-ui-badge.d.ts +82 -0
  68. package/types/nanahoshi-mona-ui-i18n.d.ts +44 -0
  69. package/types/nanahoshi-mona-ui-internal-list.d.ts +12 -0
  70. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +18 -0
  71. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +18 -0
  72. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +18 -0
  73. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +18 -0
  74. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +18 -0
  75. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +18 -0
  76. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +18 -0
  77. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +18 -0
  78. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +18 -0
  79. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +18 -0
  80. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +18 -0
  81. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +18 -0
  82. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +18 -0
  83. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +18 -0
  84. package/types/nanahoshi-mona-ui-masked-text-box.d.ts +391 -0
  85. package/types/nanahoshi-mona-ui-multi-select.d.ts +38 -0
  86. package/types/nanahoshi-mona-ui-separator.d.ts +66 -0
  87. package/types/nanahoshi-mona-ui-toolbar.d.ts +183 -0
@@ -0,0 +1,1302 @@
1
+ import { NgTemplateOutlet } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { Component, Directive, ElementRef, TemplateRef, afterNextRender, booleanAttribute, computed, contentChildren, effect, inject, input, isDevMode, model, output, signal, untracked, viewChild } from "@angular/core";
4
+ import { LucideX } from "@lucide/angular";
5
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
6
+ import { MonaI18nService, normalizeLocalizedDigits } from "@nanahoshi/mona-ui/i18n";
7
+ import { AttributeBinderDirective, createElementControlId, injectEffectiveDisabled, injectLabelAssociation, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
8
+ import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
9
+ import { twMerge } from "tailwind-merge";
10
+ import { cva } from "class-variance-authority";
11
+ var MaskedTextBoxPrefixTemplateDirective = class MaskedTextBoxPrefixTemplateDirective {
12
+ static {
13
+ this.ɵfac = i0.ɵɵngDeclareFactory({
14
+ minVersion: "12.0.0",
15
+ version: "22.2.6",
16
+ ngImport: i0,
17
+ type: MaskedTextBoxPrefixTemplateDirective,
18
+ deps: [],
19
+ target: i0.ɵɵFactoryTarget.Directive
20
+ });
21
+ }
22
+ static {
23
+ this.ɵdir = i0.ɵɵngDeclareDirective({
24
+ minVersion: "14.0.0",
25
+ version: "22.2.6",
26
+ type: MaskedTextBoxPrefixTemplateDirective,
27
+ isStandalone: true,
28
+ selector: "ng-template[monaMaskedTextBoxPrefixTemplate]",
29
+ ngImport: i0
30
+ });
31
+ }
32
+ };
33
+ i0.ɵɵngDeclareClassMetadata({
34
+ minVersion: "12.0.0",
35
+ version: "22.2.6",
36
+ ngImport: i0,
37
+ type: MaskedTextBoxPrefixTemplateDirective,
38
+ decorators: [{
39
+ type: Directive,
40
+ args: [{ selector: "ng-template[monaMaskedTextBoxPrefixTemplate]" }]
41
+ }]
42
+ });
43
+ var MaskedTextBoxSuffixTemplateDirective = class MaskedTextBoxSuffixTemplateDirective {
44
+ static {
45
+ this.ɵfac = i0.ɵɵngDeclareFactory({
46
+ minVersion: "12.0.0",
47
+ version: "22.2.6",
48
+ ngImport: i0,
49
+ type: MaskedTextBoxSuffixTemplateDirective,
50
+ deps: [],
51
+ target: i0.ɵɵFactoryTarget.Directive
52
+ });
53
+ }
54
+ static {
55
+ this.ɵdir = i0.ɵɵngDeclareDirective({
56
+ minVersion: "14.0.0",
57
+ version: "22.2.6",
58
+ type: MaskedTextBoxSuffixTemplateDirective,
59
+ isStandalone: true,
60
+ selector: "ng-template[monaMaskedTextBoxSuffixTemplate]",
61
+ ngImport: i0
62
+ });
63
+ }
64
+ };
65
+ i0.ɵɵngDeclareClassMetadata({
66
+ minVersion: "12.0.0",
67
+ version: "22.2.6",
68
+ ngImport: i0,
69
+ type: MaskedTextBoxSuffixTemplateDirective,
70
+ decorators: [{
71
+ type: Directive,
72
+ args: [{ selector: "ng-template[monaMaskedTextBoxSuffixTemplate]" }]
73
+ }]
74
+ });
75
+ const MASKED_TEXT_BOX_DEFAULT_MESSAGES = {
76
+ characterNotAllowed: "That character doesn't fit here",
77
+ clear: "Clear",
78
+ digitOnly: "Only a digit fits here",
79
+ digitOrSignOnly: "Only a digit, plus or minus fits here",
80
+ letterOnly: "Only a letter fits here",
81
+ letterOrDigitOnly: "Only a letter or a digit fits here"
82
+ };
83
+ const maskedTextBoxThemeVariants = cva(`
84
+ flex w-full min-w-0 items-center
85
+ overflow-hidden
86
+ ${themeControlSurfaceClasses} text-foreground
87
+ border border-input-border shadow-(--shadow-control)
88
+ outline-none focus-visible:outline-hidden
89
+ selection:bg-primary selection:text-primary-foreground
90
+ transition-[color,box-shadow,border] duration-(--mona-motion-standard) ease-in-out
91
+
92
+ data-[disabled='true']:pointer-events-none
93
+ data-[disabled='true']:cursor-not-allowed
94
+ data-[disabled='true']:border-disabled-border
95
+ data-[disabled='true']:bg-disabled-background
96
+ data-[disabled='true']:text-disabled-foreground
97
+ data-[disabled='true']:shadow-none
98
+ data-[readonly='true']:cursor-default
99
+
100
+ focus-within:border-focus-indicator
101
+ focus-within:ring-2 focus-within:ring-focus-indicator/35
102
+
103
+ data-[invalid='true']:border-error
104
+ data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
105
+ data-[invalid='true']:focus-within:border-error
106
+ data-[invalid='true']:focus-within:ring-error/35
107
+ `, { variants: {
108
+ rounded: {
109
+ full: "rounded-full",
110
+ large: "rounded-lg",
111
+ medium: "rounded-md",
112
+ none: "rounded-none",
113
+ small: "rounded-sm"
114
+ },
115
+ size: {
116
+ large: "h-10 text-base",
117
+ medium: "h-9 text-sm",
118
+ small: "h-8 text-xs"
119
+ }
120
+ } });
121
+ const MASKED_TEXT_BOX_FIELD_CLASSES = "relative flex h-full min-w-0 flex-1 items-center";
122
+ const MASKED_TEXT_BOX_GHOST_CLASSES = `
123
+ pointer-events-none absolute inset-0 flex items-center overflow-hidden whitespace-pre px-2
124
+ text-muted-foreground forced-colors:text-[GrayText]
125
+ `;
126
+ const MASKED_TEXT_BOX_INPUT_CLASSES = `
127
+ relative h-full w-full min-w-0 px-2
128
+ bg-transparent border-0 outline-none focus-visible:outline-hidden
129
+ placeholder:text-muted-foreground
130
+ `;
131
+ const DIGIT = /^[0-9]$/;
132
+ const LETTER = /^\p{L}$/u;
133
+ const SPACE = /^\s$/u;
134
+ const isDigit = (char) => DIGIT.test(char);
135
+ const isLetter = (char) => LETTER.test(char);
136
+ const isLetterOrDigit = (char) => isDigit(char) || isLetter(char);
137
+ const isDigitOrSign = (char) => isDigit(char) || char === "+" || char === "-";
138
+ const isNotSpace = (char) => !SPACE.test(char);
139
+ const BUILT_IN_RULES = /* @__PURE__ */ new Map([
140
+ ["#", {
141
+ kind: "digitOrSign",
142
+ optional: true,
143
+ test: isDigitOrSign
144
+ }],
145
+ ["&", {
146
+ kind: "any",
147
+ optional: false,
148
+ test: isNotSpace
149
+ }],
150
+ ["0", {
151
+ kind: "digit",
152
+ optional: false,
153
+ test: isDigit
154
+ }],
155
+ ["9", {
156
+ kind: "digit",
157
+ optional: true,
158
+ test: isDigit
159
+ }],
160
+ ["?", {
161
+ kind: "letter",
162
+ optional: true,
163
+ test: isLetter
164
+ }],
165
+ ["A", {
166
+ kind: "letterOrDigit",
167
+ optional: false,
168
+ test: isLetterOrDigit
169
+ }],
170
+ ["C", {
171
+ kind: "any",
172
+ optional: true,
173
+ test: isNotSpace
174
+ }],
175
+ ["L", {
176
+ kind: "letter",
177
+ optional: false,
178
+ test: isLetter
179
+ }],
180
+ ["a", {
181
+ kind: "letterOrDigit",
182
+ optional: true,
183
+ test: isLetterOrDigit
184
+ }]
185
+ ]);
186
+ function builtInSlot(rule) {
187
+ const fold = rule.kind !== "any";
188
+ return {
189
+ accept: (char) => {
190
+ const folded = fold ? normalizeLocalizedDigits(char) : char;
191
+ return rule.test(folded) ? folded : null;
192
+ },
193
+ kind: rule.kind,
194
+ literal: false,
195
+ optional: rule.optional
196
+ };
197
+ }
198
+ function customSlot(pattern) {
199
+ const rule = new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ""));
200
+ return {
201
+ accept: (char) => rule.test(char) && !SPACE.test(char) ? char : null,
202
+ kind: "custom",
203
+ literal: false,
204
+ optional: false
205
+ };
206
+ }
207
+ function lastFilledSlot(slots) {
208
+ for (let slot = slots.length - 1; slot >= 0; slot--) if (slots[slot] != null) return slot;
209
+ return -1;
210
+ }
211
+ function readPositionally(mask, chars, includeLiterals) {
212
+ const slots = emptySlots(mask);
213
+ if (includeLiterals) {
214
+ if (chars.length > mask.parts.length) return null;
215
+ for (const [index, char] of chars.entries()) {
216
+ const part = mask.parts[index];
217
+ if (part.literal) {
218
+ if (char !== part.char) return null;
219
+ continue;
220
+ }
221
+ if (char === " ") continue;
222
+ const accepted = part.accept(char);
223
+ if (accepted == null) return null;
224
+ slots[mask.slotIndexOfPart[index]] = accepted;
225
+ }
226
+ return slots;
227
+ }
228
+ if (chars.length > mask.slotParts.length) return null;
229
+ for (const [slot, char] of chars.entries()) {
230
+ if (char === " ") continue;
231
+ const accepted = mask.parts[mask.slotParts[slot]].accept(char);
232
+ if (accepted == null) return null;
233
+ slots[slot] = accepted;
234
+ }
235
+ return slots;
236
+ }
237
+ function clearParts(mask, slots, from, to) {
238
+ const next = [...slots];
239
+ for (let part = Math.max(0, from); part < Math.min(to, mask.parts.length); part++) {
240
+ const slot = mask.slotIndexOfPart[part];
241
+ if (slot >= 0) next[slot] = null;
242
+ }
243
+ return next;
244
+ }
245
+ function displayMask(mask, slots, prompt) {
246
+ const last = lastFilledSlot(slots);
247
+ let textParts = last < 0 ? 0 : mask.slotParts[last] + 1;
248
+ while (textParts > 0 && textParts < mask.parts.length && mask.parts[textParts].literal) textParts++;
249
+ let text = "";
250
+ let ghost = "";
251
+ const offsets = [];
252
+ for (const [index, part] of mask.parts.entries()) {
253
+ offsets.push(text.length + ghost.length);
254
+ const shown = part.literal ? part.char : slots[mask.slotIndexOfPart[index]] ?? prompt;
255
+ if (index < textParts) text += shown;
256
+ else ghost += shown;
257
+ }
258
+ offsets.push(text.length + ghost.length);
259
+ return {
260
+ ghost,
261
+ offsets,
262
+ text,
263
+ textParts
264
+ };
265
+ }
266
+ function editMask(mask, slots, start, end, kind, text = "") {
267
+ if (kind === "insert") {
268
+ const insertion = insertText(mask, start < end ? clearParts(mask, slots, start, end) : slots, start, text);
269
+ let caret = insertion.end;
270
+ while (caret < mask.parts.length && mask.parts[caret].literal) caret++;
271
+ return {
272
+ caret,
273
+ rejected: insertion.filled === 0 ? insertion.rejected : null,
274
+ slots: insertion.slots
275
+ };
276
+ }
277
+ if (start < end) return {
278
+ caret: start,
279
+ rejected: null,
280
+ slots: clearParts(mask, slots, start, end)
281
+ };
282
+ const unchanged = {
283
+ caret: start,
284
+ rejected: null,
285
+ slots
286
+ };
287
+ switch (kind) {
288
+ case "deleteBackward": {
289
+ const part = slotPartBefore(mask, start);
290
+ return part < 0 ? unchanged : {
291
+ caret: part,
292
+ rejected: null,
293
+ slots: clearParts(mask, slots, part, part + 1)
294
+ };
295
+ }
296
+ case "deleteForward": {
297
+ const part = slotPartFrom(mask, start);
298
+ return part < 0 ? unchanged : {
299
+ caret: part + 1,
300
+ rejected: null,
301
+ slots: clearParts(mask, slots, part, part + 1)
302
+ };
303
+ }
304
+ case "deleteGroupBackward": {
305
+ const part = slotPartBefore(mask, start);
306
+ if (part < 0) return unchanged;
307
+ const from = groupStart(mask, part);
308
+ return {
309
+ caret: from,
310
+ rejected: null,
311
+ slots: clearParts(mask, slots, from, part + 1)
312
+ };
313
+ }
314
+ case "deleteGroupForward": {
315
+ const part = slotPartFrom(mask, start);
316
+ if (part < 0) return unchanged;
317
+ const to = groupEnd(mask, part);
318
+ return {
319
+ caret: to,
320
+ rejected: null,
321
+ slots: clearParts(mask, slots, part, to)
322
+ };
323
+ }
324
+ case "deleteToEnd": return {
325
+ caret: start,
326
+ rejected: null,
327
+ slots: clearParts(mask, slots, start, mask.parts.length)
328
+ };
329
+ case "deleteToStart": return {
330
+ caret: 0,
331
+ rejected: null,
332
+ slots: clearParts(mask, slots, 0, start)
333
+ };
334
+ }
335
+ }
336
+ function emptySlots(mask) {
337
+ return mask.slotParts.map(() => null);
338
+ }
339
+ function formatMaskedValue(value, mask, options = {}) {
340
+ const parsed = parseMask(mask, options.rules);
341
+ return valueFromSlots(parsed, slotsFromValue(parsed, value, options.includeLiterals ?? false), true);
342
+ }
343
+ function groupEnd(mask, slotPart) {
344
+ let part = slotPart;
345
+ while (part < mask.parts.length && !mask.parts[part].literal) part++;
346
+ return part;
347
+ }
348
+ function groupStart(mask, slotPart) {
349
+ let part = slotPart;
350
+ while (part > 0 && !mask.parts[part - 1].literal) part--;
351
+ return part;
352
+ }
353
+ function insertText(mask, slots, at, text) {
354
+ const { parts, slotIndexOfPart } = mask;
355
+ const next = [...slots];
356
+ let part = at;
357
+ let filled = 0;
358
+ let rejected = null;
359
+ for (const char of text) {
360
+ let target = part;
361
+ while (target < parts.length && parts[target].literal && parts[target].char !== char) target++;
362
+ if (target >= parts.length) break;
363
+ const targetPart = parts[target];
364
+ if (targetPart.literal) {
365
+ part = target + 1;
366
+ continue;
367
+ }
368
+ const accepted = targetPart.accept(char);
369
+ if (accepted == null) {
370
+ rejected ??= targetPart;
371
+ continue;
372
+ }
373
+ next[slotIndexOfPart[target]] = accepted;
374
+ part = target + 1;
375
+ filled++;
376
+ }
377
+ return {
378
+ end: part,
379
+ filled,
380
+ rejected,
381
+ slots: next
382
+ };
383
+ }
384
+ function isMaskComplete(value, mask, options = {}) {
385
+ const parsed = parseMask(mask, options.rules);
386
+ return slotsComplete(parsed, slotsFromValue(parsed, value, options.includeLiterals ?? false));
387
+ }
388
+ function parseMask(mask, rules = {}) {
389
+ const parts = [];
390
+ const chars = Array.from(mask);
391
+ for (let index = 0; index < chars.length; index++) {
392
+ const char = chars[index];
393
+ const builtIn = BUILT_IN_RULES.get(char);
394
+ if (char === "\\" && index + 1 < chars.length) {
395
+ index++;
396
+ parts.push({
397
+ char: chars[index],
398
+ literal: true
399
+ });
400
+ } else if (Object.hasOwn(rules, char)) parts.push(customSlot(rules[char]));
401
+ else if (builtIn) parts.push(builtInSlot(builtIn));
402
+ else parts.push({
403
+ char,
404
+ literal: true
405
+ });
406
+ }
407
+ const slotParts = [];
408
+ return {
409
+ parts,
410
+ slotIndexOfPart: parts.map((part, index) => {
411
+ if (part.literal) return -1;
412
+ slotParts.push(index);
413
+ return slotParts.length - 1;
414
+ }),
415
+ slotParts
416
+ };
417
+ }
418
+ function partAt(display, position) {
419
+ let part = 0;
420
+ while (part < display.textParts && display.offsets[part + 1] <= position) part++;
421
+ return part;
422
+ }
423
+ function slotPartBefore(mask, part) {
424
+ for (let index = Math.min(part, mask.parts.length) - 1; index >= 0; index--) if (!mask.parts[index].literal) return index;
425
+ return -1;
426
+ }
427
+ function slotPartFrom(mask, part) {
428
+ for (let index = Math.max(0, part); index < mask.parts.length; index++) if (!mask.parts[index].literal) return index;
429
+ return -1;
430
+ }
431
+ function slotsComplete(mask, slots) {
432
+ return mask.slotParts.every((part, slot) => slots[slot] != null || mask.parts[part].optional);
433
+ }
434
+ function slotsFromValue(mask, value, includeLiterals) {
435
+ if (!value) return emptySlots(mask);
436
+ return readPositionally(mask, Array.from(value), includeLiterals) ?? insertText(mask, emptySlots(mask), 0, value).slots;
437
+ }
438
+ function valueFromSlots(mask, slots, includeLiterals) {
439
+ const last = lastFilledSlot(slots);
440
+ if (last < 0) return "";
441
+ if (!includeLiterals) return slots.slice(0, last + 1).map((char) => char ?? " ").join("");
442
+ const end = last === mask.slotParts.length - 1 ? mask.parts.length : mask.slotParts[last] + 1;
443
+ return mask.parts.slice(0, end).map((part, index) => part.literal ? part.char : slots[mask.slotIndexOfPart[index]] ?? " ").join("");
444
+ }
445
+ const EDIT_KINDS = {
446
+ deleteByCut: "deleteBackward",
447
+ deleteByDrag: "deleteBackward",
448
+ deleteContent: "deleteForward",
449
+ deleteContentBackward: "deleteBackward",
450
+ deleteContentForward: "deleteForward",
451
+ deleteHardLineBackward: "deleteToStart",
452
+ deleteHardLineForward: "deleteToEnd",
453
+ deleteSoftLineBackward: "deleteToStart",
454
+ deleteSoftLineForward: "deleteToEnd",
455
+ deleteWordBackward: "deleteGroupBackward",
456
+ deleteWordForward: "deleteGroupForward",
457
+ insertFromDrop: "insert",
458
+ insertFromPaste: "insert",
459
+ insertFromPasteAsQuotation: "insert",
460
+ insertFromYank: "insert",
461
+ insertReplacementText: "insert",
462
+ insertText: "insert"
463
+ };
464
+ const HISTORY_LIMIT = 100;
465
+ var MaskedTextBoxComponent = class MaskedTextBoxComponent {
466
+ #announcer;
467
+ #hostElementRef;
468
+ #i18n;
469
+ #label;
470
+ #mask;
471
+ #prompt;
472
+ #redoStack;
473
+ #slots;
474
+ #undoStack;
475
+ #composing;
476
+ #ownValue;
477
+ #typing;
478
+ constructor() {
479
+ this.#announcer = injectLiveAnnouncer();
480
+ this.#hostElementRef = inject(ElementRef);
481
+ this.#i18n = inject(MonaI18nService);
482
+ this.#label = injectLabelAssociation({
483
+ ariaDescribedBy: () => this.ariaDescribedBy(),
484
+ ariaLabel: () => this.ariaLabel(),
485
+ ariaLabelledBy: () => this.ariaLabelledBy(),
486
+ focus: () => this.focus()
487
+ });
488
+ this.#mask = computed(() => parseMask(this.mask(), this.rules()), ...ngDevMode ? [{ debugName: "#mask" }] : /* istanbul ignore next */ []);
489
+ this.#prompt = computed(() => Array.from(this.prompt())[0] ?? " ", ...ngDevMode ? [{ debugName: "#prompt" }] : /* istanbul ignore next */ []);
490
+ this.#redoStack = [];
491
+ this.#slots = computed(() => slotsFromValue(this.#mask(), this.value() ?? "", this.includeLiterals()), ...ngDevMode ? [{ debugName: "#slots" }] : /* istanbul ignore next */ []);
492
+ this.#undoStack = [];
493
+ this.#composing = false;
494
+ this.#ownValue = null;
495
+ this.#typing = false;
496
+ this.classes = computed(() => twMerge(maskedTextBoxThemeVariants({
497
+ rounded: this.rounded(),
498
+ size: this.size()
499
+ }), this.userClass()), ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
500
+ this.complete = computed(() => slotsComplete(this.#mask(), this.#slots()), ...ngDevMode ? [{ debugName: "complete" }] : /* istanbul ignore next */ []);
501
+ this.describedBy = this.#label.describedBy;
502
+ this.display = computed(() => displayMask(this.#mask(), this.#slots(), this.#prompt()), ...ngDevMode ? [{ debugName: "display" }] : /* istanbul ignore next */ []);
503
+ this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
504
+ this.empty = computed(() => this.#slots().every((slot) => slot == null), ...ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []);
505
+ this.fieldClass = MASKED_TEXT_BOX_FIELD_CLASSES;
506
+ this.focused = signal(false, ...ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []);
507
+ this.ghostClass = MASKED_TEXT_BOX_GHOST_CLASSES;
508
+ this.ghostShift = signal(0, ...ngDevMode ? [{ debugName: "ghostShift" }] : /* istanbul ignore next */ []);
509
+ this.ghostTransform = computed(() => {
510
+ const shift = this.ghostShift();
511
+ return shift === 0 ? null : `translateX(${-shift}px)`;
512
+ }, ...ngDevMode ? [{ debugName: "ghostTransform" }] : /* istanbul ignore next */ []);
513
+ this.ghostVisible = computed(() => !this.empty() || this.focused() || !this.placeholder(), ...ngDevMode ? [{ debugName: "ghostVisible" }] : /* istanbul ignore next */ []);
514
+ this.inputClasses = computed(() => twMerge(MASKED_TEXT_BOX_INPUT_CLASSES, this.inputClass()), ...ngDevMode ? [{ debugName: "inputClasses" }] : /* istanbul ignore next */ []);
515
+ this.inputMode = computed(() => {
516
+ const attribute = this.inputAttributes()["inputmode"];
517
+ if (attribute != null && attribute !== false) return String(attribute);
518
+ const slots = this.#mask().parts.filter((part) => !part.literal);
519
+ return slots.length > 0 && slots.every((slot) => slot.kind === "digit") ? "numeric" : null;
520
+ }, ...ngDevMode ? [{ debugName: "inputMode" }] : /* istanbul ignore next */ []);
521
+ this.inputRef = viewChild.required("input", ...ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []);
522
+ this.invalidInput = computed(() => this.touched() && (this.invalid() || this.required() && this.empty() || !this.empty() && !this.complete()), ...ngDevMode ? [{ debugName: "invalidInput" }] : /* istanbul ignore next */ []);
523
+ this.labelledBy = this.#label.labelledBy;
524
+ this.messages = this.#i18n.componentMessages("maskedTextBox", MASKED_TEXT_BOX_DEFAULT_MESSAGES);
525
+ this.prefixTemplateList = contentChildren(MaskedTextBoxPrefixTemplateDirective, {
526
+ ...ngDevMode ? { debugName: "prefixTemplateList" } : /* istanbul ignore next */ {},
527
+ read: TemplateRef
528
+ });
529
+ this.showClearButton = computed(() => this.clearButton() && !this.effectiveDisabled() && !this.readonly() && !this.empty(), ...ngDevMode ? [{ debugName: "showClearButton" }] : /* istanbul ignore next */ []);
530
+ this.shownPlaceholder = computed(() => this.ghostVisible() ? null : this.placeholder(), ...ngDevMode ? [{ debugName: "shownPlaceholder" }] : /* istanbul ignore next */ []);
531
+ this.suffixTemplateList = contentChildren(MaskedTextBoxSuffixTemplateDirective, {
532
+ ...ngDevMode ? { debugName: "suffixTemplateList" } : /* istanbul ignore next */ {},
533
+ read: TemplateRef
534
+ });
535
+ this.ariaDescribedBy = input("", {
536
+ ...ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {},
537
+ alias: "aria-describedby"
538
+ });
539
+ this.ariaLabel = input("", {
540
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
541
+ alias: "aria-label"
542
+ });
543
+ this.ariaLabelledBy = input("", {
544
+ ...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
545
+ alias: "aria-labelledby"
546
+ });
547
+ this.clearButton = input(false, {
548
+ ...ngDevMode ? { debugName: "clearButton" } : /* istanbul ignore next */ {},
549
+ transform: booleanAttribute
550
+ });
551
+ this.disabled = input(false, {
552
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
553
+ transform: booleanAttribute
554
+ });
555
+ this.includeLiterals = input(false, {
556
+ ...ngDevMode ? { debugName: "includeLiterals" } : /* istanbul ignore next */ {},
557
+ transform: booleanAttribute
558
+ });
559
+ this.inputAttributes = input({}, ...ngDevMode ? [{ debugName: "inputAttributes" }] : /* istanbul ignore next */ []);
560
+ this.inputBlur = output();
561
+ this.inputClass = input("", ...ngDevMode ? [{ debugName: "inputClass" }] : /* istanbul ignore next */ []);
562
+ this.inputFocus = output();
563
+ this.inputId = input(createElementControlId(), ...ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []);
564
+ this.inputStyle = input(null, ...ngDevMode ? [{ debugName: "inputStyle" }] : /* istanbul ignore next */ []);
565
+ this.invalid = input(false, {
566
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
567
+ transform: booleanAttribute
568
+ });
569
+ this.mask = input("", ...ngDevMode ? [{ debugName: "mask" }] : /* istanbul ignore next */ []);
570
+ this.name = input("", ...ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []);
571
+ this.placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
572
+ this.prompt = input("_", ...ngDevMode ? [{ debugName: "prompt" }] : /* istanbul ignore next */ []);
573
+ this.readonly = input(false, {
574
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
575
+ transform: booleanAttribute
576
+ });
577
+ this.required = input(false, {
578
+ ...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
579
+ transform: booleanAttribute
580
+ });
581
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
582
+ this.rules = input({}, ...ngDevMode ? [{ debugName: "rules" }] : /* istanbul ignore next */ []);
583
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
584
+ this.touch = output();
585
+ this.touched = input(false, {
586
+ ...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
587
+ transform: booleanAttribute
588
+ });
589
+ this.userClass = input("", {
590
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
591
+ alias: "class"
592
+ });
593
+ this.value = model("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
594
+ afterNextRender({ read: () => this.#warnIfNoMask() });
595
+ effect(() => {
596
+ const value = this.value() ?? "";
597
+ const normalized = valueFromSlots(this.#mask(), this.#slots(), this.includeLiterals());
598
+ untracked(() => {
599
+ if (value !== this.#ownValue) {
600
+ this.#undoStack.length = 0;
601
+ this.#redoStack.length = 0;
602
+ this.#typing = false;
603
+ }
604
+ if (normalized !== value) this.#setValue(normalized);
605
+ });
606
+ });
607
+ }
608
+ focus(options) {
609
+ const input = this.inputRef().nativeElement;
610
+ input.focus(options);
611
+ const display = this.display();
612
+ const firstEmpty = this.#slots().findIndex((slot) => slot == null);
613
+ const part = firstEmpty < 0 ? display.textParts : this.#mask().slotParts[firstEmpty];
614
+ const caret = Math.min(display.offsets[part] ?? display.text.length, display.text.length);
615
+ input.setSelectionRange(caret, caret);
616
+ }
617
+ setLabelledBy(id) {
618
+ this.#label.setLabelledBy(id);
619
+ }
620
+ onBeforeInput(event) {
621
+ if (event.isComposing || event.inputType.includes("Composition")) return;
622
+ if (event.inputType === "historyUndo" || event.inputType === "historyRedo") {
623
+ event.preventDefault();
624
+ this.#travel(event.inputType === "historyUndo" ? this.#undoStack : this.#redoStack);
625
+ return;
626
+ }
627
+ const kind = EDIT_KINDS[event.inputType];
628
+ if (kind === void 0) return;
629
+ event.preventDefault();
630
+ const text = kind === "insert" ? event.data ?? event.dataTransfer?.getData("text/plain") ?? "" : "";
631
+ this.#edit(kind, text, event.inputType === "insertText");
632
+ }
633
+ onBlur(event) {
634
+ this.focused.set(false);
635
+ this.inputBlur.emit(event);
636
+ }
637
+ onClearClick() {
638
+ this.#apply(emptySlots(this.#mask()), 0, false);
639
+ this.inputRef().nativeElement.focus();
640
+ }
641
+ onCompositionEnd() {
642
+ this.#composing = false;
643
+ this.#fitNativeChange();
644
+ }
645
+ onCompositionStart() {
646
+ this.#composing = true;
647
+ }
648
+ onCut(event) {
649
+ const input = this.inputRef().nativeElement;
650
+ const start = input.selectionStart ?? 0;
651
+ const end = input.selectionEnd ?? 0;
652
+ if (start === end || this.effectiveDisabled() || this.readonly()) return;
653
+ event.preventDefault();
654
+ event.clipboardData?.setData("text/plain", input.value.slice(start, end));
655
+ this.#edit("deleteBackward", "", false);
656
+ }
657
+ onFocus(event) {
658
+ this.focused.set(true);
659
+ this.inputFocus.emit(event);
660
+ }
661
+ onFocusOut(event) {
662
+ const nextTarget = event.relatedTarget;
663
+ if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) return;
664
+ this.touch.emit();
665
+ }
666
+ onInput(event) {
667
+ if (this.#composing || event instanceof InputEvent && event.isComposing) return;
668
+ this.#fitNativeChange();
669
+ }
670
+ onKeydown(event) {
671
+ if (event.key.length > 1) this.#typing = false;
672
+ if (!(event.ctrlKey || event.metaKey) || event.altKey) return;
673
+ const key = event.key.toLowerCase();
674
+ if (key === "z" && !event.shiftKey) {
675
+ event.preventDefault();
676
+ this.#travel(this.#undoStack);
677
+ } else if (key === "z" && event.shiftKey || key === "y" && event.ctrlKey && !event.metaKey) {
678
+ event.preventDefault();
679
+ this.#travel(this.#redoStack);
680
+ }
681
+ }
682
+ onPaste(event) {
683
+ const text = event.clipboardData?.getData("text") ?? "";
684
+ if (!text || this.effectiveDisabled() || this.readonly()) return;
685
+ event.preventDefault();
686
+ this.#edit("insert", text, false);
687
+ }
688
+ onPointerDown() {
689
+ this.#typing = false;
690
+ }
691
+ onScroll() {
692
+ this.ghostShift.set(this.inputRef().nativeElement.scrollLeft);
693
+ }
694
+ #announceRejection(slot) {
695
+ const messages = this.messages();
696
+ const message = {
697
+ any: messages.characterNotAllowed,
698
+ custom: messages.characterNotAllowed,
699
+ digit: messages.digitOnly,
700
+ digitOrSign: messages.digitOrSignOnly,
701
+ letter: messages.letterOnly,
702
+ letterOrDigit: messages.letterOrDigitOnly
703
+ }[slot.kind];
704
+ this.#announcer.announce(message, "polite");
705
+ }
706
+ #apply(slots, caret, typing) {
707
+ const current = this.#slots();
708
+ const changed = slots.some((slot, index) => slot !== current[index]);
709
+ if (changed && !(typing && this.#typing)) {
710
+ this.#undoStack.push({
711
+ caret: this.#caretPart(),
712
+ slots: current
713
+ });
714
+ if (this.#undoStack.length > HISTORY_LIMIT) this.#undoStack.shift();
715
+ this.#redoStack.length = 0;
716
+ }
717
+ if (changed) this.#typing = typing;
718
+ this.#write(slots, caret);
719
+ }
720
+ #caretPart() {
721
+ const input = this.inputRef().nativeElement;
722
+ return partAt(this.display(), input.selectionStart ?? input.value.length);
723
+ }
724
+ #edit(kind, text, typed) {
725
+ if (this.effectiveDisabled() || this.readonly()) return;
726
+ const input = this.inputRef().nativeElement;
727
+ const display = this.display();
728
+ const start = partAt(display, input.selectionStart ?? display.text.length);
729
+ const end = partAt(display, input.selectionEnd ?? display.text.length);
730
+ const result = editMask(this.#mask(), this.#slots(), start, end, kind, text);
731
+ if (result.rejected) this.#announceRejection(result.rejected);
732
+ this.#apply(result.slots, result.caret, typed);
733
+ }
734
+ #fitNativeChange() {
735
+ const input = this.inputRef().nativeElement;
736
+ const display = this.display();
737
+ const before = display.text;
738
+ const after = input.value;
739
+ if (before === after) return;
740
+ if (this.effectiveDisabled() || this.readonly()) {
741
+ input.value = before;
742
+ return;
743
+ }
744
+ let prefix = 0;
745
+ while (prefix < before.length && prefix < after.length && before[prefix] === after[prefix]) prefix++;
746
+ let suffix = 0;
747
+ while (suffix < before.length - prefix && suffix < after.length - prefix && before[before.length - 1 - suffix] === after[after.length - 1 - suffix]) suffix++;
748
+ const start = partAt(display, prefix);
749
+ const end = partAt(display, before.length - suffix);
750
+ const inserted = after.slice(prefix, after.length - suffix);
751
+ const result = inserted ? editMask(this.#mask(), this.#slots(), start, end, "insert", inserted) : editMask(this.#mask(), this.#slots(), start, end, "deleteForward");
752
+ if (result.rejected) this.#announceRejection(result.rejected);
753
+ this.#apply(result.slots, result.caret, false);
754
+ }
755
+ #setValue(value) {
756
+ this.#ownValue = value;
757
+ if (value !== this.value()) this.value.set(value);
758
+ }
759
+ #travel(from) {
760
+ if (this.effectiveDisabled() || this.readonly()) return;
761
+ const snapshot = from.pop();
762
+ if (snapshot == null) return;
763
+ (from === this.#undoStack ? this.#redoStack : this.#undoStack).push({
764
+ caret: this.#caretPart(),
765
+ slots: this.#slots()
766
+ });
767
+ this.#typing = false;
768
+ this.#write(snapshot.slots, snapshot.caret);
769
+ }
770
+ #warnIfNoMask() {
771
+ if (isDevMode() && this.#mask().slotParts.length === 0) console.warn("[Mona MaskedTextBox] The mask has no slots, so nothing can be typed. Set mask, such as \"(000) 000-0000\".", this.#hostElementRef.nativeElement);
772
+ }
773
+ #write(slots, caret) {
774
+ const display = displayMask(this.#mask(), slots, this.#prompt());
775
+ const input = this.inputRef().nativeElement;
776
+ input.value = display.text;
777
+ const position = Math.min(display.offsets[caret] ?? display.text.length, display.text.length);
778
+ if (input.ownerDocument.activeElement === input) input.setSelectionRange(position, position);
779
+ this.#setValue(valueFromSlots(this.#mask(), slots, this.includeLiterals()));
780
+ this.ghostShift.set(input.scrollLeft);
781
+ }
782
+ static {
783
+ this.ɵfac = i0.ɵɵngDeclareFactory({
784
+ minVersion: "12.0.0",
785
+ version: "22.2.6",
786
+ ngImport: i0,
787
+ type: MaskedTextBoxComponent,
788
+ deps: [],
789
+ target: i0.ɵɵFactoryTarget.Component
790
+ });
791
+ }
792
+ static {
793
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
794
+ minVersion: "17.0.0",
795
+ version: "22.2.6",
796
+ type: MaskedTextBoxComponent,
797
+ isStandalone: true,
798
+ selector: "mona-masked-text-box",
799
+ inputs: {
800
+ ariaDescribedBy: {
801
+ classPropertyName: "ariaDescribedBy",
802
+ publicName: "aria-describedby",
803
+ isSignal: true,
804
+ isRequired: false,
805
+ transformFunction: null
806
+ },
807
+ ariaLabel: {
808
+ classPropertyName: "ariaLabel",
809
+ publicName: "aria-label",
810
+ isSignal: true,
811
+ isRequired: false,
812
+ transformFunction: null
813
+ },
814
+ ariaLabelledBy: {
815
+ classPropertyName: "ariaLabelledBy",
816
+ publicName: "aria-labelledby",
817
+ isSignal: true,
818
+ isRequired: false,
819
+ transformFunction: null
820
+ },
821
+ clearButton: {
822
+ classPropertyName: "clearButton",
823
+ publicName: "clearButton",
824
+ isSignal: true,
825
+ isRequired: false,
826
+ transformFunction: null
827
+ },
828
+ disabled: {
829
+ classPropertyName: "disabled",
830
+ publicName: "disabled",
831
+ isSignal: true,
832
+ isRequired: false,
833
+ transformFunction: null
834
+ },
835
+ includeLiterals: {
836
+ classPropertyName: "includeLiterals",
837
+ publicName: "includeLiterals",
838
+ isSignal: true,
839
+ isRequired: false,
840
+ transformFunction: null
841
+ },
842
+ inputAttributes: {
843
+ classPropertyName: "inputAttributes",
844
+ publicName: "inputAttributes",
845
+ isSignal: true,
846
+ isRequired: false,
847
+ transformFunction: null
848
+ },
849
+ inputClass: {
850
+ classPropertyName: "inputClass",
851
+ publicName: "inputClass",
852
+ isSignal: true,
853
+ isRequired: false,
854
+ transformFunction: null
855
+ },
856
+ inputId: {
857
+ classPropertyName: "inputId",
858
+ publicName: "inputId",
859
+ isSignal: true,
860
+ isRequired: false,
861
+ transformFunction: null
862
+ },
863
+ inputStyle: {
864
+ classPropertyName: "inputStyle",
865
+ publicName: "inputStyle",
866
+ isSignal: true,
867
+ isRequired: false,
868
+ transformFunction: null
869
+ },
870
+ invalid: {
871
+ classPropertyName: "invalid",
872
+ publicName: "invalid",
873
+ isSignal: true,
874
+ isRequired: false,
875
+ transformFunction: null
876
+ },
877
+ mask: {
878
+ classPropertyName: "mask",
879
+ publicName: "mask",
880
+ isSignal: true,
881
+ isRequired: false,
882
+ transformFunction: null
883
+ },
884
+ name: {
885
+ classPropertyName: "name",
886
+ publicName: "name",
887
+ isSignal: true,
888
+ isRequired: false,
889
+ transformFunction: null
890
+ },
891
+ placeholder: {
892
+ classPropertyName: "placeholder",
893
+ publicName: "placeholder",
894
+ isSignal: true,
895
+ isRequired: false,
896
+ transformFunction: null
897
+ },
898
+ prompt: {
899
+ classPropertyName: "prompt",
900
+ publicName: "prompt",
901
+ isSignal: true,
902
+ isRequired: false,
903
+ transformFunction: null
904
+ },
905
+ readonly: {
906
+ classPropertyName: "readonly",
907
+ publicName: "readonly",
908
+ isSignal: true,
909
+ isRequired: false,
910
+ transformFunction: null
911
+ },
912
+ required: {
913
+ classPropertyName: "required",
914
+ publicName: "required",
915
+ isSignal: true,
916
+ isRequired: false,
917
+ transformFunction: null
918
+ },
919
+ rounded: {
920
+ classPropertyName: "rounded",
921
+ publicName: "rounded",
922
+ isSignal: true,
923
+ isRequired: false,
924
+ transformFunction: null
925
+ },
926
+ rules: {
927
+ classPropertyName: "rules",
928
+ publicName: "rules",
929
+ isSignal: true,
930
+ isRequired: false,
931
+ transformFunction: null
932
+ },
933
+ size: {
934
+ classPropertyName: "size",
935
+ publicName: "size",
936
+ isSignal: true,
937
+ isRequired: false,
938
+ transformFunction: null
939
+ },
940
+ touched: {
941
+ classPropertyName: "touched",
942
+ publicName: "touched",
943
+ isSignal: true,
944
+ isRequired: false,
945
+ transformFunction: null
946
+ },
947
+ userClass: {
948
+ classPropertyName: "userClass",
949
+ publicName: "class",
950
+ isSignal: true,
951
+ isRequired: false,
952
+ transformFunction: null
953
+ },
954
+ value: {
955
+ classPropertyName: "value",
956
+ publicName: "value",
957
+ isSignal: true,
958
+ isRequired: false,
959
+ transformFunction: null
960
+ }
961
+ },
962
+ outputs: {
963
+ inputBlur: "inputBlur",
964
+ inputFocus: "inputFocus",
965
+ touch: "touch",
966
+ value: "valueChange"
967
+ },
968
+ host: {
969
+ listeners: { "focusout": "onFocusOut($event)" },
970
+ properties: {
971
+ "attr.aria-describedby": "null",
972
+ "attr.aria-label": "null",
973
+ "attr.aria-labelledby": "null",
974
+ "attr.data-complete": "complete() || null",
975
+ "attr.data-disabled": "effectiveDisabled() || null",
976
+ "attr.data-invalid": "invalidInput() || null",
977
+ "attr.data-readonly": "readonly() || null",
978
+ "attr.data-required": "required() || null",
979
+ "class": "classes()"
980
+ }
981
+ },
982
+ queries: [{
983
+ propertyName: "prefixTemplateList",
984
+ predicate: MaskedTextBoxPrefixTemplateDirective,
985
+ read: TemplateRef,
986
+ isSignal: true
987
+ }, {
988
+ propertyName: "suffixTemplateList",
989
+ predicate: MaskedTextBoxSuffixTemplateDirective,
990
+ read: TemplateRef,
991
+ isSignal: true
992
+ }],
993
+ viewQueries: [{
994
+ propertyName: "inputRef",
995
+ first: true,
996
+ predicate: ["input"],
997
+ descendants: true,
998
+ isSignal: true
999
+ }],
1000
+ ngImport: i0,
1001
+ template: "@for (prefixTemplate of prefixTemplateList(); track $index) {\n <span class=\"flex h-full flex-wrap items-center\">\n <ng-container *ngTemplateOutlet=\"prefixTemplate\"></ng-container>\n </span>\n}\n\n<!-- Masked values, such as phone numbers and codes, read left to right in every language. -->\n<span [class]=\"fieldClass\" dir=\"ltr\">\n @if (ghostVisible()) {\n <span [class]=\"ghostClass\" [style.transform]=\"ghostTransform()\" aria-hidden=\"true\">\n <span class=\"invisible\">{{ display().text }}</span><span>{{ display().ghost }}</span>\n </span>\n }\n <input\n type=\"text\"\n spellcheck=\"false\"\n [id]=\"inputId()\"\n [class]=\"inputClasses()\"\n [style]=\"inputStyle()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n [required]=\"required()\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-invalid]=\"invalidInput() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.inputmode]=\"inputMode()\"\n [attr.name]=\"name() || null\"\n [attr.placeholder]=\"shownPlaceholder() || null\"\n [monaAttributeBinder]=\"inputAttributes()\"\n [value]=\"display().text\"\n (beforeinput)=\"onBeforeInput($event)\"\n (input)=\"onInput($event)\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd()\"\n (cut)=\"onCut($event)\"\n (paste)=\"onPaste($event)\"\n (keydown)=\"onKeydown($event)\"\n (pointerdown)=\"onPointerDown()\"\n (scroll)=\"onScroll()\"\n (select)=\"onScroll()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n #input />\n</span>\n\n@if (showClearButton()) {\n <button\n monaButton\n type=\"button\"\n look=\"ghost\"\n size=\"small\"\n class=\"me-1 size-6 shrink-0 p-0 text-muted-foreground hover:text-foreground\"\n [attr.aria-label]=\"messages().clear\"\n (click)=\"onClearClick()\">\n <svg lucideX class=\"size-4\"></svg>\n </button>\n}\n\n@for (suffixTemplate of suffixTemplateList(); track $index) {\n <span class=\"flex h-full flex-wrap items-center\">\n <ng-container *ngTemplateOutlet=\"suffixTemplate\"></ng-container>\n </span>\n}\n",
1002
+ dependencies: [
1003
+ {
1004
+ kind: "directive",
1005
+ type: NgTemplateOutlet,
1006
+ selector: "[ngTemplateOutlet]",
1007
+ inputs: [
1008
+ "ngTemplateOutletContext",
1009
+ "ngTemplateOutlet",
1010
+ "ngTemplateOutletInjector"
1011
+ ]
1012
+ },
1013
+ {
1014
+ kind: "directive",
1015
+ type: ButtonDirective,
1016
+ selector: "button[monaButton]",
1017
+ inputs: [
1018
+ "aria-haspopup",
1019
+ "disabled",
1020
+ "iconOnly",
1021
+ "loading",
1022
+ "look",
1023
+ "rounded",
1024
+ "selected",
1025
+ "size",
1026
+ "tabindex",
1027
+ "toggleable",
1028
+ "type",
1029
+ "class",
1030
+ "value"
1031
+ ],
1032
+ outputs: ["lookChange", "selectedChange"]
1033
+ },
1034
+ {
1035
+ kind: "directive",
1036
+ type: AttributeBinderDirective,
1037
+ selector: "[monaAttributeBinder]",
1038
+ inputs: ["monaAttributeBinder"]
1039
+ },
1040
+ {
1041
+ kind: "component",
1042
+ type: LucideX,
1043
+ selector: "svg[lucideX]"
1044
+ }
1045
+ ]
1046
+ });
1047
+ }
1048
+ };
1049
+ i0.ɵɵngDeclareClassMetadata({
1050
+ minVersion: "12.0.0",
1051
+ version: "22.2.6",
1052
+ ngImport: i0,
1053
+ type: MaskedTextBoxComponent,
1054
+ decorators: [{
1055
+ type: Component,
1056
+ args: [{
1057
+ selector: "mona-masked-text-box",
1058
+ imports: [
1059
+ NgTemplateOutlet,
1060
+ ButtonDirective,
1061
+ AttributeBinderDirective,
1062
+ LucideX
1063
+ ],
1064
+ host: {
1065
+ "[attr.aria-describedby]": "null",
1066
+ "[attr.aria-label]": "null",
1067
+ "[attr.aria-labelledby]": "null",
1068
+ "[attr.data-complete]": "complete() || null",
1069
+ "[attr.data-disabled]": "effectiveDisabled() || null",
1070
+ "[attr.data-invalid]": "invalidInput() || null",
1071
+ "[attr.data-readonly]": "readonly() || null",
1072
+ "[attr.data-required]": "required() || null",
1073
+ "[class]": "classes()",
1074
+ "(focusout)": "onFocusOut($event)"
1075
+ },
1076
+ template: "@for (prefixTemplate of prefixTemplateList(); track $index) {\n <span class=\"flex h-full flex-wrap items-center\">\n <ng-container *ngTemplateOutlet=\"prefixTemplate\"></ng-container>\n </span>\n}\n\n<!-- Masked values, such as phone numbers and codes, read left to right in every language. -->\n<span [class]=\"fieldClass\" dir=\"ltr\">\n @if (ghostVisible()) {\n <span [class]=\"ghostClass\" [style.transform]=\"ghostTransform()\" aria-hidden=\"true\">\n <span class=\"invisible\">{{ display().text }}</span><span>{{ display().ghost }}</span>\n </span>\n }\n <input\n type=\"text\"\n spellcheck=\"false\"\n [id]=\"inputId()\"\n [class]=\"inputClasses()\"\n [style]=\"inputStyle()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n [required]=\"required()\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-invalid]=\"invalidInput() ? 'true' : null\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.inputmode]=\"inputMode()\"\n [attr.name]=\"name() || null\"\n [attr.placeholder]=\"shownPlaceholder() || null\"\n [monaAttributeBinder]=\"inputAttributes()\"\n [value]=\"display().text\"\n (beforeinput)=\"onBeforeInput($event)\"\n (input)=\"onInput($event)\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd()\"\n (cut)=\"onCut($event)\"\n (paste)=\"onPaste($event)\"\n (keydown)=\"onKeydown($event)\"\n (pointerdown)=\"onPointerDown()\"\n (scroll)=\"onScroll()\"\n (select)=\"onScroll()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n #input />\n</span>\n\n@if (showClearButton()) {\n <button\n monaButton\n type=\"button\"\n look=\"ghost\"\n size=\"small\"\n class=\"me-1 size-6 shrink-0 p-0 text-muted-foreground hover:text-foreground\"\n [attr.aria-label]=\"messages().clear\"\n (click)=\"onClearClick()\">\n <svg lucideX class=\"size-4\"></svg>\n </button>\n}\n\n@for (suffixTemplate of suffixTemplateList(); track $index) {\n <span class=\"flex h-full flex-wrap items-center\">\n <ng-container *ngTemplateOutlet=\"suffixTemplate\"></ng-container>\n </span>\n}\n"
1077
+ }]
1078
+ }],
1079
+ ctorParameters: () => [],
1080
+ propDecorators: {
1081
+ inputRef: [{
1082
+ type: i0.ViewChild,
1083
+ args: ["input", { isSignal: true }]
1084
+ }],
1085
+ prefixTemplateList: [{
1086
+ type: i0.ContentChildren,
1087
+ args: [i0.forwardRef(() => MaskedTextBoxPrefixTemplateDirective), {
1088
+ read: TemplateRef,
1089
+ isSignal: true
1090
+ }]
1091
+ }],
1092
+ suffixTemplateList: [{
1093
+ type: i0.ContentChildren,
1094
+ args: [i0.forwardRef(() => MaskedTextBoxSuffixTemplateDirective), {
1095
+ read: TemplateRef,
1096
+ isSignal: true
1097
+ }]
1098
+ }],
1099
+ ariaDescribedBy: [{
1100
+ type: i0.Input,
1101
+ args: [{
1102
+ isSignal: true,
1103
+ alias: "aria-describedby",
1104
+ required: false
1105
+ }]
1106
+ }],
1107
+ ariaLabel: [{
1108
+ type: i0.Input,
1109
+ args: [{
1110
+ isSignal: true,
1111
+ alias: "aria-label",
1112
+ required: false
1113
+ }]
1114
+ }],
1115
+ ariaLabelledBy: [{
1116
+ type: i0.Input,
1117
+ args: [{
1118
+ isSignal: true,
1119
+ alias: "aria-labelledby",
1120
+ required: false
1121
+ }]
1122
+ }],
1123
+ clearButton: [{
1124
+ type: i0.Input,
1125
+ args: [{
1126
+ isSignal: true,
1127
+ alias: "clearButton",
1128
+ required: false
1129
+ }]
1130
+ }],
1131
+ disabled: [{
1132
+ type: i0.Input,
1133
+ args: [{
1134
+ isSignal: true,
1135
+ alias: "disabled",
1136
+ required: false
1137
+ }]
1138
+ }],
1139
+ includeLiterals: [{
1140
+ type: i0.Input,
1141
+ args: [{
1142
+ isSignal: true,
1143
+ alias: "includeLiterals",
1144
+ required: false
1145
+ }]
1146
+ }],
1147
+ inputAttributes: [{
1148
+ type: i0.Input,
1149
+ args: [{
1150
+ isSignal: true,
1151
+ alias: "inputAttributes",
1152
+ required: false
1153
+ }]
1154
+ }],
1155
+ inputBlur: [{
1156
+ type: i0.Output,
1157
+ args: ["inputBlur"]
1158
+ }],
1159
+ inputClass: [{
1160
+ type: i0.Input,
1161
+ args: [{
1162
+ isSignal: true,
1163
+ alias: "inputClass",
1164
+ required: false
1165
+ }]
1166
+ }],
1167
+ inputFocus: [{
1168
+ type: i0.Output,
1169
+ args: ["inputFocus"]
1170
+ }],
1171
+ inputId: [{
1172
+ type: i0.Input,
1173
+ args: [{
1174
+ isSignal: true,
1175
+ alias: "inputId",
1176
+ required: false
1177
+ }]
1178
+ }],
1179
+ inputStyle: [{
1180
+ type: i0.Input,
1181
+ args: [{
1182
+ isSignal: true,
1183
+ alias: "inputStyle",
1184
+ required: false
1185
+ }]
1186
+ }],
1187
+ invalid: [{
1188
+ type: i0.Input,
1189
+ args: [{
1190
+ isSignal: true,
1191
+ alias: "invalid",
1192
+ required: false
1193
+ }]
1194
+ }],
1195
+ mask: [{
1196
+ type: i0.Input,
1197
+ args: [{
1198
+ isSignal: true,
1199
+ alias: "mask",
1200
+ required: false
1201
+ }]
1202
+ }],
1203
+ name: [{
1204
+ type: i0.Input,
1205
+ args: [{
1206
+ isSignal: true,
1207
+ alias: "name",
1208
+ required: false
1209
+ }]
1210
+ }],
1211
+ placeholder: [{
1212
+ type: i0.Input,
1213
+ args: [{
1214
+ isSignal: true,
1215
+ alias: "placeholder",
1216
+ required: false
1217
+ }]
1218
+ }],
1219
+ prompt: [{
1220
+ type: i0.Input,
1221
+ args: [{
1222
+ isSignal: true,
1223
+ alias: "prompt",
1224
+ required: false
1225
+ }]
1226
+ }],
1227
+ readonly: [{
1228
+ type: i0.Input,
1229
+ args: [{
1230
+ isSignal: true,
1231
+ alias: "readonly",
1232
+ required: false
1233
+ }]
1234
+ }],
1235
+ required: [{
1236
+ type: i0.Input,
1237
+ args: [{
1238
+ isSignal: true,
1239
+ alias: "required",
1240
+ required: false
1241
+ }]
1242
+ }],
1243
+ rounded: [{
1244
+ type: i0.Input,
1245
+ args: [{
1246
+ isSignal: true,
1247
+ alias: "rounded",
1248
+ required: false
1249
+ }]
1250
+ }],
1251
+ rules: [{
1252
+ type: i0.Input,
1253
+ args: [{
1254
+ isSignal: true,
1255
+ alias: "rules",
1256
+ required: false
1257
+ }]
1258
+ }],
1259
+ size: [{
1260
+ type: i0.Input,
1261
+ args: [{
1262
+ isSignal: true,
1263
+ alias: "size",
1264
+ required: false
1265
+ }]
1266
+ }],
1267
+ touch: [{
1268
+ type: i0.Output,
1269
+ args: ["touch"]
1270
+ }],
1271
+ touched: [{
1272
+ type: i0.Input,
1273
+ args: [{
1274
+ isSignal: true,
1275
+ alias: "touched",
1276
+ required: false
1277
+ }]
1278
+ }],
1279
+ userClass: [{
1280
+ type: i0.Input,
1281
+ args: [{
1282
+ isSignal: true,
1283
+ alias: "class",
1284
+ required: false
1285
+ }]
1286
+ }],
1287
+ value: [{
1288
+ type: i0.Input,
1289
+ args: [{
1290
+ isSignal: true,
1291
+ alias: "value",
1292
+ required: false
1293
+ }]
1294
+ }, {
1295
+ type: i0.Output,
1296
+ args: ["valueChange"]
1297
+ }]
1298
+ }
1299
+ });
1300
+ export { MASKED_TEXT_BOX_DEFAULT_MESSAGES, MaskedTextBoxComponent, MaskedTextBoxPrefixTemplateDirective, MaskedTextBoxSuffixTemplateDirective, formatMaskedValue, isMaskComplete };
1301
+
1302
+ //# sourceMappingURL=nanahoshi-mona-ui-masked-text-box.mjs.map