react-input-mask-format 1.0.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).ReactInputMask=t(e.React)}(this,(function(e){"use strict";var t="default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,function(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;r<n.length;r++){var o=n[r],i=Object.getOwnPropertyDescriptor(t,o);i&&i.configurable&&void 0===e[o]&&Object.defineProperty(e,o,i)}}(e,t)}function o(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e,t){return e(t={exports:{}},t.exports),t.exports}var u=a((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,o=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,a=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,l=n?Symbol.for("react.provider"):60109,s=n?Symbol.for("react.context"):60110,c=n?Symbol.for("react.async_mode"):60111,f=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,p=n?Symbol.for("react.suspense"):60113,h=n?Symbol.for("react.memo"):60115,m=n?Symbol.for("react.lazy"):60116;function g(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case c:case f:case i:case u:case a:case p:return e;default:switch(e=e&&e.$$typeof){case s:case d:case l:return e;default:return t}}case m:case h:case o:return t}}}function v(e){return g(e)===f}t.typeOf=g,t.AsyncMode=c,t.ConcurrentMode=f,t.ContextConsumer=s,t.ContextProvider=l,t.Element=r,t.ForwardRef=d,t.Fragment=i,t.Lazy=m,t.Memo=h,t.Portal=o,t.Profiler=u,t.StrictMode=a,t.Suspense=p,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===f||e===u||e===a||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===h||e.$$typeof===l||e.$$typeof===s||e.$$typeof===d)},t.isAsyncMode=function(e){return v(e)||g(e)===c},t.isConcurrentMode=v,t.isContextConsumer=function(e){return g(e)===s},t.isContextProvider=function(e){return g(e)===l},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return g(e)===d},t.isFragment=function(e){return g(e)===i},t.isLazy=function(e){return g(e)===m},t.isMemo=function(e){return g(e)===h},t.isPortal=function(e){return g(e)===o},t.isProfiler=function(e){return g(e)===u},t.isStrictMode=function(e){return g(e)===a},t.isSuspense=function(e){return g(e)===p}}));i(u);u.typeOf,u.AsyncMode,u.ConcurrentMode,u.ContextConsumer,u.ContextProvider,u.Element,u.ForwardRef,u.Fragment,u.Lazy,u.Memo,u.Portal,u.Profiler,u.StrictMode,u.Suspense,u.isValidElementType,u.isAsyncMode,u.isConcurrentMode,u.isContextConsumer,u.isContextProvider,u.isElement,u.isForwardRef,u.isFragment,u.isLazy,u.isMemo,u.isPortal,u.isProfiler,u.isStrictMode,u.isSuspense;var l=a((function(){}));i(l);l.typeOf,l.AsyncMode,l.ConcurrentMode,l.ContextConsumer,l.ContextProvider,l.Element,l.ForwardRef,l.Fragment,l.Lazy,l.Memo,l.Portal,l.Profiler,l.StrictMode,l.Suspense,l.isValidElementType,l.isAsyncMode,l.isConcurrentMode,l.isContextConsumer,l.isContextProvider,l.isElement,l.isForwardRef,l.isFragment,l.isLazy,l.isMemo,l.isPortal,l.isProfiler,l.isStrictMode,l.isSuspense,a((function(e){e.exports=u}));var s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;function d(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign,Function.call.bind(Object.prototype.hasOwnProperty);function p(){}function h(){}h.resetWarningCache=p;a((function(e){e.exports=function(){function e(e,t,n,r,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var a=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");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:h,resetWarningCache:p};return n.PropTypes=n,n}()}));function m(e){return requestAnimationFrame(e)}function g(e){cancelAnimationFrame(e)}function v(e){var t=e.ownerDocument;return t.hasFocus()&&t.activeElement===e}function y(e){return null==e?void 0:e.ownerDocument}function b(e){var t=function(e){var t;return null==(t=y(e))?void 0:t.defaultView}(e);return!!t&&e instanceof t.HTMLElement}function P(t){return e.useCallback((function(){var e=t.current,n="undefined"!=typeof window&&b(e);if(!e||!n)return null;if("INPUT"!==e.nodeName&&(e=e.querySelector("input")),!e)throw new Error("react-input-mask: inputComponent doesn't contain input node");return e}),[t])}function S(t,n){var r,o,i,a,u=e.useRef({start:null,end:null}),l=P(t),s=e.useCallback((function(){return function(e){var t=e.selectionStart,n=e.selectionEnd;return{start:t,end:n,length:n-t}}(l())}),[l]),c=e.useCallback((function(){return u.current}),[]),f=e.useCallback((function(e){var t=l();t&&v(t)&&(!function(e,t,n){void 0===n&&(n=t),e.setSelectionRange(t,n)}(t,e.start,e.end),u.current=s())}),[l,s]),d=e.useCallback((function(){u.current=s()}),[s]),p=(r=d,o=e.useRef(null),i=e.useCallback((function(){null===o.current&&function e(){r(),o.current=m(e)}()}),[r]),a=e.useCallback((function(){g(o.current),o.current=null}),[]),e.useEffect((function(){o.current&&(a(),i())}),[i,a]),e.useEffect(g,[]),[i,a]),h=p[0],y=p[1];return e.useLayoutEffect((function(){if(n){var e=l();return e.addEventListener("focus",h),e.addEventListener("blur",y),v(e)&&h(),function(){e.removeEventListener("focus",h),e.removeEventListener("blur",y),y()}}})),{getSelection:s,getLastSelection:c,setSelection:f}}function E(t,n){var r=e.useRef(),o=S(r,n),i=o.getSelection,a=o.getLastSelection,u=o.setSelection,l=function(t,n){var r=P(t),o=e.useRef(n);return{getValue:e.useCallback((function(){return r().value}),[r]),getLastValue:e.useCallback((function(){return o.current}),[]),setValue:e.useCallback((function(e){o.current=e;var t=r();t&&(t.value=e)}),[r])}}(r,t),s=l.getValue,c=l.getLastValue,f=l.setValue;return{inputRef:r,getInputState:function(){return{value:s(),selection:i()}},getLastInputState:function(){return{value:c(),selection:a()}},setInputState:function(e){var t=e.value,n=e.selection;f(t),u(n)}}}var C=function(e,t,n,r,o,i,a,u){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,o,i,a,u],c=0;(l=new Error(t.replace(/%s/g,(function(){return s[c++]})))).name="Invariant Violation"}throw l.framesToPop=1,l}},k=["disabled","onBlur","onChange","onFocus","onMouseDown","readOnly","value"],O={9:/[0-9]/,a:/[A-Za-z]/,"*":/[A-Za-z0-9]/};var w=function(e){var t=this;this.isCharacterAllowedAtPosition=function(e,n){var r=t.maskOptions.maskPlaceholder;return!!t.isCharacterFillingPosition(e,n)||!!r&&r[n]===e},this.isCharacterFillingPosition=function(e,n){var r=t.maskOptions.mask;if(!e||n>=r.length)return!1;if(!t.isPositionEditable(n))return r[n]===e;var o=r[n];return new RegExp(o).test(e)},this.isPositionEditable=function(e){var n=t.maskOptions,r=n.mask,o=n.permanents;return e<r.length&&-1===o.indexOf(e)},this.isValueEmpty=function(e){return e.split("").every((function(e,n){return!t.isPositionEditable(n)||!t.isCharacterFillingPosition(e,n)}))},this.isValueFilled=function(e){return t.getFilledLength(e)===t.maskOptions.lastEditablePosition+1},this.getDefaultSelectionForValue=function(e){var n=t.getFilledLength(e),r=t.getRightEditablePosition(n);return{start:r,end:r}},this.getFilledLength=function(e){return function(e,t){for(var n=e.length-1;n>=0;n--){if(t(e[n],n))return n}return-1}(e.split(""),(function(e,n){return t.isPositionEditable(n)&&t.isCharacterFillingPosition(e,n)}))+1},this.getStringFillingLengthAtPosition=function(e,n){return e.split("").reduce((function(e,n){return t.insertCharacterAtPosition(e,n,e.length)}),function(e,t){void 0===t&&(t=1);for(var n="",r=0;r<t;r++)n+=e;return n}(" ",n)).length-n},this.getLeftEditablePosition=function(e){for(var n=e;n>=0;n--)if(t.isPositionEditable(n))return n;return null},this.getRightEditablePosition=function(e){for(var n=t.maskOptions.mask,r=e;r<n.length;r++)if(t.isPositionEditable(r))return r;return null},this.formatValue=function(e){var n=t.maskOptions,r=n.maskPlaceholder,o=n.mask;if(!r){for(e=t.insertStringAtPosition("",e,0);e.length<o.length&&!t.isPositionEditable(e.length);)e+=o[e.length];return e}return t.insertStringAtPosition(r,e,0)},this.clearRange=function(e,n,r){if(!r)return e;var o=n+r,i=t.maskOptions,a=i.maskPlaceholder,u=i.mask,l=e.split("").map((function(e,r){var i=t.isPositionEditable(r);return!a&&r>=o&&!i?"":r<n||r>=o?e:i?a?a[r]:"":u[r]})).join("");return t.formatValue(l)},this.insertCharacterAtPosition=function(e,n,r){var o=t.maskOptions,i=o.mask,a=o.maskPlaceholder;if(r>=i.length)return e;var u=t.isCharacterAllowedAtPosition(n,r),l=t.isPositionEditable(r),s=t.getRightEditablePosition(r),c=a&&s?n===a[s]:null,f=e.slice(0,r);!u&&l||(e=f+(u?n:i[r]));return u||l||c||(e=t.insertCharacterAtPosition(e,n,r+1)),e},this.insertStringAtPosition=function(e,n,r){var o=t.maskOptions,i=o.mask,a=o.maskPlaceholder;if(!n||r>=i.length)return e;var u=n.split(""),l=t.isValueFilled(e)||!!a,s=e.slice(r);if(e=u.reduce((function(e,n){return t.insertCharacterAtPosition(e,n,e.length)}),e.slice(0,r)),l)e+=s.slice(e.length-r);else if(t.isValueFilled(e))e+=i.slice(e.length).join("");else{e=s.split("").filter((function(e,n){return t.isPositionEditable(r+n)})).reduce((function(e,n){var r=t.getRightEditablePosition(e.length);return null===r?e:(t.isPositionEditable(e.length)||(e+=i.slice(e.length,r).join("")),t.insertCharacterAtPosition(e,n,e.length))}),e)}return e},this.processChange=function(e,n){var r=t.maskOptions,o=r.mask,i=r.prefix,a=r.lastEditablePosition,u=e.value,l=e.selection,s=n.value,c=n.selection,f=u,d="",p=0,h=0,m=Math.min(c.start,l.start);if(l.end>c.start?(d=f.slice(c.start,l.end),h=(p=t.getStringFillingLengthAtPosition(d,m))?c.length:0):f.length<s.length&&(h=s.length-f.length),f=s,h){if(1===h&&!c.length)m=c.start===l.start?t.getRightEditablePosition(l.start):t.getLeftEditablePosition(l.start);f=t.clearRange(f,m,h)}return f=t.insertStringAtPosition(f,d,m),(m+=p)>=o.length?m=o.length:m<i.length&&!p?m=i.length:m>=i.length&&m<a&&p&&(m=t.getRightEditablePosition(m)),{value:f=t.formatValue(f),enteredString:d,selection:{start:m,end:m}}},this.maskOptions=function(e){var t=e.mask,n=e.maskPlaceholder,r=[];if(!t)return{maskPlaceholder:null,mask:null,prefix:null,lastEditablePosition:null,permanents:[]};if("string"==typeof t){var o=!1,i="";t.split("").forEach((function(e){o||"\\"!==e?(!o&&O[e]||r.push(i.length),i+=e,o=!1):o=!0})),t=i.split("").map((function(e,t){return-1===r.indexOf(t)?O[e]:e}))}else t.forEach((function(e,t){"string"==typeof e&&r.push(t)}));n&&(n=1===n.length?t.map((function(e,t){return-1!==r.indexOf(t)?e:n})):n.split(""),r.forEach((function(e){n[e]=t[e]})),n=n.join(""));for(var a=r.filter((function(e,t){return e===t})).map((function(e){return t[e]})).join(""),u=t.length-1;-1!==r.indexOf(u);)u--;return{maskPlaceholder:n,prefix:a,mask:t,lastEditablePosition:u,permanents:r}}(e)},M=function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),n.prototype.render=function(){var e=this.props,n=e.children,r=o(e,["children"]);return t.cloneElement(n,r)},n}(t.Component),F=e.forwardRef((function(r,i){var a=r.alwaysShowMask,u=r.children,l=r.mask,s=r.maskPlaceholder,c=r.beforeMaskedStateChange,f=o(r,["alwaysShowMask","children","mask","maskPlaceholder","beforeMaskedStateChange"]);!function(e){var t=e.mask,n=e.maskPlaceholder;t&&n&&1!==n.length&&n.length!==t.length&&C(!1)}(r);var d,p,h=new w({mask:l,maskPlaceholder:s}),g=!!l,b=!f.disabled&&!f.readOnly,S=null!==r.value&&void 0!==r.value,O=(d=g,p=e.useRef(),e.useEffect((function(){p.current=d})),p.current),F=E(function(e){return""+e}((S?r.value:r.defaultValue)||""),g),j=F.inputRef,x=F.getInputState,R=F.setInputState,V=F.getLastInputState,L=P(j);if(g&&S){var A=L(),T=A&&v(A)||a||r.value?h.formatValue(r.value):r.value;c&&(T=c({nextState:{value:T,selection:{start:null,end:null}}}).value),R(n({},V(),{value:T}))}var _=V(),D=_.selection,$=_.value;e.useLayoutEffect((function(){if(g){var e=v(L()),t=D,r=x(),o=n({},r);if(!S){var i=r.value,u=h.formatValue(i),l=h.isValueEmpty(u);!l||e||a?o.value=u:l&&!e&&(o.value="")}e&&!O?o.selection=h.getDefaultSelectionForValue(o.value):S&&e&&t&&null!==t.start&&null!==t.end&&(o.selection=t),c&&(o=c({currentState:r,nextState:o})),R(o)}}));var I=n({},f,{onFocus:function(e){j.current=e.target;var t=x().value;if(g&&!h.isValueFilled(t)){var n=h.formatValue(t),o=h.getDefaultSelectionForValue(n),i={value:n,selection:o};c&&(n=(i=c({currentState:x(),nextState:i})).value,o=i.selection),R(i),n!==t&&r.onChange&&r.onChange(e),m((function(){R(V())}))}r.onFocus&&r.onFocus(e)},onBlur:function(e){var t=x().value,n=V().value;if(g&&!a&&h.isValueEmpty(n)){var o="",i={value:o,selection:{start:null,end:null}};c&&(o=(i=c({currentState:x(),nextState:i})).value),R(i),o!==t&&r.onChange&&r.onChange(e)}r.onBlur&&r.onBlur(e)},onChange:g&&b?function(e){var t=x(),n=V(),o=h.processChange(t,n);c&&(o=c({currentState:t,previousState:n,nextState:o})),R(o),r.onChange&&r.onChange(e)}:r.onChange,onMouseDown:g&&b?function(e){var t=L(),o=x().value,i=y(t);if(!v(t)&&!h.isValueFilled(o)){var a=e.clientX,u=e.clientY,l=(new Date).getTime();i.addEventListener("mouseup",(function e(r){if(i.removeEventListener("mouseup",e),v(t)){var o=Math.abs(r.clientX-a),s=Math.abs(r.clientY-u),c=Math.max(o,s),f=(new Date).getTime()-l;if(c<=10&&f<=200||c<=5&&f<=300){var d=V(),p=n({},d,{selection:h.getDefaultSelectionForValue(d.value)});R(p)}}}))}r.onMouseDown&&r.onMouseDown(e)}:r.onMouseDown,ref:function(e){j.current=e,!function(e){return"function"==typeof e}(i)?null!==i&&"object"==typeof i&&(i.current=e):i(e)},value:g&&S?$:r.value});return u?(function(e,t){k.filter((function(n){return null!=t.props[n]&&t.props[n]!==e[n]})).length&&C(!1)}(r,u),t.createElement(M,I,u)):t.createElement("input",I)}));return F.displayName="InputMask",F.defaultProps={alwaysShowMask:!1,maskPlaceholder:"_"},F}));
package/index.js DELETED
@@ -1,7 +0,0 @@
1
- /* eslint-disable import/no-unresolved */
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./lib/react-input-mask.production.min.js");
5
- } else {
6
- module.exports = require("./lib/react-input-mask.development.js");
7
- }