{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","getButtonClass","getButtonDisplayName","getUpdatedInput","updateCaretPos","isMaxLengthReached","camelCase","countInArray","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","caretPosition","source","string","position","slice","join","debug","console","log","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","_defineProperty","option","render","initCallback","prop","keys","keyboardDOMQuery","arguments","undefined","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","handleButtonClicked","syncInstanceInputs","clearInput","getInput","setInput","replaceInput","clear","addButtonTheme","removeButtonTheme","handleCaret","caretEventHandler","onInit","onRender","loadModules","handleButtonMouseUp","handleButtonMouseDown","handleButtonHold","onModulesLoaded","keyboardDOMClass","buttonElements","warn","Error","physicalKeyboardInterface","onKeyPress","handleMaxLength","onChange","e","_this2","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","_this3","_this4","innerHTML","className","callback","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","Module","constructor","classStr","init","_this8","layoutClass","layout","getDefaultLayout","useTouchEvents","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","buttonThemeClass","buttonDisplayName","ontouchstart","ontouchend","ontouchcancel","onclick","onmousedown","preventDefault","setAttribute","buttonUID","buttonSpanDOM","appendChild","initialized","onmouseup"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAA,kBAAAC,OACAA,OAAAD,QAAAD,IACA,oBAAAG,eAAAC,IACAD,OAAA,oBAAAH,GACA,kBAAAC,QACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,E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WAEDhL,KAAKoQ,cAIPpQ,KAAKoQ,aAAc,EAKdzB,IACHvO,SAASiQ,UAAY,kBAAM9B,EAAKrD,wBAMlClL,KAAK+K,+CCzxBI9B","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance){\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(this);\r\n\r\n /**\r\n * Initialize key listeners\r\n */\r\n this.initKeyboardListener();\r\n }\r\n\r\n /**\r\n * Initializes key event listeners\r\n */\r\n initKeyboardListener(){\r\n // Adding button style on keydown\r\n document.addEventListener(\"keydown\", (event) => {\r\n if(this.simpleKeyboardInstance.options.physicalKeyboardHighlight){\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM = instance.getButtonElement(buttonPressed) || instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if(buttonDOM){\r\n buttonDOM.style.backgroundColor = this.simpleKeyboardInstance.options.physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color = this.simpleKeyboardInstance.options.physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n });\r\n\r\n // Removing button style on keyup\r\n document.addEventListener(\"keyup\", (event) => {\r\n if(this.simpleKeyboardInstance.options.physicalKeyboardHighlight){\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM = instance.getButtonElement(buttonPressed) || instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if(buttonDOM && buttonDOM.removeAttribute){\r\n buttonDOM.removeAttribute(\"style\");\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Transforms a KeyboardEvent's \"key.code\" string into a simple-keyboard layout format\r\n * @param {object} event The KeyboardEvent\r\n */\r\n getSimpleKeyboardLayoutKey(event){\r\n let output;\r\n\r\n if(\r\n event.code.includes(\"Numpad\") ||\r\n event.code.includes(\"Shift\") ||\r\n event.code.includes(\"Space\") ||\r\n event.code.includes(\"Backspace\") ||\r\n event.code.includes(\"Control\") ||\r\n event.code.includes(\"Alt\") ||\r\n event.code.includes(\"Meta\")\r\n ){\r\n output = event.code;\r\n } else {\r\n output = event.key;\r\n }\r\n\r\n /**\r\n * If button is not uppercase, casting to lowercase\r\n */\r\n if (\r\n output !== output.toUpperCase() ||\r\n (event.code[0] === \"F\" && Number.isInteger(Number(event.code[1])) && event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout(){\r\n return {\r\n 'default': [\r\n '` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',\r\n '{tab} q w e r t y u i o p [ ] \\\\',\r\n '{lock} a s d f g h j k l ; \\' {enter}',\r\n '{shift} z x c v b n m , . / {shift}',\r\n '.com @ {space}'\r\n ],\r\n 'shift': [\r\n '~ ! @ # $ % ^ & * ( ) _ + {bksp}',\r\n '{tab} Q W E R T Y U I O P { } |',\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n '{shift} Z X C V B N M < > ? {shift}',\r\n '.com @ {space}'\r\n ]\r\n } \r\n }\r\n}\r\n\r\nexport default KeyboardLayout;","/**\r\n * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor(simpleKeyboardInstance){\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.getButtonClass = this.getButtonClass.bind(this);\r\n this.getButtonDisplayName = this.getButtonDisplayName.bind(this);\r\n this.getUpdatedInput = this.getUpdatedInput.bind(this);\r\n this.updateCaretPos = this.updateCaretPos.bind(this);\r\n this.isMaxLengthReached = this.isMaxLengthReached.bind(this);\r\n this.camelCase = this.camelCase.bind(this);\r\n this.countInArray = this.countInArray.bind(this);\r\n }\r\n\r\n /**\r\n * Adds default classes to a given button\r\n * \r\n * @param {string} button The button's layout name\r\n * @return {string} The classes to be added to the button\r\n */\r\n getButtonClass(button){\r\n let buttonTypeClass = (button.includes(\"{\") && button.includes(\"}\") && button !== '{//}') ? \"functionBtn\" : \"standardBtn\";\r\n let buttonWithoutBraces = button.replace(\"{\", \"\").replace(\"}\", \"\");\r\n let buttonNormalized = '';\r\n\r\n if(buttonTypeClass !== \"standardBtn\")\r\n buttonNormalized = ` hg-button-${buttonWithoutBraces}`;\r\n\r\n return `hg-${buttonTypeClass}${buttonNormalized}`;\r\n }\r\n\r\n /**\r\n * Default button display labels\r\n */\r\n getDefaultDiplay(){\r\n return {\r\n '{bksp}': 'backspace',\r\n '{backspace}': 'backspace',\r\n '{enter}': '< enter',\r\n '{shift}': 'shift',\r\n '{shiftleft}': 'shift',\r\n '{shiftright}': 'shift',\r\n '{alt}': 'alt',\r\n '{s}': 'shift',\r\n '{tab}': 'tab',\r\n '{lock}': 'caps',\r\n '{capslock}': 'caps',\r\n '{accept}': 'Submit',\r\n '{space}': ' ',\r\n '{//}': ' ',\r\n \"{esc}\": \"esc\",\r\n \"{escape}\": \"esc\",\r\n \"{f1}\": \"f1\",\r\n \"{f2}\": \"f2\",\r\n \"{f3}\": \"f3\",\r\n \"{f4}\": \"f4\",\r\n \"{f5}\": \"f5\",\r\n \"{f6}\": \"f6\",\r\n \"{f7}\": \"f7\",\r\n \"{f8}\": \"f8\",\r\n \"{f9}\": \"f9\",\r\n \"{f10}\": \"f10\",\r\n \"{f11}\": \"f11\",\r\n \"{f12}\": \"f12\",\r\n '{numpaddivide}': '/',\r\n '{numlock}': 'lock',\r\n \"{arrowup}\": \"↑\",\r\n \"{arrowleft}\": \"←\",\r\n \"{arrowdown}\": \"↓\",\r\n \"{arrowright}\": \"→\",\r\n \"{prtscr}\": \"print\",\r\n \"{scrolllock}\": \"scroll\",\r\n \"{pause}\": \"pause\",\r\n \"{insert}\": \"ins\",\r\n \"{home}\": \"home\",\r\n \"{pageup}\": \"up\",\r\n \"{delete}\": \"del\",\r\n \"{end}\": \"end\",\r\n \"{pagedown}\": \"down\",\r\n \"{numpadmultiply}\": \"*\",\r\n \"{numpadsubtract}\": \"-\",\r\n \"{numpadadd}\": \"+\",\r\n \"{numpadenter}\": \"enter\",\r\n \"{period}\": \".\",\r\n \"{numpaddecimal}\": \".\",\r\n \"{numpad0}\": \"0\",\r\n \"{numpad1}\": \"1\",\r\n \"{numpad2}\": \"2\",\r\n \"{numpad3}\": \"3\",\r\n \"{numpad4}\": \"4\",\r\n \"{numpad5}\": \"5\",\r\n \"{numpad6}\": \"6\",\r\n \"{numpad7}\": \"7\",\r\n \"{numpad8}\": \"8\",\r\n \"{numpad9}\": \"9\",\r\n };\r\n }\r\n /**\r\n * Returns the display (label) name for a given button\r\n * \r\n * @param {string} button The button's layout name\r\n * @param {object} display The provided display option\r\n * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.\r\n */\r\n getButtonDisplayName(button, display, mergeDisplay){\r\n if(mergeDisplay){\r\n display = Object.assign({}, this.getDefaultDiplay(), display);\r\n } else {\r\n display = display || this.getDefaultDiplay();\r\n }\r\n\r\n return display[button] || button;\r\n }\r\n\r\n \r\n /**\r\n * Returns the updated input resulting from clicking a given button\r\n * \r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret){\r\n \r\n let output = input;\r\n\r\n if((button === \"{bksp}\" || button === \"{backspace}\") && output.length > 0){\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n\r\n } else if(button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n\r\n else if(button === \"{tab}\" && !(typeof options.tabCharOnTab === \"boolean\" && options.tabCharOnTab === false)){\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n\r\n } else if((button === \"{enter}\" || button === \"{numpadenter}\") && options.newLineOnEnter)\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n\r\n else if(button.includes(\"numpad\") && Number.isInteger(Number(button[button.length - 2]))){\r\n output = this.addStringAt(output, button[button.length - 2], caretPos);\r\n }\r\n else if(button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, '/', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, '*', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, '-', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpadadd}\")\r\n output = this.addStringAt(output, '+', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, '.', caretPos, moveCaret);\r\n\r\n else if(button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n else if(!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n * \r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus){\r\n if(minus){\r\n if(this.simpleKeyboardInstance.caretPosition > 0)\r\n this.simpleKeyboardInstance.caretPosition = this.simpleKeyboardInstance.caretPosition - length;\r\n } else {\r\n this.simpleKeyboardInstance.caretPosition = this.simpleKeyboardInstance.caretPosition + length;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n * \r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret){\r\n let output;\r\n\r\n if(!position && position !== 0){\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join('');\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if(!this.isMaxLengthReached()){\r\n if(moveCaret) this.updateCaretPos(string.length);\r\n }\r\n\r\n }\r\n\r\n if(this.simpleKeyboardInstance.options.debug && moveCaret){\r\n console.log(\"Caret at:\", position);\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n * \r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret){\r\n if(this.simpleKeyboardInstance.caretPosition === 0){\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if(position && position >= 0){\r\n prevTwoChars = source.substring(position - 2, position)\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if(emojiMatched){\r\n output = source.substr(0, (position - 2)) + source.substr(position);\r\n if(moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, (position - 1)) + source.substr(position);\r\n if(moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if(emojiMatched){\r\n output = source.slice(0, -2);\r\n if(moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if(moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n if(this.simpleKeyboardInstance.options.debug && moveCaret){\r\n console.log(\"Caret at:\", this.simpleKeyboardInstance.caretPosition);\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n * \r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput){\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if(\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ){\r\n return false;\r\n }\r\n\r\n if(Number.isInteger(maxLength)){\r\n if(options.debug){\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if(condition){\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if(typeof maxLength === \"object\"){\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if(options.debug){\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if(condition){\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached(){\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n * \r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string){\r\n return string.toLowerCase().trim().split(/[.\\-_\\s]/g).reduce((string, word) => string + word[0].toUpperCase() + word.slice(1));\r\n };\r\n\r\n /**\r\n * Counts the number of duplicates in a given array\r\n * \r\n * @param {Array} array The haystack to search in\r\n * @param {string} value The needle to search for\r\n */\r\n countInArray(array, value){\r\n return array.reduce((n, x) => n + (x === value), 0);\r\n }\r\n\r\n}\r\n\r\nexport default Utilities;","import './Keyboard.css';\r\n\r\n// Services\r\nimport PhysicalKeyboard from '../services/PhysicalKeyboard';\r\nimport KeyboardLayout from '../services/KeyboardLayout';\r\nimport Utilities from '../services/Utilities';\r\n\r\n/**\r\n * Root class for simple-keyboard\r\n * This class:\r\n * - Parses the options\r\n * - Renders the rows and buttons\r\n * - Handles button functionality\r\n */\r\nclass SimpleKeyboard {\r\n /**\r\n * Creates an instance of SimpleKeyboard\r\n * @param {Array} params If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.\r\n */\r\n constructor(...params){\r\n let keyboardDOMQuery = typeof params[0] === \"string\" ? params[0] : '.simple-keyboard';\r\n let options = typeof params[0] === \"object\" ? params[0] : params[1];\r\n\r\n if(!options)\r\n options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault = this.options.preventMouseDownDefault === false ? false : true;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = '';\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.handleButtonClicked = this.handleButtonClicked.bind(this);\r\n this.syncInstanceInputs = this.syncInstanceInputs.bind(this);\r\n this.clearInput = this.clearInput.bind(this);\r\n this.getInput = this.getInput.bind(this);\r\n this.setInput = this.setInput.bind(this);\r\n this.replaceInput = this.replaceInput.bind(this);\r\n this.clear = this.clear.bind(this);\r\n this.dispatch = this.dispatch.bind(this);\r\n this.addButtonTheme = this.addButtonTheme.bind(this);\r\n this.removeButtonTheme = this.removeButtonTheme.bind(this);\r\n this.getButtonElement = this.getButtonElement.bind(this);\r\n this.handleCaret = this.handleCaret.bind(this);\r\n this.caretEventHandler = this.caretEventHandler.bind(this);\r\n this.onInit = this.onInit.bind(this);\r\n this.onRender = this.onRender.bind(this);\r\n this.render = this.render.bind(this);\r\n this.loadModules = this.loadModules.bind(this);\r\n this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this);\r\n this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this);\r\n this.handleButtonHold = this.handleButtonHold.bind(this);\r\n this.onModulesLoaded = this.onModulesLoaded.bind(this);\r\n\r\n /**\r\n * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).\r\n * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.\r\n * @example\r\n * // To get entered input\r\n * let input = keyboard.getInput();\r\n * \r\n * // To clear entered input.\r\n * keyboard.clearInput();\r\n * \r\n * @type {object}\r\n * @property {object} default Default SimpleKeyboard internal input.\r\n * @property {object} myInputName Example input that can be set through `options.inputName:\"myInputName\"`.\r\n */\r\n this.input = {};\r\n this.input[this.options.inputName] = '';\r\n\r\n /**\r\n * @type {string} DOM class of the keyboard wrapper, normally \"simple-keyboard\" by default.\r\n */\r\n this.keyboardDOMClass = keyboardDOMQuery.split('.').join(\"\");\r\n\r\n /**\r\n * @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: \"{enter}\").\r\n */\r\n this.buttonElements = {};\r\n\r\n /**\r\n * Rendering keyboard\r\n */\r\n if(this.keyboardDOM)\r\n this.render();\r\n else {\r\n console.warn(`\"${keyboardDOMQuery}\" was not found in the DOM.`);\r\n throw new Error(\"KEYBOARD_DOM_ERROR\");\r\n }\r\n\r\n /**\r\n * Saving instance\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if(!window['SimpleKeyboardInstances'])\r\n window['SimpleKeyboardInstances'] = {};\r\n \r\n window['SimpleKeyboardInstances'][this.utilities.camelCase(this.keyboardDOMClass)] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button){\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if(button === '{//}')\r\n return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if(typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n \r\n if(!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = '';\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button, this.input[this.options.inputName], this.options, this.caretPosition\r\n );\r\n\r\n if(this.input[this.options.inputName] !== updatedInput){\r\n\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if(this.options.maxLength && this.utilities.handleMaxLength(this.input, this.options, updatedInput)){\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button, this.input[this.options.inputName], this.options, this.caretPosition, true\r\n );\r\n\r\n if(debug)\r\n console.log('Input changed:', this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if(typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n }\r\n \r\n if(debug){\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e){\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if(this.holdInteractionTimeout)\r\n clearTimeout(this.holdInteractionTimeout);\r\n\r\n if(this.holdTimeout)\r\n clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if(\r\n this.isMouseHold &&\r\n (\r\n (!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\"\r\n )\r\n ){\r\n if(this.options.debug)\r\n console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp(){\r\n this.isMouseHold = false;\r\n if(this.holdInteractionTimeout)\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button){\r\n if(this.holdInteractionTimeout)\r\n clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if(this.isMouseHold){\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs(){\r\n this.dispatch((instance) => {\r\n instance.replaceInput(this.input);\r\n });\r\n }\r\n \r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName){\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = '';\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Get the keyboard’s input (You can also get it from the onChange prop).\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n getInput(inputName){\r\n inputName = inputName || this.options.inputName;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n\r\n return this.input[this.options.inputName];\r\n }\r\n\r\n /**\r\n * Set the keyboard’s input.\r\n * @param {string} input the input value\r\n * @param {string} inputName optional - the internal input to select\r\n */\r\n setInput(input, inputName){\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = input;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n }\r\n \r\n /**\r\n * Replace the input object (`keyboard.input`)\r\n * @param {object} inputObj The input object\r\n */\r\n replaceInput(inputObj){\r\n this.input = inputObj;\r\n }\r\n\r\n /**\r\n * Set new option or modify existing ones after initialization. \r\n * @param {object} option The option to set\r\n */\r\n setOptions = option => {\r\n option = option || {};\r\n this.options = Object.assign(this.options, option);\r\n this.render();\r\n }\r\n\r\n /**\r\n * Remove all keyboard rows and reset keyboard values.\r\n * Used interally between re-renders.\r\n */\r\n clear(){\r\n this.keyboardDOM.innerHTML = '';\r\n this.keyboardDOM.className = this.keyboardDOMClass;\r\n this.buttonElements = {};\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances at once (if you have multiple instances).\r\n * @param {function(instance: object, key: string)} callback Function to run on every instance\r\n */\r\n dispatch(callback){\r\n if(!window['SimpleKeyboardInstances']){\r\n console.warn(`SimpleKeyboardInstances is not defined. Dispatch cannot be called.`);\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n \r\n return Object.keys(window['SimpleKeyboardInstances']).forEach((key) => {\r\n callback(window['SimpleKeyboardInstances'][key], key);\r\n })\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className){\r\n if(!className || !buttons)\r\n return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if(!this.options.buttonTheme)\r\n this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n \r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n\r\n if(buttonTheme.class.split(\" \").includes(classNameItem)){\r\n classNameFound = true;\r\n \r\n let buttonThemeArray = buttonTheme.buttons.split(\" \");\r\n if(!buttonThemeArray.includes(button)){\r\n classNameFound = true;\r\n buttonThemeArray.push(button);\r\n buttonTheme.buttons = buttonThemeArray.join(\" \");\r\n }\r\n }\r\n return buttonTheme;\r\n });\r\n\r\n /**\r\n * If class is not defined, we create a new entry\r\n */\r\n if(!classNameFound){\r\n this.options.buttonTheme.push({\r\n class: classNameItem,\r\n buttons: buttons\r\n });\r\n }\r\n\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n\r\n /**\r\n * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n removeButtonTheme(buttons, className){\r\n /**\r\n * When called with empty parameters, remove all button themes\r\n */\r\n if(!buttons && !className){\r\n this.options.buttonTheme = [];\r\n this.render();\r\n return false;\r\n }\r\n\r\n /**\r\n * If buttons are passed and buttonTheme has items\r\n */\r\n if(buttons && Array.isArray(this.options.buttonTheme) && this.options.buttonTheme.length){\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if(\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ){\r\n let filteredButtonArray = buttonTheme.buttons.split(\" \").filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if(filteredButtonArray.length){\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n \r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(button){\r\n let output;\r\n\r\n let buttonArr = this.buttonElements[button];\r\n if(buttonArr){\r\n if(buttonArr.length > 1){\r\n output = buttonArr;\r\n } else {\r\n output = buttonArr[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret(){\r\n if(this.options.debug){\r\n console.log(\"Caret handling started\");\r\n }\r\n\r\n document.addEventListener(\"keyup\", this.caretEventHandler);\r\n document.addEventListener(\"mouseup\", this.caretEventHandler);\r\n document.addEventListener(\"touchend\", this.caretEventHandler);\r\n }\r\n\r\n /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event){\r\n let targetTagName;\r\n\r\n if(this.isMouseHold){\r\n this.isMouseHold = false;\r\n }\r\n\r\n if(event.target.tagName){\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n if(\r\n (targetTagName === \"textarea\" ||\r\n targetTagName === \"input\") &&\r\n !this.options.disableCaretPositioning\r\n ){\r\n /**\r\n * Tracks current cursor position\r\n * As keys are pressed, text will be added/removed at that position within the input.\r\n */\r\n this.caretPosition = event.target.selectionStart;\r\n\r\n if(this.options.debug){\r\n console.log('Caret at: ', event.target.selectionStart, event.target.tagName.toLowerCase());\r\n } \r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit(){\r\n if(this.options.debug){\r\n console.log(\"Initialized\");\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if(typeof this.options.onInit === \"function\")\r\n this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n */\r\n onRender(){\r\n if(typeof this.options.onRender === \"function\")\r\n this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded(){\r\n if(typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if(!this.modules[name])\r\n this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n }\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules(){\r\n if(Array.isArray(this.options.modules)){\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if(module.constructor.name && module.constructor.name !== \"Function\"){\r\n let classStr = `module-${this.utilities.camelCase(module.constructor.name)}`;\r\n this.keyboardPluginClasses = this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses = this.keyboardPluginClasses + ' modules-loaded';\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp = (name, prop) => {\r\n if(!this.modules[name])\r\n return false;\r\n \r\n return this.modules[name][prop];\r\n }\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList = () => {\r\n return Object.keys(this.modules);\r\n }\r\n\r\n /**\r\n * Renders rows and buttons as per options\r\n */\r\n render(){\r\n /**\r\n * Clear keyboard\r\n */\r\n this.clear();\r\n\r\n let layoutClass = this.options.layout ? \"hg-layout-custom\" : `hg-layout-${this.options.layoutName}`;\r\n let layout = this.options.layout || KeyboardLayout.getDefaultLayout();\r\n let useTouchEvents = this.options.useTouchEvents || false\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = {};\r\n if(Array.isArray(this.options.buttonTheme)){\r\n this.options.buttonTheme.forEach(themeObj => {\r\n if(themeObj.buttons && themeObj.class){\r\n let themeButtons;\r\n\r\n if(typeof themeObj.buttons === \"string\"){\r\n themeButtons = themeObj.buttons.split(' ');\r\n }\r\n\r\n if(themeButtons){\r\n themeButtons.forEach(themeButton => {\r\n let themeParsed = buttonThemesParsed[themeButton];\r\n\r\n // If the button has already been added\r\n if(themeParsed){\r\n // Making sure we don't add duplicate classes, even when buttonTheme has duplicates\r\n if(!this.utilities.countInArray(themeParsed.split(\" \"), themeObj.class)){\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${themeObj.class}`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(`buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.`)\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses}`;\r\n\r\n /**\r\n * Iterating through each row\r\n */\r\n layout[this.options.layoutName].forEach((row, rIndex) => {\r\n let rowArray = row.split(' ');\r\n\r\n /**\r\n * Creating empty row\r\n */\r\n var rowDOM = document.createElement('div');\r\n rowDOM.className += \"hg-row\";\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n let fctBtnClass = this.utilities.getButtonClass(button);\r\n let buttonThemeClass = buttonThemesParsed[button];\r\n let buttonDisplayName = this.utilities.getButtonDisplayName(button, this.options.display, this.options.mergeDisplay);\r\n\r\n /**\r\n * Creating button\r\n */\r\n var buttonDOM = document.createElement('div');\r\n buttonDOM.className += `hg-button ${fctBtnClass}${buttonThemeClass ? \" \"+buttonThemeClass : \"\"}`;\r\n \r\n if (useTouchEvents) {\r\n buttonDOM.ontouchstart = (e) => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n }\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n }\r\n buttonDOM.onmousedown = (e) => {\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n this.handleButtonMouseDown(button, e);\r\n }\r\n }\r\n \r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n var buttonSpanDOM = document.createElement('span');\r\n buttonSpanDOM.innerHTML = buttonDisplayName;\r\n buttonDOM.appendChild(buttonSpanDOM);\r\n\r\n /**\r\n * Adding to buttonElements\r\n */\r\n if(!this.buttonElements[button])\r\n this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n\r\n });\r\n\r\n /**\r\n * Appending row to keyboard\r\n */\r\n this.keyboardDOM.appendChild(rowDOM);\r\n });\r\n\r\n /**\r\n * Calling onRender\r\n */\r\n this.onRender();\r\n\r\n if(!this.initialized){\r\n /**\r\n * Ensures that onInit is only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling mouseup\r\n */\r\n if (!useTouchEvents) {\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from './components/Keyboard';\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""}