mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-20 01:22:59 +08:00
1 line
130 KiB
Plaintext
1 line
130 KiB
Plaintext
{"version":3,"sources":["webpack://SimpleKeyboard/webpack/universalModuleDefinition","webpack://SimpleKeyboard/webpack/bootstrap","webpack://SimpleKeyboard/webpack/runtime/define property getters","webpack://SimpleKeyboard/webpack/runtime/hasOwnProperty shorthand","webpack://SimpleKeyboard/webpack/runtime/make namespace object","webpack://SimpleKeyboard/./src/lib/services/Utilities.ts","webpack://SimpleKeyboard/./src/lib/services/PhysicalKeyboard.ts","webpack://SimpleKeyboard/./src/lib/components/CandidateBox.ts","webpack://SimpleKeyboard/./src/lib/components/Keyboard.ts","webpack://SimpleKeyboard/./src/lib/services/KeyboardLayout.ts","webpack://SimpleKeyboard/./src/lib/index.modern.ts"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","Utilities","getOptions","getCaretPosition","getCaretPositionEnd","dispatch","button","length","bindMethods","includes","buttonTypeClass","getButtonType","buttonWithoutBraces","replace","buttonNormalized","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","caretPosEnd","moveCaret","options","commonParams","output","removeAt","removeForwardsAt","addStringAt","tabCharOnTab","newLineOnEnter","Number","isInteger","minus","newCaretPos","updateCaretPosAction","instance","setCaretPosition","caretPosition","debug","console","log","source","str","position","positionEnd","slice","join","isMaxLengthReached","updateCaretPos","emojiMatchedReg","substring","match","substr","nextTwoChars","emojiMatched","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","Boolean","window","navigator","maxTouchPoints","PointerEvent","toLowerCase","trim","split","reduce","word","toUpperCase","arr","size","Array","Math","ceil","map","_","i","index","newIndex","startMarkerIndex","indexOf","myClass","getOwnPropertyNames","myMethod","bind","PhysicalKeyboard","event","buttonPressed","getSimpleKeyboardLayoutKey","buttonDOM","buttonName","standardButtonPressed","getButtonElement","functionButtonPressed","style","background","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","physicalKeyboardHighlightPress","physicalKeyboardHighlightPressUsePointerEvents","onpointerdown","physicalKeyboardHighlightPressUseClick","click","handleButtonClicked","removeAttribute","onpointerup","keyId","code","keyCodeToKey","keyCode","CandidateBox","utilities","pageSize","layoutCandidatesPageSize","candidateBoxElement","remove","pageIndex","candidateValue","targetElement","onSelect","candidateListPages","chunkArray","renderPage","nbPages","onItemSelected","selectedCandidate","e","destroy","document","createElement","className","candidateListULElement","forEach","candidateListItem","candidateListLIElement","getMouseEvent","mouseEvent","MouseEvent","textContent","onclick","appendChild","isPrevBtnElementActive","prevBtnElement","classList","add","isNextBtnElementActive","nextBtnElement","prepend","SimpleKeyboard","selectorOrOptions","keyboardOptions","keyboardDOMClass","keyboardDOM","querySelector","HTMLDivElement","warn","Error","caretPositionEnd","name","initCallback","modules","baseDOMClasses","keyboardClasses","filter","DOMClass","handleParams","layoutName","theme","preventMouseDownDefault","enableLayoutCandidates","excludeFromLayout","keyboardPluginClasses","defaultName","buttonElements","currentInstanceName","camelCase","allKeyboardInstances","keyboardInstanceNames","keys","isFirstKeyboardInstance","physicalKeyboard","candidateBox","render","loadModules","endPosition","layoutCandidatesObj","layoutCandidates","layoutCandidatesCaseSensitiveMatch","layoutCandidate","inputSubstr","regexp","RegExp","escapeRegex","matchAll","candidateKey","sort","a","b","show","candidateStr","disableCandidateNormalization","normalize","getInput","initialCaretPosition","newInputSubstr","newInput","caretPositionDiff","newCaretPosition","setInput","onChange","onChangeAll","getAllInputs","getUpdatedInput","isStandardButton","activeInputElement","setSelectionRange","onKeyPress","inputPattern","inputPatternIsValid","handleMaxLength","newInputValue","syncInstanceInputs","target","getInputCandidates","showCandidatesBox","isMouseHold","preventDefault","stopMouseDownPropagation","stopPropagation","activeButtonClass","holdInteractionTimeout","clearTimeout","holdTimeout","setMouseHold","disableButtonHold","setTimeout","getMouseHold","handleButtonHold","preventMouseUpDefault","stopMouseUpPropagation","contains","recurseButtons","buttonElement","onKeyReleased","replaceInput","skipSync","rtl","inputWithoutRTLControl","changedOptions","onSetOptions","newOptions","optionName","JSON","stringify","keyboardRowsDOM","setAttribute","callback","buttons","classNameItem","buttonTheme","classNameFound","buttonThemeArray","push","class","isArray","filteredButtonArray","item","splice","buttonArr","inputVal","inputPatternRaw","didInputMatch","test","addEventListener","handleKeyUp","handleKeyDown","handleMouseUp","handleTouchEnd","handleSelect","handleSelectionChange","caretEventHandler","physicalKeyboardHighlight","handleHighlightKeyUp","handleHighlightKeyDown","targetTagName","tagName","isKeyboard","path","some","hasAttribute","type","disableCaretPositioning","selectionStart","selectionEnd","getRtlOffset","fn","removeEventListener","ontouchend","ontouchcancel","onmouseup","onpointercancel","ontouchstart","onmousedown","resetRows","innerHTML","initialized","buttonClasses","themeObj","themeObjClasses","buttonAttributes","attrObj","attribute","processAutoTouchEvents","disableContextualWindow","oncontextmenu","autoUseTouchEvents","useTouchEvents","setEventListeners","onInit","isTouchDevice","onTouchDeviceDetected","beforeFirstRender","pointerEventsSupported","useMouseEvents","beforeRender","onRender","onModulesLoaded","KeyboardModule","keyboardModule","init","rowDOM","rowIndex","containerStartIndexes","containerEndIndexes","rowDOMArray","from","children","removedElements","startIndex","arrIndex","endIndex","updated_startIndex","updated_endIndex","containerDOM","containerUID","containedElements","element","layoutClass","layout","default","shift","useTouchEventsClass","disableRowButtonContainers","getKeyboardClassString","row","rIndex","rowArray","bIndex","buttonHasContainerStart","buttonHasContainerEnd","fctBtnClass","getButtonClass","buttonDisplayName","getButtonDisplayName","buttonType","useButtonTag","getButtonThemeClasses","setDOMButtonAttributes","handleButtonMouseDown","handleButtonMouseUp","buttonUID","buttonSpanDOM","parseRowDOMContainers","undefined","handleKeyboardContainerMouseDown"],"mappings":";;;;;;;;;;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IA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AWvP,EAAE,EACxCE,SAAS0K,cAAgB,SAAC5K,GAAuB,OAC/C,EAAKmP,yBAAoBI,EAAWvP,EAAE,EAExCpJ,KAAK8K,YAAYqJ,aAAe,SAAC/K,GAAuB,OACtD,EAAKwP,iCAAiCxP,EAAE,GAChC8L,IAIV5L,SAAS2K,UAAY,SAAC7K,GAAuB,OAC3C,EAAKmP,yBAAoBI,EAAWvP,EAAE,EACxCpJ,KAAK8K,YAAYsJ,YAAc,SAAChL,GAAuB,OACrD,EAAKwP,iCAAiCxP,EAAE,IAtB1CE,SAASvB,YAAc,SAACqB,GAAuB,OAC7C,EAAKmP,yBAAoBI,EAAWvP,EAAE,EACxCpJ,KAAK8K,YAAYpD,cAAgB,SAAC0B,GAAuB,OACvD,EAAKwP,iCAAiCxP,EAAE,GAyB5CpJ,KAAKoV,SAET,I,iFAAC,EAj8DiB,GAo8DpB,IEx9DA,I","file":"index.modern.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([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(this, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { KeyboardInput } from \"./../interfaces\";\r\nimport { KeyboardOptions, UtilitiesParams } from \"../interfaces\";\r\n\r\n/**\r\n * Utility Service\r\n */\r\nclass Utilities {\r\n getOptions: () => KeyboardOptions;\r\n getCaretPosition: () => number | null;\r\n getCaretPositionEnd: () => number | null;\r\n dispatch: any;\r\n maxLengthReached!: boolean;\r\n\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor({\r\n getOptions,\r\n getCaretPosition,\r\n getCaretPositionEnd,\r\n dispatch,\r\n }: UtilitiesParams) {\r\n this.getOptions = getOptions;\r\n this.getCaretPosition = getCaretPosition;\r\n this.getCaretPositionEnd = getCaretPositionEnd;\r\n this.dispatch = dispatch;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(Utilities, this);\r\n }\r\n\r\n /**\r\n * Retrieve button type\r\n *\r\n * @param {string} button The button's layout name\r\n * @return {string} The button type\r\n */\r\n getButtonType(button: string): string {\r\n return button.includes(\"{\") && button.includes(\"}\") && button !== \"{//}\"\r\n ? \"functionBtn\"\r\n : \"standardBtn\";\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: string): string {\r\n const buttonTypeClass = this.getButtonType(button);\r\n const 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 \"{forwarddelete}\": \"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(\r\n button: string,\r\n display: KeyboardOptions[\"display\"],\r\n mergeDisplay: boolean\r\n ) {\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 * 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 {number} caretPos The cursor's current position\r\n * @param {number} caretPosEnd The cursor's current end position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(\r\n button: string,\r\n input: string,\r\n caretPos: number,\r\n caretPosEnd = caretPos,\r\n moveCaret = false\r\n ) {\r\n const options = this.getOptions();\r\n const commonParams: [number, number, boolean] = [\r\n caretPos,\r\n caretPosEnd,\r\n moveCaret,\r\n ];\r\n\r\n let output = input;\r\n\r\n if (\r\n (button === \"{bksp}\" || button === \"{backspace}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeAt(output, ...commonParams);\r\n } else if (\r\n (button === \"{delete}\" || button === \"{forwarddelete}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeForwardsAt(output, ...commonParams);\r\n } else if (button === \"{space}\")\r\n output = this.addStringAt(output, \" \", ...commonParams);\r\n else if (\r\n button === \"{tab}\" &&\r\n !(\r\n typeof options.tabCharOnTab === \"boolean\" &&\r\n options.tabCharOnTab === false\r\n )\r\n ) {\r\n output = this.addStringAt(output, \"\\t\", ...commonParams);\r\n } else if (\r\n (button === \"{enter}\" || button === \"{numpadenter}\") &&\r\n options.newLineOnEnter\r\n )\r\n output = this.addStringAt(output, \"\\n\", ...commonParams);\r\n else if (\r\n button.includes(\"numpad\") &&\r\n Number.isInteger(Number(button[button.length - 2]))\r\n ) {\r\n output = this.addStringAt(\r\n output,\r\n button[button.length - 2],\r\n ...commonParams\r\n );\r\n } else if (button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, \"/\", ...commonParams);\r\n else if (button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, \"*\", ...commonParams);\r\n else if (button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, \"-\", ...commonParams);\r\n else if (button === \"{numpadadd}\")\r\n output = this.addStringAt(output, \"+\", ...commonParams);\r\n else if (button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, \".\", ...commonParams);\r\n else if (button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, ...commonParams);\r\n else if (!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, ...commonParams);\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: number, minus = false) {\r\n const newCaretPos = this.updateCaretPosAction(length, minus);\r\n\r\n this.dispatch((instance: any) => {\r\n instance.setCaretPosition(newCaretPos);\r\n });\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\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 updateCaretPosAction(length: number, minus = false) {\r\n const options = this.getOptions();\r\n let caretPosition = this.getCaretPosition();\r\n\r\n if (caretPosition != null) {\r\n if (minus) {\r\n if (caretPosition > 0) caretPosition = caretPosition - length;\r\n } else {\r\n caretPosition = caretPosition + length;\r\n }\r\n }\r\n\r\n if (options.debug) {\r\n console.log(\"Caret at:\", caretPosition);\r\n }\r\n\r\n return caretPosition;\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} str 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(\r\n source: string,\r\n str: string,\r\n position = source.length,\r\n positionEnd = source.length,\r\n moveCaret = false\r\n ) {\r\n let output;\r\n\r\n if (!position && position !== 0) {\r\n output = source + str;\r\n } else {\r\n output = [source.slice(0, position), str, source.slice(positionEnd)].join(\r\n \"\"\r\n );\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(str.length);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Check whether the button is a standard button\r\n */\r\n isStandardButton = (button: string) =>\r\n button && !(button[0] === \"{\" && button[button.length - 1] === \"}\");\r\n\r\n /**\r\n * Removes an amount of characters before 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(\r\n source: string,\r\n position = source.length,\r\n positionEnd = source.length,\r\n moveCaret = false\r\n ) {\r\n if (position === 0 && positionEnd === 0) {\r\n return source;\r\n }\r\n\r\n let output;\r\n\r\n if (position === positionEnd) {\r\n let prevTwoChars;\r\n let emojiMatched;\r\n const 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 } else {\r\n output = source.slice(0, position) + source.slice(positionEnd);\r\n if (moveCaret) {\r\n this.dispatch((instance: any) => {\r\n instance.setCaretPosition(position);\r\n });\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters after 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 */\r\n removeForwardsAt(\r\n source: string,\r\n position: number = source.length,\r\n positionEnd: number = source.length,\r\n moveCaret = false\r\n ) {\r\n if (!source?.length || position === null) {\r\n return source;\r\n }\r\n\r\n let output;\r\n\r\n if (position === positionEnd) {\r\n const 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 const nextTwoChars = source.substring(position, position + 2);\r\n const emojiMatched = nextTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.substr(0, position) + source.substr(position + 2);\r\n } else {\r\n output = source.substr(0, position) + source.substr(position + 1);\r\n }\r\n } else {\r\n output = source.slice(0, position) + source.slice(positionEnd);\r\n if (moveCaret) {\r\n this.dispatch((instance: any) => {\r\n instance.setCaretPosition(position);\r\n });\r\n }\r\n }\r\n\r\n return output;\r\n }\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 {string} updatedInput\r\n */\r\n handleMaxLength(inputObj: KeyboardInput, updatedInput: string) {\r\n const options = this.getOptions();\r\n const maxLength = options.maxLength;\r\n const currentInput = inputObj[options.inputName || \"default\"];\r\n const condition = updatedInput.length - 1 >= 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 const condition =\r\n updatedInput.length - 1 >= maxLength[options.inputName || \"default\"];\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 * Determines whether a touch device is being used\r\n */\r\n isTouchDevice() {\r\n return \"ontouchstart\" in window || navigator.maxTouchPoints;\r\n }\r\n\r\n /**\r\n * Determines whether pointer events are supported\r\n */\r\n pointerEventsSupported() {\r\n return !!window.PointerEvent;\r\n }\r\n\r\n /**\r\n * Bind all methods in a given class\r\n */\r\n\r\n static bindMethods(myClass: any, instance: any) {\r\n // eslint-disable-next-line no-unused-vars\r\n for (const myMethod of Object.getOwnPropertyNames(myClass.prototype)) {\r\n const excludeMethod =\r\n myMethod === \"constructor\" || myMethod === \"bindMethods\";\r\n if (!excludeMethod) {\r\n instance[myMethod] = instance[myMethod].bind(instance);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} str The string to transform.\r\n */\r\n camelCase(str: string): string {\r\n if (!str) return \"\";\r\n\r\n return str\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce((str, word) =>\r\n word.length ? str + word[0].toUpperCase() + word.slice(1) : str\r\n );\r\n }\r\n\r\n /**\r\n * Split array into chunks\r\n */\r\n chunkArray<T>(arr: T[], size: number): T[][] {\r\n return [...Array(Math.ceil(arr.length / size))].map((_, i) =>\r\n arr.slice(size * i, size + size * i)\r\n );\r\n }\r\n\r\n /**\r\n * Escape regex input\r\n */\r\n escapeRegex(str: string) {\r\n return str.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\r\n }\r\n\r\n /**\r\n * Calculate caret position offset when using rtl option\r\n */\r\n getRtlOffset(index: number, input: string) {\r\n let newIndex = index;\r\n const startMarkerIndex = input.indexOf(\"\\u202B\");\r\n const endMarkerIndex = input.indexOf(\"\\u202C\");\r\n\r\n if(startMarkerIndex < index && startMarkerIndex != -1){ newIndex--; }\r\n if(endMarkerIndex < index && startMarkerIndex != -1){ newIndex--; }\r\n\r\n return newIndex < 0 ? 0 : newIndex;\r\n }\r\n\r\n /**\r\n * Reusable empty function\r\n */\r\n static noop = () => {};\r\n}\r\n\r\nexport default Utilities;\r\n","import { KeyboardOptions, PhysicalKeyboardParams } from \"../interfaces\";\r\nimport Utilities from \"../services/Utilities\";\r\n\r\n/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n getOptions: () => KeyboardOptions;\r\n dispatch: any;\r\n\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor({ dispatch, getOptions }: PhysicalKeyboardParams) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.dispatch = dispatch;\r\n this.getOptions = getOptions;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(PhysicalKeyboard, this);\r\n }\r\n\r\n handleHighlightKeyDown(event: KeyboardEvent) {\r\n const options = this.getOptions();\r\n const buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.dispatch((instance: any) => {\r\n const standardButtonPressed = instance.getButtonElement(buttonPressed);\r\n const functionButtonPressed = instance.getButtonElement(\r\n `{${buttonPressed}}`\r\n );\r\n let buttonDOM;\r\n let buttonName;\r\n\r\n if (standardButtonPressed) {\r\n buttonDOM = standardButtonPressed;\r\n buttonName = buttonPressed;\r\n } else if (functionButtonPressed) {\r\n buttonDOM = functionButtonPressed;\r\n buttonName = `{${buttonPressed}}`;\r\n } else {\r\n return;\r\n }\r\n\r\n if (buttonDOM) {\r\n buttonDOM.style.background =\r\n options.physicalKeyboardHighlightBgColor || \"#dadce4\";\r\n buttonDOM.style.color =\r\n options.physicalKeyboardHighlightTextColor || \"black\";\r\n\r\n if (options.physicalKeyboardHighlightPress) {\r\n if (options.physicalKeyboardHighlightPressUsePointerEvents) {\r\n buttonDOM.onpointerdown();\r\n } else if (options.physicalKeyboardHighlightPressUseClick) {\r\n buttonDOM.click();\r\n } else {\r\n instance.handleButtonClicked(buttonName, event);\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n handleHighlightKeyUp(event: KeyboardEvent) {\r\n const options = this.getOptions();\r\n const buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.dispatch((instance: any) => {\r\n const buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM && buttonDOM.removeAttribute) {\r\n buttonDOM.removeAttribute(\"style\");\r\n if (options.physicalKeyboardHighlightPressUsePointerEvents) {\r\n buttonDOM.onpointerup();\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: KeyboardEvent) {\r\n let output = \"\";\r\n const keyId = event.code || event.key || this.keyCodeToKey(event?.keyCode);\r\n\r\n if (\r\n keyId?.includes(\"Numpad\") ||\r\n keyId?.includes(\"Shift\") ||\r\n keyId?.includes(\"Space\") ||\r\n keyId?.includes(\"Backspace\") ||\r\n keyId?.includes(\"Control\") ||\r\n keyId?.includes(\"Alt\") ||\r\n keyId?.includes(\"Meta\")\r\n ) {\r\n output = event.code || \"\";\r\n } else {\r\n output = event.key || this.keyCodeToKey(event?.keyCode) || \"\";\r\n }\r\n\r\n return output.length > 1 ? output?.toLowerCase() : output;\r\n }\r\n\r\n /**\r\n * Retrieve key from keyCode\r\n */\r\n keyCodeToKey(keyCode: number) {\r\n return {\r\n 8: \"Backspace\",\r\n 9: \"Tab\",\r\n 13: \"Enter\",\r\n 16: \"Shift\",\r\n 17: \"Ctrl\",\r\n 18: \"Alt\",\r\n 19: \"Pause\",\r\n 20: \"CapsLock\",\r\n 27: \"Esc\",\r\n 32: \"Space\",\r\n 33: \"PageUp\",\r\n 34: \"PageDown\",\r\n 35: \"End\",\r\n 36: \"Home\",\r\n 37: \"ArrowLeft\",\r\n 38: \"ArrowUp\",\r\n 39: \"ArrowRight\",\r\n 40: \"ArrowDown\",\r\n 45: \"Insert\",\r\n 46: \"Delete\",\r\n 48: \"0\",\r\n 49: \"1\",\r\n 50: \"2\",\r\n 51: \"3\",\r\n 52: \"4\",\r\n 53: \"5\",\r\n 54: \"6\",\r\n 55: \"7\",\r\n 56: \"8\",\r\n 57: \"9\",\r\n 65: \"A\",\r\n 66: \"B\",\r\n 67: \"C\",\r\n 68: \"D\",\r\n 69: \"E\",\r\n 70: \"F\",\r\n 71: \"G\",\r\n 72: \"H\",\r\n 73: \"I\",\r\n 74: \"J\",\r\n 75: \"K\",\r\n 76: \"L\",\r\n 77: \"M\",\r\n 78: \"N\",\r\n 79: \"O\",\r\n 80: \"P\",\r\n 81: \"Q\",\r\n 82: \"R\",\r\n 83: \"S\",\r\n 84: \"T\",\r\n 85: \"U\",\r\n 86: \"V\",\r\n 87: \"W\",\r\n 88: \"X\",\r\n 89: \"Y\",\r\n 90: \"Z\",\r\n 91: \"Meta\",\r\n 96: \"Numpad0\",\r\n 97: \"Numpad1\",\r\n 98: \"Numpad2\",\r\n 99: \"Numpad3\",\r\n 100: \"Numpad4\",\r\n 101: \"Numpad5\",\r\n 102: \"Numpad6\",\r\n 103: \"Numpad7\",\r\n 104: \"Numpad8\",\r\n 105: \"Numpad9\",\r\n 106: \"NumpadMultiply\",\r\n 107: \"NumpadAdd\",\r\n 109: \"NumpadSubtract\",\r\n 110: \"NumpadDecimal\",\r\n 111: \"NumpadDivide\",\r\n 112: \"F1\",\r\n 113: \"F2\",\r\n 114: \"F3\",\r\n 115: \"F4\",\r\n 116: \"F5\",\r\n 117: \"F6\",\r\n 118: \"F7\",\r\n 119: \"F8\",\r\n 120: \"F9\",\r\n 121: \"F10\",\r\n 122: \"F11\",\r\n 123: \"F12\",\r\n 144: \"NumLock\",\r\n 145: \"ScrollLock\",\r\n 186: \";\",\r\n 187: \"=\",\r\n 188: \",\",\r\n 189: \"-\",\r\n 190: \".\",\r\n 191: \"/\",\r\n 192: \"`\",\r\n 219: \"[\",\r\n 220: \"\\\\\",\r\n 221: \"]\",\r\n 222: \"'\",\r\n }[keyCode];\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;\r\n","import \"./css/CandidateBox.css\";\r\n\r\nimport Utilities from \"../services/Utilities\";\r\nimport {\r\n CandidateBoxParams,\r\n CandidateBoxRenderParams,\r\n CandidateBoxShowParams,\r\n KeyboardOptions,\r\n} from \"./../interfaces\";\r\n\r\nclass CandidateBox {\r\n utilities: Utilities;\r\n options: KeyboardOptions;\r\n candidateBoxElement!: HTMLDivElement;\r\n pageIndex = 0;\r\n pageSize;\r\n\r\n constructor({ utilities, options }: CandidateBoxParams) {\r\n this.utilities = utilities;\r\n this.options = options;\r\n Utilities.bindMethods(CandidateBox, this);\r\n this.pageSize = this.utilities.getOptions().layoutCandidatesPageSize || 5;\r\n }\r\n\r\n destroy() {\r\n if (this.candidateBoxElement) {\r\n this.candidateBoxElement.remove();\r\n this.pageIndex = 0;\r\n }\r\n }\r\n\r\n show({\r\n candidateValue,\r\n targetElement,\r\n onSelect,\r\n }: CandidateBoxShowParams): void {\r\n if (!candidateValue || !candidateValue.length) {\r\n return;\r\n }\r\n\r\n const candidateListPages = this.utilities.chunkArray(\r\n candidateValue.split(\" \"),\r\n this.pageSize\r\n );\r\n\r\n this.renderPage({\r\n candidateListPages,\r\n targetElement,\r\n pageIndex: this.pageIndex,\r\n nbPages: candidateListPages.length,\r\n onItemSelected: (selectedCandidate: string, e: MouseEvent) => {\r\n onSelect(selectedCandidate, e);\r\n this.destroy();\r\n },\r\n });\r\n }\r\n\r\n renderPage({\r\n candidateListPages,\r\n targetElement,\r\n pageIndex,\r\n nbPages,\r\n onItemSelected,\r\n }: CandidateBoxRenderParams) {\r\n // Remove current candidate box, if any\r\n this.candidateBoxElement?.remove();\r\n\r\n // Create candidate box element\r\n this.candidateBoxElement = document.createElement(\"div\");\r\n this.candidateBoxElement.className = \"hg-candidate-box\";\r\n\r\n // Candidate box list\r\n const candidateListULElement = document.createElement(\"ul\");\r\n candidateListULElement.className = \"hg-candidate-box-list\";\r\n\r\n // Create Candidate box list items\r\n candidateListPages[pageIndex].forEach((candidateListItem) => {\r\n const candidateListLIElement = document.createElement(\"li\");\r\n const getMouseEvent = () => {\r\n const mouseEvent = new MouseEvent(\"click\");\r\n Object.defineProperty(mouseEvent, \"target\", {\r\n value: candidateListLIElement,\r\n });\r\n return mouseEvent;\r\n };\r\n\r\n candidateListLIElement.className = \"hg-candidate-box-list-item\";\r\n candidateListLIElement.textContent = this.options.display?.[candidateListItem] || candidateListItem;\r\n candidateListLIElement.onclick = (e = getMouseEvent()) =>\r\n onItemSelected(candidateListItem, e);\r\n\r\n // Append list item to ul\r\n candidateListULElement.appendChild(candidateListLIElement);\r\n });\r\n\r\n // Add previous button\r\n const isPrevBtnElementActive = pageIndex > 0;\r\n const prevBtnElement = document.createElement(\"div\");\r\n prevBtnElement.classList.add(\"hg-candidate-box-prev\");\r\n isPrevBtnElementActive &&\r\n prevBtnElement.classList.add(\"hg-candidate-box-btn-active\");\r\n prevBtnElement.onclick = () => {\r\n if (!isPrevBtnElementActive) return;\r\n this.renderPage({\r\n candidateListPages,\r\n targetElement,\r\n pageIndex: pageIndex - 1,\r\n nbPages,\r\n onItemSelected,\r\n });\r\n };\r\n this.candidateBoxElement.appendChild(prevBtnElement);\r\n\r\n // Add elements to container\r\n this.candidateBoxElement.appendChild(candidateListULElement);\r\n\r\n // Add next button\r\n const isNextBtnElementActive = pageIndex < nbPages - 1;\r\n const nextBtnElement = document.createElement(\"div\");\r\n nextBtnElement.classList.add(\"hg-candidate-box-next\");\r\n isNextBtnElementActive &&\r\n nextBtnElement.classList.add(\"hg-candidate-box-btn-active\");\r\n\r\n nextBtnElement.onclick = () => {\r\n if (!isNextBtnElementActive) return;\r\n this.renderPage({\r\n candidateListPages,\r\n targetElement,\r\n pageIndex: pageIndex + 1,\r\n nbPages,\r\n onItemSelected,\r\n });\r\n };\r\n this.candidateBoxElement.appendChild(nextBtnElement);\r\n\r\n // Append candidate box to target element\r\n targetElement.prepend(this.candidateBoxElement);\r\n }\r\n}\r\n\r\nexport default CandidateBox;\r\n","import \"./css/Keyboard.css\";\r\n\r\n// Services\r\nimport { getDefaultLayout } from \"../services/KeyboardLayout\";\r\nimport PhysicalKeyboard from \"../services/PhysicalKeyboard\";\r\nimport Utilities from \"../services/Utilities\";\r\nimport {\r\n KeyboardOptions,\r\n KeyboardInput,\r\n KeyboardButtonElements,\r\n KeyboardHandlerEvent,\r\n KeyboardElement,\r\n} from \"../interfaces\";\r\nimport CandidateBox from \"./CandidateBox\";\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 input!: KeyboardInput;\r\n options!: KeyboardOptions;\r\n utilities: any;\r\n caretPosition!: number | null;\r\n caretPositionEnd!: number | null;\r\n keyboardDOM!: KeyboardElement;\r\n keyboardPluginClasses!: string;\r\n keyboardDOMClass!: string;\r\n buttonElements!: KeyboardButtonElements;\r\n currentInstanceName!: string;\r\n allKeyboardInstances!: { [key: string]: SimpleKeyboard };\r\n keyboardInstanceNames!: string[];\r\n isFirstKeyboardInstance!: boolean;\r\n physicalKeyboard!: PhysicalKeyboard;\r\n modules!: { [key: string]: any };\r\n activeButtonClass!: string;\r\n holdInteractionTimeout!: number;\r\n holdTimeout!: number;\r\n isMouseHold!: boolean;\r\n initialized!: boolean;\r\n candidateBox!: CandidateBox | null;\r\n keyboardRowsDOM!: KeyboardElement;\r\n defaultName = \"default\";\r\n activeInputElement: HTMLInputElement | HTMLTextAreaElement | null = null;\r\n\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(\r\n selectorOrOptions?: string | HTMLDivElement | KeyboardOptions,\r\n keyboardOptions?: KeyboardOptions\r\n ) {\r\n if (typeof window === \"undefined\") return;\r\n\r\n const {\r\n keyboardDOMClass,\r\n keyboardDOM,\r\n options = {},\r\n } = this.handleParams(selectorOrOptions, keyboardOptions);\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities({\r\n getOptions: this.getOptions,\r\n getCaretPosition: this.getCaretPosition,\r\n getCaretPositionEnd: this.getCaretPositionEnd,\r\n dispatch: this.dispatch,\r\n });\r\n\r\n /**\r\n * Caret position\r\n */\r\n this.caretPosition = null;\r\n\r\n /**\r\n * Caret position end\r\n */\r\n this.caretPositionEnd = null;\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = keyboardDOM;\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 {array} buttonAttributes A prop to add your own attributes 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} physicalKeyboardHighlightPress Presses keys highlighted by physicalKeyboardHighlight\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 {boolean} physicalKeyboardHighlightPressUseClick Whether physicalKeyboardHighlightPress should use clicks to trigger buttons.\r\n * @property {boolean} physicalKeyboardHighlightPressUsePointerEvents Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {boolean} preventMouseUpDefault Calling preventDefault for the mouseup events.\r\n * @property {boolean} stopMouseDownPropagation Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.\r\n * @property {boolean} stopMouseUpPropagation Stops pointer up events on simple-keyboard buttons from bubbling to parent elements.\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 * @property {boolean} useButtonTag Render buttons as a button element instead of a div element.\r\n * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.\r\n * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.\r\n * @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.\r\n * @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.\r\n * @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.\r\n * @property {function} destroy Clears keyboard listeners and DOM elements.\r\n * @property {boolean} disableButtonHold Disable button hold action.\r\n * @property {boolean} rtl Adds unicode right-to-left control characters to input return values.\r\n * @property {function} onKeyReleased Executes the callback function on key release.\r\n * @property {array} modules Module classes to be loaded by simple-keyboard.\r\n * @property {boolean} enableLayoutCandidates Enable input method editor candidate list support.\r\n * @property {object} excludeFromLayout Buttons to exclude from layout\r\n * @property {number} layoutCandidatesPageSize Determines size of layout candidate list\r\n * @property {boolean} layoutCandidatesCaseSensitiveMatch Determines whether layout candidate match should be case sensitive.\r\n * @property {boolean} disableCandidateNormalization Disables the automatic normalization for selected layout candidates\r\n */\r\n this.options = {\r\n layoutName: \"default\",\r\n theme: \"hg-theme-default\",\r\n inputName: \"default\",\r\n preventMouseDownDefault: false,\r\n enableLayoutCandidates: true,\r\n excludeFromLayout: {},\r\n ...options,\r\n };\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 Utilities.bindMethods(SimpleKeyboard, 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 * const 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 const { inputName = this.defaultName } = this.options;\r\n this.input = {};\r\n this.input[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 = keyboardDOMClass;\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 * Simple-keyboard Instances\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 this.currentInstanceName = this.utilities.camelCase(this.keyboardDOMClass);\r\n window[\"SimpleKeyboardInstances\"][this.currentInstanceName] = this;\r\n\r\n /**\r\n * Instance vars\r\n */\r\n this.allKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n this.keyboardInstanceNames = Object.keys(window[\"SimpleKeyboardInstances\"]);\r\n this.isFirstKeyboardInstance =\r\n this.keyboardInstanceNames[0] === this.currentInstanceName;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboard = new PhysicalKeyboard({\r\n dispatch: this.dispatch,\r\n getOptions: this.getOptions,\r\n });\r\n\r\n /**\r\n * Initializing CandidateBox\r\n */\r\n this.candidateBox = this.options.enableLayoutCandidates\r\n ? new CandidateBox({\r\n utilities: this.utilities,\r\n options: this.options,\r\n })\r\n : null;\r\n\r\n /**\r\n * Rendering keyboard\r\n */\r\n if (this.keyboardDOM) this.render();\r\n else {\r\n console.warn(`\".${keyboardDOMClass}\" was not found in the DOM.`);\r\n throw new Error(\"KEYBOARD_DOM_ERROR\");\r\n }\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 * parseParams\r\n */\r\n handleParams = (\r\n selectorOrOptions?: string | HTMLDivElement | KeyboardOptions,\r\n keyboardOptions?: KeyboardOptions\r\n ): {\r\n keyboardDOMClass: string;\r\n keyboardDOM: KeyboardElement;\r\n options: Partial<KeyboardOptions | undefined>;\r\n } => {\r\n let keyboardDOMClass;\r\n let keyboardDOM;\r\n let options;\r\n\r\n /**\r\n * If first parameter is a string:\r\n * Consider it as an element's class\r\n */\r\n if (typeof selectorOrOptions === \"string\") {\r\n keyboardDOMClass = selectorOrOptions.split(\".\").join(\"\");\r\n keyboardDOM = document.querySelector(\r\n `.${keyboardDOMClass}`\r\n ) as KeyboardElement;\r\n options = keyboardOptions;\r\n\r\n /**\r\n * If first parameter is an KeyboardElement\r\n * Consider it as the keyboard DOM element\r\n */\r\n } else if (selectorOrOptions instanceof HTMLDivElement) {\r\n /**\r\n * This element must have a class, otherwise throw\r\n */\r\n if (!selectorOrOptions.className) {\r\n console.warn(\"Any DOM element passed as parameter must have a class.\");\r\n throw new Error(\"KEYBOARD_DOM_CLASS_ERROR\");\r\n }\r\n\r\n keyboardDOMClass = selectorOrOptions.className.split(\" \")[0];\r\n keyboardDOM = selectorOrOptions;\r\n options = keyboardOptions;\r\n\r\n /**\r\n * Otherwise, search for .simple-keyboard DOM element\r\n */\r\n } else {\r\n keyboardDOMClass = \"simple-keyboard\";\r\n keyboardDOM = document.querySelector(\r\n `.${keyboardDOMClass}`\r\n ) as KeyboardElement;\r\n options = selectorOrOptions;\r\n }\r\n\r\n return {\r\n keyboardDOMClass,\r\n keyboardDOM,\r\n options,\r\n };\r\n };\r\n\r\n /**\r\n * Getters\r\n */\r\n getOptions = (): KeyboardOptions => this.options;\r\n getCaretPosition = (): number | null => this.caretPosition;\r\n getCaretPositionEnd = (): number | null => this.caretPositionEnd;\r\n\r\n /**\r\n * Changes the internal caret position\r\n * @param {number} position The caret's start position\r\n * @param {number} positionEnd The caret's end position\r\n */\r\n setCaretPosition(position: number | null, endPosition = position): void {\r\n this.caretPosition = position;\r\n this.caretPositionEnd = endPosition;\r\n }\r\n\r\n /**\r\n * Retrieve the candidates for a given input\r\n * @param input The input string to check\r\n */\r\n getInputCandidates(\r\n input: string\r\n ): { candidateKey: string; candidateValue: string } | Record<string, never> {\r\n const {\r\n layoutCandidates: layoutCandidatesObj,\r\n layoutCandidatesCaseSensitiveMatch,\r\n } = this.options;\r\n\r\n if (!layoutCandidatesObj || typeof layoutCandidatesObj !== \"object\") {\r\n return {};\r\n }\r\n\r\n const layoutCandidates = Object.keys(layoutCandidatesObj).filter(\r\n (layoutCandidate: string) => {\r\n const inputSubstr =\r\n input.substring(0, this.getCaretPositionEnd() || 0) || input;\r\n const regexp = new RegExp(\r\n `${this.utilities.escapeRegex(layoutCandidate)}$`,\r\n layoutCandidatesCaseSensitiveMatch ? \"g\" : \"gi\"\r\n );\r\n const matches = [...inputSubstr.matchAll(regexp)];\r\n return !!matches.length;\r\n }\r\n );\r\n\r\n if (layoutCandidates.length > 1) {\r\n const candidateKey = layoutCandidates.sort(\r\n (a, b) => b.length - a.length\r\n )[0];\r\n return {\r\n candidateKey,\r\n candidateValue: layoutCandidatesObj[candidateKey],\r\n };\r\n } else if (layoutCandidates.length) {\r\n const candidateKey = layoutCandidates[0];\r\n return {\r\n candidateKey,\r\n candidateValue: layoutCandidatesObj[candidateKey],\r\n };\r\n } else {\r\n return {};\r\n }\r\n }\r\n\r\n /**\r\n * Shows a suggestion box with a list of candidate words\r\n * @param candidates The chosen candidates string as defined in the layoutCandidates option\r\n * @param targetElement The element next to which the candidates box will be shown\r\n */\r\n showCandidatesBox(\r\n candidateKey: string,\r\n candidateValue: string,\r\n targetElement: KeyboardElement\r\n ): void {\r\n if (this.candidateBox) {\r\n this.candidateBox.show({\r\n candidateValue,\r\n targetElement,\r\n onSelect: (selectedCandidate: string, e: MouseEvent) => {\r\n const { layoutCandidatesCaseSensitiveMatch, disableCandidateNormalization } = this.options;\r\n\r\n let candidateStr = selectedCandidate;\r\n\r\n if(!disableCandidateNormalization) {\r\n /**\r\n * Making sure that our suggestions are not composed characters\r\n */\r\n candidateStr = selectedCandidate.normalize(\"NFD\");\r\n }\r\n\r\n const currentInput = this.getInput(this.options.inputName, true);\r\n const initialCaretPosition = this.getCaretPositionEnd() || 0;\r\n const inputSubstr =\r\n currentInput.substring(0, initialCaretPosition || 0) ||\r\n currentInput;\r\n\r\n const regexp = new RegExp(\r\n `${this.utilities.escapeRegex(candidateKey)}$`,\r\n layoutCandidatesCaseSensitiveMatch ? \"g\" : \"gi\"\r\n );\r\n const newInputSubstr = inputSubstr.replace(\r\n regexp,\r\n candidateStr\r\n );\r\n const newInput = currentInput.replace(inputSubstr, newInputSubstr);\r\n\r\n const caretPositionDiff = newInputSubstr.length - inputSubstr.length;\r\n let newCaretPosition =\r\n (initialCaretPosition || currentInput.length) + caretPositionDiff;\r\n\r\n if (newCaretPosition < 0) newCaretPosition = 0;\r\n\r\n this.setInput(newInput, this.options.inputName, true);\r\n this.setCaretPosition(newCaretPosition);\r\n\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(\r\n this.getInput(this.options.inputName, true),\r\n e\r\n );\r\n\r\n /**\r\n * Calling onChangeAll\r\n */\r\n if (typeof this.options.onChangeAll === \"function\")\r\n this.options.onChangeAll(this.getAllInputs(), e);\r\n },\r\n });\r\n }\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: string, e?: KeyboardHandlerEvent): void {\r\n const { inputName = this.defaultName, debug } = this.options;\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if (button === \"{//}\") return;\r\n\r\n /**\r\n * Creating inputName if it doesn't exist\r\n */\r\n if (!this.input[inputName]) this.input[inputName] = \"\";\r\n\r\n /**\r\n * Calculating new input\r\n */\r\n const updatedInput = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[inputName],\r\n this.caretPosition,\r\n this.caretPositionEnd\r\n );\r\n\r\n /**\r\n * EDGE CASE: Check for whole input selection changes that will yield same updatedInput\r\n */\r\n if (this.utilities.isStandardButton(button) && this.activeInputElement) {\r\n const isEntireInputSelection =\r\n this.input[inputName] &&\r\n this.input[inputName] === updatedInput &&\r\n this.caretPosition === 0 &&\r\n this.caretPositionEnd === updatedInput.length;\r\n\r\n if (isEntireInputSelection) {\r\n this.setInput(\"\", this.options.inputName, true);\r\n this.setCaretPosition(0);\r\n this.activeInputElement.value = \"\";\r\n this.activeInputElement.setSelectionRange(0, 0);\r\n this.handleButtonClicked(button, e);\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if (typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button, e);\r\n\r\n if (\r\n // If input will change as a result of this button press\r\n this.input[inputName] !== updatedInput &&\r\n // This pertains to the \"inputPattern\" option:\r\n // If inputPattern isn't set\r\n (!this.options.inputPattern ||\r\n // Or, if it is set and if the pattern is valid - we proceed.\r\n (this.options.inputPattern && this.inputPatternIsValid(updatedInput)))\r\n ) {\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if (\r\n this.options.maxLength &&\r\n this.utilities.handleMaxLength(this.input, updatedInput)\r\n ) {\r\n return;\r\n }\r\n\r\n /**\r\n * Updating input\r\n */\r\n const newInputValue = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[inputName],\r\n this.caretPosition,\r\n this.caretPositionEnd,\r\n true\r\n );\r\n\r\n this.setInput(newInputValue, this.options.inputName, true);\r\n\r\n if (debug) console.log(\"Input changed:\", this.getAllInputs());\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n this.getCaretPosition(),\r\n this.getCaretPositionEnd(),\r\n `(${this.keyboardDOMClass})`\r\n );\r\n }\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs();\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.getInput(this.options.inputName, true), e);\r\n\r\n /**\r\n * Calling onChangeAll\r\n */\r\n if (typeof this.options.onChangeAll === \"function\")\r\n this.options.onChangeAll(this.getAllInputs(), e);\r\n\r\n /**\r\n * Check if this new input has candidates (suggested words)\r\n */\r\n if (e?.target && this.options.enableLayoutCandidates) {\r\n const { candidateKey, candidateValue } =\r\n this.getInputCandidates(updatedInput);\r\n\r\n if (candidateKey && candidateValue) {\r\n this.showCandidatesBox(\r\n candidateKey,\r\n candidateValue,\r\n this.keyboardDOM\r\n );\r\n } else {\r\n this.candidateBox?.destroy();\r\n }\r\n }\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 * Get mouse hold state\r\n */\r\n getMouseHold() {\r\n return this.isMouseHold;\r\n }\r\n\r\n /**\r\n * Mark mouse hold state as set\r\n */\r\n setMouseHold(value: boolean) {\r\n if (this.options.syncInstanceInputs) {\r\n this.dispatch((instance: SimpleKeyboard) => {\r\n instance.isMouseHold = value;\r\n });\r\n } else {\r\n this.isMouseHold = value;\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void {\r\n if (e) {\r\n /**\r\n * Handle event options\r\n */\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n if (this.options.stopMouseDownPropagation) e.stopPropagation();\r\n\r\n /**\r\n * Add active class\r\n */\r\n e.target.classList.add(this.activeButtonClass);\r\n }\r\n\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n if (this.holdTimeout) clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.setMouseHold(true);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n if (!this.options.disableButtonHold) {\r\n this.holdTimeout = window.setTimeout(() => {\r\n if (\r\n (this.getMouseHold() &&\r\n // TODO: This needs to be configurable through options\r\n ((!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{delete}\" ||\r\n button === \"{backspace}\" ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\")) ||\r\n button === \"{arrowright}\" ||\r\n button === \"{arrowleft}\" ||\r\n button === \"{arrowup}\" ||\r\n button === \"{arrowdown}\"\r\n ) {\r\n if (this.options.debug) console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void {\r\n if (e) {\r\n /**\r\n * Handle event options\r\n */\r\n if (this.options.preventMouseUpDefault && e.preventDefault)\r\n e.preventDefault();\r\n if (this.options.stopMouseUpPropagation && e.stopPropagation)\r\n e.stopPropagation();\r\n\r\n /* istanbul ignore next */\r\n const isKeyboard =\r\n e.target === this.keyboardDOM ||\r\n (e.target && this.keyboardDOM.contains(e.target)) ||\r\n (this.candidateBox &&\r\n this.candidateBox.candidateBoxElement &&\r\n (e.target === this.candidateBox.candidateBoxElement ||\r\n (e.target &&\r\n this.candidateBox.candidateBoxElement.contains(e.target))));\r\n\r\n /**\r\n * On click outside, remove candidateBox\r\n */\r\n if (!isKeyboard && this.candidateBox) {\r\n this.candidateBox.destroy();\r\n }\r\n }\r\n\r\n /**\r\n * Remove active class\r\n */\r\n this.recurseButtons((buttonElement: Element) => {\r\n buttonElement.classList.remove(this.activeButtonClass);\r\n });\r\n\r\n this.setMouseHold(false);\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * Calling onKeyReleased\r\n */\r\n if (button && typeof this.options.onKeyReleased === \"function\")\r\n this.options.onKeyReleased(button);\r\n }\r\n\r\n /**\r\n * Handles container mousedown\r\n */\r\n handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void {\r\n /**\r\n * Handle event options\r\n */\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button: string): void {\r\n if (this.holdInteractionTimeout) 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 = window.setTimeout(() => {\r\n if (this.getMouseHold()) {\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(): void {\r\n this.dispatch((instance: SimpleKeyboard) => {\r\n instance.replaceInput(this.input);\r\n instance.setCaretPosition(this.caretPosition, this.caretPositionEnd);\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(\r\n inputName: string = this.options.inputName || this.defaultName\r\n ): void {\r\n this.input[inputName] = \"\";\r\n\r\n /**\r\n * Reset caretPosition\r\n */\r\n this.setCaretPosition(0);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs();\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(\r\n inputName: string = this.options.inputName || this.defaultName,\r\n skipSync = false\r\n ): string {\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs && !skipSync) this.syncInstanceInputs();\r\n\r\n if (this.options.rtl) {\r\n // Remove existing control chars\r\n const inputWithoutRTLControl = this.input[inputName]\r\n .replace(\"\\u202B\", \"\")\r\n .replace(\"\\u202C\", \"\");\r\n\r\n return \"\\u202B\" + inputWithoutRTLControl + \"\\u202C\";\r\n } else {\r\n return this.input[inputName];\r\n }\r\n }\r\n\r\n /**\r\n * Get all simple-keyboard inputs\r\n */\r\n getAllInputs(): KeyboardInput {\r\n const output = {};\r\n const inputNames = Object.keys(this.input);\r\n\r\n inputNames.forEach((inputName) => {\r\n output[inputName] = this.getInput(inputName, true);\r\n });\r\n\r\n return output;\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(\r\n input: string,\r\n inputName: string = this.options.inputName || this.defaultName,\r\n skipSync?: boolean\r\n ): void {\r\n this.input[inputName] = input;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (!skipSync && this.options.syncInstanceInputs) this.syncInstanceInputs();\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: KeyboardInput): void {\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} options The options to set\r\n */\r\n setOptions(options = {}): void {\r\n const changedOptions = this.changedOptions(options);\r\n this.options = Object.assign(this.options, options);\r\n\r\n if (changedOptions.length) {\r\n if (this.options.debug) {\r\n console.log(\"changedOptions\", changedOptions);\r\n }\r\n\r\n /**\r\n * Some option changes require adjustments before re-render\r\n */\r\n this.onSetOptions(changedOptions);\r\n\r\n /**\r\n * Rendering\r\n */\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Detecting changes to non-function options\r\n * This allows us to ascertain whether a button re-render is needed\r\n */\r\n changedOptions(newOptions: Partial<KeyboardOptions>): string[] {\r\n return Object.keys(newOptions).filter(\r\n (optionName) =>\r\n JSON.stringify(newOptions[optionName]) !==\r\n JSON.stringify(this.options[optionName])\r\n );\r\n }\r\n\r\n /**\r\n * Executing actions depending on changed options\r\n * @param {object} options The options to set\r\n */\r\n onSetOptions(changedOptions: string[] = []): void {\r\n /**\r\n * Changed: layoutName\r\n */\r\n if (changedOptions.includes(\"layoutName\")) {\r\n /**\r\n * Reset candidateBox\r\n */\r\n if (this.candidateBox) {\r\n this.candidateBox.destroy();\r\n }\r\n }\r\n\r\n /**\r\n * Changed: layoutCandidatesPageSize, layoutCandidates\r\n */\r\n if (\r\n changedOptions.includes(\"layoutCandidatesPageSize\") ||\r\n changedOptions.includes(\"layoutCandidates\")\r\n ) {\r\n /**\r\n * Reset and recreate candidateBox\r\n */\r\n if (this.candidateBox) {\r\n this.candidateBox.destroy();\r\n this.candidateBox = new CandidateBox({\r\n utilities: this.utilities,\r\n options: this.options,\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove all keyboard rows and reset keyboard values.\r\n * Used internally between re-renders.\r\n */\r\n resetRows(): void {\r\n if (this.keyboardRowsDOM) {\r\n this.keyboardRowsDOM.remove();\r\n }\r\n\r\n this.keyboardDOM.className = this.keyboardDOMClass;\r\n this.keyboardDOM.setAttribute(\"data-skInstance\", this.currentInstanceName);\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 // eslint-disable-next-line no-unused-vars\r\n dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void {\r\n if (!window[\"SimpleKeyboardInstances\"]) {\r\n console.warn(\r\n `SimpleKeyboardInstances is not defined. Dispatch cannot be called.`\r\n );\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: string, className: string): void {\r\n if (!className || !buttons) return;\r\n\r\n buttons.split(\" \").forEach((button) => {\r\n className.split(\" \").forEach((classNameItem) => {\r\n if (!this.options.buttonTheme) 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 if (buttonTheme?.class.split(\" \").includes(classNameItem)) {\r\n classNameFound = true;\r\n\r\n const 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 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: string, className: string): void {\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;\r\n }\r\n\r\n /**\r\n * If buttons are passed and buttonTheme has items\r\n */\r\n if (\r\n buttons &&\r\n Array.isArray(this.options.buttonTheme) &&\r\n this.options.buttonTheme.length\r\n ) {\r\n const buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button) => {\r\n this.options?.buttonTheme?.map((buttonTheme, index) => {\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 (buttonTheme &&\r\n className &&\r\n className.includes(buttonTheme.class)) ||\r\n !className\r\n ) {\r\n const filteredButtonArray = buttonTheme?.buttons\r\n .split(\" \")\r\n .filter((item) => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if (buttonTheme && 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 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(\r\n button: string\r\n ): KeyboardElement | KeyboardElement[] | undefined {\r\n let output;\r\n\r\n const 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 * This handles the \"inputPattern\" option\r\n * by checking if the provided inputPattern passes\r\n */\r\n inputPatternIsValid(inputVal: string): boolean {\r\n const inputPatternRaw = this.options.inputPattern;\r\n let inputPattern;\r\n\r\n /**\r\n * Check if input pattern is global or targeted to individual inputs\r\n */\r\n if (inputPatternRaw instanceof RegExp) {\r\n inputPattern = inputPatternRaw;\r\n } else {\r\n inputPattern =\r\n inputPatternRaw[this.options.inputName || this.defaultName];\r\n }\r\n\r\n if (inputPattern && inputVal) {\r\n const didInputMatch = inputPattern.test(inputVal);\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `inputPattern (\"${inputPattern}\"): ${\r\n didInputMatch ? \"passed\" : \"did not pass!\"\r\n }`\r\n );\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Handles simple-keyboard event listeners\r\n */\r\n setEventListeners(): void {\r\n /**\r\n * Only first instance should set the event listeners\r\n */\r\n if (this.isFirstKeyboardInstance || !this.allKeyboardInstances) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\r\n }\r\n\r\n /**\r\n * Event Listeners\r\n */\r\n document.addEventListener(\"keyup\", this.handleKeyUp);\r\n document.addEventListener(\"keydown\", this.handleKeyDown);\r\n document.addEventListener(\"mouseup\", this.handleMouseUp);\r\n document.addEventListener(\"touchend\", this.handleTouchEnd);\r\n document.addEventListener(\"select\", this.handleSelect);\r\n document.addEventListener(\"selectionchange\", this.handleSelectionChange);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: KeyUp\r\n */\r\n handleKeyUp(event: KeyboardHandlerEvent): void {\r\n this.caretEventHandler(event);\r\n\r\n if (this.options.physicalKeyboardHighlight) {\r\n this.physicalKeyboard.handleHighlightKeyUp(event);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: KeyDown\r\n */\r\n handleKeyDown(event: KeyboardHandlerEvent): void {\r\n if (this.options.physicalKeyboardHighlight) {\r\n this.physicalKeyboard.handleHighlightKeyDown(event);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: MouseUp\r\n */\r\n handleMouseUp(event: KeyboardHandlerEvent): void {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Event Handler: TouchEnd\r\n */\r\n /* istanbul ignore next */\r\n handleTouchEnd(event: KeyboardHandlerEvent): void {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Event Handler: Select\r\n */\r\n /* istanbul ignore next */\r\n handleSelect(event: KeyboardHandlerEvent): void {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Event Handler: SelectionChange\r\n */\r\n /* istanbul ignore next */\r\n handleSelectionChange(event: KeyboardHandlerEvent): void {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event: KeyboardHandlerEvent): void {\r\n let targetTagName: string;\r\n if (event.target.tagName) {\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch((instance) => {\r\n let isKeyboard =\r\n event.target === instance.keyboardDOM ||\r\n (event.target && instance.keyboardDOM.contains(event.target));\r\n\r\n /**\r\n * If syncInstanceInputs option is enabled, make isKeyboard match any instance\r\n * not just the current one\r\n */\r\n if (this.options.syncInstanceInputs && Array.isArray(event.path)) {\r\n isKeyboard = event.path.some((item: HTMLElement) =>\r\n item?.hasAttribute?.(\"data-skInstance\")\r\n );\r\n }\r\n\r\n if (\r\n (targetTagName === \"textarea\" ||\r\n (targetTagName === \"input\" &&\r\n [\"text\", \"search\", \"url\", \"tel\", \"password\"].includes(\r\n event.target.type\r\n ))) &&\r\n !instance.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 let selectionStart = event.target.selectionStart;\r\n let selectionEnd = event.target.selectionEnd;\r\n\r\n if(instance.options.rtl){\r\n selectionStart = instance.utilities.getRtlOffset(selectionStart, instance.getInput());\r\n selectionEnd = instance.utilities.getRtlOffset(selectionEnd, instance.getInput());\r\n }\r\n\r\n instance.setCaretPosition(selectionStart, selectionEnd);\r\n\r\n /**\r\n * Tracking current input in order to handle caret positioning edge cases\r\n */\r\n this.activeInputElement = event.target;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n instance.getCaretPosition(),\r\n instance.getCaretPositionEnd(),\r\n event && event.target.tagName.toLowerCase(),\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n } else if (\r\n (instance.options.disableCaretPositioning || !isKeyboard) &&\r\n event?.type !== \"selectionchange\"\r\n ) {\r\n /**\r\n * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.\r\n */\r\n instance.setCaretPosition(null);\r\n\r\n /**\r\n * Resetting activeInputElement\r\n */\r\n this.activeInputElement = null;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n `Caret position reset due to \"${event?.type}\" event`,\r\n event\r\n );\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Execute an operation on each button\r\n */\r\n recurseButtons(fn: any): void {\r\n if (!fn) return;\r\n\r\n Object.keys(this.buttonElements).forEach((buttonName) =>\r\n this.buttonElements[buttonName].forEach(fn)\r\n );\r\n }\r\n\r\n /**\r\n * Destroy keyboard listeners and DOM elements\r\n */\r\n destroy(): void {\r\n if (this.options.debug)\r\n console.log(\r\n `Destroying simple-keyboard instance: ${this.currentInstanceName}`\r\n );\r\n\r\n /**\r\n * Remove document listeners\r\n */\r\n document.removeEventListener(\"keyup\", this.handleKeyUp);\r\n document.removeEventListener(\"keydown\", this.handleKeyDown);\r\n document.removeEventListener(\"mouseup\", this.handleMouseUp);\r\n document.removeEventListener(\"touchend\", this.handleTouchEnd);\r\n document.removeEventListener(\"select\", this.handleSelect);\r\n document.removeEventListener(\"selectionchange\", this.handleSelectionChange);\r\n document.onpointerup = null;\r\n document.ontouchend = null;\r\n document.ontouchcancel = null;\r\n document.onmouseup = null;\r\n\r\n /**\r\n * Remove buttons\r\n */\r\n const deleteButton = (buttonElement: KeyboardElement | null) => {\r\n if (buttonElement) {\r\n buttonElement.onpointerdown = null;\r\n buttonElement.onpointerup = null;\r\n buttonElement.onpointercancel = null;\r\n buttonElement.ontouchstart = null;\r\n buttonElement.ontouchend = null;\r\n buttonElement.ontouchcancel = null;\r\n buttonElement.onclick = null;\r\n buttonElement.onmousedown = null;\r\n buttonElement.onmouseup = null;\r\n\r\n buttonElement.remove();\r\n buttonElement = null;\r\n }\r\n };\r\n\r\n this.recurseButtons(deleteButton);\r\n\r\n /**\r\n * Remove wrapper events\r\n */\r\n this.keyboardDOM.onpointerdown = null;\r\n this.keyboardDOM.ontouchstart = null;\r\n this.keyboardDOM.onmousedown = null;\r\n\r\n /**\r\n * Clearing keyboard rows\r\n */\r\n this.resetRows();\r\n\r\n /**\r\n * Candidate box\r\n */\r\n if (this.candidateBox) {\r\n this.candidateBox.destroy();\r\n this.candidateBox = null;\r\n }\r\n\r\n /**\r\n * Clearing activeInputElement\r\n */\r\n this.activeInputElement = null;\r\n\r\n /**\r\n * Removing instance attribute\r\n */\r\n this.keyboardDOM.removeAttribute(\"data-skInstance\");\r\n\r\n /**\r\n * Clearing keyboardDOM\r\n */\r\n this.keyboardDOM.innerHTML = \"\";\r\n\r\n /**\r\n * Remove instance\r\n */\r\n window[\"SimpleKeyboardInstances\"][this.currentInstanceName] = null;\r\n delete window[\"SimpleKeyboardInstances\"][this.currentInstanceName];\r\n\r\n /**\r\n * Reset initialized flag\r\n */\r\n this.initialized = false;\r\n }\r\n\r\n /**\r\n * Process buttonTheme option\r\n */\r\n getButtonThemeClasses(button: string): string[] {\r\n const buttonTheme = this.options.buttonTheme;\r\n let buttonClasses: string[] = [];\r\n\r\n if (Array.isArray(buttonTheme)) {\r\n buttonTheme.forEach((themeObj) => {\r\n if (\r\n themeObj &&\r\n themeObj.class &&\r\n typeof themeObj.class === \"string\" &&\r\n themeObj.buttons &&\r\n typeof themeObj.buttons === \"string\"\r\n ) {\r\n const themeObjClasses = themeObj.class.split(\" \");\r\n const themeObjButtons = themeObj.buttons.split(\" \");\r\n\r\n if (themeObjButtons.includes(button)) {\r\n buttonClasses = [...buttonClasses, ...themeObjClasses];\r\n }\r\n } else {\r\n console.warn(\r\n `Incorrect \"buttonTheme\". Please check the documentation.`,\r\n themeObj\r\n );\r\n }\r\n });\r\n }\r\n\r\n return buttonClasses;\r\n }\r\n\r\n /**\r\n * Process buttonAttributes option\r\n */\r\n setDOMButtonAttributes(button: string, callback: any): void {\r\n const buttonAttributes = this.options.buttonAttributes;\r\n\r\n if (Array.isArray(buttonAttributes)) {\r\n buttonAttributes.forEach((attrObj) => {\r\n if (\r\n attrObj.attribute &&\r\n typeof attrObj.attribute === \"string\" &&\r\n attrObj.value &&\r\n typeof attrObj.value === \"string\" &&\r\n attrObj.buttons &&\r\n typeof attrObj.buttons === \"string\"\r\n ) {\r\n const attrObjButtons = attrObj.buttons.split(\" \");\r\n\r\n if (attrObjButtons.includes(button)) {\r\n callback(attrObj.attribute, attrObj.value);\r\n }\r\n } else {\r\n console.warn(\r\n `Incorrect \"buttonAttributes\". Please check the documentation.`,\r\n attrObj\r\n );\r\n }\r\n });\r\n }\r\n }\r\n\r\n onTouchDeviceDetected() {\r\n /**\r\n * Processing autoTouchEvents\r\n */\r\n this.processAutoTouchEvents();\r\n\r\n /**\r\n * Disabling contextual window on touch devices\r\n */\r\n this.disableContextualWindow();\r\n }\r\n\r\n /**\r\n * Disabling contextual window for hg-button\r\n */\r\n /* istanbul ignore next */\r\n disableContextualWindow() {\r\n window.oncontextmenu = (event: KeyboardHandlerEvent) => {\r\n if (event.target.classList.contains(\"hg-button\")) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return false;\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Process autoTouchEvents option\r\n */\r\n processAutoTouchEvents() {\r\n if (this.options.autoUseTouchEvents) {\r\n this.options.useTouchEvents = true;\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`\r\n );\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(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * setEventListeners\r\n */\r\n this.setEventListeners();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit(this);\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender() {\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if (this.utilities.isTouchDevice()) {\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\")\r\n this.options.beforeFirstRender(this);\r\n\r\n /**\r\n * Notify about PointerEvents usage\r\n */\r\n if (\r\n this.isFirstKeyboardInstance &&\r\n this.utilities.pointerEventsSupported() &&\r\n !this.options.useTouchEvents &&\r\n !this.options.useMouseEvents\r\n ) {\r\n if (this.options.debug) {\r\n console.log(\"Using PointerEvents as it is supported by this browser\");\r\n }\r\n }\r\n\r\n /**\r\n * Notify about touch events usage\r\n */\r\n if (this.options.useTouchEvents) {\r\n if (this.options.debug) {\r\n console.log(\r\n \"useTouchEvents has been enabled. Only touch events will be used.\"\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender() {\r\n if (typeof this.options.beforeRender === \"function\")\r\n this.options.beforeRender(this);\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(this);\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(this);\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name: string, initCallback: any) => {\r\n if (!this.modules[name]) 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((KeyboardModule) => {\r\n const keyboardModule = new KeyboardModule(this);\r\n keyboardModule.init && keyboardModule.init(this);\r\n });\r\n\r\n 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: string, prop: string) {\r\n if (!this.modules[name]) 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 * Parse Row DOM containers\r\n */\r\n parseRowDOMContainers(\r\n rowDOM: HTMLDivElement,\r\n rowIndex: number,\r\n containerStartIndexes: number[],\r\n containerEndIndexes: number[]\r\n ) {\r\n const rowDOMArray = Array.from(rowDOM.children);\r\n let removedElements = 0;\r\n\r\n if (rowDOMArray.length) {\r\n containerStartIndexes.forEach((startIndex, arrIndex) => {\r\n const endIndex = containerEndIndexes[arrIndex];\r\n\r\n /**\r\n * If there exists a respective end index\r\n * if end index comes after start index\r\n */\r\n if (!endIndex || !(endIndex > startIndex)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * Updated startIndex, endIndex\r\n * This is since the removal of buttons to place a single button container\r\n * results in a modified array size\r\n */\r\n const updated_startIndex = startIndex - removedElements;\r\n const updated_endIndex = endIndex - removedElements;\r\n\r\n /**\r\n * Create button container\r\n */\r\n const containerDOM = document.createElement(\"div\");\r\n containerDOM.className += \"hg-button-container\";\r\n const containerUID = `${this.options.layoutName}-r${rowIndex}c${arrIndex}`;\r\n containerDOM.setAttribute(\"data-skUID\", containerUID);\r\n\r\n /**\r\n * Taking elements due to be inserted into container\r\n */\r\n const containedElements = rowDOMArray.splice(\r\n updated_startIndex,\r\n updated_endIndex - updated_startIndex + 1\r\n );\r\n removedElements = updated_endIndex - updated_startIndex;\r\n\r\n /**\r\n * Inserting elements to container\r\n */\r\n containedElements.forEach((element) =>\r\n containerDOM.appendChild(element)\r\n );\r\n\r\n /**\r\n * Adding container at correct position within rowDOMArray\r\n */\r\n rowDOMArray.splice(updated_startIndex, 0, containerDOM);\r\n\r\n /**\r\n * Clearing old rowDOM children structure\r\n */\r\n rowDOM.innerHTML = \"\";\r\n\r\n /**\r\n * Appending rowDOM new children list\r\n */\r\n rowDOMArray.forEach((element) => rowDOM.appendChild(element));\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n \"rowDOMContainer\",\r\n containedElements,\r\n updated_startIndex,\r\n updated_endIndex,\r\n removedElements + 1\r\n );\r\n }\r\n });\r\n }\r\n\r\n return rowDOM;\r\n }\r\n\r\n /**\r\n * getKeyboardClassString\r\n */\r\n getKeyboardClassString = (...baseDOMClasses: any[]) => {\r\n const keyboardClasses = [this.keyboardDOMClass, ...baseDOMClasses].filter(\r\n (DOMClass) => !!DOMClass\r\n );\r\n\r\n return keyboardClasses.join(\" \");\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.resetRows();\r\n\r\n /**\r\n * Calling beforeFirstRender\r\n */\r\n if (!this.initialized) {\r\n this.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Calling beforeRender\r\n */\r\n this.beforeRender();\r\n\r\n const layoutClass = `hg-layout-${this.options.layoutName}`;\r\n const layout = this.options.layout || getDefaultLayout();\r\n const useTouchEvents = this.options.useTouchEvents || false;\r\n const useTouchEventsClass = useTouchEvents ? \"hg-touch-events\" : \"\";\r\n const useMouseEvents = this.options.useMouseEvents || false;\r\n const disableRowButtonContainers = this.options.disableRowButtonContainers;\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className = this.getKeyboardClassString(\r\n this.options.theme,\r\n layoutClass,\r\n this.keyboardPluginClasses,\r\n useTouchEventsClass\r\n );\r\n\r\n /**\r\n * Adding keyboard identifier\r\n */\r\n this.keyboardDOM.setAttribute(\"data-skInstance\", this.currentInstanceName);\r\n\r\n /**\r\n * Create row wrapper\r\n */\r\n this.keyboardRowsDOM = document.createElement(\"div\");\r\n this.keyboardRowsDOM.className = \"hg-rows\";\r\n\r\n /**\r\n * Iterating through each row\r\n */\r\n layout[this.options.layoutName || this.defaultName].forEach(\r\n (row, rIndex) => {\r\n let rowArray = row.split(\" \");\r\n\r\n /**\r\n * Enforce excludeFromLayout\r\n */\r\n if (\r\n this.options.excludeFromLayout &&\r\n this.options.excludeFromLayout[\r\n this.options.layoutName || this.defaultName\r\n ]\r\n ) {\r\n rowArray = rowArray.filter(\r\n (buttonName) =>\r\n this.options.excludeFromLayout &&\r\n !this.options.excludeFromLayout[\r\n this.options.layoutName || this.defaultName\r\n ].includes(buttonName)\r\n );\r\n }\r\n\r\n /**\r\n * Creating empty row\r\n */\r\n let rowDOM = document.createElement(\"div\");\r\n rowDOM.className += \"hg-row\";\r\n\r\n /**\r\n * Tracking container indicators in rows\r\n */\r\n const containerStartIndexes: number[] = [];\r\n const containerEndIndexes: number[] = [];\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n /**\r\n * Check if button has a container indicator\r\n */\r\n const buttonHasContainerStart =\r\n !disableRowButtonContainers &&\r\n typeof button === \"string\" &&\r\n button.length > 1 &&\r\n button.indexOf(\"[\") === 0;\r\n\r\n const buttonHasContainerEnd =\r\n !disableRowButtonContainers &&\r\n typeof button === \"string\" &&\r\n button.length > 1 &&\r\n button.indexOf(\"]\") === button.length - 1;\r\n\r\n /**\r\n * Save container start index, if applicable\r\n */\r\n if (buttonHasContainerStart) {\r\n containerStartIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\[/g, \"\");\r\n }\r\n\r\n if (buttonHasContainerEnd) {\r\n containerEndIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\]/g, \"\");\r\n }\r\n\r\n /**\r\n * Processing button options\r\n */\r\n const fctBtnClass = this.utilities.getButtonClass(button);\r\n const buttonDisplayName = this.utilities.getButtonDisplayName(\r\n button,\r\n this.options.display,\r\n this.options.mergeDisplay\r\n );\r\n\r\n /**\r\n * Creating button\r\n */\r\n const buttonType = this.options.useButtonTag ? \"button\" : \"div\";\r\n const buttonDOM = document.createElement(buttonType);\r\n buttonDOM.className += `hg-button ${fctBtnClass}`;\r\n\r\n /**\r\n * Adding buttonTheme\r\n */\r\n buttonDOM.classList.add(...this.getButtonThemeClasses(button));\r\n\r\n /**\r\n * Adding buttonAttributes\r\n */\r\n this.setDOMButtonAttributes(\r\n button,\r\n (attribute: string, value: string) => {\r\n buttonDOM.setAttribute(attribute, value);\r\n }\r\n );\r\n\r\n this.activeButtonClass = \"hg-activeButton\";\r\n\r\n /**\r\n * Handle button click event\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n /**\r\n * Handle PointerEvents\r\n */\r\n buttonDOM.onpointerdown = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonClicked(button, e);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.onpointerup = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonMouseUp(button, e);\r\n };\r\n buttonDOM.onpointercancel = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonMouseUp(button, e);\r\n };\r\n } else {\r\n /**\r\n * Fallback for browsers not supporting PointerEvents\r\n */\r\n if (useTouchEvents) {\r\n /**\r\n * Handle touch events\r\n */\r\n buttonDOM.ontouchstart = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonClicked(button, e);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonMouseUp(button, e);\r\n };\r\n buttonDOM.ontouchcancel = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonMouseUp(button, e);\r\n };\r\n } else {\r\n /**\r\n * Handle mouse events\r\n */\r\n buttonDOM.onclick = (e: KeyboardHandlerEvent) => {\r\n this.setMouseHold(false);\r\n /**\r\n * Fire button handler in onclick for compatibility reasons\r\n * This fires handler before onKeyReleased, therefore when that option is set we will fire the handler\r\n * in onmousedown instead\r\n */\r\n if (typeof this.options.onKeyReleased !== \"function\") {\r\n this.handleButtonClicked(button, e);\r\n }\r\n };\r\n buttonDOM.onmousedown = (e: KeyboardHandlerEvent) => {\r\n /**\r\n * Fire button handler for onKeyReleased use-case\r\n */\r\n if (\r\n typeof this.options.onKeyReleased === \"function\" &&\r\n !this.isMouseHold\r\n ) {\r\n this.handleButtonClicked(button, e);\r\n }\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.onmouseup = (e: KeyboardHandlerEvent) => {\r\n this.handleButtonMouseUp(button, e);\r\n };\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 const buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n const 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]) 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 * Parse containers in row\r\n */\r\n rowDOM = this.parseRowDOMContainers(\r\n rowDOM,\r\n rIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n );\r\n\r\n /**\r\n * Appending row to hg-rows\r\n */\r\n this.keyboardRowsDOM.appendChild(rowDOM);\r\n }\r\n );\r\n\r\n /**\r\n * Appending row to keyboard\r\n */\r\n this.keyboardDOM.appendChild(this.keyboardRowsDOM);\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 and beforeFirstRender are only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling parent events\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n document.onpointerup = (e: KeyboardHandlerEvent) =>\r\n this.handleButtonMouseUp(undefined, e);\r\n this.keyboardDOM.onpointerdown = (e: KeyboardHandlerEvent) =>\r\n this.handleKeyboardContainerMouseDown(e);\r\n } else if (useTouchEvents) {\r\n /**\r\n * Handling ontouchend, ontouchcancel\r\n */\r\n document.ontouchend = (e: KeyboardHandlerEvent) =>\r\n this.handleButtonMouseUp(undefined, e);\r\n document.ontouchcancel = (e: KeyboardHandlerEvent) =>\r\n this.handleButtonMouseUp(undefined, e);\r\n\r\n this.keyboardDOM.ontouchstart = (e: KeyboardHandlerEvent) =>\r\n this.handleKeyboardContainerMouseDown(e);\r\n } else if (!useTouchEvents) {\r\n /**\r\n * Handling mouseup\r\n */\r\n document.onmouseup = (e: KeyboardHandlerEvent) =>\r\n this.handleButtonMouseUp(undefined, e);\r\n this.keyboardDOM.onmousedown = (e: KeyboardHandlerEvent) =>\r\n this.handleKeyboardContainerMouseDown(e);\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","export const 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","import SimpleKeyboard from \"./components/Keyboard\";\r\nexport { SimpleKeyboard };\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} |