diff --git a/build/css/index.css b/build/css/index.css index 901bac98..bdfb8a47 100644 --- a/build/css/index.css +++ b/build/css/index.css @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.6.8 + * simple-keyboard v2.7.0 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) diff --git a/build/index.js b/build/index.js index 85579a63..0677a4db 100644 --- a/build/index.js +++ b/build/index.js @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.6.8 + * simple-keyboard v2.7.0 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) @@ -9,5 +9,5 @@ * LICENSE file in the root directory of this source tree. * */ -!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(2);e.default=o.a},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(3),a=(n.n(i),n(4)),s=n(5),r=n(6),u="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c=function t(){var e=this;o(this,t),this.handleButtonClicked=function(t){var n=e.options.debug;if("{//}"===t)return!1;"function"===typeof e.options.onKeyPress&&e.options.onKeyPress(t),e.input[e.options.inputName]||(e.input[e.options.inputName]="");var o=e.utilities.getUpdatedInput(t,e.input[e.options.inputName],e.options,e.caretPosition);if(e.input[e.options.inputName]!==o){if(e.options.maxLength&&e.utilities.handleMaxLength(e.input,e.options,o))return!1;e.input[e.options.inputName]=o,n&&console.log("Input changed:",e.input),e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input),"function"===typeof e.options.onChange&&e.options.onChange(e.input[e.options.inputName])}n&&console.log("Key pressed:",t)},this.syncInstanceInputs=function(){e.dispatch(function(t){t.replaceInput(e.input)})},this.clearInput=function(t){t=t||e.options.inputName,e.input[e.options.inputName]="",e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input)},this.getInput=function(t){return t=t||e.options.inputName,e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input),e.input[e.options.inputName]},this.setInput=function(t,n){n=n||e.options.inputName,e.input[n]=t,e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input)},this.replaceInput=function(t){e.input=t},this.setOptions=function(t){t=t||{},e.options=Object.assign(e.options,t),e.render()},this.clear=function(){e.keyboardDOM.innerHTML="",e.keyboardDOM.className=e.keyboardDOMClass,e.buttonElements={}},this.dispatch=function(t){if(!window.SimpleKeyboardInstances)throw console.warn("SimpleKeyboardInstances is not defined. Dispatch cannot be called."),new Error("INSTANCES_VAR_ERROR");return Object.keys(window.SimpleKeyboardInstances).forEach(function(e){t(window.SimpleKeyboardInstances[e],e)})},this.addButtonTheme=function(t,n){if(!n||!t)return!1;t.split(" ").forEach(function(o){n.split(" ").forEach(function(n){e.options.buttonTheme||(e.options.buttonTheme=[]);var i=!1;e.options.buttonTheme.map(function(t){if(t.class.split(" ").includes(n)){i=!0;var e=t.buttons.split(" ");e.includes(o)||(i=!0,e.push(o),t.buttons=e.join(" "))}return t}),i||e.options.buttonTheme.push({class:n,buttons:t})})}),e.render()},this.removeButtonTheme=function(t,n){if(!t&&!n)return e.options.buttonTheme=[],e.render(),!1;if(t&&Array.isArray(e.options.buttonTheme)&&e.options.buttonTheme.length){t.split(" ").forEach(function(t,o){e.options.buttonTheme.map(function(o,i){if(n&&n.includes(o.class)||!n){var a=o.buttons.split(" ").filter(function(e){return e!==t});a.length?o.buttons=a.join(" "):(e.options.buttonTheme.splice(i,1),o=null)}return o})}),e.render()}},this.getButtonElement=function(t){var n=void 0,o=e.buttonElements[t];return o&&(n=o.length>1?o:o[0]),n},this.handleCaret=function(){e.options.debug&&console.log("Caret handling started"),document.addEventListener("keyup",e.caretEventHandler),document.addEventListener("mouseup",e.caretEventHandler),document.addEventListener("touchend",e.caretEventHandler)},this.caretEventHandler=function(t){var n=t.target.tagName.toLowerCase();"textarea"!==n&&"input"!==n||(e.caretPosition=t.target.selectionStart,e.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase()))},this.onInit=function(){e.options.debug&&console.log("Initialized"),e.handleCaret(),"function"===typeof e.options.onInit&&e.options.onInit()},this.onRender=function(){"function"===typeof e.options.onRender&&e.options.onRender()},this.render=function(){e.clear();var t=e.options.layout?"hg-layout-custom":"hg-layout-"+e.options.layoutName,n=e.options.layout||s.a.getDefaultLayout(),o={};Array.isArray(e.options.buttonTheme)&&e.options.buttonTheme.forEach(function(t){if(t.buttons&&t.class){var n=void 0;"string"===typeof t.buttons&&(n=t.buttons.split(" ")),n&&n.forEach(function(n){var i=o[n];i?e.utilities.countInArray(i.split(" "),t.class)||(o[n]=i+" "+t.class):o[n]=t.class})}else console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),e.keyboardDOM.className+=" "+e.options.theme+" "+t,n[e.options.layoutName].forEach(function(t,n){var i=t.split(" "),a=document.createElement("div");a.className+="hg-row",i.forEach(function(t,i){var s=e.utilities.getButtonClass(t),r=o[t],u=e.utilities.getButtonDisplayName(t,e.options.display,e.options.mergeDisplay),c=document.createElement("div");c.className+="hg-button "+s+(r?" "+r:""),c.onclick=function(){return e.handleButtonClicked(t)},c.setAttribute("data-skBtn",t);var p=e.options.layoutName+"-r"+n+"b"+i;c.setAttribute("data-skBtnUID",p),c.setAttribute("data-displayLabel",u);var l=document.createElement("span");l.innerHTML=u,c.appendChild(l),e.buttonElements[t]||(e.buttonElements[t]=[]),e.buttonElements[t].push(c),a.appendChild(c)}),e.keyboardDOM.appendChild(a)}),e.onRender(),e.initialized||(e.initialized=!0,e.onInit())};var n="string"===typeof(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:".simple-keyboard",i="object"===u(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:arguments.length<=1?void 0:arguments[1];if(i||(i={}),this.utilities=new r.a(this),this.keyboardDOM=document.querySelector(n),this.options=i,this.options.layoutName=this.options.layoutName||"default",this.options.theme=this.options.theme||"hg-theme-default",this.options.inputName=this.options.inputName||"default",this.input={},this.input[this.options.inputName]="",this.keyboardDOMClass=n.split(".").join(""),this.buttonElements={},!this.keyboardDOM)throw console.warn('"'+n+'" was not found in the DOM.'),new Error("KEYBOARD_DOM_ERROR");this.render(),window.SimpleKeyboardInstances||(window.SimpleKeyboardInstances={}),window.SimpleKeyboardInstances[this.utilities.camelCase(this.keyboardDOMClass)]=this,this.physicalKeyboardInterface=new a.a(this)};e.a=c},function(t,e){},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function t(e){var n=this;o(this,t),this.initKeyboardListener=function(){document.addEventListener("keydown",function(t){if(n.simpleKeyboardInstance.options.physicalKeyboardHighlight){var e=n.getSimpleKeyboardLayoutKey(t);n.simpleKeyboardInstance.dispatch(function(t){var o=t.getButtonElement(e)||t.getButtonElement("{"+e+"}");o&&(o.style.backgroundColor=n.simpleKeyboardInstance.options.physicalKeyboardHighlightBgColor||"#9ab4d0",o.style.color=n.simpleKeyboardInstance.options.physicalKeyboardHighlightTextColor||"white")})}}),document.addEventListener("keyup",function(t){if(n.simpleKeyboardInstance.options.physicalKeyboardHighlight){var e=n.getSimpleKeyboardLayoutKey(t);n.simpleKeyboardInstance.dispatch(function(t){var n=t.getButtonElement(e)||t.getButtonElement("{"+e+"}");n&&n.removeAttribute("style")})}})},this.getSimpleKeyboardLayoutKey=function(t){var e=void 0;return e=t.code.includes("Numpad")||t.code.includes("Shift")||t.code.includes("Space")||t.code.includes("Backspace")||t.code.includes("Control")||t.code.includes("Alt")||t.code.includes("Meta")?t.code:t.key,(e!==e.toUpperCase()||"F"===t.code[0]&&Number.isInteger(Number(t.code[1]))&&t.code.length<=3)&&(e=e.toLowerCase()),e},this.simpleKeyboardInstance=e,this.initKeyboardListener()};e.a=i},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function t(){o(this,t)};i.getDefaultLayout=function(){return{default:["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} q w e r t y u i o p [ ] \\","{lock} a s d f g h j k l ; ' {enter}","{shift} z x c v b n m , . / {shift}",".com @ {space}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} Q W E R T Y U I O P { } |",'{lock} A S D F G H J K L : " {enter}',"{shift} Z X C V B N M < > ? {shift}",".com @ {space}"]}},e.a=i},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n0?a=n.removeAt(a,i):"{space}"===t?a=n.addStringAt(a," ",i):"{tab}"!==t||"boolean"===typeof o.tabCharOnTab&&!1===o.tabCharOnTab?"{enter}"!==t&&"{numpadenter}"!==t||!o.newLineOnEnter?t.includes("numpad")&&Number.isInteger(Number(t[t.length-2]))?a=n.addStringAt(a,t[t.length-2],i):"{numpaddivide}"===t?a=n.addStringAt(a,"/",i):"{numpadmultiply}"===t?a=n.addStringAt(a,"*",i):"{numpadsubtract}"===t?a=n.addStringAt(a,"-",i):"{numpadadd}"===t?a=n.addStringAt(a,"+",i):"{numpaddecimal}"===t?a=n.addStringAt(a,".",i):"{"===t||"}"===t?a=n.addStringAt(a,t,i):t.includes("{")||t.includes("}")||(a=n.addStringAt(a,t,i)):a=n.addStringAt(a,"\n",i):a=n.addStringAt(a,"\t",i),a},this.updateCaretPos=function(t,e){e?n.simpleKeyboardInstance.caretPosition>0&&(n.simpleKeyboardInstance.caretPosition=n.simpleKeyboardInstance.caretPosition-t):n.simpleKeyboardInstance.caretPosition=n.simpleKeyboardInstance.caretPosition+t},this.isMaxLengthReached=function(){return Boolean(n.maxLengthReached)},this.camelCase=function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return t+e[0].toUpperCase()+e.slice(1)})},this.countInArray=function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)},this.simpleKeyboardInstance=e}return a(t,[{key:"getDefaultDiplay",value:function(){return{"{bksp}":"backspace","{backspace}":"backspace","{enter}":"< enter","{shift}":"shift","{shiftleft}":"shift","{shiftright}":"shift","{alt}":"alt","{s}":"shift","{tab}":"tab","{lock}":"caps","{capslock}":"caps","{accept}":"Submit","{space}":" ","{//}":" ","{esc}":"esc","{escape}":"esc","{f1}":"f1","{f2}":"f2","{f3}":"f3","{f4}":"f4","{f5}":"f5","{f6}":"f6","{f7}":"f7","{f8}":"f8","{f9}":"f9","{f10}":"f10","{f11}":"f11","{f12}":"f12","{numpaddivide}":"/","{numlock}":"lock","{arrowup}":"\u2191","{arrowleft}":"\u2190","{arrowdown}":"\u2193","{arrowright}":"\u2192","{prtscr}":"print","{scrolllock}":"scroll","{pause}":"pause","{insert}":"ins","{home}":"home","{pageup}":"up","{delete}":"del","{end}":"end","{pagedown}":"down","{numpadmultiply}":"*","{numpadsubtract}":"-","{numpadadd}":"+","{numpadenter}":"enter","{period}":".","{numpaddecimal}":".","{numpad0}":"0","{numpad1}":"1","{numpad2}":"2","{numpad3}":"3","{numpad4}":"4","{numpad5}":"5","{numpad6}":"6","{numpad7}":"7","{numpad8}":"8","{numpad9}":"9"}}},{key:"addStringAt",value:function(t,e,n){var o=void 0;return this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",n),n||0===n?(o=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||this.updateCaretPos(e.length)):o=t+e,o}},{key:"removeAt",value:function(t,e){if(0===this.simpleKeyboardInstance.caretPosition)return t;var n=void 0,o=void 0,i=void 0,a=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?(o=t.substring(e-2,e),i=o.match(a),i?(n=t.substr(0,e-2)+t.substr(e),this.updateCaretPos(2,!0)):(n=t.substr(0,e-1)+t.substr(e),this.updateCaretPos(1,!0))):(o=t.slice(-2),i=o.match(a),i?(n=t.slice(0,-2),this.updateCaretPos(2,!0)):(n=t.slice(0,-1),this.updateCaretPos(1,!0))),n}},{key:"handleMaxLength",value:function(t,e,n){var o=e.maxLength,a=t[e.inputName],s=a.length===o;if(n.length<=a.length)return!1;if(Number.isInteger(o))return e.debug&&console.log("maxLength (num) reached:",s),s?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===("undefined"===typeof o?"undefined":i(o))){var r=a.length===o[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",r),r?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}}]),t}();e.a=s}])}); +!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(2);e.default=i.a},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var s=n(3),o=(n.n(s),n(4)),a=n(5),r=n(6),u="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c=function(){function t(t,e){for(var n=0;n1?n:n[0]),e}},{key:"handleCaret",value:function(){this.options.debug&&console.log("Caret handling started"),document.addEventListener("keyup",this.caretEventHandler),document.addEventListener("mouseup",this.caretEventHandler),document.addEventListener("touchend",this.caretEventHandler)}},{key:"caretEventHandler",value:function(t){var e=t.target.tagName.toLowerCase();"textarea"!==e&&"input"!==e||(this.caretPosition=t.target.selectionStart,this.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase()))}},{key:"onInit",value:function(){this.options.debug&&console.log("Initialized"),this.handleCaret(),"function"===typeof this.options.onInit&&this.options.onInit()}},{key:"onRender",value:function(){"function"===typeof this.options.onRender&&this.options.onRender()}},{key:"render",value:function(){var t=this;this.clear();var e=this.options.layout?"hg-layout-custom":"hg-layout-"+this.options.layoutName,n=this.options.layout||a.a.getDefaultLayout(),i={};Array.isArray(this.options.buttonTheme)&&this.options.buttonTheme.forEach(function(e){if(e.buttons&&e.class){var n=void 0;"string"===typeof e.buttons&&(n=e.buttons.split(" ")),n&&n.forEach(function(n){var s=i[n];s?t.utilities.countInArray(s.split(" "),e.class)||(i[n]=s+" "+e.class):i[n]=e.class})}else console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),this.keyboardDOM.className+=" "+this.options.theme+" "+e,n[this.options.layoutName].forEach(function(e,n){var s=e.split(" "),o=document.createElement("div");o.className+="hg-row",s.forEach(function(e,s){var a=t.utilities.getButtonClass(e),r=i[e],u=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),c=document.createElement("div");c.className+="hg-button "+a+(r?" "+r:""),c.onclick=function(){return t.handleButtonClicked(e)},c.setAttribute("data-skBtn",e);var h=t.options.layoutName+"-r"+n+"b"+s;c.setAttribute("data-skBtnUID",h),c.setAttribute("data-displayLabel",u);var l=document.createElement("span");l.innerHTML=u,c.appendChild(l),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(c),o.appendChild(c)}),t.keyboardDOM.appendChild(o)}),this.onRender(),this.initialized||(this.initialized=!0,this.onInit())}}]),t}();e.a=h},function(t,e){},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var s=function(){function t(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}]),t}();e.a=o},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var s="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(){function t(t,e){for(var n=0;n0?s=this.removeAt(s,i):"{space}"===t?s=this.addStringAt(s," ",i):"{tab}"!==t||"boolean"===typeof n.tabCharOnTab&&!1===n.tabCharOnTab?"{enter}"!==t&&"{numpadenter}"!==t||!n.newLineOnEnter?t.includes("numpad")&&Number.isInteger(Number(t[t.length-2]))?s=this.addStringAt(s,t[t.length-2],i):"{numpaddivide}"===t?s=this.addStringAt(s,"/",i):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",i):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",i):"{numpadadd}"===t?s=this.addStringAt(s,"+",i):"{numpaddecimal}"===t?s=this.addStringAt(s,".",i):"{"===t||"}"===t?s=this.addStringAt(s,t,i):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,i)):s=this.addStringAt(s,"\n",i):s=this.addStringAt(s,"\t",i),s}},{key:"updateCaretPos",value:function(t,e){e?this.simpleKeyboardInstance.caretPosition>0&&(this.simpleKeyboardInstance.caretPosition=this.simpleKeyboardInstance.caretPosition-t):this.simpleKeyboardInstance.caretPosition=this.simpleKeyboardInstance.caretPosition+t}},{key:"addStringAt",value:function(t,e,n){var i=void 0;return this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",n),n||0===n?(i=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||this.updateCaretPos(e.length)):i=t+e,i}},{key:"removeAt",value:function(t,e){if(0===this.simpleKeyboardInstance.caretPosition)return t;var n=void 0,i=void 0,s=void 0,o=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?(i=t.substring(e-2,e),s=i.match(o),s?(n=t.substr(0,e-2)+t.substr(e),this.updateCaretPos(2,!0)):(n=t.substr(0,e-1)+t.substr(e),this.updateCaretPos(1,!0))):(i=t.slice(-2),s=i.match(o),s?(n=t.slice(0,-2),this.updateCaretPos(2,!0)):(n=t.slice(0,-1),this.updateCaretPos(1,!0))),n}},{key:"handleMaxLength",value:function(t,e,n){var i=e.maxLength,o=t[e.inputName],a=o.length===i;if(n.length<=o.length)return!1;if(Number.isInteger(i))return e.debug&&console.log("maxLength (num) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===("undefined"===typeof i?"undefined":s(i))){var r=o.length===i[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",r),r?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return Boolean(this.maxLengthReached)}},{key:"camelCase",value:function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return t+e[0].toUpperCase()+e.slice(1)})}},{key:"countInArray",value:function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)}}]),t}();e.a=a}])}); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map index 79cefb36..3e8f6345 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///index.js","webpack:///webpack/bootstrap ea59478eaf619d21c728","webpack:///./src/lib/index.js","webpack:///./src/lib/components/Keyboard.js","webpack:///./src/lib/services/PhysicalKeyboard.js","webpack:///./src/lib/services/KeyboardLayout.js","webpack:///./src/lib/services/Utilities.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","value","__WEBPACK_IMPORTED_MODULE_0__components_Keyboard__","_classCallCheck","instance","Constructor","TypeError","__WEBPACK_IMPORTED_MODULE_0__Keyboard_css__","__WEBPACK_IMPORTED_MODULE_1__services_PhysicalKeyboard__","__WEBPACK_IMPORTED_MODULE_2__services_KeyboardLayout__","__WEBPACK_IMPORTED_MODULE_3__services_Utilities__","_typeof","Symbol","iterator","obj","constructor","SimpleKeyboard","_this","handleButtonClicked","button","debug","options","onKeyPress","input","inputName","updatedInput","utilities","getUpdatedInput","caretPosition","maxLength","handleMaxLength","console","log","syncInstanceInputs","onChange","dispatch","replaceInput","clearInput","getInput","setInput","inputObj","setOptions","option","assign","render","clear","keyboardDOM","innerHTML","className","keyboardDOMClass","buttonElements","callback","window","warn","Error","keys","forEach","key","addButtonTheme","buttons","split","classNameItem","buttonTheme","classNameFound","map","class","includes","buttonThemeArray","push","join","removeButtonTheme","Array","isArray","length","index","filteredButtonArray","filter","item","splice","getButtonElement","output","buttonArr","handleCaret","document","addEventListener","caretEventHandler","event","targetTagName","target","tagName","toLowerCase","selectionStart","onInit","onRender","layoutClass","layout","layoutName","getDefaultLayout","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","countInArray","theme","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","getButtonClass","buttonThemeClass","buttonDisplayName","getButtonDisplayName","display","mergeDisplay","buttonDOM","onclick","setAttribute","buttonUID","buttonSpanDOM","appendChild","initialized","keyboardDOMQuery","arguments","undefined","querySelector","camelCase","physicalKeyboardInterface","PhysicalKeyboard","simpleKeyboardInstance","initKeyboardListener","physicalKeyboardHighlight","buttonPressed","getSimpleKeyboardLayoutKey","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","code","toUpperCase","Number","isInteger","KeyboardLayout","default","shift","_createClass","defineProperties","props","descriptor","writable","protoProps","staticProps","Utilities","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","getDefaultDiplay","caretPos","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","updateCaretPos","minus","isMaxLengthReached","Boolean","maxLengthReached","string","trim","reduce","word","slice","array","x","{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}","source","position","prevTwoChars","emojiMatched","emojiMatchedReg","substring","match","substr","currentInput","condition"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,iBAAAC,UAAA,iBAAAC,QACAA,OAAAD,QAAAD,IACA,mBAAAG,gBAAAC,IACAD,UAAAH,GACA,iBAAAC,SACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,KACCK,KAAA,WACD,MCAgB,UA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,OACTW,QAAQC,IAAI,2BAA4BwN,GAGvCA,GAIDnR,KAAKuM,kBAAmB,GACjB,IAEPvM,KAAKuM,kBAAmB,GACjB,EAIX,IAAwB,YAArB,oBAAO/I,GAAP,YAAAlB,EAAOkB,IAAuB,CAC/B,GAAI2N,GAAYD,EAAa9K,SAAW5C,EAAUR,EAAQG,UAM1D,OAJGH,GAAQD,OACTW,QAAQC,IAAI,2BAA4BwN,GAGvCA,GACDnR,KAAKuM,kBAAmB,GACjB,IAEPvM,KAAKuM,kBAAmB,GACjB,QNsFCf,IMrDhB7J,GAAA","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([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(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 /******/ (function(modules) { // webpackBootstrap\n/******/ \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, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\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/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(1);\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_Keyboard__ = __webpack_require__(2);\n/* harmony default export */ __webpack_exports__[\"default\"] = (__WEBPACK_IMPORTED_MODULE_0__components_Keyboard__[\"a\" /* default */]);\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Keyboard_css__ = __webpack_require__(3);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Keyboard_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__Keyboard_css__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__services_PhysicalKeyboard__ = __webpack_require__(4);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__services_KeyboardLayout__ = __webpack_require__(5);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__services_Utilities__ = __webpack_require__(6);\nvar _typeof=typeof Symbol===\"function\"&&typeof Symbol.iterator===\"symbol\"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol===\"function\"&&obj.constructor===Symbol&&obj!==Symbol.prototype?\"symbol\":typeof obj;};function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError(\"Cannot call a class as a function\");}}// Services\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 */var SimpleKeyboard=/**\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 */function SimpleKeyboard(){var _this=this;_classCallCheck(this,SimpleKeyboard);this.handleButtonClicked=function(button){var debug=_this.options.debug;/**\r\n * Ignoring placeholder buttons\r\n */if(button==='{//}')return false;/**\r\n * Calling onKeyPress\r\n */if(typeof _this.options.onKeyPress===\"function\")_this.options.onKeyPress(button);if(!_this.input[_this.options.inputName])_this.input[_this.options.inputName]='';var updatedInput=_this.utilities.getUpdatedInput(button,_this.input[_this.options.inputName],_this.options,_this.caretPosition);if(_this.input[_this.options.inputName]!==updatedInput){/**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */if(_this.options.maxLength&&_this.utilities.handleMaxLength(_this.input,_this.options,updatedInput)){return false;}_this.input[_this.options.inputName]=updatedInput;if(debug)console.log('Input changed:',_this.input);/**\r\n * Enforce syncInstanceInputs, if set\r\n */if(_this.options.syncInstanceInputs)_this.syncInstanceInputs(_this.input);/**\r\n * Calling onChange\r\n */if(typeof _this.options.onChange===\"function\")_this.options.onChange(_this.input[_this.options.inputName]);}if(debug){console.log(\"Key pressed:\",button);}};this.syncInstanceInputs=function(){_this.dispatch(function(instance){instance.replaceInput(_this.input);});};this.clearInput=function(inputName){inputName=inputName||_this.options.inputName;_this.input[_this.options.inputName]='';/**\r\n * Enforce syncInstanceInputs, if set\r\n */if(_this.options.syncInstanceInputs)_this.syncInstanceInputs(_this.input);};this.getInput=function(inputName){inputName=inputName||_this.options.inputName;/**\r\n * Enforce syncInstanceInputs, if set\r\n */if(_this.options.syncInstanceInputs)_this.syncInstanceInputs(_this.input);return _this.input[_this.options.inputName];};this.setInput=function(input,inputName){inputName=inputName||_this.options.inputName;_this.input[inputName]=input;/**\r\n * Enforce syncInstanceInputs, if set\r\n */if(_this.options.syncInstanceInputs)_this.syncInstanceInputs(_this.input);};this.replaceInput=function(inputObj){_this.input=inputObj;};this.setOptions=function(option){option=option||{};_this.options=Object.assign(_this.options,option);_this.render();};this.clear=function(){_this.keyboardDOM.innerHTML='';_this.keyboardDOM.className=_this.keyboardDOMClass;_this.buttonElements={};};this.dispatch=function(callback){if(!window['SimpleKeyboardInstances']){console.warn('SimpleKeyboardInstances is not defined. Dispatch cannot be called.');throw new Error(\"INSTANCES_VAR_ERROR\");}return Object.keys(window['SimpleKeyboardInstances']).forEach(function(key){callback(window['SimpleKeyboardInstances'][key],key);});};this.addButtonTheme=function(buttons,className){if(!className||!buttons)return false;buttons.split(\" \").forEach(function(button){className.split(\" \").forEach(function(classNameItem){if(!_this.options.buttonTheme)_this.options.buttonTheme=[];var classNameFound=false;/**\r\n * If class is already defined, we add button to class definition\r\n */_this.options.buttonTheme.map(function(buttonTheme){if(buttonTheme.class.split(\" \").includes(classNameItem)){classNameFound=true;var buttonThemeArray=buttonTheme.buttons.split(\" \");if(!buttonThemeArray.includes(button)){classNameFound=true;buttonThemeArray.push(button);buttonTheme.buttons=buttonThemeArray.join(\" \");}}return buttonTheme;});/**\r\n * If class is not defined, we create a new entry\r\n */if(!classNameFound){_this.options.buttonTheme.push({class:classNameItem,buttons:buttons});}});});_this.render();};this.removeButtonTheme=function(buttons,className){/**\r\n * When called with empty parameters, remove all button themes\r\n */if(!buttons&&!className){_this.options.buttonTheme=[];_this.render();return false;}/**\r\n * If buttons are passed and buttonTheme has items\r\n */if(buttons&&Array.isArray(_this.options.buttonTheme)&&_this.options.buttonTheme.length){var buttonArray=buttons.split(\" \");buttonArray.forEach(function(button,key){_this.options.buttonTheme.map(function(buttonTheme,index){/**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */if(className&&className.includes(buttonTheme.class)||!className){var filteredButtonArray=buttonTheme.buttons.split(\" \").filter(function(item){return item!==button;});/**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */if(filteredButtonArray.length){buttonTheme.buttons=filteredButtonArray.join(\" \");}else{_this.options.buttonTheme.splice(index,1);buttonTheme=null;}}return buttonTheme;});});_this.render();}};this.getButtonElement=function(button){var output=void 0;var buttonArr=_this.buttonElements[button];if(buttonArr){if(buttonArr.length>1){output=buttonArr;}else{output=buttonArr[0];}}return output;};this.handleCaret=function(){if(_this.options.debug){console.log(\"Caret handling started\");}document.addEventListener(\"keyup\",_this.caretEventHandler);document.addEventListener(\"mouseup\",_this.caretEventHandler);document.addEventListener(\"touchend\",_this.caretEventHandler);};this.caretEventHandler=function(event){var targetTagName=event.target.tagName.toLowerCase();if(targetTagName===\"textarea\"||targetTagName===\"input\"){/**\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 */_this.caretPosition=event.target.selectionStart;if(_this.options.debug){console.log('Caret at: ',event.target.selectionStart,event.target.tagName.toLowerCase());}}};this.onInit=function(){if(_this.options.debug){console.log(\"Initialized\");}/**\r\n * Caret handling\r\n */_this.handleCaret();if(typeof _this.options.onInit===\"function\")_this.options.onInit();};this.onRender=function(){if(typeof _this.options.onRender===\"function\")_this.options.onRender();};this.render=function(){/**\r\n * Clear keyboard\r\n */_this.clear();var layoutClass=_this.options.layout?\"hg-layout-custom\":'hg-layout-'+_this.options.layoutName;var layout=_this.options.layout||__WEBPACK_IMPORTED_MODULE_2__services_KeyboardLayout__[\"a\" /* default */].getDefaultLayout();/**\r\n * Account for buttonTheme, if set\r\n */var buttonThemesParsed={};if(Array.isArray(_this.options.buttonTheme)){_this.options.buttonTheme.forEach(function(themeObj){if(themeObj.buttons&&themeObj.class){var themeButtons=void 0;if(typeof themeObj.buttons===\"string\"){themeButtons=themeObj.buttons.split(' ');}if(themeButtons){themeButtons.forEach(function(themeButton){var themeParsed=buttonThemesParsed[themeButton];// If the button has already been added\nif(themeParsed){// Making sure we don't add duplicate classes, even when buttonTheme has duplicates\nif(!_this.utilities.countInArray(themeParsed.split(\" \"),themeObj.class)){buttonThemesParsed[themeButton]=themeParsed+' '+themeObj.class;}}else{buttonThemesParsed[themeButton]=themeObj.class;}});}}else{console.warn('buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.');}});}/**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */_this.keyboardDOM.className+=' '+_this.options.theme+' '+layoutClass;/**\r\n * Iterating through each row\r\n */layout[_this.options.layoutName].forEach(function(row,rIndex){var rowArray=row.split(' ');/**\r\n * Creating empty row\r\n */var rowDOM=document.createElement('div');rowDOM.className+=\"hg-row\";/**\r\n * Iterating through each button in row\r\n */rowArray.forEach(function(button,bIndex){var fctBtnClass=_this.utilities.getButtonClass(button);var buttonThemeClass=buttonThemesParsed[button];var buttonDisplayName=_this.utilities.getButtonDisplayName(button,_this.options.display,_this.options.mergeDisplay);/**\r\n * Creating button\r\n */var buttonDOM=document.createElement('div');buttonDOM.className+='hg-button '+fctBtnClass+(buttonThemeClass?\" \"+buttonThemeClass:\"\");buttonDOM.onclick=function(){return _this.handleButtonClicked(button);};/**\r\n * Adding identifier\r\n */buttonDOM.setAttribute(\"data-skBtn\",button);/**\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 */var buttonUID=_this.options.layoutName+'-r'+rIndex+'b'+bIndex;buttonDOM.setAttribute(\"data-skBtnUID\",buttonUID);/**\r\n * Adding display label\r\n */buttonDOM.setAttribute(\"data-displayLabel\",buttonDisplayName);/**\r\n * Adding button label to button\r\n */var buttonSpanDOM=document.createElement('span');buttonSpanDOM.innerHTML=buttonDisplayName;buttonDOM.appendChild(buttonSpanDOM);/**\r\n * Adding to buttonElements\r\n */if(!_this.buttonElements[button])_this.buttonElements[button]=[];_this.buttonElements[button].push(buttonDOM);/**\r\n * Appending button to row\r\n */rowDOM.appendChild(buttonDOM);});/**\r\n * Appending row to keyboard\r\n */_this.keyboardDOM.appendChild(rowDOM);});/**\r\n * Calling onRender\r\n */_this.onRender();if(!_this.initialized){/**\r\n * Ensures that onInit is only called once per instantiation\r\n */_this.initialized=true;/**\r\n * Calling onInit\r\n */_this.onInit();}};var keyboardDOMQuery=typeof(arguments.length<=0?undefined:arguments[0])===\"string\"?arguments.length<=0?undefined:arguments[0]:'.simple-keyboard';var options=_typeof(arguments.length<=0?undefined:arguments[0])===\"object\"?arguments.length<=0?undefined:arguments[0]:arguments.length<=1?undefined:arguments[1];if(!options)options={};/**\r\n * Initializing Utilities\r\n */this.utilities=new __WEBPACK_IMPORTED_MODULE_3__services_Utilities__[\"a\" /* default */](this);/**\r\n * Processing options\r\n */this.keyboardDOM=document.querySelector(keyboardDOMQuery);/**\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 {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 */this.options=options;this.options.layoutName=this.options.layoutName||\"default\";this.options.theme=this.options.theme||\"hg-theme-default\";this.options.inputName=this.options.inputName||\"default\";/**\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 */this.input={};this.input[this.options.inputName]='';/**\r\n * @type {string} DOM class of the keyboard wrapper, normally \"simple-keyboard\" by default.\r\n */this.keyboardDOMClass=keyboardDOMQuery.split('.').join(\"\");/**\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 */this.buttonElements={};/**\r\n * Rendering keyboard\r\n */if(this.keyboardDOM)this.render();else{console.warn('\"'+keyboardDOMQuery+'\" was not found in the DOM.');throw new Error(\"KEYBOARD_DOM_ERROR\");}/**\r\n * Saving instance\r\n * This enables multiple simple-keyboard support with easier management\r\n */if(!window['SimpleKeyboardInstances'])window['SimpleKeyboardInstances']={};window['SimpleKeyboardInstances'][this.utilities.camelCase(this.keyboardDOMClass)]=this;/**\r\n * Physical Keyboard support\r\n */this.physicalKeyboardInterface=new __WEBPACK_IMPORTED_MODULE_1__services_PhysicalKeyboard__[\"a\" /* default */](this);}/**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n *//**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n *//**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\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 * 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 * Replace the input object (`keyboard.input`)\r\n * @param {object} inputObj The input object\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 * Remove all keyboard rows and reset keyboard values.\r\n * Used interally between re-renders.\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 * 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 * 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 * 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 * Retrieves the current cursor position within a input or textarea (if any)\r\n *//**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n *//**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n *//**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n *//**\r\n * Renders rows and buttons as per options\r\n */;/* harmony default export */ __webpack_exports__[\"a\"] = (SimpleKeyboard);\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n/* 4 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nfunction _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError(\"Cannot call a class as a function\");}}/**\r\n * Physical Keyboard Service\r\n */var PhysicalKeyboard=/**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */function PhysicalKeyboard(simpleKeyboardInstance){var _this=this;_classCallCheck(this,PhysicalKeyboard);this.initKeyboardListener=function(){// Adding button style on keydown\ndocument.addEventListener(\"keydown\",function(event){if(_this.simpleKeyboardInstance.options.physicalKeyboardHighlight){var buttonPressed=_this.getSimpleKeyboardLayoutKey(event);_this.simpleKeyboardInstance.dispatch(function(instance){var buttonDOM=instance.getButtonElement(buttonPressed)||instance.getButtonElement(\"{\"+buttonPressed+\"}\");if(buttonDOM){buttonDOM.style.backgroundColor=_this.simpleKeyboardInstance.options.physicalKeyboardHighlightBgColor||\"#9ab4d0\";buttonDOM.style.color=_this.simpleKeyboardInstance.options.physicalKeyboardHighlightTextColor||\"white\";}});}});// Removing button style on keyup\ndocument.addEventListener(\"keyup\",function(event){if(_this.simpleKeyboardInstance.options.physicalKeyboardHighlight){var buttonPressed=_this.getSimpleKeyboardLayoutKey(event);_this.simpleKeyboardInstance.dispatch(function(instance){var buttonDOM=instance.getButtonElement(buttonPressed)||instance.getButtonElement(\"{\"+buttonPressed+\"}\");if(buttonDOM){buttonDOM.removeAttribute(\"style\");}});}});};this.getSimpleKeyboardLayoutKey=function(event){var output=void 0;if(event.code.includes(\"Numpad\")||event.code.includes(\"Shift\")||event.code.includes(\"Space\")||event.code.includes(\"Backspace\")||event.code.includes(\"Control\")||event.code.includes(\"Alt\")||event.code.includes(\"Meta\")){output=event.code;}else{output=event.key;}/**\r\n * If button is not uppercase, casting to lowercase\r\n */if(output!==output.toUpperCase()||event.code[0]===\"F\"&&Number.isInteger(Number(event.code[1]))&&event.code.length<=3){output=output.toLowerCase();}return output;};/**\r\n * @type {object} A simple-keyboard instance\r\n */this.simpleKeyboardInstance=simpleKeyboardInstance;this.initKeyboardListener();}/**\r\n * Initializes key event listeners\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 */;/* harmony default export */ __webpack_exports__[\"a\"] = (PhysicalKeyboard);\n\n/***/ }),\n/* 5 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nfunction _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError(\"Cannot call a class as a function\");}}/**\r\n * Keyboard Layout Service\r\n */var KeyboardLayout=function KeyboardLayout(){_classCallCheck(this,KeyboardLayout);};KeyboardLayout.getDefaultLayout=function(){return{'default':['` 1 2 3 4 5 6 7 8 9 0 - = {bksp}','{tab} q w e r t y u i o p [ ] \\\\','{lock} a s d f g h j k l ; \\' {enter}','{shift} z x c v b n m , . / {shift}','.com @ {space}'],'shift':['~ ! @ # $ % ^ & * ( ) _ + {bksp}','{tab} Q W E R T Y U I O P { } |','{lock} A S D F G H J K L : \" {enter}','{shift} Z X C V B N M < > ? {shift}','.com @ {space}']};};/* harmony default export */ __webpack_exports__[\"a\"] = (KeyboardLayout);\n\n/***/ }),\n/* 6 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nvar _typeof=typeof Symbol===\"function\"&&typeof Symbol.iterator===\"symbol\"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol===\"function\"&&obj.constructor===Symbol&&obj!==Symbol.prototype?\"symbol\":typeof obj;};var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){output=_this.removeAt(output,caretPos);}else if(button===\"{space}\")output=_this.addStringAt(output,\" \",caretPos);else if(button===\"{tab}\"&&!(typeof options.tabCharOnTab===\"boolean\"&&options.tabCharOnTab===false)){output=_this.addStringAt(output,\"\\t\",caretPos);}else if((button===\"{enter}\"||button===\"{numpadenter}\")&&options.newLineOnEnter)output=_this.addStringAt(output,\"\\n\",caretPos);else if(button.includes(\"numpad\")&&Number.isInteger(Number(button[button.length-2]))){output=_this.addStringAt(output,button[button.length-2],caretPos);}else if(button===\"{numpaddivide}\")output=_this.addStringAt(output,'/',caretPos);else if(button===\"{numpadmultiply}\")output=_this.addStringAt(output,'*',caretPos);else if(button===\"{numpadsubtract}\")output=_this.addStringAt(output,'-',caretPos);else if(button===\"{numpadadd}\")output=_this.addStringAt(output,'+',caretPos);else if(button===\"{numpaddecimal}\")output=_this.addStringAt(output,'.',caretPos);else if(button===\"{\"||button===\"}\")output=_this.addStringAt(output,button,caretPos);else if(!button.includes(\"{\")&&!button.includes(\"}\"))output=_this.addStringAt(output,button,caretPos);return output;};this.updateCaretPos=function(length,minus){if(minus){if(_this.simpleKeyboardInstance.caretPosition>0)_this.simpleKeyboardInstance.caretPosition=_this.simpleKeyboardInstance.caretPosition-length;}else{_this.simpleKeyboardInstance.caretPosition=_this.simpleKeyboardInstance.caretPosition+length;}};this.isMaxLengthReached=function(){return Boolean(_this.maxLengthReached);};this.camelCase=function(string){return string.toLowerCase().trim().split(/[.\\-_\\s]/g).reduce(function(string,word){return string+word[0].toUpperCase()+word.slice(1);});};this.countInArray=function(array,value){return array.reduce(function(n,x){return n+(x===value);},0);};/**\r\n * @type {object} A simple-keyboard instance\r\n */this.simpleKeyboardInstance=simpleKeyboardInstance;}/**\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 */_createClass(Utilities,[{key:\"getDefaultDiplay\",/**\r\n * Default button display labels\r\n */value:function getDefaultDiplay(){return{'{bksp}':'backspace','{backspace}':'backspace','{enter}':'< enter','{shift}':'shift','{shiftleft}':'shift','{shiftright}':'shift','{alt}':'alt','{s}':'shift','{tab}':'tab','{lock}':'caps','{capslock}':'caps','{accept}':'Submit','{space}':' ','{//}':' ',\"{esc}\":\"esc\",\"{escape}\":\"esc\",\"{f1}\":\"f1\",\"{f2}\":\"f2\",\"{f3}\":\"f3\",\"{f4}\":\"f4\",\"{f5}\":\"f5\",\"{f6}\":\"f6\",\"{f7}\":\"f7\",\"{f8}\":\"f8\",\"{f9}\":\"f9\",\"{f10}\":\"f10\",\"{f11}\":\"f11\",\"{f12}\":\"f12\",'{numpaddivide}':'/','{numlock}':'lock',\"{arrowup}\":\"↑\",\"{arrowleft}\":\"←\",\"{arrowdown}\":\"↓\",\"{arrowright}\":\"→\",\"{prtscr}\":\"print\",\"{scrolllock}\":\"scroll\",\"{pause}\":\"pause\",\"{insert}\":\"ins\",\"{home}\":\"home\",\"{pageup}\":\"up\",\"{delete}\":\"del\",\"{end}\":\"end\",\"{pagedown}\":\"down\",\"{numpadmultiply}\":\"*\",\"{numpadsubtract}\":\"-\",\"{numpadadd}\":\"+\",\"{numpadenter}\":\"enter\",\"{period}\":\".\",\"{numpaddecimal}\":\".\",\"{numpad0}\":\"0\",\"{numpad1}\":\"1\",\"{numpad2}\":\"2\",\"{numpad3}\":\"3\",\"{numpad4}\":\"4\",\"{numpad5}\":\"5\",\"{numpad6}\":\"6\",\"{numpad7}\":\"7\",\"{numpad8}\":\"8\",\"{numpad9}\":\"9\"};}/**\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 * 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 *//**\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 */},{key:\"addStringAt\",/**\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 */value:function addStringAt(source,string,position){var output=void 0;if(this.simpleKeyboardInstance.options.debug){console.log(\"Caret at:\",position);}if(!position&&position!==0){output=source+string;}else{output=[source.slice(0,position),string,source.slice(position)].join('');/**\r\n * Avoid caret position change when maxLength is set\r\n */if(!this.isMaxLengthReached()){this.updateCaretPos(string.length);}}return output;}/**\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 */},{key:\"removeAt\",value:function removeAt(source,position){if(this.simpleKeyboardInstance.caretPosition===0){return source;}var output=void 0;var prevTwoChars=void 0;var emojiMatched=void 0;var emojiMatchedReg=/([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;/**\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 */if(position&&position>=0){prevTwoChars=source.substring(position-2,position);emojiMatched=prevTwoChars.match(emojiMatchedReg);if(emojiMatched){output=source.substr(0,position-2)+source.substr(position);this.updateCaretPos(2,true);}else{output=source.substr(0,position-1)+source.substr(position);this.updateCaretPos(1,true);}}else{prevTwoChars=source.slice(-2);emojiMatched=prevTwoChars.match(emojiMatchedReg);if(emojiMatched){output=source.slice(0,-2);this.updateCaretPos(2,true);}else{output=source.slice(0,-1);this.updateCaretPos(1,true);}}return output;}/**\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 */},{key:\"handleMaxLength\",value:function handleMaxLength(inputObj,options,updatedInput){var maxLength=options.maxLength;var currentInput=inputObj[options.inputName];var condition=currentInput.length===maxLength;if(/**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */updatedInput.length<=currentInput.length){return false;}if(Number.isInteger(maxLength)){if(options.debug){console.log(\"maxLength (num) reached:\",condition);}if(condition){/**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */this.maxLengthReached=true;return true;}else{this.maxLengthReached=false;return false;}}if((typeof maxLength===\"undefined\"?\"undefined\":_typeof(maxLength))===\"object\"){var _condition=currentInput.length===maxLength[options.inputName];if(options.debug){console.log(\"maxLength (obj) reached:\",_condition);}if(_condition){this.maxLengthReached=true;return true;}else{this.maxLengthReached=false;return false;}}}/**\r\n * Gets the current value of maxLengthReached\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 * 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 */}]);return Utilities;}();/* harmony default export */ __webpack_exports__[\"a\"] = (Utilities);\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// index.js"," \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ea59478eaf619d21c728","import SimpleKeyboard from './components/Keyboard';\r\nexport default SimpleKeyboard;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/lib/index.js","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 {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\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 * 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(button, this.input[this.options.inputName], this.options, this.caretPosition);\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] = updatedInput;\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 * 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[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\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 = event.target.tagName.toLowerCase();\r\n\r\n if(\r\n targetTagName === \"textarea\" ||\r\n targetTagName === \"input\"\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 * 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\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}`;\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 buttonDOM.onclick = () => this.handleButtonClicked(button);\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 * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/lib/components/Keyboard.js","/**\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 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){\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;\n\n\n// WEBPACK FOOTER //\n// ./src/lib/services/PhysicalKeyboard.js","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n\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;\n\n\n// WEBPACK FOOTER //\n// ./src/lib/services/KeyboardLayout.js","/**\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 /**\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 */\r\n getUpdatedInput = (button, input, options, caretPos) => {\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);\r\n\r\n } else if(button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos);\r\n\r\n else if(button === \"{tab}\" && !(typeof options.tabCharOnTab === \"boolean\" && options.tabCharOnTab === false)){\r\n output = this.addStringAt(output, \"\\t\", caretPos);\r\n\r\n } else if((button === \"{enter}\" || button === \"{numpadenter}\") && options.newLineOnEnter)\r\n output = this.addStringAt(output, \"\\n\", caretPos);\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);\r\n\r\n else if(button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, '*', caretPos);\r\n else if(button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, '-', caretPos);\r\n\r\n else if(button === \"{numpadadd}\")\r\n output = this.addStringAt(output, '+', caretPos);\r\n\r\n else if(button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, '.', caretPos);\r\n\r\n else if(button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos);\r\n\r\n else if(!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos);\r\n\r\n return output;\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 */\r\n addStringAt(source, string, position){\r\n let output;\r\n\r\n if(this.simpleKeyboardInstance.options.debug){\r\n console.log(\"Caret at:\", position);\r\n }\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 this.updateCaretPos(string.length);\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 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 */\r\n removeAt(source, position){\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 this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, (position - 1)) + source.substr(position);\r\n 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 this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n this.updateCaretPos(1, true);\r\n }\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\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;\n\n\n// WEBPACK FOOTER //\n// ./src/lib/services/Utilities.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///index.js","webpack:///webpack/bootstrap 00c588c3323bf6c85ded","webpack:///./src/lib/index.js","webpack:///./src/lib/components/Keyboard.js","webpack:///./src/lib/services/PhysicalKeyboard.js","webpack:///./src/lib/services/KeyboardLayout.js","webpack:///./src/lib/services/Utilities.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","value","__WEBPACK_IMPORTED_MODULE_0__components_Keyboard__","_classCallCheck","instance","Constructor","TypeError","__WEBPACK_IMPORTED_MODULE_0__Keyboard_css__","__WEBPACK_IMPORTED_MODULE_1__services_PhysicalKeyboard__","__WEBPACK_IMPORTED_MODULE_2__services_KeyboardLayout__","__WEBPACK_IMPORTED_MODULE_3__services_Utilities__","_typeof","Symbol","iterator","obj","constructor","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","SimpleKeyboard","_this","setOptions","option","options","assign","render","registerModule","initCallback","getModuleProp","prop","getModulesList","keys","keyboardDOMQuery","arguments","undefined","utilities","keyboardDOM","document","querySelector","layoutName","theme","inputName","handleButtonClicked","bind","syncInstanceInputs","clearInput","getInput","setInput","replaceInput","clear","dispatch","addButtonTheme","removeButtonTheme","getButtonElement","handleCaret","caretEventHandler","onInit","onRender","input","keyboardDOMClass","split","join","buttonElements","console","warn","Error","window","camelCase","physicalKeyboardInterface","button","debug","onKeyPress","updatedInput","getUpdatedInput","caretPosition","maxLength","handleMaxLength","log","onChange","_this2","inputObj","innerHTML","className","callback","forEach","buttons","_this3","classNameItem","buttonTheme","classNameFound","map","class","includes","buttonThemeArray","push","_this4","Array","isArray","index","filteredButtonArray","filter","item","splice","output","buttonArr","addEventListener","event","targetTagName","tagName","toLowerCase","selectionStart","_this5","layoutClass","layout","getDefaultLayout","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","countInArray","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","getButtonClass","buttonThemeClass","buttonDisplayName","getButtonDisplayName","display","mergeDisplay","buttonDOM","onclick","setAttribute","buttonUID","buttonSpanDOM","appendChild","initialized","PhysicalKeyboard","simpleKeyboardInstance","initKeyboardListener","getSimpleKeyboardLayoutKey","physicalKeyboardHighlight","buttonPressed","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","code","toUpperCase","Number","isInteger","KeyboardLayout","default","shift","Utilities","updateCaretPos","isMaxLengthReached","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}","getDefaultDiplay","caretPos","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","source","string","position","slice","prevTwoChars","emojiMatched","emojiMatchedReg","substring","match","substr","currentInput","condition","maxLengthReached","Boolean","trim","reduce","word","array","x"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,iBAAAC,UAAA,iBAAAC,QACAA,OAAAD,QAAAD,IACA,mBAAAG,gBAAAC,IACAD,UAAAH,GACA,iBAAAC,SACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAA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OG,MAAM,GAAI,GAC1B9Q,KAAKmM,eAAe,GAAG,KAEvB1D,EAASkI,EAAOG,MAAM,GAAI,GAC1B9Q,KAAKmM,eAAe,GAAG,KAIpB1D,KNoIHvF,IAAI,kBAAkBtB,MAAM,SM3HlBsF,EAAUzD,EAASiD,GACjC,GAAIG,GAAYpD,EAAQoD,UACpBwK,EAAenK,EAASzD,EAAQkB,WAChC2M,EAAYD,EAAatO,SAAW8D,CAGxC,IAKEH,EAAa3D,QAAUsO,EAAatO,OAEpC,OAAO,CAGT,IAAG8I,OAAOC,UAAUjF,GAKlB,MAJGpD,GAAQ+C,OACTP,QAAQc,IAAI,2BAA4BuK,GAGvCA,GAIDtR,KAAKuR,kBAAmB,GACjB,IAEPvR,KAAKuR,kBAAmB,GACjB,EAIX,IAAwB,YAArB,oBAAO1K,GAAP,YAAAvE,EAAOuE,IAAuB,CAC/B,GAAIyK,GAAYD,EAAatO,SAAW8D,EAAUpD,EAAQkB,UAM1D,OAJGlB,GAAQ+C,OACTP,QAAQc,IAAI,2BAA4BuK,GAGvCA,GACDtR,KAAKuR,kBAAmB,GACjB,IAEPvR,KAAKuR,kBAAmB,GACjB,ONqFPrO,IAAI,qBAAqBtB,MAAM,WM5EnC,MAAO4P,SAAQxR,KAAKuR,qBNgFhBrO,IAAI,YAAYtB,MAAM,SMxElBgP,GACR,MAAOA,GAAO7H,cAAc0I,OAAO3L,MAAM,aAAa4L,OAAO,SAACd,EAAQe,GAAT,MAAkBf,GAASe,EAAK,GAAG/F,cAAgB+F,EAAKb,MAAM,QNuEsE5N,IAAI,eAKpMtB,MAAM,SMnEIgQ,EAAOhQ,GAClB,MAAOgQ,GAAMF,OAAO,SAACvQ,EAAG0Q,GAAJ,MAAU1Q,IAAK0Q,IAAMjQ,IAAQ,ONkEiEsK,IM7DtHvK,GAAA","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([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(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 /******/ (function(modules) { // webpackBootstrap\n/******/ \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, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\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/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(1);\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_Keyboard__ = __webpack_require__(2);\n/* harmony default export */ __webpack_exports__[\"default\"] = (__WEBPACK_IMPORTED_MODULE_0__components_Keyboard__[\"a\" /* default */]);\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Keyboard_css__ = __webpack_require__(3);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Keyboard_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__Keyboard_css__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__services_PhysicalKeyboard__ = __webpack_require__(4);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__services_KeyboardLayout__ = __webpack_require__(5);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__services_Utilities__ = __webpack_require__(6);\nvar _typeof=typeof Symbol===\"function\"&&typeof Symbol.iterator===\"symbol\"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol===\"function\"&&obj.constructor===Symbol&&obj!==Symbol.prototype?\"symbol\":typeof obj;};var _createClass=function(){function defineProperties(target,props){for(var i=0;i1){output=buttonArr;}else{output=buttonArr[0];}}return output;}/**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */},{key:'handleCaret',value:function handleCaret(){if(this.options.debug){console.log(\"Caret handling started\");}document.addEventListener(\"keyup\",this.caretEventHandler);document.addEventListener(\"mouseup\",this.caretEventHandler);document.addEventListener(\"touchend\",this.caretEventHandler);}/**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */},{key:'caretEventHandler',value:function caretEventHandler(event){var targetTagName=event.target.tagName.toLowerCase();if(targetTagName===\"textarea\"||targetTagName===\"input\"){/**\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 */this.caretPosition=event.target.selectionStart;if(this.options.debug){console.log('Caret at: ',event.target.selectionStart,event.target.tagName.toLowerCase());}}}/**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */},{key:'onInit',value:function onInit(){if(this.options.debug){console.log(\"Initialized\");}/**\r\n * Caret handling\r\n */this.handleCaret();if(typeof this.options.onInit===\"function\")this.options.onInit();}/**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n */},{key:'onRender',value:function onRender(){if(typeof this.options.onRender===\"function\")this.options.onRender();}/**\r\n * Register module\r\n *//**\r\n * Get module prop\r\n *//**\r\n * getModulesList\r\n */},{key:'render',/**\r\n * Renders rows and buttons as per options\r\n */value:function render(){var _this5=this;/**\r\n * Clear keyboard\r\n */this.clear();var layoutClass=this.options.layout?\"hg-layout-custom\":'hg-layout-'+this.options.layoutName;var layout=this.options.layout||__WEBPACK_IMPORTED_MODULE_2__services_KeyboardLayout__[\"a\" /* default */].getDefaultLayout();/**\r\n * Account for buttonTheme, if set\r\n */var buttonThemesParsed={};if(Array.isArray(this.options.buttonTheme)){this.options.buttonTheme.forEach(function(themeObj){if(themeObj.buttons&&themeObj.class){var themeButtons=void 0;if(typeof themeObj.buttons===\"string\"){themeButtons=themeObj.buttons.split(' ');}if(themeButtons){themeButtons.forEach(function(themeButton){var themeParsed=buttonThemesParsed[themeButton];// If the button has already been added\nif(themeParsed){// Making sure we don't add duplicate classes, even when buttonTheme has duplicates\nif(!_this5.utilities.countInArray(themeParsed.split(\" \"),themeObj.class)){buttonThemesParsed[themeButton]=themeParsed+' '+themeObj.class;}}else{buttonThemesParsed[themeButton]=themeObj.class;}});}}else{console.warn('buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.');}});}/**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */this.keyboardDOM.className+=' '+this.options.theme+' '+layoutClass;/**\r\n * Iterating through each row\r\n */layout[this.options.layoutName].forEach(function(row,rIndex){var rowArray=row.split(' ');/**\r\n * Creating empty row\r\n */var rowDOM=document.createElement('div');rowDOM.className+=\"hg-row\";/**\r\n * Iterating through each button in row\r\n */rowArray.forEach(function(button,bIndex){var fctBtnClass=_this5.utilities.getButtonClass(button);var buttonThemeClass=buttonThemesParsed[button];var buttonDisplayName=_this5.utilities.getButtonDisplayName(button,_this5.options.display,_this5.options.mergeDisplay);/**\r\n * Creating button\r\n */var buttonDOM=document.createElement('div');buttonDOM.className+='hg-button '+fctBtnClass+(buttonThemeClass?\" \"+buttonThemeClass:\"\");buttonDOM.onclick=function(){return _this5.handleButtonClicked(button);};/**\r\n * Adding identifier\r\n */buttonDOM.setAttribute(\"data-skBtn\",button);/**\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 */var buttonUID=_this5.options.layoutName+'-r'+rIndex+'b'+bIndex;buttonDOM.setAttribute(\"data-skBtnUID\",buttonUID);/**\r\n * Adding display label\r\n */buttonDOM.setAttribute(\"data-displayLabel\",buttonDisplayName);/**\r\n * Adding button label to button\r\n */var buttonSpanDOM=document.createElement('span');buttonSpanDOM.innerHTML=buttonDisplayName;buttonDOM.appendChild(buttonSpanDOM);/**\r\n * Adding to buttonElements\r\n */if(!_this5.buttonElements[button])_this5.buttonElements[button]=[];_this5.buttonElements[button].push(buttonDOM);/**\r\n * Appending button to row\r\n */rowDOM.appendChild(buttonDOM);});/**\r\n * Appending row to keyboard\r\n */_this5.keyboardDOM.appendChild(rowDOM);});/**\r\n * Calling onRender\r\n */this.onRender();if(!this.initialized){/**\r\n * Ensures that onInit is only called once per instantiation\r\n */this.initialized=true;/**\r\n * Calling onInit\r\n */this.onInit();}}}]);return SimpleKeyboard;}();/* harmony default export */ __webpack_exports__[\"a\"] = (SimpleKeyboard);\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n/* 4 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nvar _createClass=function(){function defineProperties(target,props){for(var i=0;i ? {shift}','.com @ {space}']};}}]);return KeyboardLayout;}();/* harmony default export */ __webpack_exports__[\"a\"] = (KeyboardLayout);\n\n/***/ }),\n/* 6 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nvar _typeof=typeof Symbol===\"function\"&&typeof Symbol.iterator===\"symbol\"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol===\"function\"&&obj.constructor===Symbol&&obj!==Symbol.prototype?\"symbol\":typeof obj;};var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){output=this.removeAt(output,caretPos);}else if(button===\"{space}\")output=this.addStringAt(output,\" \",caretPos);else if(button===\"{tab}\"&&!(typeof options.tabCharOnTab===\"boolean\"&&options.tabCharOnTab===false)){output=this.addStringAt(output,\"\\t\",caretPos);}else if((button===\"{enter}\"||button===\"{numpadenter}\")&&options.newLineOnEnter)output=this.addStringAt(output,\"\\n\",caretPos);else if(button.includes(\"numpad\")&&Number.isInteger(Number(button[button.length-2]))){output=this.addStringAt(output,button[button.length-2],caretPos);}else if(button===\"{numpaddivide}\")output=this.addStringAt(output,'/',caretPos);else if(button===\"{numpadmultiply}\")output=this.addStringAt(output,'*',caretPos);else if(button===\"{numpadsubtract}\")output=this.addStringAt(output,'-',caretPos);else if(button===\"{numpadadd}\")output=this.addStringAt(output,'+',caretPos);else if(button===\"{numpaddecimal}\")output=this.addStringAt(output,'.',caretPos);else if(button===\"{\"||button===\"}\")output=this.addStringAt(output,button,caretPos);else if(!button.includes(\"{\")&&!button.includes(\"}\"))output=this.addStringAt(output,button,caretPos);return output;}/**\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 */},{key:\"updateCaretPos\",value:function updateCaretPos(length,minus){if(minus){if(this.simpleKeyboardInstance.caretPosition>0)this.simpleKeyboardInstance.caretPosition=this.simpleKeyboardInstance.caretPosition-length;}else{this.simpleKeyboardInstance.caretPosition=this.simpleKeyboardInstance.caretPosition+length;}}/**\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 */},{key:\"addStringAt\",value:function addStringAt(source,string,position){var output=void 0;if(this.simpleKeyboardInstance.options.debug){console.log(\"Caret at:\",position);}if(!position&&position!==0){output=source+string;}else{output=[source.slice(0,position),string,source.slice(position)].join('');/**\r\n * Avoid caret position change when maxLength is set\r\n */if(!this.isMaxLengthReached()){this.updateCaretPos(string.length);}}return output;}/**\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 */},{key:\"removeAt\",value:function removeAt(source,position){if(this.simpleKeyboardInstance.caretPosition===0){return source;}var output=void 0;var prevTwoChars=void 0;var emojiMatched=void 0;var emojiMatchedReg=/([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;/**\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 */if(position&&position>=0){prevTwoChars=source.substring(position-2,position);emojiMatched=prevTwoChars.match(emojiMatchedReg);if(emojiMatched){output=source.substr(0,position-2)+source.substr(position);this.updateCaretPos(2,true);}else{output=source.substr(0,position-1)+source.substr(position);this.updateCaretPos(1,true);}}else{prevTwoChars=source.slice(-2);emojiMatched=prevTwoChars.match(emojiMatchedReg);if(emojiMatched){output=source.slice(0,-2);this.updateCaretPos(2,true);}else{output=source.slice(0,-1);this.updateCaretPos(1,true);}}return output;}/**\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 */},{key:\"handleMaxLength\",value:function handleMaxLength(inputObj,options,updatedInput){var maxLength=options.maxLength;var currentInput=inputObj[options.inputName];var condition=currentInput.length===maxLength;if(/**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */updatedInput.length<=currentInput.length){return false;}if(Number.isInteger(maxLength)){if(options.debug){console.log(\"maxLength (num) reached:\",condition);}if(condition){/**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */this.maxLengthReached=true;return true;}else{this.maxLengthReached=false;return false;}}if((typeof maxLength===\"undefined\"?\"undefined\":_typeof(maxLength))===\"object\"){var _condition=currentInput.length===maxLength[options.inputName];if(options.debug){console.log(\"maxLength (obj) reached:\",_condition);}if(_condition){this.maxLengthReached=true;return true;}else{this.maxLengthReached=false;return false;}}}/**\r\n * Gets the current value of maxLengthReached\r\n */},{key:\"isMaxLengthReached\",value:function isMaxLengthReached(){return Boolean(this.maxLengthReached);}/**\r\n * Transforms an arbitrary string to camelCase\r\n * \r\n * @param {string} string The string to transform.\r\n */},{key:\"camelCase\",value:function camelCase(string){return string.toLowerCase().trim().split(/[.\\-_\\s]/g).reduce(function(string,word){return string+word[0].toUpperCase()+word.slice(1);});}},{key:\"countInArray\",/**\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 */value:function countInArray(array,value){return array.reduce(function(n,x){return n+(x===value);},0);}}]);return Utilities;}();/* harmony default export */ __webpack_exports__[\"a\"] = (Utilities);\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// index.js"," \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 00c588c3323bf6c85ded","import SimpleKeyboard from './components/Keyboard';\r\nexport default SimpleKeyboard;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/lib/index.js","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 {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\r\n /**\r\n * Module namespace\r\n */\r\n this.modules = {};\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\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 * 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(button, this.input[this.options.inputName], this.options, this.caretPosition);\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] = updatedInput;\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 * 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[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\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 = event.target.tagName.toLowerCase();\r\n\r\n if(\r\n targetTagName === \"textarea\" ||\r\n targetTagName === \"input\"\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 * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\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\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}`;\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 buttonDOM.onclick = () => this.handleButtonClicked(button);\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 * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/lib/components/Keyboard.js","/**\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){\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;\n\n\n// WEBPACK FOOTER //\n// ./src/lib/services/PhysicalKeyboard.js","/**\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;\n\n\n// WEBPACK FOOTER //\n// ./src/lib/services/KeyboardLayout.js","/**\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 */\r\n getUpdatedInput(button, input, options, caretPos){\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);\r\n\r\n } else if(button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos);\r\n\r\n else if(button === \"{tab}\" && !(typeof options.tabCharOnTab === \"boolean\" && options.tabCharOnTab === false)){\r\n output = this.addStringAt(output, \"\\t\", caretPos);\r\n\r\n } else if((button === \"{enter}\" || button === \"{numpadenter}\") && options.newLineOnEnter)\r\n output = this.addStringAt(output, \"\\n\", caretPos);\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);\r\n\r\n else if(button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, '*', caretPos);\r\n else if(button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, '-', caretPos);\r\n\r\n else if(button === \"{numpadadd}\")\r\n output = this.addStringAt(output, '+', caretPos);\r\n\r\n else if(button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, '.', caretPos);\r\n\r\n else if(button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos);\r\n\r\n else if(!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos);\r\n\r\n return output;\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 */\r\n addStringAt(source, string, position){\r\n let output;\r\n\r\n if(this.simpleKeyboardInstance.options.debug){\r\n console.log(\"Caret at:\", position);\r\n }\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 this.updateCaretPos(string.length);\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 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 */\r\n removeAt(source, position){\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 this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, (position - 1)) + source.substr(position);\r\n 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 this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n this.updateCaretPos(1, true);\r\n }\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\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;\n\n\n// WEBPACK FOOTER //\n// ./src/lib/services/Utilities.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index c5a9fb84..2085a412 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-keyboard", - "version": "2.6.8", + "version": "2.7.0", "description": "On-screen Javascript Virtual Keyboard", "main": "build/index.js", "scripts": {