Socket
Socket
Sign inDemoInstall

react-imask

Package Overview
Dependencies
2
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.2.1 to 6.2.2

esm/mixin-9a4bc4a3.js

2

dist/react-imask.js

@@ -126,2 +126,4 @@ (function (global, factory) {

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -128,0 +130,0 @@

11

esm/hook.js

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

import { r as react, I as IMask } from './index-7f694484.js';
import IMask from 'imask/esm/imask';
import { useRef, useEffect } from 'react';

@@ -8,4 +9,4 @@ function useIMask(opts) {

var ref = react.exports.useRef(null);
var maskRef = react.exports.useRef(null); // methods
var ref = useRef(null);
var maskRef = useRef(null); // methods

@@ -38,3 +39,3 @@ function _initMask() {

react.exports.useEffect(function () {
useEffect(function () {
var el = ref.current;

@@ -50,3 +51,3 @@ if (!el || !(opts !== null && opts !== void 0 && opts.mask)) return _destroyMask();

}, [opts]);
react.exports.useEffect(function () {
useEffect(function () {
return _destroyMask;

@@ -53,0 +54,0 @@ }, []);

@@ -1,875 +0,7 @@

import { I as IMask, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _get, e as _getPrototypeOf, M as MaskedPattern, f as escapeRegExp, g as _slicedToArray, C as ChangeDetails, D as DIRECTION, h as _set, i as Masked, j as createMask, k as _objectWithoutProperties } from './index-7f694484.js';
export { I as IMask } from './index-7f694484.js';
export { default as IMaskMixin } from './mixin.js';
import 'imask/esm';
export { default as IMask } from 'imask/esm/imask';
export { I as IMaskMixin } from './mixin-9a4bc4a3.js';
export { default as IMaskInput } from './input.js';
export { default as useIMask } from './hook.js';
/** Pattern which validates enum values */
var MaskedEnum = /*#__PURE__*/function (_MaskedPattern) {
_inherits(MaskedEnum, _MaskedPattern);
var _super = _createSuper(MaskedEnum);
function MaskedEnum() {
_classCallCheck(this, MaskedEnum);
return _super.apply(this, arguments);
}
_createClass(MaskedEnum, [{
key: "_update",
value:
/**
@override
@param {Object} opts
*/
function _update(opts) {
// TODO type
if (opts.enum) opts.mask = '*'.repeat(opts.enum[0].length);
_get(_getPrototypeOf(MaskedEnum.prototype), "_update", this).call(this, opts);
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate() {
var _this = this,
_get2;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return this.enum.some(function (e) {
return e.indexOf(_this.unmaskedValue) >= 0;
}) && (_get2 = _get(_getPrototypeOf(MaskedEnum.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args));
}
}]);
return MaskedEnum;
}(MaskedPattern);
IMask.MaskedEnum = MaskedEnum;
/**
Number mask
@param {Object} opts
@param {string} opts.radix - Single char
@param {string} opts.thousandsSeparator - Single char
@param {Array<string>} opts.mapToRadix - Array of single chars
@param {number} opts.min
@param {number} opts.max
@param {number} opts.scale - Digits after point
@param {boolean} opts.signed - Allow negative
@param {boolean} opts.normalizeZeros - Flag to remove leading and trailing zeros in the end of editing
@param {boolean} opts.padFractionalZeros - Flag to pad trailing zeros after point in the end of editing
*/
var MaskedNumber = /*#__PURE__*/function (_Masked) {
_inherits(MaskedNumber, _Masked);
var _super = _createSuper(MaskedNumber);
/** Single char */
/** Single char */
/** Array of single chars */
/** */
/** */
/** Digits after point */
/** */
/** Flag to remove leading and trailing zeros in the end of editing */
/** Flag to pad trailing zeros after point in the end of editing */
function MaskedNumber(opts) {
_classCallCheck(this, MaskedNumber);
return _super.call(this, Object.assign({}, MaskedNumber.DEFAULTS, opts));
}
/**
@override
*/
_createClass(MaskedNumber, [{
key: "_update",
value: function _update(opts) {
_get(_getPrototypeOf(MaskedNumber.prototype), "_update", this).call(this, opts);
this._updateRegExps();
}
/** */
}, {
key: "_updateRegExps",
value: function _updateRegExps() {
// use different regexp to process user input (more strict, input suffix) and tail shifting
var start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
var midInput = '(0|([1-9]+\\d*))?';
var mid = '\\d*';
var end = (this.scale ? '(' + escapeRegExp(this.radix) + '\\d{0,' + this.scale + '})?' : '') + '$';
this._numberRegExpInput = new RegExp(start + midInput + end);
this._numberRegExp = new RegExp(start + mid + end);
this._mapToRadixRegExp = new RegExp('[' + this.mapToRadix.map(escapeRegExp).join('') + ']', 'g');
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
}
/** */
}, {
key: "_removeThousandsSeparators",
value: function _removeThousandsSeparators(value) {
return value.replace(this._thousandsSeparatorRegExp, '');
}
/** */
}, {
key: "_insertThousandsSeparators",
value: function _insertThousandsSeparators(value) {
// https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
var parts = value.split(this.radix);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
return parts.join(this.radix);
}
/**
@override
*/
}, {
key: "doPrepare",
value: function doPrepare(str) {
var _get2;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return (_get2 = _get(_getPrototypeOf(MaskedNumber.prototype), "doPrepare", this)).call.apply(_get2, [this, this._removeThousandsSeparators(str.replace(this._mapToRadixRegExp, this.radix))].concat(args));
}
/** */
}, {
key: "_separatorsCount",
value: function _separatorsCount(to) {
var extendOnSeparators = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var count = 0;
for (var pos = 0; pos < to; ++pos) {
if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
++count;
if (extendOnSeparators) to += this.thousandsSeparator.length;
}
}
return count;
}
/** */
}, {
key: "_separatorsCountFromSlice",
value: function _separatorsCountFromSlice() {
var slice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._value;
return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
}
/**
@override
*/
}, {
key: "extractInput",
value: function extractInput() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var flags = arguments.length > 2 ? arguments[2] : undefined;
var _this$_adjustRangeWit = this._adjustRangeWithSeparators(fromPos, toPos);
var _this$_adjustRangeWit2 = _slicedToArray(_this$_adjustRangeWit, 2);
fromPos = _this$_adjustRangeWit2[0];
toPos = _this$_adjustRangeWit2[1];
return this._removeThousandsSeparators(_get(_getPrototypeOf(MaskedNumber.prototype), "extractInput", this).call(this, fromPos, toPos, flags));
}
/**
@override
*/
}, {
key: "_appendCharRaw",
value: function _appendCharRaw(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.thousandsSeparator) return _get(_getPrototypeOf(MaskedNumber.prototype), "_appendCharRaw", this).call(this, ch, flags);
var prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
var prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
this._value = this._removeThousandsSeparators(this.value);
var appendDetails = _get(_getPrototypeOf(MaskedNumber.prototype), "_appendCharRaw", this).call(this, ch, flags);
this._value = this._insertThousandsSeparators(this._value);
var beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
var beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
return appendDetails;
}
/** */
}, {
key: "_findSeparatorAround",
value: function _findSeparatorAround(pos) {
if (this.thousandsSeparator) {
var searchFrom = pos - this.thousandsSeparator.length + 1;
var separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
if (separatorPos <= pos) return separatorPos;
}
return -1;
}
}, {
key: "_adjustRangeWithSeparators",
value: function _adjustRangeWithSeparators(from, to) {
var separatorAroundFromPos = this._findSeparatorAround(from);
if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
var separatorAroundToPos = this._findSeparatorAround(to);
if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
return [from, to];
}
/**
@override
*/
}, {
key: "remove",
value: function remove() {
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
var _this$_adjustRangeWit3 = this._adjustRangeWithSeparators(fromPos, toPos);
var _this$_adjustRangeWit4 = _slicedToArray(_this$_adjustRangeWit3, 2);
fromPos = _this$_adjustRangeWit4[0];
toPos = _this$_adjustRangeWit4[1];
var valueBeforePos = this.value.slice(0, fromPos);
var valueAfterPos = this.value.slice(toPos);
var prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
var beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
return new ChangeDetails({
tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
});
}
/**
@override
*/
}, {
key: "nearestInputPos",
value: function nearestInputPos(cursorPos, direction) {
if (!this.thousandsSeparator) return cursorPos;
switch (direction) {
case DIRECTION.NONE:
case DIRECTION.LEFT:
case DIRECTION.FORCE_LEFT:
{
var separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
if (separatorAtLeftPos >= 0) {
var separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
return separatorAtLeftPos;
}
}
break;
}
case DIRECTION.RIGHT:
case DIRECTION.FORCE_RIGHT:
{
var separatorAtRightPos = this._findSeparatorAround(cursorPos);
if (separatorAtRightPos >= 0) {
return separatorAtRightPos + this.thousandsSeparator.length;
}
}
}
return cursorPos;
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate(flags) {
var regexp = flags.input ? this._numberRegExpInput : this._numberRegExp; // validate as string
var valid = regexp.test(this._removeThousandsSeparators(this.value));
if (valid) {
// validate as number
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);
}
return valid && _get(_getPrototypeOf(MaskedNumber.prototype), "doValidate", this).call(this, flags);
}
/**
@override
*/
}, {
key: "doCommit",
value: function doCommit() {
if (this.value) {
var number = this.number;
var validnum = number; // check bounds
if (this.min != null) validnum = Math.max(validnum, this.min);
if (this.max != null) validnum = Math.min(validnum, this.max);
if (validnum !== number) this.unmaskedValue = String(validnum);
var formatted = this.value;
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
if (this.padFractionalZeros) formatted = this._padFractionalZeros(formatted);
this._value = formatted;
}
_get(_getPrototypeOf(MaskedNumber.prototype), "doCommit", this).call(this);
}
/** */
}, {
key: "_normalizeZeros",
value: function _normalizeZeros(value) {
var parts = this._removeThousandsSeparators(value).split(this.radix); // remove leading zeros
parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, function (match, sign, zeros, num) {
return sign + num;
}); // add leading zero
if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
if (parts.length > 1) {
parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros
if (!parts[1].length) parts.length = 1; // remove fractional
}
return this._insertThousandsSeparators(parts.join(this.radix));
}
/** */
}, {
key: "_padFractionalZeros",
value: function _padFractionalZeros(value) {
if (!value) return value;
var parts = value.split(this.radix);
if (parts.length < 2) parts.push('');
parts[1] = parts[1].padEnd(this.scale, '0');
return parts.join(this.radix);
}
/**
@override
*/
}, {
key: "unmaskedValue",
get: function get() {
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, '.');
},
set: function set(unmaskedValue) {
_set(_getPrototypeOf(MaskedNumber.prototype), "unmaskedValue", unmaskedValue.replace('.', this.radix), this, true);
}
/**
@override
*/
}, {
key: "typedValue",
get: function get() {
return Number(this.unmaskedValue);
},
set: function set(n) {
_set(_getPrototypeOf(MaskedNumber.prototype), "unmaskedValue", String(n), this, true);
}
/** Parsed Number */
}, {
key: "number",
get: function get() {
return this.typedValue;
},
set: function set(number) {
this.typedValue = number;
}
/**
Is negative allowed
@readonly
*/
}, {
key: "allowNegative",
get: function get() {
return this.signed || this.min != null && this.min < 0 || this.max != null && this.max < 0;
}
}]);
return MaskedNumber;
}(Masked);
MaskedNumber.DEFAULTS = {
radix: ',',
thousandsSeparator: '',
mapToRadix: ['.'],
scale: 2,
signed: false,
normalizeZeros: true,
padFractionalZeros: false
};
IMask.MaskedNumber = MaskedNumber;
/** Masking by custom Function */
var MaskedFunction = /*#__PURE__*/function (_Masked) {
_inherits(MaskedFunction, _Masked);
var _super = _createSuper(MaskedFunction);
function MaskedFunction() {
_classCallCheck(this, MaskedFunction);
return _super.apply(this, arguments);
}
_createClass(MaskedFunction, [{
key: "_update",
value:
/**
@override
@param {Object} opts
*/
function _update(opts) {
if (opts.mask) opts.validate = opts.mask;
_get(_getPrototypeOf(MaskedFunction.prototype), "_update", this).call(this, opts);
}
}]);
return MaskedFunction;
}(Masked);
IMask.MaskedFunction = MaskedFunction;
var _excluded = ["compiledMasks", "currentMaskRef", "currentMask"];
/** Dynamic mask for choosing apropriate mask in run-time */
var MaskedDynamic = /*#__PURE__*/function (_Masked) {
_inherits(MaskedDynamic, _Masked);
var _super = _createSuper(MaskedDynamic);
/** Currently chosen mask */
/** Compliled {@link Masked} options */
/** Chooses {@link Masked} depending on input value */
/**
@param {Object} opts
*/
function MaskedDynamic(opts) {
var _this;
_classCallCheck(this, MaskedDynamic);
_this = _super.call(this, Object.assign({}, MaskedDynamic.DEFAULTS, opts));
_this.currentMask = null;
return _this;
}
/**
@override
*/
_createClass(MaskedDynamic, [{
key: "_update",
value: function _update(opts) {
_get(_getPrototypeOf(MaskedDynamic.prototype), "_update", this).call(this, opts);
if ('mask' in opts) {
// mask could be totally dynamic with only `dispatch` option
this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(function (m) {
return createMask(m);
}) : [];
}
}
/**
@override
*/
}, {
key: "_appendCharRaw",
value: function _appendCharRaw(ch) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var details = this._applyDispatch(ch, flags);
if (this.currentMask) {
details.aggregate(this.currentMask._appendChar(ch, flags));
}
return details;
}
}, {
key: "_applyDispatch",
value: function _applyDispatch() {
var appended = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
var inputValue = this.rawInputValue;
var insertValue = flags.tail && flags._beforeTailState != null ? // $FlowFixMe - tired to fight with type system
flags._beforeTailState._rawInputValue : inputValue;
var tailValue = inputValue.slice(insertValue.length);
var prevMask = this.currentMask;
var details = new ChangeDetails();
var prevMaskState = prevMask && prevMask.state; // clone flags to prevent overwriting `_beforeTailState`
this.currentMask = this.doDispatch(appended, Object.assign({}, flags)); // restore state after dispatch
if (this.currentMask) {
if (this.currentMask !== prevMask) {
// if mask changed reapply input
this.currentMask.reset();
if (insertValue) {
// $FlowFixMe - it's ok, we don't change current mask above
var d = this.currentMask.append(insertValue, {
raw: true
});
details.tailShift = d.inserted.length - prevValueBeforeTail.length;
}
if (tailValue) {
// $FlowFixMe - it's ok, we don't change current mask above
details.tailShift += this.currentMask.append(tailValue, {
raw: true,
tail: true
}).tailShift;
}
} else {
// Dispatch can do something bad with state, so
// restore prev mask state
this.currentMask.state = prevMaskState;
}
}
return details;
}
}, {
key: "_appendPlaceholder",
value: function _appendPlaceholder() {
var details = this._applyDispatch.apply(this, arguments);
if (this.currentMask) {
details.aggregate(this.currentMask._appendPlaceholder());
}
return details;
}
/**
@override
*/
}, {
key: "doDispatch",
value: function doDispatch(appended) {
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return this.dispatch(appended, this, flags);
}
/**
@override
*/
}, {
key: "doValidate",
value: function doValidate() {
var _get2, _this$currentMask;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return (_get2 = _get(_getPrototypeOf(MaskedDynamic.prototype), "doValidate", this)).call.apply(_get2, [this].concat(args)) && (!this.currentMask || (_this$currentMask = this.currentMask).doValidate.apply(_this$currentMask, args));
}
/**
@override
*/
}, {
key: "reset",
value: function reset() {
if (this.currentMask) this.currentMask.reset();
this.compiledMasks.forEach(function (m) {
return m.reset();
});
}
/**
@override
*/
}, {
key: "value",
get: function get() {
return this.currentMask ? this.currentMask.value : '';
},
set: function set(value) {
_set(_getPrototypeOf(MaskedDynamic.prototype), "value", value, this, true);
}
/**
@override
*/
}, {
key: "unmaskedValue",
get: function get() {
return this.currentMask ? this.currentMask.unmaskedValue : '';
},
set: function set(unmaskedValue) {
_set(_getPrototypeOf(MaskedDynamic.prototype), "unmaskedValue", unmaskedValue, this, true);
}
/**
@override
*/
}, {
key: "typedValue",
get: function get() {
return this.currentMask ? this.currentMask.typedValue : '';
} // probably typedValue should not be used with dynamic
,
set: function set(value) {
var unmaskedValue = String(value); // double check it
if (this.currentMask) {
this.currentMask.typedValue = value;
unmaskedValue = this.currentMask.unmaskedValue;
}
this.unmaskedValue = unmaskedValue;
}
/**
@override
*/
}, {
key: "isComplete",
get: function get() {
return !!this.currentMask && this.currentMask.isComplete;
}
/**
@override
*/
}, {
key: "remove",
value: function remove() {
var details = new ChangeDetails();
if (this.currentMask) {
var _this$currentMask2;
details.aggregate((_this$currentMask2 = this.currentMask).remove.apply(_this$currentMask2, arguments)) // update with dispatch
.aggregate(this._applyDispatch());
}
return details;
}
/**
@override
*/
}, {
key: "state",
get: function get() {
return Object.assign({}, _get(_getPrototypeOf(MaskedDynamic.prototype), "state", this), {
_rawInputValue: this.rawInputValue,
compiledMasks: this.compiledMasks.map(function (m) {
return m.state;
}),
currentMaskRef: this.currentMask,
currentMask: this.currentMask && this.currentMask.state
});
},
set: function set(state) {
var compiledMasks = state.compiledMasks,
currentMaskRef = state.currentMaskRef,
currentMask = state.currentMask,
maskedState = _objectWithoutProperties(state, _excluded);
this.compiledMasks.forEach(function (m, mi) {
return m.state = compiledMasks[mi];
});
if (currentMaskRef != null) {
this.currentMask = currentMaskRef;
this.currentMask.state = currentMask;
}
_set(_getPrototypeOf(MaskedDynamic.prototype), "state", maskedState, this, true);
}
/**
@override
*/
}, {
key: "extractInput",
value: function extractInput() {
var _this$currentMask3;
return this.currentMask ? (_this$currentMask3 = this.currentMask).extractInput.apply(_this$currentMask3, arguments) : '';
}
/**
@override
*/
}, {
key: "extractTail",
value: function extractTail() {
var _this$currentMask4, _get3;
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.currentMask ? (_this$currentMask4 = this.currentMask).extractTail.apply(_this$currentMask4, args) : (_get3 = _get(_getPrototypeOf(MaskedDynamic.prototype), "extractTail", this)).call.apply(_get3, [this].concat(args));
}
/**
@override
*/
}, {
key: "doCommit",
value: function doCommit() {
if (this.currentMask) this.currentMask.doCommit();
_get(_getPrototypeOf(MaskedDynamic.prototype), "doCommit", this).call(this);
}
/**
@override
*/
}, {
key: "nearestInputPos",
value: function nearestInputPos() {
var _this$currentMask5, _get4;
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return this.currentMask ? (_this$currentMask5 = this.currentMask).nearestInputPos.apply(_this$currentMask5, args) : (_get4 = _get(_getPrototypeOf(MaskedDynamic.prototype), "nearestInputPos", this)).call.apply(_get4, [this].concat(args));
}
}, {
key: "overwrite",
get: function get() {
return this.currentMask ? this.currentMask.overwrite : _get(_getPrototypeOf(MaskedDynamic.prototype), "overwrite", this);
},
set: function set(overwrite) {
console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
}
}]);
return MaskedDynamic;
}(Masked);
MaskedDynamic.DEFAULTS = {
dispatch: function dispatch(appended, masked, flags) {
if (!masked.compiledMasks.length) return;
var inputValue = masked.rawInputValue; // simulate input
var inputs = masked.compiledMasks.map(function (m, index) {
m.reset();
m.append(inputValue, {
raw: true
});
m.append(appended, flags);
var weight = m.rawInputValue.length;
return {
weight: weight,
index: index
};
}); // pop masks with longer values first
inputs.sort(function (i1, i2) {
return i2.weight - i1.weight;
});
return masked.compiledMasks[inputs[0].index];
}
};
IMask.MaskedDynamic = MaskedDynamic;
/** Mask pipe source and destination types */
var PIPE_TYPE = {
MASKED: 'value',
UNMASKED: 'unmaskedValue',
TYPED: 'typedValue'
};
/** Creates new pipe function depending on mask type, source and destination options */
function createPipe(mask) {
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
var masked = createMask(mask);
return function (value) {
return masked.runIsolated(function (m) {
m[from] = value;
return m[to];
});
};
}
/** Pipes value through mask depending on mask type, source and destination options */
function pipe(value) {
for (var _len = arguments.length, pipeArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
pipeArgs[_key - 1] = arguments[_key];
}
return createPipe.apply(void 0, pipeArgs)(value);
}
IMask.PIPE_TYPE = PIPE_TYPE;
IMask.createPipe = createPipe;
IMask.pipe = pipe;
try {
globalThis.IMask = IMask;
} catch (e) {}
import 'react';
import 'prop-types';

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

import { s as _objectWithoutProperties, R as React } from './index-7f694484.js';
import IMaskMixin from './mixin.js';
import { I as IMaskMixin, _ as _objectWithoutProperties } from './mixin-9a4bc4a3.js';
import React from 'react';
import 'prop-types';
import 'imask/esm/imask';

@@ -4,0 +6,0 @@ var _excluded = ["inputRef"];

@@ -1,1341 +0,4 @@

import { o as objectAssign, I as IMask, l as _inherits, m as _createSuper, n as _createClass, R as React, p as _classCallCheck, q as _assertThisInitialized } from './index-7f694484.js';
var propTypes = {exports: {}};
var reactIs = {exports: {}};
var reactIs_production_min = {};
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var b = "function" === typeof Symbol && Symbol.for,
c = b ? Symbol.for("react.element") : 60103,
d = b ? Symbol.for("react.portal") : 60106,
e = b ? Symbol.for("react.fragment") : 60107,
f = b ? Symbol.for("react.strict_mode") : 60108,
g = b ? Symbol.for("react.profiler") : 60114,
h = b ? Symbol.for("react.provider") : 60109,
k = b ? Symbol.for("react.context") : 60110,
l = b ? Symbol.for("react.async_mode") : 60111,
m = b ? Symbol.for("react.concurrent_mode") : 60111,
n = b ? Symbol.for("react.forward_ref") : 60112,
p = b ? Symbol.for("react.suspense") : 60113,
q = b ? Symbol.for("react.suspense_list") : 60120,
r = b ? Symbol.for("react.memo") : 60115,
t = b ? Symbol.for("react.lazy") : 60116,
v = b ? Symbol.for("react.block") : 60121,
w = b ? Symbol.for("react.fundamental") : 60117,
x = b ? Symbol.for("react.responder") : 60118,
y = b ? Symbol.for("react.scope") : 60119;
function z(a) {
if ("object" === typeof a && null !== a) {
var u = a.$$typeof;
switch (u) {
case c:
switch (a = a.type, a) {
case l:
case m:
case e:
case g:
case f:
case p:
return a;
default:
switch (a = a && a.$$typeof, a) {
case k:
case n:
case t:
case r:
case h:
return a;
default:
return u;
}
}
case d:
return u;
}
}
}
function A(a) {
return z(a) === m;
}
reactIs_production_min.AsyncMode = l;
reactIs_production_min.ConcurrentMode = m;
reactIs_production_min.ContextConsumer = k;
reactIs_production_min.ContextProvider = h;
reactIs_production_min.Element = c;
reactIs_production_min.ForwardRef = n;
reactIs_production_min.Fragment = e;
reactIs_production_min.Lazy = t;
reactIs_production_min.Memo = r;
reactIs_production_min.Portal = d;
reactIs_production_min.Profiler = g;
reactIs_production_min.StrictMode = f;
reactIs_production_min.Suspense = p;
reactIs_production_min.isAsyncMode = function (a) {
return A(a) || z(a) === l;
};
reactIs_production_min.isConcurrentMode = A;
reactIs_production_min.isContextConsumer = function (a) {
return z(a) === k;
};
reactIs_production_min.isContextProvider = function (a) {
return z(a) === h;
};
reactIs_production_min.isElement = function (a) {
return "object" === typeof a && null !== a && a.$$typeof === c;
};
reactIs_production_min.isForwardRef = function (a) {
return z(a) === n;
};
reactIs_production_min.isFragment = function (a) {
return z(a) === e;
};
reactIs_production_min.isLazy = function (a) {
return z(a) === t;
};
reactIs_production_min.isMemo = function (a) {
return z(a) === r;
};
reactIs_production_min.isPortal = function (a) {
return z(a) === d;
};
reactIs_production_min.isProfiler = function (a) {
return z(a) === g;
};
reactIs_production_min.isStrictMode = function (a) {
return z(a) === f;
};
reactIs_production_min.isSuspense = function (a) {
return z(a) === p;
};
reactIs_production_min.isValidElementType = function (a) {
return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === typeof a && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
};
reactIs_production_min.typeOf = z;
var reactIs_development = {};
/** @license React v16.13.1
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (process.env.NODE_ENV !== "production") {
(function () {
// nor polyfill, then a plain number is used for performance.
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
// (unstable) APIs that have been removed. Can we remove the symbols?
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
function isValidElementType(type) {
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
}
function typeOf(object) {
if (typeof object === 'object' && object !== null) {
var $$typeof = object.$$typeof;
switch ($$typeof) {
case REACT_ELEMENT_TYPE:
var type = object.type;
switch (type) {
case REACT_ASYNC_MODE_TYPE:
case REACT_CONCURRENT_MODE_TYPE:
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
case REACT_SUSPENSE_TYPE:
return type;
default:
var $$typeofType = type && type.$$typeof;
switch ($$typeofType) {
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
case REACT_MEMO_TYPE:
case REACT_PROVIDER_TYPE:
return $$typeofType;
default:
return $$typeof;
}
}
case REACT_PORTAL_TYPE:
return $$typeof;
}
}
return undefined;
} // AsyncMode is deprecated along with isAsyncMode
var AsyncMode = REACT_ASYNC_MODE_TYPE;
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var Element = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
var Lazy = REACT_LAZY_TYPE;
var Memo = REACT_MEMO_TYPE;
var Portal = REACT_PORTAL_TYPE;
var Profiler = REACT_PROFILER_TYPE;
var StrictMode = REACT_STRICT_MODE_TYPE;
var Suspense = REACT_SUSPENSE_TYPE;
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
function isAsyncMode(object) {
{
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
}
}
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
}
function isConcurrentMode(object) {
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
}
function isContextConsumer(object) {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
function isContextProvider(object) {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
function isElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
}
function isForwardRef(object) {
return typeOf(object) === REACT_FORWARD_REF_TYPE;
}
function isFragment(object) {
return typeOf(object) === REACT_FRAGMENT_TYPE;
}
function isLazy(object) {
return typeOf(object) === REACT_LAZY_TYPE;
}
function isMemo(object) {
return typeOf(object) === REACT_MEMO_TYPE;
}
function isPortal(object) {
return typeOf(object) === REACT_PORTAL_TYPE;
}
function isProfiler(object) {
return typeOf(object) === REACT_PROFILER_TYPE;
}
function isStrictMode(object) {
return typeOf(object) === REACT_STRICT_MODE_TYPE;
}
function isSuspense(object) {
return typeOf(object) === REACT_SUSPENSE_TYPE;
}
reactIs_development.AsyncMode = AsyncMode;
reactIs_development.ConcurrentMode = ConcurrentMode;
reactIs_development.ContextConsumer = ContextConsumer;
reactIs_development.ContextProvider = ContextProvider;
reactIs_development.Element = Element;
reactIs_development.ForwardRef = ForwardRef;
reactIs_development.Fragment = Fragment;
reactIs_development.Lazy = Lazy;
reactIs_development.Memo = Memo;
reactIs_development.Portal = Portal;
reactIs_development.Profiler = Profiler;
reactIs_development.StrictMode = StrictMode;
reactIs_development.Suspense = Suspense;
reactIs_development.isAsyncMode = isAsyncMode;
reactIs_development.isConcurrentMode = isConcurrentMode;
reactIs_development.isContextConsumer = isContextConsumer;
reactIs_development.isContextProvider = isContextProvider;
reactIs_development.isElement = isElement;
reactIs_development.isForwardRef = isForwardRef;
reactIs_development.isFragment = isFragment;
reactIs_development.isLazy = isLazy;
reactIs_development.isMemo = isMemo;
reactIs_development.isPortal = isPortal;
reactIs_development.isProfiler = isProfiler;
reactIs_development.isStrictMode = isStrictMode;
reactIs_development.isSuspense = isSuspense;
reactIs_development.isValidElementType = isValidElementType;
reactIs_development.typeOf = typeOf;
})();
}
if (process.env.NODE_ENV === 'production') {
reactIs.exports = reactIs_production_min;
} else {
reactIs.exports = reactIs_development;
}
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret$3 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
var ReactPropTypesSecret_1 = ReactPropTypesSecret$3;
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var printWarning$1 = function () {};
if (process.env.NODE_ENV !== 'production') {
var ReactPropTypesSecret$2 = ReactPropTypesSecret_1;
var loggedTypeFailures = {};
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
printWarning$1 = function (text) {
var message = 'Warning: ' + text;
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
}
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param {object} typeSpecs Map of name to a ReactPropType
* @param {object} values Runtime values that need to be type-checked
* @param {string} location e.g. "prop", "context", "child context"
* @param {string} componentName Name of the component for error messages.
* @param {?Function} getStack Returns the component stack.
* @private
*/
function checkPropTypes$1(typeSpecs, values, location, componentName, getStack) {
if (process.env.NODE_ENV !== 'production') {
for (var typeSpecName in typeSpecs) {
if (has$1(typeSpecs, typeSpecName)) {
var error; // Prop type validation may throw. In case they do, we don't want to
// fail the render phase where it didn't fail before. So we log it.
// After these have been cleaned up, we'll let them throw.
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
if (typeof typeSpecs[typeSpecName] !== 'function') {
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.');
err.name = 'Invariant Violation';
throw err;
}
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$2);
} catch (ex) {
error = ex;
}
if (error && !(error instanceof Error)) {
printWarning$1((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
}
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error.message] = true;
var stack = getStack ? getStack() : '';
printWarning$1('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
}
}
}
}
}
/**
* Resets warning cache when testing.
*
* @private
*/
checkPropTypes$1.resetWarningCache = function () {
if (process.env.NODE_ENV !== 'production') {
loggedTypeFailures = {};
}
};
var checkPropTypes_1 = checkPropTypes$1;
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactIs$1 = reactIs.exports;
var assign = objectAssign;
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
var checkPropTypes = checkPropTypes_1;
var has = Function.call.bind(Object.prototype.hasOwnProperty);
var printWarning = function () {};
if (process.env.NODE_ENV !== 'production') {
printWarning = function (text) {
var message = 'Warning: ' + text;
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
}
function emptyFunctionThatReturnsNull() {
return null;
}
var factoryWithTypeCheckers = function (isValidElement, throwOnDirectAccess) {
/* global Symbol */
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
/**
* Returns the iterator method function contained on the iterable object.
*
* Be sure to invoke the function with the iterable as context:
*
* var iteratorFn = getIteratorFn(myIterable);
* if (iteratorFn) {
* var iterator = iteratorFn.call(myIterable);
* ...
* }
*
* @param {?object} maybeIterable
* @return {?function}
*/
function getIteratorFn(maybeIterable) {
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
/**
* Collection of methods that allow declaration and validation of props that are
* supplied to React components. Example usage:
*
* var Props = require('ReactPropTypes');
* var MyArticle = React.createClass({
* propTypes: {
* // An optional string prop named "description".
* description: Props.string,
*
* // A required enum prop named "category".
* category: Props.oneOf(['News','Photos']).isRequired,
*
* // A prop named "dialog" that requires an instance of Dialog.
* dialog: Props.instanceOf(Dialog).isRequired
* },
* render: function() { ... }
* });
*
* A more formal specification of how these methods are used:
*
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
* decl := ReactPropTypes.{type}(.isRequired)?
*
* Each and every declaration produces a function with the same signature. This
* allows the creation of custom validation functions. For example:
*
* var MyLink = React.createClass({
* propTypes: {
* // An optional string or URI prop named "href".
* href: function(props, propName, componentName) {
* var propValue = props[propName];
* if (propValue != null && typeof propValue !== 'string' &&
* !(propValue instanceof URI)) {
* return new Error(
* 'Expected a string or an URI for ' + propName + ' in ' +
* componentName
* );
* }
* }
* },
* render: function() {...}
* });
*
* @internal
*/
var ANONYMOUS = '<<anonymous>>'; // Important!
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
var ReactPropTypes = {
array: createPrimitiveTypeChecker('array'),
bool: createPrimitiveTypeChecker('boolean'),
func: createPrimitiveTypeChecker('function'),
number: createPrimitiveTypeChecker('number'),
object: createPrimitiveTypeChecker('object'),
string: createPrimitiveTypeChecker('string'),
symbol: createPrimitiveTypeChecker('symbol'),
any: createAnyTypeChecker(),
arrayOf: createArrayOfTypeChecker,
element: createElementTypeChecker(),
elementType: createElementTypeTypeChecker(),
instanceOf: createInstanceTypeChecker,
node: createNodeChecker(),
objectOf: createObjectOfTypeChecker,
oneOf: createEnumTypeChecker,
oneOfType: createUnionTypeChecker,
shape: createShapeTypeChecker,
exact: createStrictShapeTypeChecker
};
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
/*eslint-disable no-self-compare*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
}
/*eslint-enable no-self-compare*/
/**
* We use an Error-like object for backward compatibility as people may call
* PropTypes directly and inspect their output. However, we don't use real
* Errors anymore. We don't inspect their stack anyway, and creating them
* is prohibitively expensive if they are created too often, such as what
* happens in oneOfType() for any type before the one that matched.
*/
function PropTypeError(message) {
this.message = message;
this.stack = '';
} // Make `instanceof Error` still work for returned errors.
PropTypeError.prototype = Error.prototype;
function createChainableTypeChecker(validate) {
if (process.env.NODE_ENV !== 'production') {
var manualPropTypeCallCache = {};
var manualPropTypeWarningCount = 0;
}
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (secret !== ReactPropTypesSecret$1) {
if (throwOnDirectAccess) {
// New behavior only for users of `prop-types` package
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
err.name = 'Invariant Violation';
throw err;
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
// Old behavior for people using React.PropTypes
var cacheKey = componentName + ':' + propName;
if (!manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors
manualPropTypeWarningCount < 3) {
printWarning('You are manually calling a React.PropTypes validation ' + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.');
manualPropTypeCallCache[cacheKey] = true;
manualPropTypeWarningCount++;
}
}
}
if (props[propName] == null) {
if (isRequired) {
if (props[propName] === null) {
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
}
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
}
return null;
} else {
return validate(props, propName, componentName, location, propFullName);
}
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
function createPrimitiveTypeChecker(expectedType) {
function validate(props, propName, componentName, location, propFullName, secret) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== expectedType) {
// `propValue` being instance of, say, date/regexp, pass the 'object'
// check, but we can offer a more precise error message here rather than
// 'of type `object`'.
var preciseType = getPreciseType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createAnyTypeChecker() {
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
}
function createArrayOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
if (typeof typeChecker !== 'function') {
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
}
var propValue = props[propName];
if (!Array.isArray(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
}
for (var i = 0; i < propValue.length; i++) {
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret$1);
if (error instanceof Error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createElementTypeChecker() {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
if (!isValidElement(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createElementTypeTypeChecker() {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
if (!ReactIs$1.isValidElementType(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createInstanceTypeChecker(expectedClass) {
function validate(props, propName, componentName, location, propFullName) {
if (!(props[propName] instanceof expectedClass)) {
var expectedClassName = expectedClass.name || ANONYMOUS;
var actualClassName = getClassName(props[propName]);
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createEnumTypeChecker(expectedValues) {
if (!Array.isArray(expectedValues)) {
if (process.env.NODE_ENV !== 'production') {
if (arguments.length > 1) {
printWarning('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).');
} else {
printWarning('Invalid argument supplied to oneOf, expected an array.');
}
}
return emptyFunctionThatReturnsNull;
}
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
for (var i = 0; i < expectedValues.length; i++) {
if (is(propValue, expectedValues[i])) {
return null;
}
}
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
var type = getPreciseType(value);
if (type === 'symbol') {
return String(value);
}
return value;
});
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
}
return createChainableTypeChecker(validate);
}
function createObjectOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
if (typeof typeChecker !== 'function') {
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
}
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
}
for (var key in propValue) {
if (has(propValue, key)) {
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$1);
if (error instanceof Error) {
return error;
}
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createUnionTypeChecker(arrayOfTypeCheckers) {
if (!Array.isArray(arrayOfTypeCheckers)) {
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
return emptyFunctionThatReturnsNull;
}
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (typeof checker !== 'function') {
printWarning('Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.');
return emptyFunctionThatReturnsNull;
}
}
function validate(props, propName, componentName, location, propFullName) {
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret$1) == null) {
return null;
}
}
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
}
return createChainableTypeChecker(validate);
}
function createNodeChecker() {
function validate(props, propName, componentName, location, propFullName) {
if (!isNode(props[propName])) {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createShapeTypeChecker(shapeTypes) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
}
for (var key in shapeTypes) {
var checker = shapeTypes[key];
if (!checker) {
continue;
}
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$1);
if (error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createStrictShapeTypeChecker(shapeTypes) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
} // We need to check all keys in case some are required but missing from
// props.
var allKeys = assign({}, props[propName], shapeTypes);
for (var key in allKeys) {
var checker = shapeTypes[key];
if (!checker) {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
}
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$1);
if (error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function isNode(propValue) {
switch (typeof propValue) {
case 'number':
case 'string':
case 'undefined':
return true;
case 'boolean':
return !propValue;
case 'object':
if (Array.isArray(propValue)) {
return propValue.every(isNode);
}
if (propValue === null || isValidElement(propValue)) {
return true;
}
var iteratorFn = getIteratorFn(propValue);
if (iteratorFn) {
var iterator = iteratorFn.call(propValue);
var step;
if (iteratorFn !== propValue.entries) {
while (!(step = iterator.next()).done) {
if (!isNode(step.value)) {
return false;
}
}
} else {
// Iterator will provide entry [k,v] tuples rather than values.
while (!(step = iterator.next()).done) {
var entry = step.value;
if (entry) {
if (!isNode(entry[1])) {
return false;
}
}
}
}
} else {
return false;
}
return true;
default:
return false;
}
}
function isSymbol(propType, propValue) {
// Native Symbol.
if (propType === 'symbol') {
return true;
} // falsy value can't be a Symbol
if (!propValue) {
return false;
} // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
if (propValue['@@toStringTag'] === 'Symbol') {
return true;
} // Fallback for non-spec compliant Symbols which are polyfilled.
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
return true;
}
return false;
} // Equivalent of `typeof` but with special handling for array and regexp.
function getPropType(propValue) {
var propType = typeof propValue;
if (Array.isArray(propValue)) {
return 'array';
}
if (propValue instanceof RegExp) {
// Old webkits (at least until Android 4.0) return 'function' rather than
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
// passes PropTypes.object.
return 'object';
}
if (isSymbol(propType, propValue)) {
return 'symbol';
}
return propType;
} // This handles more types than `getPropType`. Only used for error messages.
// See `createPrimitiveTypeChecker`.
function getPreciseType(propValue) {
if (typeof propValue === 'undefined' || propValue === null) {
return '' + propValue;
}
var propType = getPropType(propValue);
if (propType === 'object') {
if (propValue instanceof Date) {
return 'date';
} else if (propValue instanceof RegExp) {
return 'regexp';
}
}
return propType;
} // Returns a string that is postfixed to a warning about an invalid type.
// For example, "undefined" or "of type array"
function getPostfixForTypeWarning(value) {
var type = getPreciseType(value);
switch (type) {
case 'array':
case 'object':
return 'an ' + type;
case 'boolean':
case 'date':
case 'regexp':
return 'a ' + type;
default:
return type;
}
} // Returns class name of the object, if any.
function getClassName(propValue) {
if (!propValue.constructor || !propValue.constructor.name) {
return ANONYMOUS;
}
return propValue.constructor.name;
}
ReactPropTypes.checkPropTypes = checkPropTypes;
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = ReactPropTypesSecret_1;
function emptyFunction() {}
function emptyFunctionWithReset() {}
emptyFunctionWithReset.resetWarningCache = emptyFunction;
var factoryWithThrowingShims = function () {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret) {
// It is still safe when called from React.
return;
}
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
err.name = 'Invariant Violation';
throw err;
}
shim.isRequired = shim;
function getShim() {
return shim;
}
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
var ReactPropTypes = {
array: shim,
bool: shim,
func: shim,
number: shim,
object: shim,
string: shim,
symbol: shim,
any: shim,
arrayOf: getShim,
element: shim,
elementType: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim,
checkPropTypes: emptyFunctionWithReset,
resetWarningCache: emptyFunction
};
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (process.env.NODE_ENV !== 'production') {
var ReactIs = reactIs.exports; // By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
propTypes.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
propTypes.exports = factoryWithThrowingShims();
}
var PropTypes = propTypes.exports;
var MASK_PROPS = {
// common
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.string, PropTypes.instanceOf(RegExp), PropTypes.oneOf([Date, Number, IMask.Masked]), PropTypes.instanceOf(IMask.Masked)]),
value: PropTypes.any,
unmask: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['typed'])]),
prepare: PropTypes.func,
validate: PropTypes.func,
commit: PropTypes.func,
overwrite: PropTypes.bool,
// events
onAccept: PropTypes.func,
onComplete: PropTypes.func,
// pattern
placeholderChar: PropTypes.string,
lazy: PropTypes.bool,
definitions: PropTypes.object,
blocks: PropTypes.object,
// date
pattern: PropTypes.string,
format: PropTypes.func,
parse: PropTypes.func,
autofix: PropTypes.bool,
// number
radix: PropTypes.string,
thousandsSeparator: PropTypes.string,
mapToRadix: PropTypes.arrayOf(PropTypes.string),
scale: PropTypes.number,
signed: PropTypes.bool,
normalizeZeros: PropTypes.bool,
padFractionalZeros: PropTypes.bool,
min: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)]),
max: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)]),
// dynamic
dispatch: PropTypes.func,
// ref
inputRef: PropTypes.func
};
var MASK_PROPS_NAMES = Object.keys(MASK_PROPS);
var NON_MASK_OPTIONS_PROPS_NAMES = ['value', 'unmask', 'onAccept', 'onComplete', 'inputRef'];
var MASK_OPTIONS_PROPS_NAMES = MASK_PROPS_NAMES.filter(function (pName) {
return NON_MASK_OPTIONS_PROPS_NAMES.indexOf(pName) < 0;
});
function IMaskMixin(ComposedComponent) {
var MaskedComponent = /*#__PURE__*/function (_React$Component) {
_inherits(MaskedComponent, _React$Component);
var _super = _createSuper(MaskedComponent);
function MaskedComponent(props) {
var _this;
_classCallCheck(this, MaskedComponent);
_this = _super.call(this, props);
_this._inputRef = _this._inputRef.bind(_assertThisInitialized(_this));
return _this;
}
_createClass(MaskedComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
if (!this.props.mask) return;
this.initMask();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
var props = this.props;
var maskOptions = this._extractMaskOptionsFromProps(props);
if (maskOptions.mask) {
if (this.maskRef) {
this.maskRef.updateOptions(maskOptions); // TODO
if ('value' in props && (props.value !== this.maskValue || // handle cases like Number('') === 0,
// for details see https://github.com/uNmAnNeR/imaskjs/issues/134
typeof props.value !== 'string' && this.maskRef.value === '' && !this.maskRef.el.isActive)) {
this.maskValue = props.value;
}
} else {
this.initMask(maskOptions); // TODO
}
} else {
this.destroyMask();
if ('value' in props) this.element.value = props.value;
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.destroyMask();
}
}, {
key: "_inputRef",
value: function _inputRef(el) {
this.element = el;
if (this.props.inputRef) this.props.inputRef(el);
}
}, {
key: "initMask",
value: function initMask() {
var maskOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._extractMaskOptionsFromProps(this.props);
this.maskRef = IMask(this.element, maskOptions).on('accept', this._onAccept.bind(this)).on('complete', this._onComplete.bind(this));
if ('value' in this.props) this.maskValue = this.props.value;
}
}, {
key: "destroyMask",
value: function destroyMask() {
if (this.maskRef) {
this.maskRef.destroy();
delete this.maskRef;
}
}
}, {
key: "_extractMaskOptionsFromProps",
value: function _extractMaskOptionsFromProps(props) {
var cloneProps = Object.assign({}, props); // keep only mask options props
Object.keys(cloneProps).filter(function (prop) {
return MASK_OPTIONS_PROPS_NAMES.indexOf(prop) < 0;
}).forEach(function (nonMaskProp) {
delete cloneProps[nonMaskProp];
});
return cloneProps;
}
}, {
key: "_extractNonMaskProps",
value: function _extractNonMaskProps(props) {
var cloneProps = Object.assign({}, props);
MASK_PROPS_NAMES.forEach(function (maskProp) {
delete cloneProps[maskProp];
});
return cloneProps;
}
}, {
key: "maskValue",
get: function get() {
if (this.props.unmask === 'typed') return this.maskRef.typedValue;
if (this.props.unmask) return this.maskRef.unmaskedValue;
return this.maskRef.value;
},
set: function set(value) {
value = value == null ? '' : value;
if (this.props.unmask === 'typed') this.maskRef.typedValue = value;else if (this.props.unmask) this.maskRef.unmaskedValue = value;else this.maskRef.value = value;
}
}, {
key: "_onAccept",
value: function _onAccept(e) {
if (this.props.onAccept) this.props.onAccept(this.maskValue, this.maskRef, e);
}
}, {
key: "_onComplete",
value: function _onComplete(e) {
if (this.props.onComplete) this.props.onComplete(this.maskValue, this.maskRef, e);
}
}, {
key: "render",
value: function render() {
return React.createElement(ComposedComponent, Object.assign({}, this._extractNonMaskProps(this.props), {
inputRef: this._inputRef
}));
}
}]);
return MaskedComponent;
}(React.Component);
var nestedComponentName = ComposedComponent.displayName || ComposedComponent.name || 'Component';
MaskedComponent.displayName = "IMask(".concat(nestedComponentName, ")");
MaskedComponent.propTypes = MASK_PROPS;
return MaskedComponent;
}
export { IMaskMixin as default };
export { I as default } from './mixin-9a4bc4a3.js';
import 'react';
import 'prop-types';
import 'imask/esm/imask';

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "6.2.1",
"version": "6.2.2",
"homepage": "https://imask.js.org/",

@@ -32,3 +32,3 @@ "description": "React input mask",

},
"gitHead": "9852bddc1907436738426467d5b007811a10fd52",
"gitHead": "739725825cbe3de18e254fcbd269295418e2f588",
"devDependencies": {

@@ -35,0 +35,0 @@ "@types/react": "^17.0.15",

@@ -16,3 +16,3 @@ # React IMask Plugin

```javascript
import {IMaskInput} from 'react-imask';
import { IMaskInput } from 'react-imask';

@@ -43,3 +43,3 @@ <IMaskInput

```javascript
import {IMaskMixin} from 'react-imask';
import { IMaskMixin } from 'react-imask';

@@ -69,2 +69,17 @@ // extend style component

## Using hook
```javascript
import { useState } from 'react';
import { useIMask } from 'react-imask';
function IMaskWithHook () {
const [ opts, setOpts ] = useState({ mask: Number });
const { ref, maskRef } = useIMask(opts);
return (
<input ref={ref} />
);
}
```
## Many Thanks to

@@ -71,0 +86,0 @@ [@Yordis Prieto](https://github.com/yordis)

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