primereact
Version:
PrimeReact is an open source UI library for React featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime
2 lines (1 loc) • 1.54 kB
JavaScript
this.primereact=this.primereact||{},this.primereact.keyfilter=function(t){"use strict";function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function r(t){if(Array.isArray(t))return e(t)}function n(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function a(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function i(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o={DEFAULT_MASKS:{pint:/[\d]/,int:/[\d\-]/,pnum:/[\d\.]/,money:/[\d\.\s,]/,num:/[\d\-\.]/,hex:/[0-9a-f]/i,email:/[a-z0-9_\.\-@]/i,alpha:/[a-z_]/i,alphanum:/[a-z0-9_]/i},getRegex:function(t){return o.DEFAULT_MASKS[t]?o.DEFAULT_MASKS[t]:t},onKeyPress:function(t,e,r){r||(t.ctrlKey||t.altKey||1===t.key.length&&(this.getRegex(e).test(t.key)||t.preventDefault()))},onPaste:function(t,e,o){if(!o){var u,l=this.getRegex(e),c=t.clipboardData.getData("text");(u=c,r(u)||n(u)||a(u)||i()).forEach((function(e){if(!l.test(e))return t.preventDefault(),!1}))}},validate:function(t,e){var r=t.target.value,n=!0,a=this.getRegex(e);return r&&!a.test(r)&&(n=!1),n}};return t.KeyFilter=o,Object.defineProperty(t,"__esModule",{value:!0}),t}({});