diff --git a/build/css/index.css b/build/css/index.css index e0e44e0c..51103377 100644 --- a/build/css/index.css +++ b/build/css/index.css @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.24.3 + * simple-keyboard v2.25.0 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) diff --git a/build/css/index.css.map b/build/css/index.css.map index 7469e59d..f419b2c1 100644 --- a/build/css/index.css.map +++ b/build/css/index.css.map @@ -1 +1 @@ -{"version":3,"sources":["index.css","Keyboard.css"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE,CCVF,UAEE,QAAS,CACT,SACF,CAEA,iBACE,4GAC+C,CAC/C,UAAW,CACX,wBAAiB,CAAjB,qBAAiB,CAAjB,oBAAiB,CAAjB,gBAAiB,CACjB,qBAAsB,CACtB,eAAgB,CAChB,yBACF,CAEA,yBACE,YACF,CAEA,0CACE,iBACF,CAMA,mGACE,gBACF,CAEA,wCACE,cACF,CAEA,8CACE,YACF,CAEA,4BACE,oBAAqB,CACrB,WAAY,CACZ,cACF,CAEA,iCACE,mBACF,CAKA,kCACE,+BAAoC,CACpC,WAAY,CACZ,iBACF,CAEA,6CACE,sCAA+C,CAC/C,WAAY,CACZ,iBAAkB,CAClB,qBAAsB,CACtB,WAAY,CACZ,eAAiB,CACjB,+BAAgC,CAChC,cAAe,CACf,YAAa,CACb,kBAAmB,CACnB,sBACF,CAGA,kCACE,cAAe,CACf,SAAU,CACV,iBACF,CAEA,+DACE,WAAY,CACZ,WAAY,CACZ,kBAAmB,CACnB,YAAa,CACb,sBACF,CAMA,oIACE,WACF,CAEA,+DACE,WACF,CAEA,2DACE,cACF,CAEA,yEACE,cACF,CAEA,+DACE,4BAAiC,CACjC,UACF,CAEA,+EACE,cACF,CAEA,4EACE,cACF","file":"index.css","sourcesContent":["/*!\n * \n * simple-keyboard v2.24.3\n * https://github.com/hodgef/simple-keyboard\n * \n * Copyright (c) Francisco Hodge (https://github.com/hodgef)\n * \n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n * \n */\nbody,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n/* When using option \"useButtonTag\" */\r\n.simple-keyboard button.hg-button {\r\n border-width: 0;\r\n outline: 0;\r\n font-size: inherit;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button {\r\n width: 33.3%;\r\n height: 60px;\r\n align-items: center;\r\n display: flex;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n\n","body,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n/* When using option \"useButtonTag\" */\r\n.simple-keyboard button.hg-button {\r\n border-width: 0;\r\n outline: 0;\r\n font-size: inherit;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button {\r\n width: 33.3%;\r\n height: 60px;\r\n align-items: center;\r\n display: flex;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["index.css","Keyboard.css"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE,CCVF,UAEE,QAAS,CACT,SACF,CAEA,iBACE,4GAC+C,CAC/C,UAAW,CACX,wBAAiB,CAAjB,qBAAiB,CAAjB,oBAAiB,CAAjB,gBAAiB,CACjB,qBAAsB,CACtB,eAAgB,CAChB,yBACF,CAEA,yBACE,YACF,CAEA,0CACE,iBACF,CAMA,mGACE,gBACF,CAEA,wCACE,cACF,CAEA,8CACE,YACF,CAEA,4BACE,oBAAqB,CACrB,WAAY,CACZ,cACF,CAEA,iCACE,mBACF,CAKA,kCACE,+BAAoC,CACpC,WAAY,CACZ,iBACF,CAEA,6CACE,sCAA+C,CAC/C,WAAY,CACZ,iBAAkB,CAClB,qBAAsB,CACtB,WAAY,CACZ,eAAiB,CACjB,+BAAgC,CAChC,cAAe,CACf,YAAa,CACb,kBAAmB,CACnB,sBACF,CAGA,kCACE,cAAe,CACf,SAAU,CACV,iBACF,CAEA,+DACE,WAAY,CACZ,WAAY,CACZ,kBAAmB,CACnB,YAAa,CACb,sBACF,CAMA,oIACE,WACF,CAEA,+DACE,WACF,CAEA,2DACE,cACF,CAEA,yEACE,cACF,CAEA,+DACE,4BAAiC,CACjC,UACF,CAEA,+EACE,cACF,CAEA,4EACE,cACF","file":"index.css","sourcesContent":["/*!\n * \n * simple-keyboard v2.25.0\n * https://github.com/hodgef/simple-keyboard\n * \n * Copyright (c) Francisco Hodge (https://github.com/hodgef)\n * \n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n * \n */\nbody,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n/* When using option \"useButtonTag\" */\r\n.simple-keyboard button.hg-button {\r\n border-width: 0;\r\n outline: 0;\r\n font-size: inherit;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button {\r\n width: 33.3%;\r\n height: 60px;\r\n align-items: center;\r\n display: flex;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n\n","body,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n/* When using option \"useButtonTag\" */\r\n.simple-keyboard button.hg-button {\r\n border-width: 0;\r\n outline: 0;\r\n font-size: inherit;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button {\r\n width: 33.3%;\r\n height: 60px;\r\n align-items: center;\r\n display: flex;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n"]} \ No newline at end of file diff --git a/build/css/simple-keyboard.css b/build/css/simple-keyboard.css index 75842043..f4df7d05 100644 --- a/build/css/simple-keyboard.css +++ b/build/css/simple-keyboard.css @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.24.3 (Non-minified build) + * simple-keyboard v2.25.0 (Non-minified build) * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) diff --git a/build/index.d.ts b/build/index.d.ts index 7ce3c41e..69cacb0c 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -10,6 +10,12 @@ declare module 'simple-keyboard' { buttons: string; } + interface KeyboardButtonAttributes { + attribute: string; + value: string; + buttons: string; + } + interface KeyboardOptions { /** * Modify the keyboard layout. @@ -41,6 +47,11 @@ declare module 'simple-keyboard' { */ buttonTheme?: KeyboardButtonTheme[]; + /** + * A prop to add your own attributes to one or several buttons. + */ + buttonAttributes?: KeyboardButtonAttributes[]; + /** * Runs a `console.log` every time a key is pressed. Displays the buttons pressed and the current input. */ diff --git a/build/index.js b/build/index.js index 93f2c26c..4894a121 100644 --- a/build/index.js +++ b/build/index.js @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.24.3 + * simple-keyboard v2.25.0 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) @@ -9,5 +9,5 @@ * LICENSE file in the root directory of this source tree. * */ -!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define("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){return(o="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 i(t,e){for(var n=0;n0?s=this.removeAt(s,n,o):"{space}"===t?s=this.addStringAt(s," ",n,o):"{tab}"!==t||"boolean"===typeof i.tabCharOnTab&&!1===i.tabCharOnTab?"{enter}"!==t&&"{numpadenter}"!==t||!i.newLineOnEnter?t.includes("numpad")&&Number.isInteger(Number(t[t.length-2]))?s=this.addStringAt(s,t[t.length-2],n,o):"{numpaddivide}"===t?s=this.addStringAt(s,"/",n,o):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",n,o):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",n,o):"{numpadadd}"===t?s=this.addStringAt(s,"+",n,o):"{numpaddecimal}"===t?s=this.addStringAt(s,".",n,o):"{"===t||"}"===t?s=this.addStringAt(s,t,n,o):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,n,o)):s=this.addStringAt(s,"\n",n,o):s=this.addStringAt(s,"\t",n,o),s}},{key:"updateCaretPos",value:function(t,e){var n=this.updateCaretPosAction(t,e);this.dispatch(function(t){t.caretPosition=n})}},{key:"updateCaretPosAction",value:function(t,e){var n=this.getOptions(),o=this.getCaretPosition();return e?o>0&&(o-=t):o+=t,n.debug&&console.log("Caret at:",o,"(".concat(this.keyboardDOMClass,")")),o}},{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){var o;if(0===this.getCaretPosition())return t;var 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){var n=this.getOptions(),i=n.maxLength,s=t[n.inputName],a=s.length===i;if(e.length<=s.length)return!1;if(Number.isInteger(i))return n.debug&&console.log("maxLength (num) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===o(i)){var u=s.length===i[n.inputName];return n.debug&&console.log("maxLength (obj) reached:",u),u?(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:"pointerEventsSupported",value:function(){return window.PointerEvent}},{key:"camelCase",value:function(t){return!!t&&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)}}])&&i(e.prototype,n),s&&i(e,s),t}();function a(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}],(n=null)&&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 h(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:"setEventListeners",value:function(){!this.isFirstKeyboardInstance&&this.allKeyboardInstances||(this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")")),document.addEventListener("keyup",this.handleKeyUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("touchend",this.handleTouchEnd))}},{key:"handleKeyUp",value:function(t){this.caretEventHandler(t),this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyUp(t)}},{key:"handleKeyDown",value:function(t){this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyDown(t)}},{key:"handleMouseUp",value:function(t){this.caretEventHandler(t)}},{key:"handleTouchEnd",value:function(t){this.caretEventHandler(t)}},{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:"destroy",value:function(){document.removeEventListener("keyup",this.handleKeyUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("touchend",this.handleTouchEnd),this.clear()}},{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.setEventListeners(),"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(),this.isFirstKeyboardInstance&&this.utilities.pointerEventsSupported()&&!this.options.useTouchEvents&&!this.options.useMouseEvents&&this.options.debug&&console.log("Using PointerEvents as it is supported by this browser"),this.options.useTouchEvents&&this.options.debug&&console.log("useTouchEvents has been enabled. Only touch events will be used.")}},{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:"getModuleProp",value:function(t,e){return!!this.modules[t]&&this.modules[t][e]}},{key:"getModulesList",value:function(){return Object.keys(this.modules)}},{key:"parseRowDOMContainers",value:function(t,e,n,o){var i=this,s=Array.from(t.children),a=0;return s.length&&n.forEach(function(n,u){var r=o[u];if(!r||!(r>n))return!1;var c=n-a,l=r-a,h=document.createElement("div");h.className+="hg-button-container";var d="".concat(i.options.layoutName,"-r").concat(e,"c").concat(u);h.setAttribute("data-skUID",d);var p=s.splice(c,l-c+1);a=l-c,p.forEach(function(t){return h.appendChild(t)}),s.splice(c,0,h),t.innerHTML="",s.forEach(function(e){return t.appendChild(e)}),i.options.debug&&console.log("rowDOMContainer",p,c,l,a+1)}),t}},{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||c.getDefaultLayout(),o=this.options.useTouchEvents||!1,i=o?"hg-touch-events":"",s=this.options.useMouseEvents||!1,a=this.options.disableRowButtonContainers,u=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(" "),r=document.createElement("div");r.className+="hg-row";var c=[],l=[];i.forEach(function(e,i){var h=!a&&e.includes("[")&&e.length>1,d=!a&&e.includes("]")&&e.length>1;h&&(c.push(i),e=e.replace(/\[/g,"")),d&&(l.push(i),e=e.replace(/\]/g,""));var p=t.utilities.getButtonClass(e),f=u[e],y=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),m=t.options.useButtonTag?"button":"div",b=document.createElement(m);b.className+="hg-button ".concat(p).concat(f?" "+f:""),!t.utilities.pointerEventsSupported()||o||s?o?(b.ontouchstart=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.ontouchend=function(){return t.handleButtonMouseUp(e)},b.ontouchcancel=function(){return t.handleButtonMouseUp(e)}):(b.onclick=function(){t.isMouseHold=!1,t.handleButtonClicked(e)},b.onmousedown=function(n){return t.handleButtonMouseDown(e,n)},b.onmouseup=function(){return t.handleButtonMouseUp(e)}):(b.onpointerdown=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.onpointerup=function(){return t.handleButtonMouseUp(e)},b.onpointercancel=function(){return t.handleButtonMouseUp(e)}),b.setAttribute("data-skBtn",e);var g="".concat(t.options.layoutName,"-r").concat(n,"b").concat(i);b.setAttribute("data-skBtnUID",g),b.setAttribute("data-displayLabel",y);var v=document.createElement("span");v.innerHTML=y,b.appendChild(v),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(b),r.appendChild(b)}),r=t.parseRowDOMContainers(r,n,c,l),t.keyboardDOM.appendChild(r)}),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||o||s?o?(document.ontouchend=function(){return t.handleButtonMouseUp()},document.ontouchcancel=function(){return t.handleButtonMouseUp()}):o||(document.onmouseup=function(){return t.handleButtonMouseUp()}):document.onpointerup=function(){return t.handleButtonMouseUp()},this.onInit())}}])&&h(e.prototype,n),o&&h(e,o),t}();e.default=d}])}); +!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){return(o="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 i(t,e){for(var n=0;n0?s=this.removeAt(s,n,o):"{space}"===t?s=this.addStringAt(s," ",n,o):"{tab}"!==t||"boolean"===typeof i.tabCharOnTab&&!1===i.tabCharOnTab?"{enter}"!==t&&"{numpadenter}"!==t||!i.newLineOnEnter?t.includes("numpad")&&Number.isInteger(Number(t[t.length-2]))?s=this.addStringAt(s,t[t.length-2],n,o):"{numpaddivide}"===t?s=this.addStringAt(s,"/",n,o):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",n,o):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",n,o):"{numpadadd}"===t?s=this.addStringAt(s,"+",n,o):"{numpaddecimal}"===t?s=this.addStringAt(s,".",n,o):"{"===t||"}"===t?s=this.addStringAt(s,t,n,o):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,n,o)):s=this.addStringAt(s,"\n",n,o):s=this.addStringAt(s,"\t",n,o),s}},{key:"updateCaretPos",value:function(t,e){var n=this.updateCaretPosAction(t,e);this.dispatch(function(t){t.caretPosition=n})}},{key:"updateCaretPosAction",value:function(t,e){var n=this.getOptions(),o=this.getCaretPosition();return e?o>0&&(o-=t):o+=t,n.debug&&console.log("Caret at:",o,"(".concat(this.keyboardDOMClass,")")),o}},{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){var o;if(0===this.getCaretPosition())return t;var 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){var n=this.getOptions(),i=n.maxLength,s=t[n.inputName],a=s.length===i;if(e.length<=s.length)return!1;if(Number.isInteger(i))return n.debug&&console.log("maxLength (num) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===o(i)){var u=s.length===i[n.inputName];return n.debug&&console.log("maxLength (obj) reached:",u),u?(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:"pointerEventsSupported",value:function(){return window.PointerEvent}},{key:"camelCase",value:function(t){return!!t&&t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return e.length?t+e[0].toUpperCase()+e.slice(1):t})}}])&&i(e.prototype,n),s&&i(e,s),t}();function a(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}],(n=null)&&r(e.prototype,n),o&&r(e,o),t}();function l(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1?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:"setEventListeners",value:function(){!this.isFirstKeyboardInstance&&this.allKeyboardInstances||(this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")")),document.addEventListener("keyup",this.handleKeyUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("touchend",this.handleTouchEnd))}},{key:"handleKeyUp",value:function(t){this.caretEventHandler(t),this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyUp(t)}},{key:"handleKeyDown",value:function(t){this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyDown(t)}},{key:"handleMouseUp",value:function(t){this.caretEventHandler(t)}},{key:"handleTouchEnd",value:function(t){this.caretEventHandler(t)}},{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:"destroy",value:function(){document.removeEventListener("keyup",this.handleKeyUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("touchend",this.handleTouchEnd),this.clear()}},{key:"getButtonThemeClasses",value:function(t){var e=this.options.buttonTheme,n=[];return Array.isArray(e)&&e.forEach(function(e){if(e.class&&"string"===typeof e.class&&e.buttons&&"string"===typeof e.buttons){var o=e.class.split(" ");e.buttons.split(" ").includes(t)&&(n=[].concat(l(n),l(o)))}else console.warn('Incorrect "buttonTheme". Please check the documentation.',e)}),n}},{key:"setDOMButtonAttributes",value:function(t,e){var n=this.options.buttonAttributes;Array.isArray(n)&&n.forEach(function(n){n.attribute&&"string"===typeof n.attribute&&n.value&&"string"===typeof n.value&&n.buttons&&"string"===typeof n.buttons?n.buttons.split(" ").includes(t)&&e(n.attribute,n.value):console.warn('Incorrect "buttonAttributes". Please check the documentation.',n)})}},{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.setEventListeners(),"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(),this.isFirstKeyboardInstance&&this.utilities.pointerEventsSupported()&&!this.options.useTouchEvents&&!this.options.useMouseEvents&&this.options.debug&&console.log("Using PointerEvents as it is supported by this browser"),this.options.useTouchEvents&&this.options.debug&&console.log("useTouchEvents has been enabled. Only touch events will be used.")}},{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:"getModuleProp",value:function(t,e){return!!this.modules[t]&&this.modules[t][e]}},{key:"getModulesList",value:function(){return Object.keys(this.modules)}},{key:"parseRowDOMContainers",value:function(t,e,n,o){var i=this,s=Array.from(t.children),a=0;return s.length&&n.forEach(function(n,u){var r=o[u];if(!r||!(r>n))return!1;var c=n-a,l=r-a,h=document.createElement("div");h.className+="hg-button-container";var d="".concat(i.options.layoutName,"-r").concat(e,"c").concat(u);h.setAttribute("data-skUID",d);var p=s.splice(c,l-c+1);a=l-c,p.forEach(function(t){return h.appendChild(t)}),s.splice(c,0,h),t.innerHTML="",s.forEach(function(e){return t.appendChild(e)}),i.options.debug&&console.log("rowDOMContainer",p,c,l,a+1)}),t}},{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||c.getDefaultLayout(),o=this.options.useTouchEvents||!1,i=o?"hg-touch-events":"",s=this.options.useMouseEvents||!1,a=this.options.disableRowButtonContainers;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(" "),u=document.createElement("div");u.className+="hg-row";var r=[],c=[];i.forEach(function(e,i){var h,d=!a&&e.includes("[")&&e.length>1,p=!a&&e.includes("]")&&e.length>1;d&&(r.push(i),e=e.replace(/\[/g,"")),p&&(c.push(i),e=e.replace(/\]/g,""));var f=t.utilities.getButtonClass(e),y=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),m=t.options.useButtonTag?"button":"div",b=document.createElement(m);b.className+="hg-button ".concat(f),(h=b.classList).add.apply(h,l(t.getButtonThemeClasses(e))),t.setDOMButtonAttributes(e,function(t,e){b.setAttribute(t,e)}),!t.utilities.pointerEventsSupported()||o||s?o?(b.ontouchstart=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.ontouchend=function(){return t.handleButtonMouseUp(e)},b.ontouchcancel=function(){return t.handleButtonMouseUp(e)}):(b.onclick=function(){t.isMouseHold=!1,t.handleButtonClicked(e)},b.onmousedown=function(n){return t.handleButtonMouseDown(e,n)},b.onmouseup=function(){return t.handleButtonMouseUp(e)}):(b.onpointerdown=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.onpointerup=function(){return t.handleButtonMouseUp(e)},b.onpointercancel=function(){return t.handleButtonMouseUp(e)}),b.setAttribute("data-skBtn",e);var g="".concat(t.options.layoutName,"-r").concat(n,"b").concat(i);b.setAttribute("data-skBtnUID",g);var v=document.createElement("span");v.innerHTML=y,b.appendChild(v),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(b),u.appendChild(b)}),u=t.parseRowDOMContainers(u,n,r,c),t.keyboardDOM.appendChild(u)}),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||o||s?o?(document.ontouchend=function(){return t.handleButtonMouseUp()},document.ontouchcancel=function(){return t.handleButtonMouseUp()}):o||(document.onmouseup=function(){return t.handleButtonMouseUp()}):document.onpointerup=function(){return t.handleButtonMouseUp()},this.onInit())}}])&&d(e.prototype,n),o&&d(e,o),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 579d8af2..4fac4070 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/Utilities.js","services/PhysicalKeyboard.js","services/KeyboardLayout.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","Utilities","_ref","getOptions","getCaretPosition","dispatch","_classCallCheck","this","bindMethods","myClass","instance","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","getOwnPropertyNames","iterator","next","done","myMethod","err","return","button","buttonTypeClass","includes","buttonWithoutBraces","replace","buttonNormalized","concat","{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","options","output","length","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","Number","isInteger","minus","newCaretPos","updateCaretPosAction","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","PointerEvent","toLowerCase","trim","split","reduce","word","toUpperCase","array","x","PhysicalKeyboard","PhysicalKeyboard_classCallCheck","event","buttonPressed","getSimpleKeyboardLayoutKey","buttonDOM","getButtonElement","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","code","KeyboardLayout","default","shift","SimpleKeyboard","_this","Keyboard_classCallCheck","registerModule","initCallback","keyboardDOMQuery","arguments","Keyboard_typeof","utilities","keyboardDOM","document","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","buttonElements","camelCase","allKeyboardInstances","currentInstanceName","keyboardInstanceNames","keys","isFirstKeyboardInstance","physicalKeyboard","warn","Error","render","loadModules","onKeyPress","getUpdatedInput","inputPattern","inputPatternIsValid","handleMaxLength","syncInstanceInputs","onChange","onChangeAll","e","_this2","preventDefault","stopMouseDownPropagation","stopPropagation","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","disableButtonHold","setTimeout","handleButtonHold","onKeyReleased","_this3","handleButtonClicked","_this4","replaceInput","onSetOptions","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","addEventListener","handleKeyUp","handleKeyDown","handleMouseUp","handleTouchEnd","caretEventHandler","physicalKeyboardHighlight","handleHighlightKeyUp","handleHighlightKeyDown","targetTagName","target","tagName","disableCaretPositioning","selectionStart","removeEventListener","clear","_this7","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","countInArray","processAutoTouchEvents","disableContextualWindow","oncontextmenu","classList","contains","autoUseTouchEvents","useTouchEvents","setEventListeners","onInit","isTouchDevice","onTouchDeviceDetected","beforeFirstRender","pointerEventsSupported","useMouseEvents","beforeRender","onRender","onModulesLoaded","_this8","Module","constructor","classStr","init","prop","rowDOM","rowIndex","containerStartIndexes","containerEndIndexes","_this9","rowDOMArray","from","children","removedElements","startIndex","arrIndex","endIndex","updated_startIndex","updated_endIndex","containerDOM","createElement","containerUID","setAttribute","containedElements","element","appendChild","_this10","initialized","layoutClass","layout","getDefaultLayout","useTouchEventsClass","disableRowButtonContainers","getButtonTheme","row","rIndex","rowArray","bIndex","buttonHasContainerStart","buttonHasContainerEnd","fctBtnClass","getButtonClass","buttonThemeClass","buttonDisplayName","getButtonDisplayName","buttonType","useButtonTag","ontouchstart","handleButtonMouseDown","ontouchend","handleButtonMouseUp","ontouchcancel","onclick","onmousedown","onmouseup","onpointerdown","onpointerup","onpointercancel","buttonUID","buttonSpanDOM","parseRowDOMContainers"],"mappings":";;;;;;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,kBAAZC,SAA0C,kBAAXC,OACxCA,OAAOD,QAAUD,IACQ,oBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,iBAAkB,GAAIH,GACH,kBAAZC,QACdA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EAAOoB,YAAY/J,KAMrB2I,EAASqB,EAAKkC,sBACZvD,EACA8B,EACA5B,EACAC,GAMFkB,EAAK3I,YAAY0I,YAAYpB,KAM/B1R,KAAKkR,WAEAlR,KAAKgT,cAIRhT,KAAKgT,aAAc,GAOjBhT,KAAKmK,UAAU4G,0BACdN,GACAO,EAGQP,GAITpG,SAASiK,WAAa,kBAAMvB,EAAKwB,uBACjClK,SAASmK,cAAgB,kBAAMzB,EAAKwB,wBAC1B9D,IAIVpG,SAASsK,UAAY,kBAAM5B,EAAKwB,wBAXhClK,SAASwK,YAAc,kBAAM9B,EAAKwB,uBAiBpCvU,KAAK2Q,e,gCCpwCIhH","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 * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor({ getOptions, getCaretPosition, dispatch }) {\r\n this.getOptions = getOptions;\r\n this.getCaretPosition = getCaretPosition;\r\n this.dispatch = dispatch;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(Utilities, this);\r\n }\r\n\r\n /**\r\n * 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 {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, caretPos, moveCaret) {\r\n let options = this.getOptions();\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(length, minus);\r\n\r\n this.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(length, minus) {\r\n let options = this.getOptions();\r\n let caretPosition = this.getCaretPosition();\r\n\r\n if (minus) {\r\n if (caretPosition > 0) caretPosition = caretPosition - length;\r\n } else {\r\n caretPosition = caretPosition + length;\r\n }\r\n\r\n if (options.debug) {\r\n console.log(\"Caret at:\", caretPosition, `(${this.keyboardDOMClass})`);\r\n }\r\n\r\n return caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} 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 let caretPosition = this.getCaretPosition();\r\n\r\n if (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 {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, updatedInput) {\r\n let options = this.getOptions();\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 * Determines whether pointer events are supported\r\n */\r\n pointerEventsSupported() {\r\n return window.PointerEvent;\r\n }\r\n\r\n /**\r\n * Bind all methods in a given class\r\n */\r\n\r\n static bindMethods(myClass, instance) {\r\n for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {\r\n let excludeMethod =\r\n myMethod === \"constructor\" || myMethod === \"bindMethods\";\r\n if (!excludeMethod) {\r\n instance[myMethod] = instance[myMethod].bind(instance);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string) {\r\n if (!string) return false;\r\n\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 Utilities from \"../services/Utilities\";\r\n\r\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({ dispatch, getOptions }) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.dispatch = dispatch;\r\n this.getOptions = getOptions;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(PhysicalKeyboard, this);\r\n }\r\n\r\n handleHighlightKeyDown(event) {\r\n let options = this.getOptions();\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.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 options.physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n options.physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n\r\n handleHighlightKeyUp(event) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.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 * 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","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({\r\n getOptions: this.getOptions,\r\n getCaretPosition: this.getCaretPosition,\r\n dispatch: this.dispatch\r\n });\r\n\r\n /**\r\n * Caret position\r\n */\r\n this.caretPosition = null;\r\n\r\n /**\r\n * 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 * @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.\r\n * @property {function} destroy Clears keyboard listeners and DOM elements.\r\n * @property {boolean} disableButtonHold Disable button hold action.\r\n * @property {function} onKeyReleased Executes the callback function on key release.\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 * Simple-keyboard Instances\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if (!window[\"SimpleKeyboardInstances\"])\r\n window[\"SimpleKeyboardInstances\"] = {};\r\n\r\n window[\"SimpleKeyboardInstances\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Instance vars\r\n */\r\n this.allKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n this.currentInstanceName = this.utilities.camelCase(this.keyboardDOMClass);\r\n this.keyboardInstanceNames = Object.keys(window[\"SimpleKeyboardInstances\"]);\r\n this.isFirstKeyboardInstance =\r\n this.keyboardInstanceNames[0] === this.currentInstanceName;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboard = new PhysicalKeyboard({\r\n dispatch: this.dispatch,\r\n getOptions: this.getOptions\r\n });\r\n\r\n /**\r\n * 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 * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Getters\r\n */\r\n getOptions = () => this.options;\r\n getCaretPosition = () => this.caretPosition;\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.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, 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.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 * Calling onChangeAll\r\n */\r\n if (typeof this.options.onChangeAll === \"function\")\r\n this.options.onChangeAll(this.input);\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 * Handle event options\r\n */\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n if (this.options.stopMouseDownPropagation) e.stopPropagation();\r\n\r\n /**\r\n * @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 if (!this.options.disableButtonHold) {\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 /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp(button) {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * Calling onKeyReleased\r\n */\r\n if (button && typeof this.options.onKeyReleased === \"function\")\r\n this.options.onKeyReleased(button);\r\n }\r\n\r\n /**\r\n * Handles 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 instance.caretPosition = this.caretPosition;\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 * Reset caretPosition\r\n */\r\n this.caretPosition = 0;\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[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} options The options to set\r\n */\r\n setOptions(options) {\r\n options = options || {};\r\n this.options = Object.assign(this.options, options);\r\n\r\n /**\r\n * Some option changes require adjustments before re-render\r\n */\r\n this.onSetOptions(options);\r\n\r\n /**\r\n * Rendering\r\n */\r\n this.render();\r\n }\r\n\r\n /**\r\n * Executing actions depending on changed options\r\n * @param {object} options The options to set\r\n */\r\n onSetOptions(options) {\r\n if (options.inputName) {\r\n /**\r\n * inputName changed. This requires a caretPosition reset\r\n */\r\n if (this.options.debug) {\r\n console.log(\"inputName changed. caretPosition reset.\");\r\n }\r\n\r\n this.caretPosition = null;\r\n }\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 * Handles simple-keyboard event listeners\r\n */\r\n setEventListeners() {\r\n /**\r\n * Only first instance should set the event listeners\r\n */\r\n if (this.isFirstKeyboardInstance || !this.allKeyboardInstances) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\r\n }\r\n\r\n /**\r\n * Event Listeners\r\n */\r\n document.addEventListener(\"keyup\", this.handleKeyUp);\r\n document.addEventListener(\"keydown\", this.handleKeyDown);\r\n document.addEventListener(\"mouseup\", this.handleMouseUp);\r\n document.addEventListener(\"touchend\", this.handleTouchEnd);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: KeyUp\r\n */\r\n handleKeyUp(event) {\r\n this.caretEventHandler(event);\r\n\r\n if (this.options.physicalKeyboardHighlight) {\r\n this.physicalKeyboard.handleHighlightKeyUp(event);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: KeyDown\r\n */\r\n handleKeyDown(event) {\r\n if (this.options.physicalKeyboardHighlight) {\r\n this.physicalKeyboard.handleHighlightKeyDown(event);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: MouseUp\r\n */\r\n handleMouseUp(event) {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Event Handler: TouchEnd\r\n */\r\n handleTouchEnd(event) {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\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 * Destroy keyboard listeners and DOM elements\r\n */\r\n destroy() {\r\n /**\r\n * Remove listeners\r\n */\r\n document.removeEventListener(\"keyup\", this.handleKeyUp);\r\n document.removeEventListener(\"keydown\", this.handleKeyDown);\r\n document.removeEventListener(\"mouseup\", this.handleMouseUp);\r\n document.removeEventListener(\"touchend\", this.handleTouchEnd);\r\n\r\n /**\r\n * Clear DOM\r\n */\r\n this.clear();\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[\r\n themeButton\r\n ] = `${themeParsed} ${themeObj.class}`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(\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 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(\r\n `autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * setEventListeners\r\n */\r\n this.setEventListeners();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender() {\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if (this.utilities.isTouchDevice()) {\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\")\r\n this.options.beforeFirstRender();\r\n\r\n /**\r\n * Notify about PointerEvents usage\r\n */\r\n if (\r\n this.isFirstKeyboardInstance &&\r\n this.utilities.pointerEventsSupported() &&\r\n !this.options.useTouchEvents &&\r\n !this.options.useMouseEvents\r\n ) {\r\n if (this.options.debug) {\r\n console.log(\"Using PointerEvents as it is supported by this browser\");\r\n }\r\n }\r\n\r\n /**\r\n * Notify about touch events usage\r\n */\r\n if (this.options.useTouchEvents) {\r\n if (this.options.debug) {\r\n console.log(\r\n \"useTouchEvents has been enabled. Only touch events will be used.\"\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender() {\r\n if (typeof this.options.beforeRender === \"function\")\r\n this.options.beforeRender();\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 * Parse Row DOM containers\r\n */\r\n parseRowDOMContainers(\r\n rowDOM,\r\n rowIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n ) {\r\n let rowDOMArray = Array.from(rowDOM.children);\r\n let removedElements = 0;\r\n\r\n if (rowDOMArray.length) {\r\n containerStartIndexes.forEach((startIndex, arrIndex) => {\r\n let endIndex = containerEndIndexes[arrIndex];\r\n\r\n /**\r\n * If there exists a respective end index\r\n * if end index comes after start index\r\n */\r\n if (!endIndex || !(endIndex > startIndex)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * Updated startIndex, endIndex\r\n * This is since the removal of buttons to place a single button container\r\n * results in a modified array size\r\n */\r\n let updated_startIndex = startIndex - removedElements;\r\n let updated_endIndex = endIndex - removedElements;\r\n\r\n /**\r\n * Create button container\r\n */\r\n let containerDOM = document.createElement(\"div\");\r\n containerDOM.className += \"hg-button-container\";\r\n let containerUID = `${this.options.layoutName}-r${rowIndex}c${arrIndex}`;\r\n containerDOM.setAttribute(\"data-skUID\", containerUID);\r\n\r\n /**\r\n * Taking elements due to be inserted into container\r\n */\r\n let containedElements = rowDOMArray.splice(\r\n updated_startIndex,\r\n updated_endIndex - updated_startIndex + 1\r\n );\r\n removedElements = updated_endIndex - updated_startIndex;\r\n\r\n /**\r\n * Inserting elements to container\r\n */\r\n containedElements.forEach(element => containerDOM.appendChild(element));\r\n\r\n /**\r\n * Adding container at correct position within rowDOMArray\r\n */\r\n rowDOMArray.splice(updated_startIndex, 0, containerDOM);\r\n\r\n /**\r\n * Clearing old rowDOM children structure\r\n */\r\n rowDOM.innerHTML = \"\";\r\n\r\n /**\r\n * Appending rowDOM new children list\r\n */\r\n rowDOMArray.forEach(element => rowDOM.appendChild(element));\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n \"rowDOMContainer\",\r\n containedElements,\r\n updated_startIndex,\r\n updated_endIndex,\r\n removedElements + 1\r\n );\r\n }\r\n });\r\n }\r\n\r\n return rowDOM;\r\n }\r\n\r\n /**\r\n * 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 let useMouseEvents = this.options.useMouseEvents || false;\r\n let disableRowButtonContainers = this.options.disableRowButtonContainers;\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = Array.isArray(this.options.buttonTheme)\r\n ? this.getButtonTheme()\r\n : {};\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses} ${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 * Tracking container indicators in rows\r\n */\r\n let containerStartIndexes = [];\r\n let containerEndIndexes = [];\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n /**\r\n * Check if button has a container indicator\r\n */\r\n let buttonHasContainerStart =\r\n !disableRowButtonContainers &&\r\n button.includes(\"[\") &&\r\n button.length > 1;\r\n let buttonHasContainerEnd =\r\n !disableRowButtonContainers &&\r\n button.includes(\"]\") &&\r\n button.length > 1;\r\n\r\n /**\r\n * Save container start index, if applicable\r\n */\r\n if (buttonHasContainerStart) {\r\n containerStartIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\[/g, \"\");\r\n }\r\n\r\n if (buttonHasContainerEnd) {\r\n containerEndIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\]/g, \"\");\r\n }\r\n\r\n /**\r\n * Processing button options\r\n */\r\n 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 /**\r\n * Handle button click event\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n /**\r\n * Handle PointerEvents\r\n */\r\n buttonDOM.onpointerdown = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.onpointerup = () => this.handleButtonMouseUp(button);\r\n buttonDOM.onpointercancel = () => this.handleButtonMouseUp(button);\r\n } else {\r\n /**\r\n * Fallback for browsers not supporting PointerEvents\r\n */\r\n if (useTouchEvents) {\r\n /**\r\n * Handle touch events\r\n */\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = () => this.handleButtonMouseUp(button);\r\n buttonDOM.ontouchcancel = () => this.handleButtonMouseUp(button);\r\n } else {\r\n /**\r\n * Handle mouse events\r\n */\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => this.handleButtonMouseDown(button, e);\r\n buttonDOM.onmouseup = () => this.handleButtonMouseUp(button);\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 * Parse containers in row\r\n */\r\n rowDOM = this.parseRowDOMContainers(\r\n rowDOM,\r\n rIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n );\r\n\r\n /**\r\n * Appending row to 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 onpointerup\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n document.onpointerup = () => this.handleButtonMouseUp();\r\n } else if (useTouchEvents) {\r\n /**\r\n * Handling ontouchend, ontouchcancel\r\n */\r\n document.ontouchend = () => this.handleButtonMouseUp();\r\n document.ontouchcancel = () => this.handleButtonMouseUp();\r\n } else if (!useTouchEvents) {\r\n /**\r\n * Handling mouseup\r\n */\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/Utilities.js","services/PhysicalKeyboard.js","services/KeyboardLayout.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","Utilities","_ref","getOptions","getCaretPosition","dispatch","_classCallCheck","this","bindMethods","myClass","instance","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","getOwnPropertyNames","iterator","next","done","myMethod","err","return","button","buttonTypeClass","includes","buttonWithoutBraces","replace","buttonNormalized","concat","{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","options","output","length","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","Number","isInteger","minus","newCaretPos","updateCaretPosAction","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","PointerEvent","toLowerCase","trim","split","reduce","word","toUpperCase","PhysicalKeyboard","PhysicalKeyboard_classCallCheck","event","buttonPressed","getSimpleKeyboardLayoutKey","buttonDOM","getButtonElement","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","code","KeyboardLayout","default","shift","SimpleKeyboard","_this","Keyboard_classCallCheck","registerModule","initCallback","keyboardDOMQuery","arguments","Keyboard_typeof","utilities","keyboardDOM","document","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","buttonElements","camelCase","allKeyboardInstances","currentInstanceName","keyboardInstanceNames","keys","isFirstKeyboardInstance","physicalKeyboard","warn","Error","render","loadModules","onKeyPress","getUpdatedInput","inputPattern","inputPatternIsValid","handleMaxLength","syncInstanceInputs","onChange","onChangeAll","e","_this2","preventDefault","stopMouseDownPropagation","stopPropagation","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","disableButtonHold","setTimeout","handleButtonHold","onKeyReleased","_this3","handleButtonClicked","_this4","replaceInput","onSetOptions","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","addEventListener","handleKeyUp","handleKeyDown","handleMouseUp","handleTouchEnd","caretEventHandler","physicalKeyboardHighlight","handleHighlightKeyUp","handleHighlightKeyDown","targetTagName","target","tagName","disableCaretPositioning","selectionStart","removeEventListener","clear","buttonClasses","themeObj","themeObjClasses","_toConsumableArray","buttonAttributes","attrObj","attribute","processAutoTouchEvents","disableContextualWindow","oncontextmenu","classList","contains","autoUseTouchEvents","useTouchEvents","setEventListeners","onInit","isTouchDevice","onTouchDeviceDetected","beforeFirstRender","pointerEventsSupported","useMouseEvents","beforeRender","onRender","onModulesLoaded","_this7","Module","constructor","classStr","init","prop","rowDOM","rowIndex","containerStartIndexes","containerEndIndexes","_this8","rowDOMArray","from","children","removedElements","startIndex","arrIndex","endIndex","updated_startIndex","updated_endIndex","containerDOM","createElement","containerUID","setAttribute","containedElements","element","appendChild","_this9","initialized","layoutClass","layout","getDefaultLayout","useTouchEventsClass","disableRowButtonContainers","row","rIndex","rowArray","bIndex","_buttonDOM$classList","buttonHasContainerStart","buttonHasContainerEnd","fctBtnClass","getButtonClass","buttonDisplayName","getButtonDisplayName","buttonType","useButtonTag","add","apply","getButtonThemeClasses","setDOMButtonAttributes","ontouchstart","handleButtonMouseDown","ontouchend","handleButtonMouseUp","ontouchcancel","onclick","onmousedown","onmouseup","onpointerdown","onpointerup","onpointercancel","buttonUID","buttonSpanDOM","parseRowDOMContainers"],"mappings":";;;;;;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,kBAAZC,SAA0C,kBAAXC,OACxCA,OAAOD,QAAUD,IACQ,oBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,iBAAkB,GAAIH,GACH,kBAAZC,QACdA,QAAwB,eAAID,IAE5BD,EAAqB,eAAIC,IAR3B,CASGK,OAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,qBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,e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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 * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor({ getOptions, getCaretPosition, dispatch }) {\r\n this.getOptions = getOptions;\r\n this.getCaretPosition = getCaretPosition;\r\n this.dispatch = dispatch;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(Utilities, this);\r\n }\r\n\r\n /**\r\n * 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 {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, caretPos, moveCaret) {\r\n let options = this.getOptions();\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(length, minus);\r\n\r\n this.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(length, minus) {\r\n let options = this.getOptions();\r\n let caretPosition = this.getCaretPosition();\r\n\r\n if (minus) {\r\n if (caretPosition > 0) caretPosition = caretPosition - length;\r\n } else {\r\n caretPosition = caretPosition + length;\r\n }\r\n\r\n if (options.debug) {\r\n console.log(\"Caret at:\", caretPosition, `(${this.keyboardDOMClass})`);\r\n }\r\n\r\n return caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} 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 let caretPosition = this.getCaretPosition();\r\n\r\n if (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 {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, updatedInput) {\r\n let options = this.getOptions();\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 * Determines whether pointer events are supported\r\n */\r\n pointerEventsSupported() {\r\n return window.PointerEvent;\r\n }\r\n\r\n /**\r\n * Bind all methods in a given class\r\n */\r\n\r\n static bindMethods(myClass, instance) {\r\n for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {\r\n let excludeMethod =\r\n myMethod === \"constructor\" || myMethod === \"bindMethods\";\r\n if (!excludeMethod) {\r\n instance[myMethod] = instance[myMethod].bind(instance);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string) {\r\n if (!string) return false;\r\n\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\nexport default Utilities;\r\n","import Utilities from \"../services/Utilities\";\r\n\r\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({ dispatch, getOptions }) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.dispatch = dispatch;\r\n this.getOptions = getOptions;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(PhysicalKeyboard, this);\r\n }\r\n\r\n handleHighlightKeyDown(event) {\r\n let options = this.getOptions();\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.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 options.physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n options.physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n\r\n handleHighlightKeyUp(event) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.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 * 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","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({\r\n getOptions: this.getOptions,\r\n getCaretPosition: this.getCaretPosition,\r\n dispatch: this.dispatch\r\n });\r\n\r\n /**\r\n * Caret position\r\n */\r\n this.caretPosition = null;\r\n\r\n /**\r\n * 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 {Array} buttonAttributes A prop to add your own attributes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} 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 * @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.\r\n * @property {function} destroy Clears keyboard listeners and DOM elements.\r\n * @property {boolean} disableButtonHold Disable button hold action.\r\n * @property {function} onKeyReleased Executes the callback function on key release.\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 * Simple-keyboard Instances\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if (!window[\"SimpleKeyboardInstances\"])\r\n window[\"SimpleKeyboardInstances\"] = {};\r\n\r\n window[\"SimpleKeyboardInstances\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Instance vars\r\n */\r\n this.allKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n this.currentInstanceName = this.utilities.camelCase(this.keyboardDOMClass);\r\n this.keyboardInstanceNames = Object.keys(window[\"SimpleKeyboardInstances\"]);\r\n this.isFirstKeyboardInstance =\r\n this.keyboardInstanceNames[0] === this.currentInstanceName;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboard = new PhysicalKeyboard({\r\n dispatch: this.dispatch,\r\n getOptions: this.getOptions\r\n });\r\n\r\n /**\r\n * 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 * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Getters\r\n */\r\n getOptions = () => this.options;\r\n getCaretPosition = () => this.caretPosition;\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.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, 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.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 * Calling onChangeAll\r\n */\r\n if (typeof this.options.onChangeAll === \"function\")\r\n this.options.onChangeAll(this.input);\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 * Handle event options\r\n */\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n if (this.options.stopMouseDownPropagation) e.stopPropagation();\r\n\r\n /**\r\n * @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 if (!this.options.disableButtonHold) {\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 /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp(button) {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * Calling onKeyReleased\r\n */\r\n if (button && typeof this.options.onKeyReleased === \"function\")\r\n this.options.onKeyReleased(button);\r\n }\r\n\r\n /**\r\n * Handles 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 instance.caretPosition = this.caretPosition;\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 * Reset caretPosition\r\n */\r\n this.caretPosition = 0;\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[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} options The options to set\r\n */\r\n setOptions(options) {\r\n options = options || {};\r\n this.options = Object.assign(this.options, options);\r\n\r\n /**\r\n * Some option changes require adjustments before re-render\r\n */\r\n this.onSetOptions(options);\r\n\r\n /**\r\n * Rendering\r\n */\r\n this.render();\r\n }\r\n\r\n /**\r\n * Executing actions depending on changed options\r\n * @param {object} options The options to set\r\n */\r\n onSetOptions(options) {\r\n if (options.inputName) {\r\n /**\r\n * inputName changed. This requires a caretPosition reset\r\n */\r\n if (this.options.debug) {\r\n console.log(\"inputName changed. caretPosition reset.\");\r\n }\r\n\r\n this.caretPosition = null;\r\n }\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 * Handles simple-keyboard event listeners\r\n */\r\n setEventListeners() {\r\n /**\r\n * Only first instance should set the event listeners\r\n */\r\n if (this.isFirstKeyboardInstance || !this.allKeyboardInstances) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\r\n }\r\n\r\n /**\r\n * Event Listeners\r\n */\r\n document.addEventListener(\"keyup\", this.handleKeyUp);\r\n document.addEventListener(\"keydown\", this.handleKeyDown);\r\n document.addEventListener(\"mouseup\", this.handleMouseUp);\r\n document.addEventListener(\"touchend\", this.handleTouchEnd);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: KeyUp\r\n */\r\n handleKeyUp(event) {\r\n this.caretEventHandler(event);\r\n\r\n if (this.options.physicalKeyboardHighlight) {\r\n this.physicalKeyboard.handleHighlightKeyUp(event);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: KeyDown\r\n */\r\n handleKeyDown(event) {\r\n if (this.options.physicalKeyboardHighlight) {\r\n this.physicalKeyboard.handleHighlightKeyDown(event);\r\n }\r\n }\r\n\r\n /**\r\n * Event Handler: MouseUp\r\n */\r\n handleMouseUp(event) {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Event Handler: TouchEnd\r\n */\r\n handleTouchEnd(event) {\r\n this.caretEventHandler(event);\r\n }\r\n\r\n /**\r\n * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\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 * Destroy keyboard listeners and DOM elements\r\n */\r\n destroy() {\r\n /**\r\n * Remove listeners\r\n */\r\n document.removeEventListener(\"keyup\", this.handleKeyUp);\r\n document.removeEventListener(\"keydown\", this.handleKeyDown);\r\n document.removeEventListener(\"mouseup\", this.handleMouseUp);\r\n document.removeEventListener(\"touchend\", this.handleTouchEnd);\r\n\r\n /**\r\n * Clear DOM\r\n */\r\n this.clear();\r\n }\r\n\r\n /**\r\n * Process buttonTheme option\r\n */\r\n getButtonThemeClasses(button) {\r\n let buttonTheme = this.options.buttonTheme;\r\n let buttonClasses = [];\r\n\r\n if (Array.isArray(buttonTheme)) {\r\n buttonTheme.forEach(themeObj => {\r\n if (\r\n themeObj.class &&\r\n typeof themeObj.class === \"string\" &&\r\n (themeObj.buttons && typeof themeObj.buttons === \"string\")\r\n ) {\r\n let themeObjClasses = themeObj.class.split(\" \");\r\n let themeObjButtons = themeObj.buttons.split(\" \");\r\n\r\n if (themeObjButtons.includes(button)) {\r\n buttonClasses = [...buttonClasses, ...themeObjClasses];\r\n }\r\n } else {\r\n console.warn(\r\n `Incorrect \"buttonTheme\". Please check the documentation.`,\r\n themeObj\r\n );\r\n }\r\n });\r\n }\r\n\r\n return buttonClasses;\r\n }\r\n\r\n /**\r\n * Process buttonAttributes option\r\n */\r\n setDOMButtonAttributes(button, callback) {\r\n let buttonAttributes = this.options.buttonAttributes;\r\n\r\n if (Array.isArray(buttonAttributes)) {\r\n buttonAttributes.forEach(attrObj => {\r\n if (\r\n attrObj.attribute &&\r\n typeof attrObj.attribute === \"string\" &&\r\n (attrObj.value && typeof attrObj.value === \"string\") &&\r\n (attrObj.buttons && typeof attrObj.buttons === \"string\")\r\n ) {\r\n let attrObjButtons = attrObj.buttons.split(\" \");\r\n\r\n if (attrObjButtons.includes(button)) {\r\n callback(attrObj.attribute, attrObj.value);\r\n }\r\n } else {\r\n console.warn(\r\n `Incorrect \"buttonAttributes\". Please check the documentation.`,\r\n attrObj\r\n );\r\n }\r\n });\r\n }\r\n }\r\n\r\n onTouchDeviceDetected() {\r\n /**\r\n * Processing autoTouchEvents\r\n */\r\n this.processAutoTouchEvents();\r\n\r\n /**\r\n * Disabling contextual window on touch devices\r\n */\r\n this.disableContextualWindow();\r\n }\r\n\r\n /**\r\n * Disabling contextual window for hg-button\r\n */\r\n /* istanbul ignore next */\r\n disableContextualWindow() {\r\n window.oncontextmenu = event => {\r\n if (event.target.classList.contains(\"hg-button\")) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return false;\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Process autoTouchEvents option\r\n */\r\n processAutoTouchEvents() {\r\n if (this.options.autoUseTouchEvents) {\r\n this.options.useTouchEvents = true;\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * setEventListeners\r\n */\r\n this.setEventListeners();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender() {\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if (this.utilities.isTouchDevice()) {\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\")\r\n this.options.beforeFirstRender();\r\n\r\n /**\r\n * Notify about PointerEvents usage\r\n */\r\n if (\r\n this.isFirstKeyboardInstance &&\r\n this.utilities.pointerEventsSupported() &&\r\n !this.options.useTouchEvents &&\r\n !this.options.useMouseEvents\r\n ) {\r\n if (this.options.debug) {\r\n console.log(\"Using PointerEvents as it is supported by this browser\");\r\n }\r\n }\r\n\r\n /**\r\n * Notify about touch events usage\r\n */\r\n if (this.options.useTouchEvents) {\r\n if (this.options.debug) {\r\n console.log(\r\n \"useTouchEvents has been enabled. Only touch events will be used.\"\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender() {\r\n if (typeof this.options.beforeRender === \"function\")\r\n this.options.beforeRender();\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 * Parse Row DOM containers\r\n */\r\n parseRowDOMContainers(\r\n rowDOM,\r\n rowIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n ) {\r\n let rowDOMArray = Array.from(rowDOM.children);\r\n let removedElements = 0;\r\n\r\n if (rowDOMArray.length) {\r\n containerStartIndexes.forEach((startIndex, arrIndex) => {\r\n let endIndex = containerEndIndexes[arrIndex];\r\n\r\n /**\r\n * If there exists a respective end index\r\n * if end index comes after start index\r\n */\r\n if (!endIndex || !(endIndex > startIndex)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * Updated startIndex, endIndex\r\n * This is since the removal of buttons to place a single button container\r\n * results in a modified array size\r\n */\r\n let updated_startIndex = startIndex - removedElements;\r\n let updated_endIndex = endIndex - removedElements;\r\n\r\n /**\r\n * Create button container\r\n */\r\n let containerDOM = document.createElement(\"div\");\r\n containerDOM.className += \"hg-button-container\";\r\n let containerUID = `${this.options.layoutName}-r${rowIndex}c${arrIndex}`;\r\n containerDOM.setAttribute(\"data-skUID\", containerUID);\r\n\r\n /**\r\n * Taking elements due to be inserted into container\r\n */\r\n let containedElements = rowDOMArray.splice(\r\n updated_startIndex,\r\n updated_endIndex - updated_startIndex + 1\r\n );\r\n removedElements = updated_endIndex - updated_startIndex;\r\n\r\n /**\r\n * Inserting elements to container\r\n */\r\n containedElements.forEach(element => containerDOM.appendChild(element));\r\n\r\n /**\r\n * Adding container at correct position within rowDOMArray\r\n */\r\n rowDOMArray.splice(updated_startIndex, 0, containerDOM);\r\n\r\n /**\r\n * Clearing old rowDOM children structure\r\n */\r\n rowDOM.innerHTML = \"\";\r\n\r\n /**\r\n * Appending rowDOM new children list\r\n */\r\n rowDOMArray.forEach(element => rowDOM.appendChild(element));\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n \"rowDOMContainer\",\r\n containedElements,\r\n updated_startIndex,\r\n updated_endIndex,\r\n removedElements + 1\r\n );\r\n }\r\n });\r\n }\r\n\r\n return rowDOM;\r\n }\r\n\r\n /**\r\n * 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 let useMouseEvents = this.options.useMouseEvents || false;\r\n let disableRowButtonContainers = this.options.disableRowButtonContainers;\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 * Tracking container indicators in rows\r\n */\r\n let containerStartIndexes = [];\r\n let containerEndIndexes = [];\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n /**\r\n * Check if button has a container indicator\r\n */\r\n let buttonHasContainerStart =\r\n !disableRowButtonContainers &&\r\n button.includes(\"[\") &&\r\n button.length > 1;\r\n let buttonHasContainerEnd =\r\n !disableRowButtonContainers &&\r\n button.includes(\"]\") &&\r\n button.length > 1;\r\n\r\n /**\r\n * Save container start index, if applicable\r\n */\r\n if (buttonHasContainerStart) {\r\n containerStartIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\[/g, \"\");\r\n }\r\n\r\n if (buttonHasContainerEnd) {\r\n containerEndIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\]/g, \"\");\r\n }\r\n\r\n /**\r\n * Processing button options\r\n */\r\n let fctBtnClass = this.utilities.getButtonClass(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\r\n /**\r\n * Adding buttonTheme\r\n */\r\n buttonDOM.classList.add(...this.getButtonThemeClasses(button));\r\n\r\n /**\r\n * Adding buttonAttributes\r\n */\r\n this.setDOMButtonAttributes(button, (attribute, value) => {\r\n buttonDOM.setAttribute(attribute, value);\r\n });\r\n\r\n /**\r\n * Handle button click event\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n /**\r\n * Handle PointerEvents\r\n */\r\n buttonDOM.onpointerdown = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.onpointerup = () => this.handleButtonMouseUp(button);\r\n buttonDOM.onpointercancel = () => this.handleButtonMouseUp(button);\r\n } else {\r\n /**\r\n * Fallback for browsers not supporting PointerEvents\r\n */\r\n if (useTouchEvents) {\r\n /**\r\n * Handle touch events\r\n */\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = () => this.handleButtonMouseUp(button);\r\n buttonDOM.ontouchcancel = () => this.handleButtonMouseUp(button);\r\n } else {\r\n /**\r\n * Handle mouse events\r\n */\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => this.handleButtonMouseDown(button, e);\r\n buttonDOM.onmouseup = () => this.handleButtonMouseUp(button);\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 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 * Parse containers in row\r\n */\r\n rowDOM = this.parseRowDOMContainers(\r\n rowDOM,\r\n rIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n );\r\n\r\n /**\r\n * Appending row to 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 onpointerup\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n document.onpointerup = () => this.handleButtonMouseUp();\r\n } else if (useTouchEvents) {\r\n /**\r\n * Handling ontouchend, ontouchcancel\r\n */\r\n document.ontouchend = () => this.handleButtonMouseUp();\r\n document.ontouchcancel = () => this.handleButtonMouseUp();\r\n } else if (!useTouchEvents) {\r\n /**\r\n * Handling mouseup\r\n */\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 e5cc68f9..0eca257e 100644 --- a/build/simple-keyboard.js +++ b/build/simple-keyboard.js @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.24.3 (Non-minified build) + * simple-keyboard v2.25.0 (Non-minified build) * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) @@ -537,18 +537,6 @@ return word.length ? string + word[0].toUpperCase() + word.slice(1) : string; }); } - /** - * Counts the number of duplicates in a given array - * - * @param {Array} array The haystack to search in - * @param {string} value The needle to search for - */ }, { - key: "countInArray", - value: function countInArray(array, value) { - return array.reduce(function(n, x) { - return n + (x === value); - }, 0); - } } ], [ { key: "bindMethods", value: function bindMethods(myClass, instance) { @@ -719,7 +707,26 @@ }(); /* harmony default export */ var services_KeyboardLayout = KeyboardLayout; // CONCATENATED MODULE: ./src/lib/components/Keyboard.js - function Keyboard_typeof(obj) { + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); + } + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); + } + function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") { + return Array.from(iter); + } + } + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + return arr2; + } + } + function Keyboard_typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { Keyboard_typeof = function _typeof(obj) { return typeof obj; @@ -808,6 +815,7 @@ * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead. * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space. * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons. + * @property {Array} buttonAttributes A prop to add your own attributes to one or several buttons. * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input. * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\n) or not. * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\t) or not. @@ -1373,35 +1381,43 @@ /** * Process buttonTheme option */ }, { - key: "getButtonTheme", - value: function getButtonTheme() { - var _this7 = this; - var buttonThemesParsed = {}; - this.options.buttonTheme.forEach(function(themeObj) { - if (themeObj.buttons && themeObj.class) { - var themeButtons; - if (typeof themeObj.buttons === "string") { - themeButtons = themeObj.buttons.split(" "); + key: "getButtonThemeClasses", + value: function getButtonThemeClasses(button) { + var buttonTheme = this.options.buttonTheme; + var buttonClasses = []; + if (Array.isArray(buttonTheme)) { + buttonTheme.forEach(function(themeObj) { + if (themeObj.class && typeof themeObj.class === "string" && themeObj.buttons && typeof themeObj.buttons === "string") { + var themeObjClasses = themeObj.class.split(" "); + var themeObjButtons = themeObj.buttons.split(" "); + if (themeObjButtons.includes(button)) { + buttonClasses = [].concat(_toConsumableArray(buttonClasses), _toConsumableArray(themeObjClasses)); + } + } else { + console.warn('Incorrect "buttonTheme". Please check the documentation.', themeObj); } - if (themeButtons) { - themeButtons.forEach(function(themeButton) { - var themeParsed = buttonThemesParsed[themeButton]; - // If the button has already been added - if (themeParsed) { - // Making sure we don't add duplicate classes, even when buttonTheme has duplicates - if (!_this7.utilities.countInArray(themeParsed.split(" "), themeObj.class)) { - buttonThemesParsed[themeButton] = "".concat(themeParsed, " ").concat(themeObj.class); - } - } else { - buttonThemesParsed[themeButton] = themeObj.class; - } - }); + }); + } + return buttonClasses; + } + /** + * Process buttonAttributes option + */ }, { + key: "setDOMButtonAttributes", + value: function setDOMButtonAttributes(button, callback) { + var buttonAttributes = this.options.buttonAttributes; + if (Array.isArray(buttonAttributes)) { + buttonAttributes.forEach(function(attrObj) { + if (attrObj.attribute && typeof attrObj.attribute === "string" && attrObj.value && typeof attrObj.value === "string" && attrObj.buttons && typeof attrObj.buttons === "string") { + var attrObjButtons = attrObj.buttons.split(" "); + if (attrObjButtons.includes(button)) { + callback(attrObj.attribute, attrObj.value); + } + } else { + console.warn('Incorrect "buttonAttributes". Please check the documentation.', attrObj); } - } else { - console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.'); - } - }); - return buttonThemesParsed; + }); + } } }, { key: "onTouchDeviceDetected", @@ -1515,15 +1531,15 @@ /** * Load modules */ value: function loadModules() { - var _this8 = this; + var _this7 = this; if (Array.isArray(this.options.modules)) { this.options.modules.forEach(function(Module) { var module = new Module(); /* istanbul ignore next */ if (module.constructor.name && module.constructor.name !== "Function") { - var classStr = "module-".concat(_this8.utilities.camelCase(module.constructor.name)); - _this8.keyboardPluginClasses = _this8.keyboardPluginClasses + " ".concat(classStr); + var classStr = "module-".concat(_this7.utilities.camelCase(module.constructor.name)); + _this7.keyboardPluginClasses = _this7.keyboardPluginClasses + " ".concat(classStr); } - module.init(_this8); + module.init(_this7); }); this.keyboardPluginClasses = this.keyboardPluginClasses + " modules-loaded"; this.render(); @@ -1552,7 +1568,7 @@ */ }, { key: "parseRowDOMContainers", value: function parseRowDOMContainers(rowDOM, rowIndex, containerStartIndexes, containerEndIndexes) { - var _this9 = this; + var _this8 = this; var rowDOMArray = Array.from(rowDOM.children); var removedElements = 0; if (rowDOMArray.length) { @@ -1574,7 +1590,7 @@ * Create button container */ var containerDOM = document.createElement("div"); containerDOM.className += "hg-button-container"; - var containerUID = "".concat(_this9.options.layoutName, "-r").concat(rowIndex, "c").concat(arrIndex); + var containerUID = "".concat(_this8.options.layoutName, "-r").concat(rowIndex, "c").concat(arrIndex); containerDOM.setAttribute("data-skUID", containerUID); /** * Taking elements due to be inserted into container @@ -1596,7 +1612,7 @@ */ rowDOMArray.forEach(function(element) { return rowDOM.appendChild(element); }); - if (_this9.options.debug) { + if (_this8.options.debug) { console.log("rowDOMContainer", containedElements, updated_startIndex, updated_endIndex, removedElements + 1); } }); @@ -1608,7 +1624,7 @@ */ }, { key: "render", value: function render() { - var _this10 = this; + var _this9 = this; /** * Clear keyboard */ this.clear(); @@ -1627,9 +1643,6 @@ var useMouseEvents = this.options.useMouseEvents || false; var disableRowButtonContainers = this.options.disableRowButtonContainers; /** - * Account for buttonTheme, if set - */ var buttonThemesParsed = Array.isArray(this.options.buttonTheme) ? this.getButtonTheme() : {}; - /** * Adding themeClass, layoutClass to keyboardDOM */ this.keyboardDOM.className += " ".concat(this.options.theme, " ").concat(layoutClass, " ").concat(this.keyboardPluginClasses, " ").concat(useTouchEventsClass); /** @@ -1647,9 +1660,10 @@ /** * Iterating through each button in row */ rowArray.forEach(function(button, bIndex) { + var _buttonDOM$classList; /** * Check if button has a container indicator - */ var buttonHasContainerStart = !disableRowButtonContainers && button.includes("[") && button.length > 1; + */ var buttonHasContainerStart = !disableRowButtonContainers && button.includes("[") && button.length > 1; var buttonHasContainerEnd = !disableRowButtonContainers && button.includes("]") && button.length > 1; /** * Save container start index, if applicable @@ -1667,28 +1681,38 @@ } /** * Processing button options - */ var fctBtnClass = _this10.utilities.getButtonClass(button); - var buttonThemeClass = buttonThemesParsed[button]; - var buttonDisplayName = _this10.utilities.getButtonDisplayName(button, _this10.options.display, _this10.options.mergeDisplay); + */ var fctBtnClass = _this9.utilities.getButtonClass(button); + var buttonDisplayName = _this9.utilities.getButtonDisplayName(button, _this9.options.display, _this9.options.mergeDisplay); /** * Creating button - */ var buttonType = _this10.options.useButtonTag ? "button" : "div"; + */ var buttonType = _this9.options.useButtonTag ? "button" : "div"; var buttonDOM = document.createElement(buttonType); - buttonDOM.className += "hg-button ".concat(fctBtnClass).concat(buttonThemeClass ? " " + buttonThemeClass : ""); + buttonDOM.className += "hg-button ".concat(fctBtnClass); + /** + * Adding buttonTheme + */ + /** + * Adding buttonTheme + */ (_buttonDOM$classList = buttonDOM.classList).add.apply(_buttonDOM$classList, _toConsumableArray(_this9.getButtonThemeClasses(button))); + /** + * Adding buttonAttributes + */ _this9.setDOMButtonAttributes(button, function(attribute, value) { + buttonDOM.setAttribute(attribute, value); + }); /** * Handle button click event - */ /* istanbul ignore next */ if (_this10.utilities.pointerEventsSupported() && !useTouchEvents && !useMouseEvents) { + */ /* istanbul ignore next */ if (_this9.utilities.pointerEventsSupported() && !useTouchEvents && !useMouseEvents) { /** * Handle PointerEvents */ buttonDOM.onpointerdown = function(e) { - _this10.handleButtonClicked(button); - _this10.handleButtonMouseDown(button, e); + _this9.handleButtonClicked(button); + _this9.handleButtonMouseDown(button, e); }; buttonDOM.onpointerup = function() { - return _this10.handleButtonMouseUp(button); + return _this9.handleButtonMouseUp(button); }; buttonDOM.onpointercancel = function() { - return _this10.handleButtonMouseUp(button); + return _this9.handleButtonMouseUp(button); }; } else { /** @@ -1697,27 +1721,27 @@ /** * Handle touch events */ buttonDOM.ontouchstart = function(e) { - _this10.handleButtonClicked(button); - _this10.handleButtonMouseDown(button, e); + _this9.handleButtonClicked(button); + _this9.handleButtonMouseDown(button, e); }; buttonDOM.ontouchend = function() { - return _this10.handleButtonMouseUp(button); + return _this9.handleButtonMouseUp(button); }; buttonDOM.ontouchcancel = function() { - return _this10.handleButtonMouseUp(button); + return _this9.handleButtonMouseUp(button); }; } else { /** * Handle mouse events */ buttonDOM.onclick = function() { - _this10.isMouseHold = false; - _this10.handleButtonClicked(button); + _this9.isMouseHold = false; + _this9.handleButtonClicked(button); }; buttonDOM.onmousedown = function(e) { - return _this10.handleButtonMouseDown(button, e); + return _this9.handleButtonMouseDown(button, e); }; buttonDOM.onmouseup = function() { - return _this10.handleButtonMouseUp(button); + return _this9.handleButtonMouseUp(button); }; } } @@ -1727,32 +1751,29 @@ /** * Adding unique id * Since there's no limit on spawning same buttons, the unique id ensures you can style every button - */ var buttonUID = "".concat(_this10.options.layoutName, "-r").concat(rIndex, "b").concat(bIndex); + */ var buttonUID = "".concat(_this9.options.layoutName, "-r").concat(rIndex, "b").concat(bIndex); buttonDOM.setAttribute("data-skBtnUID", buttonUID); /** - * Adding display label - */ buttonDOM.setAttribute("data-displayLabel", buttonDisplayName); - /** * Adding button label to button */ var buttonSpanDOM = document.createElement("span"); buttonSpanDOM.innerHTML = buttonDisplayName; buttonDOM.appendChild(buttonSpanDOM); /** * Adding to buttonElements - */ if (!_this10.buttonElements[button]) { - _this10.buttonElements[button] = []; + */ if (!_this9.buttonElements[button]) { + _this9.buttonElements[button] = []; } - _this10.buttonElements[button].push(buttonDOM); + _this9.buttonElements[button].push(buttonDOM); /** * Appending button to row */ rowDOM.appendChild(buttonDOM); }); /** * Parse containers in row - */ rowDOM = _this10.parseRowDOMContainers(rowDOM, rIndex, containerStartIndexes, containerEndIndexes); + */ rowDOM = _this9.parseRowDOMContainers(rowDOM, rIndex, containerStartIndexes, containerEndIndexes); /** * Appending row to keyboard - */ _this10.keyboardDOM.appendChild(rowDOM); + */ _this9.keyboardDOM.appendChild(rowDOM); }); /** * Calling onRender @@ -1765,22 +1786,22 @@ * Handling onpointerup */ /* istanbul ignore next */ if (this.utilities.pointerEventsSupported() && !useTouchEvents && !useMouseEvents) { document.onpointerup = function() { - return _this10.handleButtonMouseUp(); + return _this9.handleButtonMouseUp(); }; } else if (useTouchEvents) { /** * Handling ontouchend, ontouchcancel */ document.ontouchend = function() { - return _this10.handleButtonMouseUp(); + return _this9.handleButtonMouseUp(); }; document.ontouchcancel = function() { - return _this10.handleButtonMouseUp(); + return _this9.handleButtonMouseUp(); }; } else if (!useTouchEvents) { /** * Handling mouseup */ document.onmouseup = function() { - return _this10.handleButtonMouseUp(); + return _this9.handleButtonMouseUp(); }; } /**