@nanoporetech-digital/components 8.7.2 → 8.9.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 (147) hide show
  1. package/dist/cjs/{fade-NeUskjyB.js → fade-DBKqk3wh.js} +1 -1
  2. package/dist/cjs/{fullscreen-D5cgtwoy.js → fullscreen-lcdCtrG6.js} +1 -1
  3. package/dist/cjs/index-DGttnXif.js +4 -0
  4. package/dist/cjs/{lazyload-Dm1NcTJ1.js → lazyload-BjSSEx9f.js} +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/nano-avatar_5.cjs.entry.js +7 -7
  7. package/dist/cjs/nano-components.cjs.js +1 -1
  8. package/dist/cjs/nano-datalist_3.cjs.entry.js +4 -0
  9. package/dist/cjs/nano-icon-button_2.cjs.entry.js +2 -2
  10. package/dist/cjs/nano-input-otp.cjs.entry.js +710 -0
  11. package/dist/cjs/nano-intersection-observe.cjs.entry.js +1 -1
  12. package/dist/cjs/nano-masked-overflow.cjs.entry.js +3 -3
  13. package/dist/cjs/nano-menu-drawer.cjs.entry.js +2 -2
  14. package/dist/cjs/nano-more-less.cjs.entry.js +2 -2
  15. package/dist/cjs/nano-rating.cjs.entry.js +4 -4
  16. package/dist/cjs/nano-resize-observe.cjs.entry.js +2 -2
  17. package/dist/cjs/nano-slide.cjs.entry.js +1 -1
  18. package/dist/cjs/{nano-slides-ycRcUf0g.js → nano-slides-CryCLfsK.js} +7 -7
  19. package/dist/cjs/nano-slides.cjs.entry.js +1 -1
  20. package/dist/cjs/nano-sortable.cjs.entry.js +1 -1
  21. package/dist/cjs/nano-step-accordion.cjs.entry.js +1 -1
  22. package/dist/cjs/nano-step-breadcrumb.cjs.entry.js +2 -2
  23. package/dist/cjs/nano-sticker.cjs.entry.js +2 -2
  24. package/dist/cjs/nano-tab-content.cjs.entry.js +2 -2
  25. package/dist/cjs/nano-tab.cjs.entry.js +2 -2
  26. package/dist/cjs/nano-table.cjs.entry.js +2 -2
  27. package/dist/cjs/{page-dots--38yVfTZ.js → page-dots-DR1fLjRi.js} +1 -1
  28. package/dist/collection/collection-manifest.json +1 -0
  29. package/dist/collection/components/breadcrumb/breadcrumb.js +1 -1
  30. package/dist/collection/components/input-otp/input-otp-interface.js +1 -0
  31. package/dist/collection/components/input-otp/input-otp.css +184 -0
  32. package/dist/collection/components/input-otp/input-otp.js +1044 -0
  33. package/dist/collection/components/intersection-observe/intersection-observe.js +1 -1
  34. package/dist/collection/components/masked-overflow/masked-overflow.js +3 -3
  35. package/dist/collection/components/menu-drawer/menu-drawer.js +2 -2
  36. package/dist/collection/components/more-less/more-less.js +2 -2
  37. package/dist/collection/components/rating/rating.js +4 -4
  38. package/dist/collection/components/resize-observe/resize-observe.js +2 -2
  39. package/dist/collection/components/select/select.js +7 -7
  40. package/dist/collection/components/slides/slide.js +1 -1
  41. package/dist/collection/components/slides/slides.js +3 -3
  42. package/dist/collection/components/sortable/sortable.js +1 -1
  43. package/dist/collection/components/step-accordion/step-accordion.js +1 -1
  44. package/dist/collection/components/step-breadcrumb/step-breadcrumb.js +2 -2
  45. package/dist/collection/components/sticker/sticker.js +2 -2
  46. package/dist/collection/components/table/table.js +2 -2
  47. package/dist/collection/components/tabs/tab-content.js +2 -2
  48. package/dist/collection/components/tabs/tab.js +2 -2
  49. package/dist/collection/components/tag/tag.js +24 -0
  50. package/dist/collection/components/tooltip/tooltip.js +2 -2
  51. package/dist/components/masked-overflow.js +3 -3
  52. package/dist/components/nano-input-otp.d.ts +11 -0
  53. package/dist/components/nano-input-otp.js +749 -0
  54. package/dist/components/nano-intersection-observe.js +1 -1
  55. package/dist/components/nano-menu-drawer.js +2 -2
  56. package/dist/components/nano-more-less.js +2 -2
  57. package/dist/components/nano-rating.js +4 -4
  58. package/dist/components/nano-slide.js +1 -1
  59. package/dist/components/nano-sortable.js +1 -1
  60. package/dist/components/nano-step-accordion.js +1 -1
  61. package/dist/components/nano-step-breadcrumb.js +2 -2
  62. package/dist/components/nano-tab-content.js +2 -2
  63. package/dist/components/nano-tab.js +2 -2
  64. package/dist/components/nano-table.js +2 -2
  65. package/dist/components/resize-observe.js +2 -2
  66. package/dist/components/select.js +7 -7
  67. package/dist/components/slides.js +3 -3
  68. package/dist/components/sticker.js +2 -2
  69. package/dist/components/tag.js +6 -1
  70. package/dist/components/tooltip.js +2 -2
  71. package/dist/esm/{fade-BA6b-Fk9.js → fade-D980mOvm.js} +1 -1
  72. package/dist/esm/{fullscreen-De_yN4cg.js → fullscreen-CjInlYb9.js} +1 -1
  73. package/dist/esm/index-BM3Om9WE.js +4 -0
  74. package/dist/esm/{lazyload-Cl8k3tPs.js → lazyload-B9B4e3ZI.js} +1 -1
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/nano-avatar_5.entry.js +7 -7
  77. package/dist/esm/nano-components.js +1 -1
  78. package/dist/esm/nano-datalist_3.entry.js +4 -0
  79. package/dist/esm/nano-icon-button_2.entry.js +2 -2
  80. package/dist/esm/nano-input-otp.entry.js +708 -0
  81. package/dist/esm/nano-intersection-observe.entry.js +1 -1
  82. package/dist/esm/nano-masked-overflow.entry.js +3 -3
  83. package/dist/esm/nano-menu-drawer.entry.js +2 -2
  84. package/dist/esm/nano-more-less.entry.js +2 -2
  85. package/dist/esm/nano-rating.entry.js +4 -4
  86. package/dist/esm/nano-resize-observe.entry.js +2 -2
  87. package/dist/esm/nano-slide.entry.js +1 -1
  88. package/dist/esm/{nano-slides-GrbOydfa.js → nano-slides-xbY6lXX9.js} +7 -7
  89. package/dist/esm/nano-slides.entry.js +1 -1
  90. package/dist/esm/nano-sortable.entry.js +1 -1
  91. package/dist/esm/nano-step-accordion.entry.js +1 -1
  92. package/dist/esm/nano-step-breadcrumb.entry.js +2 -2
  93. package/dist/esm/nano-sticker.entry.js +2 -2
  94. package/dist/esm/nano-tab-content.entry.js +2 -2
  95. package/dist/esm/nano-tab.entry.js +2 -2
  96. package/dist/esm/nano-table.entry.js +2 -2
  97. package/dist/esm/{page-dots-CSf81OuJ.js → page-dots-CCfERISy.js} +1 -1
  98. package/dist/nano-components/{fade-BA6b-Fk9.js → fade-D980mOvm.js} +1 -1
  99. package/dist/nano-components/{fullscreen-De_yN4cg.js → fullscreen-CjInlYb9.js} +1 -1
  100. package/dist/nano-components/lazyload-B9B4e3ZI.js +4 -0
  101. package/dist/nano-components/nano-avatar_5.entry.js +1 -1
  102. package/dist/nano-components/nano-components.css +1 -1
  103. package/dist/nano-components/nano-components.esm.js +1 -1
  104. package/dist/nano-components/nano-datalist_3.entry.js +1 -1
  105. package/dist/nano-components/nano-icon-button_2.entry.js +1 -1
  106. package/dist/nano-components/nano-input-otp.entry.js +4 -0
  107. package/dist/nano-components/nano-intersection-observe.entry.js +1 -1
  108. package/dist/nano-components/nano-masked-overflow.entry.js +1 -1
  109. package/dist/nano-components/nano-menu-drawer.entry.js +1 -1
  110. package/dist/nano-components/nano-more-less.entry.js +1 -1
  111. package/dist/nano-components/nano-rating.entry.js +1 -1
  112. package/dist/nano-components/nano-resize-observe.entry.js +1 -1
  113. package/dist/nano-components/nano-slide.entry.js +1 -1
  114. package/dist/nano-components/{nano-slides-GrbOydfa.js → nano-slides-xbY6lXX9.js} +3 -3
  115. package/dist/nano-components/nano-slides.entry.js +1 -1
  116. package/dist/nano-components/nano-sortable.entry.js +1 -1
  117. package/dist/nano-components/nano-step-accordion.entry.js +1 -1
  118. package/dist/nano-components/nano-step-breadcrumb.entry.js +1 -1
  119. package/dist/nano-components/nano-sticker.entry.js +1 -1
  120. package/dist/nano-components/nano-tab-content.entry.js +1 -1
  121. package/dist/nano-components/nano-tab.entry.js +1 -1
  122. package/dist/nano-components/nano-table.entry.js +1 -1
  123. package/dist/nano-components/{page-dots-CSf81OuJ.js → page-dots-CCfERISy.js} +1 -1
  124. package/dist/style/components.css +1 -1
  125. package/dist/style/components.css.map +1 -1
  126. package/dist/style/nano.css +1 -1
  127. package/dist/style/nano.css.map +1 -1
  128. package/dist/types/components/input-otp/input-otp-interface.d.ts +24 -0
  129. package/dist/types/components/input-otp/input-otp.d.ts +281 -0
  130. package/dist/types/components/tag/tag.d.ts +4 -0
  131. package/dist/types/components.d.ts +189 -0
  132. package/docs-json.json +824 -183
  133. package/docs-vscode.json +83 -0
  134. package/hydrate/index.js +786 -45
  135. package/hydrate/index.mjs +786 -45
  136. package/package.json +2 -2
  137. package/dist/nano-components/lazyload-Cl8k3tPs.js +0 -4
  138. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/generate-vue-component.d.ts +0 -0
  139. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/index.d.ts +0 -0
  140. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/output-vue.d.ts +0 -0
  141. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/plugin.d.ts +0 -0
  142. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/types.d.ts +0 -0
  143. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/utils.d.ts +0 -0
  144. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/stencil.config.d.ts +0 -0
  145. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/stencil.config.prod.d.ts +0 -0
  146. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/testing/mocks/intersection-observer.d.ts +0 -0
  147. /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/wdio.conf.d.ts +0 -0
@@ -0,0 +1,1044 @@
1
+ /*!
2
+ * Custom elements for Nanopore-Digital Web applications
3
+ */
4
+ import { Fragment, Host, h, } from "@stencil/core";
5
+ /**
6
+ * A component for entering one-time passwords (OTP) with multiple input fields.
7
+ *
8
+ * @version 8.7.2
9
+ * @status new
10
+ *
11
+ * @slot - The default slot for the input description.
12
+ * @slot validity-icon - A slot for a custom validity icon. If not provided, a default icon will be used.
13
+ */
14
+ export class InputOTP {
15
+ inputRefs = [];
16
+ inputId = `nano-input-otp-${inputIds++}`;
17
+ /**
18
+ * Stores the initial value of the input when it receives focus.
19
+ * Used to determine if the value changed during the focus session
20
+ * to avoid emitting unnecessary change events on blur.
21
+ */
22
+ focusedValue;
23
+ /**
24
+ * Tracks whether the user is navigating through input boxes using keyboard navigation
25
+ * (arrow keys, tab) versus mouse clicks. This is used to determine the appropriate
26
+ * focus behavior when an input box is focused.
27
+ */
28
+ isKeyboardNavigation = false;
29
+ el;
30
+ inputValues = [];
31
+ hasFocus = false;
32
+ previousInputValues = [];
33
+ invalid = false;
34
+ valid = false;
35
+ /**
36
+ * If `true`, the user cannot interact with the input.
37
+ */
38
+ disabled = false;
39
+ /**
40
+ * A hint to the browser for which keyboard to display.
41
+ * Possible values: `"none"`, `"text"`, `"tel"`, `"url"`,
42
+ * `"email"`, `"numeric"`, `"decimal"`, and `"search"`.
43
+ *
44
+ * For numbers (type="number"): "numeric"
45
+ * For text (type="text"): "text"
46
+ */
47
+ inputmode;
48
+ /**
49
+ * The number of input boxes to display.
50
+ */
51
+ length = 6;
52
+ /**
53
+ * A regex pattern string for allowed characters. Defaults based on type.
54
+ *
55
+ * For numbers (`type="number"`): `"[\p{N}]"`
56
+ * For text (`type="text"`): `"[\p{L}\p{N}]"`
57
+ */
58
+ pattern;
59
+ /**
60
+ * If `true`, the user cannot modify the value.
61
+ */
62
+ readonly = false;
63
+ /**
64
+ * The type of input allowed in the input boxes.
65
+ */
66
+ type = 'number';
67
+ /**
68
+ * The value of the input group.
69
+ */
70
+ value = '';
71
+ /**
72
+ * If `true`, allows the input to be completely filled with invalid values.
73
+ * By default, if any input box contains an invalid value, the entire input group
74
+ * is marked as invalid.
75
+ * Default is `false`.
76
+ */
77
+ allowInvalid = false;
78
+ /**
79
+ * If `true`, shows a validity icon when all input boxes are filled.
80
+ * A check icon is shown if all values are valid, and an X icon is shown if any value is invalid.
81
+ * This does not affect the `invalid` or `valid` states of the input group.
82
+ * Default is `false`.
83
+ * */
84
+ showValidity = false;
85
+ /**
86
+ * The `nanoInput` event is fired each time the user modifies the input's value.
87
+ * Unlike the `nanoChange` event, the `nanoInput` event is fired for each alteration
88
+ * to the input's value. This typically happens for each keystroke as the user types.
89
+ *
90
+ * For elements that accept text input (`type=text`, `type=tel`, etc.), the interface
91
+ * is [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent); for others,
92
+ * the interface is [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). If
93
+ * the input is cleared on edit, the type is `null`.
94
+ */
95
+ nanoInput;
96
+ /**
97
+ * The `nanoChange` event is fired when the user modifies the input's value.
98
+ * Unlike the `nanoInput` event, the `nanoChange` event is only fired when changes
99
+ * are committed, not as the user types.
100
+ *
101
+ * The `nanoChange` event fires when the `<nano-input-otp>` component loses
102
+ * focus after its value has changed.
103
+ *
104
+ * This event will not emit when programmatically setting the `value` property.
105
+ */
106
+ nanoChange;
107
+ /**
108
+ * Emitted when all input boxes have been filled with valid values.
109
+ */
110
+ nanoComplete;
111
+ /**
112
+ * Emitted when the input group loses focus.
113
+ */
114
+ nanoBlur;
115
+ /**
116
+ * Emitted when the input group has focus.
117
+ */
118
+ nanoFocus;
119
+ /**
120
+ * Sets focus to an input box.
121
+ * @param index - The index of the input box to focus (0-based).
122
+ * If provided and the input box has a value, the input box at that index will be focused.
123
+ * Otherwise, the first empty input box or the last input if all are filled will be focused.
124
+ */
125
+ async setFocus(index) {
126
+ if (typeof index === 'number') {
127
+ const validIndex = Math.max(0, Math.min(index, this.length - 1));
128
+ this.inputRefs[validIndex]?.focus();
129
+ }
130
+ else {
131
+ const tabbableIndex = this.getTabbableIndex();
132
+ this.inputRefs[tabbableIndex]?.focus();
133
+ }
134
+ }
135
+ valueChanged() {
136
+ this.initializeValues();
137
+ this.updateTabIndexes();
138
+ this.computeValidity();
139
+ }
140
+ componentWillLoad() {
141
+ this.initializeValues();
142
+ this.computeValidity();
143
+ }
144
+ componentDidLoad() {
145
+ this.updateTabIndexes();
146
+ }
147
+ /**
148
+ * Get the regex pattern for allowed characters.
149
+ * If a pattern is provided, use it to create a regex pattern
150
+ * Otherwise, use the default regex pattern based on type
151
+ */
152
+ get validKeyPattern() {
153
+ return new RegExp(`^${this.getPattern()}$`, 'u');
154
+ }
155
+ get specialCharsPattern() {
156
+ return new RegExp(`^[\\p{S}\\p{P}]$`, 'u');
157
+ }
158
+ /**
159
+ * Gets the string pattern to pass to the input element
160
+ * and use in the regex for allowed characters.
161
+ * @returns {string} The regex pattern string for allowed characters.
162
+ */
163
+ getPattern() {
164
+ const { pattern, type } = this;
165
+ if (pattern) {
166
+ return pattern;
167
+ }
168
+ return type === 'number' ? '[\\p{N}]' : '[\\p{L}\\p{N}]';
169
+ }
170
+ /**
171
+ * Get the default value for inputmode.
172
+ * If inputmode is provided, use it.
173
+ * Otherwise, use the default inputmode based on type
174
+ * @returns {string} The inputmode to use for the input boxes.
175
+ */
176
+ getInputmode() {
177
+ const { inputmode } = this;
178
+ if (inputmode) {
179
+ return inputmode;
180
+ }
181
+ if (this.type == 'number') {
182
+ return 'numeric';
183
+ }
184
+ else {
185
+ return 'text';
186
+ }
187
+ }
188
+ /**
189
+ * Initializes the input values array based on the current value prop.
190
+ * This splits the value into individual characters and validates them against
191
+ * the allowed pattern. The values are then used as the values in the native
192
+ * input boxes and the value of the input group is updated.
193
+ */
194
+ initializeValues() {
195
+ // Clear all input values
196
+ this.inputValues = Array(this.length).fill('');
197
+ // If the value is null, undefined, or an empty string, return
198
+ if (this.value == null || String(this.value).length === 0) {
199
+ return;
200
+ }
201
+ // Split the value into individual characters and validate
202
+ // them against the allowed pattern if invalid characters are allowed, else just put them in
203
+ const chars = String(this.value).split('').slice(0, this.length);
204
+ chars.forEach((char, index) => {
205
+ if (this.allowInvalid && !this.specialCharsPattern.test(char)) {
206
+ this.inputValues[index] = char;
207
+ }
208
+ else if (this.validKeyPattern.test(char)) {
209
+ this.inputValues[index] = char;
210
+ }
211
+ });
212
+ // Update the value without emitting events
213
+ this.value = this.inputValues.join('');
214
+ this.previousInputValues = [...this.inputValues];
215
+ }
216
+ /**
217
+ * Returns `true` if the document or host element
218
+ * has a `dir` set to `rtl`. The host value will always
219
+ * take priority over the root document value.
220
+ * @returns {boolean} True if RTL direction is set, false otherwise.
221
+ */
222
+ isRTL = (hostEl) => {
223
+ if (hostEl) {
224
+ if (hostEl.dir !== '') {
225
+ return hostEl.dir.toLowerCase() === 'rtl';
226
+ }
227
+ }
228
+ return document?.dir.toLowerCase() === 'rtl';
229
+ };
230
+ /**
231
+ * Updates the value of the input group.
232
+ * This updates the value of the input group and emits an `nanoChange` event.
233
+ * If all of the input boxes are filled, it emits an `nanoComplete` event.
234
+ */
235
+ updateValue(event) {
236
+ const { inputValues, length } = this;
237
+ const newValue = this.getValidChars(inputValues.join('')).join('');
238
+ this.value = newValue;
239
+ this.computeValidity();
240
+ this.emitNanoInput(event);
241
+ if (newValue.length === length) {
242
+ this.nanoComplete.emit({ value: newValue, valid: this.valid });
243
+ }
244
+ }
245
+ /**
246
+ * Emits an `nanoChange` event.
247
+ * This API should be called for user committed changes.
248
+ * This API should not be used for external value changes.
249
+ */
250
+ emitNanoChange(event) {
251
+ const { value } = this;
252
+ // Checks for both null and undefined values
253
+ const newValue = value == null ? value : value.toString();
254
+ this.computeValidity();
255
+ this.nanoChange.emit({
256
+ value: newValue?.toString(),
257
+ event,
258
+ valid: this.valid,
259
+ });
260
+ }
261
+ /**
262
+ * Emits an `nanoInput` event.
263
+ * This is used to emit the input value when the user types,
264
+ * backspaces, or pastes.
265
+ */
266
+ emitNanoInput(event) {
267
+ const { value } = this;
268
+ // Checks for both null and undefined values
269
+ const newValue = value == null ? value : value.toString();
270
+ this.computeValidity();
271
+ this.nanoInput.emit({
272
+ value: newValue?.toString(),
273
+ event,
274
+ valid: this.valid,
275
+ });
276
+ }
277
+ /**
278
+ * Handles the focus behavior for the input OTP component.
279
+ *
280
+ * Focus behavior:
281
+ * 1. Keyboard navigation: Allow normal focus movement
282
+ * 2. Mouse click:
283
+ * - If clicked box has value: Focus that box
284
+ * - If clicked box is empty: Focus first empty box
285
+ *
286
+ * Emits the `nanoFocus` event when the input group gains focus.
287
+ * @returns {(event: FocusEvent) => void} Event handler for focus events.
288
+ */
289
+ onFocus = (index) => (event) => {
290
+ const { inputRefs } = this;
291
+ // Only emit nanoFocus and set the focusedValue when the
292
+ // component first gains focus
293
+ if (!this.hasFocus) {
294
+ this.nanoFocus.emit(event);
295
+ this.focusedValue = this.value;
296
+ }
297
+ this.hasFocus = true;
298
+ let finalIndex = index;
299
+ if (!this.isKeyboardNavigation) {
300
+ // If the clicked box has a value, focus it
301
+ // Otherwise focus the first empty box
302
+ const targetIndex = this.inputValues[index]
303
+ ? index
304
+ : this.getFirstEmptyIndex();
305
+ finalIndex = targetIndex === -1 ? this.length - 1 : targetIndex;
306
+ // Focus the target box
307
+ this.inputRefs[finalIndex]?.focus();
308
+ }
309
+ // Update tabIndexes to match the focused box
310
+ inputRefs.forEach((input, i) => {
311
+ input.tabIndex = i === finalIndex ? 0 : -1;
312
+ });
313
+ // Reset the keyboard navigation flag
314
+ this.isKeyboardNavigation = false;
315
+ };
316
+ /**
317
+ * Handles the blur behavior for the input OTP component.
318
+ * Emits the `nanoBlur` event when the input group loses focus.
319
+ */
320
+ onBlur = (event) => {
321
+ const { inputRefs } = this;
322
+ const relatedTarget = event.relatedTarget;
323
+ // Do not emit blur if we're moving to another input box in the same component
324
+ const isInternalFocus = relatedTarget != null &&
325
+ inputRefs.includes(relatedTarget);
326
+ if (!isInternalFocus) {
327
+ this.hasFocus = false;
328
+ // Reset tabIndexes when focus leaves the component
329
+ this.updateTabIndexes();
330
+ // Always emit nanoBlur when focus leaves the component
331
+ this.nanoBlur.emit(event);
332
+ // Only emit nanoChange if the value has actually changed
333
+ if (this.focusedValue !== this.value) {
334
+ this.emitNanoChange(event);
335
+ }
336
+ }
337
+ };
338
+ /**
339
+ * Focuses the next input box.
340
+ */
341
+ focusNext(currentIndex) {
342
+ const { inputRefs, length } = this;
343
+ if (currentIndex < length - 1) {
344
+ inputRefs[currentIndex + 1]?.focus();
345
+ }
346
+ }
347
+ /**
348
+ * Focuses the previous input box.
349
+ */
350
+ focusPrevious(currentIndex) {
351
+ const { inputRefs } = this;
352
+ if (currentIndex > 0) {
353
+ inputRefs[currentIndex - 1]?.focus();
354
+ }
355
+ }
356
+ /**
357
+ * Searches through the input values and returns the index
358
+ * of the first empty input.
359
+ * Returns -1 if all inputs are filled.
360
+ * @returns {number} The index of the first empty input, or -1 if all are filled.
361
+ */
362
+ getFirstEmptyIndex() {
363
+ const { inputValues, length } = this;
364
+ // Create an array of the same length as the input OTP
365
+ // and fill it with the input values
366
+ const values = Array.from({ length }, (_, i) => inputValues[i] || '');
367
+ return values.findIndex((value) => !value || value === '') ?? -1;
368
+ }
369
+ /**
370
+ * Returns the index of the input that should be tabbed to.
371
+ * If all inputs are filled, returns the last input's index.
372
+ * Otherwise, returns the index of the first empty input.
373
+ * @returns {number} The index to tab to.
374
+ */
375
+ getTabbableIndex() {
376
+ const { length } = this;
377
+ const firstEmptyIndex = this.getFirstEmptyIndex();
378
+ return firstEmptyIndex === -1 ? length - 1 : firstEmptyIndex;
379
+ }
380
+ /**
381
+ * Updates the tabIndexes for the input boxes.
382
+ * This is used to ensure that the correct input is
383
+ * focused when the user navigates using the tab key.
384
+ */
385
+ updateTabIndexes() {
386
+ const { inputRefs, inputValues, length } = this;
387
+ // Find first empty index after any filled boxes
388
+ let firstEmptyIndex = -1;
389
+ for (let i = 0; i < length; i++) {
390
+ if (!inputValues[i] || inputValues[i] === '') {
391
+ firstEmptyIndex = i;
392
+ break;
393
+ }
394
+ }
395
+ // Update tabIndex and aria-hidden for all inputs
396
+ inputRefs.forEach((input, index) => {
397
+ const shouldBeTabbable = firstEmptyIndex === -1
398
+ ? index === length - 1
399
+ : firstEmptyIndex === index;
400
+ input.tabIndex = shouldBeTabbable ? 0 : -1;
401
+ // If the input is empty and not the first empty input,
402
+ // it should be hidden from screen readers.
403
+ const isEmpty = !inputValues[index] || inputValues[index] === '';
404
+ input.setAttribute('aria-hidden', isEmpty && !shouldBeTabbable ? 'true' : 'false');
405
+ });
406
+ }
407
+ /**
408
+ * Handles keyboard navigation for the OTP component.
409
+ *
410
+ * Navigation:
411
+ * - Backspace: Clears current input and moves to previous box if empty
412
+ * - Arrow Left/Right: Moves focus between input boxes
413
+ * - Tab: Allows normal tab navigation between components
414
+ * @returns {(event: KeyboardEvent) => void} Event handler for keydown events.
415
+ */
416
+ onKeyDown = (index) => (event) => {
417
+ const { length } = this;
418
+ const rtl = this.isRTL(this.el);
419
+ const input = event.target;
420
+ // Meta shortcuts are used to copy, paste, and select text
421
+ // We don't want to handle these keys here
422
+ const metaShortcuts = ['a', 'c', 'v', 'x', 'r', 'z', 'y'];
423
+ const isTextSelection = input.selectionStart !== input.selectionEnd;
424
+ // Return if the key is a meta shortcut or the input value
425
+ // text is selected and let the onPaste / onInput handler manage it
426
+ if (isTextSelection ||
427
+ ((event.metaKey || event.ctrlKey) &&
428
+ metaShortcuts.includes(event.key.toLowerCase()))) {
429
+ return;
430
+ }
431
+ if (event.key === 'Backspace') {
432
+ if (this.inputValues[index]) {
433
+ // Shift all values to the right of the current index left by one
434
+ for (let i = index; i < length - 1; i++) {
435
+ this.inputValues[i] = this.inputValues[i + 1];
436
+ }
437
+ // Clear the last box
438
+ this.inputValues[length - 1] = '';
439
+ // Update all inputRefs to match inputValues
440
+ for (let i = 0; i < length; i++) {
441
+ this.inputRefs[i].value = this.inputValues[i] || '';
442
+ }
443
+ this.updateValue(event);
444
+ event.preventDefault();
445
+ }
446
+ else if (!this.inputValues[index] && index > 0) {
447
+ // If current input is empty, move to previous input
448
+ this.focusPrevious(index);
449
+ }
450
+ }
451
+ else if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
452
+ this.isKeyboardNavigation = true;
453
+ event.preventDefault();
454
+ const isLeft = event.key === 'ArrowLeft';
455
+ const shouldMoveNext = (isLeft && rtl) || (!isLeft && !rtl);
456
+ // Only allow moving to the next input if the current has a value
457
+ if (shouldMoveNext) {
458
+ if (this.inputValues[index] && index < length - 1) {
459
+ this.focusNext(index);
460
+ }
461
+ }
462
+ else {
463
+ this.focusPrevious(index);
464
+ }
465
+ }
466
+ else if (event.key === 'Tab') {
467
+ this.isKeyboardNavigation = true;
468
+ // Let all tab events proceed normally
469
+ return;
470
+ }
471
+ };
472
+ /**
473
+ * Processes all input scenarios for each input box.
474
+ *
475
+ * This function manages:
476
+ * 1. Autofill handling
477
+ * 2. Input validation
478
+ * 3. Full selection replacement or typing in an empty box
479
+ * 4. Inserting in the middle with available space (shifting)
480
+ * 5. Single character replacement
481
+ * @returns {(event: InputEvent) => void} Event handler for input events.
482
+ */
483
+ onInput = (index) => (event) => {
484
+ const { length, validKeyPattern, allowInvalid } = this;
485
+ const input = event.target;
486
+ const value = input.value;
487
+ const previousValue = this.previousInputValues[index] || '';
488
+ // 1. Autofill handling
489
+ // If the length of the value increases by more than 1 from the previous
490
+ // value, treat this as autofill. This is to prevent the case where the
491
+ // user is typing a single character into an input box containing a value
492
+ // as that will trigger this function with a value length of 2 characters.
493
+ const isAutofill = value.length - previousValue.length > 1;
494
+ if (isAutofill) {
495
+ // Distribute valid characters across input boxes
496
+ const validChars = this.getValidChars(value);
497
+ // If there are no valid characters coming from the
498
+ // autofill, all input refs have to be cleared after the
499
+ // browser has finished the autofill behavior
500
+ if (validChars.length === 0) {
501
+ requestAnimationFrame(() => {
502
+ this.inputRefs.forEach((input) => {
503
+ input.value = '';
504
+ });
505
+ });
506
+ }
507
+ for (let i = 0; i < length; i++) {
508
+ this.inputValues[i] = validChars[i] || '';
509
+ this.inputRefs[i].value = validChars[i] || '';
510
+ }
511
+ this.updateValue(event);
512
+ // Focus the first empty input box or the last input box if all boxes
513
+ // are filled after a small delay to ensure the input boxes have been
514
+ // updated before moving the focus
515
+ setTimeout(() => {
516
+ const nextIndex = validChars.length < length ? validChars.length : length - 1;
517
+ this.inputRefs[nextIndex]?.focus();
518
+ }, 20);
519
+ this.previousInputValues = [...this.inputValues];
520
+ return;
521
+ }
522
+ // 2. Input validation
523
+ // If the character entered is invalid (does not match the pattern),
524
+ // restore the previous value and exit
525
+ if ((!allowInvalid &&
526
+ value.length > 0 &&
527
+ !validKeyPattern.test(value[value.length - 1])) ||
528
+ (allowInvalid && this.specialCharsPattern.test(value[value.length - 1]))) {
529
+ input.value = this.inputValues[index] || '';
530
+ this.previousInputValues = [...this.inputValues];
531
+ return;
532
+ }
533
+ // 3. Full selection replacement or typing in an empty box
534
+ // If the user selects all text in the input box and types, or if the
535
+ // input box is empty, replace only this input box. If the box is empty,
536
+ // move to the next box, otherwise stay focused on this box.
537
+ const isAllSelected = input.selectionStart === 0 && input.selectionEnd === value.length;
538
+ const isEmpty = !this.inputValues[index];
539
+ if (isAllSelected || isEmpty) {
540
+ this.inputValues[index] = value;
541
+ input.value = value;
542
+ this.updateValue(event);
543
+ this.focusNext(index);
544
+ this.previousInputValues = [...this.inputValues];
545
+ return;
546
+ }
547
+ // 4. Inserting in the middle with available space (shifting)
548
+ // If typing in a filled input box and there are empty boxes at the end,
549
+ // shift all values starting at the current box to the right, and insert
550
+ // the new character at the current box.
551
+ const hasAvailableBoxAtEnd = this.inputValues[this.inputValues.length - 1] === '';
552
+ if (this.inputValues[index] && hasAvailableBoxAtEnd && value.length === 2) {
553
+ // Get the inserted character (from event or by diffing value/previousValue)
554
+ let newChar = event.data;
555
+ if (!newChar) {
556
+ newChar =
557
+ value.split('').find((c, i) => c !== previousValue[i]) ||
558
+ value[value.length - 1];
559
+ }
560
+ // Validate the new character before shifting
561
+ if (!allowInvalid && !validKeyPattern.test(newChar)) {
562
+ input.value = this.inputValues[index] || '';
563
+ this.previousInputValues = [...this.inputValues];
564
+ return;
565
+ }
566
+ // Shift values right from the end to the insertion point
567
+ for (let i = this.inputValues.length - 1; i > index; i--) {
568
+ this.inputValues[i] = this.inputValues[i - 1];
569
+ this.inputRefs[i].value = this.inputValues[i] || '';
570
+ }
571
+ this.inputValues[index] = newChar;
572
+ this.inputRefs[index].value = newChar;
573
+ this.updateValue(event);
574
+ this.previousInputValues = [...this.inputValues];
575
+ return;
576
+ }
577
+ // 5. Single character replacement
578
+ // Handles replacing a single character in a box containing a value based
579
+ // on the cursor position. We need the cursor position to determine which
580
+ // character was the last character typed. For example, if the user types "2"
581
+ // in an input box with the cursor at the beginning of the value of "6",
582
+ // the value will be "26", but we want to grab the "2" as the last character
583
+ // typed.
584
+ const cursorPos = input.selectionStart ?? value.length;
585
+ const newCharIndex = cursorPos - 1;
586
+ const newChar = value[newCharIndex] ?? value[0];
587
+ // Check if the new character is valid before updating the value
588
+ if (!allowInvalid && !validKeyPattern.test(newChar)) {
589
+ input.value = this.inputValues[index] || '';
590
+ this.previousInputValues = [...this.inputValues];
591
+ return;
592
+ }
593
+ this.inputValues[index] = newChar;
594
+ input.value = newChar;
595
+ this.updateValue(event);
596
+ this.previousInputValues = [...this.inputValues];
597
+ };
598
+ /**
599
+ * Handles pasting text into the input OTP component.
600
+ * This function prevents the default paste behavior and
601
+ * validates the pasted text against the allowed pattern.
602
+ * It then updates the value of the input group and focuses
603
+ * the next empty input after pasting.
604
+ */
605
+ onPaste = (event) => {
606
+ const { inputRefs, length } = this;
607
+ event.preventDefault();
608
+ const pastedText = event.clipboardData?.getData('text');
609
+ // If there is no pasted text, still emit the input change event
610
+ // because this is how the native input element behaves
611
+ // but return early because there is nothing to paste.
612
+ if (!pastedText) {
613
+ this.emitNanoInput(event);
614
+ return;
615
+ }
616
+ const validChars = this.getValidChars(pastedText);
617
+ // Always paste starting at the first box
618
+ validChars.forEach((char, index) => {
619
+ if (index < length) {
620
+ this.inputRefs[index].value = char;
621
+ this.inputValues[index] = char;
622
+ }
623
+ });
624
+ // Update the value so that all input boxes are updated
625
+ this.value = validChars.join('');
626
+ this.updateValue(event);
627
+ // Focus the next empty input after pasting
628
+ // If all boxes are filled, focus the last input
629
+ const nextEmptyIndex = validChars.length < length ? validChars.length : length - 1;
630
+ inputRefs[nextEmptyIndex]?.focus();
631
+ };
632
+ /**
633
+ * Determines if a separator should be shown for a given index by:
634
+ * - Checking if the total length is even (no separator for odd lengths)
635
+ * - If even, showing a separator after the middle index
636
+ *
637
+ * @param index - The index to check for a separator.
638
+ * @returns {boolean} True if a separator should be shown after the given index, false otherwise.
639
+ */
640
+ showSeparator(index) {
641
+ const { length } = this;
642
+ if (length < 3 || length % 2 !== 0)
643
+ return false;
644
+ return index === length / 2 - 1;
645
+ }
646
+ /**
647
+ * Filters the input string to only include valid characters based on the
648
+ * `validKeyPattern` regex. If `allowInvalid` is true, it will also
649
+ * exclude special characters. The resulting array is sliced to the
650
+ * maximum length of the input OTP.
651
+ * @param str - The input string to filter.
652
+ * @returns {string[]} An array of valid characters.
653
+ */
654
+ getValidChars(str) {
655
+ const { allowInvalid, validKeyPattern, length } = this;
656
+ const allChars = str.split('');
657
+ return (allowInvalid
658
+ ? allChars.filter((char) => char.trim() !== '' && !this.specialCharsPattern.test(char))
659
+ : allChars.filter((char) => char.trim() !== '' && validKeyPattern.test(char))).slice(0, length);
660
+ }
661
+ /**
662
+ * Computes the validity of the input group based on the current input values.
663
+ * Sets the following `invalid` and `valid` states:
664
+ * - `invalid` is true if `allowInvalid` is true and any input value is invalid.
665
+ * - `valid` is true if all input boxes are filled with valid values.
666
+ */
667
+ computeValidity() {
668
+ const { inputValues } = this;
669
+ this.invalid =
670
+ this.allowInvalid &&
671
+ this.inputValues.some((val) => val !== '' && !this.validKeyPattern.test(val));
672
+ this.valid =
673
+ this.inputValues.length === this.length &&
674
+ this.inputValues.every((val) => val !== '' && this.validKeyPattern.test(val));
675
+ inputValues.some((v) => v !== '' && !this.validKeyPattern.test(v));
676
+ }
677
+ render() {
678
+ const { disabled, el, hasFocus, inputId, inputRefs, inputValues, length, readonly, invalid, valid, } = this;
679
+ const inputmode = this.getInputmode();
680
+ const tabbableIndex = this.getTabbableIndex();
681
+ const pattern = this.getPattern();
682
+ const hasDescription = el.querySelector('.input-otp-description')?.textContent?.trim() !== '';
683
+ return (h(Host, { key: 'f397a0775d2d961ccc9013206fae72a8d0ad90ae', class: {
684
+ 'has-focus': hasFocus,
685
+ 'input-otp-disabled': disabled,
686
+ 'input-otp-readonly': readonly,
687
+ 'nano-invalid': invalid,
688
+ 'nano-valid': valid,
689
+ } }, h("div", { key: 'add5fe905af87f4c9b87d29c66134ede52ff2b6b', role: "group", "aria-label": "One-time password input", class: "input-otp-group" }, Array.from({ length }).map((_, index) => (h(Fragment, null, h("div", { class: "native-wrapper" }, h("input", { class: "native-input", id: `${inputId}-${index}`, "aria-label": `Input ${index + 1} of ${length}`, type: "text", inputmode: inputmode, pattern: pattern, disabled: disabled, readOnly: readonly, tabIndex: index === tabbableIndex ? 0 : -1, value: inputValues[index] || '', autocomplete: "one-time-code", ref: (el) => (inputRefs[index] = el), onInput: this.onInput(index), onBlur: this.onBlur, onFocus: this.onFocus(index), onKeyDown: this.onKeyDown(index), onPaste: this.onPaste })), this.showSeparator(index) && h("div", { class: "input-otp-separator" })))), this.showValidity && (h("div", { key: '71d38d8f343be559d187f1c5710a64733cf7ceaa', class: {
690
+ 'input-otp-icon': true,
691
+ 'input-otp-icon--valid': valid,
692
+ 'input-otp-icon--invalid': invalid,
693
+ } }, h("slot", { key: '14529ecc57a6268932bc1485f0a425bb6cb45c51', name: "validity-icon" }, h("nano-icon", { key: '65669a6b4ca76011b721e76fb68b7f9bfeb87092', hidden: !valid, name: "light/circle-check", class: "input-otp-valid-icon", "aria-label": "Valid input" }))))), h("div", { key: '3e677ab8517765759a0cc4a0aa6f0fec58767c90', class: {
694
+ 'input-otp-description': true,
695
+ 'input-otp-description-hidden': !hasDescription,
696
+ 'input-otp-description-inset': this.showValidity,
697
+ } }, h("slot", { key: 'e875d5c5d7ed8f804b9866618b7ed5e5211dd7b1' }))));
698
+ }
699
+ static get is() { return "nano-input-otp"; }
700
+ static get encapsulation() { return "scoped"; }
701
+ static get originalStyleUrls() {
702
+ return {
703
+ "$": ["input-otp.scss"]
704
+ };
705
+ }
706
+ static get styleUrls() {
707
+ return {
708
+ "$": ["input-otp.css"]
709
+ };
710
+ }
711
+ static get properties() {
712
+ return {
713
+ "disabled": {
714
+ "type": "boolean",
715
+ "attribute": "disabled",
716
+ "mutable": false,
717
+ "complexType": {
718
+ "original": "boolean",
719
+ "resolved": "boolean",
720
+ "references": {}
721
+ },
722
+ "required": false,
723
+ "optional": false,
724
+ "docs": {
725
+ "tags": [],
726
+ "text": "If `true`, the user cannot interact with the input."
727
+ },
728
+ "getter": false,
729
+ "setter": false,
730
+ "reflect": true,
731
+ "defaultValue": "false"
732
+ },
733
+ "inputmode": {
734
+ "type": "string",
735
+ "attribute": "inputmode",
736
+ "mutable": false,
737
+ "complexType": {
738
+ "original": "| 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'",
739
+ "resolved": "\"decimal\" | \"email\" | \"none\" | \"numeric\" | \"search\" | \"tel\" | \"text\" | \"url\"",
740
+ "references": {}
741
+ },
742
+ "required": false,
743
+ "optional": true,
744
+ "docs": {
745
+ "tags": [],
746
+ "text": "A hint to the browser for which keyboard to display.\nPossible values: `\"none\"`, `\"text\"`, `\"tel\"`, `\"url\"`,\n`\"email\"`, `\"numeric\"`, `\"decimal\"`, and `\"search\"`.\n\nFor numbers (type=\"number\"): \"numeric\"\nFor text (type=\"text\"): \"text\""
747
+ },
748
+ "getter": false,
749
+ "setter": false,
750
+ "reflect": false
751
+ },
752
+ "length": {
753
+ "type": "number",
754
+ "attribute": "length",
755
+ "mutable": false,
756
+ "complexType": {
757
+ "original": "number",
758
+ "resolved": "number",
759
+ "references": {}
760
+ },
761
+ "required": false,
762
+ "optional": false,
763
+ "docs": {
764
+ "tags": [],
765
+ "text": "The number of input boxes to display."
766
+ },
767
+ "getter": false,
768
+ "setter": false,
769
+ "reflect": false,
770
+ "defaultValue": "6"
771
+ },
772
+ "pattern": {
773
+ "type": "string",
774
+ "attribute": "pattern",
775
+ "mutable": false,
776
+ "complexType": {
777
+ "original": "string",
778
+ "resolved": "string",
779
+ "references": {}
780
+ },
781
+ "required": false,
782
+ "optional": true,
783
+ "docs": {
784
+ "tags": [],
785
+ "text": "A regex pattern string for allowed characters. Defaults based on type.\n\nFor numbers (`type=\"number\"`): `\"[\\p{N}]\"`\nFor text (`type=\"text\"`): `\"[\\p{L}\\p{N}]\"`"
786
+ },
787
+ "getter": false,
788
+ "setter": false,
789
+ "reflect": false
790
+ },
791
+ "readonly": {
792
+ "type": "boolean",
793
+ "attribute": "readonly",
794
+ "mutable": false,
795
+ "complexType": {
796
+ "original": "boolean",
797
+ "resolved": "boolean",
798
+ "references": {}
799
+ },
800
+ "required": false,
801
+ "optional": false,
802
+ "docs": {
803
+ "tags": [],
804
+ "text": "If `true`, the user cannot modify the value."
805
+ },
806
+ "getter": false,
807
+ "setter": false,
808
+ "reflect": true,
809
+ "defaultValue": "false"
810
+ },
811
+ "type": {
812
+ "type": "string",
813
+ "attribute": "type",
814
+ "mutable": false,
815
+ "complexType": {
816
+ "original": "'text' | 'number'",
817
+ "resolved": "\"number\" | \"text\"",
818
+ "references": {}
819
+ },
820
+ "required": false,
821
+ "optional": false,
822
+ "docs": {
823
+ "tags": [],
824
+ "text": "The type of input allowed in the input boxes."
825
+ },
826
+ "getter": false,
827
+ "setter": false,
828
+ "reflect": false,
829
+ "defaultValue": "'number'"
830
+ },
831
+ "value": {
832
+ "type": "any",
833
+ "attribute": "value",
834
+ "mutable": true,
835
+ "complexType": {
836
+ "original": "string | number | null",
837
+ "resolved": "number | string",
838
+ "references": {}
839
+ },
840
+ "required": false,
841
+ "optional": true,
842
+ "docs": {
843
+ "tags": [],
844
+ "text": "The value of the input group."
845
+ },
846
+ "getter": false,
847
+ "setter": false,
848
+ "reflect": false,
849
+ "defaultValue": "''"
850
+ },
851
+ "allowInvalid": {
852
+ "type": "boolean",
853
+ "attribute": "allow-invalid",
854
+ "mutable": false,
855
+ "complexType": {
856
+ "original": "boolean",
857
+ "resolved": "boolean",
858
+ "references": {}
859
+ },
860
+ "required": false,
861
+ "optional": false,
862
+ "docs": {
863
+ "tags": [],
864
+ "text": "If `true`, allows the input to be completely filled with invalid values.\nBy default, if any input box contains an invalid value, the entire input group\nis marked as invalid.\nDefault is `false`."
865
+ },
866
+ "getter": false,
867
+ "setter": false,
868
+ "reflect": true,
869
+ "defaultValue": "false"
870
+ },
871
+ "showValidity": {
872
+ "type": "boolean",
873
+ "attribute": "show-validity",
874
+ "mutable": false,
875
+ "complexType": {
876
+ "original": "boolean",
877
+ "resolved": "boolean",
878
+ "references": {}
879
+ },
880
+ "required": false,
881
+ "optional": false,
882
+ "docs": {
883
+ "tags": [],
884
+ "text": "If `true`, shows a validity icon when all input boxes are filled.\nA check icon is shown if all values are valid, and an X icon is shown if any value is invalid.\nThis does not affect the `invalid` or `valid` states of the input group.\nDefault is `false`."
885
+ },
886
+ "getter": false,
887
+ "setter": false,
888
+ "reflect": true,
889
+ "defaultValue": "false"
890
+ }
891
+ };
892
+ }
893
+ static get states() {
894
+ return {
895
+ "inputValues": {},
896
+ "hasFocus": {},
897
+ "previousInputValues": {},
898
+ "invalid": {},
899
+ "valid": {}
900
+ };
901
+ }
902
+ static get events() {
903
+ return [{
904
+ "method": "nanoInput",
905
+ "name": "nanoInput",
906
+ "bubbles": true,
907
+ "cancelable": true,
908
+ "composed": true,
909
+ "docs": {
910
+ "tags": [],
911
+ "text": "The `nanoInput` event is fired each time the user modifies the input's value.\nUnlike the `nanoChange` event, the `nanoInput` event is fired for each alteration\nto the input's value. This typically happens for each keystroke as the user types.\n\nFor elements that accept text input (`type=text`, `type=tel`, etc.), the interface\nis [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent); for others,\nthe interface is [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). If\nthe input is cleared on edit, the type is `null`."
912
+ },
913
+ "complexType": {
914
+ "original": "InputOtpInputEventDetail",
915
+ "resolved": "InputOtpInputEventDetail",
916
+ "references": {
917
+ "InputOtpInputEventDetail": {
918
+ "location": "import",
919
+ "path": "./input-otp-interface.js",
920
+ "id": "src/components/input-otp/input-otp-interface.ts::InputOtpInputEventDetail"
921
+ }
922
+ }
923
+ }
924
+ }, {
925
+ "method": "nanoChange",
926
+ "name": "nanoChange",
927
+ "bubbles": true,
928
+ "cancelable": true,
929
+ "composed": true,
930
+ "docs": {
931
+ "tags": [],
932
+ "text": "The `nanoChange` event is fired when the user modifies the input's value.\nUnlike the `nanoInput` event, the `nanoChange` event is only fired when changes\nare committed, not as the user types.\n\nThe `nanoChange` event fires when the `<nano-input-otp>` component loses\nfocus after its value has changed.\n\nThis event will not emit when programmatically setting the `value` property."
933
+ },
934
+ "complexType": {
935
+ "original": "InputOtpChangeEventDetail",
936
+ "resolved": "InputOtpChangeEventDetail",
937
+ "references": {
938
+ "InputOtpChangeEventDetail": {
939
+ "location": "import",
940
+ "path": "./input-otp-interface.js",
941
+ "id": "src/components/input-otp/input-otp-interface.ts::InputOtpChangeEventDetail"
942
+ }
943
+ }
944
+ }
945
+ }, {
946
+ "method": "nanoComplete",
947
+ "name": "nanoComplete",
948
+ "bubbles": true,
949
+ "cancelable": true,
950
+ "composed": true,
951
+ "docs": {
952
+ "tags": [],
953
+ "text": "Emitted when all input boxes have been filled with valid values."
954
+ },
955
+ "complexType": {
956
+ "original": "InputOtpCompleteEventDetail",
957
+ "resolved": "InputOtpCompleteEventDetail",
958
+ "references": {
959
+ "InputOtpCompleteEventDetail": {
960
+ "location": "import",
961
+ "path": "./input-otp-interface.js",
962
+ "id": "src/components/input-otp/input-otp-interface.ts::InputOtpCompleteEventDetail"
963
+ }
964
+ }
965
+ }
966
+ }, {
967
+ "method": "nanoBlur",
968
+ "name": "nanoBlur",
969
+ "bubbles": true,
970
+ "cancelable": true,
971
+ "composed": true,
972
+ "docs": {
973
+ "tags": [],
974
+ "text": "Emitted when the input group loses focus."
975
+ },
976
+ "complexType": {
977
+ "original": "FocusEvent",
978
+ "resolved": "FocusEvent",
979
+ "references": {
980
+ "FocusEvent": {
981
+ "location": "global",
982
+ "id": "global::FocusEvent"
983
+ }
984
+ }
985
+ }
986
+ }, {
987
+ "method": "nanoFocus",
988
+ "name": "nanoFocus",
989
+ "bubbles": true,
990
+ "cancelable": true,
991
+ "composed": true,
992
+ "docs": {
993
+ "tags": [],
994
+ "text": "Emitted when the input group has focus."
995
+ },
996
+ "complexType": {
997
+ "original": "FocusEvent",
998
+ "resolved": "FocusEvent",
999
+ "references": {
1000
+ "FocusEvent": {
1001
+ "location": "global",
1002
+ "id": "global::FocusEvent"
1003
+ }
1004
+ }
1005
+ }
1006
+ }];
1007
+ }
1008
+ static get methods() {
1009
+ return {
1010
+ "setFocus": {
1011
+ "complexType": {
1012
+ "signature": "(index?: number) => Promise<void>",
1013
+ "parameters": [{
1014
+ "name": "index",
1015
+ "type": "number",
1016
+ "docs": "- The index of the input box to focus (0-based).\nIf provided and the input box has a value, the input box at that index will be focused.\nOtherwise, the first empty input box or the last input if all are filled will be focused."
1017
+ }],
1018
+ "references": {
1019
+ "Promise": {
1020
+ "location": "global",
1021
+ "id": "global::Promise"
1022
+ }
1023
+ },
1024
+ "return": "Promise<void>"
1025
+ },
1026
+ "docs": {
1027
+ "text": "Sets focus to an input box.",
1028
+ "tags": [{
1029
+ "name": "param",
1030
+ "text": "index - The index of the input box to focus (0-based).\nIf provided and the input box has a value, the input box at that index will be focused.\nOtherwise, the first empty input box or the last input if all are filled will be focused."
1031
+ }]
1032
+ }
1033
+ }
1034
+ };
1035
+ }
1036
+ static get elementRef() { return "el"; }
1037
+ static get watchers() {
1038
+ return [{
1039
+ "propName": "value",
1040
+ "methodName": "valueChanged"
1041
+ }];
1042
+ }
1043
+ }
1044
+ let inputIds = 0;