Socket
Socket
Sign inDemoInstall

vanilla-text-mask

Package Overview
Dependencies
0
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.3 to 4.0.0

2

dist/vanillaTextMask.js

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

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.vanillaTextMask=r():e.vanillaTextMask=r()}(this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var r=e.inputElement,t=(0,u.default)(e),n=function(e){var r=e.target.value;return t.update(r)};return r.addEventListener("input",n),t.update(r.value),{textMaskInputElement:t,destroy:function(){r.removeEventListener("input",n)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.conformToMask=void 0,r.maskInput=o;var i=t(2);Object.defineProperty(r,"conformToMask",{enumerable:!0,get:function(){return n(i).default}});var a=t(5),u=n(a);r.default=o},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.placeholderChar="_"},function(e,r,t){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.guide,u=void 0===n||n,l=t.previousConformedValue,s=void 0===l?a:l,f=t.placeholderChar,d=void 0===f?i.placeholderChar:f,c=t.placeholder,p=void 0===c?(0,o.convertMaskToPlaceholder)(r,d):c,v=t.currentCaretPosition,h=t.keepCharPositions,m=u===!1&&void 0!==s,g=e.length,y=s.length,C=p.length,b=r.length,x=g-y,k=x>0,P=v+(k?-x:0),O=P+Math.abs(x);if(h===!0&&!k){for(var T=a,M=P;M<O;M++)p[M]===d&&(T+=d);e=e.slice(0,P)+T+e.slice(P,g)}for(var _=e.split(a).map(function(e,r){return{char:e,isNew:r>=P&&r<O}}),j=g-1;j>=0;j--){var w=_[j].char;if(w!==d){var S=j>=P&&y===b;w===p[S?j-x:j]&&_.splice(j,1)}}var V=a,N=!1;e:for(var E=0;E<C;E++){var A=p[E];if(A===d){if(_.length>0)for(;_.length>0;){var I=_.shift(),L=I.char,R=I.isNew;if(L===d&&m!==!0){V+=d;continue e}if(r[E].test(L)){if(h===!0&&R!==!1&&s!==a&&u!==!1&&k){for(var J=_.length,q=null,F=0;F<J;F++){var W=_[F];if(W.char!==d&&W.isNew===!1)break;if(W.char===d){q=F;break}}null!==q?(V+=L,_.splice(q,1)):E--}else V+=L;continue e}N=!0}m===!1&&(V+=p.substr(E,C));break}V+=A}if(m&&k===!1){for(var z=null,B=0;B<V.length;B++)p[B]===d&&(z=B);V=null!==z?V.substr(0,z+1):a}return{conformedValue:V,meta:{someCharsRejected:N}}}Object.defineProperty(r,"__esModule",{value:!0}),r.default=n;var o=t(3),i=t(1),a=""},function(e,r,t){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.placeholderChar;if(e.indexOf(r)!==-1)throw new Error("Placeholder character must not be used as part of the mask. Please specify a character that is not present in your mask as your placeholder character.\n\n"+("The placeholder character that was received is: "+JSON.stringify(r)+"\n\n")+("The mask that was received is: "+JSON.stringify(e)));return e.map(function(e){return e instanceof RegExp?r:e}).join("")}function o(e){return"string"==typeof e||e instanceof String}function i(e){return"number"==typeof e&&void 0===e.length&&!isNaN(e)}function a(e){for(var r=[],t=void 0;t=e.indexOf(s),t!==-1;)r.push(t),e.splice(t,1);return{maskWithoutCaretTraps:e,indexes:r}}Object.defineProperty(r,"__esModule",{value:!0}),r.convertMaskToPlaceholder=n,r.isString=o,r.isNumber=i,r.processCaretTraps=a;var u=t(1),l=[],s="[]"},function(e,r){"use strict";function t(e){var r=e.previousConformedValue,t=void 0===r?o:r,i=e.currentCaretPosition,a=void 0===i?0:i,u=e.conformedValue,l=e.rawValue,s=e.placeholderChar,f=e.placeholder,d=e.indexesOfPipedChars,c=void 0===d?n:d,p=e.caretTrapIndexes,v=void 0===p?n:p;if(0===a)return 0;var h=l.length,m=t.length,g=f.length,y=u.length,C=h-m,b=C>0,x=0===m,k=C>1&&!b&&!x;if(k)return a;var P=b&&(t===u||u===f),O=0;if(P)O=a-C;else for(var T=u.toLowerCase(),M=l.toLowerCase(),_=M.substr(0,a).split(o),j=_.filter(function(e){return T.indexOf(e)!==-1}),w=j[j.length-1],S=c.map(function(e){return T[e]}),V=S.filter(function(e){return e===w}).length,N=j.filter(function(e){return e===w}).length,E=f.substr(0,f.indexOf(s)).split(o).filter(function(e,r){return e===w&&l[r]!==e}).length,A=E+N+V,I=0,L=0;L<y;L++){var R=T[L];if(O=L+1,R===w&&I++,I>=A)break}if(b){for(var J=O,q=O;q<=g;q++)if(f[q]===s&&(J=q),f[q]===s||v.indexOf(q)!==-1||q===g)return J}else for(var F=O;F>=0;F--)if(f[F-1]===s||v.indexOf(F)!==-1||0===F)return F}Object.defineProperty(r,"__esModule",{value:!0}),r.default=t;var n=[],o=""},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var r={previousConformedValue:void 0};return{state:r,update:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,o=n.inputElement,s=n.mask,d=n.guide,g=n.pipe,C=n.placeholderChar,b=void 0===C?v.placeholderChar:C,x=n.keepCharPositions,k=void 0!==x&&x;if("undefined"==typeof t&&(t=o.value),t!==r.previousConformedValue){("undefined"==typeof s?"undefined":l(s))===y&&void 0!==s.pipe&&void 0!==s.mask&&(g=s.pipe,s=s.mask);var P=void 0,O=void 0;if(s instanceof Array&&(P=(0,p.convertMaskToPlaceholder)(s,b)),s!==!1){var T=a(t),M=o.selectionStart,_=r.previousConformedValue,j=void 0;if(("undefined"==typeof s?"undefined":l(s))===h){if(O=s(T,{currentCaretPosition:M,previousConformedValue:_,placeholderChar:b}),O===!1)return;var w=(0,p.processCaretTraps)(O),S=w.maskWithoutCaretTraps,V=w.indexes;O=S,j=V,P=(0,p.convertMaskToPlaceholder)(O,b)}else O=s;var N={previousConformedValue:_,guide:d,placeholderChar:b,pipe:g,placeholder:P,currentCaretPosition:M,keepCharPositions:k},E=(0,c.default)(T,O,N),A=E.conformedValue,I=("undefined"==typeof g?"undefined":l(g))===h,L={};I&&(L=g(A,u({rawValue:T},N)),L===!1?L={value:_,rejected:!0}:(0,p.isString)(L)&&(L={value:L}));var R=I?L.value:A,J=(0,f.default)({previousConformedValue:_,conformedValue:R,placeholder:P,rawValue:T,currentCaretPosition:M,placeholderChar:b,indexesOfPipedChars:L.indexesOfPipedChars,caretTrapIndexes:j}),q=R===P&&0===J,F=q?m:R;r.previousConformedValue=F,o.value!==F&&(o.value=F,i(o,J))}}}}}function i(e,r){document.activeElement===e&&(C?b(function(){return e.setSelectionRange(r,r,g)},0):e.setSelectionRange(r,r,g))}function a(e){if((0,p.isString)(e))return e;if((0,p.isNumber)(e))return String(e);if(void 0===e||null===e)return m;throw new Error("The 'value' provided to Text Mask needs to be a string or a number. The value received was:\n\n "+JSON.stringify(e))}Object.defineProperty(r,"__esModule",{value:!0});var u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.default=o;var s=t(4),f=n(s),d=t(2),c=n(d),p=t(3),v=t(1),h="function",m="",g="none",y="object",C="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),b="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:setTimeout}])});
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.vanillaTextMask=r():e.vanillaTextMask=r()}(this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var r=e.inputElement,t=(0,u.default)(e),n=function(e){var r=e.target.value;return t.update(r)};return r.addEventListener("input",n),t.update(r.value),{textMaskInputElement:t,destroy:function(){r.removeEventListener("input",n)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.conformToMask=void 0,r.maskInput=o;var i=t(2);Object.defineProperty(r,"conformToMask",{enumerable:!0,get:function(){return n(i).default}});var a=t(5),u=n(a);r.default=o},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.placeholderChar="_"},function(e,r,t){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.guide,u=void 0===n||n,l=t.previousConformedValue,s=void 0===l?a:l,d=t.placeholderChar,f=void 0===d?i.placeholderChar:d,c=t.placeholder,v=void 0===c?(0,o.convertMaskToPlaceholder)(r,f):c,p=t.currentCaretPosition,h=t.keepCharPositions,m=u===!1&&void 0!==s,g=e.length,y=s.length,C=v.length,b=r.length,P=g-y,x=P>0,k=p+(x?-P:0),O=k+Math.abs(P);if(h===!0&&!x){for(var T=a,M=k;M<O;M++)v[M]===f&&(T+=f);e=e.slice(0,k)+T+e.slice(k,g)}for(var _=e.split(a).map(function(e,r){return{char:e,isNew:r>=k&&r<O}}),j=g-1;j>=0;j--){var w=_[j].char;if(w!==f){var S=j>=k&&y===b;w===v[S?j-P:j]&&_.splice(j,1)}}var V=a,N=!1;e:for(var E=0;E<C;E++){var A=v[E];if(A===f){if(_.length>0)for(;_.length>0;){var I=_.shift(),L=I.char,R=I.isNew;if(L===f&&m!==!0){V+=f;continue e}if(r[E].test(L)){if(h===!0&&R!==!1&&s!==a&&u!==!1&&x){for(var J=_.length,q=null,F=0;F<J;F++){var W=_[F];if(W.char!==f&&W.isNew===!1)break;if(W.char===f){q=F;break}}null!==q?(V+=L,_.splice(q,1)):E--}else V+=L;continue e}N=!0}m===!1&&(V+=v.substr(E,C));break}V+=A}if(m&&x===!1){for(var z=null,B=0;B<V.length;B++)v[B]===f&&(z=B);V=null!==z?V.substr(0,z+1):a}return{conformedValue:V,meta:{someCharsRejected:N}}}Object.defineProperty(r,"__esModule",{value:!0}),r.default=n;var o=t(3),i=t(1),a=""},function(e,r,t){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.placeholderChar;if(e.indexOf(r)!==-1)throw new Error("Placeholder character must not be used as part of the mask. Please specify a character that is not present in your mask as your placeholder character.\n\n"+("The placeholder character that was received is: "+JSON.stringify(r)+"\n\n")+("The mask that was received is: "+JSON.stringify(e)));return e.map(function(e){return e instanceof RegExp?r:e}).join("")}function o(e){return"string"==typeof e||e instanceof String}function i(e){return"number"==typeof e&&void 0===e.length&&!isNaN(e)}function a(e){for(var r=[],t=void 0;t=e.indexOf(s),t!==-1;)r.push(t),e.splice(t,1);return{maskWithoutCaretTraps:e,indexes:r}}Object.defineProperty(r,"__esModule",{value:!0}),r.convertMaskToPlaceholder=n,r.isString=o,r.isNumber=i,r.processCaretTraps=a;var u=t(1),l=[],s="[]"},function(e,r){"use strict";function t(e){var r=e.previousConformedValue,t=void 0===r?o:r,i=e.previousPlaceholder,a=void 0===i?o:i,u=e.currentCaretPosition,l=void 0===u?0:u,s=e.conformedValue,d=e.rawValue,f=e.placeholderChar,c=e.placeholder,v=e.indexesOfPipedChars,p=void 0===v?n:v,h=e.caretTrapIndexes,m=void 0===h?n:h;if(0===l)return 0;var g=d.length,y=t.length,C=c.length,b=s.length,P=g-y,x=P>0,k=0===y,O=P>1&&!x&&!k;if(O)return l;var T=x&&(t===s||s===c),M=0,_=void 0;if(T)M=l-P;else{var j=s.toLowerCase(),w=d.toLowerCase(),S=w.substr(0,l).split(o),V=S.filter(function(e){return j.indexOf(e)!==-1}),N=V[V.length-1];_=void 0!==a[V.length-1]&&void 0!==c[V.length-2]&&a[V.length-1]!==f&&a[V.length-1]!==c[V.length-1]&&a[V.length-1]===c[V.length-2];for(var E=p.map(function(e){return j[e]}),A=E.filter(function(e){return e===N}).length,I=V.filter(function(e){return e===N}).length,L=c.substr(0,c.indexOf(f)).split(o).filter(function(e,r){return e===N&&d[r]!==e}).length,R=L+I+A,J=0,q=0;q<b;q++){var F=j[q];if(M=q+1,F===N&&J++,J>=R)break}}if(x){for(var W=M,z=M;z<=C;z++)if(c[z]===f&&(W=z),c[z]===f||m.indexOf(z)!==-1||z===C)return W}else for(var B=M+(_?1:0);B>=0;B--)if(c[B-1]===f||m.indexOf(B)!==-1||0===B)return B}Object.defineProperty(r,"__esModule",{value:!0}),r.default=t;var n=[],o=""},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var r={previousConformedValue:void 0,previousPlaceholder:void 0};return{state:r,update:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,o=n.inputElement,s=n.mask,f=n.guide,g=n.pipe,C=n.placeholderChar,b=void 0===C?p.placeholderChar:C,P=n.keepCharPositions,x=void 0!==P&&P;if("undefined"==typeof t&&(t=o.value),t!==r.previousConformedValue){("undefined"==typeof s?"undefined":l(s))===y&&void 0!==s.pipe&&void 0!==s.mask&&(g=s.pipe,s=s.mask);var k=void 0,O=void 0;if(s instanceof Array&&(k=(0,v.convertMaskToPlaceholder)(s,b)),s!==!1){var T=a(t),M=o.selectionStart,_=r.previousConformedValue,j=r.previousPlaceholder,w=void 0;if(("undefined"==typeof s?"undefined":l(s))===h){if(O=s(T,{currentCaretPosition:M,previousConformedValue:_,placeholderChar:b}),O===!1)return;var S=(0,v.processCaretTraps)(O),V=S.maskWithoutCaretTraps,N=S.indexes;O=V,w=N,k=(0,v.convertMaskToPlaceholder)(O,b)}else O=s;var E={previousConformedValue:_,guide:f,placeholderChar:b,pipe:g,placeholder:k,currentCaretPosition:M,keepCharPositions:x},A=(0,c.default)(T,O,E),I=A.conformedValue,L=("undefined"==typeof g?"undefined":l(g))===h,R={};L&&(R=g(I,u({rawValue:T},E)),R===!1?R={value:_,rejected:!0}:(0,v.isString)(R)&&(R={value:R}));var J=L?R.value:I,q=(0,d.default)({previousConformedValue:_,previousPlaceholder:j,conformedValue:J,placeholder:k,rawValue:T,currentCaretPosition:M,placeholderChar:b,indexesOfPipedChars:R.indexesOfPipedChars,caretTrapIndexes:w}),F=J===k&&0===q,W=F?m:J;r.previousConformedValue=W,r.previousPlaceholder=k,o.value!==W&&(o.value=W,i(o,q))}}}}}function i(e,r){document.activeElement===e&&(C?b(function(){return e.setSelectionRange(r,r,g)},0):e.setSelectionRange(r,r,g))}function a(e){if((0,v.isString)(e))return e;if((0,v.isNumber)(e))return String(e);if(void 0===e||null===e)return m;throw new Error("The 'value' provided to Text Mask needs to be a string or a number. The value received was:\n\n "+JSON.stringify(e))}Object.defineProperty(r,"__esModule",{value:!0});var u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.default=o;var s=t(4),d=n(s),f=t(2),c=n(f),v=t(3),p=t(1),h="function",m="",g="none",y="object",C="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),b="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:setTimeout}])});
{
"name": "vanilla-text-mask",
"version": "3.2.3",
"version": "4.0.0",
"description": "JavaScript function that makes input HTML element accept mask pattern",

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

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc