Socket
Socket
Sign inDemoInstall

imask

Package Overview
Dependencies
0
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.2.2 to 6.3.0-alpha.0

esm/_rollupPluginBabelHelpers-b054ecd2.js

20

esm/controls/html-contenteditable-mask-element.js

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import HTMLMaskElement from './html-mask-element.js';

@@ -27,3 +27,10 @@ import IMask from '../core/holder.js';

var selection = root.getSelection && root.getSelection();
return selection && selection.anchorOffset;
var anchorOffset = selection && selection.anchorOffset;
var focusOffset = selection && selection.focusOffset;
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
return anchorOffset;
}
return focusOffset;
}

@@ -40,3 +47,10 @@ /**

var selection = root.getSelection && root.getSelection();
return selection && this._unsafeSelectionStart + String(selection).length;
var anchorOffset = selection && selection.anchorOffset;
var focusOffset = selection && selection.focusOffset;
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
return anchorOffset;
}
return focusOffset;
}

@@ -43,0 +57,0 @@ /**

6

esm/controls/html-mask-element.js

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import MaskElement from './mask-element.js';

@@ -36,3 +36,5 @@ import IMask from '../core/holder.js';

get: function get() {
return this.input.getRootNode ? this.input.getRootNode() : document;
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
}

@@ -39,0 +41,0 @@ /**

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

import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import { objectIncludes, DIRECTION } from '../core/utils.js';

@@ -10,4 +10,4 @@ import ActionDetails from '../core/action-details.js';

import IMask from '../core/holder.js';
import '../core/change-details.js';
import '../masked/pattern.js';
import '../core/change-details.js';
import '../masked/base.js';

@@ -72,3 +72,3 @@ import '../core/continuous-tail-details.js';

set: function set(mask) {
if (this.maskEquals(mask)) return;
if (this.maskEquals(mask)) return; // $FlowFixMe No ideas ... after update

@@ -204,3 +204,5 @@ if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {

key: "_saveSelection",
value: function _saveSelection() {
value: function
/* ev */
_saveSelection() {
if (this.value !== this.el.value) {

@@ -207,0 +209,0 @@ console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console

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

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import IMask from '../core/holder.js';

@@ -3,0 +3,0 @@

@@ -1,3 +0,4 @@

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import { DIRECTION } from './utils.js';
import './change-details.js';

@@ -4,0 +5,0 @@ /** Provides details of changing input */

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

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-b054ecd2.js';

@@ -3,0 +3,0 @@ /**

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

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-b054ecd2.js';

@@ -52,5 +52,5 @@ /** Provides details of continuous extracted tail */

}, {
key: "shiftBefore",
value: function shiftBefore(pos) {
if (this.from >= pos || !this.value.length) return '';
key: "unshift",
value: function unshift(beforePos) {
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
var shiftChar = this.value[0];

@@ -57,0 +57,0 @@ this.value = this.value.slice(1);

@@ -1,4 +0,6 @@

import { c as _typeof } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { c as _typeof } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import ChangeDetails from './change-details.js';
/** Checks if value is string */
function isString(str) {

@@ -67,2 +69,5 @@ return typeof str === 'string' || str instanceof String;

return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
}
function normalizePrepare(prep) {
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
} // cloned from https://github.com/epoberezkin/fast-deep-equal with small changes

@@ -100,2 +105,3 @@

for (i = 0; i < keys.length; i++) {
// $FlowFixMe ... ???
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;

@@ -117,2 +123,2 @@ }

export { DIRECTION, escapeRegExp, forceDirection, indexInDirection, isString, objectIncludes, posInDirection };
export { DIRECTION, escapeRegExp, forceDirection, indexInDirection, isString, normalizePrepare, objectIncludes, posInDirection };

@@ -81,3 +81,3 @@ export as namespace IMask;

Masked<MaskType>,
'parent' | 'prepare' | 'validate' | 'commit' | 'overwrite'
'parent' | 'prepare' | 'validate' | 'commit' | 'overwrite' | 'eager'
>

@@ -103,3 +103,3 @@ >;

flags: AppendFlags,
) => string;
) => string | [string, ChangeDetails];
validate: (

@@ -112,2 +112,3 @@ value: string,

overwrite?: boolean;
eager?: boolean;
isInitialized: boolean;

@@ -128,3 +129,3 @@

remove(fromPos?: number, toPos?: number): ChangeDetails;
doPrepare(str: string, flags: AppendFlags): string;
doPrepare(str: string, flags: AppendFlags): string | [string, ChangeDetails];
doValidate(flags: AppendFlags): boolean;

@@ -382,3 +383,3 @@ doCommit(): boolean;

value: string,
masked: AnyMasked,
masked: MaskedDynamic,
flags: AppendFlags

@@ -385,0 +386,0 @@ ) => AnyMasked;

import './controls/input.js';
import IMask from './core/holder.js';
export { default } from './core/holder.js';
import './_rollupPluginBabelHelpers-a0b34764.js';
import './_rollupPluginBabelHelpers-b054ecd2.js';
import './core/utils.js';
import './core/change-details.js';
import './core/action-details.js';
import './masked/date.js';
import './masked/pattern.js';
import './core/change-details.js';
import './masked/base.js';

@@ -11,0 +11,0 @@ import './core/continuous-tail-details.js';

@@ -18,6 +18,6 @@ export { default as InputMask } from './controls/input.js';

export { PIPE_TYPE, createPipe, pipe } from './masked/pipe.js';
import './_rollupPluginBabelHelpers-a0b34764.js';
import './_rollupPluginBabelHelpers-b054ecd2.js';
import './core/utils.js';
import './core/change-details.js';
import './core/action-details.js';
import './core/change-details.js';
import './core/continuous-tail-details.js';

@@ -24,0 +24,0 @@ import './masked/pattern/input-definition.js';

@@ -1,5 +0,5 @@

import { _ as _createClass, a as _classCallCheck } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck, f as _slicedToArray } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import ChangeDetails from '../core/change-details.js';
import ContinuousTailDetails from '../core/continuous-tail-details.js';
import { isString } from '../core/utils.js';
import { isString, normalizePrepare, forceDirection, DIRECTION } from '../core/utils.js';
import IMask from '../core/holder.js';

@@ -31,2 +31,4 @@

/** */
/** */
function Masked(opts) {

@@ -47,3 +49,4 @@ _classCallCheck(this, Masked);

value: function updateOptions(opts) {
if (!Object.keys(opts).length) return;
if (!Object.keys(opts).length) return; // $FlowFixMe
this.withValueRefresh(this._update.bind(this, opts));

@@ -147,2 +150,9 @@ }

}
/** */
}, {
key: "isFilled",
get: function get() {
return this.isComplete;
}
/** Finds nearest input position in direction */

@@ -202,5 +212,12 @@

var consistentState = this.state;
var details;
var details = this._appendCharRaw(this.doPrepare(ch, flags), flags);
var _normalizePrepare = normalizePrepare(this.doPrepare(ch, flags));
var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
ch = _normalizePrepare2[0];
details = _normalizePrepare2[1];
details = details.aggregate(this._appendCharRaw(ch, flags));
if (details.inserted) {

@@ -216,3 +233,3 @@ var consistentTail;

consistentTail = checkTail.state;
checkTail.shiftBefore(this.value.length);
checkTail.unshift(this.value.length);
}

@@ -243,2 +260,9 @@

}
/** Appends optional eager placeholder at end */
}, {
key: "_appendEager",
value: function _appendEager() {
return new ChangeDetails();
}
/** Appends symbols considering flags */

@@ -266,2 +290,6 @@ // $FlowFixMe no ideas

if (this.eager && flags !== null && flags !== void 0 && flags.input && str) {
details.aggregate(this._appendEager());
}
return details;

@@ -363,10 +391,34 @@ }

var tail = this.extractTail(tailPos);
var oldRawValue;
if (this.eager) {
removeDirection = forceDirection(removeDirection);
oldRawValue = this.extractInput(0, tailPos, {
raw: true
});
}
var startChangePos = this.nearestInputPos(start, removeDirection);
var changeDetails = new ChangeDetails({
var details = new ChangeDetails({
tailShift: startChangePos - start // adjust tailShift if start was aligned
}).aggregate(this.remove(startChangePos)).aggregate(this.append(inserted, {
}).aggregate(this.remove(startChangePos));
if (this.eager && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
if (removeDirection === DIRECTION.FORCE_LEFT) {
var valLength;
while (oldRawValue === this.rawInputValue && (valLength = this.value.length)) {
details.aggregate(new ChangeDetails({
tailShift: -1
})).aggregate(this.remove(valLength - 1));
}
} else if (removeDirection === DIRECTION.FORCE_RIGHT) {
tail.unshift();
}
}
return details.aggregate(this.append(inserted, {
input: true
}, tail));
return changeDetails;
}

@@ -373,0 +425,0 @@ }]);

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, f as _slicedToArray, g as _get, h as _getPrototypeOf, i as _set } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, f as _slicedToArray, g as _get, h as _getPrototypeOf, i as _set } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import MaskedPattern from './pattern.js';

@@ -3,0 +3,0 @@ import MaskedRange from './range.js';

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, i as _set, b as _objectWithoutProperties } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, i as _set, b as _objectWithoutProperties } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import ChangeDetails from '../core/change-details.js';

@@ -3,0 +3,0 @@ import createMask from './factory.js';

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import MaskedPattern from './pattern.js';

@@ -3,0 +3,0 @@ import IMask from '../core/holder.js';

import { isString } from '../core/utils.js';
import IMask from '../core/holder.js';
import '../_rollupPluginBabelHelpers-a0b34764.js';
import '../_rollupPluginBabelHelpers-b054ecd2.js';
import '../core/change-details.js';

@@ -25,5 +26,5 @@ /** Get Masked class by mask type */

if (mask instanceof Function) return IMask.MaskedFunction; // $FlowFixMe
if (mask instanceof IMask.Masked) return mask.constructor; // $FlowFixMe
if (mask instanceof IMask.Masked) return mask.constructor;
if (mask instanceof Function) return IMask.MaskedFunction;
console.warn('Mask not found for mask', mask); // eslint-disable-line no-console

@@ -30,0 +31,0 @@ // $FlowFixMe

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import Masked from './base.js';

@@ -3,0 +3,0 @@ import IMask from '../core/holder.js';

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, f as _slicedToArray, i as _set } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, f as _slicedToArray, i as _set } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import { escapeRegExp, DIRECTION } from '../core/utils.js';

@@ -285,3 +285,5 @@ import ChangeDetails from '../core/change-details.js';

var number = this.number;
valid = valid && !isNaN(number) && (this.min == null || this.min >= 0 || this.min <= this.number) && (this.max == null || this.max <= 0 || this.number <= this.max);
valid = valid && !isNaN(number) && ( // check min bound for negative values
this.min == null || this.min >= 0 || this.min <= this.number) && ( // check max bound for positive values
this.max == null || this.max <= 0 || this.number <= this.max);
}

@@ -288,0 +290,0 @@

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

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, b as _objectWithoutProperties, i as _set } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, b as _objectWithoutProperties, i as _set } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import { DIRECTION, forceDirection } from '../core/utils.js';

@@ -95,2 +95,3 @@ import ChangeDetails from '../core/change-details.js';

lazy: _this.lazy,
eager: _this.eager,
placeholderChar: _this.placeholderChar,

@@ -147,2 +148,3 @@ overwrite: _this.overwrite

lazy: this.lazy,
eager: this.eager,
placeholderChar: this.placeholderChar,

@@ -153,2 +155,3 @@ mask: defs[char],

char: char,
eager: this.eager,
isUnmasking: unmaskingBlock

@@ -212,2 +215,13 @@ });

}, {
key: "isFilled",
get: function get() {
return this._blocks.every(function (b) {
return b.isFilled;
});
}
/**
@override
*/
}, {
key: "doCommit",

@@ -264,2 +278,26 @@ value: function doCommit() {

}, {
key: "_appendEager",
value: function _appendEager() {
var _this$_mapPosToBlock;
var details = new ChangeDetails();
var startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.value.length)) === null || _this$_mapPosToBlock === void 0 ? void 0 : _this$_mapPosToBlock.index;
if (startBlockIndex == null) return details; // TODO test if it works for nested pattern masks
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
for (var bi = startBlockIndex; bi < this._blocks.length; ++bi) {
var d = this._blocks[bi]._appendEager();
if (!d.inserted) break;
details.aggregate(d);
}
return details;
}
/**
@override
*/
}, {
key: "_appendCharRaw",

@@ -535,20 +573,22 @@ value: function _appendCharRaw(ch) {

// any|not-len-aligned or end
// check if first block at right is filled input
var firstFilledBlockIndexAtRight;
if (direction === DIRECTION.LEFT) {
// check if first block at right is filled input
var firstFilledBlockIndexAtRight;
for (var _bi2 = searchBlockIndex; _bi2 < this._blocks.length; ++_bi2) {
if (this._blocks[_bi2].value) {
firstFilledBlockIndexAtRight = _bi2;
break;
for (var _bi2 = searchBlockIndex; _bi2 < this._blocks.length; ++_bi2) {
if (this._blocks[_bi2].value) {
firstFilledBlockIndexAtRight = _bi2;
break;
}
}
}
if (firstFilledBlockIndexAtRight != null) {
var filledBlock = this._blocks[firstFilledBlockIndexAtRight];
if (firstFilledBlockIndexAtRight != null) {
var filledBlock = this._blocks[firstFilledBlockIndexAtRight];
var _blockInputPos3 = filledBlock.nearestInputPos(0, DIRECTION.RIGHT);
var _blockInputPos3 = filledBlock.nearestInputPos(0, DIRECTION.RIGHT);
if (_blockInputPos3 === 0 && filledBlock.unmaskedValue.length) {
// filled block is input
return this._blockStartPos(firstFilledBlockIndexAtRight) + _blockInputPos3;
if (_blockInputPos3 === 0 && filledBlock.unmaskedValue.length) {
// filled block is input
return this._blockStartPos(firstFilledBlockIndexAtRight) + _blockInputPos3;
}
}

@@ -555,0 +595,0 @@ } // <-

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

import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../../_rollupPluginBabelHelpers-b054ecd2.js';
import ChangeDetails from '../../core/change-details.js';

@@ -33,3 +33,4 @@ import { isString } from '../../core/utils.js';

var lastChunk = this.chunks[this.chunks.length - 1];
var extendLast = lastChunk && (lastChunk.stop === tailChunk.stop || tailChunk.stop == null) && // if tail chunk goes just after last chunk
var extendLast = lastChunk && ( // if stops are same or tail has no stop
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) && // if tail chunk goes just after last chunk
tailChunk.from === lastChunk.from + lastChunk.toString().length;

@@ -85,3 +86,4 @@

if (stop != null && (!lastBlockIter || lastBlockIter.index <= stop)) {
if (stop != null && ( // if block not found or stop is behind lastBlock
!lastBlockIter || lastBlockIter.index <= stop)) {
if (chunk instanceof ChunksTailDetails || // for continuous block also check if stop is exist

@@ -139,6 +141,6 @@ masked._stops.indexOf(stop) >= 0) {

}, {
key: "shiftBefore",
value: function shiftBefore(pos) {
if (this.from >= pos || !this.chunks.length) return '';
var chunkShiftPos = pos - this.from;
key: "unshift",
value: function unshift(beforePos) {
if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
var chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
var ci = 0;

@@ -148,3 +150,3 @@

var chunk = this.chunks[ci];
var shiftChar = chunk.shiftBefore(chunkShiftPos);
var shiftChar = chunk.unshift(chunkShiftPos);

@@ -151,0 +153,0 @@ if (chunk.toString()) {

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

import { _ as _createClass, a as _classCallCheck } from '../../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck } from '../../_rollupPluginBabelHelpers-b054ecd2.js';
import ChangeDetails from '../../core/change-details.js';

@@ -14,2 +14,4 @@ import { DIRECTION, isString } from '../../core/utils.js';

/** */
/** */
function PatternFixedDefinition(opts) {

@@ -80,9 +82,14 @@ _classCallCheck(this, PatternFixedDefinition);

}, {
key: "isFilled",
get: function get() {
return Boolean(this._value);
}
}, {
key: "_appendChar",
value: function _appendChar(str) {
value: function _appendChar(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var details = new ChangeDetails();
if (this._value) return details;
var appended = this.char === str[0];
var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && !flags.tail;
var appended = this.char === ch;
var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && !this.eager && !flags.tail;
if (isResolved) details.rawInserted = this.char;

@@ -94,2 +101,7 @@ this._value = details.inserted = this.char;

}, {
key: "_appendEager",
value: function _appendEager() {
return this._appendChar(this.char);
}
}, {
key: "_appendPlaceholder",

@@ -118,3 +130,3 @@ value: function _appendPlaceholder() {

value: function append(str, flags, tail) {
var details = this._appendChar(str, flags);
var details = this._appendChar(str[0], flags);

@@ -121,0 +133,0 @@ if (tail != null) {

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

import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../../_rollupPluginBabelHelpers-a0b34764.js';
import { _ as _createClass, a as _classCallCheck, b as _objectWithoutProperties } from '../../_rollupPluginBabelHelpers-b054ecd2.js';
import createMask from '../factory.js';

@@ -28,2 +28,4 @@ import ChangeDetails from '../../core/change-details.js';

/** */
/** */
function PatternInputDefinition(opts) {

@@ -44,3 +46,3 @@ _classCallCheck(this, PatternInputDefinition);

value: function reset() {
this._isFilled = false;
this.isFilled = false;
this.masked.reset();

@@ -55,3 +57,3 @@ }

if (fromPos === 0 && toPos >= 1) {
this._isFilled = false;
this.isFilled = false;
return this.masked.remove(fromPos, toPos);

@@ -65,3 +67,3 @@ }

get: function get() {
return this.masked.value || (this._isFilled && !this.isOptional ? this.placeholderChar : '');
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
}

@@ -80,8 +82,8 @@ }, {

key: "_appendChar",
value: function _appendChar(str) {
value: function _appendChar(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (this._isFilled) return new ChangeDetails();
if (this.isFilled) return new ChangeDetails();
var state = this.masked.state; // simulate input
var details = this.masked._appendChar(str, flags);
var details = this.masked._appendChar(ch, flags);

@@ -98,3 +100,3 @@ if (details.inserted && this.doValidate(flags) === false) {

details.skip = !details.inserted && !this.isOptional;
this._isFilled = Boolean(details.inserted);
this.isFilled = Boolean(details.inserted);
return details;

@@ -107,2 +109,3 @@ }

// TODO probably should be done via _appendChar
return (_this$masked = this.masked).append.apply(_this$masked, arguments);

@@ -114,4 +117,4 @@ }

var details = new ChangeDetails();
if (this._isFilled || this.isOptional) return details;
this._isFilled = true;
if (this.isFilled || this.isOptional) return details;
this.isFilled = true;
details.inserted = this.placeholderChar;

@@ -121,2 +124,7 @@ return details;

}, {
key: "_appendEager",
value: function _appendEager() {
return new ChangeDetails();
}
}, {
key: "extractTail",

@@ -182,3 +190,3 @@ value: function extractTail() {

masked: this.masked.state,
_isFilled: this._isFilled
isFilled: this.isFilled
};

@@ -188,3 +196,3 @@ },

this.masked.state = state.masked;
this._isFilled = state._isFilled;
this.isFilled = state.isFilled;
}

@@ -191,0 +199,0 @@ }]);

import createMask from './factory.js';
import IMask from '../core/holder.js';
import '../core/utils.js';
import '../_rollupPluginBabelHelpers-a0b34764.js';
import '../_rollupPluginBabelHelpers-b054ecd2.js';
import '../core/change-details.js';

@@ -6,0 +7,0 @@ /** Mask pipe source and destination types */

@@ -1,5 +0,5 @@

import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, f as _slicedToArray } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass, g as _get, h as _getPrototypeOf, f as _slicedToArray } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import MaskedPattern from './pattern.js';
import { normalizePrepare } from '../core/utils.js';
import IMask from '../core/holder.js';
import '../core/utils.js';
import '../core/change-details.js';

@@ -98,3 +98,4 @@ import './base.js';

return [minstr, maxstr];
}
} // TODO str is a single char everytime
/**

@@ -106,23 +107,34 @@ @override

key: "doPrepare",
value: function doPrepare(str) {
value: function doPrepare(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
str = _get(_getPrototypeOf(MaskedRange.prototype), "doPrepare", this).call(this, str, flags).replace(/\D/g, '');
if (!this.autofix) return str;
var details;
var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedRange.prototype), "doPrepare", this).call(this, ch.replace(/\D/g, ''), flags));
var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
ch = _normalizePrepare2[0];
details = _normalizePrepare2[1];
if (!this.autofix || !ch) return ch;
var fromStr = String(this.from).padStart(this.maxLength, '0');
var toStr = String(this.to).padStart(this.maxLength, '0');
var val = this.value;
var prepStr = '';
var nextVal = this.value + ch;
if (nextVal.length > this.maxLength) return '';
for (var ci = 0; ci < str.length; ++ci) {
var nextVal = val + prepStr + str[ci];
var _this$boundaries = this.boundaries(nextVal),
_this$boundaries2 = _slicedToArray(_this$boundaries, 2),
minstr = _this$boundaries2[0],
maxstr = _this$boundaries2[1];
var _this$boundaries = this.boundaries(nextVal),
_this$boundaries2 = _slicedToArray(_this$boundaries, 2),
minstr = _this$boundaries2[0],
maxstr = _this$boundaries2[1];
if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
if (Number(maxstr) < this.from) prepStr += fromStr[nextVal.length - 1];else if (Number(minstr) > this.to) prepStr += toStr[nextVal.length - 1];else prepStr += str[ci];
if (Number(minstr) > this.to) {
if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
}
return toStr[nextVal.length - 1];
}
return prepStr;
return ch;
}

@@ -129,0 +141,0 @@ /**

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

import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-a0b34764.js';
import { d as _inherits, e as _createSuper, _ as _createClass, a as _classCallCheck, g as _get, h as _getPrototypeOf } from '../_rollupPluginBabelHelpers-b054ecd2.js';
import Masked from './base.js';

@@ -3,0 +3,0 @@ import IMask from '../core/holder.js';

@@ -70,2 +70,2 @@ var $$3 = require('../internals/export');

// TODO: Remove from `core-js@4`
require('./es.global-this');
require('../modules/es.global-this');

@@ -81,3 +81,3 @@ export as namespace IMask;

Masked<MaskType>,
'parent' | 'prepare' | 'validate' | 'commit' | 'overwrite'
'parent' | 'prepare' | 'validate' | 'commit' | 'overwrite' | 'eager'
>

@@ -103,3 +103,3 @@ >;

flags: AppendFlags,
) => string;
) => string | [string, ChangeDetails];
validate: (

@@ -112,2 +112,3 @@ value: string,

overwrite?: boolean;
eager?: boolean;
isInitialized: boolean;

@@ -128,3 +129,3 @@

remove(fromPos?: number, toPos?: number): ChangeDetails;
doPrepare(str: string, flags: AppendFlags): string;
doPrepare(str: string, flags: AppendFlags): string | [string, ChangeDetails];
doValidate(flags: AppendFlags): boolean;

@@ -382,3 +383,3 @@ doCommit(): boolean;

value: string,
masked: AnyMasked,
masked: MaskedDynamic,
flags: AppendFlags

@@ -385,0 +386,0 @@ ) => AnyMasked;

{
"name": "imask",
"version": "6.2.2",
"version": "6.3.0-alpha.0",
"author": "Alexey Kryazhev",

@@ -31,3 +31,3 @@ "license": "MIT",

],
"gitHead": "228f2a4dce7125d0c7156868fcb5364b4487c8e6"
"gitHead": "89ea815984ff2ca015974ff1ecb8e8df727bfc07"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc