diff --git a/build/css/index.css b/build/css/index.css index 265d6052..8f435e59 100644 --- a/build/css/index.css +++ b/build/css/index.css @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.14.3 + * simple-keyboard v2.15.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 2363c116..c2083512 100644 --- a/build/css/index.css.map +++ b/build/css/index.css.map @@ -1 +1 @@ -{"version":3,"sources":["index.css","X:/Dev/simple-keyboard/src/lib/components/X:/Dev/simple-keyboard/src/lib/components/Keyboard.css"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG,ACVH,UACE,SAAU,AACV,SAAW,CACZ,AAED,iBACE,6GAA4H,AAC5H,WAAY,AACZ,yBAAkB,AAAlB,sBAAkB,AAAlB,qBAAkB,AAAlB,iBAAkB,AAClB,sBAAuB,AACvB,gBAAiB,AACjB,yBAA2B,CAC5B,AAED,yBACE,YAAc,CACf,AAED,0CACE,iBAAmB,CACpB,AAED,qDACE,gBAAkB,CACnB,AAED,4BACE,qBAAsB,AACtB,YAAa,AACb,cAAgB,CACjB,AAED,gBACE,eAAiB,CAClB,AAKD,kCACE,gCAAkC,AAClC,YAAa,AACb,iBAAmB,CACnB,AAEF,6CACE,uCAA6C,AAC7C,YAAa,AACb,kBAAmB,AACnB,sBAAuB,AACvB,YAAa,AACb,gBAAkB,AAClB,gCAAiC,AACjC,eAAgB,AAChB,aAAc,AACd,mBAAoB,AACpB,sBAAwB,CACxB,AAGD,kCACC,eAAgB,AAChB,UAAW,AACX,iBAAmB,CACpB,AAEA,oDACC,kBAAoB,CACpB,AAEF,+DACE,YAAa,AACb,YAAa,AACb,mBAAoB,AACpB,aAAc,AACd,sBAAwB,CACzB,AAMD,oIACE,WAAa,CACd,AAED,+DACE,WAAa,CACd,AAED,2DACE,cAAgB,CACjB,AAED,yEACE,cAAgB,CACjB,AAED,+DACE,6BAAkC,AAClC,UAAa,CACd,AAED,+EACE,cAAgB,CACjB,AAED,4EACE,cAAgB,CDejB","file":"index.css","sourcesContent":["/*!\n * \n * simple-keyboard v2.14.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 a dual license system (MIT or GPL-3.0), as found in the\n * LICENSE file in the root directory of this source tree.\n * \n */\nbody, html {\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\", 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-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.hg-standardBtn {\r\n max-width: 100px;\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-button:active {\r\n background: #e4e4e4;\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}\n","body, html {\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\", 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-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.hg-standardBtn {\r\n max-width: 100px;\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-button:active {\r\n background: #e4e4e4;\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}"]} \ No newline at end of file +{"version":3,"sources":["index.css","X:/Dev/simple-keyboard/src/lib/components/X:/Dev/simple-keyboard/src/lib/components/Keyboard.css"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG,ACVH,UAEE,SAAU,AACV,SAAW,CACZ,AAED,iBACE,6GACgD,AAChD,WAAY,AACZ,yBAAkB,AAAlB,sBAAkB,AAAlB,qBAAkB,AAAlB,iBAAkB,AAClB,sBAAuB,AACvB,gBAAiB,AACjB,yBAA2B,CAC5B,AAED,yBACE,YAAc,CACf,AAED,0CACE,iBAAmB,CACpB,AAED,qDACE,gBAAkB,CACnB,AAED,4BACE,qBAAsB,AACtB,YAAa,AACb,cAAgB,CACjB,AAED,gBACE,eAAiB,CAClB,AAKD,kCACE,gCAAqC,AACrC,YAAa,AACb,iBAAmB,CACpB,AAED,6CACE,uCAAgD,AAChD,YAAa,AACb,kBAAmB,AACnB,sBAAuB,AACvB,YAAa,AACb,gBAAkB,AAClB,gCAAiC,AACjC,eAAgB,AAChB,aAAc,AACd,mBAAoB,AACpB,sBAAwB,CACzB,AAGD,kCACE,eAAgB,AAChB,UAAW,AACX,iBAAmB,CACpB,AAED,oDACE,kBAAoB,CACrB,AAED,+DACE,YAAa,AACb,YAAa,AACb,mBAAoB,AACpB,aAAc,AACd,sBAAwB,CACzB,AAMD,oIACE,WAAa,CACd,AAED,+DACE,WAAa,CACd,AAED,2DACE,cAAgB,CACjB,AAED,yEACE,cAAgB,CACjB,AAED,+DACE,6BAAkC,AAClC,UAAa,CACd,AAED,+EACE,cAAgB,CACjB,AAED,4EACE,cAAgB,CACjB","file":"index.css","sourcesContent":["/*!\n * \n * simple-keyboard v2.15.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 a dual license system (MIT or GPL-3.0), as 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-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.hg-standardBtn {\r\n max-width: 100px;\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-button:active {\r\n background: #e4e4e4;\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-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.hg-standardBtn {\r\n max-width: 100px;\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-button:active {\r\n background: #e4e4e4;\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 new file mode 100644 index 00000000..8ae44b09 --- /dev/null +++ b/build/css/simple-keyboard.css @@ -0,0 +1,127 @@ +/*! + * + * simple-keyboard v2.15.0 (Non-minified build) + * https://github.com/hodgef/simple-keyboard + * + * Copyright (c) Francisco Hodge (https://github.com/hodgef) + * + * This source code is licensed under a dual license system (MIT or GPL-3.0), as found in the + * LICENSE file in the root directory of this source tree. + * + */ +body, +html { + margin: 0; + padding: 0; +} + +.simple-keyboard { + font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", + Helvetica, Arial, "Lucida Grande", sans-serif; + width: 100%; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + box-sizing: border-box; + overflow: hidden; + touch-action: manipulation; +} + +.simple-keyboard .hg-row { + display: flex; +} + +.simple-keyboard .hg-row:not(:last-child) { + margin-bottom: 5px; +} + +.simple-keyboard .hg-row .hg-button:not(:last-child) { + margin-right: 5px; +} + +.simple-keyboard .hg-button { + display: inline-block; + flex-grow: 1; + cursor: pointer; +} + +.hg-standardBtn { + max-width: 100px; +} + +/** + * hg-theme-default theme + */ +.simple-keyboard.hg-theme-default { + background-color: rgba(0, 0, 0, 0.1); + padding: 5px; + border-radius: 5px; +} + +.simple-keyboard.hg-theme-default .hg-button { + box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3); + height: 40px; + border-radius: 5px; + box-sizing: border-box; + padding: 5px; + background: white; + border-bottom: 1px solid #b5b5b5; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; +} + +/* When using option "useButtonTag" */ +.simple-keyboard button.hg-button { + border-width: 0; + outline: 0; + font-size: inherit; +} + +.simple-keyboard.hg-theme-default .hg-button:active { + background: #e4e4e4; +} + +.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button { + width: 33.3%; + height: 60px; + align-items: center; + display: flex; + justify-content: center; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd { + height: 85px; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter { + height: 85px; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 { + width: 105px; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-button-com { + max-width: 85px; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at { + max-width: 45px; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton { + background: rgba(5, 25, 70, 0.53); + color: white; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"] { + max-width: 82px; +} + +.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"] { + max-width: 60px; +} + diff --git a/build/index.js b/build/index.js index a7ee8adf..8fd23df2 100644 --- a/build/index.js +++ b/build/index.js @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.14.3 + * simple-keyboard v2.15.0 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) diff --git a/build/index.js.map b/build/index.js.map index 2288f208..afc39ed7 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","getButtonClass","getButtonDisplayName","getUpdatedInput","updateCaretPos","updateCaretPosAction","isMaxLengthReached","camelCase","countInArray","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","newCaretPos","syncInstanceInputs","caretPosition","debug","console","log","keyboardDOMClass","source","string","position","slice","join","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","_defineProperty","option","render","initCallback","prop","keys","keyboardDOMQuery","arguments","undefined","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","handleButtonClicked","clearInput","getInput","setInput","replaceInput","clear","addButtonTheme","removeButtonTheme","handleCaret","caretEventHandler","onInit","onRender","loadModules","handleButtonMouseUp","handleButtonMouseDown","handleButtonHold","onModulesLoaded","inputPatternIsValid","buttonElements","warn","Error","physicalKeyboardInterface","onKeyPress","inputPattern","handleMaxLength","onChange","e","_this2","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","_this3","_this4","innerHTML","className","callback","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","inputVal","inputPatternRaw","RegExp","didInputMatch","test","simpleKeyboardInstances","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","Module","constructor","classStr","init","_this8","layoutClass","layout","getDefaultLayout","useTouchEvents","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","buttonThemeClass","buttonDisplayName","buttonType","useButtonTag","ontouchstart","ontouchend","ontouchcancel","onclick","onmousedown","preventDefault","setAttribute","buttonUID","buttonSpanDOM","appendChild","initialized","onmouseup"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAA,kBAAAC,OACAA,OAAAD,QAAAD,IACA,oBAAAG,eAAAC,IACAD,OAAA,oBAAAH,GACA,kBAAAC,QACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAQ,GAAA,EAGAR,EAAAD,QA0DA,OArDAM,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAAtB,GACA,qBAAAuB,eAAAC,aACAN,OAAAC,eAAAnB,EAAAuB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAnB,EAAA,cAAiDyB,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GADA,EA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QwJ,KAOvCtL,EAAUgQ,aAAa,aAAclO,GAMrC,IAAImO,EAAS,GAAA/P,OAAMmO,EAAK1O,QAAQ6J,WAAnB,MAAAtJ,OAAkC8O,EAAlC,KAAA9O,OAA4CkP,GACzDpP,EAAUgQ,aAAa,gBAAiBC,GAKxCjQ,EAAUgQ,aAAa,oBAAqBT,GAK5C,IAAIW,EAAgB1Q,SAAS2P,cAAc,QAC3Ce,EAAcnE,UAAYwD,EAC1BvP,EAAUmQ,YAAYD,GAKlB7B,EAAKvD,eAAehJ,KACtBuM,EAAKvD,eAAehJ,GAAU,IAEhCuM,EAAKvD,eAAehJ,GAAQ6K,KAAK3M,GAKjCkP,EAAOiB,YAAYnQ,KAOrBqO,EAAK/E,YAAY6G,YAAYjB,KAM/B9P,KAAKmL,WAEDnL,KAAKgR,cAIPhR,KAAKgR,aAAc,EAKd3B,IACHjP,SAAS6Q,UAAY,kBAAMhC,EAAK5D,wBAMlCrL,KAAKkL,+CC71BI7B","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance){\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(this);\r\n\r\n /**\r\n * Initialize key listeners\r\n */\r\n this.initKeyboardListener();\r\n }\r\n\r\n /**\r\n * Initializes key event listeners\r\n */\r\n initKeyboardListener(){\r\n // Adding button style on keydown\r\n document.addEventListener(\"keydown\", (event) => {\r\n if(this.simpleKeyboardInstance.options.physicalKeyboardHighlight){\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM = instance.getButtonElement(buttonPressed) || instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if(buttonDOM){\r\n buttonDOM.style.backgroundColor = this.simpleKeyboardInstance.options.physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color = this.simpleKeyboardInstance.options.physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n });\r\n\r\n // Removing button style on keyup\r\n document.addEventListener(\"keyup\", (event) => {\r\n if(this.simpleKeyboardInstance.options.physicalKeyboardHighlight){\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM = instance.getButtonElement(buttonPressed) || instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if(buttonDOM && buttonDOM.removeAttribute){\r\n buttonDOM.removeAttribute(\"style\");\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Transforms a KeyboardEvent's \"key.code\" string into a simple-keyboard layout format\r\n * @param {object} event The KeyboardEvent\r\n */\r\n getSimpleKeyboardLayoutKey(event){\r\n let output;\r\n\r\n if(\r\n event.code.includes(\"Numpad\") ||\r\n event.code.includes(\"Shift\") ||\r\n event.code.includes(\"Space\") ||\r\n event.code.includes(\"Backspace\") ||\r\n event.code.includes(\"Control\") ||\r\n event.code.includes(\"Alt\") ||\r\n event.code.includes(\"Meta\")\r\n ){\r\n output = event.code;\r\n } else {\r\n output = event.key;\r\n }\r\n\r\n /**\r\n * If button is not uppercase, casting to lowercase\r\n */\r\n if (\r\n output !== output.toUpperCase() ||\r\n (event.code[0] === \"F\" && Number.isInteger(Number(event.code[1])) && event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout(){\r\n return {\r\n 'default': [\r\n '` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',\r\n '{tab} q w e r t y u i o p [ ] \\\\',\r\n '{lock} a s d f g h j k l ; \\' {enter}',\r\n '{shift} z x c v b n m , . / {shift}',\r\n '.com @ {space}'\r\n ],\r\n 'shift': [\r\n '~ ! @ # $ % ^ & * ( ) _ + {bksp}',\r\n '{tab} Q W E R T Y U I O P { } |',\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n '{shift} Z X C V B N M < > ? {shift}',\r\n '.com @ {space}'\r\n ]\r\n } \r\n }\r\n}\r\n\r\nexport default KeyboardLayout;","/**\r\n * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor(simpleKeyboardInstance){\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.getButtonClass = this.getButtonClass.bind(this);\r\n this.getButtonDisplayName = this.getButtonDisplayName.bind(this);\r\n this.getUpdatedInput = this.getUpdatedInput.bind(this);\r\n this.updateCaretPos = this.updateCaretPos.bind(this);\r\n this.updateCaretPosAction = this.updateCaretPosAction.bind(this);\r\n this.isMaxLengthReached = this.isMaxLengthReached.bind(this);\r\n this.camelCase = this.camelCase.bind(this);\r\n this.countInArray = this.countInArray.bind(this);\r\n }\r\n\r\n /**\r\n * Adds default classes to a given button\r\n * \r\n * @param {string} button The button's layout name\r\n * @return {string} The classes to be added to the button\r\n */\r\n getButtonClass(button){\r\n let buttonTypeClass = (button.includes(\"{\") && button.includes(\"}\") && button !== '{//}') ? \"functionBtn\" : \"standardBtn\";\r\n let buttonWithoutBraces = button.replace(\"{\", \"\").replace(\"}\", \"\");\r\n let buttonNormalized = '';\r\n\r\n if(buttonTypeClass !== \"standardBtn\")\r\n buttonNormalized = ` hg-button-${buttonWithoutBraces}`;\r\n\r\n return `hg-${buttonTypeClass}${buttonNormalized}`;\r\n }\r\n\r\n /**\r\n * Default button display labels\r\n */\r\n getDefaultDiplay(){\r\n return {\r\n '{bksp}': 'backspace',\r\n '{backspace}': 'backspace',\r\n '{enter}': '< enter',\r\n '{shift}': 'shift',\r\n '{shiftleft}': 'shift',\r\n '{shiftright}': 'shift',\r\n '{alt}': 'alt',\r\n '{s}': 'shift',\r\n '{tab}': 'tab',\r\n '{lock}': 'caps',\r\n '{capslock}': 'caps',\r\n '{accept}': 'Submit',\r\n '{space}': ' ',\r\n '{//}': ' ',\r\n \"{esc}\": \"esc\",\r\n \"{escape}\": \"esc\",\r\n \"{f1}\": \"f1\",\r\n \"{f2}\": \"f2\",\r\n \"{f3}\": \"f3\",\r\n \"{f4}\": \"f4\",\r\n \"{f5}\": \"f5\",\r\n \"{f6}\": \"f6\",\r\n \"{f7}\": \"f7\",\r\n \"{f8}\": \"f8\",\r\n \"{f9}\": \"f9\",\r\n \"{f10}\": \"f10\",\r\n \"{f11}\": \"f11\",\r\n \"{f12}\": \"f12\",\r\n '{numpaddivide}': '/',\r\n '{numlock}': 'lock',\r\n \"{arrowup}\": \"↑\",\r\n \"{arrowleft}\": \"←\",\r\n \"{arrowdown}\": \"↓\",\r\n \"{arrowright}\": \"→\",\r\n \"{prtscr}\": \"print\",\r\n \"{scrolllock}\": \"scroll\",\r\n \"{pause}\": \"pause\",\r\n \"{insert}\": \"ins\",\r\n \"{home}\": \"home\",\r\n \"{pageup}\": \"up\",\r\n \"{delete}\": \"del\",\r\n \"{end}\": \"end\",\r\n \"{pagedown}\": \"down\",\r\n \"{numpadmultiply}\": \"*\",\r\n \"{numpadsubtract}\": \"-\",\r\n \"{numpadadd}\": \"+\",\r\n \"{numpadenter}\": \"enter\",\r\n \"{period}\": \".\",\r\n \"{numpaddecimal}\": \".\",\r\n \"{numpad0}\": \"0\",\r\n \"{numpad1}\": \"1\",\r\n \"{numpad2}\": \"2\",\r\n \"{numpad3}\": \"3\",\r\n \"{numpad4}\": \"4\",\r\n \"{numpad5}\": \"5\",\r\n \"{numpad6}\": \"6\",\r\n \"{numpad7}\": \"7\",\r\n \"{numpad8}\": \"8\",\r\n \"{numpad9}\": \"9\",\r\n };\r\n }\r\n /**\r\n * Returns the display (label) name for a given button\r\n * \r\n * @param {string} button The button's layout name\r\n * @param {object} display The provided display option\r\n * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.\r\n */\r\n getButtonDisplayName(button, display, mergeDisplay){\r\n if(mergeDisplay){\r\n display = Object.assign({}, this.getDefaultDiplay(), display);\r\n } else {\r\n display = display || this.getDefaultDiplay();\r\n }\r\n\r\n return display[button] || button;\r\n }\r\n\r\n \r\n /**\r\n * Returns the updated input resulting from clicking a given button\r\n * \r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret){\r\n \r\n let output = input;\r\n\r\n if((button === \"{bksp}\" || button === \"{backspace}\") && output.length > 0){\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n\r\n } else if(button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n\r\n else if(button === \"{tab}\" && !(typeof options.tabCharOnTab === \"boolean\" && options.tabCharOnTab === false)){\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n\r\n } else if((button === \"{enter}\" || button === \"{numpadenter}\") && options.newLineOnEnter)\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n\r\n else if(button.includes(\"numpad\") && Number.isInteger(Number(button[button.length - 2]))){\r\n output = this.addStringAt(output, button[button.length - 2], caretPos, moveCaret);\r\n }\r\n else if(button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, '/', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, '*', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, '-', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpadadd}\")\r\n output = this.addStringAt(output, '+', caretPos, moveCaret);\r\n\r\n else if(button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, '.', caretPos, moveCaret);\r\n\r\n else if(button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n else if(!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n * \r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus){\r\n let newCaretPos = this.updateCaretPosAction(this.simpleKeyboardInstance, length, minus);\r\n\r\n if(this.simpleKeyboardInstance.options.syncInstanceInputs){\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n * \r\n * @param {object} instance The instance whose position should be updated\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(instance, length, minus){\r\n if(minus){\r\n if(instance.caretPosition > 0)\r\n instance.caretPosition = instance.caretPosition - length;\r\n } else {\r\n instance.caretPosition = instance.caretPosition + length;\r\n }\r\n\r\n if(this.simpleKeyboardInstance.options.debug){\r\n console.log(\"Caret at:\", instance.caretPosition, `(${instance.keyboardDOMClass})`);\r\n }\r\n\r\n return instance.caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n * \r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret){\r\n let output;\r\n\r\n if(!position && position !== 0){\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join('');\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if(!this.isMaxLengthReached()){\r\n if(moveCaret) this.updateCaretPos(string.length);\r\n }\r\n\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n * \r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret){\r\n if(this.simpleKeyboardInstance.caretPosition === 0){\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if(position && position >= 0){\r\n prevTwoChars = source.substring(position - 2, position)\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if(emojiMatched){\r\n output = source.substr(0, (position - 2)) + source.substr(position);\r\n if(moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, (position - 1)) + source.substr(position);\r\n if(moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if(emojiMatched){\r\n output = source.slice(0, -2);\r\n if(moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if(moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n * \r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput){\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if(\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ){\r\n return false;\r\n }\r\n\r\n if(Number.isInteger(maxLength)){\r\n if(options.debug){\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if(condition){\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if(typeof maxLength === \"object\"){\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if(options.debug){\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if(condition){\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached(){\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n * \r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string){\r\n return string\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce(\r\n (string, word) =>\r\n word.length ? string + word[0].toUpperCase() + word.slice(1) : string\r\n );\r\n };\r\n\r\n /**\r\n * Counts the number of duplicates in a given array\r\n * \r\n * @param {Array} array The haystack to search in\r\n * @param {string} value The needle to search for\r\n */\r\n countInArray(array, value){\r\n return array.reduce((n, x) => n + (x === value), 0);\r\n }\r\n}\r\n\r\nexport default Utilities;\r\n","import './Keyboard.css';\r\n\r\n// Services\r\nimport PhysicalKeyboard from '../services/PhysicalKeyboard';\r\nimport KeyboardLayout from '../services/KeyboardLayout';\r\nimport Utilities from '../services/Utilities';\r\n\r\n/**\r\n * Root class for simple-keyboard\r\n * This class:\r\n * - Parses the options\r\n * - Renders the rows and buttons\r\n * - Handles button functionality\r\n */\r\nclass SimpleKeyboard {\r\n /**\r\n * Creates an instance of SimpleKeyboard\r\n * @param {Array} params If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.\r\n */\r\n constructor(...params){\r\n let keyboardDOMQuery = typeof params[0] === \"string\" ? params[0] : \".simple-keyboard\";\r\n let options = typeof params[0] === \"object\" ? params[0] : params[1];\r\n\r\n if(!options)\r\n options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n * @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 */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault = this.options.preventMouseDownDefault || false;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = '';\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.handleButtonClicked = this.handleButtonClicked.bind(this);\r\n this.syncInstanceInputs = this.syncInstanceInputs.bind(this);\r\n this.clearInput = this.clearInput.bind(this);\r\n this.getInput = this.getInput.bind(this);\r\n this.setInput = this.setInput.bind(this);\r\n this.replaceInput = this.replaceInput.bind(this);\r\n this.clear = this.clear.bind(this);\r\n this.dispatch = this.dispatch.bind(this);\r\n this.addButtonTheme = this.addButtonTheme.bind(this);\r\n this.removeButtonTheme = this.removeButtonTheme.bind(this);\r\n this.getButtonElement = this.getButtonElement.bind(this);\r\n this.handleCaret = this.handleCaret.bind(this);\r\n this.caretEventHandler = this.caretEventHandler.bind(this);\r\n this.onInit = this.onInit.bind(this);\r\n this.onRender = this.onRender.bind(this);\r\n this.render = this.render.bind(this);\r\n this.loadModules = this.loadModules.bind(this);\r\n this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this);\r\n this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this);\r\n this.handleButtonHold = this.handleButtonHold.bind(this);\r\n this.onModulesLoaded = this.onModulesLoaded.bind(this);\r\n this.inputPatternIsValid = this.inputPatternIsValid.bind(this);\r\n\r\n /**\r\n * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).\r\n * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.\r\n * @example\r\n * // To get entered input\r\n * let input = keyboard.getInput();\r\n * \r\n * // To clear entered input.\r\n * keyboard.clearInput();\r\n * \r\n * @type {object}\r\n * @property {object} default Default SimpleKeyboard internal input.\r\n * @property {object} myInputName Example input that can be set through `options.inputName:\"myInputName\"`.\r\n */\r\n this.input = {};\r\n this.input[this.options.inputName] = '';\r\n\r\n /**\r\n * @type {string} DOM class of the keyboard wrapper, normally \"simple-keyboard\" by default.\r\n */\r\n this.keyboardDOMClass = keyboardDOMQuery.split('.').join(\"\");\r\n\r\n /**\r\n * @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: \"{enter}\").\r\n */\r\n this.buttonElements = {};\r\n\r\n /**\r\n * Rendering keyboard\r\n */\r\n if(this.keyboardDOM)\r\n this.render();\r\n else {\r\n console.warn(`\"${keyboardDOMQuery}\" was not found in the DOM.`);\r\n throw new Error(\"KEYBOARD_DOM_ERROR\");\r\n }\r\n\r\n /**\r\n * Saving instance\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if(!window['SimpleKeyboardInstances'])\r\n window['SimpleKeyboardInstances'] = {};\r\n \r\n window['SimpleKeyboardInstances'][this.utilities.camelCase(this.keyboardDOMClass)] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button){\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if(button === '{//}')\r\n return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if(typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n \r\n if(!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = '';\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button, this.input[this.options.inputName], this.options, this.caretPosition\r\n );\r\n\r\n if(\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 (\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\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if(this.options.maxLength && this.utilities.handleMaxLength(this.input, this.options, updatedInput)){\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button, this.input[this.options.inputName], this.options, this.caretPosition, true\r\n );\r\n\r\n if(debug)\r\n console.log('Input changed:', this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if(typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n }\r\n \r\n if(debug){\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e){\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if(this.holdInteractionTimeout)\r\n clearTimeout(this.holdInteractionTimeout);\r\n\r\n if(this.holdTimeout)\r\n clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if(\r\n this.isMouseHold &&\r\n (\r\n (!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\"\r\n )\r\n ){\r\n if(this.options.debug)\r\n console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp(){\r\n this.isMouseHold = false;\r\n if(this.holdInteractionTimeout)\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button){\r\n if(this.holdInteractionTimeout)\r\n clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if(this.isMouseHold){\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs(){\r\n this.dispatch((instance) => {\r\n instance.replaceInput(this.input);\r\n });\r\n }\r\n \r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName){\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = '';\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Get the keyboard’s input (You can also get it from the onChange prop).\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n getInput(inputName){\r\n inputName = inputName || this.options.inputName;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n\r\n return this.input[this.options.inputName];\r\n }\r\n\r\n /**\r\n * Set the keyboard’s input.\r\n * @param {string} input the input value\r\n * @param {string} inputName optional - the internal input to select\r\n */\r\n setInput(input, inputName){\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = input;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if(this.options.syncInstanceInputs)\r\n this.syncInstanceInputs(this.input);\r\n }\r\n \r\n /**\r\n * Replace the input object (`keyboard.input`)\r\n * @param {object} inputObj The input object\r\n */\r\n replaceInput(inputObj){\r\n this.input = inputObj;\r\n }\r\n\r\n /**\r\n * Set new option or modify existing ones after initialization. \r\n * @param {object} option The option to set\r\n */\r\n setOptions = option => {\r\n option = option || {};\r\n this.options = Object.assign(this.options, option);\r\n this.render();\r\n }\r\n\r\n /**\r\n * Remove all keyboard rows and reset keyboard values.\r\n * Used interally between re-renders.\r\n */\r\n clear(){\r\n this.keyboardDOM.innerHTML = '';\r\n this.keyboardDOM.className = this.keyboardDOMClass;\r\n this.buttonElements = {};\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances at once (if you have multiple instances).\r\n * @param {function(instance: object, key: string)} callback Function to run on every instance\r\n */\r\n dispatch(callback){\r\n if(!window['SimpleKeyboardInstances']){\r\n console.warn(`SimpleKeyboardInstances is not defined. Dispatch cannot be called.`);\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n \r\n return Object.keys(window['SimpleKeyboardInstances']).forEach((key) => {\r\n callback(window['SimpleKeyboardInstances'][key], key);\r\n })\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className){\r\n if(!className || !buttons)\r\n return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if(!this.options.buttonTheme)\r\n this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n \r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n\r\n if(buttonTheme.class.split(\" \").includes(classNameItem)){\r\n classNameFound = true;\r\n \r\n let buttonThemeArray = buttonTheme.buttons.split(\" \");\r\n if(!buttonThemeArray.includes(button)){\r\n classNameFound = true;\r\n buttonThemeArray.push(button);\r\n buttonTheme.buttons = buttonThemeArray.join(\" \");\r\n }\r\n }\r\n return buttonTheme;\r\n });\r\n\r\n /**\r\n * If class is not defined, we create a new entry\r\n */\r\n if(!classNameFound){\r\n this.options.buttonTheme.push({\r\n class: classNameItem,\r\n buttons: buttons\r\n });\r\n }\r\n\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n\r\n /**\r\n * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n removeButtonTheme(buttons, className){\r\n /**\r\n * When called with empty parameters, remove all button themes\r\n */\r\n if(!buttons && !className){\r\n this.options.buttonTheme = [];\r\n this.render();\r\n return false;\r\n }\r\n\r\n /**\r\n * If buttons are passed and buttonTheme has items\r\n */\r\n if(buttons && Array.isArray(this.options.buttonTheme) && this.options.buttonTheme.length){\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if(\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ){\r\n let filteredButtonArray = buttonTheme.buttons.split(\" \").filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if(filteredButtonArray.length){\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n \r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(button){\r\n let output;\r\n\r\n let buttonArr = this.buttonElements[button];\r\n if(buttonArr){\r\n if(buttonArr.length > 1){\r\n output = buttonArr;\r\n } else {\r\n output = buttonArr[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * 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(`inputPattern (\"${inputPattern}\"): ${didInputMatch ? \"passed\" : \"did not pass!\"}`);\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret(){\r\n /**\r\n * Only first instance should insall the caret handling events\r\n */\r\n this.caretPosition = null;\r\n let simpleKeyboardInstances = window['SimpleKeyboardInstances'];\r\n\r\n if(\r\n (\r\n simpleKeyboardInstances &&\r\n Object.keys(simpleKeyboardInstances)[0] === this.utilities.camelCase(this.keyboardDOMClass)\r\n ) ||\r\n !simpleKeyboardInstances\r\n ){\r\n if(this.options.debug){\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`)\r\n }\r\n\r\n document.addEventListener(\"keyup\", this.caretEventHandler);\r\n document.addEventListener(\"mouseup\", this.caretEventHandler);\r\n document.addEventListener(\"touchend\", this.caretEventHandler);\r\n }\r\n }\r\n\r\n /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event){\r\n let targetTagName;\r\n if(event.target.tagName){\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch(instance => {\r\n if(instance.isMouseHold){\r\n instance.isMouseHold = false;\r\n }\r\n\r\n if(\r\n (targetTagName === \"textarea\" ||\r\n 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(\"Caret at: \", event.target.selectionStart, event.target.tagName.toLowerCase(), `(${instance.keyboardDOMClass})`);\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 * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit(){\r\n if(this.options.debug){\r\n console.log(`${this.keyboardDOMClass} Initialized`)\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if(typeof this.options.onInit === \"function\")\r\n this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n */\r\n onRender(){\r\n if(typeof this.options.onRender === \"function\")\r\n this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded(){\r\n if(typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if(!this.modules[name])\r\n this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n }\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules(){\r\n if(Array.isArray(this.options.modules)){\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if(module.constructor.name && module.constructor.name !== \"Function\"){\r\n let classStr = `module-${this.utilities.camelCase(module.constructor.name)}`;\r\n this.keyboardPluginClasses = this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses = this.keyboardPluginClasses + \" modules-loaded\";\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp = (name, prop) => {\r\n if(!this.modules[name])\r\n return false;\r\n \r\n return this.modules[name][prop];\r\n }\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList = () => {\r\n return Object.keys(this.modules);\r\n }\r\n\r\n /**\r\n * Renders rows and buttons as per options\r\n */\r\n render(){\r\n /**\r\n * Clear keyboard\r\n */\r\n this.clear();\r\n\r\n let layoutClass = `hg-layout-${this.options.layoutName}`;\r\n let layout = this.options.layout || KeyboardLayout.getDefaultLayout();\r\n let useTouchEvents = this.options.useTouchEvents || false\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = {};\r\n if(Array.isArray(this.options.buttonTheme)){\r\n this.options.buttonTheme.forEach(themeObj => {\r\n if(themeObj.buttons && themeObj.class){\r\n let themeButtons;\r\n\r\n if(typeof themeObj.buttons === \"string\"){\r\n themeButtons = themeObj.buttons.split(\" \");\r\n }\r\n\r\n if(themeButtons){\r\n themeButtons.forEach(themeButton => {\r\n let themeParsed = buttonThemesParsed[themeButton];\r\n\r\n // If the button has already been added\r\n if(themeParsed){\r\n // Making sure we don't add duplicate classes, even when buttonTheme has duplicates\r\n if(!this.utilities.countInArray(themeParsed.split(\" \"), themeObj.class)){\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${themeObj.class}`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(`buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.`)\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses}`;\r\n\r\n /**\r\n * Iterating through each row\r\n */\r\n layout[this.options.layoutName].forEach((row, rIndex) => {\r\n let rowArray = row.split(\" \");\r\n\r\n /**\r\n * Creating empty row\r\n */\r\n let rowDOM = document.createElement(\"div\");\r\n rowDOM.className += \"hg-row\";\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n let fctBtnClass = this.utilities.getButtonClass(button);\r\n let buttonThemeClass = buttonThemesParsed[button];\r\n let buttonDisplayName = this.utilities.getButtonDisplayName(button, this.options.display, this.options.mergeDisplay);\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}${buttonThemeClass ? \" \"+buttonThemeClass : \"\"}`;\r\n \r\n if (useTouchEvents) {\r\n buttonDOM.ontouchstart = (e) => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n }\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n }\r\n buttonDOM.onmousedown = (e) => {\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n this.handleButtonMouseDown(button, e);\r\n }\r\n }\r\n \r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n 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])\r\n this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n\r\n });\r\n\r\n /**\r\n * Appending row to keyboard\r\n */\r\n this.keyboardDOM.appendChild(rowDOM);\r\n });\r\n\r\n /**\r\n * Calling onRender\r\n */\r\n this.onRender();\r\n\r\n if(!this.initialized){\r\n /**\r\n * Ensures that onInit is only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling mouseup\r\n */\r\n if (!useTouchEvents) {\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from './components/Keyboard';\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","getButtonClass","getButtonDisplayName","getUpdatedInput","updateCaretPos","updateCaretPosAction","isMaxLengthReached","camelCase","countInArray","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","newCaretPos","syncInstanceInputs","caretPosition","debug","console","log","keyboardDOMClass","source","string","position","slice","join","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","_defineProperty","option","render","initCallback","prop","keys","keyboardDOMQuery","arguments","undefined","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","handleButtonClicked","clearInput","getInput","setInput","replaceInput","clear","addButtonTheme","removeButtonTheme","handleCaret","caretEventHandler","onInit","onRender","loadModules","handleButtonMouseUp","handleButtonMouseDown","handleButtonHold","onModulesLoaded","inputPatternIsValid","buttonElements","warn","Error","physicalKeyboardInterface","onKeyPress","inputPattern","handleMaxLength","onChange","e","_this2","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","_this3","_this4","innerHTML","className","callback","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","inputVal","inputPatternRaw","RegExp","didInputMatch","test","simpleKeyboardInstances","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","Module","constructor","classStr","init","_this8","layoutClass","layout","getDefaultLayout","useTouchEvents","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","row","rIndex","rowArray","rowDOM","createElement","bIndex","fctBtnClass","buttonThemeClass","buttonDisplayName","buttonType","useButtonTag","ontouchstart","ontouchend","ontouchcancel","onclick","onmousedown","preventDefault","setAttribute","buttonUID","buttonSpanDOM","appendChild","initialized","onmouseup"],"mappings":";;;;;;;;;;;CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAA,kBAAAC,OACAA,OAAAD,QAAAD,IACA,oBAAAG,eAAAC,IACAD,OAAA,oBAAAH,GACA,kBAAAC,QACAA,QAAA,eAAAD,IAEAD,EAAA,eAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAQ,GAAA,EAGAR,EAAAD,QA0DA,OArDAM,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAAtB,GACA,qBAAAuB,eAAAC,aACAN,OAAAC,eAAAnB,EAAAuB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAnB,EAAA,cAAiDyB,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GAD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AclO,GAMrC,IAAImO,EAAS,GAAA/P,OAAMmO,EAAK1O,QAAQ6J,WAAnB,MAAAtJ,OAAkC8O,EAAlC,KAAA9O,OAA4CkP,GACzDpP,EAAUgQ,aAAa,gBAAiBC,GAKxCjQ,EAAUgQ,aAAa,oBAAqBT,GAK5C,IAAIW,EAAgB1Q,SAAS2P,cAAc,QAC3Ce,EAAcnE,UAAYwD,EAC1BvP,EAAUmQ,YAAYD,GAKjB7B,EAAKvD,eAAehJ,KAASuM,EAAKvD,eAAehJ,GAAU,IAEhEuM,EAAKvD,eAAehJ,GAAQ6K,KAAK3M,GAKjCkP,EAAOiB,YAAYnQ,KAMrBqO,EAAK/E,YAAY6G,YAAYjB,KAM/B9P,KAAKmL,WAEAnL,KAAKgR,cAIRhR,KAAKgR,aAAc,EAKd3B,IACHjP,SAAS6Q,UAAY,kBAAMhC,EAAK5D,wBAMlCrL,KAAKkL,+CCj3BI7B","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(\r\n this\r\n );\r\n\r\n /**\r\n * Initialize key listeners\r\n */\r\n this.initKeyboardListener();\r\n }\r\n\r\n /**\r\n * Initializes key event listeners\r\n */\r\n initKeyboardListener() {\r\n // Adding button style on keydown\r\n document.addEventListener(\"keydown\", event => {\r\n if (this.simpleKeyboardInstance.options.physicalKeyboardHighlight) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM) {\r\n buttonDOM.style.backgroundColor =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n });\r\n\r\n // Removing button style on keyup\r\n document.addEventListener(\"keyup\", event => {\r\n if (this.simpleKeyboardInstance.options.physicalKeyboardHighlight) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM && buttonDOM.removeAttribute) {\r\n buttonDOM.removeAttribute(\"style\");\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Transforms a KeyboardEvent's \"key.code\" string into a simple-keyboard layout format\r\n * @param {object} event The KeyboardEvent\r\n */\r\n getSimpleKeyboardLayoutKey(event) {\r\n let output;\r\n\r\n if (\r\n event.code.includes(\"Numpad\") ||\r\n event.code.includes(\"Shift\") ||\r\n event.code.includes(\"Space\") ||\r\n event.code.includes(\"Backspace\") ||\r\n event.code.includes(\"Control\") ||\r\n event.code.includes(\"Alt\") ||\r\n event.code.includes(\"Meta\")\r\n ) {\r\n output = event.code;\r\n } else {\r\n output = event.key;\r\n }\r\n\r\n /**\r\n * If button is not uppercase, casting to lowercase\r\n */\r\n if (\r\n output !== output.toUpperCase() ||\r\n (event.code[0] === \"F\" &&\r\n Number.isInteger(Number(event.code[1])) &&\r\n event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;\r\n","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout() {\r\n return {\r\n default: [\r\n \"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}\",\r\n \"{tab} q w e r t y u i o p [ ] \\\\\",\r\n \"{lock} a s d f g h j k l ; ' {enter}\",\r\n \"{shift} z x c v b n m , . / {shift}\",\r\n \".com @ {space}\"\r\n ],\r\n shift: [\r\n \"~ ! @ # $ % ^ & * ( ) _ + {bksp}\",\r\n \"{tab} Q W E R T Y U I O P { } |\",\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n \"{shift} Z X C V B N M < > ? {shift}\",\r\n \".com @ {space}\"\r\n ]\r\n };\r\n }\r\n}\r\n\r\nexport default KeyboardLayout;\r\n","/**\r\n * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.getButtonClass = this.getButtonClass.bind(this);\r\n this.getButtonDisplayName = this.getButtonDisplayName.bind(this);\r\n this.getUpdatedInput = this.getUpdatedInput.bind(this);\r\n this.updateCaretPos = this.updateCaretPos.bind(this);\r\n this.updateCaretPosAction = this.updateCaretPosAction.bind(this);\r\n this.isMaxLengthReached = this.isMaxLengthReached.bind(this);\r\n this.camelCase = this.camelCase.bind(this);\r\n this.countInArray = this.countInArray.bind(this);\r\n }\r\n\r\n /**\r\n * Adds default classes to a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @return {string} The classes to be added to the button\r\n */\r\n getButtonClass(button) {\r\n let buttonTypeClass =\r\n button.includes(\"{\") && button.includes(\"}\") && button !== \"{//}\"\r\n ? \"functionBtn\"\r\n : \"standardBtn\";\r\n let buttonWithoutBraces = button.replace(\"{\", \"\").replace(\"}\", \"\");\r\n let buttonNormalized = \"\";\r\n\r\n if (buttonTypeClass !== \"standardBtn\")\r\n buttonNormalized = ` hg-button-${buttonWithoutBraces}`;\r\n\r\n return `hg-${buttonTypeClass}${buttonNormalized}`;\r\n }\r\n\r\n /**\r\n * Default button display labels\r\n */\r\n getDefaultDiplay() {\r\n return {\r\n \"{bksp}\": \"backspace\",\r\n \"{backspace}\": \"backspace\",\r\n \"{enter}\": \"< enter\",\r\n \"{shift}\": \"shift\",\r\n \"{shiftleft}\": \"shift\",\r\n \"{shiftright}\": \"shift\",\r\n \"{alt}\": \"alt\",\r\n \"{s}\": \"shift\",\r\n \"{tab}\": \"tab\",\r\n \"{lock}\": \"caps\",\r\n \"{capslock}\": \"caps\",\r\n \"{accept}\": \"Submit\",\r\n \"{space}\": \" \",\r\n \"{//}\": \" \",\r\n \"{esc}\": \"esc\",\r\n \"{escape}\": \"esc\",\r\n \"{f1}\": \"f1\",\r\n \"{f2}\": \"f2\",\r\n \"{f3}\": \"f3\",\r\n \"{f4}\": \"f4\",\r\n \"{f5}\": \"f5\",\r\n \"{f6}\": \"f6\",\r\n \"{f7}\": \"f7\",\r\n \"{f8}\": \"f8\",\r\n \"{f9}\": \"f9\",\r\n \"{f10}\": \"f10\",\r\n \"{f11}\": \"f11\",\r\n \"{f12}\": \"f12\",\r\n \"{numpaddivide}\": \"/\",\r\n \"{numlock}\": \"lock\",\r\n \"{arrowup}\": \"↑\",\r\n \"{arrowleft}\": \"←\",\r\n \"{arrowdown}\": \"↓\",\r\n \"{arrowright}\": \"→\",\r\n \"{prtscr}\": \"print\",\r\n \"{scrolllock}\": \"scroll\",\r\n \"{pause}\": \"pause\",\r\n \"{insert}\": \"ins\",\r\n \"{home}\": \"home\",\r\n \"{pageup}\": \"up\",\r\n \"{delete}\": \"del\",\r\n \"{end}\": \"end\",\r\n \"{pagedown}\": \"down\",\r\n \"{numpadmultiply}\": \"*\",\r\n \"{numpadsubtract}\": \"-\",\r\n \"{numpadadd}\": \"+\",\r\n \"{numpadenter}\": \"enter\",\r\n \"{period}\": \".\",\r\n \"{numpaddecimal}\": \".\",\r\n \"{numpad0}\": \"0\",\r\n \"{numpad1}\": \"1\",\r\n \"{numpad2}\": \"2\",\r\n \"{numpad3}\": \"3\",\r\n \"{numpad4}\": \"4\",\r\n \"{numpad5}\": \"5\",\r\n \"{numpad6}\": \"6\",\r\n \"{numpad7}\": \"7\",\r\n \"{numpad8}\": \"8\",\r\n \"{numpad9}\": \"9\"\r\n };\r\n }\r\n /**\r\n * Returns the display (label) name for a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {object} display The provided display option\r\n * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.\r\n */\r\n getButtonDisplayName(button, display, mergeDisplay) {\r\n if (mergeDisplay) {\r\n display = Object.assign({}, this.getDefaultDiplay(), display);\r\n } else {\r\n display = display || this.getDefaultDiplay();\r\n }\r\n\r\n return display[button] || button;\r\n }\r\n\r\n /**\r\n * Returns the updated input resulting from clicking a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret) {\r\n let output = input;\r\n\r\n if (\r\n (button === \"{bksp}\" || button === \"{backspace}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n } else if (button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n else if (\r\n button === \"{tab}\" &&\r\n !(\r\n typeof options.tabCharOnTab === \"boolean\" &&\r\n options.tabCharOnTab === false\r\n )\r\n ) {\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n } else if (\r\n (button === \"{enter}\" || button === \"{numpadenter}\") &&\r\n options.newLineOnEnter\r\n )\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n else if (\r\n button.includes(\"numpad\") &&\r\n Number.isInteger(Number(button[button.length - 2]))\r\n ) {\r\n output = this.addStringAt(\r\n output,\r\n button[button.length - 2],\r\n caretPos,\r\n moveCaret\r\n );\r\n } else if (button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, \"/\", caretPos, moveCaret);\r\n else if (button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, \"*\", caretPos, moveCaret);\r\n else if (button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, \"-\", caretPos, moveCaret);\r\n else if (button === \"{numpadadd}\")\r\n output = this.addStringAt(output, \"+\", caretPos, moveCaret);\r\n else if (button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, \".\", caretPos, moveCaret);\r\n else if (button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n else if (!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus) {\r\n let newCaretPos = this.updateCaretPosAction(\r\n this.simpleKeyboardInstance,\r\n length,\r\n minus\r\n );\r\n\r\n if (this.simpleKeyboardInstance.options.syncInstanceInputs) {\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {object} instance The instance whose position should be updated\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(instance, length, minus) {\r\n if (minus) {\r\n if (instance.caretPosition > 0)\r\n instance.caretPosition = instance.caretPosition - length;\r\n } else {\r\n instance.caretPosition = instance.caretPosition + length;\r\n }\r\n\r\n if (this.simpleKeyboardInstance.options.debug) {\r\n console.log(\r\n \"Caret at:\",\r\n instance.caretPosition,\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n\r\n return instance.caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret) {\r\n let output;\r\n\r\n if (!position && position !== 0) {\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join(\r\n \"\"\r\n );\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if (!this.isMaxLengthReached()) {\r\n if (moveCaret) this.updateCaretPos(string.length);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret) {\r\n if (this.simpleKeyboardInstance.caretPosition === 0) {\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if (position && position >= 0) {\r\n prevTwoChars = source.substring(position - 2, position);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.substr(0, position - 2) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, position - 1) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.slice(0, -2);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n *\r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput) {\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if (\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ) {\r\n return false;\r\n }\r\n\r\n if (Number.isInteger(maxLength)) {\r\n if (options.debug) {\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if (typeof maxLength === \"object\") {\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if (options.debug) {\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached() {\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string) {\r\n return string\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce((string, word) =>\r\n word.length ? string + word[0].toUpperCase() + word.slice(1) : string\r\n );\r\n }\r\n\r\n /**\r\n * Counts the number of duplicates in a given array\r\n *\r\n * @param {Array} array The haystack to search in\r\n * @param {string} value The needle to search for\r\n */\r\n countInArray(array, value) {\r\n return array.reduce((n, x) => n + (x === value), 0);\r\n }\r\n}\r\n\r\nexport default Utilities;\r\n","import \"./Keyboard.css\";\r\n\r\n// Services\r\nimport PhysicalKeyboard from \"../services/PhysicalKeyboard\";\r\nimport KeyboardLayout from \"../services/KeyboardLayout\";\r\nimport Utilities from \"../services/Utilities\";\r\n\r\n/**\r\n * Root class for simple-keyboard\r\n * This class:\r\n * - Parses the options\r\n * - Renders the rows and buttons\r\n * - Handles button functionality\r\n */\r\nclass SimpleKeyboard {\r\n /**\r\n * Creates an instance of SimpleKeyboard\r\n * @param {Array} params If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.\r\n */\r\n constructor(...params) {\r\n let keyboardDOMQuery =\r\n typeof params[0] === \"string\" ? params[0] : \".simple-keyboard\";\r\n let options = typeof params[0] === \"object\" ? params[0] : params[1];\r\n\r\n if (!options) options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n * @property {boolean} useButtonTag Render buttons as a button element instead of a div element.\r\n * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.\r\n * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.\r\n */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault =\r\n this.options.preventMouseDownDefault || false;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = \"\";\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.handleButtonClicked = this.handleButtonClicked.bind(this);\r\n this.syncInstanceInputs = this.syncInstanceInputs.bind(this);\r\n this.clearInput = this.clearInput.bind(this);\r\n this.getInput = this.getInput.bind(this);\r\n this.setInput = this.setInput.bind(this);\r\n this.replaceInput = this.replaceInput.bind(this);\r\n this.clear = this.clear.bind(this);\r\n this.dispatch = this.dispatch.bind(this);\r\n this.addButtonTheme = this.addButtonTheme.bind(this);\r\n this.removeButtonTheme = this.removeButtonTheme.bind(this);\r\n this.getButtonElement = this.getButtonElement.bind(this);\r\n this.handleCaret = this.handleCaret.bind(this);\r\n this.caretEventHandler = this.caretEventHandler.bind(this);\r\n this.onInit = this.onInit.bind(this);\r\n this.onRender = this.onRender.bind(this);\r\n this.render = this.render.bind(this);\r\n this.loadModules = this.loadModules.bind(this);\r\n this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this);\r\n this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this);\r\n this.handleButtonHold = this.handleButtonHold.bind(this);\r\n this.onModulesLoaded = this.onModulesLoaded.bind(this);\r\n this.inputPatternIsValid = this.inputPatternIsValid.bind(this);\r\n\r\n /**\r\n * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).\r\n * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.\r\n * @example\r\n * // To get entered input\r\n * let input = keyboard.getInput();\r\n *\r\n * // To clear entered input.\r\n * keyboard.clearInput();\r\n *\r\n * @type {object}\r\n * @property {object} default Default SimpleKeyboard internal input.\r\n * @property {object} myInputName Example input that can be set through `options.inputName:\"myInputName\"`.\r\n */\r\n this.input = {};\r\n this.input[this.options.inputName] = \"\";\r\n\r\n /**\r\n * @type {string} DOM class of the keyboard wrapper, normally \"simple-keyboard\" by default.\r\n */\r\n this.keyboardDOMClass = keyboardDOMQuery.split(\".\").join(\"\");\r\n\r\n /**\r\n * @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: \"{enter}\").\r\n */\r\n this.buttonElements = {};\r\n\r\n /**\r\n * Rendering keyboard\r\n */\r\n if (this.keyboardDOM) this.render();\r\n else {\r\n console.warn(`\"${keyboardDOMQuery}\" was not found in the DOM.`);\r\n throw new Error(\"KEYBOARD_DOM_ERROR\");\r\n }\r\n\r\n /**\r\n * Saving instance\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if (!window[\"SimpleKeyboardInstances\"])\r\n window[\"SimpleKeyboardInstances\"] = {};\r\n\r\n window[\"SimpleKeyboardInstances\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button) {\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if (button === \"{//}\") return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if (typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n\r\n if (!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = \"\";\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition\r\n );\r\n\r\n if (\r\n // If input will change as a result of this button press\r\n this.input[this.options.inputName] !== updatedInput &&\r\n // This pertains to the \"inputPattern\" option:\r\n // If inputPattern isn't set\r\n (!this.options.inputPattern ||\r\n // Or, if it is set and if the pattern is valid - we proceed.\r\n (this.options.inputPattern && this.inputPatternIsValid(updatedInput)))\r\n ) {\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if (\r\n this.options.maxLength &&\r\n this.utilities.handleMaxLength(this.input, this.options, updatedInput)\r\n ) {\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition,\r\n true\r\n );\r\n\r\n if (debug) console.log(\"Input changed:\", this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n }\r\n\r\n if (debug) {\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e) {\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n if (this.holdTimeout) clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if (\r\n this.isMouseHold &&\r\n ((!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\")\r\n ) {\r\n if (this.options.debug) console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp() {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button) {\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if (this.isMouseHold) {\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs() {\r\n this.dispatch(instance => {\r\n instance.replaceInput(this.input);\r\n });\r\n }\r\n\r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = \"\";\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Get the keyboard’s input (You can also get it from the onChange prop).\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n getInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n return this.input[this.options.inputName];\r\n }\r\n\r\n /**\r\n * Set the keyboard’s input.\r\n * @param {string} input the input value\r\n * @param {string} inputName optional - the internal input to select\r\n */\r\n setInput(input, inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = input;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Replace the input object (`keyboard.input`)\r\n * @param {object} inputObj The input object\r\n */\r\n replaceInput(inputObj) {\r\n this.input = inputObj;\r\n }\r\n\r\n /**\r\n * Set new option or modify existing ones after initialization.\r\n * @param {object} option The option to set\r\n */\r\n setOptions = option => {\r\n option = option || {};\r\n this.options = Object.assign(this.options, option);\r\n this.render();\r\n };\r\n\r\n /**\r\n * Remove all keyboard rows and reset keyboard values.\r\n * Used interally between re-renders.\r\n */\r\n clear() {\r\n this.keyboardDOM.innerHTML = \"\";\r\n this.keyboardDOM.className = this.keyboardDOMClass;\r\n this.buttonElements = {};\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances at once (if you have multiple instances).\r\n * @param {function(instance: object, key: string)} callback Function to run on every instance\r\n */\r\n dispatch(callback) {\r\n if (!window[\"SimpleKeyboardInstances\"]) {\r\n console.warn(\r\n `SimpleKeyboardInstances is not defined. Dispatch cannot be called.`\r\n );\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n\r\n return Object.keys(window[\"SimpleKeyboardInstances\"]).forEach(key => {\r\n callback(window[\"SimpleKeyboardInstances\"][key], key);\r\n });\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className) {\r\n if (!className || !buttons) return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if (!this.options.buttonTheme) this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n\r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n if (buttonTheme.class.split(\" \").includes(classNameItem)) {\r\n classNameFound = true;\r\n\r\n let buttonThemeArray = buttonTheme.buttons.split(\" \");\r\n if (!buttonThemeArray.includes(button)) {\r\n classNameFound = true;\r\n buttonThemeArray.push(button);\r\n buttonTheme.buttons = buttonThemeArray.join(\" \");\r\n }\r\n }\r\n return buttonTheme;\r\n });\r\n\r\n /**\r\n * If class is not defined, we create a new entry\r\n */\r\n if (!classNameFound) {\r\n this.options.buttonTheme.push({\r\n class: classNameItem,\r\n buttons: buttons\r\n });\r\n }\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n\r\n /**\r\n * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n removeButtonTheme(buttons, className) {\r\n /**\r\n * When called with empty parameters, remove all button themes\r\n */\r\n if (!buttons && !className) {\r\n this.options.buttonTheme = [];\r\n this.render();\r\n return false;\r\n }\r\n\r\n /**\r\n * If buttons are passed and buttonTheme has items\r\n */\r\n if (\r\n buttons &&\r\n Array.isArray(this.options.buttonTheme) &&\r\n this.options.buttonTheme.length\r\n ) {\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if (\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ) {\r\n let filteredButtonArray = buttonTheme.buttons\r\n .split(\" \")\r\n .filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if (filteredButtonArray.length) {\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(button) {\r\n let output;\r\n\r\n let buttonArr = this.buttonElements[button];\r\n if (buttonArr) {\r\n if (buttonArr.length > 1) {\r\n output = buttonArr;\r\n } else {\r\n output = buttonArr[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * This handles the \"inputPattern\" option\r\n * by checking if the provided inputPattern passes\r\n */\r\n inputPatternIsValid(inputVal) {\r\n let inputPatternRaw = this.options.inputPattern;\r\n let inputPattern;\r\n\r\n /**\r\n * Check if input pattern is global or targeted to individual inputs\r\n */\r\n if (inputPatternRaw instanceof RegExp) {\r\n inputPattern = inputPatternRaw;\r\n } else {\r\n inputPattern = inputPatternRaw[this.options.inputName];\r\n }\r\n\r\n if (inputPattern && inputVal) {\r\n let didInputMatch = inputPattern.test(inputVal);\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `inputPattern (\"${inputPattern}\"): ${\r\n didInputMatch ? \"passed\" : \"did not pass!\"\r\n }`\r\n );\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret() {\r\n /**\r\n * Only first instance should insall the caret handling events\r\n */\r\n this.caretPosition = null;\r\n let simpleKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n\r\n if (\r\n (simpleKeyboardInstances &&\r\n Object.keys(simpleKeyboardInstances)[0] ===\r\n this.utilities.camelCase(this.keyboardDOMClass)) ||\r\n !simpleKeyboardInstances\r\n ) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\r\n }\r\n\r\n document.addEventListener(\"keyup\", this.caretEventHandler);\r\n document.addEventListener(\"mouseup\", this.caretEventHandler);\r\n document.addEventListener(\"touchend\", this.caretEventHandler);\r\n }\r\n }\r\n\r\n /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\r\n let targetTagName;\r\n if (event.target.tagName) {\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch(instance => {\r\n if (instance.isMouseHold) {\r\n instance.isMouseHold = false;\r\n }\r\n\r\n if (\r\n (targetTagName === \"textarea\" || targetTagName === \"input\") &&\r\n !instance.options.disableCaretPositioning\r\n ) {\r\n /**\r\n * Tracks current cursor position\r\n * As keys are pressed, text will be added/removed at that position within the input.\r\n */\r\n instance.caretPosition = event.target.selectionStart;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n event.target.selectionStart,\r\n event.target.tagName.toLowerCase(),\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n } else if (instance.options.disableCaretPositioning) {\r\n /**\r\n * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.\r\n */\r\n instance.caretPosition = null;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n */\r\n onRender() {\r\n if (typeof this.options.onRender === \"function\") this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded() {\r\n if (typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if (!this.modules[name]) this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n };\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules() {\r\n if (Array.isArray(this.options.modules)) {\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if (module.constructor.name && module.constructor.name !== \"Function\") {\r\n let classStr = `module-${this.utilities.camelCase(\r\n module.constructor.name\r\n )}`;\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + \" modules-loaded\";\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp = (name, prop) => {\r\n if (!this.modules[name]) return false;\r\n\r\n return this.modules[name][prop];\r\n };\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList = () => {\r\n return Object.keys(this.modules);\r\n };\r\n\r\n /**\r\n * Renders rows and buttons as per options\r\n */\r\n render() {\r\n /**\r\n * Clear keyboard\r\n */\r\n this.clear();\r\n\r\n 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\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = {};\r\n if (Array.isArray(this.options.buttonTheme)) {\r\n this.options.buttonTheme.forEach(themeObj => {\r\n if (themeObj.buttons && themeObj.class) {\r\n let themeButtons;\r\n\r\n if (typeof themeObj.buttons === \"string\") {\r\n themeButtons = themeObj.buttons.split(\" \");\r\n }\r\n\r\n if (themeButtons) {\r\n themeButtons.forEach(themeButton => {\r\n let themeParsed = buttonThemesParsed[themeButton];\r\n\r\n // If the button has already been added\r\n if (themeParsed) {\r\n // Making sure we don't add duplicate classes, even when buttonTheme has duplicates\r\n if (\r\n !this.utilities.countInArray(\r\n themeParsed.split(\" \"),\r\n themeObj.class\r\n )\r\n ) {\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${\r\n themeObj.class\r\n }`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(\r\n `buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.`\r\n );\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${\r\n this.keyboardPluginClasses\r\n }`;\r\n\r\n /**\r\n * Iterating through each row\r\n */\r\n layout[this.options.layoutName].forEach((row, rIndex) => {\r\n let rowArray = row.split(\" \");\r\n\r\n /**\r\n * Creating empty row\r\n */\r\n let rowDOM = document.createElement(\"div\");\r\n rowDOM.className += \"hg-row\";\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n let fctBtnClass = this.utilities.getButtonClass(button);\r\n let buttonThemeClass = buttonThemesParsed[button];\r\n let buttonDisplayName = this.utilities.getButtonDisplayName(\r\n button,\r\n this.options.display,\r\n this.options.mergeDisplay\r\n );\r\n\r\n /**\r\n * Creating button\r\n */\r\n let buttonType = this.options.useButtonTag ? \"button\" : \"div\";\r\n let buttonDOM = document.createElement(buttonType);\r\n buttonDOM.className += `hg-button ${fctBtnClass}${\r\n buttonThemeClass ? \" \" + buttonThemeClass : \"\"\r\n }`;\r\n\r\n if (useTouchEvents) {\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => {\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n }\r\n\r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n let buttonSpanDOM = document.createElement(\"span\");\r\n buttonSpanDOM.innerHTML = buttonDisplayName;\r\n buttonDOM.appendChild(buttonSpanDOM);\r\n\r\n /**\r\n * Adding to buttonElements\r\n */\r\n if (!this.buttonElements[button]) this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n });\r\n\r\n /**\r\n * Appending row to keyboard\r\n */\r\n this.keyboardDOM.appendChild(rowDOM);\r\n });\r\n\r\n /**\r\n * Calling onRender\r\n */\r\n this.onRender();\r\n\r\n if (!this.initialized) {\r\n /**\r\n * Ensures that onInit is only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling mouseup\r\n */\r\n if (!useTouchEvents) {\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from \"./components/Keyboard\";\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/build/simple-keyboard.js b/build/simple-keyboard.js new file mode 100644 index 00000000..0265f3ba --- /dev/null +++ b/build/simple-keyboard.js @@ -0,0 +1,1459 @@ +/*! + * + * simple-keyboard v2.15.0 (Non-minified build) + * https://github.com/hodgef/simple-keyboard + * + * Copyright (c) Francisco Hodge (https://github.com/hodgef) + * + * This source code is licensed under a dual license system (MIT or GPL-3.0), as found in the + * LICENSE file in the root directory of this source tree. + * + */ +(function webpackUniversalModuleDefinition(root, factory) { + if (typeof exports === "object" && typeof module === "object") { + module.exports = factory(); + } else if (typeof define === "function" && define.amd) { + define("SimpleKeyboard", [], factory); + } else if (typeof exports === "object") { + exports["SimpleKeyboard"] = factory(); + } else { + root["SimpleKeyboard"] = factory(); + } +})(window, function() { + /******/ + return function(modules) { + // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if (installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if (!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + enumerable: true, + get: getter + }); + /******/ } + /******/ }; + /******/ + /******/ // define __esModule on exports + /******/ __webpack_require__.r = function(exports) { + /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) { + /******/ Object.defineProperty(exports, Symbol.toStringTag, { + value: "Module" + }); + /******/ } + /******/ Object.defineProperty(exports, "__esModule", { + value: true + }); + /******/ }; + /******/ + /******/ // create a fake namespace object + /******/ // mode & 1: value is a module id, require it + /******/ // mode & 2: merge all properties of value into the ns + /******/ // mode & 4: return value when already ns object + /******/ // mode & 8|1: behave like require + /******/ __webpack_require__.t = function(value, mode) { + /******/ if (mode & 1) { + value = __webpack_require__(value); + /******/ } + if (mode & 8) { + return value; + /******/ } + if (mode & 4 && typeof value === "object" && value && value.__esModule) { + return value; + /******/ } + var ns = Object.create(null); + /******/ __webpack_require__.r(ns); + /******/ Object.defineProperty(ns, "default", { + enumerable: true, + value: value + }); + /******/ if (mode & 2 && typeof value != "string") { + for (var key in value) { + __webpack_require__.d(ns, key, function(key) { + return value[key]; + }.bind(null, key)); + /******/ } + } + return ns; + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { + return module["default"]; + } : + /******/ function getModuleExports() { + return module; + }; + /******/ __webpack_require__.d(getter, "a", getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { + return Object.prototype.hasOwnProperty.call(object, property); + }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 0); + /******/ } + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ function(module, exports, __webpack_require__) { + module.exports = __webpack_require__(2); + /***/ }, + /* 1 */ + /***/ function(module, exports, __webpack_require__) { + // extracted by mini-css-extract-plugin + /***/}, + /* 2 */ + /***/ function(module, __webpack_exports__, __webpack_require__) { + "use strict"; + __webpack_require__.r(__webpack_exports__); + // EXTERNAL MODULE: ./src/lib/components/Keyboard.css + var Keyboard = __webpack_require__(1); + // CONCATENATED MODULE: ./src/lib/services/PhysicalKeyboard.js + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) { + descriptor.writable = true; + } + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) { + _defineProperties(Constructor.prototype, protoProps); + } + if (staticProps) { + _defineProperties(Constructor, staticProps); + } + return Constructor; + } + /** + * Physical Keyboard Service + */ var PhysicalKeyboard = /* */ function() { + /** + * Creates an instance of the PhysicalKeyboard service + */ function PhysicalKeyboard(simpleKeyboardInstance) { + _classCallCheck(this, PhysicalKeyboard); + /** + * @type {object} A simple-keyboard instance + */ this.simpleKeyboardInstance = simpleKeyboardInstance; + /** + * Bindings + */ this.initKeyboardListener = this.initKeyboardListener.bind(this); + this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(this); + /** + * Initialize key listeners + */ this.initKeyboardListener(); + } + /** + * Initializes key event listeners + */ _createClass(PhysicalKeyboard, [ { + key: "initKeyboardListener", + value: function initKeyboardListener() { + var _this = this; + // Adding button style on keydown + document.addEventListener("keydown", function(event) { + if (_this.simpleKeyboardInstance.options.physicalKeyboardHighlight) { + var buttonPressed = _this.getSimpleKeyboardLayoutKey(event); + _this.simpleKeyboardInstance.dispatch(function(instance) { + var buttonDOM = instance.getButtonElement(buttonPressed) || instance.getButtonElement("{".concat(buttonPressed, "}")); + if (buttonDOM) { + buttonDOM.style.backgroundColor = _this.simpleKeyboardInstance.options.physicalKeyboardHighlightBgColor || "#9ab4d0"; + buttonDOM.style.color = _this.simpleKeyboardInstance.options.physicalKeyboardHighlightTextColor || "white"; + } + }); + } + }); + // Removing button style on keyup + document.addEventListener("keyup", function(event) { + if (_this.simpleKeyboardInstance.options.physicalKeyboardHighlight) { + var buttonPressed = _this.getSimpleKeyboardLayoutKey(event); + _this.simpleKeyboardInstance.dispatch(function(instance) { + var buttonDOM = instance.getButtonElement(buttonPressed) || instance.getButtonElement("{".concat(buttonPressed, "}")); + if (buttonDOM && buttonDOM.removeAttribute) { + buttonDOM.removeAttribute("style"); + } + }); + } + }); + } + /** + * Transforms a KeyboardEvent's "key.code" string into a simple-keyboard layout format + * @param {object} event The KeyboardEvent + */ }, { + key: "getSimpleKeyboardLayoutKey", + value: function getSimpleKeyboardLayoutKey(event) { + var output; + if (event.code.includes("Numpad") || event.code.includes("Shift") || event.code.includes("Space") || event.code.includes("Backspace") || event.code.includes("Control") || event.code.includes("Alt") || event.code.includes("Meta")) { + output = event.code; + } else { + output = event.key; + } + /** + * If button is not uppercase, casting to lowercase + */ if (output !== output.toUpperCase() || event.code[0] === "F" && Number.isInteger(Number(event.code[1])) && event.code.length <= 3) { + output = output.toLowerCase(); + } + return output; + } + } ]); + return PhysicalKeyboard; + }(); + /* harmony default export */ var services_PhysicalKeyboard = PhysicalKeyboard; + // CONCATENATED MODULE: ./src/lib/services/KeyboardLayout.js + function KeyboardLayout_classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function KeyboardLayout_defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) { + descriptor.writable = true; + } + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function KeyboardLayout_createClass(Constructor, protoProps, staticProps) { + if (protoProps) { + KeyboardLayout_defineProperties(Constructor.prototype, protoProps); + } + if (staticProps) { + KeyboardLayout_defineProperties(Constructor, staticProps); + } + return Constructor; + } + /** + * Keyboard Layout Service + */ var KeyboardLayout = /* */ function() { + function KeyboardLayout() { + KeyboardLayout_classCallCheck(this, KeyboardLayout); + } + KeyboardLayout_createClass(KeyboardLayout, null, [ { + key: "getDefaultLayout", + /** + * Get default simple-keyboard layout + * @return {object} The default layout (US-QWERTY) + */ value: function getDefaultLayout() { + return { + default: [ "` 1 2 3 4 5 6 7 8 9 0 - = {bksp}", "{tab} q w e r t y u i o p [ ] \\", "{lock} a s d f g h j k l ; ' {enter}", "{shift} z x c v b n m , . / {shift}", ".com @ {space}" ], + shift: [ "~ ! @ # $ % ^ & * ( ) _ + {bksp}", "{tab} Q W E R T Y U I O P { } |", '{lock} A S D F G H J K L : " {enter}', "{shift} Z X C V B N M < > ? {shift}", ".com @ {space}" ] + }; + } + } ]); + return KeyboardLayout; + }(); + /* harmony default export */ var services_KeyboardLayout = KeyboardLayout; + // CONCATENATED MODULE: ./src/lib/services/Utilities.js + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + return _typeof(obj); + } + function Utilities_classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function Utilities_defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) { + descriptor.writable = true; + } + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function Utilities_createClass(Constructor, protoProps, staticProps) { + if (protoProps) { + Utilities_defineProperties(Constructor.prototype, protoProps); + } + if (staticProps) { + Utilities_defineProperties(Constructor, staticProps); + } + return Constructor; + } + /** + * Utility Service + */ var Utilities = /* */ function() { + /** + * Creates an instance of the Utility service + */ function Utilities(simpleKeyboardInstance) { + Utilities_classCallCheck(this, Utilities); + /** + * @type {object} A simple-keyboard instance + */ this.simpleKeyboardInstance = simpleKeyboardInstance; + /** + * Bindings + */ this.getButtonClass = this.getButtonClass.bind(this); + this.getButtonDisplayName = this.getButtonDisplayName.bind(this); + this.getUpdatedInput = this.getUpdatedInput.bind(this); + this.updateCaretPos = this.updateCaretPos.bind(this); + this.updateCaretPosAction = this.updateCaretPosAction.bind(this); + this.isMaxLengthReached = this.isMaxLengthReached.bind(this); + this.camelCase = this.camelCase.bind(this); + this.countInArray = this.countInArray.bind(this); + } + /** + * Adds default classes to a given button + * + * @param {string} button The button's layout name + * @return {string} The classes to be added to the button + */ Utilities_createClass(Utilities, [ { + key: "getButtonClass", + value: function getButtonClass(button) { + var buttonTypeClass = button.includes("{") && button.includes("}") && button !== "{//}" ? "functionBtn" : "standardBtn"; + var buttonWithoutBraces = button.replace("{", "").replace("}", ""); + var buttonNormalized = ""; + if (buttonTypeClass !== "standardBtn") { + buttonNormalized = " hg-button-".concat(buttonWithoutBraces); + } + return "hg-".concat(buttonTypeClass).concat(buttonNormalized); + } + /** + * Default button display labels + */ }, { + key: "getDefaultDiplay", + value: function getDefaultDiplay() { + return { + "{bksp}": "backspace", + "{backspace}": "backspace", + "{enter}": "< enter", + "{shift}": "shift", + "{shiftleft}": "shift", + "{shiftright}": "shift", + "{alt}": "alt", + "{s}": "shift", + "{tab}": "tab", + "{lock}": "caps", + "{capslock}": "caps", + "{accept}": "Submit", + "{space}": " ", + "{//}": " ", + "{esc}": "esc", + "{escape}": "esc", + "{f1}": "f1", + "{f2}": "f2", + "{f3}": "f3", + "{f4}": "f4", + "{f5}": "f5", + "{f6}": "f6", + "{f7}": "f7", + "{f8}": "f8", + "{f9}": "f9", + "{f10}": "f10", + "{f11}": "f11", + "{f12}": "f12", + "{numpaddivide}": "/", + "{numlock}": "lock", + "{arrowup}": "↑", + "{arrowleft}": "←", + "{arrowdown}": "↓", + "{arrowright}": "→", + "{prtscr}": "print", + "{scrolllock}": "scroll", + "{pause}": "pause", + "{insert}": "ins", + "{home}": "home", + "{pageup}": "up", + "{delete}": "del", + "{end}": "end", + "{pagedown}": "down", + "{numpadmultiply}": "*", + "{numpadsubtract}": "-", + "{numpadadd}": "+", + "{numpadenter}": "enter", + "{period}": ".", + "{numpaddecimal}": ".", + "{numpad0}": "0", + "{numpad1}": "1", + "{numpad2}": "2", + "{numpad3}": "3", + "{numpad4}": "4", + "{numpad5}": "5", + "{numpad6}": "6", + "{numpad7}": "7", + "{numpad8}": "8", + "{numpad9}": "9" + }; + } + /** + * Returns the display (label) name for a given button + * + * @param {string} button The button's layout name + * @param {object} display The provided display option + * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one. + */ }, { + key: "getButtonDisplayName", + value: function getButtonDisplayName(button, display, mergeDisplay) { + if (mergeDisplay) { + display = Object.assign({}, this.getDefaultDiplay(), display); + } else { + display = display || this.getDefaultDiplay(); + } + return display[button] || button; + } + /** + * Returns the updated input resulting from clicking a given button + * + * @param {string} button The button's layout name + * @param {string} input The input string + * @param {object} options The simple-keyboard options object + * @param {number} caretPos The cursor's current position + * @param {boolean} moveCaret Whether to update simple-keyboard's cursor + */ }, { + key: "getUpdatedInput", + value: function getUpdatedInput(button, input, options, caretPos, moveCaret) { + var output = input; + if ((button === "{bksp}" || button === "{backspace}") && output.length > 0) { + output = this.removeAt(output, caretPos, moveCaret); + } else if (button === "{space}") { + output = this.addStringAt(output, " ", caretPos, moveCaret); + } else if (button === "{tab}" && !(typeof options.tabCharOnTab === "boolean" && options.tabCharOnTab === false)) { + output = this.addStringAt(output, "\t", caretPos, moveCaret); + } else if ((button === "{enter}" || button === "{numpadenter}") && options.newLineOnEnter) { + output = this.addStringAt(output, "\n", caretPos, moveCaret); + } else if (button.includes("numpad") && Number.isInteger(Number(button[button.length - 2]))) { + output = this.addStringAt(output, button[button.length - 2], caretPos, moveCaret); + } else if (button === "{numpaddivide}") { + output = this.addStringAt(output, "/", caretPos, moveCaret); + } else if (button === "{numpadmultiply}") { + output = this.addStringAt(output, "*", caretPos, moveCaret); + } else if (button === "{numpadsubtract}") { + output = this.addStringAt(output, "-", caretPos, moveCaret); + } else if (button === "{numpadadd}") { + output = this.addStringAt(output, "+", caretPos, moveCaret); + } else if (button === "{numpaddecimal}") { + output = this.addStringAt(output, ".", caretPos, moveCaret); + } else if (button === "{" || button === "}") { + output = this.addStringAt(output, button, caretPos, moveCaret); + } else if (!button.includes("{") && !button.includes("}")) { + output = this.addStringAt(output, button, caretPos, moveCaret); + } + return output; + } + /** + * Moves the cursor position by a given amount + * + * @param {number} length Represents by how many characters the input should be moved + * @param {boolean} minus Whether the cursor should be moved to the left or not. + */ }, { + key: "updateCaretPos", + value: function updateCaretPos(length, minus) { + var newCaretPos = this.updateCaretPosAction(this.simpleKeyboardInstance, length, minus); + if (this.simpleKeyboardInstance.options.syncInstanceInputs) { + this.simpleKeyboardInstance.dispatch(function(instance) { + instance.caretPosition = newCaretPos; + }); + } + } + /** + * Action method of updateCaretPos + * + * @param {object} instance The instance whose position should be updated + * @param {number} length Represents by how many characters the input should be moved + * @param {boolean} minus Whether the cursor should be moved to the left or not. + */ }, { + key: "updateCaretPosAction", + value: function updateCaretPosAction(instance, length, minus) { + if (minus) { + if (instance.caretPosition > 0) { + instance.caretPosition = instance.caretPosition - length; + } + } else { + instance.caretPosition = instance.caretPosition + length; + } + if (this.simpleKeyboardInstance.options.debug) { + console.log("Caret at:", instance.caretPosition, "(".concat(instance.keyboardDOMClass, ")")); + } + return instance.caretPosition; + } + /** + * Adds a string to the input at a given position + * + * @param {string} source The source input + * @param {string} string The string to add + * @param {number} position The (cursor) position where the string should be added + * @param {boolean} moveCaret Whether to update simple-keyboard's cursor + */ }, { + key: "addStringAt", + value: function addStringAt(source, string, position, moveCaret) { + var output; + if (!position && position !== 0) { + output = source + string; + } else { + output = [ source.slice(0, position), string, source.slice(position) ].join(""); + /** + * Avoid caret position change when maxLength is set + */ if (!this.isMaxLengthReached()) { + if (moveCaret) { + this.updateCaretPos(string.length); + } + } + } + return output; + } + /** + * Removes an amount of characters at a given position + * + * @param {string} source The source input + * @param {number} position The (cursor) position from where the characters should be removed + * @param {boolean} moveCaret Whether to update simple-keyboard's cursor + */ }, { + key: "removeAt", + value: function removeAt(source, position, moveCaret) { + if (this.simpleKeyboardInstance.caretPosition === 0) { + return source; + } + var output; + var prevTwoChars; + var emojiMatched; + var emojiMatchedReg = /([\uD800-\uDBFF][\uDC00-\uDFFF])/g; + /** + * Emojis are made out of two characters, so we must take a custom approach to trim them. + * For more info: https://mathiasbynens.be/notes/javascript-unicode + */ if (position && position >= 0) { + prevTwoChars = source.substring(position - 2, position); + emojiMatched = prevTwoChars.match(emojiMatchedReg); + if (emojiMatched) { + output = source.substr(0, position - 2) + source.substr(position); + if (moveCaret) { + this.updateCaretPos(2, true); + } + } else { + output = source.substr(0, position - 1) + source.substr(position); + if (moveCaret) { + this.updateCaretPos(1, true); + } + } + } else { + prevTwoChars = source.slice(-2); + emojiMatched = prevTwoChars.match(emojiMatchedReg); + if (emojiMatched) { + output = source.slice(0, -2); + if (moveCaret) { + this.updateCaretPos(2, true); + } + } else { + output = source.slice(0, -1); + if (moveCaret) { + this.updateCaretPos(1, true); + } + } + } + return output; + } + /** + * Determines whether the maxLength has been reached. This function is called when the maxLength option it set. + * + * @param {object} inputObj + * @param {object} options + * @param {string} updatedInput + */ }, { + key: "handleMaxLength", + value: function handleMaxLength(inputObj, options, updatedInput) { + var maxLength = options.maxLength; + var currentInput = inputObj[options.inputName]; + var condition = currentInput.length === maxLength; + if ( + /** + * If pressing this button won't add more characters + * We exit out of this limiter function + */ updatedInput.length <= currentInput.length) { + return false; + } + if (Number.isInteger(maxLength)) { + if (options.debug) { + console.log("maxLength (num) reached:", condition); + } + if (condition) { + /** + * @type {boolean} Boolean value that shows whether maxLength has been reached + */ this.maxLengthReached = true; + return true; + } else { + this.maxLengthReached = false; + return false; + } + } + if (_typeof(maxLength) === "object") { + var _condition = currentInput.length === maxLength[options.inputName]; + if (options.debug) { + console.log("maxLength (obj) reached:", _condition); + } + if (_condition) { + this.maxLengthReached = true; + return true; + } else { + this.maxLengthReached = false; + return false; + } + } + } + /** + * Gets the current value of maxLengthReached + */ }, { + key: "isMaxLengthReached", + value: function isMaxLengthReached() { + return Boolean(this.maxLengthReached); + } + /** + * Transforms an arbitrary string to camelCase + * + * @param {string} string The string to transform. + */ }, { + key: "camelCase", + value: function camelCase(string) { + return string.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(string, word) { + return word.length ? string + word[0].toUpperCase() + word.slice(1) : string; + }); + } + /** + * 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); + } + } ]); + return Utilities; + }(); + /* harmony default export */ var services_Utilities = Utilities; + // CONCATENATED MODULE: ./src/lib/components/Keyboard.js + function Keyboard_typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + Keyboard_typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + Keyboard_typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + return Keyboard_typeof(obj); + } + function Keyboard_classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function Keyboard_defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) { + descriptor.writable = true; + } + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function Keyboard_createClass(Constructor, protoProps, staticProps) { + if (protoProps) { + Keyboard_defineProperties(Constructor.prototype, protoProps); + } + if (staticProps) { + Keyboard_defineProperties(Constructor, staticProps); + } + return Constructor; + } + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + // Services + /** + * Root class for simple-keyboard + * This class: + * - Parses the options + * - Renders the rows and buttons + * - Handles button functionality + */ var Keyboard_SimpleKeyboard = /* */ function() { + /** + * Creates an instance of SimpleKeyboard + * @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. + */ function SimpleKeyboard() { + var _this = this; + Keyboard_classCallCheck(this, SimpleKeyboard); + _defineProperty(this, "setOptions", function(option) { + option = option || {}; + _this.options = Object.assign(_this.options, option); + _this.render(); + }); + _defineProperty(this, "registerModule", function(name, initCallback) { + if (!_this.modules[name]) { + _this.modules[name] = {}; + } + initCallback(_this.modules[name]); + }); + _defineProperty(this, "getModuleProp", function(name, prop) { + if (!_this.modules[name]) { + return false; + } + return _this.modules[name][prop]; + }); + _defineProperty(this, "getModulesList", function() { + return Object.keys(_this.modules); + }); + var keyboardDOMQuery = typeof (arguments.length <= 0 ? undefined : arguments[0]) === "string" ? arguments.length <= 0 ? undefined : arguments[0] : ".simple-keyboard"; + var options = Keyboard_typeof(arguments.length <= 0 ? undefined : arguments[0]) === "object" ? arguments.length <= 0 ? undefined : arguments[0] : arguments.length <= 1 ? undefined : arguments[1]; + if (!options) { + options = {}; + /** + * Initializing Utilities + */ } + this.utilities = new services_Utilities(this); + /** + * Processing options + */ this.keyboardDOM = document.querySelector(keyboardDOMQuery); + /** + * @type {object} + * @property {object} layout Modify the keyboard layout. + * @property {string} layoutName Specifies which layout should be used. + * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”). + * @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 {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. + * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs. + * @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. + * @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. + * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance. + * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard. + * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input. + * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have. + * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have. + * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”). + * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string. + * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts). + * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization). + * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs. + * @property {boolean} useButtonTag Render buttons as a button element instead of a div element. + * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string. + * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern. + */ this.options = options; + this.options.layoutName = this.options.layoutName || "default"; + this.options.theme = this.options.theme || "hg-theme-default"; + this.options.inputName = this.options.inputName || "default"; + this.options.preventMouseDownDefault = this.options.preventMouseDownDefault || false; + /** + * @type {object} Classes identifying loaded plugins + */ this.keyboardPluginClasses = ""; + /** + * Bindings + */ this.handleButtonClicked = this.handleButtonClicked.bind(this); + this.syncInstanceInputs = this.syncInstanceInputs.bind(this); + this.clearInput = this.clearInput.bind(this); + this.getInput = this.getInput.bind(this); + this.setInput = this.setInput.bind(this); + this.replaceInput = this.replaceInput.bind(this); + this.clear = this.clear.bind(this); + this.dispatch = this.dispatch.bind(this); + this.addButtonTheme = this.addButtonTheme.bind(this); + this.removeButtonTheme = this.removeButtonTheme.bind(this); + this.getButtonElement = this.getButtonElement.bind(this); + this.handleCaret = this.handleCaret.bind(this); + this.caretEventHandler = this.caretEventHandler.bind(this); + this.onInit = this.onInit.bind(this); + this.onRender = this.onRender.bind(this); + this.render = this.render.bind(this); + this.loadModules = this.loadModules.bind(this); + this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this); + this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this); + this.handleButtonHold = this.handleButtonHold.bind(this); + this.onModulesLoaded = this.onModulesLoaded.bind(this); + this.inputPatternIsValid = this.inputPatternIsValid.bind(this); + /** + * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`). + * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example. + * @example + * // To get entered input + * let input = keyboard.getInput(); + * + * // To clear entered input. + * keyboard.clearInput(); + * + * @type {object} + * @property {object} default Default SimpleKeyboard internal input. + * @property {object} myInputName Example input that can be set through `options.inputName:"myInputName"`. + */ this.input = {}; + this.input[this.options.inputName] = ""; + /** + * @type {string} DOM class of the keyboard wrapper, normally "simple-keyboard" by default. + */ this.keyboardDOMClass = keyboardDOMQuery.split(".").join(""); + /** + * @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: "{enter}"). + */ this.buttonElements = {}; + /** + * Rendering keyboard + */ if (this.keyboardDOM) { + this.render(); + } else { + console.warn('"'.concat(keyboardDOMQuery, '" was not found in the DOM.')); + throw new Error("KEYBOARD_DOM_ERROR"); + } + /** + * Saving instance + * This enables multiple simple-keyboard support with easier management + */ if (!window["SimpleKeyboardInstances"]) { + window["SimpleKeyboardInstances"] = {}; + } + window["SimpleKeyboardInstances"][this.utilities.camelCase(this.keyboardDOMClass)] = this; + /** + * Physical Keyboard support + */ this.physicalKeyboardInterface = new services_PhysicalKeyboard(this); + /** + * Modules + */ this.modules = {}; + this.loadModules(); + } + /** + * Handles clicks made to keyboard buttons + * @param {string} button The button's layout name. + */ Keyboard_createClass(SimpleKeyboard, [ { + key: "handleButtonClicked", + value: function handleButtonClicked(button) { + var debug = this.options.debug; + /** + * Ignoring placeholder buttons + */ if (button === "{//}") { + return false; + /** + * Calling onKeyPress + */ } + if (typeof this.options.onKeyPress === "function") { + this.options.onKeyPress(button); + } + if (!this.input[this.options.inputName]) { + this.input[this.options.inputName] = ""; + } + var updatedInput = this.utilities.getUpdatedInput(button, this.input[this.options.inputName], this.options, this.caretPosition); + if (// If input will change as a result of this button press + this.input[this.options.inputName] !== updatedInput && (// This pertains to the "inputPattern" option: + // If inputPattern isn't set + !this.options.inputPattern || // Or, if it is set and if the pattern is valid - we proceed. + this.options.inputPattern && this.inputPatternIsValid(updatedInput))) { + /** + * If maxLength and handleMaxLength yield true, halting + */ if (this.options.maxLength && this.utilities.handleMaxLength(this.input, this.options, updatedInput)) { + return false; + } + this.input[this.options.inputName] = this.utilities.getUpdatedInput(button, this.input[this.options.inputName], this.options, this.caretPosition, true); + if (debug) { + console.log("Input changed:", this.input); + /** + * Enforce syncInstanceInputs, if set + */ } + if (this.options.syncInstanceInputs) { + this.syncInstanceInputs(this.input); + /** + * Calling onChange + */ } + if (typeof this.options.onChange === "function") { + this.options.onChange(this.input[this.options.inputName]); + } + } + if (debug) { + console.log("Key pressed:", button); + } + } + /** + * Handles button mousedown + */ /* istanbul ignore next */ }, { + key: "handleButtonMouseDown", + value: function handleButtonMouseDown(button, e) { + var _this2 = this; + /** + * @type {boolean} Whether the mouse is being held onKeyPress + */ this.isMouseHold = true; + if (this.holdInteractionTimeout) { + clearTimeout(this.holdInteractionTimeout); + } + if (this.holdTimeout) { + clearTimeout(this.holdTimeout); + /** + * @type {object} Time to wait until a key hold is detected + */ } + this.holdTimeout = setTimeout(function() { + if (_this2.isMouseHold && (!button.includes("{") && !button.includes("}") || button === "{bksp}" || button === "{space}" || button === "{tab}")) { + if (_this2.options.debug) { + console.log("Button held:", button); + } + _this2.handleButtonHold(button, e); + } + clearTimeout(_this2.holdTimeout); + }, 500); + } + /** + * Handles button mouseup + */ }, { + key: "handleButtonMouseUp", + value: function handleButtonMouseUp() { + this.isMouseHold = false; + if (this.holdInteractionTimeout) { + clearTimeout(this.holdInteractionTimeout); + } + } + /** + * Handles button hold + */ /* istanbul ignore next */ }, { + key: "handleButtonHold", + value: function handleButtonHold(button) { + var _this3 = this; + if (this.holdInteractionTimeout) { + clearTimeout(this.holdInteractionTimeout); + /** + * @type {object} Timeout dictating the speed of key hold iterations + */ } + this.holdInteractionTimeout = setTimeout(function() { + if (_this3.isMouseHold) { + _this3.handleButtonClicked(button); + _this3.handleButtonHold(button); + } else { + clearTimeout(_this3.holdInteractionTimeout); + } + }, 100); + } + /** + * Send a command to all simple-keyboard instances (if you have several instances). + */ }, { + key: "syncInstanceInputs", + value: function syncInstanceInputs() { + var _this4 = this; + this.dispatch(function(instance) { + instance.replaceInput(_this4.input); + }); + } + /** + * Clear the keyboard’s input. + * @param {string} [inputName] optional - the internal input to select + */ }, { + key: "clearInput", + value: function clearInput(inputName) { + inputName = inputName || this.options.inputName; + this.input[inputName] = ""; + /** + * Enforce syncInstanceInputs, if set + */ if (this.options.syncInstanceInputs) { + this.syncInstanceInputs(this.input); + } + } + /** + * Get the keyboard’s input (You can also get it from the onChange prop). + * @param {string} [inputName] optional - the internal input to select + */ }, { + key: "getInput", + value: function getInput(inputName) { + inputName = inputName || this.options.inputName; + /** + * Enforce syncInstanceInputs, if set + */ if (this.options.syncInstanceInputs) { + this.syncInstanceInputs(this.input); + } + return this.input[this.options.inputName]; + } + /** + * Set the keyboard’s input. + * @param {string} input the input value + * @param {string} inputName optional - the internal input to select + */ }, { + key: "setInput", + value: function setInput(input, inputName) { + inputName = inputName || this.options.inputName; + this.input[inputName] = input; + /** + * Enforce syncInstanceInputs, if set + */ if (this.options.syncInstanceInputs) { + this.syncInstanceInputs(this.input); + } + } + /** + * Replace the input object (`keyboard.input`) + * @param {object} inputObj The input object + */ }, { + key: "replaceInput", + value: function replaceInput(inputObj) { + this.input = inputObj; + } + /** + * Set new option or modify existing ones after initialization. + * @param {object} option The option to set + */ }, { + key: "clear", + /** + * Remove all keyboard rows and reset keyboard values. + * Used interally between re-renders. + */ value: function clear() { + this.keyboardDOM.innerHTML = ""; + this.keyboardDOM.className = this.keyboardDOMClass; + this.buttonElements = {}; + } + /** + * Send a command to all simple-keyboard instances at once (if you have multiple instances). + * @param {function(instance: object, key: string)} callback Function to run on every instance + */ }, { + key: "dispatch", + value: function dispatch(callback) { + if (!window["SimpleKeyboardInstances"]) { + console.warn("SimpleKeyboardInstances is not defined. Dispatch cannot be called."); + throw new Error("INSTANCES_VAR_ERROR"); + } + return Object.keys(window["SimpleKeyboardInstances"]).forEach(function(key) { + callback(window["SimpleKeyboardInstances"][key], key); + }); + } + /** + * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button. + * @param {string} buttons List of buttons to select (separated by a space). + * @param {string} className Classes to give to the selected buttons (separated by space). + */ }, { + key: "addButtonTheme", + value: function addButtonTheme(buttons, className) { + var _this5 = this; + if (!className || !buttons) { + return false; + } + buttons.split(" ").forEach(function(button) { + className.split(" ").forEach(function(classNameItem) { + if (!_this5.options.buttonTheme) { + _this5.options.buttonTheme = []; + } + var classNameFound = false; + /** + * If class is already defined, we add button to class definition + */ _this5.options.buttonTheme.map(function(buttonTheme) { + if (buttonTheme.class.split(" ").includes(classNameItem)) { + classNameFound = true; + var buttonThemeArray = buttonTheme.buttons.split(" "); + if (!buttonThemeArray.includes(button)) { + classNameFound = true; + buttonThemeArray.push(button); + buttonTheme.buttons = buttonThemeArray.join(" "); + } + } + return buttonTheme; + }); + /** + * If class is not defined, we create a new entry + */ if (!classNameFound) { + _this5.options.buttonTheme.push({ + class: classNameItem, + buttons: buttons + }); + } + }); + }); + this.render(); + } + /** + * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme. + * @param {string} buttons List of buttons to select (separated by a space). + * @param {string} className Classes to give to the selected buttons (separated by space). + */ }, { + key: "removeButtonTheme", + value: function removeButtonTheme(buttons, className) { + var _this6 = this; + /** + * When called with empty parameters, remove all button themes + */ if (!buttons && !className) { + this.options.buttonTheme = []; + this.render(); + return false; + } + /** + * If buttons are passed and buttonTheme has items + */ if (buttons && Array.isArray(this.options.buttonTheme) && this.options.buttonTheme.length) { + var buttonArray = buttons.split(" "); + buttonArray.forEach(function(button, key) { + _this6.options.buttonTheme.map(function(buttonTheme, index) { + /** + * If className is set, we affect the buttons only for that class + * Otherwise, we afect all classes + */ if (className && className.includes(buttonTheme.class) || !className) { + var filteredButtonArray = buttonTheme.buttons.split(" ").filter(function(item) { + return item !== button; + }); + /** + * If buttons left, return them, otherwise, remove button Theme + */ if (filteredButtonArray.length) { + buttonTheme.buttons = filteredButtonArray.join(" "); + } else { + _this6.options.buttonTheme.splice(index, 1); + buttonTheme = null; + } + } + return buttonTheme; + }); + }); + this.render(); + } + } + /** + * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned. + * @param {string} button The button layout name to select + */ }, { + key: "getButtonElement", + value: function getButtonElement(button) { + var output; + var buttonArr = this.buttonElements[button]; + if (buttonArr) { + if (buttonArr.length > 1) { + output = buttonArr; + } else { + output = buttonArr[0]; + } + } + return output; + } + /** + * This handles the "inputPattern" option + * by checking if the provided inputPattern passes + */ }, { + key: "inputPatternIsValid", + value: function inputPatternIsValid(inputVal) { + var inputPatternRaw = this.options.inputPattern; + var inputPattern; + /** + * Check if input pattern is global or targeted to individual inputs + */ if (inputPatternRaw instanceof RegExp) { + inputPattern = inputPatternRaw; + } else { + inputPattern = inputPatternRaw[this.options.inputName]; + } + if (inputPattern && inputVal) { + var didInputMatch = inputPattern.test(inputVal); + if (this.options.debug) { + console.log('inputPattern ("'.concat(inputPattern, '"): ').concat(didInputMatch ? "passed" : "did not pass!")); + } + return didInputMatch; + } else { + /** + * inputPattern doesn't seem to be set for the current input, or input is empty. Pass. + */ return true; + } + } + /** + * Retrieves the current cursor position within a input or textarea (if any) + */ }, { + key: "handleCaret", + value: function handleCaret() { + /** + * Only first instance should insall the caret handling events + */ this.caretPosition = null; + var simpleKeyboardInstances = window["SimpleKeyboardInstances"]; + if (simpleKeyboardInstances && Object.keys(simpleKeyboardInstances)[0] === this.utilities.camelCase(this.keyboardDOMClass) || !simpleKeyboardInstances) { + if (this.options.debug) { + console.log("Caret handling started (".concat(this.keyboardDOMClass, ")")); + } + document.addEventListener("keyup", this.caretEventHandler); + document.addEventListener("mouseup", this.caretEventHandler); + document.addEventListener("touchend", this.caretEventHandler); + } + } + /** + * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered + */ }, { + key: "caretEventHandler", + value: function caretEventHandler(event) { + var targetTagName; + if (event.target.tagName) { + targetTagName = event.target.tagName.toLowerCase(); + } + this.dispatch(function(instance) { + if (instance.isMouseHold) { + instance.isMouseHold = false; + } + if ((targetTagName === "textarea" || targetTagName === "input") && !instance.options.disableCaretPositioning) { + /** + * Tracks current cursor position + * As keys are pressed, text will be added/removed at that position within the input. + */ instance.caretPosition = event.target.selectionStart; + if (instance.options.debug) { + console.log("Caret at: ", event.target.selectionStart, event.target.tagName.toLowerCase(), "(".concat(instance.keyboardDOMClass, ")")); + } + } else if (instance.options.disableCaretPositioning) { + /** + * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated. + */ instance.caretPosition = null; + } + }); + } + /** + * Executes the callback function once simple-keyboard is rendered for the first time (on initialization). + */ }, { + key: "onInit", + value: function onInit() { + if (this.options.debug) { + console.log("".concat(this.keyboardDOMClass, " Initialized")); + } + /** + * Caret handling + */ this.handleCaret(); + if (typeof this.options.onInit === "function") { + this.options.onInit(); + } + } + /** + * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts). + */ }, { + key: "onRender", + value: function onRender() { + if (typeof this.options.onRender === "function") { + this.options.onRender(); + } + } + /** + * Executes the callback function once all modules have been loaded + */ }, { + key: "onModulesLoaded", + value: function onModulesLoaded() { + if (typeof this.options.onModulesLoaded === "function") { + this.options.onModulesLoaded(); + } + } + /** + * Register module + */ }, { + key: "loadModules", + /** + * Load modules + */ value: function loadModules() { + 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(_this7.utilities.camelCase(module.constructor.name)); + _this7.keyboardPluginClasses = _this7.keyboardPluginClasses + " ".concat(classStr); + } + module.init(_this7); + }); + this.keyboardPluginClasses = this.keyboardPluginClasses + " modules-loaded"; + this.render(); + this.onModulesLoaded(); + } + } + /** + * Get module prop + */ }, { + key: "render", + /** + * Renders rows and buttons as per options + */ value: function render() { + var _this8 = this; + /** + * Clear keyboard + */ this.clear(); + var layoutClass = "hg-layout-".concat(this.options.layoutName); + var layout = this.options.layout || services_KeyboardLayout.getDefaultLayout(); + var useTouchEvents = this.options.useTouchEvents || false; + /** + * Account for buttonTheme, if set + */ var buttonThemesParsed = {}; + if (Array.isArray(this.options.buttonTheme)) { + this.options.buttonTheme.forEach(function(themeObj) { + if (themeObj.buttons && themeObj.class) { + var themeButtons; + if (typeof themeObj.buttons === "string") { + themeButtons = themeObj.buttons.split(" "); + } + if (themeButtons) { + themeButtons.forEach(function(themeButton) { + var themeParsed = buttonThemesParsed[themeButton]; + // If the button has already been added + if (themeParsed) { + // Making sure we don't add duplicate classes, even when buttonTheme has duplicates + if (!_this8.utilities.countInArray(themeParsed.split(" "), themeObj.class)) { + buttonThemesParsed[themeButton] = "".concat(themeParsed, " ").concat(themeObj.class); + } + } else { + buttonThemesParsed[themeButton] = themeObj.class; + } + }); + } + } else { + console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.'); + } + }); + } + /** + * Adding themeClass, layoutClass to keyboardDOM + */ this.keyboardDOM.className += " ".concat(this.options.theme, " ").concat(layoutClass, " ").concat(this.keyboardPluginClasses); + /** + * Iterating through each row + */ layout[this.options.layoutName].forEach(function(row, rIndex) { + var rowArray = row.split(" "); + /** + * Creating empty row + */ var rowDOM = document.createElement("div"); + rowDOM.className += "hg-row"; + /** + * Iterating through each button in row + */ rowArray.forEach(function(button, bIndex) { + var fctBtnClass = _this8.utilities.getButtonClass(button); + var buttonThemeClass = buttonThemesParsed[button]; + var buttonDisplayName = _this8.utilities.getButtonDisplayName(button, _this8.options.display, _this8.options.mergeDisplay); + /** + * Creating button + */ var buttonType = _this8.options.useButtonTag ? "button" : "div"; + var buttonDOM = document.createElement(buttonType); + buttonDOM.className += "hg-button ".concat(fctBtnClass).concat(buttonThemeClass ? " " + buttonThemeClass : ""); + if (useTouchEvents) { + buttonDOM.ontouchstart = function(e) { + _this8.handleButtonClicked(button); + _this8.handleButtonMouseDown(button, e); + }; + buttonDOM.ontouchend = function(e) { + return _this8.handleButtonMouseUp(); + }; + buttonDOM.ontouchcancel = function(e) { + return _this8.handleButtonMouseUp(); + }; + } else { + buttonDOM.onclick = function() { + _this8.isMouseHold = false; + _this8.handleButtonClicked(button); + }; + buttonDOM.onmousedown = function(e) { + if (_this8.options.preventMouseDownDefault) { + e.preventDefault(); + } + _this8.handleButtonMouseDown(button, e); + }; + } + /** + * Adding identifier + */ buttonDOM.setAttribute("data-skBtn", button); + /** + * Adding unique id + * Since there's no limit on spawning same buttons, the unique id ensures you can style every button + */ var buttonUID = "".concat(_this8.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 (!_this8.buttonElements[button]) { + _this8.buttonElements[button] = []; + } + _this8.buttonElements[button].push(buttonDOM); + /** + * Appending button to row + */ rowDOM.appendChild(buttonDOM); + }); + /** + * Appending row to keyboard + */ _this8.keyboardDOM.appendChild(rowDOM); + }); + /** + * Calling onRender + */ this.onRender(); + if (!this.initialized) { + /** + * Ensures that onInit is only called once per instantiation + */ this.initialized = true; + /** + * Handling mouseup + */ if (!useTouchEvents) { + document.onmouseup = function() { + return _this8.handleButtonMouseUp(); + }; + } + /** + * Calling onInit + */ this.onInit(); + } + } + } ]); + return SimpleKeyboard; + }(); + /* harmony default export */ var components_Keyboard = Keyboard_SimpleKeyboard; + // CONCATENATED MODULE: ./src/lib/index.js + /* harmony default export */ var lib = __webpack_exports__["default"] = components_Keyboard; + /***/ } + /******/ ]); +}); \ No newline at end of file diff --git a/config/webpack.config.unminified.js b/config/webpack.config.unminified.js new file mode 100644 index 00000000..994ee554 --- /dev/null +++ b/config/webpack.config.unminified.js @@ -0,0 +1,504 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const webpack = require('webpack'); +const resolve = require('resolve'); +const PnpWebpackPlugin = require('pnp-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); +const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); +const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent'); +const paths = require('./paths'); +const getClientEnvironment = require('./env'); +const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin-alt'); +const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); +const getPackageJson = require('./getPackageJson'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); + + +// Webpack uses `publicPath` to determine where the app is being served from. +// It requires a trailing slash, or the file assets will get an incorrect path. +const publicPath = paths.servedPath; +// Some apps do not use client-side routing with pushState. +// For these, "homepage" can be set to "." to enable relative asset paths. +const shouldUseRelativeAssetPaths = publicPath === './'; +// Source maps are resource heavy and can cause out of memory issue for large source files. +const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; +// Some apps do not need the benefits of saving a web request, so not inlining the chunk +// makes for a smoother build process. +const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false'; +// `publicUrl` is just like `publicPath`, but we will provide it to our app +// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. +// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz. +const publicUrl = publicPath.slice(0, -1); +// Get environment variables to inject into our app. +const env = getClientEnvironment(publicUrl); + +// Check if TypeScript is setup +const useTypeScript = fs.existsSync(paths.appTsConfig); + +// style files regexes +const cssRegex = /\.css$/; +const cssModuleRegex = /\.module\.css$/; +const sassRegex = /\.(scss|sass)$/; +const sassModuleRegex = /\.module\.(scss|sass)$/; + +const { + version, + name, + license, + repository, + author, +} = getPackageJson('version', 'name', 'license', 'repository', 'author'); + +const banner = ` + ${name} v${version} (Non-minified build) + ${repository.url} + + Copyright (c) ${author.replace(/ *\<[^)]*\> */g, " ")} + + This source code is licensed under a dual license system ${license}, as found in the + LICENSE file in the root directory of this source tree. + `; + +// common function to get style loaders +const getStyleLoaders = (cssOptions, preProcessor) => { + const loaders = [ + { + loader: MiniCssExtractPlugin.loader, + options: Object.assign( + {}, + shouldUseRelativeAssetPaths ? { publicPath: '../../' } : undefined + ), + }, + { + loader: require.resolve('css-loader'), + options: cssOptions, + }, + { + // Options for PostCSS as we reference these options twice + // Adds vendor prefixing based on your specified browser support in + // package.json + loader: require.resolve('postcss-loader'), + options: { + // Necessary for external CSS imports to work + // https://github.com/facebook/create-react-app/issues/2677 + ident: 'postcss', + plugins: () => [ + require('postcss-flexbugs-fixes'), + require('postcss-preset-env')({ + autoprefixer: { + flexbox: 'no-2009', + }, + stage: 3, + }), + ], + sourceMap: shouldUseSourceMap, + }, + }, + ]; + if (preProcessor) { + loaders.push({ + loader: require.resolve(preProcessor), + options: { + sourceMap: shouldUseSourceMap, + }, + }); + } + return loaders; +}; + +// This is the production configuration. +// It compiles slowly and is focused on producing a fast and minimal bundle. +// The development configuration is different and lives in a separate file. +module.exports = { + mode: 'production', + // Don't attempt to continue if there are any errors. + bail: true, + // We generate sourcemaps in production. This is slow but gives good results. + // You can exclude the *.map files from the build during deployment. + devtool: false, + // In production, we only want to load the app code. + entry: [paths.appLibIndexJs], + output: { + // The build folder. + path: paths.appBuild, + // Generated JS file names (with nested folders). + // There will be one main bundle, and one file per asynchronous chunk. + // We don't currently advertise code splitting but Webpack supports it. + filename: 'simple-keyboard.js', + chunkFilename: 'index.[chunkhash:8].chunk.js', + // We inferred the "public path" (such as / or /my-project) from homepage. + publicPath: publicPath, + library: "SimpleKeyboard", + libraryTarget: 'umd', + umdNamedDefine: true, + // Point sourcemap entries to original disk location (format as URL on Windows) + devtoolModuleFilenameTemplate: info => + path + .relative(paths.appSrcLib, info.absoluteResourcePath) + .replace(/\\/g, '/'), + }, + optimization: { + minimizer: [ + // we specify a custom UglifyJsPlugin here to get source maps in production + new UglifyJsPlugin({ + cache: false, + parallel: false, + uglifyOptions: { + output: { + comments: true, + beautify: true, + braces: true, + indent_level: 2 + }, + mangle: false, + compress: false + }, + sourceMap: false + }), + new webpack.BannerPlugin({ + banner: banner, + entryOnly: true + }) + ] + }, + resolve: { + // This allows you to set a fallback for where Webpack should look for modules. + // We placed these paths second because we want `node_modules` to "win" + // if there are any conflicts. This matches Node resolution mechanism. + // https://github.com/facebook/create-react-app/issues/253 + modules: ['node_modules'].concat( + // It is guaranteed to exist because we tweak it in `env.js` + process.env.NODE_PATH.split(path.delimiter).filter(Boolean) + ), + // These are the reasonable defaults supported by the Node ecosystem. + // We also include JSX as a common component filename extension to support + // some tools, although we do not recommend using it, see: + // https://github.com/facebook/create-react-app/issues/290 + // `web` extension prefixes have been added for better support + // for React Native Web. + extensions: paths.moduleFileExtensions + .map(ext => `.${ext}`) + .filter(ext => useTypeScript || !ext.includes('ts')), + alias: { + // Support React Native Web + // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ + 'react-native': 'react-native-web', + }, + plugins: [ + // Adds support for installing with Plug'n'Play, leading to faster installs and adding + // guards against forgotten dependencies and such. + PnpWebpackPlugin, + // Prevents users from importing files from outside of src/ (or node_modules/). + // This often causes confusion because we only process files within src/ with babel. + // To fix this, we prevent you from importing files out of src/ -- if you'd like to, + // please link the files into your node_modules/ and let module-resolution kick in. + // Make sure your source files are compiled, as they will not be processed in any way. + new ModuleScopePlugin(paths.appSrcLib, [paths.appPackageJson]), + ], + }, + resolveLoader: { + plugins: [ + // Also related to Plug'n'Play, but this time it tells Webpack to load its loaders + // from the current package. + PnpWebpackPlugin.moduleLoader(module), + ], + }, + module: { + strictExportPresence: true, + rules: [ + // Disable require.ensure as it's not a standard language feature. + { parser: { requireEnsure: false } }, + + // First, run the linter. + // It's important to do this before Babel processes the JS. + { + test: /\.(js|mjs|jsx)$/, + enforce: 'pre', + use: [ + { + options: { + formatter: require.resolve('react-dev-utils/eslintFormatter'), + eslintPath: require.resolve('eslint'), + + }, + loader: require.resolve('eslint-loader'), + }, + ], + include: paths.appSrcLib, + }, + { + // "oneOf" will traverse all following loaders until one will + // match the requirements. When no loader matches it will fall + // back to the "file" loader at the end of the loader list. + oneOf: [ + // "url" loader works just like "file" loader but it also embeds + // assets smaller than specified size as data URLs to avoid requests. + { + test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], + loader: require.resolve('url-loader'), + options: { + limit: 10000, + name: 'static/media/[name].[hash:8].[ext]', + }, + }, + // Process application JS with Babel. + // The preset includes JSX, Flow, TypeScript and some ESnext features. + { + test: /\.(js|mjs|jsx|ts|tsx)$/, + include: paths.appSrcLib, + + loader: require.resolve('babel-loader'), + options: { + customize: require.resolve( + 'babel-preset-react-app/webpack-overrides' + ), + + plugins: [ + [ + require.resolve('babel-plugin-named-asset-import'), + { + loaderMap: { + svg: { + ReactComponent: '@svgr/webpack?-prettier,-svgo![path]', + }, + }, + }, + ], + ], + cacheDirectory: true, + // Save disk space when time isn't as important + cacheCompression: true, + compact: true, + }, + }, + // Process any JS outside of the app with Babel. + // Unlike the application JS, we only compile the standard ES features. + { + test: /\.(js|mjs)$/, + exclude: /@babel(?:\/|\\{1,2})runtime/, + loader: require.resolve('babel-loader'), + options: { + babelrc: false, + configFile: false, + compact: false, + presets: [ + [ + require.resolve('babel-preset-react-app/dependencies'), + { helpers: true }, + ], + ], + cacheDirectory: true, + // Save disk space when time isn't as important + cacheCompression: true, + + // If an error happens in a package, it's possible to be + // because it was compiled. Thus, we don't want the browser + // debugger to show the original code. Instead, the code + // being evaluated would be much more helpful. + sourceMaps: false, + }, + }, + // "postcss" loader applies autoprefixer to our CSS. + // "css" loader resolves paths in CSS and adds assets as dependencies. + // `MiniCSSExtractPlugin` extracts styles into CSS + // files. If you use code splitting, async bundles will have their own separate CSS chunk file. + // By default we support CSS Modules with the extension .module.css + { + test: cssRegex, + exclude: cssModuleRegex, + loader: getStyleLoaders({ + importLoaders: 1, + sourceMap: shouldUseSourceMap, + }), + // Don't consider CSS imports dead code even if the + // containing package claims to have no side effects. + // Remove this when webpack adds a warning or an error for this. + // See https://github.com/webpack/webpack/issues/6571 + sideEffects: true, + }, + // Adds support for CSS Modules (https://github.com/css-modules/css-modules) + // using the extension .module.css + { + test: cssModuleRegex, + loader: getStyleLoaders({ + importLoaders: 1, + sourceMap: shouldUseSourceMap, + modules: true, + getLocalIdent: getCSSModuleLocalIdent, + }), + }, + // Opt-in support for SASS. The logic here is somewhat similar + // as in the CSS routine, except that "sass-loader" runs first + // to compile SASS files into CSS. + // By default we support SASS Modules with the + // extensions .module.scss or .module.sass + { + test: sassRegex, + exclude: sassModuleRegex, + loader: getStyleLoaders( + { + importLoaders: 2, + sourceMap: shouldUseSourceMap, + }, + 'sass-loader' + ), + // Don't consider CSS imports dead code even if the + // containing package claims to have no side effects. + // Remove this when webpack adds a warning or an error for this. + // See https://github.com/webpack/webpack/issues/6571 + sideEffects: true, + }, + // Adds support for CSS Modules, but using SASS + // using the extension .module.scss or .module.sass + { + test: sassModuleRegex, + loader: getStyleLoaders( + { + importLoaders: 2, + sourceMap: shouldUseSourceMap, + modules: true, + getLocalIdent: getCSSModuleLocalIdent, + }, + 'sass-loader' + ), + }, + // "file" loader makes sure assets end up in the `build` folder. + // When you `import` an asset, you get its filename. + // This loader doesn't use a "test" so it will catch all modules + // that fall through the other loaders. + { + loader: require.resolve('file-loader'), + // Exclude `js` files to keep "css" loader working as it injects + // it's runtime that would otherwise be processed through "file" loader. + // Also exclude `html` and `json` extensions so they get processed + // by webpacks internal loaders. + exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], + options: { + name: 'static/media/[name].[hash:8].[ext]', + }, + }, + // ** STOP ** Are you adding a new loader? + // Make sure to add the new loader(s) before the "file" loader. + ], + }, + ], + }, + plugins: [ + // Generates an `index.html` file with the