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 2.1.0 to 2.2.0

35

dist/react-imask.js

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

value: function componentDidMount() {
if (!this.props.mask) return;
this.initMask();

@@ -118,5 +120,16 @@ }

key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(props) {
this.maskRef.updateOptions(this._extractOptionsFromProps(_extends({}, props)));
this.maskValue = props.value;
value: function componentWillReceiveProps(nextProps) {
var props = _extends({}, this.props, nextProps);
var maskOptions = this._extractOptionsFromProps(props);
if (maskOptions.mask) {
if (this.maskRef) {
this.maskRef.updateOptions(maskOptions);
if ('value' in props) this.maskValue = props.value;
} else {
this.initMask(maskOptions);
}
} else {
this.destroyMask();
if ('value' in props) this.element.value = props.value;
}
}

@@ -126,3 +139,3 @@ }, {

value: function componentWillUnmount() {
this.maskRef.destroy();
this.destroyMask();
}

@@ -144,7 +157,17 @@ }, {

value: function initMask() {
this.maskRef = new IMask(this.element, this._extractOptionsFromProps(_extends({}, this.props))).on('accept', this._onAccept.bind(this)).on('complete', this._onComplete.bind(this));
var maskOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._extractOptionsFromProps(_extends({}, 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',
value: function destroyMask() {
if (this.maskRef) {
this.maskRef.destroy();
delete this.maskRef;
}
}
}, {
key: '_extractOptionsFromProps',

@@ -202,3 +225,3 @@ value: function _extractOptionsFromProps(props) {

// common
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.string, PropTypes.instanceOf(RegExp), PropTypes.oneOf([Date, Number, IMask.Masked]), PropTypes.instanceOf(IMask.Masked)]).isRequired,
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.string, PropTypes.instanceOf(RegExp), PropTypes.oneOf([Date, Number, IMask.Masked]), PropTypes.instanceOf(IMask.Masked)]),
value: PropTypes.string,

@@ -205,0 +228,0 @@ unmask: PropTypes.bool,

2

package.json
{
"name": "react-imask",
"version": "2.1.0",
"version": "2.2.0",
"description": "React input mask",

@@ -5,0 +5,0 @@ "main": "dist/react-imask.js",

@@ -10,12 +10,25 @@ import React from 'react';

componentDidMount () {
if (!this.props.mask) return;
this.initMask();
}
componentWillReceiveProps (props) {
this.maskRef.updateOptions(this._extractOptionsFromProps({...props}));
this.maskValue = props.value;
componentWillReceiveProps (nextProps) {
const props = {...this.props, ...nextProps};
const maskOptions = this._extractOptionsFromProps(props);
if (maskOptions.mask) {
if (this.maskRef) {
this.maskRef.updateOptions(maskOptions);
if ('value' in props) this.maskValue = props.value;
} else {
this.initMask(maskOptions);
}
} else {
this.destroyMask();
if ('value' in props) this.element.value = props.value;
}
}
componentWillUnmount () {
this.maskRef.destroy();
this.destroyMask();
}

@@ -31,4 +44,4 @@

initMask () {
this.maskRef = new IMask(this.element, this._extractOptionsFromProps({...this.props}))
initMask (maskOptions=this._extractOptionsFromProps({...this.props})) {
this.maskRef = new IMask(this.element, maskOptions)
.on('accept', this._onAccept.bind(this))

@@ -40,2 +53,9 @@ .on('complete', this._onComplete.bind(this));

destroyMask () {
if (this.maskRef) {
this.maskRef.destroy();
delete this.maskRef;
}
}
_extractOptionsFromProps (props) {

@@ -97,3 +117,3 @@ props = {...props};

PropTypes.instanceOf(IMask.Masked),
]).isRequired,
]),
value: PropTypes.string,

@@ -100,0 +120,0 @@ unmask: PropTypes.bool,

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