1 line
14 KiB
JSON
1 line
14 KiB
JSON
|
{"ast":null,"code":"import { DomHandler } from 'primereact/utils';\n\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}\n\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nvar KeyFilter = /*#__PURE__*/function () {\n function KeyFilter() {\n _classCallCheck(this, KeyFilter);\n }\n\n _createClass(KeyFilter, null, [{\n key: \"isNavKeyPress\",\n value:\n /* eslint-disable */\n\n /* eslint-enable */\n function isNavKeyPress(e) {\n var k = e.keyCode;\n k = DomHandler.getBrowser().safari ? KeyFilter.SAFARI_KEYS[k] || k : k;\n return k >= 33 && k <= 40 || k === KeyFilter.KEYS.RETURN || k === KeyFilter.KEYS.TAB || k === KeyFilter.KEYS.ESC;\n }\n }, {\n key: \"isSpecialKey\",\n value: function isSpecialKey(e) {\n var k = e.keyCode;\n return k === 9 || k === 13 || k === 27 || k === 16 || k === 17 || k >= 18 && k <= 20 || DomHandler.getBrowser().opera && !e.shiftKey && (k === 8 || k >= 33 && k <= 35 || k >= 36 && k <= 39 || k >= 44 && k <= 45);\n }\n }, {\n key: \"getKey\",\n value: function getKey(e) {\n var k = e.keyCode || e.charCode;\n return DomHandler.getBrowser().safari ? KeyFilter.SAFARI_KEYS[k] || k : k;\n }\n }, {\n key: \"getCharCode\",\n value: function getCharCode(e) {\n return e.charCode || e.keyCode || e.which;\n }\n }, {\n key: \"onKeyPress\",\n value: function onKeyPress(e, keyfilter, validateOnly) {\n if (validateOnly) {\n return;\n }\n\n var regex = KeyFilter.DEFAULT_MASKS[keyfilter] ? KeyFilter.DEFAULT_MASKS[keyfilter] : keyfilter;\n var browser = DomHandler.getBrowser();\n\n if (e.ctrlKey || e.altKey) {\n return;\n }\n\n var k = this.getKey(e);\n\n if (browser.mozilla && (this.isNavKeyPress(e) || k === KeyFilter.KEYS.BACKSPACE || k === KeyFilter.KEYS.DELETE && e.charCode === 0)) {\n return;\n }\n\n var c = this.getCharCode(e);\n var cc = String.fromCharCode(c);\n\n if (browser.mozilla && (this.isSpecialKey(e) || !cc)) {\n return;\n }\n\n if (!regex.test(cc)) {\n e.preventDefault();\n }\n }\n }, {\n key: \"validate\",\n value: function validate(e, keyfilter) {\n var value = e.target.value,\n validatePattern = true;\n\n if (value && !keyfilter.test(value)) {\n validatePattern = false;\n }\n\n return validatePattern;\n }\n }]);\n\n return KeyFilter;\n}();\n\n_defineProperty(KeyFilter, \"DEFAULT_MASKS\", {\n pint: /[\\d]/,\n \"int\": /[\\d\\-]/,\n pnum: /[\\d\\.]/,\n money: /[\\d\\.\\s,]/,\n num: /[\\d\\-\\.]/,\n hex: /[0-9a-f]/i,\n email: /[a-z0-9_\\.\\-@]/i,\n alpha: /[a-z_]/i,\n alphanum: /[a-z0-9_]/i\n});\n\n_defineProperty(KeyFilter, \"KEYS\", {\n TAB: 9,\n RETURN: 13,\n ESC: 27,\n BACKSPACE: 8,\n DELETE: 46\n});\n\n_defineProperty(KeyFilter, \"SAFARI_KEYS\", {\n 63234: 37,\n // left\n 63235: 39,\n // right\n 63232: 38,\n // up\n 63233: 40,\n // down\n 63276: 33,\n // page up\n 63277: 34,\n // page down\n 63272: 46,\n // delete\n 63273:
|