@nanahoshi/mona-ui 0.24.11 → 0.25.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 (163) hide show
  1. package/README.md +9 -0
  2. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
  3. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
  4. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
  5. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
  6. package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
  7. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
  8. package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
  9. package/fesm2022/nanahoshi-mona-ui-chart.mjs +27 -22
  10. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
  11. package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
  12. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
  13. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
  14. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
  15. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
  16. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
  17. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
  18. package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
  19. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
  20. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
  21. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
  22. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
  23. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
  24. package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
  25. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
  26. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
  27. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
  28. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
  29. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
  30. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
  31. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
  32. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
  33. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  34. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +39 -4
  35. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
  36. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
  37. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
  38. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
  39. package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
  40. package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
  41. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
  42. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
  43. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +33 -4
  44. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +33 -4
  45. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +33 -4
  46. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +33 -4
  47. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +33 -4
  48. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +33 -4
  49. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +33 -4
  50. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +33 -4
  51. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +33 -4
  52. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +33 -4
  53. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +33 -4
  54. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +33 -4
  55. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +33 -4
  56. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
  57. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
  58. package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
  59. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
  60. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
  61. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
  62. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
  63. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
  64. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
  65. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
  66. package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
  67. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
  68. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
  69. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
  70. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
  71. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
  72. package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
  73. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
  74. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
  75. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
  76. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
  77. package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
  78. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
  79. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
  80. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
  81. package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
  82. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
  83. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
  84. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
  85. package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
  86. package/i18n/catalogs/en-US.messages.json +33 -4
  87. package/locales/ar-sa/ar-sa.messages.json +33 -4
  88. package/locales/de-de/de-de.messages.json +33 -4
  89. package/locales/es-es/es-es.messages.json +33 -4
  90. package/locales/fr-fr/fr-fr.messages.json +33 -4
  91. package/locales/id-id/id-id.messages.json +33 -4
  92. package/locales/it-it/it-it.messages.json +33 -4
  93. package/locales/ja-jp/ja-jp.messages.json +33 -4
  94. package/locales/ko-kr/ko-kr.messages.json +33 -4
  95. package/locales/pt-br/pt-br.messages.json +33 -4
  96. package/locales/ru-ru/ru-ru.messages.json +33 -4
  97. package/locales/tr-tr/tr-tr.messages.json +33 -4
  98. package/locales/zh-cn/zh-cn.messages.json +33 -4
  99. package/locales/zh-tw/zh-tw.messages.json +33 -4
  100. package/package.json +2 -1
  101. package/styles.css +156 -0
  102. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
  103. package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
  104. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
  105. package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
  106. package/types/nanahoshi-mona-ui-button.d.ts +26 -3
  107. package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
  108. package/types/nanahoshi-mona-ui-card.d.ts +22 -6
  109. package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
  110. package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
  111. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
  112. package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
  113. package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
  114. package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
  115. package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
  116. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
  117. package/types/nanahoshi-mona-ui-common.d.ts +28 -2
  118. package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
  119. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
  120. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
  121. package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
  122. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
  123. package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
  124. package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
  125. package/types/nanahoshi-mona-ui-i18n.d.ts +38 -3
  126. package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
  127. package/types/nanahoshi-mona-ui-label.d.ts +17 -2
  128. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +29 -0
  129. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +29 -0
  130. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +29 -0
  131. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +29 -0
  132. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +29 -0
  133. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +29 -0
  134. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +29 -0
  135. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +29 -0
  136. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +29 -0
  137. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +29 -0
  138. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +29 -0
  139. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +29 -0
  140. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +29 -0
  141. package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
  142. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
  143. package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
  144. package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
  145. package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
  146. package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
  147. package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
  148. package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
  149. package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
  150. package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
  151. package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
  152. package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
  153. package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
  154. package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
  155. package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
  156. package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
  157. package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
  158. package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
  159. package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
  160. package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
  161. package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
  162. package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
  163. package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
@@ -1,7 +1,7 @@
1
1
  import { NgTemplateOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, TemplateRef, Directive, computed, signal, viewChild, contentChild, input, output, model, effect, Component } from '@angular/core';
4
- import { themeControlSurfaceClasses, AttributeBinderDirective } from '@nanahoshi/mona-ui/internal';
3
+ import { inject, TemplateRef, Directive, signal, ElementRef, computed, viewChild, contentChild, input, output, booleanAttribute, numberAttribute, model, afterNextRender, effect, Component } from '@angular/core';
4
+ import { themeControlSurfaceClasses, createElementControlId, injectLabelAssociation, injectEffectiveDisabled, AttributeBinderDirective } from '@nanahoshi/mona-ui/internal';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
7
7
  import { cva } from 'class-variance-authority';
@@ -31,20 +31,20 @@ const OTP_INPUT_DEFAULT_MESSAGES = {
31
31
 
32
32
  const otpInputHostThemeVariants = cva(`
33
33
  relative inline-flex items-center gap-2
34
- outline-none
34
+ outline-none focus-visible:outline-hidden
35
35
  transition-[color,box-shadow,border] duration-(--mona-motion-standard) ease-in-out
36
36
  data-[disabled='true']:pointer-events-none
37
37
  data-[disabled='true']:cursor-not-allowed
38
38
  data-[readonly='true']:cursor-default
39
39
  `);
40
- const otpInputFieldThemeVariants = cva(`pointer-events-none absolute inset-0 size-full opacity-0 outline-none select-none -z-10`);
40
+ const otpInputFieldThemeVariants = cva(`absolute inset-0 z-10 size-full cursor-text opacity-0 outline-none focus-visible:outline-hidden read-only:cursor-default`);
41
41
  const otpInputSlotThemeVariants = cva(`
42
42
  relative inline-flex items-center justify-center
43
43
  text-center font-mono tabular-nums select-none
44
44
  overflow-hidden
45
45
  ${themeControlSurfaceClasses} text-foreground
46
46
  border border-input-border shadow-(--shadow-control)
47
- outline-none
47
+ outline-none focus-visible:outline-hidden
48
48
  transition-[color,box-shadow,border,background-color] duration-(--mona-motion-standard) ease-in-out
49
49
 
50
50
  data-[disabled='true']:pointer-events-none
@@ -107,8 +107,15 @@ const COMPONENT_MANAGED_ATTRIBUTES = new Set([
107
107
  "aria-label",
108
108
  "aria-labelledby",
109
109
  "autocomplete",
110
- "inputmode"
110
+ "id",
111
+ "inputmode",
112
+ "name"
111
113
  ]);
114
+ /** The zero of each decimal digit block a phone or IME commonly types: Arabic-Indic, Devanagari, Thai and so on. */
115
+ const DECIMAL_DIGIT_ZEROES = [
116
+ 0x0660, 0x06f0, 0x07c0, 0x0966, 0x09e6, 0x0a66, 0x0ae6, 0x0b66, 0x0be6, 0x0c66, 0x0ce6, 0x0d66, 0x0e50, 0x0ed0, 0x0f20,
117
+ 0x1040, 0x17e0, 0x1810
118
+ ];
112
119
  function findAttribute(attrs, name) {
113
120
  const target = name.toLowerCase();
114
121
  for (const [key, value] of Object.entries(attrs)) {
@@ -151,14 +158,32 @@ function isValidCharacter(char, type, characterPattern) {
151
158
  }
152
159
  return /^[a-zA-Z0-9]$/.test(char);
153
160
  }
161
+ /**
162
+ * Returns the character as the control would keep it, or null when it isn't allowed. A character the rules reject is
163
+ * converted first, so fullwidth and Eastern Arabic digits count as the digits they are.
164
+ */
165
+ function acceptCharacter(char, type, characterPattern) {
166
+ if (isValidCharacter(char, type, characterPattern)) {
167
+ return char;
168
+ }
169
+ const converted = convertCharacter(char);
170
+ return isValidCharacter(converted, type, characterPattern) ? converted : null;
171
+ }
172
+ function convertCharacter(char) {
173
+ const compatible = char.normalize("NFKC");
174
+ const codePoint = compatible.codePointAt(0) ?? 0;
175
+ const zero = DECIMAL_DIGIT_ZEROES.find(digitZero => codePoint >= digitZero && codePoint <= digitZero + 9);
176
+ return zero === undefined ? compatible : String(codePoint - zero);
177
+ }
154
178
  function filterCharacters(raw, type, characterPattern, maxLength) {
155
179
  if (!raw) {
156
180
  return "";
157
181
  }
158
182
  let result = "";
159
183
  for (const char of raw) {
160
- if (isValidCharacter(char, type, characterPattern)) {
161
- result += char;
184
+ const accepted = acceptCharacter(char, type, characterPattern);
185
+ if (accepted !== null) {
186
+ result += accepted;
162
187
  if (result.length >= maxLength) {
163
188
  break;
164
189
  }
@@ -275,9 +300,23 @@ function computeSlotClasses(options) {
275
300
  }
276
301
 
277
302
  class OtpInputComponent {
303
+ #generatedId;
304
+ #hasNativeLabel;
305
+ #hostElementRef;
278
306
  #i18n;
307
+ #label;
308
+ #touchPress;
279
309
  constructor() {
310
+ this.#generatedId = createElementControlId();
311
+ this.#hasNativeLabel = signal(false, /* @ts-ignore */
312
+ ...(ngDevMode ? [{ debugName: "#hasNativeLabel" }] : /* istanbul ignore next */ []));
313
+ this.#hostElementRef = inject(ElementRef);
280
314
  this.#i18n = inject(MonaI18nService);
315
+ this.#label = injectLabelAssociation({
316
+ ariaLabel: () => this.ariaLabel(),
317
+ ariaLabelledBy: () => this.ariaLabelledBy()
318
+ });
319
+ this.#touchPress = false;
281
320
  this.activeSlotIndex = computed(() => {
282
321
  if (!this.hasFocus()) {
283
322
  return -1;
@@ -299,6 +338,11 @@ class OtpInputComponent {
299
338
  return twMerge(baseClasses, this.userClass());
300
339
  }, /* @ts-ignore */
301
340
  ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
341
+ this.computedAriaDescribedby = computed(() => {
342
+ const raw = findUsableAttribute(this.inputAttributes(), "aria-describedby");
343
+ return toNonEmptyString(raw) ?? toNonEmptyString(this.ariaDescribedBy());
344
+ }, /* @ts-ignore */
345
+ ...(ngDevMode ? [{ debugName: "computedAriaDescribedby" }] : /* istanbul ignore next */ []));
302
346
  this.computedAriaLabel = computed(() => {
303
347
  const labelledby = this.computedAriaLabelledby();
304
348
  if (labelledby != null) {
@@ -310,14 +354,18 @@ class OtpInputComponent {
310
354
  if (customAttrLabel != null) {
311
355
  return customAttrLabel;
312
356
  }
313
- const fallback = toNonEmptyString(this.ariaLabel());
314
- return fallback ?? this.messages().verificationCode;
357
+ const explicit = toNonEmptyString(this.ariaLabel());
358
+ if (explicit != null) {
359
+ return explicit;
360
+ }
361
+ // A real <label> names the input, so the generic name would only hide it.
362
+ return this.#hasNativeLabel() ? null : this.messages().verificationCode;
315
363
  }, /* @ts-ignore */
316
364
  ...(ngDevMode ? [{ debugName: "computedAriaLabel" }] : /* istanbul ignore next */ []));
317
365
  this.computedAriaLabelledby = computed(() => {
318
366
  const attrs = this.inputAttributes();
319
367
  const raw = findUsableAttribute(attrs, "aria-labelledby");
320
- return toNonEmptyString(raw);
368
+ return toNonEmptyString(raw) ?? this.#label.labelledBy();
321
369
  }, /* @ts-ignore */
322
370
  ...(ngDevMode ? [{ debugName: "computedAriaLabelledby" }] : /* istanbul ignore next */ []));
323
371
  this.derivedAutocomplete = computed(() => {
@@ -335,6 +383,16 @@ class OtpInputComponent {
335
383
  return this.type() === "number" ? "numeric" : "text";
336
384
  }, /* @ts-ignore */
337
385
  ...(ngDevMode ? [{ debugName: "derivedInputMode" }] : /* istanbul ignore next */ []));
386
+ this.derivedName = computed(() => {
387
+ const name = this.name();
388
+ if (name) {
389
+ return name;
390
+ }
391
+ const attribute = findUsableAttribute(this.inputAttributes(), "name");
392
+ return attribute != null ? String(attribute) : null;
393
+ }, /* @ts-ignore */
394
+ ...(ngDevMode ? [{ debugName: "derivedName" }] : /* istanbul ignore next */ []));
395
+ this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
338
396
  this.hasFocus = signal(false, /* @ts-ignore */
339
397
  ...(ngDevMode ? [{ debugName: "hasFocus" }] : /* istanbul ignore next */ []));
340
398
  this.inputClass = computed(() => otpInputFieldThemeVariants(), /* @ts-ignore */
@@ -364,6 +422,16 @@ class OtpInputComponent {
364
422
  ...(ngDevMode ? [{ debugName: "nativeInputType" }] : /* istanbul ignore next */ []));
365
423
  this.normalizedLength = computed(() => normalizeLength(this.length()), /* @ts-ignore */
366
424
  ...(ngDevMode ? [{ debugName: "normalizedLength" }] : /* istanbul ignore next */ []));
425
+ /** The one thing that writes the id. `inputId` wins, and an id in `inputAttributes` stands in for a generated one. */
426
+ this.resolvedId = computed(() => {
427
+ const id = this.inputId();
428
+ if (id !== this.#generatedId) {
429
+ return id;
430
+ }
431
+ const attribute = findUsableAttribute(this.inputAttributes(), "id");
432
+ return attribute != null ? String(attribute) : id;
433
+ }, /* @ts-ignore */
434
+ ...(ngDevMode ? [{ debugName: "resolvedId" }] : /* istanbul ignore next */ []));
367
435
  this.sanitizedAttributes = computed(() => sanitizeInputAttributes(this.inputAttributes()), /* @ts-ignore */
368
436
  ...(ngDevMode ? [{ debugName: "sanitizedAttributes" }] : /* istanbul ignore next */ []));
369
437
  this.selectionEnd = signal(0, /* @ts-ignore */
@@ -435,11 +503,21 @@ class OtpInputComponent {
435
503
  }, /* @ts-ignore */
436
504
  ...(ngDevMode ? [{ debugName: "visualGroups" }] : /* istanbul ignore next */ []));
437
505
  /**
438
- * @description Accessible name for the inner `<input>` element.
506
+ * @description Id of an element that describes the inner `<input>`, such as an error message.
439
507
  * @default null
440
508
  */
441
- this.ariaLabel = input(null, /* @ts-ignore */
442
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
509
+ this.ariaDescribedBy = input(null, { ...(ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {}), alias: "aria-describedby" });
510
+ /**
511
+ * @description Accessible name for the inner `<input>` element. A `<label>` or `mona-label` names it too, and the
512
+ * generic "Verification code" name only applies when there is neither.
513
+ * @default null
514
+ */
515
+ this.ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
516
+ /**
517
+ * @description Id of the element that labels the inner `<input>`.
518
+ * @default null
519
+ */
520
+ this.ariaLabelledBy = input(null, { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
443
521
  /**
444
522
  * @description Regular expression used to determine whether each individual OTP character is allowed.
445
523
  * @default null
@@ -447,7 +525,9 @@ class OtpInputComponent {
447
525
  this.characterPattern = input(null, /* @ts-ignore */
448
526
  ...(ngDevMode ? [{ debugName: "characterPattern" }] : /* istanbul ignore next */ []));
449
527
  /**
450
- * @description Emitted when a user interaction completes the verification code.
528
+ * @description Emitted when a user interaction completes the verification code. Pasting a different full code over
529
+ * a complete one emits again, so auto-submit sees the new code. Correcting a complete code one character at a time
530
+ * doesn't.
451
531
  */
452
532
  this.complete = output();
453
533
  /**
@@ -455,8 +535,7 @@ class OtpInputComponent {
455
535
  * When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
456
536
  * @default false
457
537
  */
458
- this.disabled = input(false, /* @ts-ignore */
459
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
538
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
460
539
  /**
461
540
  * @description Configures slot grouping lengths. Accepts a uniform number or an array of group sizes.
462
541
  * @default null
@@ -477,19 +556,32 @@ class OtpInputComponent {
477
556
  * @description Emitted when the inner input gains focus.
478
557
  */
479
558
  this.inputFocus = output();
559
+ /**
560
+ * @description Id of the inner `<input>` element. Point a `<label for>` or `<mona-label for>` at it to label the
561
+ * control. A unique id is generated when it isn't set.
562
+ * @default generated
563
+ */
564
+ this.inputId = input(this.#generatedId, /* @ts-ignore */
565
+ ...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
480
566
  /**
481
567
  * @description Marks the OTP input as invalid. When bound to a signal form field via `[formField]`,
482
568
  * this is written by the `FormField` directive.
483
569
  * @default false
484
570
  */
485
- this.invalid = input(false, /* @ts-ignore */
486
- ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
571
+ this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
487
572
  /**
488
573
  * @description Sets the total number of characters accepted by the OTP input and the number of visual slots.
489
574
  * @default 4
490
575
  */
491
576
  this.length = input(4, /* @ts-ignore */
492
577
  ...(ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []));
578
+ /**
579
+ * @description Name of the native input, used in native form submission and by browsers for autofill. When bound to
580
+ * a signal form field via `[formField]`, this is written by the `FormField` directive.
581
+ * @default ""
582
+ */
583
+ this.name = input("", /* @ts-ignore */
584
+ ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
493
585
  /**
494
586
  * @description Hint character displayed in empty visual slots.
495
587
  * @default ""
@@ -501,15 +593,13 @@ class OtpInputComponent {
501
593
  * When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
502
594
  * @default false
503
595
  */
504
- this.readonly = input(false, /* @ts-ignore */
505
- ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
596
+ this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
506
597
  /**
507
598
  * @description Marks the OTP input as required. Triggers invalid state when touched and incomplete.
508
599
  * When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
509
600
  * @default false
510
601
  */
511
- this.required = input(false, /* @ts-ignore */
512
- ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
602
+ this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
513
603
  /**
514
604
  * @description Border-radius preset applied to the OTP slots.
515
605
  * @default "medium"
@@ -544,11 +634,15 @@ class OtpInputComponent {
544
634
  * @description Determines whether visual slots within a group have spacing between them or are joined together.
545
635
  * @default true
546
636
  */
547
- this.spacing = input(true, /* @ts-ignore */
548
- ...(ngDevMode ? [{ debugName: "spacing" }] : /* istanbul ignore next */ []));
637
+ this.spacing = input(true, { ...(ngDevMode ? { debugName: "spacing" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
549
638
  /**
550
- * @description Emitted when the OTP input is interacted with — on blur or user value change.
551
- * The `FormField` directive listens to this to mark the field as touched.
639
+ * @description Tab index of the inner `<input>`.
640
+ * @default 0
641
+ */
642
+ this.tabindex = input(0, { ...(ngDevMode ? { debugName: "tabindex" } : /* istanbul ignore next */ {}), transform: (value) => numberAttribute(value, 0) });
643
+ /**
644
+ * @description Emitted when the inner input loses focus. The `FormField` directive listens to this to mark the field
645
+ * as touched.
552
646
  */
553
647
  this.touch = output();
554
648
  /**
@@ -556,8 +650,7 @@ class OtpInputComponent {
556
650
  * this is written by the `FormField` directive.
557
651
  * @default false
558
652
  */
559
- this.touched = input(false, /* @ts-ignore */
560
- ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
653
+ this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
561
654
  /**
562
655
  * @description Sets the type of the OTP input ("text", "number", or "password").
563
656
  * @default "text"
@@ -575,6 +668,9 @@ class OtpInputComponent {
575
668
  */
576
669
  this.value = model("", /* @ts-ignore */
577
670
  ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
671
+ afterNextRender(() => {
672
+ this.#hasNativeLabel.set((this.inputRef().nativeElement.labels?.length ?? 0) > 0);
673
+ });
578
674
  effect(() => {
579
675
  const val = this.value();
580
676
  const inputType = this.type();
@@ -590,7 +686,7 @@ class OtpInputComponent {
590
686
  this.inputRef().nativeElement.blur();
591
687
  }
592
688
  focus(target) {
593
- if (this.disabled()) {
689
+ if (this.effectiveDisabled()) {
594
690
  return;
595
691
  }
596
692
  const el = this.inputRef().nativeElement;
@@ -622,8 +718,14 @@ class OtpInputComponent {
622
718
  }
623
719
  this.syncSelection();
624
720
  }
721
+ /**
722
+ * @internal
723
+ */
724
+ setLabelledBy(id) {
725
+ this.#label.setLabelledBy(id);
726
+ }
625
727
  onBeforeInput(event) {
626
- if (this.disabled() || this.readonly()) {
728
+ if (this.effectiveDisabled() || this.readonly()) {
627
729
  event.preventDefault();
628
730
  return;
629
731
  }
@@ -641,7 +743,8 @@ class OtpInputComponent {
641
743
  return;
642
744
  }
643
745
  if (event.data.length === 1) {
644
- if (!isValidCharacter(event.data, this.type(), this.characterPattern())) {
746
+ const accepted = acceptCharacter(event.data, this.type(), this.characterPattern());
747
+ if (accepted === null) {
645
748
  event.preventDefault();
646
749
  return;
647
750
  }
@@ -649,7 +752,13 @@ class OtpInputComponent {
649
752
  event.preventDefault();
650
753
  return;
651
754
  }
652
- if (start === end && start < val.length) {
755
+ const overwrites = start === end && start < val.length;
756
+ if (accepted !== event.data) {
757
+ event.preventDefault();
758
+ this.applyUserInsertion(accepted, start, overwrites ? start + 1 : end);
759
+ return;
760
+ }
761
+ if (overwrites) {
653
762
  inputEl.setSelectionRange(start, start + 1);
654
763
  }
655
764
  }
@@ -683,7 +792,7 @@ class OtpInputComponent {
683
792
  this.inputFocus.emit(event);
684
793
  }
685
794
  onInput(_event) {
686
- if (this.disabled() || this.readonly()) {
795
+ if (this.effectiveDisabled() || this.readonly()) {
687
796
  const inputEl = this.inputRef().nativeElement;
688
797
  inputEl.value = this.value();
689
798
  return;
@@ -698,14 +807,30 @@ class OtpInputComponent {
698
807
  inputEl.value = nextVal;
699
808
  const wasIncomplete = prevVal.length < this.normalizedLength();
700
809
  this.value.set(nextVal);
701
- this.touch.emit();
702
810
  if (wasIncomplete && nextVal.length === this.normalizedLength()) {
703
811
  this.complete.emit(nextVal);
704
812
  }
705
813
  this.syncSelection();
706
814
  }
815
+ onInputClick(event) {
816
+ // A touch leaves the press to the browser, for its paste menu, and places the caret once it's a tap.
817
+ if (this.#touchPress && !this.effectiveDisabled()) {
818
+ this.focus(this.#slotIndexAt(event.clientX));
819
+ }
820
+ }
821
+ onInputMouseDown(event) {
822
+ // The secondary button is left alone as well, so it opens the browser's menu with Paste.
823
+ if (this.#touchPress || this.effectiveDisabled() || event.button !== 0 || event.ctrlKey) {
824
+ return;
825
+ }
826
+ event.preventDefault();
827
+ this.focus(this.#slotIndexAt(event.clientX));
828
+ }
829
+ onInputPointerDown(event) {
830
+ this.#touchPress = event.pointerType === "touch" || event.pointerType === "pen";
831
+ }
707
832
  onKeyDown(event) {
708
- if (this.disabled() || this.readonly() || this.isComposing() || event.isComposing) {
833
+ if (this.effectiveDisabled() || this.readonly() || this.isComposing() || event.isComposing) {
709
834
  return;
710
835
  }
711
836
  if (event.ctrlKey || event.metaKey || event.altKey) {
@@ -719,7 +844,7 @@ class OtpInputComponent {
719
844
  const end = inputEl.selectionEnd ?? 0;
720
845
  const val = this.value();
721
846
  const maxLen = this.normalizedLength();
722
- if (!isValidCharacter(event.key, this.type(), this.characterPattern())) {
847
+ if (acceptCharacter(event.key, this.type(), this.characterPattern()) === null) {
723
848
  event.preventDefault();
724
849
  return;
725
850
  }
@@ -735,7 +860,7 @@ class OtpInputComponent {
735
860
  this.syncSelection();
736
861
  }
737
862
  onPaste(event) {
738
- if (this.disabled() || this.readonly()) {
863
+ if (this.effectiveDisabled() || this.readonly()) {
739
864
  event.preventDefault();
740
865
  return;
741
866
  }
@@ -752,15 +877,8 @@ class OtpInputComponent {
752
877
  onSelect() {
753
878
  this.syncSelection();
754
879
  }
755
- onSlotPointerDown(event, index) {
756
- if (this.disabled()) {
757
- return;
758
- }
759
- event.preventDefault();
760
- this.focus(index);
761
- }
762
880
  applyUserInsertion(text, selectionStart, selectionEnd) {
763
- if (this.disabled() || this.readonly()) {
881
+ if (this.effectiveDisabled() || this.readonly()) {
764
882
  return;
765
883
  }
766
884
  const inputEl = this.inputRef().nativeElement;
@@ -770,8 +888,10 @@ class OtpInputComponent {
770
888
  if (filtered.length === 0 && selectionStart === selectionEnd) {
771
889
  return;
772
890
  }
773
- const start = Math.max(0, Math.min(selectionStart, currentVal.length));
774
- const end = Math.max(start, Math.min(selectionEnd, currentVal.length));
891
+ // A full code replaces what's there, wherever the caret is, because merging would make up a code nobody entered.
892
+ const replacesAll = filtered.length >= maxLen;
893
+ const start = replacesAll ? 0 : Math.max(0, Math.min(selectionStart, currentVal.length));
894
+ const end = replacesAll ? currentVal.length : Math.max(start, Math.min(selectionEnd, currentVal.length));
775
895
  const before = currentVal.substring(0, start);
776
896
  const after = currentVal.substring(end);
777
897
  let combined = before + filtered + after;
@@ -779,41 +899,57 @@ class OtpInputComponent {
779
899
  combined = combined.substring(0, maxLen);
780
900
  }
781
901
  const newCaretPos = Math.min(start + filtered.length, maxLen);
782
- const wasIncomplete = currentVal.length < maxLen;
783
902
  inputEl.value = combined;
784
903
  this.value.set(combined);
785
904
  inputEl.setSelectionRange(newCaretPos, newCaretPos);
786
905
  this.selectionStart.set(newCaretPos);
787
906
  this.selectionEnd.set(newCaretPos);
788
- this.touch.emit();
789
- if (wasIncomplete && combined.length === maxLen) {
907
+ if (combined !== currentVal && combined.length === maxLen) {
790
908
  this.complete.emit(combined);
791
909
  }
792
910
  }
911
+ #slotIndexAt(clientX) {
912
+ const slots = this.#hostElementRef.nativeElement.querySelectorAll("[data-slot-index]");
913
+ let closest = 0;
914
+ let closestDistance = Number.POSITIVE_INFINITY;
915
+ slots.forEach((slot, index) => {
916
+ const { left, right } = slot.getBoundingClientRect();
917
+ const distance = clientX < left ? left - clientX : Math.max(0, clientX - right);
918
+ if (distance < closestDistance) {
919
+ closest = index;
920
+ closestDistance = distance;
921
+ }
922
+ });
923
+ return closest;
924
+ }
793
925
  syncSelection() {
794
926
  const el = this.inputRef().nativeElement;
795
927
  this.selectionStart.set(el.selectionStart ?? 0);
796
928
  this.selectionEnd.set(el.selectionEnd ?? 0);
797
929
  }
798
930
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: OtpInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
799
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: OtpInputComponent, isStandalone: true, selector: "mona-otp-input", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, characterPattern: { classPropertyName: "characterPattern", publicName: "characterPattern", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, groupLength: { classPropertyName: "groupLength", publicName: "groupLength", isSignal: true, isRequired: false, transformFunction: null }, inputAttributes: { classPropertyName: "inputAttributes", publicName: "inputAttributes", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, length: { classPropertyName: "length", publicName: "length", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, separator: { classPropertyName: "separator", publicName: "separator", isSignal: true, isRequired: false, transformFunction: null }, separatorClass: { classPropertyName: "separatorClass", publicName: "separatorClass", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, slotClass: { classPropertyName: "slotClass", publicName: "slotClass", isSignal: true, isRequired: false, transformFunction: null }, spacing: { classPropertyName: "spacing", publicName: "spacing", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { complete: "complete", inputBlur: "inputBlur", inputFocus: "inputFocus", touch: "touch", value: "valueChange" }, host: { attributes: { "dir": "ltr" }, properties: { "attr.dir": "'ltr'", "attr.data-disabled": "disabled() || null", "attr.data-readonly": "readonly() || null", "attr.data-required": "required() || null", "attr.data-invalid": "invalidState() || null", "attr.data-complete": "isComplete() || null", "attr.data-focused": "hasFocus() || null", "class": "classes()" } }, queries: [{ propertyName: "separatorTemplate", first: true, predicate: OtpInputSeparatorTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: "<input\n #input\n [class]=\"inputClass()\"\n tabindex=\"0\"\n [value]=\"value()\"\n [disabled]=\"disabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [type]=\"nativeInputType()\"\n [attr.inputmode]=\"derivedInputMode()\"\n [attr.autocomplete]=\"derivedAutocomplete()\"\n [attr.autocapitalize]=\"'off'\"\n [attr.spellcheck]=\"'false'\"\n [attr.aria-label]=\"computedAriaLabel()\"\n [attr.aria-labelledby]=\"computedAriaLabelledby()\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.maxlength]=\"normalizedLength()\"\n [monaAttributeBinder]=\"sanitizedAttributes()\"\n (beforeinput)=\"onBeforeInput($event)\"\n (keydown)=\"onKeyDown($event)\"\n (input)=\"onInput($event)\"\n (paste)=\"onPaste($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (select)=\"onSelect()\"\n (keyup)=\"onKeyUp()\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd($event)\" />\n\n@for (group of visualGroups(); track group.index; let lastGroup = $last) {\n <div\n class=\"inline-flex items-center\"\n [class.gap-1.5]=\"spacing()\"\n [class]=\"!spacing() ? '[&>*:not(:first-child)]:-ms-px' : ''\"\n [attr.data-group-index]=\"group.index\">\n @for (slot of group.slots; track slot.index) {\n <span\n class=\"otp-slot\"\n [class]=\"slot.classes\"\n [attr.data-slot-index]=\"slot.index\"\n [attr.data-active]=\"slot.active || null\"\n [attr.data-selected]=\"slot.selected || null\"\n [attr.data-filled]=\"slot.filled || null\"\n [attr.data-placeholder]=\"slot.placeholder || null\"\n [attr.data-disabled]=\"disabled() || null\"\n [attr.data-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n (pointerdown)=\"onSlotPointerDown($event, slot.index)\"\n aria-hidden=\"true\">\n {{ slot.displayCharacter }}\n @if (slot.active && !slot.filled && hasFocus() && !disabled() && !readonly()) {\n <span\n class=\"pointer-events-none absolute inset-y-2 w-0.5 animate-pulse motion-reduce:animate-none bg-foreground\"\n aria-hidden=\"true\"></span>\n }\n </span>\n }\n </div>\n\n @if (!lastGroup && (separator() || separatorTemplate())) {\n <span\n class=\"inline-flex items-center justify-center text-muted-foreground select-none px-1\"\n [class]=\"separatorClass()\"\n aria-hidden=\"true\">\n @if (separatorTemplate(); as customTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplate;\n context: { $implicit: group.index, groupIndex: group.index }\n \"></ng-container>\n } @else {\n {{ separator() }}\n }\n </span>\n }\n}\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: AttributeBinderDirective, selector: "[monaAttributeBinder]", inputs: ["monaAttributeBinder"] }] }); }
931
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: OtpInputComponent, isStandalone: true, selector: "mona-otp-input", inputs: { ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, characterPattern: { classPropertyName: "characterPattern", publicName: "characterPattern", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, groupLength: { classPropertyName: "groupLength", publicName: "groupLength", isSignal: true, isRequired: false, transformFunction: null }, inputAttributes: { classPropertyName: "inputAttributes", publicName: "inputAttributes", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, length: { classPropertyName: "length", publicName: "length", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, separator: { classPropertyName: "separator", publicName: "separator", isSignal: true, isRequired: false, transformFunction: null }, separatorClass: { classPropertyName: "separatorClass", publicName: "separatorClass", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, slotClass: { classPropertyName: "slotClass", publicName: "slotClass", isSignal: true, isRequired: false, transformFunction: null }, spacing: { classPropertyName: "spacing", publicName: "spacing", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { complete: "complete", inputBlur: "inputBlur", inputFocus: "inputFocus", touch: "touch", value: "valueChange" }, host: { properties: { "attr.aria-describedby": "null", "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.tabindex": "null", "attr.dir": "'ltr'", "attr.data-disabled": "effectiveDisabled() || null", "attr.data-readonly": "readonly() || null", "attr.data-required": "required() || null", "attr.data-invalid": "invalidState() || null", "attr.data-complete": "isComplete() || null", "attr.data-focused": "hasFocus() || null", "class": "classes()" } }, queries: [{ propertyName: "separatorTemplate", first: true, predicate: OtpInputSeparatorTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: "<input\n #input\n [class]=\"inputClass()\"\n [id]=\"resolvedId()\"\n [attr.tabindex]=\"tabindex()\"\n [value]=\"value()\"\n [disabled]=\"effectiveDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [type]=\"nativeInputType()\"\n [attr.inputmode]=\"derivedInputMode()\"\n [attr.autocomplete]=\"derivedAutocomplete()\"\n [attr.autocapitalize]=\"'off'\"\n [attr.spellcheck]=\"'false'\"\n [attr.aria-label]=\"computedAriaLabel()\"\n [attr.aria-labelledby]=\"computedAriaLabelledby()\"\n [attr.aria-describedby]=\"computedAriaDescribedby()\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.maxlength]=\"normalizedLength()\"\n [attr.name]=\"derivedName()\"\n [monaAttributeBinder]=\"sanitizedAttributes()\"\n (beforeinput)=\"onBeforeInput($event)\"\n (keydown)=\"onKeyDown($event)\"\n (input)=\"onInput($event)\"\n (paste)=\"onPaste($event)\"\n (click)=\"onInputClick($event)\"\n (mousedown)=\"onInputMouseDown($event)\"\n (pointerdown)=\"onInputPointerDown($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (select)=\"onSelect()\"\n (selectionchange)=\"onSelect()\"\n (keyup)=\"onKeyUp()\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd($event)\" />\n\n@for (group of visualGroups(); track group.index; let lastGroup = $last) {\n <div\n class=\"inline-flex items-center\"\n [class.gap-1.5]=\"spacing()\"\n [class]=\"!spacing() ? '[&>*:not(:first-child)]:-ms-px' : ''\"\n [attr.data-group-index]=\"group.index\">\n @for (slot of group.slots; track slot.index) {\n <span\n class=\"otp-slot\"\n [class]=\"slot.classes\"\n [attr.data-slot-index]=\"slot.index\"\n [attr.data-active]=\"slot.active || null\"\n [attr.data-selected]=\"slot.selected || null\"\n [attr.data-filled]=\"slot.filled || null\"\n [attr.data-placeholder]=\"slot.placeholder || null\"\n [attr.data-disabled]=\"effectiveDisabled() || null\"\n [attr.data-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n aria-hidden=\"true\">\n {{ slot.displayCharacter }}\n @if (slot.active && !slot.filled && hasFocus() && !effectiveDisabled() && !readonly()) {\n <span\n class=\"pointer-events-none absolute inset-y-2 w-0.5 animate-pulse motion-reduce:animate-none bg-foreground\"\n aria-hidden=\"true\"></span>\n }\n </span>\n }\n </div>\n\n @if (!lastGroup && (separator() || separatorTemplate())) {\n <span\n class=\"inline-flex items-center justify-center text-muted-foreground select-none px-1\"\n [class]=\"separatorClass()\"\n aria-hidden=\"true\">\n @if (separatorTemplate(); as customTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplate;\n context: { $implicit: group.index, groupIndex: group.index }\n \"></ng-container>\n } @else {\n {{ separator() }}\n }\n </span>\n }\n}\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: AttributeBinderDirective, selector: "[monaAttributeBinder]", inputs: ["monaAttributeBinder"] }] }); }
800
932
  }
801
933
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: OtpInputComponent, decorators: [{
802
934
  type: Component,
803
935
  args: [{ selector: "mona-otp-input", imports: [NgTemplateOutlet, AttributeBinderDirective], host: {
804
- dir: "ltr",
936
+ // The ARIA inputs are applied to the inner input, so the host must not keep the static attributes.
937
+ "[attr.aria-describedby]": "null",
938
+ "[attr.aria-label]": "null",
939
+ "[attr.aria-labelledby]": "null",
940
+ "[attr.tabindex]": "null",
805
941
  "[attr.dir]": "'ltr'",
806
- "[attr.data-disabled]": "disabled() || null",
942
+ "[attr.data-disabled]": "effectiveDisabled() || null",
807
943
  "[attr.data-readonly]": "readonly() || null",
808
944
  "[attr.data-required]": "required() || null",
809
945
  "[attr.data-invalid]": "invalidState() || null",
810
946
  "[attr.data-complete]": "isComplete() || null",
811
947
  "[attr.data-focused]": "hasFocus() || null",
812
948
  "[class]": "classes()"
813
- }, template: "<input\n #input\n [class]=\"inputClass()\"\n tabindex=\"0\"\n [value]=\"value()\"\n [disabled]=\"disabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [type]=\"nativeInputType()\"\n [attr.inputmode]=\"derivedInputMode()\"\n [attr.autocomplete]=\"derivedAutocomplete()\"\n [attr.autocapitalize]=\"'off'\"\n [attr.spellcheck]=\"'false'\"\n [attr.aria-label]=\"computedAriaLabel()\"\n [attr.aria-labelledby]=\"computedAriaLabelledby()\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.maxlength]=\"normalizedLength()\"\n [monaAttributeBinder]=\"sanitizedAttributes()\"\n (beforeinput)=\"onBeforeInput($event)\"\n (keydown)=\"onKeyDown($event)\"\n (input)=\"onInput($event)\"\n (paste)=\"onPaste($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (select)=\"onSelect()\"\n (keyup)=\"onKeyUp()\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd($event)\" />\n\n@for (group of visualGroups(); track group.index; let lastGroup = $last) {\n <div\n class=\"inline-flex items-center\"\n [class.gap-1.5]=\"spacing()\"\n [class]=\"!spacing() ? '[&>*:not(:first-child)]:-ms-px' : ''\"\n [attr.data-group-index]=\"group.index\">\n @for (slot of group.slots; track slot.index) {\n <span\n class=\"otp-slot\"\n [class]=\"slot.classes\"\n [attr.data-slot-index]=\"slot.index\"\n [attr.data-active]=\"slot.active || null\"\n [attr.data-selected]=\"slot.selected || null\"\n [attr.data-filled]=\"slot.filled || null\"\n [attr.data-placeholder]=\"slot.placeholder || null\"\n [attr.data-disabled]=\"disabled() || null\"\n [attr.data-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n (pointerdown)=\"onSlotPointerDown($event, slot.index)\"\n aria-hidden=\"true\">\n {{ slot.displayCharacter }}\n @if (slot.active && !slot.filled && hasFocus() && !disabled() && !readonly()) {\n <span\n class=\"pointer-events-none absolute inset-y-2 w-0.5 animate-pulse motion-reduce:animate-none bg-foreground\"\n aria-hidden=\"true\"></span>\n }\n </span>\n }\n </div>\n\n @if (!lastGroup && (separator() || separatorTemplate())) {\n <span\n class=\"inline-flex items-center justify-center text-muted-foreground select-none px-1\"\n [class]=\"separatorClass()\"\n aria-hidden=\"true\">\n @if (separatorTemplate(); as customTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplate;\n context: { $implicit: group.index, groupIndex: group.index }\n \"></ng-container>\n } @else {\n {{ separator() }}\n }\n </span>\n }\n}\n" }]
949
+ }, template: "<input\n #input\n [class]=\"inputClass()\"\n [id]=\"resolvedId()\"\n [attr.tabindex]=\"tabindex()\"\n [value]=\"value()\"\n [disabled]=\"effectiveDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [type]=\"nativeInputType()\"\n [attr.inputmode]=\"derivedInputMode()\"\n [attr.autocomplete]=\"derivedAutocomplete()\"\n [attr.autocapitalize]=\"'off'\"\n [attr.spellcheck]=\"'false'\"\n [attr.aria-label]=\"computedAriaLabel()\"\n [attr.aria-labelledby]=\"computedAriaLabelledby()\"\n [attr.aria-describedby]=\"computedAriaDescribedby()\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.maxlength]=\"normalizedLength()\"\n [attr.name]=\"derivedName()\"\n [monaAttributeBinder]=\"sanitizedAttributes()\"\n (beforeinput)=\"onBeforeInput($event)\"\n (keydown)=\"onKeyDown($event)\"\n (input)=\"onInput($event)\"\n (paste)=\"onPaste($event)\"\n (click)=\"onInputClick($event)\"\n (mousedown)=\"onInputMouseDown($event)\"\n (pointerdown)=\"onInputPointerDown($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (select)=\"onSelect()\"\n (selectionchange)=\"onSelect()\"\n (keyup)=\"onKeyUp()\"\n (compositionstart)=\"onCompositionStart()\"\n (compositionend)=\"onCompositionEnd($event)\" />\n\n@for (group of visualGroups(); track group.index; let lastGroup = $last) {\n <div\n class=\"inline-flex items-center\"\n [class.gap-1.5]=\"spacing()\"\n [class]=\"!spacing() ? '[&>*:not(:first-child)]:-ms-px' : ''\"\n [attr.data-group-index]=\"group.index\">\n @for (slot of group.slots; track slot.index) {\n <span\n class=\"otp-slot\"\n [class]=\"slot.classes\"\n [attr.data-slot-index]=\"slot.index\"\n [attr.data-active]=\"slot.active || null\"\n [attr.data-selected]=\"slot.selected || null\"\n [attr.data-filled]=\"slot.filled || null\"\n [attr.data-placeholder]=\"slot.placeholder || null\"\n [attr.data-disabled]=\"effectiveDisabled() || null\"\n [attr.data-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n aria-hidden=\"true\">\n {{ slot.displayCharacter }}\n @if (slot.active && !slot.filled && hasFocus() && !effectiveDisabled() && !readonly()) {\n <span\n class=\"pointer-events-none absolute inset-y-2 w-0.5 animate-pulse motion-reduce:animate-none bg-foreground\"\n aria-hidden=\"true\"></span>\n }\n </span>\n }\n </div>\n\n @if (!lastGroup && (separator() || separatorTemplate())) {\n <span\n class=\"inline-flex items-center justify-center text-muted-foreground select-none px-1\"\n [class]=\"separatorClass()\"\n aria-hidden=\"true\">\n @if (separatorTemplate(); as customTemplate) {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplate;\n context: { $implicit: group.index, groupIndex: group.index }\n \"></ng-container>\n } @else {\n {{ separator() }}\n }\n </span>\n }\n}\n" }]
814
950
  }], ctorParameters: () => [], propDecorators: { inputRef: [{ type: i0.ViewChild, args: ["input", { isSignal: true }] }], separatorTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => OtpInputSeparatorTemplateDirective), { ...{
815
951
  read: TemplateRef
816
- }, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], characterPattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "characterPattern", required: false }] }], complete: [{ type: i0.Output, args: ["complete"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], groupLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupLength", required: false }] }], inputAttributes: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputAttributes", required: false }] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], inputFocus: [{ type: i0.Output, args: ["inputFocus"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], length: [{ type: i0.Input, args: [{ isSignal: true, alias: "length", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], separator: [{ type: i0.Input, args: [{ isSignal: true, alias: "separator", required: false }] }], separatorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "separatorClass", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], slotClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "slotClass", required: false }] }], spacing: [{ type: i0.Input, args: [{ isSignal: true, alias: "spacing", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
952
+ }, isSignal: true }] }], ariaDescribedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-describedby", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], characterPattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "characterPattern", required: false }] }], complete: [{ type: i0.Output, args: ["complete"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], groupLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupLength", required: false }] }], inputAttributes: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputAttributes", required: false }] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], inputFocus: [{ type: i0.Output, args: ["inputFocus"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], length: [{ type: i0.Input, args: [{ isSignal: true, alias: "length", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], separator: [{ type: i0.Input, args: [{ isSignal: true, alias: "separator", required: false }] }], separatorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "separatorClass", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], slotClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "slotClass", required: false }] }], spacing: [{ type: i0.Input, args: [{ isSignal: true, alias: "spacing", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
817
953
 
818
954
  /*
819
955
  * Public API Surface of @nanahoshi/mona-ui/otp-input