@maskito/core
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -146,3 +146,3 @@ 'use strict'; | ||
for (let i = validatedValuePart.length; i < mask.length; i++) { | ||
const charConstraint = mask[i]; | ||
const charConstraint = mask[i] || ''; | ||
const isInitiallyExisted = (initialElementState === null || initialElementState === void 0 ? void 0 : initialElementState.value[i]) === charConstraint; | ||
@@ -162,3 +162,3 @@ if (!isFixedCharacter(charConstraint) || | ||
Array.from(value).every((char, i) => { | ||
const charConstraint = maskExpression[i]; | ||
const charConstraint = maskExpression[i] || ''; | ||
return isFixedCharacter(charConstraint) | ||
@@ -178,3 +178,3 @@ ? char === charConstraint | ||
const newValidatedChars = validatedCharacters + leadingCharacters; | ||
const charConstraint = mask[newValidatedChars.length]; | ||
const charConstraint = mask[newValidatedChars.length] || ''; | ||
if (isFixedCharacter(charConstraint)) { | ||
@@ -240,3 +240,3 @@ return newValidatedChars + charConstraint; | ||
const unmaskedValue = Array.from(initialElementState.value).reduce((rawValue, char, i) => { | ||
const charConstraint = mask[i]; | ||
const charConstraint = mask[i] || ''; | ||
if (i === from) { | ||
@@ -272,3 +272,3 @@ selection.push(rawValue.length); | ||
addCharacters([from, to], newCharacters) { | ||
const { value } = this; | ||
const { value, maskOptions } = this; | ||
const maskExpression = this.getMaskExpression({ | ||
@@ -280,3 +280,3 @@ value: value.slice(0, from) + newCharacters + value.slice(to), | ||
const unmaskedElementState = removeFixedMaskCharacters(initialElementState, maskExpression); | ||
const [unmaskedFrom, unmaskedTo] = applyOverwriteMode(unmaskedElementState, newCharacters, this.maskOptions.overwriteMode).selection; | ||
const [unmaskedFrom, unmaskedTo] = applyOverwriteMode(unmaskedElementState, newCharacters, maskOptions.overwriteMode).selection; | ||
const newUnmaskedLeadingValuePart = unmaskedElementState.value.slice(0, unmaskedFrom) + newCharacters; | ||
@@ -283,0 +283,0 @@ const newCaretIndex = newUnmaskedLeadingValuePart.length; |
@@ -144,3 +144,3 @@ function getContentEditableSelection(element) { | ||
for (let i = validatedValuePart.length; i < mask.length; i++) { | ||
const charConstraint = mask[i]; | ||
const charConstraint = mask[i] || ''; | ||
const isInitiallyExisted = (initialElementState === null || initialElementState === void 0 ? void 0 : initialElementState.value[i]) === charConstraint; | ||
@@ -160,3 +160,3 @@ if (!isFixedCharacter(charConstraint) || | ||
Array.from(value).every((char, i) => { | ||
const charConstraint = maskExpression[i]; | ||
const charConstraint = maskExpression[i] || ''; | ||
return isFixedCharacter(charConstraint) | ||
@@ -176,3 +176,3 @@ ? char === charConstraint | ||
const newValidatedChars = validatedCharacters + leadingCharacters; | ||
const charConstraint = mask[newValidatedChars.length]; | ||
const charConstraint = mask[newValidatedChars.length] || ''; | ||
if (isFixedCharacter(charConstraint)) { | ||
@@ -238,3 +238,3 @@ return newValidatedChars + charConstraint; | ||
const unmaskedValue = Array.from(initialElementState.value).reduce((rawValue, char, i) => { | ||
const charConstraint = mask[i]; | ||
const charConstraint = mask[i] || ''; | ||
if (i === from) { | ||
@@ -270,3 +270,3 @@ selection.push(rawValue.length); | ||
addCharacters([from, to], newCharacters) { | ||
const { value } = this; | ||
const { value, maskOptions } = this; | ||
const maskExpression = this.getMaskExpression({ | ||
@@ -278,3 +278,3 @@ value: value.slice(0, from) + newCharacters + value.slice(to), | ||
const unmaskedElementState = removeFixedMaskCharacters(initialElementState, maskExpression); | ||
const [unmaskedFrom, unmaskedTo] = applyOverwriteMode(unmaskedElementState, newCharacters, this.maskOptions.overwriteMode).selection; | ||
const [unmaskedFrom, unmaskedTo] = applyOverwriteMode(unmaskedElementState, newCharacters, maskOptions.overwriteMode).selection; | ||
const newUnmaskedLeadingValuePart = unmaskedElementState.value.slice(0, unmaskedFrom) + newCharacters; | ||
@@ -281,0 +281,0 @@ const newCaretIndex = newUnmaskedLeadingValuePart.length; |
{ | ||
"name": "@maskito/core", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "The main zero-dependency and framework-agnostic Maskito's package to create an input mask", | ||
@@ -33,3 +33,4 @@ "keywords": [ | ||
"module": "./index.esm.js", | ||
"main": "./index.cjs.js" | ||
"main": "./index.cjs.js", | ||
"types": "./index.esm.d.ts" | ||
} |
export { MASKITO_DEFAULT_ELEMENT_PREDICATE, MASKITO_DEFAULT_OPTIONS, } from './lib/constants'; | ||
export { Maskito } from './lib/mask'; | ||
export { maskitoChangeEventPlugin, maskitoInitialCalibrationPlugin, maskitoStrictCompositionPlugin, } from './lib/plugins'; | ||
export { MaskitoElement, MaskitoElementPredicate, MaskitoMask, MaskitoMaskExpression, MaskitoOptions, MaskitoPlugin, MaskitoPostprocessor, MaskitoPreprocessor, } from './lib/types'; | ||
export type { MaskitoElement, MaskitoElementPredicate, MaskitoMask, MaskitoMaskExpression, MaskitoOptions, MaskitoPlugin, MaskitoPostprocessor, MaskitoPreprocessor, } from './lib/types'; | ||
export { maskitoAdaptContentEditable, maskitoPipe, maskitoTransform, maskitoUpdateElement, } from './lib/utils'; | ||
//# sourceMappingURL=index.d.ts.map |
export { MaskHistory } from './mask-history'; | ||
export { MaskModel } from './mask-model/mask-model'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,0 +0,0 @@ import type { ElementState, TypedInputEvent } from '../types'; |
@@ -0,0 +0,0 @@ import type { ElementState, MaskitoOptions, SelectionRange } from '../../types'; |
import type { ElementState, MaskitoOptions } from '../../../types'; | ||
export declare function applyOverwriteMode({ value, selection }: ElementState, newCharacters: string, mode: MaskitoOptions['overwriteMode']): ElementState; | ||
//# sourceMappingURL=apply-overwrite-mode.d.ts.map |
import type { ElementState, MaskitoMaskExpression } from '../../../types'; | ||
export declare function calibrateValueByMask(elementState: ElementState, mask: MaskitoMaskExpression, initialElementState?: ElementState | null): ElementState; | ||
//# sourceMappingURL=calibrate-value-by-mask.d.ts.map |
import type { ElementState } from '../../../types'; | ||
export declare function getLeadingFixedCharacters(mask: Array<RegExp | string>, validatedValuePart: string, newCharacter: string, initialElementState: ElementState | null): string; | ||
//# sourceMappingURL=get-leading-fixed-characters.d.ts.map |
import type { ElementState } from '../../../types'; | ||
export declare function guessValidValueByPattern(elementState: ElementState, mask: Array<RegExp | string>, initialElementState: ElementState | null): ElementState; | ||
//# sourceMappingURL=guess-valid-value-by-pattern.d.ts.map |
import type { ElementState } from '../../../types'; | ||
export declare function guessValidValueByRegExp({ value, selection }: ElementState, maskRegExp: RegExp): ElementState; | ||
//# sourceMappingURL=guess-valid-value-by-reg-exp.d.ts.map |
export declare function isFixedCharacter(char: RegExp | string): char is string; | ||
//# sourceMappingURL=is-fixed-character.d.ts.map |
import type { ElementState, MaskitoMaskExpression } from '../../../types'; | ||
export declare function removeFixedMaskCharacters(initialElementState: ElementState, mask: MaskitoMaskExpression): ElementState; | ||
//# sourceMappingURL=remove-fixed-mask-characters.d.ts.map |
import type { MaskitoMaskExpression } from '../../../types'; | ||
export declare function validateValueWithMask(value: string, maskExpression: MaskitoMaskExpression): boolean; | ||
//# sourceMappingURL=validate-value-with-mask.d.ts.map |
import type { MaskitoElementPredicate } from '../types'; | ||
export declare const MASKITO_DEFAULT_ELEMENT_PREDICATE: MaskitoElementPredicate; | ||
//# sourceMappingURL=default-element-predicate.d.ts.map |
import type { MaskitoOptions } from '../types'; | ||
export declare const MASKITO_DEFAULT_OPTIONS: Required<MaskitoOptions>; | ||
//# sourceMappingURL=default-options.d.ts.map |
export * from './default-element-predicate'; | ||
export * from './default-options'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,0 +0,0 @@ import { MaskHistory } from './classes'; |
import type { MaskitoPlugin } from '../types'; | ||
export declare function maskitoChangeEventPlugin(): MaskitoPlugin; | ||
//# sourceMappingURL=change-event-plugin.d.ts.map |
@@ -0,0 +0,0 @@ export * from './change-event-plugin'; |
import type { MaskitoOptions, MaskitoPlugin } from '../types'; | ||
export declare function maskitoInitialCalibrationPlugin(customOptions?: MaskitoOptions): MaskitoPlugin; | ||
//# sourceMappingURL=initial-calibration-plugin.d.ts.map |
import type { MaskitoPlugin } from '../types'; | ||
export declare function maskitoStrictCompositionPlugin(): MaskitoPlugin; | ||
//# sourceMappingURL=strict-composition-plugin.d.ts.map |
import type { MaskitoElement } from './maskito-element'; | ||
export type MaskitoElementPredicate = (element: HTMLElement) => MaskitoElement | Promise<MaskitoElement>; | ||
//# sourceMappingURL=element-predicate.d.ts.map |
@@ -0,0 +0,0 @@ import type { SelectionRange } from './selection-range'; |
@@ -0,0 +0,0 @@ export * from './element-predicate'; |
@@ -0,0 +0,0 @@ import type { ElementState } from './element-state'; |
@@ -0,0 +0,0 @@ import type { ElementState } from './element-state'; |
@@ -0,0 +0,0 @@ import type { ElementState } from './element-state'; |
export type TextfieldLike = Pick<HTMLInputElement, 'maxLength' | 'select' | 'selectionEnd' | 'selectionStart' | 'setSelectionRange' | 'value'>; | ||
export type MaskitoElement = HTMLElement & TextfieldLike; | ||
//# sourceMappingURL=maskito-element.d.ts.map |
@@ -0,0 +0,0 @@ import type { MaskitoOptions } from './mask-options'; |
export type SelectionRange = readonly [from: number, to: number]; | ||
//# sourceMappingURL=selection-range.d.ts.map |
@@ -0,0 +0,0 @@ export interface TypedInputEvent extends InputEvent { |
import type { MaskitoElement } from '../types'; | ||
export declare function maskitoAdaptContentEditable(element: HTMLElement): MaskitoElement; | ||
//# sourceMappingURL=content-editable.d.ts.map |
@@ -0,0 +0,0 @@ import type { TypedInputEvent } from '../../types'; |
import type { SelectionRange } from '../../types'; | ||
export declare function getContentEditableSelection(element: HTMLElement): SelectionRange; | ||
//# sourceMappingURL=get-content-editable-selection.d.ts.map |
export declare function isRedo(event: KeyboardEvent): boolean; | ||
export declare function isUndo(event: KeyboardEvent): boolean; | ||
//# sourceMappingURL=history-events.d.ts.map |
@@ -0,0 +0,0 @@ export declare const HotkeyModifier: { |
import type { SelectionRange } from '../../types'; | ||
export declare function setContentEditableSelection(element: HTMLElement, [from, to]: SelectionRange): void; | ||
//# sourceMappingURL=set-content-editable-selection.d.ts.map |
@@ -0,0 +0,0 @@ import type { ElementState, MaskitoElement } from '../../types'; |
@@ -0,0 +0,0 @@ import type { ElementState } from '../types'; |
import type { ElementState, SelectionRange } from '../types'; | ||
export declare function getLineSelection({ value, selection }: ElementState, isForward: boolean): SelectionRange; | ||
//# sourceMappingURL=get-line-selection.d.ts.map |
import type { ElementState, SelectionRange } from '../types'; | ||
export declare function getNotEmptySelection({ value, selection }: ElementState, isForward: boolean): SelectionRange; | ||
//# sourceMappingURL=get-not-empty-selection.d.ts.map |
import type { ElementState, SelectionRange } from '../types'; | ||
export declare function getWordSelection({ value, selection }: ElementState, isForward: boolean): SelectionRange; | ||
//# sourceMappingURL=get-word-selection.d.ts.map |
@@ -0,0 +0,0 @@ export * from './content-editable'; |
@@ -0,0 +0,0 @@ import type { MaskitoPostprocessor, MaskitoPreprocessor } from '../types'; |
@@ -0,0 +0,0 @@ import type { ElementState, MaskitoOptions } from '../types'; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94380