2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
*
|
2024-02-22 08:52:39 +00:00
|
|
|
* InputOtp is used to enter one time passwords.
|
2024-02-21 18:38:16 +00:00
|
|
|
*
|
2024-02-22 08:52:39 +00:00
|
|
|
* [Live Demo](https://www.primevue.org/inputotp/)
|
2024-02-21 18:38:16 +00:00
|
|
|
*
|
|
|
|
* @module inputotp
|
|
|
|
*
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
import { VNode } from 'vue';
|
2024-04-24 22:43:32 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2024-02-22 08:52:39 +00:00
|
|
|
import { InputTextPassThroughOptions } from '../inputtext';
|
2024-02-21 18:38:16 +00:00
|
|
|
import { PassThroughOptions } from '../passthrough';
|
2024-04-02 08:24:31 +00:00
|
|
|
import { ClassComponent, DesignToken, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
|
2024-02-21 18:38:16 +00:00
|
|
|
|
2024-02-22 08:52:39 +00:00
|
|
|
export declare type InputOtpPassThroughOptionType = InputOtpPassThroughAttributes | ((options: InputOtpPassThroughMethodOptions) => InputOtpPassThroughAttributes | string) | string | null | undefined;
|
2024-02-21 18:38:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpPassThroughMethodOptions {
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Defines instance.
|
|
|
|
*/
|
|
|
|
instance: any;
|
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
props: InputOtpProps;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
state: InputOtpState;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Defines valid attributes.
|
|
|
|
*/
|
|
|
|
attrs: any;
|
|
|
|
/**
|
|
|
|
* Defines passthrough(pt) options in global config.
|
|
|
|
*/
|
|
|
|
global: object | undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Custom shared passthrough(pt) option method.
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpSharedPassThroughMethodOptions {
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Defines valid properties.
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
props: InputOtpProps;
|
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
|
|
|
state: InputOtpState;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link InputOtpProps.pt}
|
|
|
|
*/
|
|
|
|
export interface InputOtpPassThroughOptions {
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
root?: InputOtpPassThroughOptionType;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Used to pass attributes to the InputText component.
|
|
|
|
* @see {@link InputTextPassThroughOptions}
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcInput?: InputTextPassThroughOptions<InputOtpSharedPassThroughMethodOptions>;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Used to manage all lifecycle hooks.
|
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpPassThroughAttributes {
|
2024-02-21 18:38:16 +00:00
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Defines current inline state in InputOtp component.
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpState {
|
|
|
|
/**
|
|
|
|
* Array of input tokens
|
|
|
|
*/
|
|
|
|
tokens: string[] | number[];
|
2024-02-21 18:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* InputOtp attr options
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpTemplateAttrsOptions {
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Input token value
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
value: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* InputOtp templating events
|
|
|
|
*/
|
|
|
|
export interface InputOtpTemplateEvents {
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Input event
|
|
|
|
* @param {Event} event - Browser event
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
input: (event: Event) => void;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Keydown event
|
|
|
|
* @param {Event} event - Browser event
|
|
|
|
*/
|
|
|
|
keydown: (event: Event) => void;
|
|
|
|
/**
|
|
|
|
* Focus event
|
|
|
|
* @param {Event} event - Browser event
|
|
|
|
*/
|
|
|
|
focus: (event: Event) => void;
|
|
|
|
/**
|
|
|
|
* Blur event
|
|
|
|
* @param {Event} event - Browser event
|
|
|
|
*/
|
|
|
|
blur: (event: Event) => void;
|
|
|
|
/**
|
|
|
|
* Paste event
|
|
|
|
* @param {Event} event - Browser event
|
|
|
|
*/
|
|
|
|
paste: (event: Event) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines valid properties in InputOtp component.
|
|
|
|
*/
|
|
|
|
export interface InputOtpProps {
|
|
|
|
/**
|
|
|
|
* Specifies whether a inputotp should be checked or not.
|
2024-02-21 18:38:16 +00:00
|
|
|
* @defaultValue false
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
modelValue?: boolean | string | undefined;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* When present, it specifies that the component should have invalid state style.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
invalid?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* When present, it specifies that the component should be disabled.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
disabled?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* When present, it specifies that an input field is read-only.
|
2024-02-22 08:52:39 +00:00
|
|
|
* @defaultValue false
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
|
|
|
readonly?: boolean | undefined;
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Specifies the input variant of the component.
|
|
|
|
* @defaultValue outlined
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
variant?: 'outlined' | 'filled' | undefined;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Index of the element in tabbing order.
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
tabindex?: number | undefined;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Number of characters to initiate.
|
|
|
|
* @defaultValue 4
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
length?: number | undefined;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Mask pattern.
|
|
|
|
* @defaultValue false
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
mask?: boolean | undefined;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* When present, it specifies that an input field is integer-only.
|
|
|
|
* @defaultValue false
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
integerOnly?: boolean | undefined;
|
2024-04-02 08:24:31 +00:00
|
|
|
/**
|
|
|
|
* It generates scoped CSS variables using design tokens for the component.
|
|
|
|
*/
|
|
|
|
dt?: DesignToken<any>;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2024-02-22 08:52:39 +00:00
|
|
|
* @type {InputOtpPassThroughOptions}
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
pt?: PassThrough<InputOtpPassThroughOptions>;
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Used to configure passthrough(pt) options of the component.
|
|
|
|
* @type {PassThroughOptions}
|
|
|
|
*/
|
|
|
|
ptOptions?: PassThroughOptions;
|
|
|
|
/**
|
|
|
|
* When enabled, it removes component related styles in the core.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
unstyled?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
*
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpSlots {
|
|
|
|
/**
|
|
|
|
* Default content slot.
|
|
|
|
*/
|
|
|
|
default(scope: {
|
|
|
|
/**
|
|
|
|
* Events of the component
|
|
|
|
* @param {number} index - Index of the input field
|
|
|
|
* @return {InputOtpTemplateEvents}
|
|
|
|
*/
|
|
|
|
events: (index: number) => InputOtpTemplateEvents;
|
|
|
|
/**
|
|
|
|
* Attributes of the component
|
|
|
|
* @param {number} index - Index of the input field
|
|
|
|
* @return {InputOtpTemplateAttrsOptions}
|
|
|
|
*/
|
|
|
|
attrs: (index: number) => InputOtpTemplateAttrsOptions;
|
|
|
|
/**
|
|
|
|
* Index of the input field
|
|
|
|
*/
|
|
|
|
index: number;
|
|
|
|
}): VNode[];
|
2024-02-21 18:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* Defines valid emits in InputOtp component.
|
2024-02-21 18:38:16 +00:00
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
export interface InputOtpEmits {
|
2024-02-21 18:38:16 +00:00
|
|
|
/**
|
|
|
|
* Emitted when the value changes.
|
|
|
|
* @param {boolean} value - New value.
|
|
|
|
*/
|
|
|
|
'update:modelValue'(value: boolean): void;
|
|
|
|
/**
|
|
|
|
* Callback to invoke on value change.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
|
|
|
change(event: Event): void;
|
|
|
|
/**
|
|
|
|
* Callback to invoke when the component receives focus.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
|
|
|
focus(event: Event): void;
|
|
|
|
/**
|
|
|
|
* Callback to invoke when the component loses focus.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
|
|
|
blur(event: Event): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-22 08:52:39 +00:00
|
|
|
* **PrimeVue - InputOtp**
|
2024-02-21 18:38:16 +00:00
|
|
|
*
|
2024-02-22 08:52:39 +00:00
|
|
|
* _InputOtp is used to enter one time passwords._
|
2024-02-21 18:38:16 +00:00
|
|
|
*
|
2024-02-22 08:52:39 +00:00
|
|
|
* [Live Demo](https://www.primevue.org/inputotp/)
|
2024-02-21 18:38:16 +00:00
|
|
|
* --- ---
|
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*
|
|
|
|
*/
|
2024-02-22 08:52:39 +00:00
|
|
|
declare class InputOtp extends ClassComponent<InputOtpProps, InputOtpSlots, InputOtpEmits> {}
|
2024-02-21 18:38:16 +00:00
|
|
|
|
2024-03-14 22:58:11 +00:00
|
|
|
declare module 'vue' {
|
|
|
|
export interface GlobalComponents {
|
2024-02-22 08:52:39 +00:00
|
|
|
InputOtp: GlobalComponentConstructor<InputOtp>;
|
2024-02-21 18:38:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-22 08:52:39 +00:00
|
|
|
export default InputOtp;
|