@ionic/core 8.5.7-dev.11748379940.12698faf → 8.5.7-dev.11748545890.14d6a067

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/hydrate/index.mjs CHANGED
@@ -16983,10 +16983,6 @@ class InputOTP {
16983
16983
  * If `true`, the user cannot modify the value.
16984
16984
  */
16985
16985
  this.readonly = false;
16986
- /**
16987
- * The size of the input boxes.
16988
- */
16989
- this.size = 'medium';
16990
16986
  /**
16991
16987
  * The shape of the input boxes.
16992
16988
  * If "round" they will have an increased border radius.
@@ -16994,6 +16990,10 @@ class InputOTP {
16994
16990
  * If "soft" they will have a soft border radius.
16995
16991
  */
16996
16992
  this.shape = 'round';
16993
+ /**
16994
+ * The size of the input boxes.
16995
+ */
16996
+ this.size = 'medium';
16997
16997
  /**
16998
16998
  * The type of input allowed in the input boxes.
16999
16999
  */
@@ -17002,34 +17002,63 @@ class InputOTP {
17002
17002
  * The value of the input group.
17003
17003
  */
17004
17004
  this.value = '';
17005
- this.onInput = (index) => (event) => {
17006
- const { validKeyPattern } = this;
17007
- const value = event.target.value;
17008
- // Only allow input if it's a single character and matches the pattern
17009
- if (value.length > 1 || (value.length > 0 && !validKeyPattern.test(value))) {
17010
- // Reset the input value if not valid
17011
- this.inputRefs[index].value = '';
17012
- this.inputValues[index] = '';
17013
- return;
17014
- }
17015
- // Find the first empty box before or at the current index
17016
- let targetIndex = index;
17017
- for (let i = 0; i < index; i++) {
17018
- if (!this.inputValues[i] || this.inputValues[i] === '') {
17019
- targetIndex = i;
17020
- break;
17021
- }
17005
+ /**
17006
+ * Handles the focus behavior for the input OTP component.
17007
+ *
17008
+ * Focus behavior:
17009
+ * 1. Keyboard navigation: Allow normal focus movement
17010
+ * 2. Mouse click:
17011
+ * - If clicked box has value: Focus that box
17012
+ * - If clicked box is empty: Focus first empty box
17013
+ *
17014
+ * Emits the `ionFocus` event when the input group gains focus.
17015
+ */
17016
+ this.onFocus = (index) => (event) => {
17017
+ var _a;
17018
+ const { inputRefs } = this;
17019
+ // Only emit ionFocus and set the focusedValue when the
17020
+ // component first gains focus
17021
+ if (!this.hasFocus) {
17022
+ this.ionFocus.emit(event);
17023
+ this.focusedValue = this.value;
17022
17024
  }
17023
- // Set the value at the target index
17024
- this.inputValues[targetIndex] = value;
17025
- // If the value was entered in a later box, clear the current box
17026
- if (targetIndex !== index) {
17027
- this.inputRefs[index].value = '';
17025
+ this.hasFocus = true;
17026
+ let finalIndex = index;
17027
+ if (!this.isKeyboardNavigation) {
17028
+ // If the clicked box has a value, focus it
17029
+ // Otherwise focus the first empty box
17030
+ const targetIndex = this.inputValues[index] ? index : this.getFirstEmptyIndex();
17031
+ finalIndex = targetIndex === -1 ? this.length - 1 : targetIndex;
17032
+ // Focus the target box
17033
+ (_a = this.inputRefs[finalIndex]) === null || _a === void 0 ? void 0 : _a.focus();
17028
17034
  }
17029
- if (value.length > 0) {
17030
- this.focusNext(targetIndex);
17035
+ // Update tabIndexes to match the focused box
17036
+ inputRefs.forEach((input, i) => {
17037
+ input.tabIndex = i === finalIndex ? 0 : -1;
17038
+ });
17039
+ // Reset the keyboard navigation flag
17040
+ this.isKeyboardNavigation = false;
17041
+ };
17042
+ /**
17043
+ * Handles the blur behavior for the input OTP component.
17044
+ * Emits the `ionBlur` event when the input group loses focus.
17045
+ */
17046
+ this.onBlur = (event) => {
17047
+ const { inputRefs } = this;
17048
+ const relatedTarget = event.relatedTarget;
17049
+ // Do not emit blur if we're moving to another input box in the same component
17050
+ const isInternalFocus = relatedTarget != null && inputRefs.includes(relatedTarget);
17051
+ if (!isInternalFocus) {
17052
+ this.hasFocus = false;
17053
+ // Reset tabIndexes when focus leaves the component
17054
+ this.updateTabIndexes();
17055
+ // Always emit ionBlur when focus leaves the component
17056
+ this.ionBlur.emit(event);
17057
+ // Only emit ionChange if the value has actually changed
17058
+ if (this.focusedValue !== this.value) {
17059
+ this.emitIonChange(event);
17060
+ }
17031
17061
  }
17032
- this.updateValue(event);
17033
17062
  };
17034
17063
  /**
17035
17064
  * Handles keyboard navigation and input for the OTP component.
@@ -17115,6 +17144,35 @@ class InputOTP {
17115
17144
  event.preventDefault();
17116
17145
  }
17117
17146
  };
17147
+ this.onInput = (index) => (event) => {
17148
+ const { validKeyPattern } = this;
17149
+ const value = event.target.value;
17150
+ // Only allow input if it's a single character and matches the pattern
17151
+ if (value.length > 1 || (value.length > 0 && !validKeyPattern.test(value))) {
17152
+ // Reset the input value if not valid
17153
+ this.inputRefs[index].value = '';
17154
+ this.inputValues[index] = '';
17155
+ return;
17156
+ }
17157
+ // Find the first empty box before or at the current index
17158
+ let targetIndex = index;
17159
+ for (let i = 0; i < index; i++) {
17160
+ if (!this.inputValues[i] || this.inputValues[i] === '') {
17161
+ targetIndex = i;
17162
+ break;
17163
+ }
17164
+ }
17165
+ // Set the value at the target index
17166
+ this.inputValues[targetIndex] = value;
17167
+ // If the value was entered in a later box, clear the current box
17168
+ if (targetIndex !== index) {
17169
+ this.inputRefs[index].value = '';
17170
+ }
17171
+ if (value.length > 0) {
17172
+ this.focusNext(targetIndex);
17173
+ }
17174
+ this.updateValue(event);
17175
+ };
17118
17176
  /**
17119
17177
  * Handles pasting text into the input OTP component.
17120
17178
  * This function prevents the default paste behavior and
@@ -17158,67 +17216,27 @@ class InputOTP {
17158
17216
  (_c = inputRefs[length - 1]) === null || _c === void 0 ? void 0 : _c.focus();
17159
17217
  }
17160
17218
  };
17161
- /**
17162
- * Handles the focus behavior for the input OTP component.
17163
- *
17164
- * Focus behavior:
17165
- * 1. Keyboard navigation: Allow normal focus movement
17166
- * 2. Mouse click:
17167
- * - If clicked box has value: Focus that box
17168
- * - If clicked box is empty: Focus first empty box
17169
- *
17170
- * Emits the `ionFocus` event when the input group gains focus.
17171
- */
17172
- this.onFocus = (index) => (event) => {
17173
- var _a;
17174
- const { inputRefs } = this;
17175
- // Only emit ionFocus and set the focusedValue when the
17176
- // component first gains focus
17177
- if (!this.hasFocus) {
17178
- this.ionFocus.emit(event);
17179
- this.focusedValue = this.value;
17180
- }
17181
- this.hasFocus = true;
17182
- let finalIndex = index;
17183
- if (!this.isKeyboardNavigation) {
17184
- // If the clicked box has a value, focus it
17185
- // Otherwise focus the first empty box
17186
- const targetIndex = this.inputValues[index] ? index : this.getFirstEmptyIndex();
17187
- finalIndex = targetIndex === -1 ? this.length - 1 : targetIndex;
17188
- // Focus the target box
17189
- (_a = this.inputRefs[finalIndex]) === null || _a === void 0 ? void 0 : _a.focus();
17190
- }
17191
- // Update tabIndexes to match the focused box
17192
- inputRefs.forEach((input, i) => {
17193
- input.tabIndex = i === finalIndex ? 0 : -1;
17194
- });
17195
- // Reset the keyboard navigation flag
17196
- this.isKeyboardNavigation = false;
17197
- };
17198
- /**
17199
- * Handles the blur behavior for the input OTP component.
17200
- * Emits the `ionBlur` event when the input group loses focus.
17201
- */
17202
- this.onBlur = (event) => {
17203
- const { inputRefs } = this;
17204
- const relatedTarget = event.relatedTarget;
17205
- // Do not emit blur if we're moving to another input box in the same component
17206
- const isInternalFocus = relatedTarget != null && inputRefs.includes(relatedTarget);
17207
- if (!isInternalFocus) {
17208
- this.hasFocus = false;
17209
- // Reset tabIndexes when focus leaves the component
17210
- this.updateTabIndexes();
17211
- // Always emit ionBlur when focus leaves the component
17212
- this.ionBlur.emit(event);
17213
- // Only emit ionChange if the value has actually changed
17214
- if (this.focusedValue !== this.value) {
17215
- this.emitIonChange(event);
17216
- }
17217
- }
17218
- };
17219
+ }
17220
+ /**
17221
+ * Sets focus to an input box.
17222
+ * @param index - The index of the input box to focus (0-based).
17223
+ * If provided and the input box has a value, the input box at that index will be focused.
17224
+ * Otherwise, the first empty input box or the last input if all are filled will be focused.
17225
+ */
17226
+ async setFocus(index) {
17227
+ var _a, _b;
17228
+ if (typeof index === 'number') {
17229
+ const validIndex = Math.max(0, Math.min(index, this.length - 1));
17230
+ (_a = this.inputRefs[validIndex]) === null || _a === void 0 ? void 0 : _a.focus();
17231
+ }
17232
+ else {
17233
+ const tabbableIndex = this.getTabbableIndex();
17234
+ (_b = this.inputRefs[tabbableIndex]) === null || _b === void 0 ? void 0 : _b.focus();
17235
+ }
17219
17236
  }
17220
17237
  valueChanged() {
17221
17238
  this.initializeValues();
17239
+ this.updateTabIndexes();
17222
17240
  }
17223
17241
  /**
17224
17242
  * Processes the separators prop into an array of numbers.
@@ -17276,59 +17294,6 @@ class InputOTP {
17276
17294
  componentDidLoad() {
17277
17295
  this.updateTabIndexes();
17278
17296
  }
17279
- /**
17280
- * Initializes the input values array based on the current value prop.
17281
- * This splits the value into individual characters and validates them against
17282
- * the allowed pattern. The values are then used as the values in the native
17283
- * input boxes and the value of the input group is updated.
17284
- */
17285
- initializeValues() {
17286
- // Clear all input values
17287
- this.inputValues = Array(this.length).fill('');
17288
- // If the value is null, undefined, or an empty string, return
17289
- if (this.value == null || String(this.value).length === 0) {
17290
- return;
17291
- }
17292
- // Split the value into individual characters and validate
17293
- // them against the allowed pattern
17294
- const chars = String(this.value).split('').slice(0, this.length);
17295
- chars.forEach((char, index) => {
17296
- if (this.validKeyPattern.test(char)) {
17297
- this.inputValues[index] = char;
17298
- }
17299
- });
17300
- // Update the value without emitting events
17301
- this.value = this.inputValues.join('');
17302
- }
17303
- /**
17304
- * Resets the value and focus state.
17305
- */
17306
- async reset() {
17307
- this.value = '';
17308
- this.focusedValue = null;
17309
- this.hasFocus = false;
17310
- this.inputRefs.forEach((input) => {
17311
- input.blur();
17312
- });
17313
- this.updateTabIndexes();
17314
- }
17315
- /**
17316
- * Sets focus to an input box.
17317
- * @param index - The index of the input box to focus (0-based).
17318
- * If provided and the input box has a value, the input box at that index will be focused.
17319
- * Otherwise, the first empty input box or the last input if all are filled will be focused.
17320
- */
17321
- async setFocus(index) {
17322
- var _a, _b;
17323
- if (typeof index === 'number') {
17324
- const validIndex = Math.max(0, Math.min(index, this.length - 1));
17325
- (_a = this.inputRefs[validIndex]) === null || _a === void 0 ? void 0 : _a.focus();
17326
- }
17327
- else {
17328
- const tabbableIndex = this.getTabbableIndex();
17329
- (_b = this.inputRefs[tabbableIndex]) === null || _b === void 0 ? void 0 : _b.focus();
17330
- }
17331
- }
17332
17297
  /**
17333
17298
  * Get the regex pattern for allowed characters.
17334
17299
  * If a pattern is provided, use it to create a regex pattern
@@ -17365,6 +17330,30 @@ class InputOTP {
17365
17330
  return 'text';
17366
17331
  }
17367
17332
  }
17333
+ /**
17334
+ * Initializes the input values array based on the current value prop.
17335
+ * This splits the value into individual characters and validates them against
17336
+ * the allowed pattern. The values are then used as the values in the native
17337
+ * input boxes and the value of the input group is updated.
17338
+ */
17339
+ initializeValues() {
17340
+ // Clear all input values
17341
+ this.inputValues = Array(this.length).fill('');
17342
+ // If the value is null, undefined, or an empty string, return
17343
+ if (this.value == null || String(this.value).length === 0) {
17344
+ return;
17345
+ }
17346
+ // Split the value into individual characters and validate
17347
+ // them against the allowed pattern
17348
+ const chars = String(this.value).split('').slice(0, this.length);
17349
+ chars.forEach((char, index) => {
17350
+ if (this.validKeyPattern.test(char)) {
17351
+ this.inputValues[index] = char;
17352
+ }
17353
+ });
17354
+ // Update the value without emitting events
17355
+ this.value = this.inputValues.join('');
17356
+ }
17368
17357
  /**
17369
17358
  * Updates the value of the input group.
17370
17359
  * This updates the value of the input group and emits an `ionChange` event.
@@ -17378,7 +17367,6 @@ class InputOTP {
17378
17367
  if (newValue.length === length) {
17379
17368
  this.ionComplete.emit({ value: newValue });
17380
17369
  }
17381
- this.updateTabIndexes();
17382
17370
  }
17383
17371
  /**
17384
17372
  * Emits an `ionChange` event.
@@ -17423,12 +17411,27 @@ class InputOTP {
17423
17411
  }
17424
17412
  }
17425
17413
  /**
17426
- * Determines if a separator should be shown for a given index by
17427
- * checking if the index is included in the parsed separators array.
17414
+ * Searches through the input values and returns the index
17415
+ * of the first empty input.
17416
+ * Returns -1 if all inputs are filled.
17428
17417
  */
17429
- showSeparator(index) {
17418
+ getFirstEmptyIndex() {
17419
+ var _a;
17420
+ const { inputValues, length } = this;
17421
+ // Create an array of the same length as the input OTP
17422
+ // and fill it with the input values
17423
+ const values = Array.from({ length }, (_, i) => inputValues[i] || '');
17424
+ return (_a = values.findIndex((value) => !value || value === '')) !== null && _a !== void 0 ? _a : -1;
17425
+ }
17426
+ /**
17427
+ * Returns the index of the input that should be tabbed to.
17428
+ * If all inputs are filled, returns the last input's index.
17429
+ * Otherwise, returns the index of the first empty input.
17430
+ */
17431
+ getTabbableIndex() {
17430
17432
  const { length } = this;
17431
- return this.parsedSeparators.includes(index + 1) && index < length - 1;
17433
+ const firstEmptyIndex = this.getFirstEmptyIndex();
17434
+ return firstEmptyIndex === -1 ? length - 1 : firstEmptyIndex;
17432
17435
  }
17433
17436
  /**
17434
17437
  * Updates the tabIndexes for the input boxes.
@@ -17456,27 +17459,12 @@ class InputOTP {
17456
17459
  });
17457
17460
  }
17458
17461
  /**
17459
- * Searches through the input values and returns the index
17460
- * of the first empty input.
17461
- * Returns -1 if all inputs are filled.
17462
- */
17463
- getFirstEmptyIndex() {
17464
- var _a;
17465
- const { inputValues, length } = this;
17466
- // Create an array of the same length as the input OTP
17467
- // and fill it with the input values
17468
- const values = Array.from({ length }, (_, i) => inputValues[i] || '');
17469
- return (_a = values.findIndex((value) => !value || value === '')) !== null && _a !== void 0 ? _a : -1;
17470
- }
17471
- /**
17472
- * Returns the index of the input that should be tabbed to.
17473
- * If all inputs are filled, returns the last input's index.
17474
- * Otherwise, returns the index of the first empty input.
17462
+ * Determines if a separator should be shown for a given index by
17463
+ * checking if the index is included in the parsed separators array.
17475
17464
  */
17476
- getTabbableIndex() {
17465
+ showSeparator(index) {
17477
17466
  const { length } = this;
17478
- const firstEmptyIndex = this.getFirstEmptyIndex();
17479
- return firstEmptyIndex === -1 ? length - 1 : firstEmptyIndex;
17467
+ return this.parsedSeparators.includes(index + 1) && index < length - 1;
17480
17468
  }
17481
17469
  render() {
17482
17470
  var _a, _b;
@@ -17486,7 +17474,7 @@ class InputOTP {
17486
17474
  const tabbableIndex = this.getTabbableIndex();
17487
17475
  const pattern = this.getPattern();
17488
17476
  const hasDescription = ((_b = (_a = el.querySelector('.input-otp-description')) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== '';
17489
- return (hAsync(Host, { key: '973743fa99d77dbdaaf9b630b64180a189b5d778', class: createColorClasses$1(color, {
17477
+ return (hAsync(Host, { key: 'e87987e639fcff31612db32baa45ef928f1214fe', class: createColorClasses$1(color, {
17490
17478
  [mode]: true,
17491
17479
  'has-focus': hasFocus,
17492
17480
  [`input-otp-size-${size}`]: true,
@@ -17494,10 +17482,10 @@ class InputOTP {
17494
17482
  [`input-otp-fill-${fill}`]: true,
17495
17483
  'input-otp-disabled': disabled,
17496
17484
  'input-otp-readonly': readonly,
17497
- }) }, hAsync("div", Object.assign({ key: '3891cbdc07d4fa017ea04590bbb6225ab68deff2', role: "group", "aria-label": "One-time password input", class: "input-otp-group" }, inheritedAttributes), Array.from({ length }).map((_, index) => (hAsync(Fragment, null, hAsync("div", { class: "native-wrapper" }, hAsync("input", { class: "native-input", id: `${inputId}-${index}`, "aria-label": `Input ${index + 1} of ${length}`, type: "text", autoCapitalize: autocapitalize, inputmode: inputmode, maxLength: 1, pattern: pattern, disabled: disabled, readOnly: readonly, tabIndex: index === tabbableIndex ? 0 : -1, value: inputValues[index] || '', autocomplete: index === 0 ? 'one-time-code' : 'off', 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) && hAsync("div", { class: "input-otp-separator" }))))), hAsync("div", { key: '0d3cfa8c081552d0c52a544a1c52c0e3d5d4f532', class: {
17485
+ }) }, hAsync("div", Object.assign({ key: '10d82d5c21171e3673b337da472139e8c9e077d7', role: "group", "aria-label": "One-time password input", class: "input-otp-group" }, inheritedAttributes), Array.from({ length }).map((_, index) => (hAsync(Fragment, null, hAsync("div", { class: "native-wrapper" }, hAsync("input", { class: "native-input", id: `${inputId}-${index}`, "aria-label": `Input ${index + 1} of ${length}`, type: "text", autoCapitalize: autocapitalize, inputmode: inputmode, maxLength: 1, pattern: pattern, disabled: disabled, readOnly: readonly, tabIndex: index === tabbableIndex ? 0 : -1, value: inputValues[index] || '', autocomplete: index === 0 ? 'one-time-code' : 'off', 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) && hAsync("div", { class: "input-otp-separator" }))))), hAsync("div", { key: '3cbb5dd138c5640c71c51a5088ad1047a74d3ad6', class: {
17498
17486
  'input-otp-description': true,
17499
17487
  'input-otp-description-hidden': !hasDescription,
17500
- } }, hAsync("slot", { key: '13c3f795956749ccdf396bfb0ff882a9c9e9ce81' }))));
17488
+ } }, hAsync("slot", { key: '9fdeca4d1eebd60334a48b103229d43849bbb0ac' }))));
17501
17489
  }
17502
17490
  get el() { return getElement(this); }
17503
17491
  static get watchers() { return {
@@ -17521,14 +17509,13 @@ class InputOTP {
17521
17509
  "length": [2],
17522
17510
  "pattern": [1],
17523
17511
  "readonly": [516],
17524
- "size": [1],
17525
17512
  "separators": [1],
17526
17513
  "shape": [1],
17514
+ "size": [1],
17527
17515
  "type": [1],
17528
17516
  "value": [1032],
17529
17517
  "inputValues": [32],
17530
17518
  "hasFocus": [32],
17531
- "reset": [64],
17532
17519
  "setFocus": [64]
17533
17520
  },
17534
17521
  "$listeners$": undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionic/core",
3
- "version": "8.5.7-dev.11748379940.12698faf",
3
+ "version": "8.5.7-dev.11748545890.14d6a067",
4
4
  "description": "Base components for Ionic",
5
5
  "keywords": [
6
6
  "ionic",
@@ -1,4 +0,0 @@
1
- /*!
2
- * (C) Ionic http://ionicframework.com - MIT License
3
- */
4
- import{r as i,c as o,h as t,F as n,d as p,g as r}from"./p-3GtB1kQI.js";import{i as s}from"./p-CG4wBMWx.js";import{p as e}from"./p-CEo1SqXS.js";import{i as a}from"./p-C53feagD.js";import{c as l}from"./p-DiVJyqlX.js";import{b as d}from"./p-B7Khsp7D.js";const c=class{constructor(t){i(this,t),this.ionInput=o(this,"ionInput",7),this.ionChange=o(this,"ionChange",7),this.ionComplete=o(this,"ionComplete",7),this.ionBlur=o(this,"ionBlur",7),this.ionFocus=o(this,"ionFocus",7),this.inheritedAttributes={},this.inputRefs=[],this.inputId="ion-input-otp-"+u++,this.parsedSeparators=[],this.isKeyboardNavigation=!1,this.inputValues=[],this.hasFocus=!1,this.autocapitalize="off",this.disabled=!1,this.fill="outline",this.length=4,this.readonly=!1,this.size="medium",this.shape="round",this.type="number",this.value="",this.onInput=i=>o=>{const{validKeyPattern:t}=this,n=o.target.value;if(n.length>1||n.length>0&&!t.test(n))return this.inputRefs[i].value="",void(this.inputValues[i]="");let p=i;for(let o=0;o<i;o++)if(!this.inputValues[o]||""===this.inputValues[o]){p=o;break}this.inputValues[p]=n,p!==i&&(this.inputRefs[i].value=""),n.length>0&&this.focusNext(p),this.updateValue(o)},this.onKeyDown=i=>o=>{const{length:t}=this,n=a(this.el),p=o.target;if((!o.metaKey&&!o.ctrlKey||"v"!==o.key.toLowerCase())&&p.selectionStart===p.selectionEnd){if("Backspace"===o.key)if(this.inputValues[i]){for(let o=i;o<t-1;o++)this.inputValues[o]=this.inputValues[o+1];this.inputValues[t-1]="";for(let i=0;i<t;i++)this.inputRefs[i].value=this.inputValues[i]||"";this.updateValue(o),o.preventDefault()}else!this.inputValues[i]&&i>0&&this.focusPrevious(i);else if("ArrowLeft"===o.key||"ArrowRight"===o.key){this.isKeyboardNavigation=!0,o.preventDefault();const p="ArrowLeft"===o.key;p&&n||!p&&!n?this.inputValues[i]&&i<t-1&&this.focusNext(i):this.focusPrevious(i)}else if("Tab"===o.key)return void(this.isKeyboardNavigation=!0);if(this.inputValues[i]&&this.validKeyPattern.test(o.key)){if(!this.inputValues[t-1])for(let o=t-1;o>i;o--)this.inputValues[o]=this.inputValues[o-1],this.inputRefs[o].value=this.inputValues[o]||"";this.inputValues[i]=o.key,this.inputRefs[i].value=o.key,this.updateValue(o),o.preventDefault()}}},this.onPaste=i=>{var o,t,n;const{inputRefs:p,length:r,validKeyPattern:s}=this;i.preventDefault();const e=null===(o=i.clipboardData)||void 0===o?void 0:o.getData("text");if(!e)return void this.emitIonInput(i);const a=e.split("").filter((i=>s.test(i))).slice(0,r);a.forEach(((i,o)=>{o<r&&(this.inputRefs[o].value=i,this.inputValues[o]=i)})),this.value=a.join(""),this.updateValue(i);const l=a.length;l<r?null===(t=p[l])||void 0===t||t.focus():null===(n=p[r-1])||void 0===n||n.focus()},this.onFocus=i=>o=>{var t;const{inputRefs:n}=this;this.hasFocus||(this.ionFocus.emit(o),this.focusedValue=this.value),this.hasFocus=!0;let p=i;if(!this.isKeyboardNavigation){const o=this.inputValues[i]?i:this.getFirstEmptyIndex();p=-1===o?this.length-1:o,null===(t=this.inputRefs[p])||void 0===t||t.focus()}n.forEach(((i,o)=>{i.tabIndex=o===p?0:-1})),this.isKeyboardNavigation=!1},this.onBlur=i=>{const{inputRefs:o}=this,t=i.relatedTarget;null!=t&&o.includes(t)||(this.hasFocus=!1,this.updateTabIndexes(),this.ionBlur.emit(i),this.focusedValue!==this.value&&this.emitIonChange(i))}}valueChanged(){this.initializeValues()}processSeparators(){const{separators:i,length:o}=this;if(void 0===i)return void(this.parsedSeparators=[]);if("string"==typeof i&&"all"!==i&&!/^(\d+)(,\d+)*$/.test(i))return e(`[ion-input-otp] - Invalid separators format. Expected a comma-separated list of numbers, an array of numbers, or "all". Received: ${i}`,this.el),void(this.parsedSeparators=[]);let t;t="all"===i?Array.from({length:o-1},((i,o)=>o+1)):Array.isArray(i)?i:i.split(",").map((i=>parseInt(i,10))).filter((i=>!isNaN(i))),t.filter(((i,o)=>t.indexOf(i)!==o)).length>0&&e(`[ion-input-otp] - Duplicate separator positions are not allowed. Received: ${i}`,this.el);const n=t.filter((i=>i>o));n.length>0&&e(`[ion-input-otp] - The following separator positions are greater than the input length (${o}): ${n.join(", ")}. These separators will be ignored.`,this.el),this.parsedSeparators=t.filter((i=>i<=o))}componentWillLoad(){this.inheritedAttributes=s(this.el),this.processSeparators(),this.initializeValues()}componentDidLoad(){this.updateTabIndexes()}initializeValues(){this.inputValues=Array(this.length).fill(""),null!=this.value&&0!==String(this.value).length&&(String(this.value).split("").slice(0,this.length).forEach(((i,o)=>{this.validKeyPattern.test(i)&&(this.inputValues[o]=i)})),this.value=this.inputValues.join(""))}async reset(){this.value="",this.focusedValue=null,this.hasFocus=!1,this.inputRefs.forEach((i=>{i.blur()})),this.updateTabIndexes()}async setFocus(i){var o,t;if("number"==typeof i){const t=Math.max(0,Math.min(i,this.length-1));null===(o=this.inputRefs[t])||void 0===o||o.focus()}else{const i=this.getTabbableIndex();null===(t=this.inputRefs[i])||void 0===t||t.focus()}}get validKeyPattern(){return new RegExp(`^${this.getPattern()}$`,"u")}getPattern(){const{pattern:i,type:o}=this;return i||("number"===o?"[\\p{N}]":"[\\p{L}\\p{N}]")}getInputmode(){const{inputmode:i}=this;return i||("number"==this.type?"numeric":"text")}updateValue(i){const{inputValues:o,length:t}=this,n=o.join("");this.value=n,this.emitIonInput(i),n.length===t&&this.ionComplete.emit({value:n}),this.updateTabIndexes()}emitIonChange(i){const{value:o}=this,t=null==o?o:o.toString();this.ionChange.emit({value:t,event:i})}emitIonInput(i){const{value:o}=this,t=null==o?o:o.toString();this.ionInput.emit({value:t,event:i})}focusNext(i){var o;const{inputRefs:t,length:n}=this;i<n-1&&(null===(o=t[i+1])||void 0===o||o.focus())}focusPrevious(i){var o;const{inputRefs:t}=this;i>0&&(null===(o=t[i-1])||void 0===o||o.focus())}showSeparator(i){const{length:o}=this;return this.parsedSeparators.includes(i+1)&&i<o-1}updateTabIndexes(){const{inputRefs:i,inputValues:o,length:t}=this;let n=-1;for(let i=0;i<t;i++)if(!o[i]||""===o[i]){n=i;break}i.forEach(((i,p)=>{const r=-1===n?p===t-1:n===p;i.tabIndex=r?0:-1,i.setAttribute("aria-hidden",o[p]&&""!==o[p]||r?"false":"true")}))}getFirstEmptyIndex(){var i;const{inputValues:o,length:t}=this;return null!==(i=Array.from({length:t},((i,t)=>o[t]||"")).findIndex((i=>!i||""===i)))&&void 0!==i?i:-1}getTabbableIndex(){const{length:i}=this,o=this.getFirstEmptyIndex();return-1===o?i-1:o}render(){var i,o;const{autocapitalize:r,color:s,disabled:e,el:a,fill:c,hasFocus:u,inheritedAttributes:h,inputId:g,inputRefs:v,inputValues:m,length:f,readonly:b,shape:x,size:w}=this,k=d(this),y=this.getInputmode(),z=this.getTabbableIndex(),I=this.getPattern(),$=""!==(null===(o=null===(i=a.querySelector(".input-otp-description"))||void 0===i?void 0:i.textContent)||void 0===o?void 0:o.trim());return t(p,{key:"973743fa99d77dbdaaf9b630b64180a189b5d778",class:l(s,{[k]:!0,"has-focus":u,[`input-otp-size-${w}`]:!0,[`input-otp-shape-${x}`]:!0,[`input-otp-fill-${c}`]:!0,"input-otp-disabled":e,"input-otp-readonly":b})},t("div",Object.assign({key:"3891cbdc07d4fa017ea04590bbb6225ab68deff2",role:"group","aria-label":"One-time password input",class:"input-otp-group"},h),Array.from({length:f}).map(((i,o)=>t(n,null,t("div",{class:"native-wrapper"},t("input",{class:"native-input",id:`${g}-${o}`,"aria-label":`Input ${o+1} of ${f}`,type:"text",autoCapitalize:r,inputmode:y,maxLength:1,pattern:I,disabled:e,readOnly:b,tabIndex:o===z?0:-1,value:m[o]||"",autocomplete:0===o?"one-time-code":"off",ref:i=>v[o]=i,onInput:this.onInput(o),onBlur:this.onBlur,onFocus:this.onFocus(o),onKeyDown:this.onKeyDown(o),onPaste:this.onPaste})),this.showSeparator(o)&&t("div",{class:"input-otp-separator"}))))),t("div",{key:"0d3cfa8c081552d0c52a544a1c52c0e3d5d4f532",class:{"input-otp-description":!0,"input-otp-description-hidden":!$}},t("slot",{key:"13c3f795956749ccdf396bfb0ff882a9c9e9ce81"})))}get el(){return r(this)}static get watchers(){return{value:["valueChanged"],separators:["processSeparators"],length:["processSeparators"]}}};let u=0;c.style={ios:".sc-ion-input-otp-ios-h{--margin-top:0;--margin-end:0;--margin-bottom:0;--margin-start:0;--padding-top:16px;--padding-end:0;--padding-bottom:16px;--padding-start:0;--color:initial;--min-width:40px;--separator-width:8px;--separator-height:var(--separator-width);--separator-border-radius:999px;--separator-color:var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9));--highlight-color-focused:var(--ion-color-primary, #0054e9);--highlight-color-valid:var(--ion-color-success, #2dd55b);--highlight-color-invalid:var(--ion-color-danger, #c5000f);--highlight-color:var(--highlight-color-focused);display:block;position:relative;font-size:0.875rem}.input-otp-group.sc-ion-input-otp-ios{-webkit-margin-start:var(--margin-start);margin-inline-start:var(--margin-start);-webkit-margin-end:var(--margin-end);margin-inline-end:var(--margin-end);margin-top:var(--margin-top);margin-bottom:var(--margin-bottom);-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.native-wrapper.sc-ion-input-otp-ios{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-width:var(--min-width)}.native-input.sc-ion-input-otp-ios{border-radius:var(--border-radius);width:var(--width);min-width:inherit;height:var(--height);border-width:var(--border-width);border-style:solid;border-color:var(--border-color);background:var(--background);color:var(--color);font-size:inherit;text-align:center;-webkit-appearance:none;-moz-appearance:none;appearance:none}.has-focus.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios{caret-color:var(--highlight-color)}.input-otp-description.sc-ion-input-otp-ios{color:var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));font-size:0.75rem;line-height:1.25rem;text-align:center}.input-otp-description-hidden.sc-ion-input-otp-ios{display:none}.input-otp-separator.sc-ion-input-otp-ios{border-radius:var(--separator-border-radius);-ms-flex-negative:0;flex-shrink:0;width:var(--separator-width);height:var(--separator-height);background:var(--separator-color)}.input-otp-size-small.sc-ion-input-otp-ios-h{--width:40px;--height:40px}.input-otp-size-small.sc-ion-input-otp-ios-h .input-otp-group.sc-ion-input-otp-ios{gap:8px}.input-otp-size-medium.sc-ion-input-otp-ios-h{--width:48px;--height:48px}.input-otp-size-large.sc-ion-input-otp-ios-h{--width:56px;--height:56px}.input-otp-size-medium.sc-ion-input-otp-ios-h .input-otp-group.sc-ion-input-otp-ios,.input-otp-size-large.sc-ion-input-otp-ios-h .input-otp-group.sc-ion-input-otp-ios{gap:12px}.input-otp-shape-round.sc-ion-input-otp-ios-h{--border-radius:16px}.input-otp-shape-soft.sc-ion-input-otp-ios-h{--border-radius:8px}.input-otp-shape-rectangular.sc-ion-input-otp-ios-h{--border-radius:0}.input-otp-fill-outline.sc-ion-input-otp-ios-h{--background:none}.input-otp-fill-solid.sc-ion-input-otp-ios-h{--border-color:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));--background:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2))}.input-otp-disabled.sc-ion-input-otp-ios-h{--color:var(--ion-color-step-350, var(--ion-text-color-step-650, #a6a6a6))}.input-otp-fill-outline.input-otp-disabled.sc-ion-input-otp-ios-h{--background:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));--border-color:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6))}.input-otp-disabled.sc-ion-input-otp-ios-h,.input-otp-disabled.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios:disabled{cursor:not-allowed}.has-focus.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios:focus{--border-color:var(--highlight-color);outline:none}.input-otp-fill-outline.input-otp-readonly.sc-ion-input-otp-ios-h{--background:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2))}.input-otp-fill-solid.input-otp-disabled.sc-ion-input-otp-ios-h,.input-otp-fill-solid.input-otp-readonly.sc-ion-input-otp-ios-h{--border-color:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6));--background:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6))}.ion-touched.ion-invalid.sc-ion-input-otp-ios-h{--highlight-color:var(--highlight-color-invalid)}.ion-valid.sc-ion-input-otp-ios-h{--highlight-color:var(--highlight-color-valid)}.has-focus.ion-valid.sc-ion-input-otp-ios-h,.ion-touched.ion-invalid.sc-ion-input-otp-ios-h{--border-color:var(--highlight-color)}.ion-color.sc-ion-input-otp-ios-h{--highlight-color-focused:var(--ion-color-base)}.input-otp-fill-outline.ion-color.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-solid.ion-color.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios:focus{border-color:rgba(var(--ion-color-base-rgb), 0.6)}.input-otp-fill-outline.ion-color.ion-invalid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-solid.ion-color.ion-invalid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-outline.ion-color.has-focus.ion-invalid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-solid.ion-color.has-focus.ion-invalid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios{border-color:var(--ion-color-danger, #c5000f)}.input-otp-fill-outline.ion-color.ion-valid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-solid.ion-color.ion-valid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-outline.ion-color.has-focus.ion-valid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios,.input-otp-fill-solid.ion-color.has-focus.ion-valid.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios{border-color:var(--ion-color-success, #2dd55b)}.input-otp-fill-outline.input-otp-disabled.ion-color.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios{border-color:rgba(var(--ion-color-base-rgb), 0.3)}.sc-ion-input-otp-ios-h{--border-width:0.55px}.has-focus.sc-ion-input-otp-ios-h .native-input.sc-ion-input-otp-ios:focus{--border-width:1px}.input-otp-fill-outline.sc-ion-input-otp-ios-h{--border-color:var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-250, var(--ion-background-color-step-250, #c8c7cc))))}",md:".sc-ion-input-otp-md-h{--margin-top:0;--margin-end:0;--margin-bottom:0;--margin-start:0;--padding-top:16px;--padding-end:0;--padding-bottom:16px;--padding-start:0;--color:initial;--min-width:40px;--separator-width:8px;--separator-height:var(--separator-width);--separator-border-radius:999px;--separator-color:var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9));--highlight-color-focused:var(--ion-color-primary, #0054e9);--highlight-color-valid:var(--ion-color-success, #2dd55b);--highlight-color-invalid:var(--ion-color-danger, #c5000f);--highlight-color:var(--highlight-color-focused);display:block;position:relative;font-size:0.875rem}.input-otp-group.sc-ion-input-otp-md{-webkit-margin-start:var(--margin-start);margin-inline-start:var(--margin-start);-webkit-margin-end:var(--margin-end);margin-inline-end:var(--margin-end);margin-top:var(--margin-top);margin-bottom:var(--margin-bottom);-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.native-wrapper.sc-ion-input-otp-md{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-width:var(--min-width)}.native-input.sc-ion-input-otp-md{border-radius:var(--border-radius);width:var(--width);min-width:inherit;height:var(--height);border-width:var(--border-width);border-style:solid;border-color:var(--border-color);background:var(--background);color:var(--color);font-size:inherit;text-align:center;-webkit-appearance:none;-moz-appearance:none;appearance:none}.has-focus.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md{caret-color:var(--highlight-color)}.input-otp-description.sc-ion-input-otp-md{color:var(--ion-color-step-700, var(--ion-text-color-step-300, #4d4d4d));font-size:0.75rem;line-height:1.25rem;text-align:center}.input-otp-description-hidden.sc-ion-input-otp-md{display:none}.input-otp-separator.sc-ion-input-otp-md{border-radius:var(--separator-border-radius);-ms-flex-negative:0;flex-shrink:0;width:var(--separator-width);height:var(--separator-height);background:var(--separator-color)}.input-otp-size-small.sc-ion-input-otp-md-h{--width:40px;--height:40px}.input-otp-size-small.sc-ion-input-otp-md-h .input-otp-group.sc-ion-input-otp-md{gap:8px}.input-otp-size-medium.sc-ion-input-otp-md-h{--width:48px;--height:48px}.input-otp-size-large.sc-ion-input-otp-md-h{--width:56px;--height:56px}.input-otp-size-medium.sc-ion-input-otp-md-h .input-otp-group.sc-ion-input-otp-md,.input-otp-size-large.sc-ion-input-otp-md-h .input-otp-group.sc-ion-input-otp-md{gap:12px}.input-otp-shape-round.sc-ion-input-otp-md-h{--border-radius:16px}.input-otp-shape-soft.sc-ion-input-otp-md-h{--border-radius:8px}.input-otp-shape-rectangular.sc-ion-input-otp-md-h{--border-radius:0}.input-otp-fill-outline.sc-ion-input-otp-md-h{--background:none}.input-otp-fill-solid.sc-ion-input-otp-md-h{--border-color:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));--background:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2))}.input-otp-disabled.sc-ion-input-otp-md-h{--color:var(--ion-color-step-350, var(--ion-text-color-step-650, #a6a6a6))}.input-otp-fill-outline.input-otp-disabled.sc-ion-input-otp-md-h{--background:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2));--border-color:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6))}.input-otp-disabled.sc-ion-input-otp-md-h,.input-otp-disabled.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md:disabled{cursor:not-allowed}.has-focus.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md:focus{--border-color:var(--highlight-color);outline:none}.input-otp-fill-outline.input-otp-readonly.sc-ion-input-otp-md-h{--background:var(--ion-color-step-50, var(--ion-background-color-step-50, #f2f2f2))}.input-otp-fill-solid.input-otp-disabled.sc-ion-input-otp-md-h,.input-otp-fill-solid.input-otp-readonly.sc-ion-input-otp-md-h{--border-color:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6));--background:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6))}.ion-touched.ion-invalid.sc-ion-input-otp-md-h{--highlight-color:var(--highlight-color-invalid)}.ion-valid.sc-ion-input-otp-md-h{--highlight-color:var(--highlight-color-valid)}.has-focus.ion-valid.sc-ion-input-otp-md-h,.ion-touched.ion-invalid.sc-ion-input-otp-md-h{--border-color:var(--highlight-color)}.ion-color.sc-ion-input-otp-md-h{--highlight-color-focused:var(--ion-color-base)}.input-otp-fill-outline.ion-color.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-solid.ion-color.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md:focus{border-color:rgba(var(--ion-color-base-rgb), 0.6)}.input-otp-fill-outline.ion-color.ion-invalid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-solid.ion-color.ion-invalid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-outline.ion-color.has-focus.ion-invalid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-solid.ion-color.has-focus.ion-invalid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md{border-color:var(--ion-color-danger, #c5000f)}.input-otp-fill-outline.ion-color.ion-valid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-solid.ion-color.ion-valid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-outline.ion-color.has-focus.ion-valid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md,.input-otp-fill-solid.ion-color.has-focus.ion-valid.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md{border-color:var(--ion-color-success, #2dd55b)}.input-otp-fill-outline.input-otp-disabled.ion-color.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md{border-color:rgba(var(--ion-color-base-rgb), 0.3)}.sc-ion-input-otp-md-h{--border-width:1px}.has-focus.sc-ion-input-otp-md-h .native-input.sc-ion-input-otp-md:focus{--border-width:2px}.input-otp-fill-outline.sc-ion-input-otp-md-h{--border-color:var(--ion-color-step-300, var(--ion-background-color-step-300, #b3b3b3))}"};export{c as ion_input_otp}