diff --git a/build/index.js b/build/index.js index b6468422..55f983b1 100644 --- a/build/index.js +++ b/build/index.js @@ -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("SimpleKeyboard",[],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(2)},function(t,e,n){},function(t,e,n){"use strict";n.r(e);n(1);function o(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}],(n=null)&&s(e.prototype,n),o&&s(e,o),t}();function u(t){return(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})(t)}function r(t,e){for(var n=0;n0?s=this.removeAt(s,o,i):"{space}"===t?s=this.addStringAt(s," ",o,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],o,i):"{numpaddivide}"===t?s=this.addStringAt(s,"/",o,i):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",o,i):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",o,i):"{numpadadd}"===t?s=this.addStringAt(s,"+",o,i):"{numpaddecimal}"===t?s=this.addStringAt(s,".",o,i):"{"===t||"}"===t?s=this.addStringAt(s,t,o,i):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,o,i)):s=this.addStringAt(s,"\n",o,i):s=this.addStringAt(s,"\t",o,i),s}},{key:"updateCaretPos",value:function(t,e){var n=this.updateCaretPosAction(this.simpleKeyboardInstance,t,e);this.simpleKeyboardInstance.options.syncInstanceInputs&&this.simpleKeyboardInstance.dispatch(function(t){t.caretPosition=n})}},{key:"updateCaretPosAction",value:function(t,e,n){return n?t.caretPosition>0&&(t.caretPosition=t.caretPosition-e):t.caretPosition=t.caretPosition+e,this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",t.caretPosition,"(".concat(t.keyboardDOMClass,")")),t.caretPosition}},{key:"addStringAt",value:function(t,e,n,o){var i;return n||0===n?(i=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||o&&this.updateCaretPos(e.length)):i=t+e,i}},{key:"removeAt",value:function(t,e,n){if(0===this.simpleKeyboardInstance.caretPosition)return t;var o,i=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?t.substring(e-2,e).match(i)?(o=t.substr(0,e-2)+t.substr(e),n&&this.updateCaretPos(2,!0)):(o=t.substr(0,e-1)+t.substr(e),n&&this.updateCaretPos(1,!0)):t.slice(-2).match(i)?(o=t.slice(0,-2),n&&this.updateCaretPos(2,!0)):(o=t.slice(0,-1),n&&this.updateCaretPos(1,!0)),o}},{key:"handleMaxLength",value:function(t,e,n){var o=e.maxLength,i=t[e.inputName],s=i.length===o;if(n.length<=i.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"===u(o)){var a=i.length===o[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return Boolean(this.maxLengthReached)}},{key:"isTouchDevice",value:function(){return"ontouchstart"in window||navigator.maxTouchPoints}},{key:"camelCase",value:function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return e.length?t+e[0].toUpperCase()+e.slice(1):t})}},{key:"countInArray",value:function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)}}])&&r(e.prototype,n),o&&r(e,o),t}();function l(t){return(l="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})(t)}function d(t,e){for(var n=0;n1?n:n[0]),e}},{key:"inputPatternIsValid",value:function(t){var e,n=this.options.inputPattern;if((e=n instanceof RegExp?n:n[this.options.inputName])&&t){var o=e.test(t);return this.options.debug&&console.log('inputPattern ("'.concat(e,'"): ').concat(o?"passed":"did not pass!")),o}return!0}},{key:"handleCaret",value:function(){this.caretPosition=null;var t=window.SimpleKeyboardInstances;(t&&Object.keys(t)[0]===this.utilities.camelCase(this.keyboardDOMClass)||!t)&&(this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")")),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&&(e=t.target.tagName.toLowerCase()),this.dispatch(function(n){n.isMouseHold&&(n.isMouseHold=!1),"textarea"!==e&&"input"!==e||n.options.disableCaretPositioning?n.options.disableCaretPositioning&&(n.caretPosition=null):(n.caretPosition=t.target.selectionStart,n.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase(),"(".concat(n.keyboardDOMClass,")")))})}},{key:"getButtonTheme",value:function(){var t=this,e={};return this.options.buttonTheme.forEach(function(n){var o;n.buttons&&n.class?("string"===typeof n.buttons&&(o=n.buttons.split(" ")),o&&o.forEach(function(o){var i=e[o];i?t.utilities.countInArray(i.split(" "),n.class)||(e[o]="".concat(i," ").concat(n.class)):e[o]=n.class})):console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),e}},{key:"onTouchDeviceDetected",value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:"disableContextualWindow",value:function(){window.oncontextmenu=function(t){if(t.target.classList.contains("hg-button"))return t.preventDefault(),t.stopPropagation(),!1}}},{key:"processAutoTouchEvents",value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log("autoUseTouchEvents: Touch device detected, useTouchEvents enabled."))}},{key:"onInit",value:function(){this.options.debug&&console.log("".concat(this.keyboardDOMClass," Initialized")),this.handleCaret(),"function"===typeof this.options.onInit&&this.options.onInit()}},{key:"beforeFirstRender",value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),"function"===typeof this.options.beforeFirstRender&&this.options.beforeFirstRender()}},{key:"beforeRender",value:function(){"function"===typeof this.options.beforeRender&&this.options.beforeRender()}},{key:"onRender",value:function(){"function"===typeof this.options.onRender&&this.options.onRender()}},{key:"onModulesLoaded",value:function(){"function"===typeof this.options.onModulesLoaded&&this.options.onModulesLoaded()}},{key:"loadModules",value:function(){var t=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach(function(e){var n=new e;if(n.constructor.name&&"Function"!==n.constructor.name){var o="module-".concat(t.utilities.camelCase(n.constructor.name));t.keyboardPluginClasses=t.keyboardPluginClasses+" ".concat(o)}n.init(t)}),this.keyboardPluginClasses=this.keyboardPluginClasses+" modules-loaded",this.render(),this.onModulesLoaded())}},{key:"render",value:function(){var t=this;this.clear(),this.initialized||this.beforeFirstRender(),this.beforeRender();var e="hg-layout-".concat(this.options.layoutName),n=this.options.layout||a.getDefaultLayout(),o=this.options.useTouchEvents||!1,i=o?"hg-touch-events":"",s=Array.isArray(this.options.buttonTheme)?this.getButtonTheme():{};this.keyboardDOM.className+=" ".concat(this.options.theme," ").concat(e," ").concat(this.keyboardPluginClasses," ").concat(i),n[this.options.layoutName].forEach(function(e,n){var i=e.split(" "),a=document.createElement("div");a.className+="hg-row",i.forEach(function(e,i){var u=t.utilities.getButtonClass(e),r=s[e],c=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),l=t.options.useButtonTag?"button":"div",d=document.createElement(l);d.className+="hg-button ".concat(u).concat(r?" "+r:""),o?(d.ontouchstart=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},d.ontouchend=function(e){return t.handleButtonMouseUp()},d.ontouchcancel=function(e){return t.handleButtonMouseUp()}):(d.onclick=function(){t.isMouseHold=!1,t.handleButtonClicked(e)},d.onmousedown=function(n){t.options.preventMouseDownDefault&&n.preventDefault(),t.handleButtonMouseDown(e,n)}),d.setAttribute("data-skBtn",e);var h="".concat(t.options.layoutName,"-r").concat(n,"b").concat(i);d.setAttribute("data-skBtnUID",h),d.setAttribute("data-displayLabel",c);var p=document.createElement("span");p.innerHTML=c,d.appendChild(p),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(d),a.appendChild(d)}),t.keyboardDOM.appendChild(a)}),this.onRender(),this.initialized||(this.initialized=!0,o||(document.onmouseup=function(){return t.handleButtonMouseUp()}),this.onInit())}}])&&d(e.prototype,n),o&&d(e,o),t}();e.default=p}])}); +!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define("SimpleKeyboard",[],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(window,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(2)},function(t,e,n){},function(t,e,n){"use strict";n.r(e);n(1);function i(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}],(n=null)&&s(e.prototype,n),i&&s(e,i),t}();function u(t){return(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})(t)}function r(t,e){for(var n=0;n0?s=this.removeAt(s,i,o):"{space}"===t?s=this.addStringAt(s," ",i,o):"{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,o):"{numpaddivide}"===t?s=this.addStringAt(s,"/",i,o):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",i,o):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",i,o):"{numpadadd}"===t?s=this.addStringAt(s,"+",i,o):"{numpaddecimal}"===t?s=this.addStringAt(s,".",i,o):"{"===t||"}"===t?s=this.addStringAt(s,t,i,o):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,i,o)):s=this.addStringAt(s,"\n",i,o):s=this.addStringAt(s,"\t",i,o),s}},{key:"updateCaretPos",value:function(t,e){var n=this.updateCaretPosAction(this.simpleKeyboardInstance,t,e);this.simpleKeyboardInstance.options.syncInstanceInputs&&this.simpleKeyboardInstance.dispatch(function(t){t.caretPosition=n})}},{key:"updateCaretPosAction",value:function(t,e,n){return n?t.caretPosition>0&&(t.caretPosition=t.caretPosition-e):t.caretPosition=t.caretPosition+e,this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",t.caretPosition,"(".concat(t.keyboardDOMClass,")")),t.caretPosition}},{key:"addStringAt",value:function(t,e,n,i){var o;return n||0===n?(o=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||i&&this.updateCaretPos(e.length)):o=t+e,o}},{key:"removeAt",value:function(t,e,n){if(0===this.simpleKeyboardInstance.caretPosition)return t;var i,o=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?t.substring(e-2,e).match(o)?(i=t.substr(0,e-2)+t.substr(e),n&&this.updateCaretPos(2,!0)):(i=t.substr(0,e-1)+t.substr(e),n&&this.updateCaretPos(1,!0)):t.slice(-2).match(o)?(i=t.slice(0,-2),n&&this.updateCaretPos(2,!0)):(i=t.slice(0,-1),n&&this.updateCaretPos(1,!0)),i}},{key:"handleMaxLength",value:function(t,e,n){var i=e.maxLength,o=t[e.inputName],s=o.length===i;if(n.length<=o.length)return!1;if(Number.isInteger(i))return e.debug&&console.log("maxLength (num) reached:",s),s?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===u(i)){var a=o.length===i[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return Boolean(this.maxLengthReached)}},{key:"isTouchDevice",value:function(){return"ontouchstart"in window||navigator.maxTouchPoints}},{key:"camelCase",value:function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return e.length?t+e[0].toUpperCase()+e.slice(1):t})}},{key:"countInArray",value:function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)}}])&&r(e.prototype,n),i&&r(e,i),t}();function h(t){return(h="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})(t)}function l(t,e){for(var n=0;n1?n:n[0]),e}},{key:"inputPatternIsValid",value:function(t){var e,n=this.options.inputPattern;if((e=n instanceof RegExp?n:n[this.options.inputName])&&t){var i=e.test(t);return this.options.debug&&console.log('inputPattern ("'.concat(e,'"): ').concat(i?"passed":"did not pass!")),i}return!0}},{key:"handleCaret",value:function(){this.caretPosition=null;var t=window.SimpleKeyboardInstances;(t&&Object.keys(t)[0]===this.utilities.camelCase(this.keyboardDOMClass)||!t)&&(this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")")),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&&(e=t.target.tagName.toLowerCase()),this.dispatch(function(n){n.isMouseHold&&(n.isMouseHold=!1),"textarea"!==e&&"input"!==e||n.options.disableCaretPositioning?n.options.disableCaretPositioning&&(n.caretPosition=null):(n.caretPosition=t.target.selectionStart,n.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase(),"(".concat(n.keyboardDOMClass,")")))})}},{key:"getButtonTheme",value:function(){var t=this,e={};return this.options.buttonTheme.forEach(function(n){var i;n.buttons&&n.class?("string"===typeof n.buttons&&(i=n.buttons.split(" ")),i&&i.forEach(function(i){var o=e[i];o?t.utilities.countInArray(o.split(" "),n.class)||(e[i]="".concat(o," ").concat(n.class)):e[i]=n.class})):console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),e}},{key:"onTouchDeviceDetected",value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:"disableContextualWindow",value:function(){window.oncontextmenu=function(t){if(t.target.classList.contains("hg-button"))return t.preventDefault(),t.stopPropagation(),!1}}},{key:"processAutoTouchEvents",value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log("autoUseTouchEvents: Touch device detected, useTouchEvents enabled."))}},{key:"onInit",value:function(){this.options.debug&&console.log("".concat(this.keyboardDOMClass," Initialized")),this.handleCaret(),"function"===typeof this.options.onInit&&this.options.onInit()}},{key:"beforeFirstRender",value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),"function"===typeof this.options.beforeFirstRender&&this.options.beforeFirstRender()}},{key:"beforeRender",value:function(){"function"===typeof this.options.beforeRender&&this.options.beforeRender()}},{key:"onRender",value:function(){"function"===typeof this.options.onRender&&this.options.onRender()}},{key:"onModulesLoaded",value:function(){"function"===typeof this.options.onModulesLoaded&&this.options.onModulesLoaded()}},{key:"loadModules",value:function(){var t=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach(function(e){var n=new e;if(n.constructor.name&&"Function"!==n.constructor.name){var i="module-".concat(t.utilities.camelCase(n.constructor.name));t.keyboardPluginClasses=t.keyboardPluginClasses+" ".concat(i)}n.init(t)}),this.keyboardPluginClasses=this.keyboardPluginClasses+" modules-loaded",this.render(),this.onModulesLoaded())}},{key:"render",value:function(){var t=this;this.clear(),this.initialized||this.beforeFirstRender(),this.beforeRender();var e="hg-layout-".concat(this.options.layoutName),n=this.options.layout||a.getDefaultLayout(),i=this.options.useTouchEvents||!1,o=i?"hg-touch-events":"",s=Array.isArray(this.options.buttonTheme)?this.getButtonTheme():{};this.keyboardDOM.className+=" ".concat(this.options.theme," ").concat(e," ").concat(this.keyboardPluginClasses," ").concat(o),n[this.options.layoutName].forEach(function(e,n){var o=e.split(" "),a=document.createElement("div");a.className+="hg-row",o.forEach(function(e,o){var u=t.utilities.getButtonClass(e),r=s[e],c=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),h=t.options.useButtonTag?"button":"div",l=document.createElement(h);l.className+="hg-button ".concat(u).concat(r?" "+r:""),i?(l.ontouchstart=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},l.ontouchend=function(e){return t.handleButtonMouseUp()},l.ontouchcancel=function(e){return t.handleButtonMouseUp()}):(l.onclick=function(){t.isMouseHold=!1,t.handleButtonClicked(e)},l.onmousedown=function(n){t.options.preventMouseDownDefault&&n.preventDefault(),t.handleButtonMouseDown(e,n)}),l.setAttribute("data-skBtn",e);var d="".concat(t.options.layoutName,"-r").concat(n,"b").concat(o);l.setAttribute("data-skBtnUID",d),l.setAttribute("data-displayLabel",c);var p=document.createElement("span");p.innerHTML=c,l.appendChild(p),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(l),a.appendChild(l)}),t.keyboardDOM.appendChild(a)}),this.onRender(),this.initialized||(this.initialized=!0,i||(document.onmouseup=function(){return t.handleButtonMouseUp()}),this.onInit())}}])&&l(e.prototype,n),i&&l(e,i),t}();e.default=p}])}); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map index f6e75f56..ceb47fda 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","bindMethods","myClass","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","getOwnPropertyNames","iterator","next","done","myMethod","err","return","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","newCaretPos","updateCaretPosAction","syncInstanceInputs","caretPosition","debug","console","log","keyboardDOMClass","source","string","position","slice","join","isMaxLengthReached","updateCaretPos","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","navigator","maxTouchPoints","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","_defineProperty","option","render","initCallback","prop","keys","keyboardDOMQuery","arguments","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","buttonElements","warn","Error","camelCase","physicalKeyboardInterface","loadModules","onKeyPress","getUpdatedInput","inputPattern","inputPatternIsValid","handleMaxLength","onChange","e","_this2","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","handleButtonHold","_this3","handleButtonClicked","_this4","replaceInput","innerHTML","className","callback","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","inputVal","inputPatternRaw","RegExp","didInputMatch","test","simpleKeyboardInstances","caretEventHandler","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","countInArray","processAutoTouchEvents","disableContextualWindow","oncontextmenu","classList","contains","preventDefault","stopPropagation","autoUseTouchEvents","useTouchEvents","handleCaret","onInit","isTouchDevice","onTouchDeviceDetected","beforeFirstRender","beforeRender","onRender","onModulesLoaded","_this8","Module","constructor","classStr","init","_this9","clear","initialized","layoutClass","layout","getDefaultLayout","useTouchEventsClass","getButtonTheme","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","getButtonClass","buttonThemeClass","buttonDisplayName","getButtonDisplayName","buttonType","useButtonTag","ontouchstart","handleButtonMouseDown","ontouchend","handleButtonMouseUp","ontouchcancel","onclick","onmousedown","setAttribute","buttonUID","buttonSpanDOM","appendChild","onmouseup"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAA,kBAAAC,OACAA,OAAAD,QAAAD,IACA,oBAAAG,eAAAC,IACAD,OAAA,oBAAAH,GACA,kBAAAC,QACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAA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BrC,EAAUyR,YAAc,SAAAtG,GAClB2E,EAAKnQ,QAAQ0K,yBAAyBc,EAAE0D,iBAC5CiB,EAAKsB,sBAAsB/O,EAAQ8I,KAOvCnL,EAAU0R,aAAa,aAAcrP,GAMrC,IAAIsP,EAAS,GAAAzR,OAAM4P,EAAKnQ,QAAQwK,WAAnB,MAAAjK,OAAkCqQ,EAAlC,KAAArQ,OAA4CyQ,GACzD3Q,EAAU0R,aAAa,gBAAiBC,GAKxC3R,EAAU0R,aAAa,oBAAqBX,GAK5C,IAAIa,EAAgBpS,SAASkR,cAAc,QAC3CkB,EAAc7F,UAAYgF,EAC1B/Q,EAAU6R,YAAYD,GAKjB9B,EAAKvF,eAAelI,KAASyN,EAAKvF,eAAelI,GAAU,IAEhEyN,EAAKvF,eAAelI,GAAQsK,KAAK3M,GAKjCyQ,EAAOoB,YAAY7R,KAMrB8P,EAAK7F,YAAY4H,YAAYpB,KAM/BrR,KAAKmQ,WAEAnQ,KAAK4Q,cAIR5Q,KAAK4Q,aAAc,EAKdhB,IACHxP,SAASsS,UAAY,kBAAMhC,EAAKwB,wBAMlClS,KAAK8P,+CCh7BI7F","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(\r\n this\r\n );\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 =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM) {\r\n buttonDOM.style.backgroundColor =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n this.simpleKeyboardInstance.options\r\n .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 =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM && buttonDOM.removeAttribute) {\r\n buttonDOM.removeAttribute(\"style\");\r\n }\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\" &&\r\n Number.isInteger(Number(event.code[1])) &&\r\n event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;\r\n","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout() {\r\n return {\r\n default: [\r\n \"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}\",\r\n \"{tab} q w e r t y u i o p [ ] \\\\\",\r\n \"{lock} a s d f g h j k l ; ' {enter}\",\r\n \"{shift} z x c v b n m , . / {shift}\",\r\n \".com @ {space}\"\r\n ],\r\n shift: [\r\n \"~ ! @ # $ % ^ & * ( ) _ + {bksp}\",\r\n \"{tab} Q W E R T Y U I O P { } |\",\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n \"{shift} Z X C V B N M < > ? {shift}\",\r\n \".com @ {space}\"\r\n ]\r\n };\r\n }\r\n}\r\n\r\nexport default KeyboardLayout;\r\n","/**\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 Utilities.bindMethods(Utilities, 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 =\r\n button.includes(\"{\") && button.includes(\"}\") && button !== \"{//}\"\r\n ? \"functionBtn\"\r\n : \"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 * Returns the updated input resulting from clicking a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret) {\r\n let output = input;\r\n\r\n if (\r\n (button === \"{bksp}\" || button === \"{backspace}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n } else if (button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n else if (\r\n button === \"{tab}\" &&\r\n !(\r\n typeof options.tabCharOnTab === \"boolean\" &&\r\n options.tabCharOnTab === false\r\n )\r\n ) {\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n } else if (\r\n (button === \"{enter}\" || button === \"{numpadenter}\") &&\r\n options.newLineOnEnter\r\n )\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n else if (\r\n button.includes(\"numpad\") &&\r\n Number.isInteger(Number(button[button.length - 2]))\r\n ) {\r\n output = this.addStringAt(\r\n output,\r\n button[button.length - 2],\r\n caretPos,\r\n moveCaret\r\n );\r\n } else if (button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, \"/\", caretPos, moveCaret);\r\n else if (button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, \"*\", caretPos, moveCaret);\r\n else if (button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, \"-\", caretPos, moveCaret);\r\n else if (button === \"{numpadadd}\")\r\n output = this.addStringAt(output, \"+\", caretPos, moveCaret);\r\n else if (button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, \".\", caretPos, moveCaret);\r\n else if (button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n else if (!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus) {\r\n let newCaretPos = this.updateCaretPosAction(\r\n this.simpleKeyboardInstance,\r\n length,\r\n minus\r\n );\r\n\r\n if (this.simpleKeyboardInstance.options.syncInstanceInputs) {\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {object} instance The instance whose position should be updated\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(instance, length, minus) {\r\n if (minus) {\r\n if (instance.caretPosition > 0)\r\n instance.caretPosition = instance.caretPosition - length;\r\n } else {\r\n instance.caretPosition = instance.caretPosition + length;\r\n }\r\n\r\n if (this.simpleKeyboardInstance.options.debug) {\r\n console.log(\r\n \"Caret at:\",\r\n instance.caretPosition,\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n\r\n return instance.caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret) {\r\n let output;\r\n\r\n if (!position && position !== 0) {\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join(\r\n \"\"\r\n );\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if (!this.isMaxLengthReached()) {\r\n if (moveCaret) this.updateCaretPos(string.length);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret) {\r\n if (this.simpleKeyboardInstance.caretPosition === 0) {\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if (position && position >= 0) {\r\n prevTwoChars = source.substring(position - 2, position);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.substr(0, position - 2) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, position - 1) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.slice(0, -2);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n *\r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput) {\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if (\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ) {\r\n return false;\r\n }\r\n\r\n if (Number.isInteger(maxLength)) {\r\n if (options.debug) {\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if (typeof maxLength === \"object\") {\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if (options.debug) {\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached() {\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Determines whether a touch device is being used \r\n */\r\n isTouchDevice(){\r\n return 'ontouchstart' in window || navigator.maxTouchPoints; \r\n }\r\n\r\n /**\r\n * Bind all methods in a given class\r\n */\r\n static bindMethods(myClass, instance) {\r\n for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {\r\n let excludeMethod = (myMethod === \"constructor\" || myMethod === \"bindMethods\");\r\n if (!excludeMethod) {\r\n instance[myMethod] = instance[myMethod].bind(instance);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string) {\r\n return string\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce((string, word) =>\r\n word.length ? string + word[0].toUpperCase() + word.slice(1) : string\r\n );\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\nexport default Utilities;\r\n","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 =\r\n 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) options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n * @property {boolean} useButtonTag Render buttons as a button element instead of a div element.\r\n * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.\r\n * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.\r\n * @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.\r\n * @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.\r\n */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault =\r\n this.options.preventMouseDownDefault || false;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = \"\";\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(SimpleKeyboard, this);\r\n\r\n /**\r\n * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).\r\n * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.\r\n * @example\r\n * // To get entered input\r\n * 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) 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\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button) {\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if (button === \"{//}\") return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if (typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n\r\n if (!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = \"\";\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition\r\n );\r\n\r\n if (\r\n // If input will change as a result of this button press\r\n this.input[this.options.inputName] !== updatedInput &&\r\n // This pertains to the \"inputPattern\" option:\r\n // If inputPattern isn't set\r\n (!this.options.inputPattern ||\r\n // Or, if it is set and if the pattern is valid - we proceed.\r\n (this.options.inputPattern && this.inputPatternIsValid(updatedInput)))\r\n ) {\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if (\r\n this.options.maxLength &&\r\n this.utilities.handleMaxLength(this.input, this.options, updatedInput)\r\n ) {\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition,\r\n true\r\n );\r\n\r\n if (debug) console.log(\"Input changed:\", this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n }\r\n\r\n if (debug) {\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e) {\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n if (this.holdTimeout) clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if (\r\n this.isMouseHold &&\r\n ((!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{delete}\" ||\r\n button === \"{backspace}\" ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\")\r\n ) {\r\n if (this.options.debug) console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp() {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button) {\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if (this.isMouseHold) {\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs() {\r\n this.dispatch(instance => {\r\n instance.replaceInput(this.input);\r\n });\r\n }\r\n\r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = \"\";\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) 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) 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) 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(\r\n `SimpleKeyboardInstances is not defined. Dispatch cannot be called.`\r\n );\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n\r\n return Object.keys(window[\"SimpleKeyboardInstances\"]).forEach(key => {\r\n callback(window[\"SimpleKeyboardInstances\"][key], key);\r\n });\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className) {\r\n if (!className || !buttons) return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if (!this.options.buttonTheme) this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n\r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n if (buttonTheme.class.split(\" \").includes(classNameItem)) {\r\n classNameFound = true;\r\n\r\n 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 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 (\r\n buttons &&\r\n Array.isArray(this.options.buttonTheme) &&\r\n this.options.buttonTheme.length\r\n ) {\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if (\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ) {\r\n let filteredButtonArray = buttonTheme.buttons\r\n .split(\" \")\r\n .filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if (filteredButtonArray.length) {\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(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 * This handles the \"inputPattern\" option\r\n * by checking if the provided inputPattern passes\r\n */\r\n inputPatternIsValid(inputVal) {\r\n let inputPatternRaw = this.options.inputPattern;\r\n let inputPattern;\r\n\r\n /**\r\n * Check if input pattern is global or targeted to individual inputs\r\n */\r\n if (inputPatternRaw instanceof RegExp) {\r\n inputPattern = inputPatternRaw;\r\n } else {\r\n inputPattern = inputPatternRaw[this.options.inputName];\r\n }\r\n\r\n if (inputPattern && inputVal) {\r\n let didInputMatch = inputPattern.test(inputVal);\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `inputPattern (\"${inputPattern}\"): ${\r\n didInputMatch ? \"passed\" : \"did not pass!\"\r\n }`\r\n );\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret() {\r\n /**\r\n * Only first instance should insall the caret handling events\r\n */\r\n this.caretPosition = null;\r\n let simpleKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n\r\n if (\r\n (simpleKeyboardInstances &&\r\n Object.keys(simpleKeyboardInstances)[0] ===\r\n this.utilities.camelCase(this.keyboardDOMClass)) ||\r\n !simpleKeyboardInstances\r\n ) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\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 /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\r\n let targetTagName;\r\n if (event.target.tagName) {\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch(instance => {\r\n if (instance.isMouseHold) {\r\n instance.isMouseHold = false;\r\n }\r\n\r\n if (\r\n (targetTagName === \"textarea\" || targetTagName === \"input\") &&\r\n !instance.options.disableCaretPositioning\r\n ) {\r\n /**\r\n * Tracks current cursor position\r\n * As keys are pressed, text will be added/removed at that position within the input.\r\n */\r\n instance.caretPosition = event.target.selectionStart;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n event.target.selectionStart,\r\n event.target.tagName.toLowerCase(),\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n } else if (instance.options.disableCaretPositioning) {\r\n /**\r\n * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.\r\n */\r\n instance.caretPosition = null;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Process buttonTheme option\r\n */\r\n getButtonTheme(){\r\n let buttonThemesParsed = {};\r\n \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 (\r\n !this.utilities.countInArray(\r\n themeParsed.split(\" \"),\r\n themeObj.class\r\n )\r\n ) {\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${\r\n themeObj.class\r\n }`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(\r\n `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 return buttonThemesParsed;\r\n }\r\n\r\n onTouchDeviceDetected(){\r\n /**\r\n * Processing autoTouchEvents\r\n */\r\n this.processAutoTouchEvents();\r\n\r\n /**\r\n * Disabling contextual window on touch devices\r\n */\r\n this.disableContextualWindow();\r\n }\r\n\r\n /**\r\n * Disabling contextual window for hg-button\r\n */\r\n /* istanbul ignore next */\r\n disableContextualWindow(){\r\n window.oncontextmenu = (event) => {\r\n if(event.target.classList.contains(\"hg-button\")){\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return false;\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Process autoTouchEvents option\r\n */\r\n processAutoTouchEvents(){\r\n if (this.options.autoUseTouchEvents){\r\n this.options.useTouchEvents = true;\r\n\r\n if (this.options.debug) {\r\n console.log(`autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender(){\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if(this.utilities.isTouchDevice()){\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\") this.options.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender(){\r\n if (typeof this.options.beforeRender === \"function\") this.options.beforeRender();\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\") this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded() {\r\n if (typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if (!this.modules[name]) this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n };\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules() {\r\n if (Array.isArray(this.options.modules)) {\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if (module.constructor.name && module.constructor.name !== \"Function\") {\r\n let classStr = `module-${this.utilities.camelCase(\r\n module.constructor.name\r\n )}`;\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + \" modules-loaded\";\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp = (name, prop) => {\r\n if (!this.modules[name]) return false;\r\n\r\n return this.modules[name][prop];\r\n };\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList = () => {\r\n return Object.keys(this.modules);\r\n };\r\n\r\n /**\r\n * 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 /**\r\n * Calling beforeFirstRender\r\n */\r\n if(!this.initialized){\r\n this.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Calling beforeRender\r\n */\r\n this.beforeRender();\r\n\r\n let layoutClass = `hg-layout-${this.options.layoutName}`;\r\n let layout = this.options.layout || KeyboardLayout.getDefaultLayout();\r\n let useTouchEvents = this.options.useTouchEvents || false;\r\n let useTouchEventsClass = useTouchEvents ? \"hg-touch-events\" : \"\";\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = Array.isArray(this.options.buttonTheme) ? this.getButtonTheme() : {};\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses} ${useTouchEventsClass}`;\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 let 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(\r\n button,\r\n this.options.display,\r\n this.options.mergeDisplay\r\n );\r\n\r\n /**\r\n * Creating button\r\n */\r\n let buttonType = this.options.useButtonTag ? \"button\" : \"div\";\r\n let buttonDOM = document.createElement(buttonType);\r\n buttonDOM.className += `hg-button ${fctBtnClass}${\r\n buttonThemeClass ? \" \" + buttonThemeClass : \"\"\r\n }`;\r\n\r\n if (useTouchEvents) {\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => {\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n }\r\n\r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n let buttonSpanDOM = document.createElement(\"span\");\r\n buttonSpanDOM.innerHTML = buttonDisplayName;\r\n buttonDOM.appendChild(buttonSpanDOM);\r\n\r\n /**\r\n * Adding to buttonElements\r\n */\r\n if (!this.buttonElements[button]) this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n });\r\n\r\n /**\r\n * 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 and beforeFirstRender are only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling mouseup\r\n */\r\n if (!useTouchEvents) {\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from \"./components/Keyboard\";\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","getButtonClass","getButtonDisplayName","getUpdatedInput","updateCaretPos","updateCaretPosAction","isMaxLengthReached","camelCase","countInArray","isTouchDevice","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","newCaretPos","syncInstanceInputs","caretPosition","debug","console","log","keyboardDOMClass","source","string","position","slice","join","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","navigator","maxTouchPoints","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","_defineProperty","option","render","initCallback","prop","keys","keyboardDOMQuery","arguments","undefined","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","handleButtonClicked","clearInput","getInput","setInput","replaceInput","clear","addButtonTheme","removeButtonTheme","handleCaret","caretEventHandler","onInit","onRender","loadModules","handleButtonMouseUp","handleButtonMouseDown","handleButtonHold","onModulesLoaded","inputPatternIsValid","beforeFirstRender","beforeRender","disableContextualWindow","onTouchDeviceDetected","processAutoTouchEvents","buttonElements","warn","Error","physicalKeyboardInterface","onKeyPress","inputPattern","handleMaxLength","onChange","e","_this2","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","_this3","_this4","innerHTML","className","callback","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","inputVal","inputPatternRaw","RegExp","didInputMatch","test","simpleKeyboardInstances","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","oncontextmenu","classList","contains","preventDefault","stopPropagation","autoUseTouchEvents","useTouchEvents","_this8","Module","constructor","classStr","init","_this9","initialized","layoutClass","layout","getDefaultLayout","useTouchEventsClass","getButtonTheme","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","buttonThemeClass","buttonDisplayName","buttonType","useButtonTag","ontouchstart","ontouchend","ontouchcancel","onclick","onmousedown","setAttribute","buttonUID","buttonSpanDOM","appendChild","onmouseup"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAA,kBAAAC,OACAA,OAAAD,QAAAD,IACA,oBAAAG,eAAAC,IACAD,OAAA,oBAAAH,GACA,kBAAAC,QACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAQ,GAAA,EAGAR,EAAAD,QA0DA,OArDAM,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KA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Q,EAAlC,KAAAhQ,OAA4CoQ,GACzDtQ,EAAUiR,aAAa,gBAAiBC,GAKxClR,EAAUiR,aAAa,oBAAqBR,GAK5C,IAAIU,EAAgB3R,SAAS6Q,cAAc,QAC3Cc,EAAc5E,UAAYkE,EAC1BzQ,EAAUoR,YAAYD,GAKjBzB,EAAKpE,eAAevJ,KAAS2N,EAAKpE,eAAevJ,GAAU,IAEhE2N,EAAKpE,eAAevJ,GAAQoL,KAAKnN,GAKjCoQ,EAAOgB,YAAYpR,KAMrB0P,EAAKjG,YAAY2H,YAAYhB,KAM/BhR,KAAKsL,WAEAtL,KAAKuQ,cAIRvQ,KAAKuQ,aAAc,EAKdP,IACH5P,SAAS6R,UAAY,kBAAM3B,EAAK9E,wBAMlCxL,KAAKqL,+CC18BI7B","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(\r\n this\r\n );\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 =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM) {\r\n buttonDOM.style.backgroundColor =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n this.simpleKeyboardInstance.options\r\n .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 =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM && buttonDOM.removeAttribute) {\r\n buttonDOM.removeAttribute(\"style\");\r\n }\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\" &&\r\n Number.isInteger(Number(event.code[1])) &&\r\n event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;\r\n","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout() {\r\n return {\r\n default: [\r\n \"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}\",\r\n \"{tab} q w e r t y u i o p [ ] \\\\\",\r\n \"{lock} a s d f g h j k l ; ' {enter}\",\r\n \"{shift} z x c v b n m , . / {shift}\",\r\n \".com @ {space}\"\r\n ],\r\n shift: [\r\n \"~ ! @ # $ % ^ & * ( ) _ + {bksp}\",\r\n \"{tab} Q W E R T Y U I O P { } |\",\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n \"{shift} Z X C V B N M < > ? {shift}\",\r\n \".com @ {space}\"\r\n ]\r\n };\r\n }\r\n}\r\n\r\nexport default KeyboardLayout;\r\n","/**\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.updateCaretPosAction = this.updateCaretPosAction.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 this.isTouchDevice = this.isTouchDevice.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 =\r\n button.includes(\"{\") && button.includes(\"}\") && button !== \"{//}\"\r\n ? \"functionBtn\"\r\n : \"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 * Returns the updated input resulting from clicking a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret) {\r\n let output = input;\r\n\r\n if (\r\n (button === \"{bksp}\" || button === \"{backspace}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n } else if (button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n else if (\r\n button === \"{tab}\" &&\r\n !(\r\n typeof options.tabCharOnTab === \"boolean\" &&\r\n options.tabCharOnTab === false\r\n )\r\n ) {\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n } else if (\r\n (button === \"{enter}\" || button === \"{numpadenter}\") &&\r\n options.newLineOnEnter\r\n )\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n else if (\r\n button.includes(\"numpad\") &&\r\n Number.isInteger(Number(button[button.length - 2]))\r\n ) {\r\n output = this.addStringAt(\r\n output,\r\n button[button.length - 2],\r\n caretPos,\r\n moveCaret\r\n );\r\n } else if (button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, \"/\", caretPos, moveCaret);\r\n else if (button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, \"*\", caretPos, moveCaret);\r\n else if (button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, \"-\", caretPos, moveCaret);\r\n else if (button === \"{numpadadd}\")\r\n output = this.addStringAt(output, \"+\", caretPos, moveCaret);\r\n else if (button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, \".\", caretPos, moveCaret);\r\n else if (button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n else if (!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus) {\r\n let newCaretPos = this.updateCaretPosAction(\r\n this.simpleKeyboardInstance,\r\n length,\r\n minus\r\n );\r\n\r\n if (this.simpleKeyboardInstance.options.syncInstanceInputs) {\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {object} instance The instance whose position should be updated\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(instance, length, minus) {\r\n if (minus) {\r\n if (instance.caretPosition > 0)\r\n instance.caretPosition = instance.caretPosition - length;\r\n } else {\r\n instance.caretPosition = instance.caretPosition + length;\r\n }\r\n\r\n if (this.simpleKeyboardInstance.options.debug) {\r\n console.log(\r\n \"Caret at:\",\r\n instance.caretPosition,\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n\r\n return instance.caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret) {\r\n let output;\r\n\r\n if (!position && position !== 0) {\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join(\r\n \"\"\r\n );\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if (!this.isMaxLengthReached()) {\r\n if (moveCaret) this.updateCaretPos(string.length);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret) {\r\n if (this.simpleKeyboardInstance.caretPosition === 0) {\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if (position && position >= 0) {\r\n prevTwoChars = source.substring(position - 2, position);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.substr(0, position - 2) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, position - 1) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.slice(0, -2);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n *\r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput) {\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if (\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ) {\r\n return false;\r\n }\r\n\r\n if (Number.isInteger(maxLength)) {\r\n if (options.debug) {\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if (typeof maxLength === \"object\") {\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if (options.debug) {\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached() {\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Determines whether a touch device is being used\r\n */\r\n isTouchDevice() {\r\n return \"ontouchstart\" in window || navigator.maxTouchPoints;\r\n }\r\n\r\n /**\r\n * 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\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce((string, word) =>\r\n word.length ? string + word[0].toUpperCase() + word.slice(1) : string\r\n );\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\nexport default Utilities;\r\n","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 =\r\n 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) options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n * @property {boolean} useButtonTag Render buttons as a button element instead of a div element.\r\n * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.\r\n * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.\r\n * @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.\r\n * @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.\r\n */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault =\r\n this.options.preventMouseDownDefault || false;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = \"\";\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.handleButtonClicked = this.handleButtonClicked.bind(this);\r\n this.syncInstanceInputs = this.syncInstanceInputs.bind(this);\r\n this.clearInput = this.clearInput.bind(this);\r\n this.getInput = this.getInput.bind(this);\r\n this.setInput = this.setInput.bind(this);\r\n this.replaceInput = this.replaceInput.bind(this);\r\n this.clear = this.clear.bind(this);\r\n this.dispatch = this.dispatch.bind(this);\r\n this.addButtonTheme = this.addButtonTheme.bind(this);\r\n this.removeButtonTheme = this.removeButtonTheme.bind(this);\r\n this.getButtonElement = this.getButtonElement.bind(this);\r\n this.handleCaret = this.handleCaret.bind(this);\r\n this.caretEventHandler = this.caretEventHandler.bind(this);\r\n this.onInit = this.onInit.bind(this);\r\n this.onRender = this.onRender.bind(this);\r\n this.render = this.render.bind(this);\r\n this.loadModules = this.loadModules.bind(this);\r\n this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this);\r\n this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this);\r\n this.handleButtonHold = this.handleButtonHold.bind(this);\r\n this.onModulesLoaded = this.onModulesLoaded.bind(this);\r\n this.inputPatternIsValid = this.inputPatternIsValid.bind(this);\r\n this.beforeFirstRender = this.beforeFirstRender.bind(this);\r\n this.beforeRender = this.beforeRender.bind(this);\r\n this.disableContextualWindow = this.disableContextualWindow.bind(this);\r\n this.onTouchDeviceDetected = this.onTouchDeviceDetected.bind(this);\r\n this.processAutoTouchEvents = this.processAutoTouchEvents.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) 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\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button) {\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if (button === \"{//}\") return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if (typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n\r\n if (!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = \"\";\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition\r\n );\r\n\r\n if (\r\n // If input will change as a result of this button press\r\n this.input[this.options.inputName] !== updatedInput &&\r\n // This pertains to the \"inputPattern\" option:\r\n // If inputPattern isn't set\r\n (!this.options.inputPattern ||\r\n // Or, if it is set and if the pattern is valid - we proceed.\r\n (this.options.inputPattern && this.inputPatternIsValid(updatedInput)))\r\n ) {\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if (\r\n this.options.maxLength &&\r\n this.utilities.handleMaxLength(this.input, this.options, updatedInput)\r\n ) {\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition,\r\n true\r\n );\r\n\r\n if (debug) console.log(\"Input changed:\", this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n }\r\n\r\n if (debug) {\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e) {\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n if (this.holdTimeout) clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if (\r\n this.isMouseHold &&\r\n ((!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{delete}\" ||\r\n button === \"{backspace}\" ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\")\r\n ) {\r\n if (this.options.debug) console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp() {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button) {\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if (this.isMouseHold) {\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs() {\r\n this.dispatch(instance => {\r\n instance.replaceInput(this.input);\r\n });\r\n }\r\n\r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = \"\";\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) 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) 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) 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(\r\n `SimpleKeyboardInstances is not defined. Dispatch cannot be called.`\r\n );\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n\r\n return Object.keys(window[\"SimpleKeyboardInstances\"]).forEach(key => {\r\n callback(window[\"SimpleKeyboardInstances\"][key], key);\r\n });\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className) {\r\n if (!className || !buttons) return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if (!this.options.buttonTheme) this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n\r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n if (buttonTheme.class.split(\" \").includes(classNameItem)) {\r\n classNameFound = true;\r\n\r\n 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 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 (\r\n buttons &&\r\n Array.isArray(this.options.buttonTheme) &&\r\n this.options.buttonTheme.length\r\n ) {\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if (\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ) {\r\n let filteredButtonArray = buttonTheme.buttons\r\n .split(\" \")\r\n .filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if (filteredButtonArray.length) {\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(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 * This handles the \"inputPattern\" option\r\n * by checking if the provided inputPattern passes\r\n */\r\n inputPatternIsValid(inputVal) {\r\n let inputPatternRaw = this.options.inputPattern;\r\n let inputPattern;\r\n\r\n /**\r\n * Check if input pattern is global or targeted to individual inputs\r\n */\r\n if (inputPatternRaw instanceof RegExp) {\r\n inputPattern = inputPatternRaw;\r\n } else {\r\n inputPattern = inputPatternRaw[this.options.inputName];\r\n }\r\n\r\n if (inputPattern && inputVal) {\r\n let didInputMatch = inputPattern.test(inputVal);\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `inputPattern (\"${inputPattern}\"): ${\r\n didInputMatch ? \"passed\" : \"did not pass!\"\r\n }`\r\n );\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret() {\r\n /**\r\n * Only first instance should insall the caret handling events\r\n */\r\n this.caretPosition = null;\r\n let simpleKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n\r\n if (\r\n (simpleKeyboardInstances &&\r\n Object.keys(simpleKeyboardInstances)[0] ===\r\n this.utilities.camelCase(this.keyboardDOMClass)) ||\r\n !simpleKeyboardInstances\r\n ) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\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 /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\r\n let targetTagName;\r\n if (event.target.tagName) {\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch(instance => {\r\n if (instance.isMouseHold) {\r\n instance.isMouseHold = false;\r\n }\r\n\r\n if (\r\n (targetTagName === \"textarea\" || targetTagName === \"input\") &&\r\n !instance.options.disableCaretPositioning\r\n ) {\r\n /**\r\n * Tracks current cursor position\r\n * As keys are pressed, text will be added/removed at that position within the input.\r\n */\r\n instance.caretPosition = event.target.selectionStart;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n event.target.selectionStart,\r\n event.target.tagName.toLowerCase(),\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n } else if (instance.options.disableCaretPositioning) {\r\n /**\r\n * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.\r\n */\r\n instance.caretPosition = null;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Process buttonTheme option\r\n */\r\n getButtonTheme(){\r\n let buttonThemesParsed = {};\r\n \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 (\r\n !this.utilities.countInArray(\r\n themeParsed.split(\" \"),\r\n themeObj.class\r\n )\r\n ) {\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${\r\n themeObj.class\r\n }`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(\r\n `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 return buttonThemesParsed;\r\n }\r\n\r\n onTouchDeviceDetected() {\r\n /**\r\n * Processing autoTouchEvents\r\n */\r\n this.processAutoTouchEvents();\r\n\r\n /**\r\n * Disabling contextual window on touch devices\r\n */\r\n this.disableContextualWindow();\r\n }\r\n\r\n /**\r\n * Disabling contextual window for hg-button\r\n */\r\n /* istanbul ignore next */\r\n disableContextualWindow() {\r\n window.oncontextmenu = event => {\r\n if (event.target.classList.contains(\"hg-button\")) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return false;\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Process autoTouchEvents option\r\n */\r\n processAutoTouchEvents() {\r\n if (this.options.autoUseTouchEvents) {\r\n this.options.useTouchEvents = true;\r\n\r\n if (this.options.debug) {\r\n console.log(`autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender(){\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if (this.utilities.isTouchDevice()) {\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\") this.options.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender(){\r\n if (typeof this.options.beforeRender === \"function\") this.options.beforeRender();\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\") this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded() {\r\n if (typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if (!this.modules[name]) this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n };\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules() {\r\n if (Array.isArray(this.options.modules)) {\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if (module.constructor.name && module.constructor.name !== \"Function\") {\r\n let classStr = `module-${this.utilities.camelCase(\r\n module.constructor.name\r\n )}`;\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + \" modules-loaded\";\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp = (name, prop) => {\r\n if (!this.modules[name]) return false;\r\n\r\n return this.modules[name][prop];\r\n };\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList = () => {\r\n return Object.keys(this.modules);\r\n };\r\n\r\n /**\r\n * 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 /**\r\n * Calling beforeFirstRender\r\n */\r\n if(!this.initialized){\r\n this.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Calling beforeRender\r\n */\r\n this.beforeRender();\r\n\r\n let layoutClass = `hg-layout-${this.options.layoutName}`;\r\n let layout = this.options.layout || KeyboardLayout.getDefaultLayout();\r\n let useTouchEvents = this.options.useTouchEvents || false;\r\n let useTouchEventsClass = useTouchEvents ? \"hg-touch-events\" : \"\";\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = Array.isArray(this.options.buttonTheme) ? this.getButtonTheme() : {};\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses} ${useTouchEventsClass}`;\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 let 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(\r\n button,\r\n this.options.display,\r\n this.options.mergeDisplay\r\n );\r\n\r\n /**\r\n * Creating button\r\n */\r\n let buttonType = this.options.useButtonTag ? \"button\" : \"div\";\r\n let buttonDOM = document.createElement(buttonType);\r\n buttonDOM.className += `hg-button ${fctBtnClass}${\r\n buttonThemeClass ? \" \" + buttonThemeClass : \"\"\r\n }`;\r\n\r\n if (useTouchEvents) {\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => {\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n }\r\n\r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n let buttonSpanDOM = document.createElement(\"span\");\r\n buttonSpanDOM.innerHTML = buttonDisplayName;\r\n buttonDOM.appendChild(buttonSpanDOM);\r\n\r\n /**\r\n * Adding to buttonElements\r\n */\r\n if (!this.buttonElements[button]) this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n });\r\n\r\n /**\r\n * 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 and beforeFirstRender are only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling mouseup\r\n */\r\n if (!useTouchEvents) {\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from \"./components/Keyboard\";\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/build/simple-keyboard.js b/build/simple-keyboard.js index a531b644..cf79025e 100644 --- a/build/simple-keyboard.js +++ b/build/simple-keyboard.js @@ -347,7 +347,15 @@ */ this.simpleKeyboardInstance = simpleKeyboardInstance; /** * Bindings - */ Utilities.bindMethods(Utilities, this); + */ this.getButtonClass = this.getButtonClass.bind(this); + this.getButtonDisplayName = this.getButtonDisplayName.bind(this); + this.getUpdatedInput = this.getUpdatedInput.bind(this); + this.updateCaretPos = this.updateCaretPos.bind(this); + this.updateCaretPosAction = this.updateCaretPosAction.bind(this); + this.isMaxLengthReached = this.isMaxLengthReached.bind(this); + this.camelCase = this.camelCase.bind(this); + this.countInArray = this.countInArray.bind(this); + this.isTouchDevice = this.isTouchDevice.bind(this); } /** * Adds default classes to a given button @@ -660,14 +668,12 @@ return "ontouchstart" in window || navigator.maxTouchPoints; } /** - * Bind all methods in a given class - */ }, { - key: "camelCase", - /** * Transforms an arbitrary string to camelCase * * @param {string} string The string to transform. - */ value: function camelCase(string) { + */ }, { + key: "camelCase", + value: function camelCase(string) { return string.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(string, word) { return word.length ? string + word[0].toUpperCase() + word.slice(1) : string; }); @@ -684,35 +690,6 @@ return n + (x === value); }, 0); } - } ], [ { - key: "bindMethods", - value: function bindMethods(myClass, instance) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - try { - for (var _iterator = Object.getOwnPropertyNames(myClass.prototype)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var myMethod = _step.value; - var excludeMethod = myMethod === "constructor" || myMethod === "bindMethods"; - if (!excludeMethod) { - instance[myMethod] = instance[myMethod].bind(instance); - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } } ]); return Utilities; }(); @@ -852,7 +829,33 @@ */ this.keyboardPluginClasses = ""; /** * Bindings - */ services_Utilities.bindMethods(SimpleKeyboard, this); + */ this.handleButtonClicked = this.handleButtonClicked.bind(this); + this.syncInstanceInputs = this.syncInstanceInputs.bind(this); + this.clearInput = this.clearInput.bind(this); + this.getInput = this.getInput.bind(this); + this.setInput = this.setInput.bind(this); + this.replaceInput = this.replaceInput.bind(this); + this.clear = this.clear.bind(this); + this.dispatch = this.dispatch.bind(this); + this.addButtonTheme = this.addButtonTheme.bind(this); + this.removeButtonTheme = this.removeButtonTheme.bind(this); + this.getButtonElement = this.getButtonElement.bind(this); + this.handleCaret = this.handleCaret.bind(this); + this.caretEventHandler = this.caretEventHandler.bind(this); + this.onInit = this.onInit.bind(this); + this.onRender = this.onRender.bind(this); + this.render = this.render.bind(this); + this.loadModules = this.loadModules.bind(this); + this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this); + this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this); + this.handleButtonHold = this.handleButtonHold.bind(this); + this.onModulesLoaded = this.onModulesLoaded.bind(this); + this.inputPatternIsValid = this.inputPatternIsValid.bind(this); + this.beforeFirstRender = this.beforeFirstRender.bind(this); + this.beforeRender = this.beforeRender.bind(this); + this.disableContextualWindow = this.disableContextualWindow.bind(this); + this.onTouchDeviceDetected = this.onTouchDeviceDetected.bind(this); + this.processAutoTouchEvents = this.processAutoTouchEvents.bind(this); /** * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`). * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example. diff --git a/src/lib/components/Keyboard.js b/src/lib/components/Keyboard.js index d769a1b5..0afbf1e8 100644 --- a/src/lib/components/Keyboard.js +++ b/src/lib/components/Keyboard.js @@ -79,7 +79,33 @@ class SimpleKeyboard { /** * Bindings */ - Utilities.bindMethods(SimpleKeyboard, this); + this.handleButtonClicked = this.handleButtonClicked.bind(this); + this.syncInstanceInputs = this.syncInstanceInputs.bind(this); + this.clearInput = this.clearInput.bind(this); + this.getInput = this.getInput.bind(this); + this.setInput = this.setInput.bind(this); + this.replaceInput = this.replaceInput.bind(this); + this.clear = this.clear.bind(this); + this.dispatch = this.dispatch.bind(this); + this.addButtonTheme = this.addButtonTheme.bind(this); + this.removeButtonTheme = this.removeButtonTheme.bind(this); + this.getButtonElement = this.getButtonElement.bind(this); + this.handleCaret = this.handleCaret.bind(this); + this.caretEventHandler = this.caretEventHandler.bind(this); + this.onInit = this.onInit.bind(this); + this.onRender = this.onRender.bind(this); + this.render = this.render.bind(this); + this.loadModules = this.loadModules.bind(this); + this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this); + this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this); + this.handleButtonHold = this.handleButtonHold.bind(this); + this.onModulesLoaded = this.onModulesLoaded.bind(this); + this.inputPatternIsValid = this.inputPatternIsValid.bind(this); + this.beforeFirstRender = this.beforeFirstRender.bind(this); + this.beforeRender = this.beforeRender.bind(this); + this.disableContextualWindow = this.disableContextualWindow.bind(this); + this.onTouchDeviceDetected = this.onTouchDeviceDetected.bind(this); + this.processAutoTouchEvents = this.processAutoTouchEvents.bind(this); /** * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`). @@ -647,7 +673,6 @@ class SimpleKeyboard { return buttonThemesParsed; } - /* istanbul ignore next */ onTouchDeviceDetected() { /** * Processing autoTouchEvents @@ -677,7 +702,6 @@ class SimpleKeyboard { /** * Process autoTouchEvents option */ - /* istanbul ignore next */ processAutoTouchEvents() { if (this.options.autoUseTouchEvents) { this.options.useTouchEvents = true; @@ -713,7 +737,6 @@ class SimpleKeyboard { /** * Performing actions when touch device detected */ - /* istanbul ignore next */ if (this.utilities.isTouchDevice()) { this.onTouchDeviceDetected(); } diff --git a/src/lib/components/tests/Keyboard.test.js b/src/lib/components/tests/Keyboard.test.js index 4c92cc5c..39b77b19 100644 --- a/src/lib/components/tests/Keyboard.test.js +++ b/src/lib/components/tests/Keyboard.test.js @@ -977,6 +977,31 @@ it('Keyboard inputPattern will work by input name', () => { expect(keyboard.getInput()).toBe("q1"); }); +it('Keyboard processAutoTouchEvents will work', () => { + testUtil.setDOM(); + + navigator.maxTouchPoints = true; + + let keyboard = new Keyboard({ + autoUseTouchEvents: true + }); + + expect(keyboard.options.useTouchEvents).toBeTruthy(); +}); + +it('Keyboard processAutoTouchEvents will work with debugging enabled', () => { + testUtil.setDOM(); + + navigator.maxTouchPoints = true; + + let keyboard = new Keyboard({ + autoUseTouchEvents: true, + debug: true + }); + + expect(keyboard.options.useTouchEvents).toBeTruthy(); +}); + it('Keyboard beforeFirstRender method will work', () => { testUtil.setDOM(); diff --git a/src/lib/services/Utilities.js b/src/lib/services/Utilities.js index b7ffad82..b9559a4e 100644 --- a/src/lib/services/Utilities.js +++ b/src/lib/services/Utilities.js @@ -14,7 +14,15 @@ class Utilities { /** * Bindings */ - Utilities.bindMethods(Utilities, this); + this.getButtonClass = this.getButtonClass.bind(this); + this.getButtonDisplayName = this.getButtonDisplayName.bind(this); + this.getUpdatedInput = this.getUpdatedInput.bind(this); + this.updateCaretPos = this.updateCaretPos.bind(this); + this.updateCaretPosAction = this.updateCaretPosAction.bind(this); + this.isMaxLengthReached = this.isMaxLengthReached.bind(this); + this.camelCase = this.camelCase.bind(this); + this.countInArray = this.countInArray.bind(this); + this.isTouchDevice = this.isTouchDevice.bind(this); } /** @@ -372,19 +380,6 @@ class Utilities { return "ontouchstart" in window || navigator.maxTouchPoints; } - /** - * Bind all methods in a given class - */ - static bindMethods(myClass, instance) { - for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) { - let excludeMethod = - myMethod === "constructor" || myMethod === "bindMethods"; - if (!excludeMethod) { - instance[myMethod] = instance[myMethod].bind(instance); - } - } - } - /** * Transforms an arbitrary string to camelCase *