/**
 *
 * Mask is a directive used to enter input in a certain format such as numeric, date, currency, email and phone.
 *
 * [Live Demo](https://primevue.dev/mask)
 *
 * @module mask
 *
 */
import type { DesignToken, PassThrough } from '@primevue/core';
import type { DirectiveHooks } from '@primevue/core/basedirective';
import type { PassThroughOptions } from 'primevue/passthrough';
import { DirectiveBinding, ObjectDirective } from 'vue';

export declare type MaskDirectivePassThroughOptionType = MaskDirectivePassThroughAttributes | null | undefined;

/**
 * Payload passed to the {@link MaskOptions.onChange} callback.
 */
export interface MaskChangeEvent {
    /**
     * The formatted value including the mask characters.
     */
    value: string;
    /**
     * The raw value without the mask formatting characters.
     */
    rawValue: string;
}

/**
 * Defines options of Mask.
 */
export interface MaskOptions {
    /**
     * Mask pattern.
     */
    mask?: string | undefined;
    /**
     * Placeholder character in the mask, default is underscore.
     * @defaultValue _
     */
    slotChar?: string | undefined;
    /**
     * Clears the incomplete value on blur.
     * @defaultValue true
     */
    autoClear?: boolean | undefined;
    /**
     * Defines if the directive emits the raw unmasked value or the formatted mask value through v-model.
     * @defaultValue false
     */
    unmask?: boolean | undefined;
    /**
     * Callback invoked on every value change, receiving both the masked and the raw (unmasked) values.
     * @param {MaskChangeEvent} event - Object holding the masked and raw values.
     */
    onChange?: (event: MaskChangeEvent) => void;
    /**
     * It generates scoped CSS variables using design tokens for the component.
     */
    dt?: DesignToken<any>;
    /**
     * Used to pass attributes to DOM elements inside the component.
     * @type {MaskDirectivePassThroughOptions}
     */
    pt?: PassThrough<MaskDirectivePassThroughOptions>;
    /**
     * 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;
}

/**
 * Custom passthrough(pt) options.
 * @see {@link MaskOptions.pt}
 */
export interface MaskDirectivePassThroughOptions {
    /**
     * Used to pass attributes to the root's DOM element.
     */
    root?: MaskDirectivePassThroughOptionType;
    /**
     * Used to manage all lifecycle hooks.
     * @see {@link BaseDirective.DirectiveHooks}
     */
    hooks?: DirectiveHooks;
}

/**
 * Custom passthrough attributes for each DOM elements
 */
export interface MaskDirectivePassThroughAttributes {
    [key: string]: any;
}

/**
 * Binding of Mask directive.
 */
export interface MaskDirectiveBinding extends Omit<DirectiveBinding, 'value'> {
    /**
     * Value of the Mask directive. Either a mask pattern string or a full options object.
     */
    value?: string | MaskOptions | undefined;
}

/**
 * **PrimeVue - Mask**
 *
 * _Mask is a directive used to enter input in a certain format such as numeric, date, currency, email and phone._
 *
 * [Live Demo](https://www.primevue.dev/mask/)
 * --- ---
 * ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
 *
 */
declare const Mask: ObjectDirective;

export default Mask;
