Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@maskito/core

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maskito/core - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

2

package.json
{
"name": "@maskito/core",
"version": "0.1.1",
"version": "0.2.0",
"description": "The main zero-dependency and framework-agnostic Maskito's package to create an input mask",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,8 +6,15 @@ # @maskito/core

[Documentation](https://tinkoff.github.io/maskito) •
[Submit an Issue](https://github.com/Tinkoff/maskito/issues/new/choose) • [Contact Us](https://t.me/taiga_ui)
<p align="center">
<img src="https://raw.githubusercontent.com/Tinkoff/maskito/main/projects/demo/src/assets/icons/maskito.svg" alt="Maskito logo" height="120px">
</p>
> It is the main zero-dependency and framework-agnostic Maskito's package. It can be used alone in Vanilla Javascript
> project.
<p align="center">
<a href="https://tinkoff.github.io/maskito">Documentation</a> •
<a href="https://github.com/Tinkoff/maskito/issues/new/choose">Submit an Issue</a> •
<a href="https://t.me/taiga_ui">Contact Us</a>
</p>
> It is the main zero-dependency and framework-agnostic Maskito's package.<br />It can be used alone in
> vanilla JavaScript project.
## How to install

@@ -14,0 +21,0 @@

@@ -7,7 +7,7 @@ import { ElementState, MaskitoOptions, SelectionRange } from '../../types';

selection: SelectionRange;
private get maskExpression();
constructor(initialElementState: ElementState, maskOptions: MaskitoOptions);
addCharacters(selection: SelectionRange, newCharacters: string): void;
addCharacters([from, to]: SelectionRange, newCharacters: string): void;
deleteCharacters([from, to]: SelectionRange): void;
private getMaskExpression;
}
//# sourceMappingURL=mask-model.d.ts.map

@@ -11,13 +11,13 @@ import { areElementStatesEqual } from '../../utils';

this.selection = [0, 0];
const { value, selection } = calibrateValueByMask(initialElementState, this.maskExpression);
const { value, selection } = calibrateValueByMask(initialElementState, this.getMaskExpression(initialElementState));
this.value = value;
this.selection = selection;
}
get maskExpression() {
const { mask } = this.maskOptions;
return typeof mask === 'function' ? mask() : mask;
}
addCharacters(selection, newCharacters) {
const { maskExpression, value } = this;
const initialElementState = { value, selection };
addCharacters([from, to], newCharacters) {
const { value } = this;
const maskExpression = this.getMaskExpression({
value: value.slice(0, from) + newCharacters + value.slice(to),
selection: [from + newCharacters.length, from + newCharacters.length],
});
const initialElementState = { value, selection: [from, to] };
const unmaskedElementState = removeFixedMaskCharacters(initialElementState, maskExpression);

@@ -41,9 +41,10 @@ const [unmaskedFrom, unmaskedTo] = applyOverwriteMode(unmaskedElementState, newCharacters, this.maskOptions.overwriteMode).selection;

deleteCharacters([from, to]) {
if (from === 0 && to === 0) {
if (from === to || !to) {
return;
}
if (from === to) {
return;
}
const { maskExpression, value } = this;
const { value } = this;
const maskExpression = this.getMaskExpression({
value: value.slice(0, from) + value.slice(to),
selection: [from, from],
});
const initialElementState = { value, selection: [from, to] };

@@ -58,3 +59,7 @@ const unmaskedElementState = removeFixedMaskCharacters(initialElementState, maskExpression);

}
getMaskExpression(elementState) {
const { mask } = this.maskOptions;
return typeof mask === 'function' ? mask(elementState) : mask;
}
}
//# sourceMappingURL=mask-model.js.map

@@ -25,5 +25,5 @@ import { isFixedCharacter } from './is-fixed-character';

value: unmaskedValue,
selection: selection,
selection: [selection[0], selection[1]],
};
}
//# sourceMappingURL=remove-fixed-mask-characters.js.map
import { SelectionRange } from './selection-range';
export interface ElementState {
value: string;
selection: SelectionRange;
readonly value: string;
readonly selection: SelectionRange;
}
//# sourceMappingURL=element-state.d.ts.map

@@ -5,7 +5,7 @@ import { ElementState } from './element-state';

export interface MaskitoOptions {
mask: MaskExpression | (() => MaskExpression);
preprocessor?: MaskPreprocessor;
postprocessor?: MaskPostprocessor;
overwriteMode?: 'replace' | 'shift' | ((elementState: ElementState) => 'replace' | 'shift');
readonly mask: MaskExpression | ((elementState: ElementState) => MaskExpression);
readonly preprocessor?: MaskPreprocessor;
readonly postprocessor?: MaskPostprocessor;
readonly overwriteMode?: 'replace' | 'shift' | ((elementState: ElementState) => 'replace' | 'shift');
}
//# sourceMappingURL=mask-options.d.ts.map

@@ -1,2 +0,2 @@

export declare type SelectionRange = [from: number, to: number];
export declare type SelectionRange = readonly [from: number, to: number];
//# sourceMappingURL=selection-range.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc