vira
Version:
A simple and highly versatile design system using element-vir.
62 lines (61 loc) • 2.21 kB
TypeScript
import { type AttributeValues } from 'element-vir';
/**
* Inputs shared between the multiple input elements.
*
* @category Internal
*/
export type SharedTextInputElementInputs = {
value: string;
/** Shown when no other text is present. Input restrictions do not apply to this property. */
placeholder?: string;
/** Set to true to trigger disabled styles and to block all user input. */
disabled?: boolean;
/**
* Only letters in the given string or matches to the given RegExp will be allowed.
* blockedInputs takes precedence over this input.
*
* For example: if allowedInputs is set to "abcd" and blockedInputs is set to "d", only "a",
* "b", or "c" letters will be allowed.
*/
allowedInputs?: string | RegExp;
/** Any letters in the given string or matches to the given RegExp will be blocked. */
blockedInputs?: string | RegExp;
/** Disable all browser helps like spellchecking, autocomplete, etc. */
disableBrowserHelps?: boolean;
/** Set this to true to make the whole element size to only fit the input text. */
fitText?: boolean;
/** A set of attributes that will be applied to the inner native text element. */
attributePassthrough?: AttributeValues | undefined;
};
/**
* Inputs used to check if the current input element value is allowed.
*
* @category Internal
*/
export type IsAllowedInputs = {
value: string;
allowed: string | RegExp | undefined;
blocked: string | RegExp | undefined;
};
/**
* Filters out blocked text from an input element's value.
*
* @category Internal
*/
export declare function filterTextInputValue(inputs: IsAllowedInputs): {
filtered: string;
blocked: string;
};
/**
* A function to be called when an input element's value changes.
*
* @category Internal
*/
export declare function textInputListener({ inputs, previousValue, event, inputBlockedCallback, newValueCallback, }: {
inputs: SharedTextInputElementInputs;
/** The value of the input element before this listener fired. */
previousValue: string;
event: Event;
inputBlockedCallback: (blockedInput: string) => void;
newValueCallback: (newValue: string) => void;
}): void;