ngx-json-ui
Version:
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
53 lines (52 loc) • 2.81 kB
TypeScript
import { ElementRef } from '@angular/core';
import * as i0 from "@angular/core";
export declare class ConstrainedNumberDirective {
private el;
/** decimal places to allow; if unset → integer‐only */
precision: number | undefined;
/** allow a leading minus? */
allowNegative: boolean;
/** clamp these on blur */
min?: number;
max?: number;
greater?: number;
less?: number;
constructor(el: ElementRef<HTMLInputElement>);
/**
*
* @returns RegExp
* Builds a regular expression pattern based on the precision and constraints provided.
* The pattern allows for optional negative sign, digits, and decimal part based on the precision.
* The decimal part is optional and can have a maximum number of digits defined by the precision.
* The pattern is used to validate the input value in the onKeydown and onPaste methods.
*/
private buildPattern;
/**
*
* @param e KeyboardEvent
* Handles keydown events on the input element. It prevents invalid keystrokes based on the defined pattern.
* The method allows navigation keys, backspace, delete, and copy/paste operations.
* It checks if the new value after the keystroke matches the pattern. If not, it prevents the default action.
* @returns
*/
onKeydown(e: KeyboardEvent): void;
/**
*
* @param e ClipboardEvent
* Handles paste events on the input element. It prevents pasting invalid values based on the defined pattern.
* The method checks if the pasted value, when combined with the current value of the input, matches the pattern.
* If not, it prevents the paste action.
*
*/
onPaste(e: ClipboardEvent): void;
/**
* Handles blur events on the input element. It validates the input value and clamps it within the defined min/max range.
* It also ensures that the value is greater than the defined greater constraint and less than the defined less constraint.
* If the value is NaN or doesn't meet the constraints, it sets the input value to an empty string.
* * The method is called when the input loses focus, ensuring that the value is valid before further processing.
* @returns void
*/
onBlur(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<ConstrainedNumberDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ConstrainedNumberDirective, "[appConstrainedNumber]", never, { "precision": { "alias": "precision"; "required": false; }; "allowNegative": { "alias": "allowNegative"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "greater": { "alias": "greater"; "required": false; }; "less": { "alias": "less"; "required": false; }; }, {}, never, never, false, never>;
}