UNPKG

rn-web-cli

Version:

React Native for Web

1 lines 4.9 kB
{"version":3,"sources":["node_modules\\react-dom\\lib\\getEventKey.js"],"names":["getEventCharCode","require","normalizeKey","Esc","Spacebar","Left","Up","Right","Down","Del","Win","Menu","Apps","Scroll","MozPrintableKey","translateToKey","getEventKey","nativeEvent","key","type","charCode","String","fromCharCode","keyCode","module","exports"],"mappings":";;;;;;;;;;AAUA;;AAEA,GAAIA,kBAAmBC,QAAQ,oBAAR,CAAvB;;;;;;AAMA,GAAIC,cAAe;AACjBC,IAAK,QADY;AAEjBC,SAAU,GAFO;AAGjBC,KAAM,WAHW;AAIjBC,GAAI,SAJa;AAKjBC,MAAO,YALU;AAMjBC,KAAM,WANW;AAOjBC,IAAK,QAPY;AAQjBC,IAAK,IARY;AASjBC,KAAM,aATW;AAUjBC,KAAM,aAVW;AAWjBC,OAAQ,YAXS;AAYjBC,gBAAiB,cAZA,CAAnB;;;;;;;;AAoBA,GAAIC,gBAAiB;AACnB,EAAG,WADgB;AAEnB,EAAG,KAFgB;AAGnB,GAAI,OAHe;AAInB,GAAI,OAJe;AAKnB,GAAI,OALe;AAMnB,GAAI,SANe;AAOnB,GAAI,KAPe;AAQnB,GAAI,OARe;AASnB,GAAI,UATe;AAUnB,GAAI,QAVe;AAWnB,GAAI,GAXe;AAYnB,GAAI,QAZe;AAanB,GAAI,UAbe;AAcnB,GAAI,KAde;AAenB,GAAI,MAfe;AAgBnB,GAAI,WAhBe;AAiBnB,GAAI,SAjBe;AAkBnB,GAAI,YAlBe;AAmBnB,GAAI,WAnBe;AAoBnB,GAAI,QApBe;AAqBnB,GAAI,QArBe;AAsBnB,IAAK,IAtBc;AAuBnB,IAAK,IAvBc;AAwBnB,IAAK,IAxBc;AAyBnB,IAAK,IAzBc;AA0BnB,IAAK,IA1Bc;AA2BnB,IAAK,IA3Bc;AA4BnB,IAAK,IA5Bc;AA6BnB,IAAK,IA7Bc;AA8BnB,IAAK,IA9Bc;AA+BnB,IAAK,KA/Bc;AAgCnB,IAAK,KAhCc;AAiCnB,IAAK,KAjCc;AAkCnB,IAAK,SAlCc;AAmCnB,IAAK,YAnCc;AAoCnB,IAAK,MApCc,CAArB;;;;;;;AA2CA,QAASC,YAAT,CAAqBC,WAArB,CAAkC;AAChC,GAAIA,YAAYC,GAAhB,CAAqB;;;;;;AAMnB,GAAIA,KAAMhB,aAAae,YAAYC,GAAzB,GAAiCD,YAAYC,GAAvD;AACA,GAAIA,MAAQ,cAAZ,CAA4B;AAC1B,MAAOA,IAAP;AACD;AACF;;;AAGD,GAAID,YAAYE,IAAZ,GAAqB,UAAzB,CAAqC;AACnC,GAAIC,UAAWpB,iBAAiBiB,WAAjB,CAAf;;;;AAIA,MAAOG,YAAa,EAAb,CAAkB,OAAlB,CAA4BC,OAAOC,YAAP,CAAoBF,QAApB,CAAnC;AACD;AACD,GAAIH,YAAYE,IAAZ,GAAqB,SAArB,EAAkCF,YAAYE,IAAZ,GAAqB,OAA3D,CAAoE;;;AAGlE,MAAOJ,gBAAeE,YAAYM,OAA3B,GAAuC,cAA9C;AACD;AACD,MAAO,EAAP;AACD;;AAEDC,OAAOC,OAAP,CAAiBT,WAAjB","file":"getEventKey.js","sourceRoot":"D:/Work/Office/react-native-on-web/cli/tmpl/project","sourcesContent":["/**\n * Copyright 2013-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n *\n */\n\n'use strict';\n\nvar getEventCharCode = require('./getEventCharCode');\n\n/**\n * Normalization of deprecated HTML5 `key` values\n * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names\n */\nvar normalizeKey = {\n Esc: 'Escape',\n Spacebar: ' ',\n Left: 'ArrowLeft',\n Up: 'ArrowUp',\n Right: 'ArrowRight',\n Down: 'ArrowDown',\n Del: 'Delete',\n Win: 'OS',\n Menu: 'ContextMenu',\n Apps: 'ContextMenu',\n Scroll: 'ScrollLock',\n MozPrintableKey: 'Unidentified'\n};\n\n/**\n * Translation from legacy `keyCode` to HTML5 `key`\n * Only special keys supported, all others depend on keyboard layout or browser\n * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names\n */\nvar translateToKey = {\n 8: 'Backspace',\n 9: 'Tab',\n 12: 'Clear',\n 13: 'Enter',\n 16: 'Shift',\n 17: 'Control',\n 18: 'Alt',\n 19: 'Pause',\n 20: 'CapsLock',\n 27: 'Escape',\n 32: ' ',\n 33: 'PageUp',\n 34: 'PageDown',\n 35: 'End',\n 36: 'Home',\n 37: 'ArrowLeft',\n 38: 'ArrowUp',\n 39: 'ArrowRight',\n 40: 'ArrowDown',\n 45: 'Insert',\n 46: 'Delete',\n 112: 'F1',\n 113: 'F2',\n 114: 'F3',\n 115: 'F4',\n 116: 'F5',\n 117: 'F6',\n 118: 'F7',\n 119: 'F8',\n 120: 'F9',\n 121: 'F10',\n 122: 'F11',\n 123: 'F12',\n 144: 'NumLock',\n 145: 'ScrollLock',\n 224: 'Meta'\n};\n\n/**\n * @param {object} nativeEvent Native browser event.\n * @return {string} Normalized `key` property.\n */\nfunction getEventKey(nativeEvent) {\n if (nativeEvent.key) {\n // Normalize inconsistent values reported by browsers due to\n // implementations of a working draft specification.\n\n // FireFox implements `key` but returns `MozPrintableKey` for all\n // printable characters (normalized to `Unidentified`), ignore it.\n var key = normalizeKey[nativeEvent.key] || nativeEvent.key;\n if (key !== 'Unidentified') {\n return key;\n }\n }\n\n // Browser does not implement `key`, polyfill as much of it as we can.\n if (nativeEvent.type === 'keypress') {\n var charCode = getEventCharCode(nativeEvent);\n\n // The enter-key is technically both printable and non-printable and can\n // thus be captured by `keypress`, no other non-printable key should.\n return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);\n }\n if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {\n // While user keyboard layout determines the actual meaning of each\n // `keyCode` value, almost all function keys have a universal value.\n return translateToKey[nativeEvent.keyCode] || 'Unidentified';\n }\n return '';\n}\n\nmodule.exports = getEventKey;"]}