Socket
Socket
Sign inDemoInstall

react-imask

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-imask - npm Package Compare versions

Comparing version 3.4.0 to 4.0.0

226

dist/react-imask.js

@@ -11,43 +11,61 @@ (function (global, factory) {

var classCallCheck = function (instance, Constructor) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
}
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var _extends = Object.assign || function (target) {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var inherits = function (subClass, superClass) {
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
throw new TypeError("Super expression must either be null or a function");
}

@@ -58,3 +76,2 @@

value: subClass,
enumerable: false,
writable: true,

@@ -64,25 +81,73 @@ configurable: true

});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
if (superClass) _setPrototypeOf(subClass, superClass);
}
var objectWithoutProperties = function (obj, keys) {
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
var MASK_PROPS = {

@@ -96,7 +161,5 @@ // common

commit: PropTypes.func,
// events
onAccept: PropTypes.func,
onComplete: PropTypes.func,
// pattern

@@ -106,4 +169,3 @@ placeholderChar: PropTypes.string,

definitions: PropTypes.object,
groups: PropTypes.object,
blocks: PropTypes.object,
// date

@@ -113,3 +175,2 @@ pattern: PropTypes.string,

parse: PropTypes.func,
// number

@@ -125,30 +186,31 @@ radix: PropTypes.string,

max: PropTypes.number,
// dynamic
dispatch: PropTypes.func
};
var MASK_PROPS_NAMES = Object.keys(MASK_PROPS);
function IMaskMixin(ComposedComponent) {
var MaskedComponent = function (_React$Component) {
inherits(MaskedComponent, _React$Component);
var MaskedComponent =
/*#__PURE__*/
function (_React$Component) {
_inherits(MaskedComponent, _React$Component);
function MaskedComponent() {
classCallCheck(this, MaskedComponent);
return possibleConstructorReturn(this, (MaskedComponent.__proto__ || Object.getPrototypeOf(MaskedComponent)).apply(this, arguments));
_classCallCheck(this, MaskedComponent);
return _possibleConstructorReturn(this, _getPrototypeOf(MaskedComponent).apply(this, arguments));
}
createClass(MaskedComponent, [{
key: 'componentDidMount',
_createClass(MaskedComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
if (!this.props.mask) return;
this.initMask();
}
}, {
key: 'componentWillReceiveProps',
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(nextProps) {
var props = _extends({}, this.props, nextProps);
var props = _objectSpread({}, this.props, nextProps);
var maskOptions = this._extractOptionsFromProps(props);
if (maskOptions.mask) {

@@ -167,3 +229,3 @@ if (this.maskRef) {

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -173,10 +235,10 @@ this.destroyMask();

}, {
key: 'render',
key: "render",
value: function render() {
var _this2 = this;
var _this = this;
return React.createElement(ComposedComponent, _extends({}, this._extractNonMaskProps(this.props), {
return React.createElement(ComposedComponent, _objectSpread({}, this._extractNonMaskProps(this.props), {
defaultValue: this.props.value,
inputRef: function inputRef(el) {
return _this2.element = el;
return _this.element = el;
}

@@ -186,12 +248,10 @@ }));

}, {
key: 'initMask',
key: "initMask",
value: function initMask() {
var maskOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._extractOptionsFromProps(_extends({}, this.props));
var maskOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._extractOptionsFromProps(_objectSpread({}, this.props));
this.maskRef = new IMask(this.element, maskOptions).on('accept', this._onAccept.bind(this)).on('complete', this._onComplete.bind(this));
this.maskValue = this.props.value;
}
}, {
key: 'destroyMask',
key: "destroyMask",
value: function destroyMask() {

@@ -204,7 +264,6 @@ if (this.maskRef) {

}, {
key: '_extractOptionsFromProps',
key: "_extractOptionsFromProps",
value: function _extractOptionsFromProps(props) {
props = _extends({}, props);
props = _objectSpread({}, props); // keep only mask props
// keep only mask props
Object.keys(props).filter(function (prop) {

@@ -215,21 +274,17 @@ return MASK_PROPS_NAMES.indexOf(prop) < 0;

});
delete props.value;
delete props.unmask;
return props;
}
}, {
key: '_extractNonMaskProps',
key: "_extractNonMaskProps",
value: function _extractNonMaskProps(props) {
props = _extends({}, props);
props = _objectSpread({}, props);
MASK_PROPS_NAMES.forEach(function (maskProp) {
delete props[maskProp];
});
return props;
}
}, {
key: '_onAccept',
key: "_onAccept",
value: function _onAccept() {

@@ -239,3 +294,3 @@ if (this.props.onAccept) this.props.onAccept(this.maskValue, this.maskRef);

}, {
key: '_onComplete',
key: "_onComplete",
value: function _onComplete() {

@@ -245,4 +300,4 @@ if (this.props.onComplete) this.props.onComplete(this.maskValue, this.maskRef);

}, {
key: 'maskValue',
get: function get$$1() {
key: "maskValue",
get: function get() {
if (this.props.unmask === 'typed') return this.maskRef.typedValue;

@@ -252,3 +307,3 @@ if (this.props.unmask) return this.maskRef.unmaskedValue;

},
set: function set$$1(value) {
set: function set(value) {
value = value || '';

@@ -258,9 +313,9 @@ if (this.props.unmask === 'typed') this.maskRef.typedValue = value;else if (this.props.unmask) this.maskRef.unmaskedValue = value;else this.maskRef.value = value;

}]);
return MaskedComponent;
}(React.Component);
MaskedComponent.propTypes = MASK_PROPS;
var nestedComponentName = ComposedComponent.displayName || ComposedComponent.name || 'Component';
MaskedComponent.displayName = 'IMask(' + nestedComponentName + ')';
MaskedComponent.displayName = "IMask(".concat(nestedComponentName, ")");
return MaskedComponent;

@@ -271,4 +326,5 @@ }

var inputRef = _ref.inputRef,
props = objectWithoutProperties(_ref, ['inputRef']);
return React.createElement('input', _extends({}, props, {
props = _objectWithoutProperties(_ref, ["inputRef"]);
return React.createElement('input', _objectSpread({}, props, {
ref: inputRef

@@ -275,0 +331,0 @@ }));

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

"license": "MIT",
"version": "3.4.0",
"version": "4.0.0",
"homepage": "https://unmanner.github.io/imaskjs/",

@@ -8,0 +8,0 @@ "description": "React input mask",

@@ -32,3 +32,3 @@ import React from 'react';

definitions: PropTypes.object,
groups: PropTypes.object,
blocks: PropTypes.object,

@@ -35,0 +35,0 @@ // date

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc