@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.
- package/dist/cjs/{fade-NeUskjyB.js → fade-DBKqk3wh.js} +1 -1
- package/dist/cjs/{fullscreen-D5cgtwoy.js → fullscreen-lcdCtrG6.js} +1 -1
- package/dist/cjs/index-DGttnXif.js +4 -0
- package/dist/cjs/{lazyload-Dm1NcTJ1.js → lazyload-BjSSEx9f.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-avatar_5.cjs.entry.js +7 -7
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/nano-datalist_3.cjs.entry.js +4 -0
- package/dist/cjs/nano-icon-button_2.cjs.entry.js +2 -2
- package/dist/cjs/nano-input-otp.cjs.entry.js +710 -0
- package/dist/cjs/nano-intersection-observe.cjs.entry.js +1 -1
- package/dist/cjs/nano-masked-overflow.cjs.entry.js +3 -3
- package/dist/cjs/nano-menu-drawer.cjs.entry.js +2 -2
- package/dist/cjs/nano-more-less.cjs.entry.js +2 -2
- package/dist/cjs/nano-rating.cjs.entry.js +4 -4
- package/dist/cjs/nano-resize-observe.cjs.entry.js +2 -2
- package/dist/cjs/nano-slide.cjs.entry.js +1 -1
- package/dist/cjs/{nano-slides-ycRcUf0g.js → nano-slides-CryCLfsK.js} +7 -7
- package/dist/cjs/nano-slides.cjs.entry.js +1 -1
- package/dist/cjs/nano-sortable.cjs.entry.js +1 -1
- package/dist/cjs/nano-step-accordion.cjs.entry.js +1 -1
- package/dist/cjs/nano-step-breadcrumb.cjs.entry.js +2 -2
- package/dist/cjs/nano-sticker.cjs.entry.js +2 -2
- package/dist/cjs/nano-tab-content.cjs.entry.js +2 -2
- package/dist/cjs/nano-tab.cjs.entry.js +2 -2
- package/dist/cjs/nano-table.cjs.entry.js +2 -2
- package/dist/cjs/{page-dots--38yVfTZ.js → page-dots-DR1fLjRi.js} +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/collection/components/input-otp/input-otp-interface.js +1 -0
- package/dist/collection/components/input-otp/input-otp.css +184 -0
- package/dist/collection/components/input-otp/input-otp.js +1044 -0
- package/dist/collection/components/intersection-observe/intersection-observe.js +1 -1
- package/dist/collection/components/masked-overflow/masked-overflow.js +3 -3
- package/dist/collection/components/menu-drawer/menu-drawer.js +2 -2
- package/dist/collection/components/more-less/more-less.js +2 -2
- package/dist/collection/components/rating/rating.js +4 -4
- package/dist/collection/components/resize-observe/resize-observe.js +2 -2
- package/dist/collection/components/select/select.js +7 -7
- package/dist/collection/components/slides/slide.js +1 -1
- package/dist/collection/components/slides/slides.js +3 -3
- package/dist/collection/components/sortable/sortable.js +1 -1
- package/dist/collection/components/step-accordion/step-accordion.js +1 -1
- package/dist/collection/components/step-breadcrumb/step-breadcrumb.js +2 -2
- package/dist/collection/components/sticker/sticker.js +2 -2
- package/dist/collection/components/table/table.js +2 -2
- package/dist/collection/components/tabs/tab-content.js +2 -2
- package/dist/collection/components/tabs/tab.js +2 -2
- package/dist/collection/components/tag/tag.js +24 -0
- package/dist/collection/components/tooltip/tooltip.js +2 -2
- package/dist/components/masked-overflow.js +3 -3
- package/dist/components/nano-input-otp.d.ts +11 -0
- package/dist/components/nano-input-otp.js +749 -0
- package/dist/components/nano-intersection-observe.js +1 -1
- package/dist/components/nano-menu-drawer.js +2 -2
- package/dist/components/nano-more-less.js +2 -2
- package/dist/components/nano-rating.js +4 -4
- package/dist/components/nano-slide.js +1 -1
- package/dist/components/nano-sortable.js +1 -1
- package/dist/components/nano-step-accordion.js +1 -1
- package/dist/components/nano-step-breadcrumb.js +2 -2
- package/dist/components/nano-tab-content.js +2 -2
- package/dist/components/nano-tab.js +2 -2
- package/dist/components/nano-table.js +2 -2
- package/dist/components/resize-observe.js +2 -2
- package/dist/components/select.js +7 -7
- package/dist/components/slides.js +3 -3
- package/dist/components/sticker.js +2 -2
- package/dist/components/tag.js +6 -1
- package/dist/components/tooltip.js +2 -2
- package/dist/esm/{fade-BA6b-Fk9.js → fade-D980mOvm.js} +1 -1
- package/dist/esm/{fullscreen-De_yN4cg.js → fullscreen-CjInlYb9.js} +1 -1
- package/dist/esm/index-BM3Om9WE.js +4 -0
- package/dist/esm/{lazyload-Cl8k3tPs.js → lazyload-B9B4e3ZI.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-avatar_5.entry.js +7 -7
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/nano-datalist_3.entry.js +4 -0
- package/dist/esm/nano-icon-button_2.entry.js +2 -2
- package/dist/esm/nano-input-otp.entry.js +708 -0
- package/dist/esm/nano-intersection-observe.entry.js +1 -1
- package/dist/esm/nano-masked-overflow.entry.js +3 -3
- package/dist/esm/nano-menu-drawer.entry.js +2 -2
- package/dist/esm/nano-more-less.entry.js +2 -2
- package/dist/esm/nano-rating.entry.js +4 -4
- package/dist/esm/nano-resize-observe.entry.js +2 -2
- package/dist/esm/nano-slide.entry.js +1 -1
- package/dist/esm/{nano-slides-GrbOydfa.js → nano-slides-xbY6lXX9.js} +7 -7
- package/dist/esm/nano-slides.entry.js +1 -1
- package/dist/esm/nano-sortable.entry.js +1 -1
- package/dist/esm/nano-step-accordion.entry.js +1 -1
- package/dist/esm/nano-step-breadcrumb.entry.js +2 -2
- package/dist/esm/nano-sticker.entry.js +2 -2
- package/dist/esm/nano-tab-content.entry.js +2 -2
- package/dist/esm/nano-tab.entry.js +2 -2
- package/dist/esm/nano-table.entry.js +2 -2
- package/dist/esm/{page-dots-CSf81OuJ.js → page-dots-CCfERISy.js} +1 -1
- package/dist/nano-components/{fade-BA6b-Fk9.js → fade-D980mOvm.js} +1 -1
- package/dist/nano-components/{fullscreen-De_yN4cg.js → fullscreen-CjInlYb9.js} +1 -1
- package/dist/nano-components/lazyload-B9B4e3ZI.js +4 -0
- package/dist/nano-components/nano-avatar_5.entry.js +1 -1
- package/dist/nano-components/nano-components.css +1 -1
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-datalist_3.entry.js +1 -1
- package/dist/nano-components/nano-icon-button_2.entry.js +1 -1
- package/dist/nano-components/nano-input-otp.entry.js +4 -0
- package/dist/nano-components/nano-intersection-observe.entry.js +1 -1
- package/dist/nano-components/nano-masked-overflow.entry.js +1 -1
- package/dist/nano-components/nano-menu-drawer.entry.js +1 -1
- package/dist/nano-components/nano-more-less.entry.js +1 -1
- package/dist/nano-components/nano-rating.entry.js +1 -1
- package/dist/nano-components/nano-resize-observe.entry.js +1 -1
- package/dist/nano-components/nano-slide.entry.js +1 -1
- package/dist/nano-components/{nano-slides-GrbOydfa.js → nano-slides-xbY6lXX9.js} +3 -3
- package/dist/nano-components/nano-slides.entry.js +1 -1
- package/dist/nano-components/nano-sortable.entry.js +1 -1
- package/dist/nano-components/nano-step-accordion.entry.js +1 -1
- package/dist/nano-components/nano-step-breadcrumb.entry.js +1 -1
- package/dist/nano-components/nano-sticker.entry.js +1 -1
- package/dist/nano-components/nano-tab-content.entry.js +1 -1
- package/dist/nano-components/nano-tab.entry.js +1 -1
- package/dist/nano-components/nano-table.entry.js +1 -1
- package/dist/nano-components/{page-dots-CSf81OuJ.js → page-dots-CCfERISy.js} +1 -1
- package/dist/style/components.css +1 -1
- package/dist/style/components.css.map +1 -1
- package/dist/style/nano.css +1 -1
- package/dist/style/nano.css.map +1 -1
- package/dist/types/components/input-otp/input-otp-interface.d.ts +24 -0
- package/dist/types/components/input-otp/input-otp.d.ts +281 -0
- package/dist/types/components/tag/tag.d.ts +4 -0
- package/dist/types/components.d.ts +189 -0
- package/docs-json.json +824 -183
- package/docs-vscode.json +83 -0
- package/hydrate/index.js +786 -45
- package/hydrate/index.mjs +786 -45
- package/package.json +2 -2
- package/dist/nano-components/lazyload-Cl8k3tPs.js +0 -4
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/generate-vue-component.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/index.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/output-vue.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/plugin.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/types.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/utils.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/stencil.config.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/stencil.config.prod.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/testing/mocks/intersection-observer.d.ts +0 -0
- /package/dist/types/builds/{QrfEi4pt → HitvqeWT}/0/Digital/nano-components/packages/components/.stencil/wdio.conf.d.ts +0 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Values are converted to strings when emitted which is
|
3
|
+
* why we do not have a `number` type here even though the
|
4
|
+
* `value` prop accepts a `number` type.
|
5
|
+
*/
|
6
|
+
export interface InputOtpInputEventDetail {
|
7
|
+
value?: string | null;
|
8
|
+
valid?: boolean;
|
9
|
+
event?: Event;
|
10
|
+
}
|
11
|
+
export interface InputOtpChangeEventDetail {
|
12
|
+
value?: string | null;
|
13
|
+
valid?: boolean;
|
14
|
+
event?: Event;
|
15
|
+
}
|
16
|
+
export interface InputOtpCompleteEventDetail {
|
17
|
+
value?: string | null;
|
18
|
+
valid?: boolean;
|
19
|
+
event?: Event;
|
20
|
+
}
|
21
|
+
export interface InputOtpCustomEvent<T = InputOtpChangeEventDetail> extends CustomEvent {
|
22
|
+
detail: T;
|
23
|
+
target: HTMLNanoInputOtpElement;
|
24
|
+
}
|
@@ -0,0 +1,281 @@
|
|
1
|
+
import type { ComponentInterface, EventEmitter } from '../../stencil-public-runtime';
|
2
|
+
import type { InputOtpChangeEventDetail, InputOtpCompleteEventDetail, InputOtpInputEventDetail } from './input-otp-interface.js';
|
3
|
+
/**
|
4
|
+
* A component for entering one-time passwords (OTP) with multiple input fields.
|
5
|
+
*
|
6
|
+
* @version 8.7.2
|
7
|
+
* @status new
|
8
|
+
*
|
9
|
+
* @slot - The default slot for the input description.
|
10
|
+
* @slot validity-icon - A slot for a custom validity icon. If not provided, a default icon will be used.
|
11
|
+
*/
|
12
|
+
export declare class InputOTP implements ComponentInterface {
|
13
|
+
private inputRefs;
|
14
|
+
private inputId;
|
15
|
+
/**
|
16
|
+
* Stores the initial value of the input when it receives focus.
|
17
|
+
* Used to determine if the value changed during the focus session
|
18
|
+
* to avoid emitting unnecessary change events on blur.
|
19
|
+
*/
|
20
|
+
private focusedValue?;
|
21
|
+
/**
|
22
|
+
* Tracks whether the user is navigating through input boxes using keyboard navigation
|
23
|
+
* (arrow keys, tab) versus mouse clicks. This is used to determine the appropriate
|
24
|
+
* focus behavior when an input box is focused.
|
25
|
+
*/
|
26
|
+
private isKeyboardNavigation;
|
27
|
+
el: HTMLNanoInputOtpElement;
|
28
|
+
private inputValues;
|
29
|
+
hasFocus: boolean;
|
30
|
+
private previousInputValues;
|
31
|
+
private invalid;
|
32
|
+
private valid;
|
33
|
+
/**
|
34
|
+
* If `true`, the user cannot interact with the input.
|
35
|
+
*/
|
36
|
+
disabled: boolean;
|
37
|
+
/**
|
38
|
+
* A hint to the browser for which keyboard to display.
|
39
|
+
* Possible values: `"none"`, `"text"`, `"tel"`, `"url"`,
|
40
|
+
* `"email"`, `"numeric"`, `"decimal"`, and `"search"`.
|
41
|
+
*
|
42
|
+
* For numbers (type="number"): "numeric"
|
43
|
+
* For text (type="text"): "text"
|
44
|
+
*/
|
45
|
+
inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
|
46
|
+
/**
|
47
|
+
* The number of input boxes to display.
|
48
|
+
*/
|
49
|
+
length: number;
|
50
|
+
/**
|
51
|
+
* A regex pattern string for allowed characters. Defaults based on type.
|
52
|
+
*
|
53
|
+
* For numbers (`type="number"`): `"[\p{N}]"`
|
54
|
+
* For text (`type="text"`): `"[\p{L}\p{N}]"`
|
55
|
+
*/
|
56
|
+
pattern?: string;
|
57
|
+
/**
|
58
|
+
* If `true`, the user cannot modify the value.
|
59
|
+
*/
|
60
|
+
readonly: boolean;
|
61
|
+
/**
|
62
|
+
* The type of input allowed in the input boxes.
|
63
|
+
*/
|
64
|
+
type: 'text' | 'number';
|
65
|
+
/**
|
66
|
+
* The value of the input group.
|
67
|
+
*/
|
68
|
+
value?: string | number | null;
|
69
|
+
/**
|
70
|
+
* If `true`, allows the input to be completely filled with invalid values.
|
71
|
+
* By default, if any input box contains an invalid value, the entire input group
|
72
|
+
* is marked as invalid.
|
73
|
+
* Default is `false`.
|
74
|
+
*/
|
75
|
+
allowInvalid: boolean;
|
76
|
+
/**
|
77
|
+
* If `true`, shows a validity icon when all input boxes are filled.
|
78
|
+
* A check icon is shown if all values are valid, and an X icon is shown if any value is invalid.
|
79
|
+
* This does not affect the `invalid` or `valid` states of the input group.
|
80
|
+
* Default is `false`.
|
81
|
+
* */
|
82
|
+
showValidity: boolean;
|
83
|
+
/**
|
84
|
+
* The `nanoInput` event is fired each time the user modifies the input's value.
|
85
|
+
* Unlike the `nanoChange` event, the `nanoInput` event is fired for each alteration
|
86
|
+
* to the input's value. This typically happens for each keystroke as the user types.
|
87
|
+
*
|
88
|
+
* For elements that accept text input (`type=text`, `type=tel`, etc.), the interface
|
89
|
+
* is [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent); for others,
|
90
|
+
* the interface is [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). If
|
91
|
+
* the input is cleared on edit, the type is `null`.
|
92
|
+
*/
|
93
|
+
nanoInput: EventEmitter<InputOtpInputEventDetail>;
|
94
|
+
/**
|
95
|
+
* The `nanoChange` event is fired when the user modifies the input's value.
|
96
|
+
* Unlike the `nanoInput` event, the `nanoChange` event is only fired when changes
|
97
|
+
* are committed, not as the user types.
|
98
|
+
*
|
99
|
+
* The `nanoChange` event fires when the `<nano-input-otp>` component loses
|
100
|
+
* focus after its value has changed.
|
101
|
+
*
|
102
|
+
* This event will not emit when programmatically setting the `value` property.
|
103
|
+
*/
|
104
|
+
nanoChange: EventEmitter<InputOtpChangeEventDetail>;
|
105
|
+
/**
|
106
|
+
* Emitted when all input boxes have been filled with valid values.
|
107
|
+
*/
|
108
|
+
nanoComplete: EventEmitter<InputOtpCompleteEventDetail>;
|
109
|
+
/**
|
110
|
+
* Emitted when the input group loses focus.
|
111
|
+
*/
|
112
|
+
nanoBlur: EventEmitter<FocusEvent>;
|
113
|
+
/**
|
114
|
+
* Emitted when the input group has focus.
|
115
|
+
*/
|
116
|
+
nanoFocus: EventEmitter<FocusEvent>;
|
117
|
+
/**
|
118
|
+
* Sets focus to an input box.
|
119
|
+
* @param index - The index of the input box to focus (0-based).
|
120
|
+
* If provided and the input box has a value, the input box at that index will be focused.
|
121
|
+
* Otherwise, the first empty input box or the last input if all are filled will be focused.
|
122
|
+
*/
|
123
|
+
setFocus(index?: number): Promise<void>;
|
124
|
+
valueChanged(): void;
|
125
|
+
componentWillLoad(): void;
|
126
|
+
componentDidLoad(): void;
|
127
|
+
/**
|
128
|
+
* Get the regex pattern for allowed characters.
|
129
|
+
* If a pattern is provided, use it to create a regex pattern
|
130
|
+
* Otherwise, use the default regex pattern based on type
|
131
|
+
*/
|
132
|
+
private get validKeyPattern();
|
133
|
+
private get specialCharsPattern();
|
134
|
+
/**
|
135
|
+
* Gets the string pattern to pass to the input element
|
136
|
+
* and use in the regex for allowed characters.
|
137
|
+
* @returns {string} The regex pattern string for allowed characters.
|
138
|
+
*/
|
139
|
+
private getPattern;
|
140
|
+
/**
|
141
|
+
* Get the default value for inputmode.
|
142
|
+
* If inputmode is provided, use it.
|
143
|
+
* Otherwise, use the default inputmode based on type
|
144
|
+
* @returns {string} The inputmode to use for the input boxes.
|
145
|
+
*/
|
146
|
+
private getInputmode;
|
147
|
+
/**
|
148
|
+
* Initializes the input values array based on the current value prop.
|
149
|
+
* This splits the value into individual characters and validates them against
|
150
|
+
* the allowed pattern. The values are then used as the values in the native
|
151
|
+
* input boxes and the value of the input group is updated.
|
152
|
+
*/
|
153
|
+
private initializeValues;
|
154
|
+
/**
|
155
|
+
* Returns `true` if the document or host element
|
156
|
+
* has a `dir` set to `rtl`. The host value will always
|
157
|
+
* take priority over the root document value.
|
158
|
+
* @returns {boolean} True if RTL direction is set, false otherwise.
|
159
|
+
*/
|
160
|
+
private isRTL;
|
161
|
+
/**
|
162
|
+
* Updates the value of the input group.
|
163
|
+
* This updates the value of the input group and emits an `nanoChange` event.
|
164
|
+
* If all of the input boxes are filled, it emits an `nanoComplete` event.
|
165
|
+
*/
|
166
|
+
private updateValue;
|
167
|
+
/**
|
168
|
+
* Emits an `nanoChange` event.
|
169
|
+
* This API should be called for user committed changes.
|
170
|
+
* This API should not be used for external value changes.
|
171
|
+
*/
|
172
|
+
private emitNanoChange;
|
173
|
+
/**
|
174
|
+
* Emits an `nanoInput` event.
|
175
|
+
* This is used to emit the input value when the user types,
|
176
|
+
* backspaces, or pastes.
|
177
|
+
*/
|
178
|
+
private emitNanoInput;
|
179
|
+
/**
|
180
|
+
* Handles the focus behavior for the input OTP component.
|
181
|
+
*
|
182
|
+
* Focus behavior:
|
183
|
+
* 1. Keyboard navigation: Allow normal focus movement
|
184
|
+
* 2. Mouse click:
|
185
|
+
* - If clicked box has value: Focus that box
|
186
|
+
* - If clicked box is empty: Focus first empty box
|
187
|
+
*
|
188
|
+
* Emits the `nanoFocus` event when the input group gains focus.
|
189
|
+
* @returns {(event: FocusEvent) => void} Event handler for focus events.
|
190
|
+
*/
|
191
|
+
private onFocus;
|
192
|
+
/**
|
193
|
+
* Handles the blur behavior for the input OTP component.
|
194
|
+
* Emits the `nanoBlur` event when the input group loses focus.
|
195
|
+
*/
|
196
|
+
private onBlur;
|
197
|
+
/**
|
198
|
+
* Focuses the next input box.
|
199
|
+
*/
|
200
|
+
private focusNext;
|
201
|
+
/**
|
202
|
+
* Focuses the previous input box.
|
203
|
+
*/
|
204
|
+
private focusPrevious;
|
205
|
+
/**
|
206
|
+
* Searches through the input values and returns the index
|
207
|
+
* of the first empty input.
|
208
|
+
* Returns -1 if all inputs are filled.
|
209
|
+
* @returns {number} The index of the first empty input, or -1 if all are filled.
|
210
|
+
*/
|
211
|
+
private getFirstEmptyIndex;
|
212
|
+
/**
|
213
|
+
* Returns the index of the input that should be tabbed to.
|
214
|
+
* If all inputs are filled, returns the last input's index.
|
215
|
+
* Otherwise, returns the index of the first empty input.
|
216
|
+
* @returns {number} The index to tab to.
|
217
|
+
*/
|
218
|
+
private getTabbableIndex;
|
219
|
+
/**
|
220
|
+
* Updates the tabIndexes for the input boxes.
|
221
|
+
* This is used to ensure that the correct input is
|
222
|
+
* focused when the user navigates using the tab key.
|
223
|
+
*/
|
224
|
+
private updateTabIndexes;
|
225
|
+
/**
|
226
|
+
* Handles keyboard navigation for the OTP component.
|
227
|
+
*
|
228
|
+
* Navigation:
|
229
|
+
* - Backspace: Clears current input and moves to previous box if empty
|
230
|
+
* - Arrow Left/Right: Moves focus between input boxes
|
231
|
+
* - Tab: Allows normal tab navigation between components
|
232
|
+
* @returns {(event: KeyboardEvent) => void} Event handler for keydown events.
|
233
|
+
*/
|
234
|
+
private onKeyDown;
|
235
|
+
/**
|
236
|
+
* Processes all input scenarios for each input box.
|
237
|
+
*
|
238
|
+
* This function manages:
|
239
|
+
* 1. Autofill handling
|
240
|
+
* 2. Input validation
|
241
|
+
* 3. Full selection replacement or typing in an empty box
|
242
|
+
* 4. Inserting in the middle with available space (shifting)
|
243
|
+
* 5. Single character replacement
|
244
|
+
* @returns {(event: InputEvent) => void} Event handler for input events.
|
245
|
+
*/
|
246
|
+
private onInput;
|
247
|
+
/**
|
248
|
+
* Handles pasting text into the input OTP component.
|
249
|
+
* This function prevents the default paste behavior and
|
250
|
+
* validates the pasted text against the allowed pattern.
|
251
|
+
* It then updates the value of the input group and focuses
|
252
|
+
* the next empty input after pasting.
|
253
|
+
*/
|
254
|
+
private onPaste;
|
255
|
+
/**
|
256
|
+
* Determines if a separator should be shown for a given index by:
|
257
|
+
* - Checking if the total length is even (no separator for odd lengths)
|
258
|
+
* - If even, showing a separator after the middle index
|
259
|
+
*
|
260
|
+
* @param index - The index to check for a separator.
|
261
|
+
* @returns {boolean} True if a separator should be shown after the given index, false otherwise.
|
262
|
+
*/
|
263
|
+
private showSeparator;
|
264
|
+
/**
|
265
|
+
* Filters the input string to only include valid characters based on the
|
266
|
+
* `validKeyPattern` regex. If `allowInvalid` is true, it will also
|
267
|
+
* exclude special characters. The resulting array is sliced to the
|
268
|
+
* maximum length of the input OTP.
|
269
|
+
* @param str - The input string to filter.
|
270
|
+
* @returns {string[]} An array of valid characters.
|
271
|
+
*/
|
272
|
+
private getValidChars;
|
273
|
+
/**
|
274
|
+
* Computes the validity of the input group based on the current input values.
|
275
|
+
* Sets the following `invalid` and `valid` states:
|
276
|
+
* - `invalid` is true if `allowInvalid` is true and any input value is invalid.
|
277
|
+
* - `valid` is true if all input boxes are filled with valid values.
|
278
|
+
*/
|
279
|
+
private computeValidity;
|
280
|
+
render(): any;
|
281
|
+
}
|
@@ -17,6 +17,10 @@ export declare class NanoTag {
|
|
17
17
|
* The size of the tag.
|
18
18
|
*/
|
19
19
|
size?: 'regular' | 'large';
|
20
|
+
/**
|
21
|
+
* If true, the tag will have a different background color.
|
22
|
+
*/
|
23
|
+
selected?: boolean;
|
20
24
|
el: HTMLNanoTagElement;
|
21
25
|
/**
|
22
26
|
* Fires when close button is clicked
|
@@ -26,6 +26,7 @@ import { FileInputChangeEventDetail, FileWithUrl } from "./components/file-uploa
|
|
26
26
|
import { AlgoliaNetworkError, MyAccountData } from "./components/global-nav/global-nav-interface";
|
27
27
|
import { NanoDatePicker } from "./components/date-picker/date-picker";
|
28
28
|
import { InputChangeEventDetail } from "./components/input/input-interface";
|
29
|
+
import { InputOtpChangeEventDetail, InputOtpCompleteEventDetail, InputOtpInputEventDetail } from "./components/input-otp/input-otp-interface.js";
|
29
30
|
import { NavItemEventDetail } from "./components/nav-item/nav-item-interface";
|
30
31
|
import { RangeChangeEventDetail, RangeValue } from "./components/range/range-interface";
|
31
32
|
import { ResizeStateChangeEventDetail } from "./components/resize-observe/resize-observe-interface";
|
@@ -52,6 +53,7 @@ export { FileInputChangeEventDetail, FileWithUrl } from "./components/file-uploa
|
|
52
53
|
export { AlgoliaNetworkError, MyAccountData } from "./components/global-nav/global-nav-interface";
|
53
54
|
export { NanoDatePicker } from "./components/date-picker/date-picker";
|
54
55
|
export { InputChangeEventDetail } from "./components/input/input-interface";
|
56
|
+
export { InputOtpChangeEventDetail, InputOtpCompleteEventDetail, InputOtpInputEventDetail } from "./components/input-otp/input-otp-interface.js";
|
55
57
|
export { NavItemEventDetail } from "./components/nav-item/nav-item-interface";
|
56
58
|
export { RangeChangeEventDetail, RangeValue } from "./components/range/range-interface";
|
57
59
|
export { ResizeStateChangeEventDetail } from "./components/resize-observe/resize-observe-interface";
|
@@ -2183,6 +2185,68 @@ export namespace Components {
|
|
2183
2185
|
*/
|
2184
2186
|
"valueAsNumber": number;
|
2185
2187
|
}
|
2188
|
+
/**
|
2189
|
+
* A component for entering one-time passwords (OTP) with multiple input fields.
|
2190
|
+
* @version 8.7.2
|
2191
|
+
* @status new
|
2192
|
+
*/
|
2193
|
+
interface NanoInputOtp {
|
2194
|
+
/**
|
2195
|
+
* If `true`, allows the input to be completely filled with invalid values. By default, if any input box contains an invalid value, the entire input group is marked as invalid. Default is `false`.
|
2196
|
+
* @default false
|
2197
|
+
*/
|
2198
|
+
"allowInvalid": boolean;
|
2199
|
+
/**
|
2200
|
+
* If `true`, the user cannot interact with the input.
|
2201
|
+
* @default false
|
2202
|
+
*/
|
2203
|
+
"disabled": boolean;
|
2204
|
+
/**
|
2205
|
+
* A hint to the browser for which keyboard to display. Possible values: `"none"`, `"text"`, `"tel"`, `"url"`, `"email"`, `"numeric"`, `"decimal"`, and `"search"`. For numbers (type="number"): "numeric" For text (type="text"): "text"
|
2206
|
+
*/
|
2207
|
+
"inputmode"?: | 'none'
|
2208
|
+
| 'text'
|
2209
|
+
| 'tel'
|
2210
|
+
| 'url'
|
2211
|
+
| 'email'
|
2212
|
+
| 'numeric'
|
2213
|
+
| 'decimal'
|
2214
|
+
| 'search';
|
2215
|
+
/**
|
2216
|
+
* The number of input boxes to display.
|
2217
|
+
* @default 6
|
2218
|
+
*/
|
2219
|
+
"length": number;
|
2220
|
+
/**
|
2221
|
+
* A regex pattern string for allowed characters. Defaults based on type. For numbers (`type="number"`): `"[\p{N}]"` For text (`type="text"`): `"[\p{L}\p{N}]"`
|
2222
|
+
*/
|
2223
|
+
"pattern"?: string;
|
2224
|
+
/**
|
2225
|
+
* If `true`, the user cannot modify the value.
|
2226
|
+
* @default false
|
2227
|
+
*/
|
2228
|
+
"readonly": boolean;
|
2229
|
+
/**
|
2230
|
+
* Sets focus to an input box.
|
2231
|
+
* @param index - The index of the input box to focus (0-based). If provided and the input box has a value, the input box at that index will be focused. Otherwise, the first empty input box or the last input if all are filled will be focused.
|
2232
|
+
*/
|
2233
|
+
"setFocus": (index?: number) => Promise<void>;
|
2234
|
+
/**
|
2235
|
+
* If `true`, shows a validity icon when all input boxes are filled. A check icon is shown if all values are valid, and an X icon is shown if any value is invalid. This does not affect the `invalid` or `valid` states of the input group. Default is `false`.
|
2236
|
+
* @default false
|
2237
|
+
*/
|
2238
|
+
"showValidity": boolean;
|
2239
|
+
/**
|
2240
|
+
* The type of input allowed in the input boxes.
|
2241
|
+
* @default 'number'
|
2242
|
+
*/
|
2243
|
+
"type": 'text' | 'number';
|
2244
|
+
/**
|
2245
|
+
* The value of the input group.
|
2246
|
+
* @default ''
|
2247
|
+
*/
|
2248
|
+
"value"?: string | number | null;
|
2249
|
+
}
|
2186
2250
|
/**
|
2187
2251
|
* A thin, declarative interface to the [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver).
|
2188
2252
|
* @version 6.0.0
|
@@ -3329,6 +3393,11 @@ export namespace Components {
|
|
3329
3393
|
* @default false
|
3330
3394
|
*/
|
3331
3395
|
"closable"?: boolean;
|
3396
|
+
/**
|
3397
|
+
* If true, the tag will have a different background color.
|
3398
|
+
* @default false
|
3399
|
+
*/
|
3400
|
+
"selected"?: boolean;
|
3332
3401
|
/**
|
3333
3402
|
* The size of the tag.
|
3334
3403
|
* @default 'regular'
|
@@ -3502,6 +3571,10 @@ export interface NanoInputCustomEvent<T> extends CustomEvent<T> {
|
|
3502
3571
|
detail: T;
|
3503
3572
|
target: HTMLNanoInputElement;
|
3504
3573
|
}
|
3574
|
+
export interface NanoInputOtpCustomEvent<T> extends CustomEvent<T> {
|
3575
|
+
detail: T;
|
3576
|
+
target: HTMLNanoInputOtpElement;
|
3577
|
+
}
|
3505
3578
|
export interface NanoIntersectionObserveCustomEvent<T> extends CustomEvent<T> {
|
3506
3579
|
detail: T;
|
3507
3580
|
target: HTMLNanoIntersectionObserveElement;
|
@@ -4391,6 +4464,32 @@ declare global {
|
|
4391
4464
|
prototype: HTMLNanoInputElement;
|
4392
4465
|
new (): HTMLNanoInputElement;
|
4393
4466
|
};
|
4467
|
+
interface HTMLNanoInputOtpElementEventMap {
|
4468
|
+
"nanoInput": InputOtpInputEventDetail;
|
4469
|
+
"nanoChange": InputOtpChangeEventDetail;
|
4470
|
+
"nanoComplete": InputOtpCompleteEventDetail;
|
4471
|
+
"nanoBlur": FocusEvent;
|
4472
|
+
"nanoFocus": FocusEvent;
|
4473
|
+
}
|
4474
|
+
/**
|
4475
|
+
* A component for entering one-time passwords (OTP) with multiple input fields.
|
4476
|
+
* @version 8.7.2
|
4477
|
+
* @status new
|
4478
|
+
*/
|
4479
|
+
interface HTMLNanoInputOtpElement extends Components.NanoInputOtp, HTMLStencilElement {
|
4480
|
+
addEventListener<K extends keyof HTMLNanoInputOtpElementEventMap>(type: K, listener: (this: HTMLNanoInputOtpElement, ev: NanoInputOtpCustomEvent<HTMLNanoInputOtpElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
4481
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
4482
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
4483
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
4484
|
+
removeEventListener<K extends keyof HTMLNanoInputOtpElementEventMap>(type: K, listener: (this: HTMLNanoInputOtpElement, ev: NanoInputOtpCustomEvent<HTMLNanoInputOtpElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
|
4485
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
4486
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
4487
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
4488
|
+
}
|
4489
|
+
var HTMLNanoInputOtpElement: {
|
4490
|
+
prototype: HTMLNanoInputOtpElement;
|
4491
|
+
new (): HTMLNanoInputOtpElement;
|
4492
|
+
};
|
4394
4493
|
interface HTMLNanoIntersectionObserveElementEventMap {
|
4395
4494
|
"nanoIntersectionChange": IntersectionObserverEntry;
|
4396
4495
|
"nanoIntersecting": IntersectionObserverEntry;
|
@@ -4999,6 +5098,7 @@ declare global {
|
|
4999
5098
|
"nano-in-page-nav": HTMLNanoInPageNavElement;
|
5000
5099
|
"nano-increment": HTMLNanoIncrementElement;
|
5001
5100
|
"nano-input": HTMLNanoInputElement;
|
5101
|
+
"nano-input-otp": HTMLNanoInputOtpElement;
|
5002
5102
|
"nano-intersection-observe": HTMLNanoIntersectionObserveElement;
|
5003
5103
|
"nano-masked-overflow": HTMLNanoMaskedOverflowElement;
|
5004
5104
|
"nano-menu": HTMLNanoMenuElement;
|
@@ -7241,6 +7341,83 @@ declare namespace LocalJSX {
|
|
7241
7341
|
*/
|
7242
7342
|
"valueAsNumber"?: number;
|
7243
7343
|
}
|
7344
|
+
/**
|
7345
|
+
* A component for entering one-time passwords (OTP) with multiple input fields.
|
7346
|
+
* @version 8.7.2
|
7347
|
+
* @status new
|
7348
|
+
*/
|
7349
|
+
interface NanoInputOtp {
|
7350
|
+
/**
|
7351
|
+
* If `true`, allows the input to be completely filled with invalid values. By default, if any input box contains an invalid value, the entire input group is marked as invalid. Default is `false`.
|
7352
|
+
* @default false
|
7353
|
+
*/
|
7354
|
+
"allowInvalid"?: boolean;
|
7355
|
+
/**
|
7356
|
+
* If `true`, the user cannot interact with the input.
|
7357
|
+
* @default false
|
7358
|
+
*/
|
7359
|
+
"disabled"?: boolean;
|
7360
|
+
/**
|
7361
|
+
* A hint to the browser for which keyboard to display. Possible values: `"none"`, `"text"`, `"tel"`, `"url"`, `"email"`, `"numeric"`, `"decimal"`, and `"search"`. For numbers (type="number"): "numeric" For text (type="text"): "text"
|
7362
|
+
*/
|
7363
|
+
"inputmode"?: | 'none'
|
7364
|
+
| 'text'
|
7365
|
+
| 'tel'
|
7366
|
+
| 'url'
|
7367
|
+
| 'email'
|
7368
|
+
| 'numeric'
|
7369
|
+
| 'decimal'
|
7370
|
+
| 'search';
|
7371
|
+
/**
|
7372
|
+
* The number of input boxes to display.
|
7373
|
+
* @default 6
|
7374
|
+
*/
|
7375
|
+
"length"?: number;
|
7376
|
+
/**
|
7377
|
+
* Emitted when the input group loses focus.
|
7378
|
+
*/
|
7379
|
+
"onNanoBlur"?: (event: NanoInputOtpCustomEvent<FocusEvent>) => void;
|
7380
|
+
/**
|
7381
|
+
* The `nanoChange` event is fired when the user modifies the input's value. Unlike the `nanoInput` event, the `nanoChange` event is only fired when changes are committed, not as the user types. The `nanoChange` event fires when the `<nano-input-otp>` component loses focus after its value has changed. This event will not emit when programmatically setting the `value` property.
|
7382
|
+
*/
|
7383
|
+
"onNanoChange"?: (event: NanoInputOtpCustomEvent<InputOtpChangeEventDetail>) => void;
|
7384
|
+
/**
|
7385
|
+
* Emitted when all input boxes have been filled with valid values.
|
7386
|
+
*/
|
7387
|
+
"onNanoComplete"?: (event: NanoInputOtpCustomEvent<InputOtpCompleteEventDetail>) => void;
|
7388
|
+
/**
|
7389
|
+
* Emitted when the input group has focus.
|
7390
|
+
*/
|
7391
|
+
"onNanoFocus"?: (event: NanoInputOtpCustomEvent<FocusEvent>) => void;
|
7392
|
+
/**
|
7393
|
+
* The `nanoInput` event is fired each time the user modifies the input's value. Unlike the `nanoChange` event, the `nanoInput` event is fired for each alteration to the input's value. This typically happens for each keystroke as the user types. For elements that accept text input (`type=text`, `type=tel`, etc.), the interface is [`InputEvent`](https://developer.mozilla.org/en-US/docs/Web/API/InputEvent); for others, the interface is [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). If the input is cleared on edit, the type is `null`.
|
7394
|
+
*/
|
7395
|
+
"onNanoInput"?: (event: NanoInputOtpCustomEvent<InputOtpInputEventDetail>) => void;
|
7396
|
+
/**
|
7397
|
+
* A regex pattern string for allowed characters. Defaults based on type. For numbers (`type="number"`): `"[\p{N}]"` For text (`type="text"`): `"[\p{L}\p{N}]"`
|
7398
|
+
*/
|
7399
|
+
"pattern"?: string;
|
7400
|
+
/**
|
7401
|
+
* If `true`, the user cannot modify the value.
|
7402
|
+
* @default false
|
7403
|
+
*/
|
7404
|
+
"readonly"?: boolean;
|
7405
|
+
/**
|
7406
|
+
* If `true`, shows a validity icon when all input boxes are filled. A check icon is shown if all values are valid, and an X icon is shown if any value is invalid. This does not affect the `invalid` or `valid` states of the input group. Default is `false`.
|
7407
|
+
* @default false
|
7408
|
+
*/
|
7409
|
+
"showValidity"?: boolean;
|
7410
|
+
/**
|
7411
|
+
* The type of input allowed in the input boxes.
|
7412
|
+
* @default 'number'
|
7413
|
+
*/
|
7414
|
+
"type"?: 'text' | 'number';
|
7415
|
+
/**
|
7416
|
+
* The value of the input group.
|
7417
|
+
* @default ''
|
7418
|
+
*/
|
7419
|
+
"value"?: string | number | null;
|
7420
|
+
}
|
7244
7421
|
/**
|
7245
7422
|
* A thin, declarative interface to the [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver).
|
7246
7423
|
* @version 6.0.0
|
@@ -8440,6 +8617,11 @@ declare namespace LocalJSX {
|
|
8440
8617
|
* Fires when close button is clicked
|
8441
8618
|
*/
|
8442
8619
|
"onNanoClose"?: (event: NanoTagCustomEvent<any>) => void;
|
8620
|
+
/**
|
8621
|
+
* If true, the tag will have a different background color.
|
8622
|
+
* @default false
|
8623
|
+
*/
|
8624
|
+
"selected"?: boolean;
|
8443
8625
|
/**
|
8444
8626
|
* The size of the tag.
|
8445
8627
|
* @default 'regular'
|
@@ -8562,6 +8744,7 @@ declare namespace LocalJSX {
|
|
8562
8744
|
"nano-in-page-nav": NanoInPageNav;
|
8563
8745
|
"nano-increment": NanoIncrement;
|
8564
8746
|
"nano-input": NanoInput;
|
8747
|
+
"nano-input-otp": NanoInputOtp;
|
8565
8748
|
"nano-intersection-observe": NanoIntersectionObserve;
|
8566
8749
|
"nano-masked-overflow": NanoMaskedOverflow;
|
8567
8750
|
"nano-menu": NanoMenu;
|
@@ -8852,6 +9035,12 @@ declare module "@stencil/core" {
|
|
8852
9035
|
* @version 1.0.0
|
8853
9036
|
*/
|
8854
9037
|
"nano-input": LocalJSX.NanoInput & JSXBase.HTMLAttributes<HTMLNanoInputElement>;
|
9038
|
+
/**
|
9039
|
+
* A component for entering one-time passwords (OTP) with multiple input fields.
|
9040
|
+
* @version 8.7.2
|
9041
|
+
* @status new
|
9042
|
+
*/
|
9043
|
+
"nano-input-otp": LocalJSX.NanoInputOtp & JSXBase.HTMLAttributes<HTMLNanoInputOtpElement>;
|
8855
9044
|
/**
|
8856
9045
|
* A thin, declarative interface to the [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver).
|
8857
9046
|
* @version 6.0.0
|