diff --git a/.esdoc.json b/.esdoc.json deleted file mode 100644 index 5f2bc385..00000000 --- a/.esdoc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "source": "./src", - "destination": "./docs", - "plugins": [ - {"name": "esdoc-standard-plugin"}, - {"name": "esdoc-ecmascript-proposal-plugin", "option": {"all": true}} - ] -} \ No newline at end of file diff --git a/.npmignore b/.npmignore index a102e46d..a5c3b097 100644 --- a/.npmignore +++ b/.npmignore @@ -19,7 +19,6 @@ yarn-debug.log* yarn-error.log* /.github /demo -.esdoc.json # Development folders and files public diff --git a/.travis.yml b/.travis.yml index 5fc7428e..bb3e29d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ install: script: - npm run start -- --testMode - npm run demo -- npm run test -- --coverage +- npm run coverage - codecov after_success: - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh diff --git a/README.md b/README.md index e3490f8e..38a92f14 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Build Status Coverage Status - Documentation Status Codacy Badge

diff --git a/build/css/index.css b/build/css/index.css index aa56f540..61ff80cf 100644 --- a/build/css/index.css +++ b/build/css/index.css @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.20.9 + * simple-keyboard v2.21.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 5aacfa45..681c2a6d 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/Keyboard.css","Keyboard.css"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG,ACVH,UAEE,SAAA,AACA,SAAA,CCCF,ADEA,iBACE,6GCC+C,ADC/C,WAAA,AACA,yBAAA,sBAAA,qBAAA,iBAAA,AACA,sBAAA,AACA,gBAAA,AACA,yBAAA,CCIF,ADDA,yBACE,qBAAA,YAAA,CCKF,ADFA,0CACE,iBAAA,CCKF,ADEA,mGACE,gBAAA,CCKF,ADFA,wCACE,cAAA,CCKF,ADFA,8CACE,qBAAA,YAAA,CCMF,ADHA,4BACE,qBAAA,AACA,oBAAA,YAAA,AACA,cAAA,CCOF,ADJA,iCACE,mBAAA,CCOF,ADDA,kCACE,gCAAA,AACA,YAAA,AACA,iBAAA,CCOF,ADJA,6CACE,uCAAA,AACA,YAAA,AACA,kBAAA,AACA,sBAAA,AACA,YAAA,AACA,gBAAA,AACA,gCAAA,AACA,eAAA,AACA,qBAAA,aAAA,AACA,2BAAA,mBAAA,AACA,+BAAA,sBAAA,CCUF,ADNA,kCACE,eAAA,AACA,UAAA,AACA,iBAAA,CCUF,ADPA,0EACE,kBAAA,CCUF,ADPA,+DACE,YAAA,AACA,YAAA,AACA,2BAAA,mBAAA,AACA,qBAAA,aAAA,AACA,+BAAA,sBAAA,CCaF,ADNA,oIACE,WAAA,CCaF,ADVA,+DACE,WAAA,CCaF,ADVA,2DACE,cAAA,CCaF,ADVA,yEACE,cAAA,CCaF,ADVA,+DACE,6BAAA,AACA,UAAA,CCaF,ADVA,+EACE,cAAA,CCaF,ADVA,4EACE,cAAA,CCaF","file":"index.css","sourcesContent":["/*!\n * \n * simple-keyboard v2.20.9\n * https://github.com/hodgef/simple-keyboard\n * \n * Copyright (c) Francisco Hodge (https://github.com/hodgef)\n * \n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n * \n */\nbody,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n -webkit-flex-grow: 1;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n -webkit-justify-content: 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:not(.hg-touch-events) .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 -webkit-align-items: center;\r\n align-items: center;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-justify-content: center;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n\n","body,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n/* When using option \"useButtonTag\" */\r\n.simple-keyboard button.hg-button {\r\n border-width: 0;\r\n outline: 0;\r\n font-size: inherit;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default:not(.hg-touch-events) .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","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 -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: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n -webkit-flex-grow: 1;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n -webkit-justify-content: 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:not(.hg-touch-events) .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 -webkit-align-items: center;\r\n align-items: center;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-justify-content: center;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["index.css","X:/Dev/simple-keyboard/src/lib/components/Keyboard.css","Keyboard.css"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG,ACVH,UAEE,SAAA,AACA,SAAA,CCCF,ADEA,iBACE,6GCC+C,ADC/C,WAAA,AACA,yBAAA,sBAAA,qBAAA,iBAAA,AACA,sBAAA,AACA,gBAAA,AACA,yBAAA,CCIF,ADDA,yBACE,qBAAA,YAAA,CCKF,ADFA,0CACE,iBAAA,CCKF,ADEA,mGACE,gBAAA,CCKF,ADFA,wCACE,cAAA,CCKF,ADFA,8CACE,qBAAA,YAAA,CCMF,ADHA,4BACE,qBAAA,AACA,oBAAA,YAAA,AACA,cAAA,CCOF,ADJA,iCACE,mBAAA,CCOF,ADDA,kCACE,gCAAA,AACA,YAAA,AACA,iBAAA,CCOF,ADJA,6CACE,uCAAA,AACA,YAAA,AACA,kBAAA,AACA,sBAAA,AACA,YAAA,AACA,gBAAA,AACA,gCAAA,AACA,eAAA,AACA,qBAAA,aAAA,AACA,2BAAA,mBAAA,AACA,+BAAA,sBAAA,CCUF,ADNA,kCACE,eAAA,AACA,UAAA,AACA,iBAAA,CCUF,ADPA,0EACE,kBAAA,CCUF,ADPA,+DACE,YAAA,AACA,YAAA,AACA,2BAAA,mBAAA,AACA,qBAAA,aAAA,AACA,+BAAA,sBAAA,CCaF,ADNA,oIACE,WAAA,CCaF,ADVA,+DACE,WAAA,CCaF,ADVA,2DACE,cAAA,CCaF,ADVA,yEACE,cAAA,CCaF,ADVA,+DACE,6BAAA,AACA,UAAA,CCaF,ADVA,+EACE,cAAA,CCaF,ADVA,4EACE,cAAA,CCaF","file":"index.css","sourcesContent":["/*!\n * \n * simple-keyboard v2.21.0\n * https://github.com/hodgef/simple-keyboard\n * \n * Copyright (c) Francisco Hodge (https://github.com/hodgef)\n * \n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n * \n */\nbody,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n -webkit-flex-grow: 1;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n -webkit-justify-content: 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:not(.hg-touch-events) .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 -webkit-align-items: center;\r\n align-items: center;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-justify-content: center;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n\n","body,\r\nhtml {\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n.simple-keyboard {\r\n font-family: \"HelveticaNeue-Light\", \"Helvetica Neue Light\", \"Helvetica Neue\",\r\n Helvetica, Arial, \"Lucida Grande\", sans-serif;\r\n width: 100%;\r\n user-select: none;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n touch-action: manipulation;\r\n}\r\n\r\n.simple-keyboard .hg-row {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n/* When using option \"useButtonTag\" */\r\n.simple-keyboard button.hg-button {\r\n border-width: 0;\r\n outline: 0;\r\n font-size: inherit;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default:not(.hg-touch-events) .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","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 -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: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-row:not(:last-child) {\r\n margin-bottom: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button:not(:last-child) {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n margin-right: 5px;\r\n}\r\n\r\n.simple-keyboard .hg-row > div:last-child {\r\n margin-right: 0;\r\n}\r\n\r\n.simple-keyboard .hg-row .hg-button-container {\r\n display: -webkit-flex;\r\n display: flex;\r\n}\r\n\r\n.simple-keyboard .hg-button {\r\n display: inline-block;\r\n -webkit-flex-grow: 1;\r\n flex-grow: 1;\r\n cursor: pointer;\r\n}\r\n\r\n.simple-keyboard .hg-button span {\r\n pointer-events: none;\r\n}\r\n\r\n/**\r\n * hg-theme-default theme\r\n */\r\n.simple-keyboard.hg-theme-default {\r\n background-color: rgba(0, 0, 0, 0.1);\r\n padding: 5px;\r\n border-radius: 5px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button {\r\n box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);\r\n height: 40px;\r\n border-radius: 5px;\r\n box-sizing: border-box;\r\n padding: 5px;\r\n background: white;\r\n border-bottom: 1px solid #b5b5b5;\r\n cursor: pointer;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n -webkit-justify-content: 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:not(.hg-touch-events) .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 -webkit-align-items: center;\r\n align-items: center;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-justify-content: center;\r\n justify-content: center;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {\r\n height: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {\r\n width: 105px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-button-com {\r\n max-width: 85px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {\r\n max-width: 45px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {\r\n background: rgba(5, 25, 70, 0.53);\r\n color: white;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\".com\"] {\r\n max-width: 82px;\r\n}\r\n\r\n.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\"@\"] {\r\n max-width: 60px;\r\n}\r\n"]} \ No newline at end of file diff --git a/build/css/simple-keyboard.css b/build/css/simple-keyboard.css index a40ad6cb..f6fb868e 100644 --- a/build/css/simple-keyboard.css +++ b/build/css/simple-keyboard.css @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.20.9 (Non-minified build) + * simple-keyboard v2.21.0 (Non-minified build) * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) @@ -8,141 +8,4 @@ * This source code is licensed under the MIT license 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: -webkit-flex; - 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-row .hg-button-container { - margin-right: 5px; -} - -.simple-keyboard .hg-row > div:last-child { - margin-right: 0; -} - -.simple-keyboard .hg-row .hg-button-container { - display: -webkit-flex; - display: flex; -} - -.simple-keyboard .hg-button { - display: inline-block; - -webkit-flex-grow: 1; - flex-grow: 1; - cursor: pointer; -} - -.simple-keyboard .hg-button span { - pointer-events: none; -} - -/** - * 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: -webkit-flex; - display: flex; - -webkit-align-items: center; - align-items: center; - -webkit-justify-content: 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:not(.hg-touch-events) .hg-button:active { - background: #e4e4e4; -} - -.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button { - width: 33.3%; - height: 60px; - -webkit-align-items: center; - align-items: center; - display: -webkit-flex; - display: flex; - -webkit-justify-content: center; - 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; -} - + */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:-webkit-flex;display:flex}.simple-keyboard .hg-row:not(:last-child){margin-bottom:5px}.simple-keyboard .hg-row .hg-button-container,.simple-keyboard .hg-row .hg-button:not(:last-child){margin-right:5px}.simple-keyboard .hg-row>div:last-child{margin-right:0}.simple-keyboard .hg-row .hg-button-container{display:-webkit-flex;display:flex}.simple-keyboard .hg-button{display:inline-block;-webkit-flex-grow:1;flex-grow:1;cursor:pointer}.simple-keyboard .hg-button span{pointer-events:none}.simple-keyboard.hg-theme-default{background-color:rgba(0,0,0,.1);padding:5px;border-radius:5px}.simple-keyboard.hg-theme-default .hg-button{box-shadow:0 0 3px -1px rgba(0,0,0,.3);height:40px;border-radius:5px;box-sizing:border-box;padding:5px;background:#fff;border-bottom:1px solid #b5b5b5;cursor:pointer;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.simple-keyboard button.hg-button{border-width:0;outline:0;font-size:inherit}.simple-keyboard.hg-theme-default:not(.hg-touch-events) .hg-button:active{background:#e4e4e4}.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;-webkit-align-items:center;align-items:center;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd,.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,.53);color:#fff}.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} \ No newline at end of file diff --git a/build/index.js b/build/index.js index ae7d65d9..7acf39b2 100644 --- a/build/index.js +++ b/build/index.js @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.20.9 + * simple-keyboard v2.21.0 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) @@ -9,5 +9,5 @@ * LICENSE file in the root directory of this source tree. * */ -!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define("SimpleKeyboard",[],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(2)},function(t,e,n){},function(t,e,n){"use strict";n.r(e);n(1);function o(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}],(n=null)&&s(e.prototype,n),o&&s(e,o),t}();function u(t){return(u="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){for(var n=0;n0?s=this.removeAt(s,o,i):"{space}"===t?s=this.addStringAt(s," ",o,i):"{tab}"!==t||"boolean"===typeof n.tabCharOnTab&&!1===n.tabCharOnTab?"{enter}"!==t&&"{numpadenter}"!==t||!n.newLineOnEnter?t.includes("numpad")&&Number.isInteger(Number(t[t.length-2]))?s=this.addStringAt(s,t[t.length-2],o,i):"{numpaddivide}"===t?s=this.addStringAt(s,"/",o,i):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",o,i):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",o,i):"{numpadadd}"===t?s=this.addStringAt(s,"+",o,i):"{numpaddecimal}"===t?s=this.addStringAt(s,".",o,i):"{"===t||"}"===t?s=this.addStringAt(s,t,o,i):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,o,i)):s=this.addStringAt(s,"\n",o,i):s=this.addStringAt(s,"\t",o,i),s}},{key:"updateCaretPos",value:function(t,e){var n=this.updateCaretPosAction(this.simpleKeyboardInstance,t,e);this.simpleKeyboardInstance.options.syncInstanceInputs&&this.simpleKeyboardInstance.dispatch(function(t){t.caretPosition=n})}},{key:"updateCaretPosAction",value:function(t,e,n){return n?t.caretPosition>0&&(t.caretPosition=t.caretPosition-e):t.caretPosition=t.caretPosition+e,this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",t.caretPosition,"(".concat(t.keyboardDOMClass,")")),t.caretPosition}},{key:"addStringAt",value:function(t,e,n,o){var i;return n||0===n?(i=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||o&&this.updateCaretPos(e.length)):i=t+e,i}},{key:"removeAt",value:function(t,e,n){if(0===this.simpleKeyboardInstance.caretPosition)return t;var o,i=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?t.substring(e-2,e).match(i)?(o=t.substr(0,e-2)+t.substr(e),n&&this.updateCaretPos(2,!0)):(o=t.substr(0,e-1)+t.substr(e),n&&this.updateCaretPos(1,!0)):t.slice(-2).match(i)?(o=t.slice(0,-2),n&&this.updateCaretPos(2,!0)):(o=t.slice(0,-1),n&&this.updateCaretPos(1,!0)),o}},{key:"handleMaxLength",value:function(t,e,n){var o=e.maxLength,i=t[e.inputName],s=i.length===o;if(n.length<=i.length)return!1;if(Number.isInteger(o))return e.debug&&console.log("maxLength (num) reached:",s),s?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===u(o)){var a=i.length===o[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return Boolean(this.maxLengthReached)}},{key:"isTouchDevice",value:function(){return"ontouchstart"in window||navigator.maxTouchPoints}},{key:"pointerEventsSupported",value:function(){return window.PointerEvent}},{key:"camelCase",value:function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return e.length?t+e[0].toUpperCase()+e.slice(1):t})}},{key:"countInArray",value:function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)}}])&&r(e.prototype,n),o&&r(e,o),t}();function l(t){return(l="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){for(var n=0;n1?n:n[0]),e}},{key:"inputPatternIsValid",value:function(t){var e,n=this.options.inputPattern;if((e=n instanceof RegExp?n:n[this.options.inputName])&&t){var o=e.test(t);return this.options.debug&&console.log('inputPattern ("'.concat(e,'"): ').concat(o?"passed":"did not pass!")),o}return!0}},{key:"handleCaret",value:function(){this.caretPosition=null;var t=window.SimpleKeyboardInstances;(t&&Object.keys(t)[0]===this.utilities.camelCase(this.keyboardDOMClass)||!t)&&(this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")")),document.addEventListener("keyup",this.caretEventHandler),document.addEventListener("mouseup",this.caretEventHandler),document.addEventListener("touchend",this.caretEventHandler))}},{key:"caretEventHandler",value:function(t){var e;t.target.tagName&&(e=t.target.tagName.toLowerCase()),this.dispatch(function(n){n.isMouseHold&&(n.isMouseHold=!1),"textarea"!==e&&"input"!==e||n.options.disableCaretPositioning?n.options.disableCaretPositioning&&(n.caretPosition=null):(n.caretPosition=t.target.selectionStart,n.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase(),"(".concat(n.keyboardDOMClass,")")))})}},{key:"getButtonTheme",value:function(){var t=this,e={};return this.options.buttonTheme.forEach(function(n){var o;n.buttons&&n.class?("string"===typeof n.buttons&&(o=n.buttons.split(" ")),o&&o.forEach(function(o){var i=e[o];i?t.utilities.countInArray(i.split(" "),n.class)||(e[o]="".concat(i," ").concat(n.class)):e[o]=n.class})):console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),e}},{key:"onTouchDeviceDetected",value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:"disableContextualWindow",value:function(){window.oncontextmenu=function(t){if(t.target.classList.contains("hg-button"))return t.preventDefault(),t.stopPropagation(),!1}}},{key:"processAutoTouchEvents",value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log("autoUseTouchEvents: Touch device detected, useTouchEvents enabled."))}},{key:"onInit",value:function(){this.options.debug&&console.log("".concat(this.keyboardDOMClass," Initialized")),this.handleCaret(),"function"===typeof this.options.onInit&&this.options.onInit()}},{key:"beforeFirstRender",value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),"function"===typeof this.options.beforeFirstRender&&this.options.beforeFirstRender(),!this.utilities.pointerEventsSupported()||this.options.useTouchEvents||this.options.useMouseEvents||this.options.debug&&console.log("Using PointerEvents as it is supported by this browser"),this.options.useTouchEvents&&this.options.debug&&console.log("useTouchEvents has been enabled. Only touch events will be used.")}},{key:"beforeRender",value:function(){"function"===typeof this.options.beforeRender&&this.options.beforeRender()}},{key:"onRender",value:function(){"function"===typeof this.options.onRender&&this.options.onRender()}},{key:"onModulesLoaded",value:function(){"function"===typeof this.options.onModulesLoaded&&this.options.onModulesLoaded()}},{key:"loadModules",value:function(){var t=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach(function(e){var n=new e;if(n.constructor.name&&"Function"!==n.constructor.name){var o="module-".concat(t.utilities.camelCase(n.constructor.name));t.keyboardPluginClasses=t.keyboardPluginClasses+" ".concat(o)}n.init(t)}),this.keyboardPluginClasses=this.keyboardPluginClasses+" modules-loaded",this.render(),this.onModulesLoaded())}},{key:"getModuleProp",value:function(t,e){return!!this.modules[t]&&this.modules[t][e]}},{key:"getModulesList",value:function(){return Object.keys(this.modules)}},{key:"parseRowDOMContainers",value:function(t,e,n,o){var i=this,s=Array.from(t.children),a=0;return s.length&&n.forEach(function(n,u){var r=o[u];if(!r||!(r>n))return!1;var c=n-a,l=r-a,h=document.createElement("div");h.className+="hg-button-container";var d="".concat(i.options.layoutName,"-r").concat(e,"c").concat(u);h.setAttribute("data-skUID",d);var p=s.splice(c,l-c+1);a=l-c,p.forEach(function(t){return h.appendChild(t)}),s.splice(c,0,h),t.innerHTML="",s.forEach(function(e){return t.appendChild(e)}),i.options.debug&&console.log("rowDOMContainer",p,c,l,a+1)}),t}},{key:"render",value:function(){var t=this;this.clear(),this.initialized||this.beforeFirstRender(),this.beforeRender();var e="hg-layout-".concat(this.options.layoutName),n=this.options.layout||a.getDefaultLayout(),o=this.options.useTouchEvents||!1,i=o?"hg-touch-events":"",s=this.options.useMouseEvents||!1,u=this.options.disableRowButtonContainers,r=Array.isArray(this.options.buttonTheme)?this.getButtonTheme():{};this.keyboardDOM.className+=" ".concat(this.options.theme," ").concat(e," ").concat(this.keyboardPluginClasses," ").concat(i),n[this.options.layoutName].forEach(function(e,n){var i=e.split(" "),a=document.createElement("div");a.className+="hg-row";var c=[],l=[];i.forEach(function(e,i){var h=!u&&e.includes("[")&&e.length>1,d=!u&&e.includes("]")&&e.length>1;h&&(c.push(i),e=e.replace(/\[/g,"")),d&&(l.push(i),e=e.replace(/\]/g,""));var p=t.utilities.getButtonClass(e),f=r[e],y=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),m=t.options.useButtonTag?"button":"div",b=document.createElement(m);b.className+="hg-button ".concat(p).concat(f?" "+f:""),!t.utilities.pointerEventsSupported()||o||s?o?(b.ontouchstart=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.ontouchend=function(e){return t.handleButtonMouseUp()},b.ontouchcancel=function(e){return t.handleButtonMouseUp()}):(b.onclick=function(){t.isMouseHold=!1,t.handleButtonClicked(e)},b.onmousedown=function(n){t.handleButtonMouseDown(e,n)}):(b.onpointerdown=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.onpointerup=function(e){t.handleButtonMouseUp()},b.onpointercancel=function(e){return t.handleButtonMouseUp()}),b.setAttribute("data-skBtn",e);var v="".concat(t.options.layoutName,"-r").concat(n,"b").concat(i);b.setAttribute("data-skBtnUID",v),b.setAttribute("data-displayLabel",y);var g=document.createElement("span");g.innerHTML=y,b.appendChild(g),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(b),a.appendChild(b)}),a=t.parseRowDOMContainers(a,n,c,l),t.keyboardDOM.appendChild(a)}),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||o||s?o?(document.ontouchend=function(e){return t.handleButtonMouseUp()},document.ontouchcancel=function(e){return t.handleButtonMouseUp()}):o||(document.onmouseup=function(){return t.handleButtonMouseUp()}):document.onpointerup=function(){return t.handleButtonMouseUp()},this.onInit())}}])&&h(e.prototype,n),o&&h(e,o),t}();e.default=d}])}); +!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define("SimpleKeyboard",[],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(2)},function(t,e,n){},function(t,e,n){"use strict";n.r(e);n(1);function o(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}],(n=null)&&s(e.prototype,n),o&&s(e,o),t}();function u(t){return(u="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){for(var n=0;n0?s=this.removeAt(s,o,i):"{space}"===t?s=this.addStringAt(s," ",o,i):"{tab}"!==t||"boolean"===typeof n.tabCharOnTab&&!1===n.tabCharOnTab?"{enter}"!==t&&"{numpadenter}"!==t||!n.newLineOnEnter?t.includes("numpad")&&Number.isInteger(Number(t[t.length-2]))?s=this.addStringAt(s,t[t.length-2],o,i):"{numpaddivide}"===t?s=this.addStringAt(s,"/",o,i):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",o,i):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",o,i):"{numpadadd}"===t?s=this.addStringAt(s,"+",o,i):"{numpaddecimal}"===t?s=this.addStringAt(s,".",o,i):"{"===t||"}"===t?s=this.addStringAt(s,t,o,i):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,o,i)):s=this.addStringAt(s,"\n",o,i):s=this.addStringAt(s,"\t",o,i),s}},{key:"updateCaretPos",value:function(t,e){var n=this.updateCaretPosAction(this.simpleKeyboardInstance,t,e);this.simpleKeyboardInstance.options.syncInstanceInputs&&this.simpleKeyboardInstance.dispatch(function(t){t.caretPosition=n})}},{key:"updateCaretPosAction",value:function(t,e,n){return n?t.caretPosition>0&&(t.caretPosition=t.caretPosition-e):t.caretPosition=t.caretPosition+e,this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",t.caretPosition,"(".concat(t.keyboardDOMClass,")")),t.caretPosition}},{key:"addStringAt",value:function(t,e,n,o){var i;return n||0===n?(i=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||o&&this.updateCaretPos(e.length)):i=t+e,i}},{key:"removeAt",value:function(t,e,n){if(0===this.simpleKeyboardInstance.caretPosition)return t;var o,i=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?t.substring(e-2,e).match(i)?(o=t.substr(0,e-2)+t.substr(e),n&&this.updateCaretPos(2,!0)):(o=t.substr(0,e-1)+t.substr(e),n&&this.updateCaretPos(1,!0)):t.slice(-2).match(i)?(o=t.slice(0,-2),n&&this.updateCaretPos(2,!0)):(o=t.slice(0,-1),n&&this.updateCaretPos(1,!0)),o}},{key:"handleMaxLength",value:function(t,e,n){var o=e.maxLength,i=t[e.inputName],s=i.length===o;if(n.length<=i.length)return!1;if(Number.isInteger(o))return e.debug&&console.log("maxLength (num) reached:",s),s?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===u(o)){var a=i.length===o[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return Boolean(this.maxLengthReached)}},{key:"isTouchDevice",value:function(){return"ontouchstart"in window||navigator.maxTouchPoints}},{key:"pointerEventsSupported",value:function(){return window.PointerEvent}},{key:"camelCase",value:function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return e.length?t+e[0].toUpperCase()+e.slice(1):t})}},{key:"countInArray",value:function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)}}])&&r(e.prototype,n),o&&r(e,o),t}();function l(t){return(l="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){for(var n=0;n1?n:n[0]),e}},{key:"inputPatternIsValid",value:function(t){var e,n=this.options.inputPattern;if((e=n instanceof RegExp?n:n[this.options.inputName])&&t){var o=e.test(t);return this.options.debug&&console.log('inputPattern ("'.concat(e,'"): ').concat(o?"passed":"did not pass!")),o}return!0}},{key:"handleCaret",value:function(){this.caretPosition=null;var t=window.SimpleKeyboardInstances;(t&&Object.keys(t)[0]===this.utilities.camelCase(this.keyboardDOMClass)||!t)&&(this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")")),document.addEventListener("keyup",this.caretEventHandler),document.addEventListener("mouseup",this.caretEventHandler),document.addEventListener("touchend",this.caretEventHandler))}},{key:"caretEventHandler",value:function(t){var e;t.target.tagName&&(e=t.target.tagName.toLowerCase()),this.dispatch(function(n){n.isMouseHold&&(n.isMouseHold=!1),"textarea"!==e&&"input"!==e||n.options.disableCaretPositioning?n.options.disableCaretPositioning&&(n.caretPosition=null):(n.caretPosition=t.target.selectionStart,n.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase(),"(".concat(n.keyboardDOMClass,")")))})}},{key:"getButtonTheme",value:function(){var t=this,e={};return this.options.buttonTheme.forEach(function(n){var o;n.buttons&&n.class?("string"===typeof n.buttons&&(o=n.buttons.split(" ")),o&&o.forEach(function(o){var i=e[o];i?t.utilities.countInArray(i.split(" "),n.class)||(e[o]="".concat(i," ").concat(n.class)):e[o]=n.class})):console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),e}},{key:"onTouchDeviceDetected",value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:"disableContextualWindow",value:function(){window.oncontextmenu=function(t){if(t.target.classList.contains("hg-button"))return t.preventDefault(),t.stopPropagation(),!1}}},{key:"processAutoTouchEvents",value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log("autoUseTouchEvents: Touch device detected, useTouchEvents enabled."))}},{key:"onInit",value:function(){this.options.debug&&console.log("".concat(this.keyboardDOMClass," Initialized")),this.handleCaret(),"function"===typeof this.options.onInit&&this.options.onInit()}},{key:"beforeFirstRender",value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),"function"===typeof this.options.beforeFirstRender&&this.options.beforeFirstRender(),!this.utilities.pointerEventsSupported()||this.options.useTouchEvents||this.options.useMouseEvents||this.options.debug&&console.log("Using PointerEvents as it is supported by this browser"),this.options.useTouchEvents&&this.options.debug&&console.log("useTouchEvents has been enabled. Only touch events will be used.")}},{key:"beforeRender",value:function(){"function"===typeof this.options.beforeRender&&this.options.beforeRender()}},{key:"onRender",value:function(){"function"===typeof this.options.onRender&&this.options.onRender()}},{key:"onModulesLoaded",value:function(){"function"===typeof this.options.onModulesLoaded&&this.options.onModulesLoaded()}},{key:"loadModules",value:function(){var t=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach(function(e){var n=new e;if(n.constructor.name&&"Function"!==n.constructor.name){var o="module-".concat(t.utilities.camelCase(n.constructor.name));t.keyboardPluginClasses=t.keyboardPluginClasses+" ".concat(o)}n.init(t)}),this.keyboardPluginClasses=this.keyboardPluginClasses+" modules-loaded",this.render(),this.onModulesLoaded())}},{key:"getModuleProp",value:function(t,e){return!!this.modules[t]&&this.modules[t][e]}},{key:"getModulesList",value:function(){return Object.keys(this.modules)}},{key:"parseRowDOMContainers",value:function(t,e,n,o){var i=this,s=Array.from(t.children),a=0;return s.length&&n.forEach(function(n,u){var r=o[u];if(!r||!(r>n))return!1;var c=n-a,l=r-a,h=document.createElement("div");h.className+="hg-button-container";var d="".concat(i.options.layoutName,"-r").concat(e,"c").concat(u);h.setAttribute("data-skUID",d);var p=s.splice(c,l-c+1);a=l-c,p.forEach(function(t){return h.appendChild(t)}),s.splice(c,0,h),t.innerHTML="",s.forEach(function(e){return t.appendChild(e)}),i.options.debug&&console.log("rowDOMContainer",p,c,l,a+1)}),t}},{key:"render",value:function(){var t=this;this.clear(),this.initialized||this.beforeFirstRender(),this.beforeRender();var e="hg-layout-".concat(this.options.layoutName),n=this.options.layout||a.getDefaultLayout(),o=this.options.useTouchEvents||!1,i=o?"hg-touch-events":"",s=this.options.useMouseEvents||!1,u=this.options.disableRowButtonContainers,r=Array.isArray(this.options.buttonTheme)?this.getButtonTheme():{};this.keyboardDOM.className+=" ".concat(this.options.theme," ").concat(e," ").concat(this.keyboardPluginClasses," ").concat(i),n[this.options.layoutName].forEach(function(e,n){var i=e.split(" "),a=document.createElement("div");a.className+="hg-row";var c=[],l=[];i.forEach(function(e,i){var h=!u&&e.includes("[")&&e.length>1,d=!u&&e.includes("]")&&e.length>1;h&&(c.push(i),e=e.replace(/\[/g,"")),d&&(l.push(i),e=e.replace(/\]/g,""));var p=t.utilities.getButtonClass(e),f=r[e],y=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),m=t.options.useButtonTag?"button":"div",b=document.createElement(m);b.className+="hg-button ".concat(p).concat(f?" "+f:""),!t.utilities.pointerEventsSupported()||o||s?o?(b.ontouchstart=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.ontouchend=function(e){return t.handleButtonMouseUp()},b.ontouchcancel=function(e){return t.handleButtonMouseUp()}):(b.onclick=function(){t.isMouseHold=!1,t.handleButtonClicked(e)},b.onmousedown=function(n){t.handleButtonMouseDown(e,n)}):(b.onpointerdown=function(n){t.handleButtonClicked(e),t.handleButtonMouseDown(e,n)},b.onpointerup=function(e){t.handleButtonMouseUp()},b.onpointercancel=function(e){return t.handleButtonMouseUp()}),b.setAttribute("data-skBtn",e);var v="".concat(t.options.layoutName,"-r").concat(n,"b").concat(i);b.setAttribute("data-skBtnUID",v),b.setAttribute("data-displayLabel",y);var g=document.createElement("span");g.innerHTML=y,b.appendChild(g),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(b),a.appendChild(b)}),a=t.parseRowDOMContainers(a,n,c,l),t.keyboardDOM.appendChild(a)}),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||o||s?o?(document.ontouchend=function(e){return t.handleButtonMouseUp()},document.ontouchcancel=function(e){return t.handleButtonMouseUp()}):o||(document.onmouseup=function(){return t.handleButtonMouseUp()}):document.onpointerup=function(){return t.handleButtonMouseUp()},this.onInit())}}])&&h(e.prototype,n),o&&h(e,o),t}();e.default=d}])}); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map index 4a33b534..0b1dffc8 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","bindMethods","myClass","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","getOwnPropertyNames","iterator","next","done","myMethod","err","return","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","newCaretPos","updateCaretPosAction","syncInstanceInputs","caretPosition","debug","console","log","keyboardDOMClass","source","string","position","slice","join","isMaxLengthReached","updateCaretPos","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","navigator","maxTouchPoints","PointerEvent","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","initCallback","keyboardDOMQuery","arguments","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","buttonElements","warn","Error","render","camelCase","physicalKeyboardInterface","loadModules","onKeyPress","getUpdatedInput","inputPattern","inputPatternIsValid","handleMaxLength","onChange","onChangeAll","e","_this2","preventDefault","stopMouseDownPropagation","stopPropagation","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","handleButtonHold","_this3","handleButtonClicked","_this4","replaceInput","onSetOptions","innerHTML","className","callback","keys","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","inputVal","inputPatternRaw","RegExp","didInputMatch","test","simpleKeyboardInstances","caretEventHandler","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","countInArray","processAutoTouchEvents","disableContextualWindow","oncontextmenu","classList","contains","autoUseTouchEvents","useTouchEvents","handleCaret","onInit","isTouchDevice","onTouchDeviceDetected","beforeFirstRender","pointerEventsSupported","useMouseEvents","beforeRender","onRender","onModulesLoaded","_this8","Module","constructor","classStr","init","prop","rowDOM","rowIndex","containerStartIndexes","containerEndIndexes","_this9","rowDOMArray","from","children","removedElements","startIndex","arrIndex","endIndex","updated_startIndex","updated_endIndex","containerDOM","createElement","containerUID","setAttribute","containedElements","element","appendChild","_this10","clear","initialized","layoutClass","layout","getDefaultLayout","useTouchEventsClass","disableRowButtonContainers","getButtonTheme","row","rIndex","rowArray","bIndex","buttonHasContainerStart","buttonHasContainerEnd","fctBtnClass","getButtonClass","buttonThemeClass","buttonDisplayName","getButtonDisplayName","buttonType","useButtonTag","ontouchstart","handleButtonMouseDown","ontouchend","handleButtonMouseUp","ontouchcancel","onclick","onmousedown","onpointerdown","onpointerup","onpointercancel","buttonUID","buttonSpanDOM","parseRowDOMContainers","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,EAA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IAE3BrC,EAAUmT,YAAc,SAAAlI,GACtBsG,EAAKuB,sBAAsBzQ,EAAQ4I,MA/BvCjL,EAAUoT,cAAgB,SAAAnI,GACxBsG,EAAK1F,oBAAoBxJ,GACzBkP,EAAKuB,sBAAsBzQ,EAAQ4I,IAErCjL,EAAUqT,YAAc,SAAApI,GACtBsG,EAAKyB,uBAEPhT,EAAUsT,gBAAkB,SAAArI,GAAC,OAAIsG,EAAKyB,wBAgCxChT,EAAUmR,aAAa,aAAc9O,GAMrC,IAAIkR,EAAS,GAAArT,OAAMqR,EAAK5R,QAAQoK,WAAnB,MAAA7J,OAAkC+R,EAAlC,KAAA/R,OAA4CiS,GACzDnS,EAAUmR,aAAa,gBAAiBoC,GAKxCvT,EAAUmR,aAAa,oBAAqBsB,GAK5C,IAAIe,EAAgBhU,SAASyR,cAAc,QAC3CuC,EAAcvH,UAAYwG,EAC1BzS,EAAUsR,YAAYkC,GAKjBjC,EAAKpH,eAAe9H,KAASkP,EAAKpH,eAAe9H,GAAU,IAEhEkP,EAAKpH,eAAe9H,GAAQyK,KAAK9M,GAKjCkQ,EAAOoB,YAAYtR,KAMrBkQ,EAASqB,EAAKkC,sBACZvD,EACA+B,EACA7B,EACAC,GAMFkB,EAAK1H,YAAYyH,YAAYpB,KAM/B9Q,KAAKsQ,WAEAtQ,KAAKqS,cAIRrS,KAAKqS,aAAc,GAOjBrS,KAAKwK,UAAU2F,0BACdN,GACAO,EAGQP,GAITzP,SAASuT,WAAa,SAAA9H,GAAC,OAAIsG,EAAKyB,uBAChCxT,SAASyT,cAAgB,SAAAhI,GAAC,OAAIsG,EAAKyB,wBACzB/D,IAIVzP,SAASkU,UAAY,kBAAMnC,EAAKyB,wBAXhCxT,SAAS6T,YAAc,kBAAM9B,EAAKyB,uBAiBpC5T,KAAK+P,+CCtrCI7F","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(\r\n this\r\n );\r\n\r\n /**\r\n * Initialize key listeners\r\n */\r\n this.initKeyboardListener();\r\n }\r\n\r\n /**\r\n * Initializes key event listeners\r\n */\r\n initKeyboardListener() {\r\n // Adding button style on keydown\r\n document.addEventListener(\"keydown\", event => {\r\n if (this.simpleKeyboardInstance.options.physicalKeyboardHighlight) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM) {\r\n buttonDOM.style.backgroundColor =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n });\r\n\r\n // Removing button style on keyup\r\n document.addEventListener(\"keyup\", event => {\r\n if (this.simpleKeyboardInstance.options.physicalKeyboardHighlight) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM && buttonDOM.removeAttribute) {\r\n buttonDOM.removeAttribute(\"style\");\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Transforms a KeyboardEvent's \"key.code\" string into a simple-keyboard layout format\r\n * @param {object} event The KeyboardEvent\r\n */\r\n getSimpleKeyboardLayoutKey(event) {\r\n let output;\r\n\r\n if (\r\n event.code.includes(\"Numpad\") ||\r\n event.code.includes(\"Shift\") ||\r\n event.code.includes(\"Space\") ||\r\n event.code.includes(\"Backspace\") ||\r\n event.code.includes(\"Control\") ||\r\n event.code.includes(\"Alt\") ||\r\n event.code.includes(\"Meta\")\r\n ) {\r\n output = event.code;\r\n } else {\r\n output = event.key;\r\n }\r\n\r\n /**\r\n * If button is not uppercase, casting to lowercase\r\n */\r\n if (\r\n output !== output.toUpperCase() ||\r\n (event.code[0] === \"F\" &&\r\n Number.isInteger(Number(event.code[1])) &&\r\n event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;\r\n","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout() {\r\n return {\r\n default: [\r\n \"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}\",\r\n \"{tab} q w e r t y u i o p [ ] \\\\\",\r\n \"{lock} a s d f g h j k l ; ' {enter}\",\r\n \"{shift} z x c v b n m , . / {shift}\",\r\n \".com @ {space}\"\r\n ],\r\n shift: [\r\n \"~ ! @ # $ % ^ & * ( ) _ + {bksp}\",\r\n \"{tab} Q W E R T Y U I O P { } |\",\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n \"{shift} Z X C V B N M < > ? {shift}\",\r\n \".com @ {space}\"\r\n ]\r\n };\r\n }\r\n}\r\n\r\nexport default KeyboardLayout;\r\n","/**\r\n * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(Utilities, this);\r\n }\r\n\r\n /**\r\n * Adds default classes to a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @return {string} The classes to be added to the button\r\n */\r\n getButtonClass(button) {\r\n let buttonTypeClass =\r\n button.includes(\"{\") && button.includes(\"}\") && button !== \"{//}\"\r\n ? \"functionBtn\"\r\n : \"standardBtn\";\r\n let buttonWithoutBraces = button.replace(\"{\", \"\").replace(\"}\", \"\");\r\n let buttonNormalized = \"\";\r\n\r\n if (buttonTypeClass !== \"standardBtn\")\r\n buttonNormalized = ` hg-button-${buttonWithoutBraces}`;\r\n\r\n return `hg-${buttonTypeClass}${buttonNormalized}`;\r\n }\r\n\r\n /**\r\n * Default button display labels\r\n */\r\n getDefaultDiplay() {\r\n return {\r\n \"{bksp}\": \"backspace\",\r\n \"{backspace}\": \"backspace\",\r\n \"{enter}\": \"< enter\",\r\n \"{shift}\": \"shift\",\r\n \"{shiftleft}\": \"shift\",\r\n \"{shiftright}\": \"shift\",\r\n \"{alt}\": \"alt\",\r\n \"{s}\": \"shift\",\r\n \"{tab}\": \"tab\",\r\n \"{lock}\": \"caps\",\r\n \"{capslock}\": \"caps\",\r\n \"{accept}\": \"Submit\",\r\n \"{space}\": \" \",\r\n \"{//}\": \" \",\r\n \"{esc}\": \"esc\",\r\n \"{escape}\": \"esc\",\r\n \"{f1}\": \"f1\",\r\n \"{f2}\": \"f2\",\r\n \"{f3}\": \"f3\",\r\n \"{f4}\": \"f4\",\r\n \"{f5}\": \"f5\",\r\n \"{f6}\": \"f6\",\r\n \"{f7}\": \"f7\",\r\n \"{f8}\": \"f8\",\r\n \"{f9}\": \"f9\",\r\n \"{f10}\": \"f10\",\r\n \"{f11}\": \"f11\",\r\n \"{f12}\": \"f12\",\r\n \"{numpaddivide}\": \"/\",\r\n \"{numlock}\": \"lock\",\r\n \"{arrowup}\": \"↑\",\r\n \"{arrowleft}\": \"←\",\r\n \"{arrowdown}\": \"↓\",\r\n \"{arrowright}\": \"→\",\r\n \"{prtscr}\": \"print\",\r\n \"{scrolllock}\": \"scroll\",\r\n \"{pause}\": \"pause\",\r\n \"{insert}\": \"ins\",\r\n \"{home}\": \"home\",\r\n \"{pageup}\": \"up\",\r\n \"{delete}\": \"del\",\r\n \"{end}\": \"end\",\r\n \"{pagedown}\": \"down\",\r\n \"{numpadmultiply}\": \"*\",\r\n \"{numpadsubtract}\": \"-\",\r\n \"{numpadadd}\": \"+\",\r\n \"{numpadenter}\": \"enter\",\r\n \"{period}\": \".\",\r\n \"{numpaddecimal}\": \".\",\r\n \"{numpad0}\": \"0\",\r\n \"{numpad1}\": \"1\",\r\n \"{numpad2}\": \"2\",\r\n \"{numpad3}\": \"3\",\r\n \"{numpad4}\": \"4\",\r\n \"{numpad5}\": \"5\",\r\n \"{numpad6}\": \"6\",\r\n \"{numpad7}\": \"7\",\r\n \"{numpad8}\": \"8\",\r\n \"{numpad9}\": \"9\"\r\n };\r\n }\r\n /**\r\n * Returns the display (label) name for a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {object} display The provided display option\r\n * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.\r\n */\r\n getButtonDisplayName(button, display, mergeDisplay) {\r\n if (mergeDisplay) {\r\n display = Object.assign({}, this.getDefaultDiplay(), display);\r\n } else {\r\n display = display || this.getDefaultDiplay();\r\n }\r\n\r\n return display[button] || button;\r\n }\r\n\r\n /**\r\n * Returns the updated input resulting from clicking a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret) {\r\n let output = input;\r\n\r\n if (\r\n (button === \"{bksp}\" || button === \"{backspace}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n } else if (button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n else if (\r\n button === \"{tab}\" &&\r\n !(\r\n typeof options.tabCharOnTab === \"boolean\" &&\r\n options.tabCharOnTab === false\r\n )\r\n ) {\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n } else if (\r\n (button === \"{enter}\" || button === \"{numpadenter}\") &&\r\n options.newLineOnEnter\r\n )\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n else if (\r\n button.includes(\"numpad\") &&\r\n Number.isInteger(Number(button[button.length - 2]))\r\n ) {\r\n output = this.addStringAt(\r\n output,\r\n button[button.length - 2],\r\n caretPos,\r\n moveCaret\r\n );\r\n } else if (button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, \"/\", caretPos, moveCaret);\r\n else if (button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, \"*\", caretPos, moveCaret);\r\n else if (button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, \"-\", caretPos, moveCaret);\r\n else if (button === \"{numpadadd}\")\r\n output = this.addStringAt(output, \"+\", caretPos, moveCaret);\r\n else if (button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, \".\", caretPos, moveCaret);\r\n else if (button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n else if (!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus) {\r\n let newCaretPos = this.updateCaretPosAction(\r\n this.simpleKeyboardInstance,\r\n length,\r\n minus\r\n );\r\n\r\n if (this.simpleKeyboardInstance.options.syncInstanceInputs) {\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {object} instance The instance whose position should be updated\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(instance, length, minus) {\r\n if (minus) {\r\n if (instance.caretPosition > 0)\r\n instance.caretPosition = instance.caretPosition - length;\r\n } else {\r\n instance.caretPosition = instance.caretPosition + length;\r\n }\r\n\r\n if (this.simpleKeyboardInstance.options.debug) {\r\n console.log(\r\n \"Caret at:\",\r\n instance.caretPosition,\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n\r\n return instance.caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret) {\r\n let output;\r\n\r\n if (!position && position !== 0) {\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join(\r\n \"\"\r\n );\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if (!this.isMaxLengthReached()) {\r\n if (moveCaret) this.updateCaretPos(string.length);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret) {\r\n if (this.simpleKeyboardInstance.caretPosition === 0) {\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if (position && position >= 0) {\r\n prevTwoChars = source.substring(position - 2, position);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.substr(0, position - 2) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, position - 1) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.slice(0, -2);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n *\r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput) {\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if (\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ) {\r\n return false;\r\n }\r\n\r\n if (Number.isInteger(maxLength)) {\r\n if (options.debug) {\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if (typeof maxLength === \"object\") {\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if (options.debug) {\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached() {\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Determines whether a touch device is being used\r\n */\r\n isTouchDevice() {\r\n return \"ontouchstart\" in window || navigator.maxTouchPoints;\r\n }\r\n\r\n /**\r\n * Determines whether pointer events are supported\r\n */\r\n pointerEventsSupported() {\r\n return window.PointerEvent;\r\n }\r\n\r\n /**\r\n * Bind all methods in a given class\r\n */\r\n\r\n static bindMethods(myClass, instance) {\r\n for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {\r\n let excludeMethod =\r\n myMethod === \"constructor\" || myMethod === \"bindMethods\";\r\n if (!excludeMethod) {\r\n instance[myMethod] = instance[myMethod].bind(instance);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string) {\r\n return string\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce((string, word) =>\r\n word.length ? string + word[0].toUpperCase() + word.slice(1) : string\r\n );\r\n }\r\n\r\n /**\r\n * Counts the number of duplicates in a given array\r\n *\r\n * @param {Array} array The haystack to search in\r\n * @param {string} value The needle to search for\r\n */\r\n countInArray(array, value) {\r\n return array.reduce((n, x) => n + (x === value), 0);\r\n }\r\n}\r\n\r\nexport default Utilities;\r\n","import \"./Keyboard.css\";\r\n\r\n// Services\r\nimport PhysicalKeyboard from \"../services/PhysicalKeyboard\";\r\nimport KeyboardLayout from \"../services/KeyboardLayout\";\r\nimport Utilities from \"../services/Utilities\";\r\n\r\n/**\r\n * Root class for simple-keyboard\r\n * This class:\r\n * - Parses the options\r\n * - Renders the rows and buttons\r\n * - Handles button functionality\r\n */\r\nclass SimpleKeyboard {\r\n /**\r\n * Creates an instance of SimpleKeyboard\r\n * @param {Array} params If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.\r\n */\r\n constructor(...params) {\r\n let keyboardDOMQuery =\r\n typeof params[0] === \"string\" ? params[0] : \".simple-keyboard\";\r\n let options = typeof params[0] === \"object\" ? params[0] : params[1];\r\n\r\n if (!options) options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n * @property {boolean} useButtonTag Render buttons as a button element instead of a div element.\r\n * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.\r\n * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.\r\n * @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.\r\n * @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.\r\n * @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.\r\n */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault =\r\n this.options.preventMouseDownDefault || false;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = \"\";\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(SimpleKeyboard, this);\r\n\r\n /**\r\n * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).\r\n * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.\r\n * @example\r\n * // To get entered input\r\n * let input = keyboard.getInput();\r\n *\r\n * // To clear entered input.\r\n * keyboard.clearInput();\r\n *\r\n * @type {object}\r\n * @property {object} default Default SimpleKeyboard internal input.\r\n * @property {object} myInputName Example input that can be set through `options.inputName:\"myInputName\"`.\r\n */\r\n this.input = {};\r\n this.input[this.options.inputName] = \"\";\r\n\r\n /**\r\n * @type {string} DOM class of the keyboard wrapper, normally \"simple-keyboard\" by default.\r\n */\r\n this.keyboardDOMClass = keyboardDOMQuery.split(\".\").join(\"\");\r\n\r\n /**\r\n * @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: \"{enter}\").\r\n */\r\n this.buttonElements = {};\r\n\r\n /**\r\n * Rendering keyboard\r\n */\r\n if (this.keyboardDOM) this.render();\r\n else {\r\n console.warn(`\"${keyboardDOMQuery}\" was not found in the DOM.`);\r\n throw new Error(\"KEYBOARD_DOM_ERROR\");\r\n }\r\n\r\n /**\r\n * Saving instance\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if (!window[\"SimpleKeyboardInstances\"])\r\n window[\"SimpleKeyboardInstances\"] = {};\r\n\r\n window[\"SimpleKeyboardInstances\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button) {\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if (button === \"{//}\") return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if (typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n\r\n if (!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = \"\";\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition\r\n );\r\n\r\n if (\r\n // If input will change as a result of this button press\r\n this.input[this.options.inputName] !== updatedInput &&\r\n // This pertains to the \"inputPattern\" option:\r\n // If inputPattern isn't set\r\n (!this.options.inputPattern ||\r\n // Or, if it is set and if the pattern is valid - we proceed.\r\n (this.options.inputPattern && this.inputPatternIsValid(updatedInput)))\r\n ) {\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if (\r\n this.options.maxLength &&\r\n this.utilities.handleMaxLength(this.input, this.options, updatedInput)\r\n ) {\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition,\r\n true\r\n );\r\n\r\n if (debug) console.log(\"Input changed:\", this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n\r\n /**\r\n * Calling onChangeAll\r\n */\r\n if (typeof this.options.onChangeAll === \"function\")\r\n this.options.onChangeAll(this.input);\r\n }\r\n\r\n if (debug) {\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e) {\r\n /**\r\n * Handle event options\r\n */\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n if (this.options.stopMouseDownPropagation) e.stopPropagation();\r\n\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n if (this.holdTimeout) clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if (\r\n this.isMouseHold &&\r\n ((!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{delete}\" ||\r\n button === \"{backspace}\" ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\")\r\n ) {\r\n if (this.options.debug) console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp() {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button) {\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if (this.isMouseHold) {\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs() {\r\n this.dispatch(instance => {\r\n instance.replaceInput(this.input);\r\n instance.caretPosition = this.caretPosition;\r\n });\r\n }\r\n\r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = \"\";\r\n\r\n /**\r\n * Reset caretPosition\r\n */\r\n this.caretPosition = 0;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Get the keyboard’s input (You can also get it from the onChange prop).\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n getInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n return this.input[inputName];\r\n }\r\n\r\n /**\r\n * Set the keyboard’s input.\r\n * @param {string} input the input value\r\n * @param {string} inputName optional - the internal input to select\r\n */\r\n setInput(input, inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = input;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Replace the input object (`keyboard.input`)\r\n * @param {object} inputObj The input object\r\n */\r\n replaceInput(inputObj) {\r\n this.input = inputObj;\r\n }\r\n\r\n /**\r\n * Set new option or modify existing ones after initialization.\r\n * @param {object} options The options to set\r\n */\r\n setOptions(options) {\r\n options = options || {};\r\n this.options = Object.assign(this.options, options);\r\n\r\n /**\r\n * Some option changes require adjustments before re-render\r\n */\r\n this.onSetOptions(options);\r\n\r\n /**\r\n * Rendering\r\n */\r\n this.render();\r\n }\r\n\r\n /**\r\n * Executing actions depending on changed options\r\n * @param {object} options The options to set\r\n */\r\n onSetOptions(options) {\r\n if (options.inputName) {\r\n /**\r\n * inputName changed. This requires a caretPosition reset\r\n */\r\n if (this.options.debug) {\r\n console.log(\"inputName changed. caretPosition reset.\");\r\n }\r\n\r\n this.caretPosition = null;\r\n }\r\n }\r\n\r\n /**\r\n * Remove all keyboard rows and reset keyboard values.\r\n * Used interally between re-renders.\r\n */\r\n clear() {\r\n this.keyboardDOM.innerHTML = \"\";\r\n this.keyboardDOM.className = this.keyboardDOMClass;\r\n this.buttonElements = {};\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances at once (if you have multiple instances).\r\n * @param {function(instance: object, key: string)} callback Function to run on every instance\r\n */\r\n dispatch(callback) {\r\n if (!window[\"SimpleKeyboardInstances\"]) {\r\n console.warn(\r\n `SimpleKeyboardInstances is not defined. Dispatch cannot be called.`\r\n );\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n\r\n return Object.keys(window[\"SimpleKeyboardInstances\"]).forEach(key => {\r\n callback(window[\"SimpleKeyboardInstances\"][key], key);\r\n });\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className) {\r\n if (!className || !buttons) return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if (!this.options.buttonTheme) this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n\r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n if (buttonTheme.class.split(\" \").includes(classNameItem)) {\r\n classNameFound = true;\r\n\r\n let buttonThemeArray = buttonTheme.buttons.split(\" \");\r\n if (!buttonThemeArray.includes(button)) {\r\n classNameFound = true;\r\n buttonThemeArray.push(button);\r\n buttonTheme.buttons = buttonThemeArray.join(\" \");\r\n }\r\n }\r\n return buttonTheme;\r\n });\r\n\r\n /**\r\n * If class is not defined, we create a new entry\r\n */\r\n if (!classNameFound) {\r\n this.options.buttonTheme.push({\r\n class: classNameItem,\r\n buttons: buttons\r\n });\r\n }\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n\r\n /**\r\n * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n removeButtonTheme(buttons, className) {\r\n /**\r\n * When called with empty parameters, remove all button themes\r\n */\r\n if (!buttons && !className) {\r\n this.options.buttonTheme = [];\r\n this.render();\r\n return false;\r\n }\r\n\r\n /**\r\n * If buttons are passed and buttonTheme has items\r\n */\r\n if (\r\n buttons &&\r\n Array.isArray(this.options.buttonTheme) &&\r\n this.options.buttonTheme.length\r\n ) {\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if (\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ) {\r\n let filteredButtonArray = buttonTheme.buttons\r\n .split(\" \")\r\n .filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if (filteredButtonArray.length) {\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(button) {\r\n let output;\r\n\r\n let buttonArr = this.buttonElements[button];\r\n if (buttonArr) {\r\n if (buttonArr.length > 1) {\r\n output = buttonArr;\r\n } else {\r\n output = buttonArr[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * This handles the \"inputPattern\" option\r\n * by checking if the provided inputPattern passes\r\n */\r\n inputPatternIsValid(inputVal) {\r\n let inputPatternRaw = this.options.inputPattern;\r\n let inputPattern;\r\n\r\n /**\r\n * Check if input pattern is global or targeted to individual inputs\r\n */\r\n if (inputPatternRaw instanceof RegExp) {\r\n inputPattern = inputPatternRaw;\r\n } else {\r\n inputPattern = inputPatternRaw[this.options.inputName];\r\n }\r\n\r\n if (inputPattern && inputVal) {\r\n let didInputMatch = inputPattern.test(inputVal);\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `inputPattern (\"${inputPattern}\"): ${\r\n didInputMatch ? \"passed\" : \"did not pass!\"\r\n }`\r\n );\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret() {\r\n /**\r\n * Only first instance should insall the caret handling events\r\n */\r\n this.caretPosition = null;\r\n let simpleKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n\r\n if (\r\n (simpleKeyboardInstances &&\r\n Object.keys(simpleKeyboardInstances)[0] ===\r\n this.utilities.camelCase(this.keyboardDOMClass)) ||\r\n !simpleKeyboardInstances\r\n ) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\r\n }\r\n\r\n document.addEventListener(\"keyup\", this.caretEventHandler);\r\n document.addEventListener(\"mouseup\", this.caretEventHandler);\r\n document.addEventListener(\"touchend\", this.caretEventHandler);\r\n }\r\n }\r\n\r\n /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\r\n let targetTagName;\r\n if (event.target.tagName) {\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch(instance => {\r\n if (instance.isMouseHold) {\r\n instance.isMouseHold = false;\r\n }\r\n\r\n if (\r\n (targetTagName === \"textarea\" || targetTagName === \"input\") &&\r\n !instance.options.disableCaretPositioning\r\n ) {\r\n /**\r\n * Tracks current cursor position\r\n * As keys are pressed, text will be added/removed at that position within the input.\r\n */\r\n instance.caretPosition = event.target.selectionStart;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n event.target.selectionStart,\r\n event.target.tagName.toLowerCase(),\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n } else if (instance.options.disableCaretPositioning) {\r\n /**\r\n * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.\r\n */\r\n instance.caretPosition = null;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Process buttonTheme option\r\n */\r\n getButtonTheme() {\r\n let buttonThemesParsed = {};\r\n\r\n this.options.buttonTheme.forEach(themeObj => {\r\n if (themeObj.buttons && themeObj.class) {\r\n let themeButtons;\r\n\r\n if (typeof themeObj.buttons === \"string\") {\r\n themeButtons = themeObj.buttons.split(\" \");\r\n }\r\n\r\n if (themeButtons) {\r\n themeButtons.forEach(themeButton => {\r\n let themeParsed = buttonThemesParsed[themeButton];\r\n\r\n // If the button has already been added\r\n if (themeParsed) {\r\n // Making sure we don't add duplicate classes, even when buttonTheme has duplicates\r\n if (\r\n !this.utilities.countInArray(\r\n themeParsed.split(\" \"),\r\n themeObj.class\r\n )\r\n ) {\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${\r\n themeObj.class\r\n }`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(\r\n `buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.`\r\n );\r\n }\r\n });\r\n\r\n return buttonThemesParsed;\r\n }\r\n\r\n onTouchDeviceDetected() {\r\n /**\r\n * Processing autoTouchEvents\r\n */\r\n this.processAutoTouchEvents();\r\n\r\n /**\r\n * Disabling contextual window on touch devices\r\n */\r\n this.disableContextualWindow();\r\n }\r\n\r\n /**\r\n * Disabling contextual window for hg-button\r\n */\r\n /* istanbul ignore next */\r\n disableContextualWindow() {\r\n window.oncontextmenu = event => {\r\n if (event.target.classList.contains(\"hg-button\")) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return false;\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Process autoTouchEvents option\r\n */\r\n processAutoTouchEvents() {\r\n if (this.options.autoUseTouchEvents) {\r\n this.options.useTouchEvents = true;\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender() {\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if (this.utilities.isTouchDevice()) {\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\")\r\n this.options.beforeFirstRender();\r\n\r\n /**\r\n * Notify about PointerEvents usage\r\n */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !this.options.useTouchEvents &&\r\n !this.options.useMouseEvents\r\n ) {\r\n if (this.options.debug) {\r\n console.log(\"Using PointerEvents as it is supported by this browser\");\r\n }\r\n }\r\n\r\n /**\r\n * Notify about touch events usage\r\n */\r\n if (this.options.useTouchEvents) {\r\n if (this.options.debug) {\r\n console.log(\r\n \"useTouchEvents has been enabled. Only touch events will be used.\"\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender() {\r\n if (typeof this.options.beforeRender === \"function\")\r\n this.options.beforeRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n */\r\n onRender() {\r\n if (typeof this.options.onRender === \"function\") this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded() {\r\n if (typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if (!this.modules[name]) this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n };\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules() {\r\n if (Array.isArray(this.options.modules)) {\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if (module.constructor.name && module.constructor.name !== \"Function\") {\r\n let classStr = `module-${this.utilities.camelCase(\r\n module.constructor.name\r\n )}`;\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + \" modules-loaded\";\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp(name, prop) {\r\n if (!this.modules[name]) return false;\r\n\r\n return this.modules[name][prop];\r\n }\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList() {\r\n return Object.keys(this.modules);\r\n }\r\n\r\n /**\r\n * Parse Row DOM containers\r\n */\r\n parseRowDOMContainers(\r\n rowDOM,\r\n rowIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n ) {\r\n let rowDOMArray = Array.from(rowDOM.children);\r\n let removedElements = 0;\r\n\r\n if (rowDOMArray.length) {\r\n containerStartIndexes.forEach((startIndex, arrIndex) => {\r\n let endIndex = containerEndIndexes[arrIndex];\r\n\r\n /**\r\n * If there exists a respective end index\r\n * if end index comes after start index\r\n */\r\n if (!endIndex || !(endIndex > startIndex)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * Updated startIndex, endIndex\r\n * This is since the removal of buttons to place a single button container\r\n * results in a modified array size\r\n */\r\n let updated_startIndex = startIndex - removedElements;\r\n let updated_endIndex = endIndex - removedElements;\r\n\r\n /**\r\n * Create button container\r\n */\r\n let containerDOM = document.createElement(\"div\");\r\n containerDOM.className += \"hg-button-container\";\r\n let containerUID = `${\r\n this.options.layoutName\r\n }-r${rowIndex}c${arrIndex}`;\r\n containerDOM.setAttribute(\"data-skUID\", containerUID);\r\n\r\n /**\r\n * Taking elements due to be inserted into container\r\n */\r\n let containedElements = rowDOMArray.splice(\r\n updated_startIndex,\r\n updated_endIndex - updated_startIndex + 1\r\n );\r\n removedElements = updated_endIndex - updated_startIndex;\r\n\r\n /**\r\n * Inserting elements to container\r\n */\r\n containedElements.forEach(element => containerDOM.appendChild(element));\r\n\r\n /**\r\n * Adding container at correct position within rowDOMArray\r\n */\r\n rowDOMArray.splice(updated_startIndex, 0, containerDOM);\r\n\r\n /**\r\n * Clearing old rowDOM children structure\r\n */\r\n rowDOM.innerHTML = \"\";\r\n\r\n /**\r\n * Appending rowDOM new children list\r\n */\r\n rowDOMArray.forEach(element => rowDOM.appendChild(element));\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n \"rowDOMContainer\",\r\n containedElements,\r\n updated_startIndex,\r\n updated_endIndex,\r\n removedElements + 1\r\n );\r\n }\r\n });\r\n }\r\n\r\n return rowDOM;\r\n }\r\n\r\n /**\r\n * Renders rows and buttons as per options\r\n */\r\n render() {\r\n /**\r\n * Clear keyboard\r\n */\r\n this.clear();\r\n\r\n /**\r\n * Calling beforeFirstRender\r\n */\r\n if (!this.initialized) {\r\n this.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Calling beforeRender\r\n */\r\n this.beforeRender();\r\n\r\n let layoutClass = `hg-layout-${this.options.layoutName}`;\r\n let layout = this.options.layout || KeyboardLayout.getDefaultLayout();\r\n let useTouchEvents = this.options.useTouchEvents || false;\r\n let useTouchEventsClass = useTouchEvents ? \"hg-touch-events\" : \"\";\r\n let useMouseEvents = this.options.useMouseEvents || false;\r\n let disableRowButtonContainers = this.options.disableRowButtonContainers;\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = Array.isArray(this.options.buttonTheme)\r\n ? this.getButtonTheme()\r\n : {};\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${\r\n this.keyboardPluginClasses\r\n } ${useTouchEventsClass}`;\r\n\r\n /**\r\n * Iterating through each row\r\n */\r\n layout[this.options.layoutName].forEach((row, rIndex) => {\r\n let rowArray = row.split(\" \");\r\n\r\n /**\r\n * Creating empty row\r\n */\r\n let rowDOM = document.createElement(\"div\");\r\n rowDOM.className += \"hg-row\";\r\n\r\n /**\r\n * Tracking container indicators in rows\r\n */\r\n let containerStartIndexes = [];\r\n let containerEndIndexes = [];\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n /**\r\n * Check if button has a container indicator\r\n */\r\n let buttonHasContainerStart =\r\n !disableRowButtonContainers &&\r\n button.includes(\"[\") &&\r\n button.length > 1;\r\n let buttonHasContainerEnd =\r\n !disableRowButtonContainers &&\r\n button.includes(\"]\") &&\r\n button.length > 1;\r\n\r\n /**\r\n * Save container start index, if applicable\r\n */\r\n if (buttonHasContainerStart) {\r\n containerStartIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\[/g, \"\");\r\n }\r\n\r\n if (buttonHasContainerEnd) {\r\n containerEndIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\]/g, \"\");\r\n }\r\n\r\n /**\r\n * Processing button options\r\n */\r\n let fctBtnClass = this.utilities.getButtonClass(button);\r\n let buttonThemeClass = buttonThemesParsed[button];\r\n let buttonDisplayName = this.utilities.getButtonDisplayName(\r\n button,\r\n this.options.display,\r\n this.options.mergeDisplay\r\n );\r\n\r\n /**\r\n * Creating button\r\n */\r\n let buttonType = this.options.useButtonTag ? \"button\" : \"div\";\r\n let buttonDOM = document.createElement(buttonType);\r\n buttonDOM.className += `hg-button ${fctBtnClass}${\r\n buttonThemeClass ? \" \" + buttonThemeClass : \"\"\r\n }`;\r\n\r\n /**\r\n * Handle button click event\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n /**\r\n * Handle PointerEvents\r\n */\r\n buttonDOM.onpointerdown = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.onpointerup = e => {\r\n this.handleButtonMouseUp();\r\n };\r\n buttonDOM.onpointercancel = e => this.handleButtonMouseUp();\r\n } else {\r\n /**\r\n * Fallback for browsers not supporting PointerEvents\r\n */\r\n if (useTouchEvents) {\r\n /**\r\n * Handle touch events\r\n */\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n /**\r\n * Handle mouse events\r\n */\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => {\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n let buttonSpanDOM = document.createElement(\"span\");\r\n buttonSpanDOM.innerHTML = buttonDisplayName;\r\n buttonDOM.appendChild(buttonSpanDOM);\r\n\r\n /**\r\n * Adding to buttonElements\r\n */\r\n if (!this.buttonElements[button]) this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n });\r\n\r\n /**\r\n * Parse containers in row\r\n */\r\n rowDOM = this.parseRowDOMContainers(\r\n rowDOM,\r\n rIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n );\r\n\r\n /**\r\n * Appending row to keyboard\r\n */\r\n this.keyboardDOM.appendChild(rowDOM);\r\n });\r\n\r\n /**\r\n * Calling onRender\r\n */\r\n this.onRender();\r\n\r\n if (!this.initialized) {\r\n /**\r\n * Ensures that onInit and beforeFirstRender are only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling onpointerup\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n document.onpointerup = () => this.handleButtonMouseUp();\r\n } else if (useTouchEvents) {\r\n /**\r\n * Handling ontouchend, ontouchcancel\r\n */\r\n document.ontouchend = e => this.handleButtonMouseUp();\r\n document.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else if (!useTouchEvents) {\r\n /**\r\n * Handling mouseup\r\n */\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from \"./components/Keyboard\";\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../../webpack/universalModuleDefinition","../../webpack/bootstrap","services/PhysicalKeyboard.js","services/KeyboardLayout.js","services/Utilities.js","components/Keyboard.js","index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","PhysicalKeyboard","simpleKeyboardInstance","_classCallCheck","this","initKeyboardListener","getSimpleKeyboardLayoutKey","_this","document","addEventListener","event","options","physicalKeyboardHighlight","buttonPressed","dispatch","instance","buttonDOM","getButtonElement","concat","style","backgroundColor","physicalKeyboardHighlightBgColor","color","physicalKeyboardHighlightTextColor","removeAttribute","output","code","includes","toUpperCase","Number","isInteger","length","toLowerCase","KeyboardLayout","default","shift","Utilities","Utilities_classCallCheck","bindMethods","myClass","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","getOwnPropertyNames","iterator","next","done","myMethod","err","return","button","buttonTypeClass","buttonWithoutBraces","replace","buttonNormalized","{bksp}","{backspace}","{enter}","{shift}","{shiftleft}","{shiftright}","{alt}","{s}","{tab}","{lock}","{capslock}","{accept}","{space}","{//}","{esc}","{escape}","{f1}","{f2}","{f3}","{f4}","{f5}","{f6}","{f7}","{f8}","{f9}","{f10}","{f11}","{f12}","{numpaddivide}","{numlock}","{arrowup}","{arrowleft}","{arrowdown}","{arrowright}","{prtscr}","{scrolllock}","{pause}","{insert}","{home}","{pageup}","{delete}","{end}","{pagedown}","{numpadmultiply}","{numpadsubtract}","{numpadadd}","{numpadenter}","{period}","{numpaddecimal}","{numpad0}","{numpad1}","{numpad2}","{numpad3}","{numpad4}","{numpad5}","{numpad6}","{numpad7}","{numpad8}","{numpad9}","display","mergeDisplay","assign","getDefaultDiplay","input","caretPos","moveCaret","removeAt","addStringAt","tabCharOnTab","newLineOnEnter","minus","newCaretPos","updateCaretPosAction","syncInstanceInputs","caretPosition","debug","console","log","keyboardDOMClass","source","string","position","slice","join","isMaxLengthReached","updateCaretPos","emojiMatchedReg","substring","match","substr","inputObj","updatedInput","maxLength","currentInput","inputName","condition","maxLengthReached","_typeof","Boolean","navigator","maxTouchPoints","PointerEvent","trim","split","reduce","word","array","x","SimpleKeyboard","Keyboard_classCallCheck","registerModule","initCallback","keyboardDOMQuery","arguments","Keyboard_typeof","utilities","keyboardDOM","querySelector","layoutName","theme","preventMouseDownDefault","keyboardPluginClasses","buttonElements","warn","Error","render","camelCase","physicalKeyboardInterface","loadModules","onKeyPress","getUpdatedInput","inputPattern","inputPatternIsValid","handleMaxLength","onChange","onChangeAll","e","_this2","preventDefault","stopMouseDownPropagation","stopPropagation","isMouseHold","holdInteractionTimeout","clearTimeout","holdTimeout","setTimeout","handleButtonHold","_this3","handleButtonClicked","_this4","replaceInput","onSetOptions","innerHTML","className","callback","keys","forEach","buttons","_this5","classNameItem","buttonTheme","classNameFound","map","class","buttonThemeArray","push","_this6","Array","isArray","index","filteredButtonArray","filter","item","splice","buttonArr","inputVal","inputPatternRaw","RegExp","didInputMatch","test","simpleKeyboardInstances","caretEventHandler","targetTagName","target","tagName","disableCaretPositioning","selectionStart","_this7","buttonThemesParsed","themeObj","themeButtons","themeButton","themeParsed","countInArray","processAutoTouchEvents","disableContextualWindow","oncontextmenu","classList","contains","autoUseTouchEvents","useTouchEvents","handleCaret","onInit","isTouchDevice","onTouchDeviceDetected","beforeFirstRender","pointerEventsSupported","useMouseEvents","beforeRender","onRender","onModulesLoaded","_this8","Module","constructor","classStr","init","prop","rowDOM","rowIndex","containerStartIndexes","containerEndIndexes","_this9","rowDOMArray","from","children","removedElements","startIndex","arrIndex","endIndex","updated_startIndex","updated_endIndex","containerDOM","createElement","containerUID","setAttribute","containedElements","element","appendChild","_this10","clear","initialized","layoutClass","layout","getDefaultLayout","useTouchEventsClass","disableRowButtonContainers","getButtonTheme","row","rIndex","rowArray","bIndex","buttonHasContainerStart","buttonHasContainerEnd","fctBtnClass","getButtonClass","buttonThemeClass","buttonDisplayName","getButtonDisplayName","buttonType","useButtonTag","ontouchstart","handleButtonMouseDown","ontouchend","handleButtonMouseUp","ontouchcancel","onclick","onmousedown","onpointerdown","onpointerup","onpointercancel","buttonUID","buttonSpanDOM","parseRowDOMContainers","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,EAAAA,IAAAF,EAAAnB,EAAAmB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,kBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFAxB,EAAAgB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAAnB,EAAAQ,EAAAe,EAAAE,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AgCxCjT,EAAUoR,aAAa,aAAc/O,GAMrC,IAAImR,EAAS,GAAAtT,OAAMsR,EAAK7R,QAAQqK,WAAnB,MAAA9J,OAAkCgS,EAAlC,KAAAhS,OAA4CkS,GACzDpS,EAAUoR,aAAa,gBAAiBoC,GAKxCxT,EAAUoR,aAAa,oBAAqBsB,GAK5C,IAAIe,EAAgBjU,SAAS0R,cAAc,QAC3CuC,EAAcvH,UAAYwG,EAC1B1S,EAAUuR,YAAYkC,GAKjBjC,EAAKpH,eAAe/H,KAASmP,EAAKpH,eAAe/H,GAAU,IAEhEmP,EAAKpH,eAAe/H,GAAQ0K,KAAK/M,GAKjCmQ,EAAOoB,YAAYvR,KAMrBmQ,EAASqB,EAAKkC,sBACZvD,EACA+B,EACA7B,EACAC,GAMFkB,EAAK1H,YAAYyH,YAAYpB,KAM/B/Q,KAAKuQ,WAEAvQ,KAAKsS,cAIRtS,KAAKsS,aAAc,GAOjBtS,KAAKyK,UAAU2F,0BACdN,GACAO,EAGQP,GAIT1P,SAASwT,WAAa,SAAA9H,GAAC,OAAIsG,EAAKyB,uBAChCzT,SAAS0T,cAAgB,SAAAhI,GAAC,OAAIsG,EAAKyB,wBACzB/D,IAIV1P,SAASmU,UAAY,kBAAMnC,EAAKyB,wBAXhCzT,SAAS8T,YAAc,kBAAM9B,EAAKyB,uBAiBpC7T,KAAKgQ,+CCtrCI9F","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SimpleKeyboard\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SimpleKeyboard\"] = factory();\n\telse\n\t\troot[\"SimpleKeyboard\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Physical Keyboard Service\r\n */\r\nclass PhysicalKeyboard {\r\n /**\r\n * Creates an instance of the PhysicalKeyboard service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n this.initKeyboardListener = this.initKeyboardListener.bind(this);\r\n this.getSimpleKeyboardLayoutKey = this.getSimpleKeyboardLayoutKey.bind(\r\n this\r\n );\r\n\r\n /**\r\n * Initialize key listeners\r\n */\r\n this.initKeyboardListener();\r\n }\r\n\r\n /**\r\n * Initializes key event listeners\r\n */\r\n initKeyboardListener() {\r\n // Adding button style on keydown\r\n document.addEventListener(\"keydown\", event => {\r\n if (this.simpleKeyboardInstance.options.physicalKeyboardHighlight) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM) {\r\n buttonDOM.style.backgroundColor =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightBgColor || \"#9ab4d0\";\r\n buttonDOM.style.color =\r\n this.simpleKeyboardInstance.options\r\n .physicalKeyboardHighlightTextColor || \"white\";\r\n }\r\n });\r\n }\r\n });\r\n\r\n // Removing button style on keyup\r\n document.addEventListener(\"keyup\", event => {\r\n if (this.simpleKeyboardInstance.options.physicalKeyboardHighlight) {\r\n let buttonPressed = this.getSimpleKeyboardLayoutKey(event);\r\n\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n let buttonDOM =\r\n instance.getButtonElement(buttonPressed) ||\r\n instance.getButtonElement(`{${buttonPressed}}`);\r\n\r\n if (buttonDOM && buttonDOM.removeAttribute) {\r\n buttonDOM.removeAttribute(\"style\");\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Transforms a KeyboardEvent's \"key.code\" string into a simple-keyboard layout format\r\n * @param {object} event The KeyboardEvent\r\n */\r\n getSimpleKeyboardLayoutKey(event) {\r\n let output;\r\n\r\n if (\r\n event.code.includes(\"Numpad\") ||\r\n event.code.includes(\"Shift\") ||\r\n event.code.includes(\"Space\") ||\r\n event.code.includes(\"Backspace\") ||\r\n event.code.includes(\"Control\") ||\r\n event.code.includes(\"Alt\") ||\r\n event.code.includes(\"Meta\")\r\n ) {\r\n output = event.code;\r\n } else {\r\n output = event.key;\r\n }\r\n\r\n /**\r\n * If button is not uppercase, casting to lowercase\r\n */\r\n if (\r\n output !== output.toUpperCase() ||\r\n (event.code[0] === \"F\" &&\r\n Number.isInteger(Number(event.code[1])) &&\r\n event.code.length <= 3)\r\n ) {\r\n output = output.toLowerCase();\r\n }\r\n\r\n return output;\r\n }\r\n}\r\n\r\nexport default PhysicalKeyboard;\r\n","/**\r\n * Keyboard Layout Service\r\n */\r\nclass KeyboardLayout {\r\n /**\r\n * Get default simple-keyboard layout\r\n * @return {object} The default layout (US-QWERTY)\r\n */\r\n static getDefaultLayout() {\r\n return {\r\n default: [\r\n \"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}\",\r\n \"{tab} q w e r t y u i o p [ ] \\\\\",\r\n \"{lock} a s d f g h j k l ; ' {enter}\",\r\n \"{shift} z x c v b n m , . / {shift}\",\r\n \".com @ {space}\"\r\n ],\r\n shift: [\r\n \"~ ! @ # $ % ^ & * ( ) _ + {bksp}\",\r\n \"{tab} Q W E R T Y U I O P { } |\",\r\n '{lock} A S D F G H J K L : \" {enter}',\r\n \"{shift} Z X C V B N M < > ? {shift}\",\r\n \".com @ {space}\"\r\n ]\r\n };\r\n }\r\n}\r\n\r\nexport default KeyboardLayout;\r\n","/**\r\n * Utility Service\r\n */\r\nclass Utilities {\r\n /**\r\n * Creates an instance of the Utility service\r\n */\r\n constructor(simpleKeyboardInstance) {\r\n /**\r\n * @type {object} A simple-keyboard instance\r\n */\r\n this.simpleKeyboardInstance = simpleKeyboardInstance;\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(Utilities, this);\r\n }\r\n\r\n /**\r\n * Adds default classes to a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @return {string} The classes to be added to the button\r\n */\r\n getButtonClass(button) {\r\n let buttonTypeClass =\r\n button.includes(\"{\") && button.includes(\"}\") && button !== \"{//}\"\r\n ? \"functionBtn\"\r\n : \"standardBtn\";\r\n let buttonWithoutBraces = button.replace(\"{\", \"\").replace(\"}\", \"\");\r\n let buttonNormalized = \"\";\r\n\r\n if (buttonTypeClass !== \"standardBtn\")\r\n buttonNormalized = ` hg-button-${buttonWithoutBraces}`;\r\n\r\n return `hg-${buttonTypeClass}${buttonNormalized}`;\r\n }\r\n\r\n /**\r\n * Default button display labels\r\n */\r\n getDefaultDiplay() {\r\n return {\r\n \"{bksp}\": \"backspace\",\r\n \"{backspace}\": \"backspace\",\r\n \"{enter}\": \"< enter\",\r\n \"{shift}\": \"shift\",\r\n \"{shiftleft}\": \"shift\",\r\n \"{shiftright}\": \"shift\",\r\n \"{alt}\": \"alt\",\r\n \"{s}\": \"shift\",\r\n \"{tab}\": \"tab\",\r\n \"{lock}\": \"caps\",\r\n \"{capslock}\": \"caps\",\r\n \"{accept}\": \"Submit\",\r\n \"{space}\": \" \",\r\n \"{//}\": \" \",\r\n \"{esc}\": \"esc\",\r\n \"{escape}\": \"esc\",\r\n \"{f1}\": \"f1\",\r\n \"{f2}\": \"f2\",\r\n \"{f3}\": \"f3\",\r\n \"{f4}\": \"f4\",\r\n \"{f5}\": \"f5\",\r\n \"{f6}\": \"f6\",\r\n \"{f7}\": \"f7\",\r\n \"{f8}\": \"f8\",\r\n \"{f9}\": \"f9\",\r\n \"{f10}\": \"f10\",\r\n \"{f11}\": \"f11\",\r\n \"{f12}\": \"f12\",\r\n \"{numpaddivide}\": \"/\",\r\n \"{numlock}\": \"lock\",\r\n \"{arrowup}\": \"↑\",\r\n \"{arrowleft}\": \"←\",\r\n \"{arrowdown}\": \"↓\",\r\n \"{arrowright}\": \"→\",\r\n \"{prtscr}\": \"print\",\r\n \"{scrolllock}\": \"scroll\",\r\n \"{pause}\": \"pause\",\r\n \"{insert}\": \"ins\",\r\n \"{home}\": \"home\",\r\n \"{pageup}\": \"up\",\r\n \"{delete}\": \"del\",\r\n \"{end}\": \"end\",\r\n \"{pagedown}\": \"down\",\r\n \"{numpadmultiply}\": \"*\",\r\n \"{numpadsubtract}\": \"-\",\r\n \"{numpadadd}\": \"+\",\r\n \"{numpadenter}\": \"enter\",\r\n \"{period}\": \".\",\r\n \"{numpaddecimal}\": \".\",\r\n \"{numpad0}\": \"0\",\r\n \"{numpad1}\": \"1\",\r\n \"{numpad2}\": \"2\",\r\n \"{numpad3}\": \"3\",\r\n \"{numpad4}\": \"4\",\r\n \"{numpad5}\": \"5\",\r\n \"{numpad6}\": \"6\",\r\n \"{numpad7}\": \"7\",\r\n \"{numpad8}\": \"8\",\r\n \"{numpad9}\": \"9\"\r\n };\r\n }\r\n /**\r\n * Returns the display (label) name for a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {object} display The provided display option\r\n * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.\r\n */\r\n getButtonDisplayName(button, display, mergeDisplay) {\r\n if (mergeDisplay) {\r\n display = Object.assign({}, this.getDefaultDiplay(), display);\r\n } else {\r\n display = display || this.getDefaultDiplay();\r\n }\r\n\r\n return display[button] || button;\r\n }\r\n\r\n /**\r\n * Returns the updated input resulting from clicking a given button\r\n *\r\n * @param {string} button The button's layout name\r\n * @param {string} input The input string\r\n * @param {object} options The simple-keyboard options object\r\n * @param {number} caretPos The cursor's current position\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n getUpdatedInput(button, input, options, caretPos, moveCaret) {\r\n let output = input;\r\n\r\n if (\r\n (button === \"{bksp}\" || button === \"{backspace}\") &&\r\n output.length > 0\r\n ) {\r\n output = this.removeAt(output, caretPos, moveCaret);\r\n } else if (button === \"{space}\")\r\n output = this.addStringAt(output, \" \", caretPos, moveCaret);\r\n else if (\r\n button === \"{tab}\" &&\r\n !(\r\n typeof options.tabCharOnTab === \"boolean\" &&\r\n options.tabCharOnTab === false\r\n )\r\n ) {\r\n output = this.addStringAt(output, \"\\t\", caretPos, moveCaret);\r\n } else if (\r\n (button === \"{enter}\" || button === \"{numpadenter}\") &&\r\n options.newLineOnEnter\r\n )\r\n output = this.addStringAt(output, \"\\n\", caretPos, moveCaret);\r\n else if (\r\n button.includes(\"numpad\") &&\r\n Number.isInteger(Number(button[button.length - 2]))\r\n ) {\r\n output = this.addStringAt(\r\n output,\r\n button[button.length - 2],\r\n caretPos,\r\n moveCaret\r\n );\r\n } else if (button === \"{numpaddivide}\")\r\n output = this.addStringAt(output, \"/\", caretPos, moveCaret);\r\n else if (button === \"{numpadmultiply}\")\r\n output = this.addStringAt(output, \"*\", caretPos, moveCaret);\r\n else if (button === \"{numpadsubtract}\")\r\n output = this.addStringAt(output, \"-\", caretPos, moveCaret);\r\n else if (button === \"{numpadadd}\")\r\n output = this.addStringAt(output, \"+\", caretPos, moveCaret);\r\n else if (button === \"{numpaddecimal}\")\r\n output = this.addStringAt(output, \".\", caretPos, moveCaret);\r\n else if (button === \"{\" || button === \"}\")\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n else if (!button.includes(\"{\") && !button.includes(\"}\"))\r\n output = this.addStringAt(output, button, caretPos, moveCaret);\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Moves the cursor position by a given amount\r\n *\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPos(length, minus) {\r\n let newCaretPos = this.updateCaretPosAction(\r\n this.simpleKeyboardInstance,\r\n length,\r\n minus\r\n );\r\n\r\n if (this.simpleKeyboardInstance.options.syncInstanceInputs) {\r\n this.simpleKeyboardInstance.dispatch(instance => {\r\n instance.caretPosition = newCaretPos;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Action method of updateCaretPos\r\n *\r\n * @param {object} instance The instance whose position should be updated\r\n * @param {number} length Represents by how many characters the input should be moved\r\n * @param {boolean} minus Whether the cursor should be moved to the left or not.\r\n */\r\n updateCaretPosAction(instance, length, minus) {\r\n if (minus) {\r\n if (instance.caretPosition > 0)\r\n instance.caretPosition = instance.caretPosition - length;\r\n } else {\r\n instance.caretPosition = instance.caretPosition + length;\r\n }\r\n\r\n if (this.simpleKeyboardInstance.options.debug) {\r\n console.log(\r\n \"Caret at:\",\r\n instance.caretPosition,\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n\r\n return instance.caretPosition;\r\n }\r\n\r\n /**\r\n * Adds a string to the input at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {string} string The string to add\r\n * @param {number} position The (cursor) position where the string should be added\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n addStringAt(source, string, position, moveCaret) {\r\n let output;\r\n\r\n if (!position && position !== 0) {\r\n output = source + string;\r\n } else {\r\n output = [source.slice(0, position), string, source.slice(position)].join(\r\n \"\"\r\n );\r\n\r\n /**\r\n * Avoid caret position change when maxLength is set\r\n */\r\n if (!this.isMaxLengthReached()) {\r\n if (moveCaret) this.updateCaretPos(string.length);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Removes an amount of characters at a given position\r\n *\r\n * @param {string} source The source input\r\n * @param {number} position The (cursor) position from where the characters should be removed\r\n * @param {boolean} moveCaret Whether to update simple-keyboard's cursor\r\n */\r\n removeAt(source, position, moveCaret) {\r\n if (this.simpleKeyboardInstance.caretPosition === 0) {\r\n return source;\r\n }\r\n\r\n let output;\r\n let prevTwoChars;\r\n let emojiMatched;\r\n let emojiMatchedReg = /([\\uD800-\\uDBFF][\\uDC00-\\uDFFF])/g;\r\n\r\n /**\r\n * Emojis are made out of two characters, so we must take a custom approach to trim them.\r\n * For more info: https://mathiasbynens.be/notes/javascript-unicode\r\n */\r\n if (position && position >= 0) {\r\n prevTwoChars = source.substring(position - 2, position);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.substr(0, position - 2) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.substr(0, position - 1) + source.substr(position);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n } else {\r\n prevTwoChars = source.slice(-2);\r\n emojiMatched = prevTwoChars.match(emojiMatchedReg);\r\n\r\n if (emojiMatched) {\r\n output = source.slice(0, -2);\r\n if (moveCaret) this.updateCaretPos(2, true);\r\n } else {\r\n output = source.slice(0, -1);\r\n if (moveCaret) this.updateCaretPos(1, true);\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n /**\r\n * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.\r\n *\r\n * @param {object} inputObj\r\n * @param {object} options\r\n * @param {string} updatedInput\r\n */\r\n handleMaxLength(inputObj, options, updatedInput) {\r\n let maxLength = options.maxLength;\r\n let currentInput = inputObj[options.inputName];\r\n let condition = currentInput.length === maxLength;\r\n\r\n if (\r\n /**\r\n * If pressing this button won't add more characters\r\n * We exit out of this limiter function\r\n */\r\n updatedInput.length <= currentInput.length\r\n ) {\r\n return false;\r\n }\r\n\r\n if (Number.isInteger(maxLength)) {\r\n if (options.debug) {\r\n console.log(\"maxLength (num) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n /**\r\n * @type {boolean} Boolean value that shows whether maxLength has been reached\r\n */\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n\r\n if (typeof maxLength === \"object\") {\r\n let condition = currentInput.length === maxLength[options.inputName];\r\n\r\n if (options.debug) {\r\n console.log(\"maxLength (obj) reached:\", condition);\r\n }\r\n\r\n if (condition) {\r\n this.maxLengthReached = true;\r\n return true;\r\n } else {\r\n this.maxLengthReached = false;\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of maxLengthReached\r\n */\r\n isMaxLengthReached() {\r\n return Boolean(this.maxLengthReached);\r\n }\r\n\r\n /**\r\n * Determines whether a touch device is being used\r\n */\r\n isTouchDevice() {\r\n return \"ontouchstart\" in window || navigator.maxTouchPoints;\r\n }\r\n\r\n /**\r\n * Determines whether pointer events are supported\r\n */\r\n pointerEventsSupported() {\r\n return window.PointerEvent;\r\n }\r\n\r\n /**\r\n * Bind all methods in a given class\r\n */\r\n\r\n static bindMethods(myClass, instance) {\r\n for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {\r\n let excludeMethod =\r\n myMethod === \"constructor\" || myMethod === \"bindMethods\";\r\n if (!excludeMethod) {\r\n instance[myMethod] = instance[myMethod].bind(instance);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Transforms an arbitrary string to camelCase\r\n *\r\n * @param {string} string The string to transform.\r\n */\r\n camelCase(string) {\r\n return string\r\n .toLowerCase()\r\n .trim()\r\n .split(/[.\\-_\\s]/g)\r\n .reduce((string, word) =>\r\n word.length ? string + word[0].toUpperCase() + word.slice(1) : string\r\n );\r\n }\r\n\r\n /**\r\n * Counts the number of duplicates in a given array\r\n *\r\n * @param {Array} array The haystack to search in\r\n * @param {string} value The needle to search for\r\n */\r\n countInArray(array, value) {\r\n return array.reduce((n, x) => n + (x === value), 0);\r\n }\r\n}\r\n\r\nexport default Utilities;\r\n","import \"./Keyboard.css\";\r\n\r\n// Services\r\nimport PhysicalKeyboard from \"../services/PhysicalKeyboard\";\r\nimport KeyboardLayout from \"../services/KeyboardLayout\";\r\nimport Utilities from \"../services/Utilities\";\r\n\r\n/**\r\n * Root class for simple-keyboard\r\n * This class:\r\n * - Parses the options\r\n * - Renders the rows and buttons\r\n * - Handles button functionality\r\n */\r\nclass SimpleKeyboard {\r\n /**\r\n * Creates an instance of SimpleKeyboard\r\n * @param {Array} params If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.\r\n */\r\n constructor(...params) {\r\n let keyboardDOMQuery =\r\n typeof params[0] === \"string\" ? params[0] : \".simple-keyboard\";\r\n let options = typeof params[0] === \"object\" ? params[0] : params[1];\r\n\r\n if (!options) options = {};\r\n\r\n /**\r\n * Initializing Utilities\r\n */\r\n this.utilities = new Utilities(this);\r\n\r\n /**\r\n * Processing options\r\n */\r\n this.keyboardDOM = document.querySelector(keyboardDOMQuery);\r\n\r\n /**\r\n * @type {object}\r\n * @property {object} layout Modify the keyboard layout.\r\n * @property {string} layoutName Specifies which layout should be used.\r\n * @property {object} display Replaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: “backspace”).\r\n * @property {boolean} mergeDisplay By default, when you set the display property, you replace the default one. This setting merges them instead.\r\n * @property {string} theme A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.\r\n * @property {Array} buttonTheme A prop to add your own css classes to one or several buttons.\r\n * @property {boolean} debug Runs a console.log every time a key is pressed. Displays the buttons pressed and the current input.\r\n * @property {boolean} newLineOnEnter Specifies whether clicking the “ENTER” button will input a newline (\\n) or not.\r\n * @property {boolean} tabCharOnTab Specifies whether clicking the “TAB” button will input a tab character (\\t) or not.\r\n * @property {string} inputName Allows you to use a single simple-keyboard instance for several inputs.\r\n * @property {number} maxLength Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.\r\n * @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.\r\n * @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.\r\n * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.\r\n * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.\r\n * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.\r\n * @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).\r\n * @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.\r\n * @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n * @property {function} onInit Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n * @property {function(inputs: object):object} onChangeAll Executes the callback function on input change. Returns the input object with all defined inputs.\r\n * @property {boolean} useButtonTag Render buttons as a button element instead of a div element.\r\n * @property {boolean} disableCaretPositioning A prop to ensure characters are always be added/removed at the end of the string.\r\n * @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.\r\n * @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.\r\n * @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.\r\n * @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.\r\n */\r\n this.options = options;\r\n this.options.layoutName = this.options.layoutName || \"default\";\r\n this.options.theme = this.options.theme || \"hg-theme-default\";\r\n this.options.inputName = this.options.inputName || \"default\";\r\n this.options.preventMouseDownDefault =\r\n this.options.preventMouseDownDefault || false;\r\n\r\n /**\r\n * @type {object} Classes identifying loaded plugins\r\n */\r\n this.keyboardPluginClasses = \"\";\r\n\r\n /**\r\n * Bindings\r\n */\r\n Utilities.bindMethods(SimpleKeyboard, this);\r\n\r\n /**\r\n * simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).\r\n * This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.\r\n * @example\r\n * // To get entered input\r\n * let input = keyboard.getInput();\r\n *\r\n * // To clear entered input.\r\n * keyboard.clearInput();\r\n *\r\n * @type {object}\r\n * @property {object} default Default SimpleKeyboard internal input.\r\n * @property {object} myInputName Example input that can be set through `options.inputName:\"myInputName\"`.\r\n */\r\n this.input = {};\r\n this.input[this.options.inputName] = \"\";\r\n\r\n /**\r\n * @type {string} DOM class of the keyboard wrapper, normally \"simple-keyboard\" by default.\r\n */\r\n this.keyboardDOMClass = keyboardDOMQuery.split(\".\").join(\"\");\r\n\r\n /**\r\n * @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: \"{enter}\").\r\n */\r\n this.buttonElements = {};\r\n\r\n /**\r\n * Rendering keyboard\r\n */\r\n if (this.keyboardDOM) this.render();\r\n else {\r\n console.warn(`\"${keyboardDOMQuery}\" was not found in the DOM.`);\r\n throw new Error(\"KEYBOARD_DOM_ERROR\");\r\n }\r\n\r\n /**\r\n * Saving instance\r\n * This enables multiple simple-keyboard support with easier management\r\n */\r\n if (!window[\"SimpleKeyboardInstances\"])\r\n window[\"SimpleKeyboardInstances\"] = {};\r\n\r\n window[\"SimpleKeyboardInstances\"][\r\n this.utilities.camelCase(this.keyboardDOMClass)\r\n ] = this;\r\n\r\n /**\r\n * Physical Keyboard support\r\n */\r\n this.physicalKeyboardInterface = new PhysicalKeyboard(this);\r\n\r\n /**\r\n * Modules\r\n */\r\n this.modules = {};\r\n this.loadModules();\r\n }\r\n\r\n /**\r\n * Handles clicks made to keyboard buttons\r\n * @param {string} button The button's layout name.\r\n */\r\n handleButtonClicked(button) {\r\n let debug = this.options.debug;\r\n\r\n /**\r\n * Ignoring placeholder buttons\r\n */\r\n if (button === \"{//}\") return false;\r\n\r\n /**\r\n * Calling onKeyPress\r\n */\r\n if (typeof this.options.onKeyPress === \"function\")\r\n this.options.onKeyPress(button);\r\n\r\n if (!this.input[this.options.inputName])\r\n this.input[this.options.inputName] = \"\";\r\n\r\n let updatedInput = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition\r\n );\r\n\r\n if (\r\n // If input will change as a result of this button press\r\n this.input[this.options.inputName] !== updatedInput &&\r\n // This pertains to the \"inputPattern\" option:\r\n // If inputPattern isn't set\r\n (!this.options.inputPattern ||\r\n // Or, if it is set and if the pattern is valid - we proceed.\r\n (this.options.inputPattern && this.inputPatternIsValid(updatedInput)))\r\n ) {\r\n /**\r\n * If maxLength and handleMaxLength yield true, halting\r\n */\r\n if (\r\n this.options.maxLength &&\r\n this.utilities.handleMaxLength(this.input, this.options, updatedInput)\r\n ) {\r\n return false;\r\n }\r\n\r\n this.input[this.options.inputName] = this.utilities.getUpdatedInput(\r\n button,\r\n this.input[this.options.inputName],\r\n this.options,\r\n this.caretPosition,\r\n true\r\n );\r\n\r\n if (debug) console.log(\"Input changed:\", this.input);\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n /**\r\n * Calling onChange\r\n */\r\n if (typeof this.options.onChange === \"function\")\r\n this.options.onChange(this.input[this.options.inputName]);\r\n\r\n /**\r\n * Calling onChangeAll\r\n */\r\n if (typeof this.options.onChangeAll === \"function\")\r\n this.options.onChangeAll(this.input);\r\n }\r\n\r\n if (debug) {\r\n console.log(\"Key pressed:\", button);\r\n }\r\n }\r\n\r\n /**\r\n * Handles button mousedown\r\n */\r\n /* istanbul ignore next */\r\n handleButtonMouseDown(button, e) {\r\n /**\r\n * Handle event options\r\n */\r\n if (this.options.preventMouseDownDefault) e.preventDefault();\r\n if (this.options.stopMouseDownPropagation) e.stopPropagation();\r\n\r\n /**\r\n * @type {boolean} Whether the mouse is being held onKeyPress\r\n */\r\n this.isMouseHold = true;\r\n\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n if (this.holdTimeout) clearTimeout(this.holdTimeout);\r\n\r\n /**\r\n * @type {object} Time to wait until a key hold is detected\r\n */\r\n this.holdTimeout = setTimeout(() => {\r\n if (\r\n this.isMouseHold &&\r\n ((!button.includes(\"{\") && !button.includes(\"}\")) ||\r\n button === \"{delete}\" ||\r\n button === \"{backspace}\" ||\r\n button === \"{bksp}\" ||\r\n button === \"{space}\" ||\r\n button === \"{tab}\")\r\n ) {\r\n if (this.options.debug) console.log(\"Button held:\", button);\r\n\r\n this.handleButtonHold(button, e);\r\n }\r\n clearTimeout(this.holdTimeout);\r\n }, 500);\r\n }\r\n\r\n /**\r\n * Handles button mouseup\r\n */\r\n handleButtonMouseUp() {\r\n this.isMouseHold = false;\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n }\r\n\r\n /**\r\n * Handles button hold\r\n */\r\n /* istanbul ignore next */\r\n handleButtonHold(button) {\r\n if (this.holdInteractionTimeout) clearTimeout(this.holdInteractionTimeout);\r\n\r\n /**\r\n * @type {object} Timeout dictating the speed of key hold iterations\r\n */\r\n this.holdInteractionTimeout = setTimeout(() => {\r\n if (this.isMouseHold) {\r\n this.handleButtonClicked(button);\r\n this.handleButtonHold(button);\r\n } else {\r\n clearTimeout(this.holdInteractionTimeout);\r\n }\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances (if you have several instances).\r\n */\r\n syncInstanceInputs() {\r\n this.dispatch(instance => {\r\n instance.replaceInput(this.input);\r\n instance.caretPosition = this.caretPosition;\r\n });\r\n }\r\n\r\n /**\r\n * Clear the keyboard’s input.\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n clearInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = \"\";\r\n\r\n /**\r\n * Reset caretPosition\r\n */\r\n this.caretPosition = 0;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Get the keyboard’s input (You can also get it from the onChange prop).\r\n * @param {string} [inputName] optional - the internal input to select\r\n */\r\n getInput(inputName) {\r\n inputName = inputName || this.options.inputName;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n\r\n return this.input[inputName];\r\n }\r\n\r\n /**\r\n * Set the keyboard’s input.\r\n * @param {string} input the input value\r\n * @param {string} inputName optional - the internal input to select\r\n */\r\n setInput(input, inputName) {\r\n inputName = inputName || this.options.inputName;\r\n this.input[inputName] = input;\r\n\r\n /**\r\n * Enforce syncInstanceInputs, if set\r\n */\r\n if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);\r\n }\r\n\r\n /**\r\n * Replace the input object (`keyboard.input`)\r\n * @param {object} inputObj The input object\r\n */\r\n replaceInput(inputObj) {\r\n this.input = inputObj;\r\n }\r\n\r\n /**\r\n * Set new option or modify existing ones after initialization.\r\n * @param {object} options The options to set\r\n */\r\n setOptions(options) {\r\n options = options || {};\r\n this.options = Object.assign(this.options, options);\r\n\r\n /**\r\n * Some option changes require adjustments before re-render\r\n */\r\n this.onSetOptions(options);\r\n\r\n /**\r\n * Rendering\r\n */\r\n this.render();\r\n }\r\n\r\n /**\r\n * Executing actions depending on changed options\r\n * @param {object} options The options to set\r\n */\r\n onSetOptions(options) {\r\n if (options.inputName) {\r\n /**\r\n * inputName changed. This requires a caretPosition reset\r\n */\r\n if (this.options.debug) {\r\n console.log(\"inputName changed. caretPosition reset.\");\r\n }\r\n\r\n this.caretPosition = null;\r\n }\r\n }\r\n\r\n /**\r\n * Remove all keyboard rows and reset keyboard values.\r\n * Used interally between re-renders.\r\n */\r\n clear() {\r\n this.keyboardDOM.innerHTML = \"\";\r\n this.keyboardDOM.className = this.keyboardDOMClass;\r\n this.buttonElements = {};\r\n }\r\n\r\n /**\r\n * Send a command to all simple-keyboard instances at once (if you have multiple instances).\r\n * @param {function(instance: object, key: string)} callback Function to run on every instance\r\n */\r\n dispatch(callback) {\r\n if (!window[\"SimpleKeyboardInstances\"]) {\r\n console.warn(\r\n `SimpleKeyboardInstances is not defined. Dispatch cannot be called.`\r\n );\r\n throw new Error(\"INSTANCES_VAR_ERROR\");\r\n }\r\n\r\n return Object.keys(window[\"SimpleKeyboardInstances\"]).forEach(key => {\r\n callback(window[\"SimpleKeyboardInstances\"][key], key);\r\n });\r\n }\r\n\r\n /**\r\n * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n addButtonTheme(buttons, className) {\r\n if (!className || !buttons) return false;\r\n\r\n buttons.split(\" \").forEach(button => {\r\n className.split(\" \").forEach(classNameItem => {\r\n if (!this.options.buttonTheme) this.options.buttonTheme = [];\r\n\r\n let classNameFound = false;\r\n\r\n /**\r\n * If class is already defined, we add button to class definition\r\n */\r\n this.options.buttonTheme.map(buttonTheme => {\r\n if (buttonTheme.class.split(\" \").includes(classNameItem)) {\r\n classNameFound = true;\r\n\r\n let buttonThemeArray = buttonTheme.buttons.split(\" \");\r\n if (!buttonThemeArray.includes(button)) {\r\n classNameFound = true;\r\n buttonThemeArray.push(button);\r\n buttonTheme.buttons = buttonThemeArray.join(\" \");\r\n }\r\n }\r\n return buttonTheme;\r\n });\r\n\r\n /**\r\n * If class is not defined, we create a new entry\r\n */\r\n if (!classNameFound) {\r\n this.options.buttonTheme.push({\r\n class: classNameItem,\r\n buttons: buttons\r\n });\r\n }\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n\r\n /**\r\n * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.\r\n * @param {string} buttons List of buttons to select (separated by a space).\r\n * @param {string} className Classes to give to the selected buttons (separated by space).\r\n */\r\n removeButtonTheme(buttons, className) {\r\n /**\r\n * When called with empty parameters, remove all button themes\r\n */\r\n if (!buttons && !className) {\r\n this.options.buttonTheme = [];\r\n this.render();\r\n return false;\r\n }\r\n\r\n /**\r\n * If buttons are passed and buttonTheme has items\r\n */\r\n if (\r\n buttons &&\r\n Array.isArray(this.options.buttonTheme) &&\r\n this.options.buttonTheme.length\r\n ) {\r\n let buttonArray = buttons.split(\" \");\r\n buttonArray.forEach((button, key) => {\r\n this.options.buttonTheme.map((buttonTheme, index) => {\r\n /**\r\n * If className is set, we affect the buttons only for that class\r\n * Otherwise, we afect all classes\r\n */\r\n if (\r\n (className && className.includes(buttonTheme.class)) ||\r\n !className\r\n ) {\r\n let filteredButtonArray = buttonTheme.buttons\r\n .split(\" \")\r\n .filter(item => item !== button);\r\n\r\n /**\r\n * If buttons left, return them, otherwise, remove button Theme\r\n */\r\n if (filteredButtonArray.length) {\r\n buttonTheme.buttons = filteredButtonArray.join(\" \");\r\n } else {\r\n this.options.buttonTheme.splice(index, 1);\r\n buttonTheme = null;\r\n }\r\n }\r\n\r\n return buttonTheme;\r\n });\r\n });\r\n\r\n this.render();\r\n }\r\n }\r\n\r\n /**\r\n * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.\r\n * @param {string} button The button layout name to select\r\n */\r\n getButtonElement(button) {\r\n let output;\r\n\r\n let buttonArr = this.buttonElements[button];\r\n if (buttonArr) {\r\n if (buttonArr.length > 1) {\r\n output = buttonArr;\r\n } else {\r\n output = buttonArr[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * This handles the \"inputPattern\" option\r\n * by checking if the provided inputPattern passes\r\n */\r\n inputPatternIsValid(inputVal) {\r\n let inputPatternRaw = this.options.inputPattern;\r\n let inputPattern;\r\n\r\n /**\r\n * Check if input pattern is global or targeted to individual inputs\r\n */\r\n if (inputPatternRaw instanceof RegExp) {\r\n inputPattern = inputPatternRaw;\r\n } else {\r\n inputPattern = inputPatternRaw[this.options.inputName];\r\n }\r\n\r\n if (inputPattern && inputVal) {\r\n let didInputMatch = inputPattern.test(inputVal);\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `inputPattern (\"${inputPattern}\"): ${\r\n didInputMatch ? \"passed\" : \"did not pass!\"\r\n }`\r\n );\r\n }\r\n\r\n return didInputMatch;\r\n } else {\r\n /**\r\n * inputPattern doesn't seem to be set for the current input, or input is empty. Pass.\r\n */\r\n return true;\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the current cursor position within a input or textarea (if any)\r\n */\r\n handleCaret() {\r\n /**\r\n * Only first instance should insall the caret handling events\r\n */\r\n this.caretPosition = null;\r\n let simpleKeyboardInstances = window[\"SimpleKeyboardInstances\"];\r\n\r\n if (\r\n (simpleKeyboardInstances &&\r\n Object.keys(simpleKeyboardInstances)[0] ===\r\n this.utilities.camelCase(this.keyboardDOMClass)) ||\r\n !simpleKeyboardInstances\r\n ) {\r\n if (this.options.debug) {\r\n console.log(`Caret handling started (${this.keyboardDOMClass})`);\r\n }\r\n\r\n document.addEventListener(\"keyup\", this.caretEventHandler);\r\n document.addEventListener(\"mouseup\", this.caretEventHandler);\r\n document.addEventListener(\"touchend\", this.caretEventHandler);\r\n }\r\n }\r\n\r\n /**\r\n * Called by {@link handleCaret} when an event that warrants a cursor position update is triggered\r\n */\r\n caretEventHandler(event) {\r\n let targetTagName;\r\n if (event.target.tagName) {\r\n targetTagName = event.target.tagName.toLowerCase();\r\n }\r\n\r\n this.dispatch(instance => {\r\n if (instance.isMouseHold) {\r\n instance.isMouseHold = false;\r\n }\r\n\r\n if (\r\n (targetTagName === \"textarea\" || targetTagName === \"input\") &&\r\n !instance.options.disableCaretPositioning\r\n ) {\r\n /**\r\n * Tracks current cursor position\r\n * As keys are pressed, text will be added/removed at that position within the input.\r\n */\r\n instance.caretPosition = event.target.selectionStart;\r\n\r\n if (instance.options.debug) {\r\n console.log(\r\n \"Caret at: \",\r\n event.target.selectionStart,\r\n event.target.tagName.toLowerCase(),\r\n `(${instance.keyboardDOMClass})`\r\n );\r\n }\r\n } else if (instance.options.disableCaretPositioning) {\r\n /**\r\n * If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.\r\n */\r\n instance.caretPosition = null;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Process buttonTheme option\r\n */\r\n getButtonTheme() {\r\n let buttonThemesParsed = {};\r\n\r\n this.options.buttonTheme.forEach(themeObj => {\r\n if (themeObj.buttons && themeObj.class) {\r\n let themeButtons;\r\n\r\n if (typeof themeObj.buttons === \"string\") {\r\n themeButtons = themeObj.buttons.split(\" \");\r\n }\r\n\r\n if (themeButtons) {\r\n themeButtons.forEach(themeButton => {\r\n let themeParsed = buttonThemesParsed[themeButton];\r\n\r\n // If the button has already been added\r\n if (themeParsed) {\r\n // Making sure we don't add duplicate classes, even when buttonTheme has duplicates\r\n if (\r\n !this.utilities.countInArray(\r\n themeParsed.split(\" \"),\r\n themeObj.class\r\n )\r\n ) {\r\n buttonThemesParsed[themeButton] = `${themeParsed} ${\r\n themeObj.class\r\n }`;\r\n }\r\n } else {\r\n buttonThemesParsed[themeButton] = themeObj.class;\r\n }\r\n });\r\n }\r\n } else {\r\n console.warn(\r\n `buttonTheme row is missing the \"buttons\" or the \"class\". Please check the documentation.`\r\n );\r\n }\r\n });\r\n\r\n return buttonThemesParsed;\r\n }\r\n\r\n onTouchDeviceDetected() {\r\n /**\r\n * Processing autoTouchEvents\r\n */\r\n this.processAutoTouchEvents();\r\n\r\n /**\r\n * Disabling contextual window on touch devices\r\n */\r\n this.disableContextualWindow();\r\n }\r\n\r\n /**\r\n * Disabling contextual window for hg-button\r\n */\r\n /* istanbul ignore next */\r\n disableContextualWindow() {\r\n window.oncontextmenu = event => {\r\n if (event.target.classList.contains(\"hg-button\")) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return false;\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Process autoTouchEvents option\r\n */\r\n processAutoTouchEvents() {\r\n if (this.options.autoUseTouchEvents) {\r\n this.options.useTouchEvents = true;\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n `autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).\r\n */\r\n onInit() {\r\n if (this.options.debug) {\r\n console.log(`${this.keyboardDOMClass} Initialized`);\r\n }\r\n\r\n /**\r\n * Caret handling\r\n */\r\n this.handleCaret();\r\n\r\n if (typeof this.options.onInit === \"function\") this.options.onInit();\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeFirstRender() {\r\n /**\r\n * Performing actions when touch device detected\r\n */\r\n if (this.utilities.isTouchDevice()) {\r\n this.onTouchDeviceDetected();\r\n }\r\n\r\n if (typeof this.options.beforeFirstRender === \"function\")\r\n this.options.beforeFirstRender();\r\n\r\n /**\r\n * Notify about PointerEvents usage\r\n */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !this.options.useTouchEvents &&\r\n !this.options.useMouseEvents\r\n ) {\r\n if (this.options.debug) {\r\n console.log(\"Using PointerEvents as it is supported by this browser\");\r\n }\r\n }\r\n\r\n /**\r\n * Notify about touch events usage\r\n */\r\n if (this.options.useTouchEvents) {\r\n if (this.options.debug) {\r\n console.log(\r\n \"useTouchEvents has been enabled. Only touch events will be used.\"\r\n );\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Executes the callback function before a simple-keyboard render.\r\n */\r\n beforeRender() {\r\n if (typeof this.options.beforeRender === \"function\")\r\n this.options.beforeRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).\r\n */\r\n onRender() {\r\n if (typeof this.options.onRender === \"function\") this.options.onRender();\r\n }\r\n\r\n /**\r\n * Executes the callback function once all modules have been loaded\r\n */\r\n onModulesLoaded() {\r\n if (typeof this.options.onModulesLoaded === \"function\")\r\n this.options.onModulesLoaded();\r\n }\r\n\r\n /**\r\n * Register module\r\n */\r\n registerModule = (name, initCallback) => {\r\n if (!this.modules[name]) this.modules[name] = {};\r\n\r\n initCallback(this.modules[name]);\r\n };\r\n\r\n /**\r\n * Load modules\r\n */\r\n loadModules() {\r\n if (Array.isArray(this.options.modules)) {\r\n this.options.modules.forEach(Module => {\r\n let module = new Module();\r\n\r\n /* istanbul ignore next */\r\n if (module.constructor.name && module.constructor.name !== \"Function\") {\r\n let classStr = `module-${this.utilities.camelCase(\r\n module.constructor.name\r\n )}`;\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + ` ${classStr}`;\r\n }\r\n\r\n module.init(this);\r\n });\r\n\r\n this.keyboardPluginClasses =\r\n this.keyboardPluginClasses + \" modules-loaded\";\r\n\r\n this.render();\r\n this.onModulesLoaded();\r\n }\r\n }\r\n\r\n /**\r\n * Get module prop\r\n */\r\n getModuleProp(name, prop) {\r\n if (!this.modules[name]) return false;\r\n\r\n return this.modules[name][prop];\r\n }\r\n\r\n /**\r\n * getModulesList\r\n */\r\n getModulesList() {\r\n return Object.keys(this.modules);\r\n }\r\n\r\n /**\r\n * Parse Row DOM containers\r\n */\r\n parseRowDOMContainers(\r\n rowDOM,\r\n rowIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n ) {\r\n let rowDOMArray = Array.from(rowDOM.children);\r\n let removedElements = 0;\r\n\r\n if (rowDOMArray.length) {\r\n containerStartIndexes.forEach((startIndex, arrIndex) => {\r\n let endIndex = containerEndIndexes[arrIndex];\r\n\r\n /**\r\n * If there exists a respective end index\r\n * if end index comes after start index\r\n */\r\n if (!endIndex || !(endIndex > startIndex)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * Updated startIndex, endIndex\r\n * This is since the removal of buttons to place a single button container\r\n * results in a modified array size\r\n */\r\n let updated_startIndex = startIndex - removedElements;\r\n let updated_endIndex = endIndex - removedElements;\r\n\r\n /**\r\n * Create button container\r\n */\r\n let containerDOM = document.createElement(\"div\");\r\n containerDOM.className += \"hg-button-container\";\r\n let containerUID = `${\r\n this.options.layoutName\r\n }-r${rowIndex}c${arrIndex}`;\r\n containerDOM.setAttribute(\"data-skUID\", containerUID);\r\n\r\n /**\r\n * Taking elements due to be inserted into container\r\n */\r\n let containedElements = rowDOMArray.splice(\r\n updated_startIndex,\r\n updated_endIndex - updated_startIndex + 1\r\n );\r\n removedElements = updated_endIndex - updated_startIndex;\r\n\r\n /**\r\n * Inserting elements to container\r\n */\r\n containedElements.forEach(element => containerDOM.appendChild(element));\r\n\r\n /**\r\n * Adding container at correct position within rowDOMArray\r\n */\r\n rowDOMArray.splice(updated_startIndex, 0, containerDOM);\r\n\r\n /**\r\n * Clearing old rowDOM children structure\r\n */\r\n rowDOM.innerHTML = \"\";\r\n\r\n /**\r\n * Appending rowDOM new children list\r\n */\r\n rowDOMArray.forEach(element => rowDOM.appendChild(element));\r\n\r\n if (this.options.debug) {\r\n console.log(\r\n \"rowDOMContainer\",\r\n containedElements,\r\n updated_startIndex,\r\n updated_endIndex,\r\n removedElements + 1\r\n );\r\n }\r\n });\r\n }\r\n\r\n return rowDOM;\r\n }\r\n\r\n /**\r\n * Renders rows and buttons as per options\r\n */\r\n render() {\r\n /**\r\n * Clear keyboard\r\n */\r\n this.clear();\r\n\r\n /**\r\n * Calling beforeFirstRender\r\n */\r\n if (!this.initialized) {\r\n this.beforeFirstRender();\r\n }\r\n\r\n /**\r\n * Calling beforeRender\r\n */\r\n this.beforeRender();\r\n\r\n let layoutClass = `hg-layout-${this.options.layoutName}`;\r\n let layout = this.options.layout || KeyboardLayout.getDefaultLayout();\r\n let useTouchEvents = this.options.useTouchEvents || false;\r\n let useTouchEventsClass = useTouchEvents ? \"hg-touch-events\" : \"\";\r\n let useMouseEvents = this.options.useMouseEvents || false;\r\n let disableRowButtonContainers = this.options.disableRowButtonContainers;\r\n\r\n /**\r\n * Account for buttonTheme, if set\r\n */\r\n let buttonThemesParsed = Array.isArray(this.options.buttonTheme)\r\n ? this.getButtonTheme()\r\n : {};\r\n\r\n /**\r\n * Adding themeClass, layoutClass to keyboardDOM\r\n */\r\n this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${\r\n this.keyboardPluginClasses\r\n } ${useTouchEventsClass}`;\r\n\r\n /**\r\n * Iterating through each row\r\n */\r\n layout[this.options.layoutName].forEach((row, rIndex) => {\r\n let rowArray = row.split(\" \");\r\n\r\n /**\r\n * Creating empty row\r\n */\r\n let rowDOM = document.createElement(\"div\");\r\n rowDOM.className += \"hg-row\";\r\n\r\n /**\r\n * Tracking container indicators in rows\r\n */\r\n let containerStartIndexes = [];\r\n let containerEndIndexes = [];\r\n\r\n /**\r\n * Iterating through each button in row\r\n */\r\n rowArray.forEach((button, bIndex) => {\r\n /**\r\n * Check if button has a container indicator\r\n */\r\n let buttonHasContainerStart =\r\n !disableRowButtonContainers &&\r\n button.includes(\"[\") &&\r\n button.length > 1;\r\n let buttonHasContainerEnd =\r\n !disableRowButtonContainers &&\r\n button.includes(\"]\") &&\r\n button.length > 1;\r\n\r\n /**\r\n * Save container start index, if applicable\r\n */\r\n if (buttonHasContainerStart) {\r\n containerStartIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\[/g, \"\");\r\n }\r\n\r\n if (buttonHasContainerEnd) {\r\n containerEndIndexes.push(bIndex);\r\n\r\n /**\r\n * Removing indicator\r\n */\r\n button = button.replace(/\\]/g, \"\");\r\n }\r\n\r\n /**\r\n * Processing button options\r\n */\r\n let fctBtnClass = this.utilities.getButtonClass(button);\r\n let buttonThemeClass = buttonThemesParsed[button];\r\n let buttonDisplayName = this.utilities.getButtonDisplayName(\r\n button,\r\n this.options.display,\r\n this.options.mergeDisplay\r\n );\r\n\r\n /**\r\n * Creating button\r\n */\r\n let buttonType = this.options.useButtonTag ? \"button\" : \"div\";\r\n let buttonDOM = document.createElement(buttonType);\r\n buttonDOM.className += `hg-button ${fctBtnClass}${\r\n buttonThemeClass ? \" \" + buttonThemeClass : \"\"\r\n }`;\r\n\r\n /**\r\n * Handle button click event\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n /**\r\n * Handle PointerEvents\r\n */\r\n buttonDOM.onpointerdown = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.onpointerup = e => {\r\n this.handleButtonMouseUp();\r\n };\r\n buttonDOM.onpointercancel = e => this.handleButtonMouseUp();\r\n } else {\r\n /**\r\n * Fallback for browsers not supporting PointerEvents\r\n */\r\n if (useTouchEvents) {\r\n /**\r\n * Handle touch events\r\n */\r\n buttonDOM.ontouchstart = e => {\r\n this.handleButtonClicked(button);\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n buttonDOM.ontouchend = e => this.handleButtonMouseUp();\r\n buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else {\r\n /**\r\n * Handle mouse events\r\n */\r\n buttonDOM.onclick = () => {\r\n this.isMouseHold = false;\r\n this.handleButtonClicked(button);\r\n };\r\n buttonDOM.onmousedown = e => {\r\n this.handleButtonMouseDown(button, e);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Adding identifier\r\n */\r\n buttonDOM.setAttribute(\"data-skBtn\", button);\r\n\r\n /**\r\n * Adding unique id\r\n * Since there's no limit on spawning same buttons, the unique id ensures you can style every button\r\n */\r\n let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;\r\n buttonDOM.setAttribute(\"data-skBtnUID\", buttonUID);\r\n\r\n /**\r\n * Adding display label\r\n */\r\n buttonDOM.setAttribute(\"data-displayLabel\", buttonDisplayName);\r\n\r\n /**\r\n * Adding button label to button\r\n */\r\n let buttonSpanDOM = document.createElement(\"span\");\r\n buttonSpanDOM.innerHTML = buttonDisplayName;\r\n buttonDOM.appendChild(buttonSpanDOM);\r\n\r\n /**\r\n * Adding to buttonElements\r\n */\r\n if (!this.buttonElements[button]) this.buttonElements[button] = [];\r\n\r\n this.buttonElements[button].push(buttonDOM);\r\n\r\n /**\r\n * Appending button to row\r\n */\r\n rowDOM.appendChild(buttonDOM);\r\n });\r\n\r\n /**\r\n * Parse containers in row\r\n */\r\n rowDOM = this.parseRowDOMContainers(\r\n rowDOM,\r\n rIndex,\r\n containerStartIndexes,\r\n containerEndIndexes\r\n );\r\n\r\n /**\r\n * Appending row to keyboard\r\n */\r\n this.keyboardDOM.appendChild(rowDOM);\r\n });\r\n\r\n /**\r\n * Calling onRender\r\n */\r\n this.onRender();\r\n\r\n if (!this.initialized) {\r\n /**\r\n * Ensures that onInit and beforeFirstRender are only called once per instantiation\r\n */\r\n this.initialized = true;\r\n\r\n /**\r\n * Handling onpointerup\r\n */\r\n /* istanbul ignore next */\r\n if (\r\n this.utilities.pointerEventsSupported() &&\r\n !useTouchEvents &&\r\n !useMouseEvents\r\n ) {\r\n document.onpointerup = () => this.handleButtonMouseUp();\r\n } else if (useTouchEvents) {\r\n /**\r\n * Handling ontouchend, ontouchcancel\r\n */\r\n document.ontouchend = e => this.handleButtonMouseUp();\r\n document.ontouchcancel = e => this.handleButtonMouseUp();\r\n } else if (!useTouchEvents) {\r\n /**\r\n * Handling mouseup\r\n */\r\n document.onmouseup = () => this.handleButtonMouseUp();\r\n }\r\n\r\n /**\r\n * Calling onInit\r\n */\r\n this.onInit();\r\n }\r\n }\r\n}\r\n\r\nexport default SimpleKeyboard;\r\n","import SimpleKeyboard from \"./components/Keyboard\";\r\nexport default SimpleKeyboard;\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/build/simple-keyboard.js b/build/simple-keyboard.js index 87b3c20f..990e2980 100644 --- a/build/simple-keyboard.js +++ b/build/simple-keyboard.js @@ -1,6 +1,6 @@ /*! * - * simple-keyboard v2.20.9 (Non-minified build) + * simple-keyboard v2.21.0 (Non-minified build) * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) @@ -762,19 +762,6 @@ } 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 @@ -789,12 +776,12 @@ */ function SimpleKeyboard() { var _this = this; Keyboard_classCallCheck(this, SimpleKeyboard); - _defineProperty(this, "registerModule", function(name, initCallback) { + this.registerModule = function(name, initCallback) { if (!_this.modules[name]) { _this.modules[name] = {}; } initCallback(_this.modules[name]); - }); + }; 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) { diff --git a/config/jest/fileTransform.js b/config/jest/fileTransform.js index 07010e33..4ed6bdb0 100644 --- a/config/jest/fileTransform.js +++ b/config/jest/fileTransform.js @@ -10,18 +10,19 @@ module.exports = { const assetFilename = JSON.stringify(path.basename(filename)); if (filename.match(/\.svg$/)) { - return `module.exports = { + return `const React = require('react'); + module.exports = { __esModule: true, default: ${assetFilename}, - ReactComponent: (props) => ({ + ReactComponent: React.forwardRef((props, ref) => ({ $$typeof: Symbol.for('react.element'), type: 'svg', - ref: null, + ref: ref, key: null, props: Object.assign({}, props, { children: ${assetFilename} }) - }), + })), };`; } diff --git a/config/modules.js b/config/modules.js new file mode 100644 index 00000000..4646eb05 --- /dev/null +++ b/config/modules.js @@ -0,0 +1,84 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); +const chalk = require('react-dev-utils/chalk'); + +/** + * Get the baseUrl of a compilerOptions object. + * + * @param {Object} options + */ +function getAdditionalModulePaths(options = {}) { + const baseUrl = options.baseUrl; + + // We need to explicitly check for null and undefined (and not a falsy value) because + // TypeScript treats an empty string as `.`. + if (baseUrl == null) { + // If there's no baseUrl set we respect NODE_PATH + // Note that NODE_PATH is deprecated and will be removed + // in the next major release of create-react-app. + + const nodePath = process.env.NODE_PATH || ''; + return nodePath.split(path.delimiter).filter(Boolean); + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + // We don't need to do anything if `baseUrl` is set to `node_modules`. This is + // the default behavior. + if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { + return null; + } + + // Allow the user set the `baseUrl` to `appSrc`. + if (path.relative(paths.appSrc, baseUrlResolved) === '') { + return [paths.appSrc]; + } + + // Otherwise, throw an error. + throw new Error( + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) + ); +} + +function getModules() { + // Check if TypeScript is setup + const hasTsConfig = fs.existsSync(paths.appTsConfig); + const hasJsConfig = fs.existsSync(paths.appJsConfig); + + if (hasTsConfig && hasJsConfig) { + throw new Error( + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + ); + } + + let config; + + // If there's a tsconfig.json we assume it's a + // TypeScript project and set up the config + // based on tsconfig.json + if (hasTsConfig) { + config = require(paths.appTsConfig); + // Otherwise we'll check if there is jsconfig.json + // for non TS projects. + } else if (hasJsConfig) { + config = require(paths.appJsConfig); + } + + config = config || {}; + const options = config.compilerOptions || {}; + + const additionalModulePaths = getAdditionalModulePaths(options); + + return { + additionalModulePaths: additionalModulePaths, + hasTsConfig, + }; +} + +module.exports = getModules(); diff --git a/config/paths.js b/config/paths.js index 7b5f7cc0..78509b4a 100644 --- a/config/paths.js +++ b/config/paths.js @@ -82,6 +82,7 @@ module.exports = { appSrcLibTypes: resolveApp('src/lib/@types'), appSrcDemo: resolveApp('src/demo'), appTsConfig: resolveApp('tsconfig.json'), + appJsConfig: resolveApp('jsconfig.json'), yarnLockFile: resolveApp('yarn.lock'), testsSetup: resolveModule(resolveApp, 'src/setupTests'), proxySetup: resolveApp('src/setupProxy.js'), diff --git a/config/webpack.config.demo.js b/config/webpack.config.demo.js index 9f08eb58..0a0ef2c3 100644 --- a/config/webpack.config.demo.js +++ b/config/webpack.config.demo.js @@ -1,11 +1,13 @@ 'use strict'; const fs = require('fs'); +const isWsl = require('is-wsl'); 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 CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin'); const TerserPlugin = require('terser-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -14,38 +16,23 @@ const safePostCssParser = require('postcss-safe-parser'); const ManifestPlugin = require('webpack-manifest-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); const WorkboxWebpackPlugin = require('workbox-webpack-plugin'); +const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent'); const paths = require('./paths'); +const modules = require('./modules'); const getClientEnvironment = require('./env'); const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin-alt'); +const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin'); const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); +const postcssNormalize = require('postcss-normalize'); -// 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); - -// Assert this just to be safe. -// Development builds of React are slow and not intended for production. -if (env.stringified['process.env'].NODE_ENV !== '"production"') { - throw new Error('Production builds must have NODE_ENV=production.'); -} // Check if TypeScript is setup const useTypeScript = fs.existsSync(paths.appTsConfig); @@ -56,490 +43,542 @@ const cssModuleRegex = /\.module\.css$/; const sassRegex = /\.(scss|sass)$/; const sassModuleRegex = /\.module\.(scss|sass)$/; -// 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 and development configuration. +// It is focused on developer experience, fast rebuilds, and a minimal bundle. +module.exports = function(webpackEnv) { + const isEnvProduction = webpackEnv === 'production'; -// 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: shouldUseSourceMap ? 'source-map' : false, - // In production, we only want to load the app code. - entry: [paths.appDemoIndexJs], - output: { - // The build folder. - path: paths.appDemo, - // 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: 'index.js', - chunkFilename: 'index.[chunkhash:8].chunk.js', - // We inferred the "public path" (such as / or /my-project) from homepage. - publicPath: publicPath, - // Point sourcemap entries to original disk location (format as URL on Windows) - devtoolModuleFilenameTemplate: info => - path - .relative(paths.appSrcDemo, info.absoluteResourcePath) - .replace(/\\/g, '/'), - }, - optimization: { - minimizer: [ - new TerserPlugin({ - terserOptions: { - parse: { - // we want terser to parse ecma 8 code. However, we don't want it - // to apply any minfication steps that turns valid ecma 5 code - // into invalid ecma 5 code. This is why the 'compress' and 'output' - // sections only apply transformations that are ecma 5 safe - // https://github.com/facebook/create-react-app/pull/4234 - ecma: 8, - }, - compress: { - ecma: 5, - warnings: false, - // Disabled because of an issue with Uglify breaking seemingly valid code: - // https://github.com/facebook/create-react-app/issues/2376 - // Pending further investigation: - // https://github.com/mishoo/UglifyJS2/issues/2011 - comparisons: false, - // Disabled because of an issue with Terser breaking valid code: - // https://github.com/facebook/create-react-app/issues/5250 - // Pending futher investigation: - // https://github.com/terser-js/terser/issues/120 - inline: 2, - }, - mangle: { - safari10: true, - }, - output: { - ecma: 5, - comments: false, - // Turned on because emoji and regex is not minified properly using default - // https://github.com/facebook/create-react-app/issues/2488 - ascii_only: true, - }, + // 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. + // In development, we always serve from the root. This makes config easier. + 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 === './'; + + // `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); + + // common function to get style loaders + const getStyleLoaders = (cssOptions, preProcessor) => { + const loaders = [ + isEnvProduction && { + 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, + }), + // Adds PostCSS Normalize as the reset css with default options, + // so that it honors browserslist config in package.json + // which in turn let's users customize the target behavior as per their needs. + postcssNormalize(), + ], + sourceMap: isEnvProduction && shouldUseSourceMap, }, - // Use multi-process parallel running to improve the build speed - // Default number of concurrent runs: os.cpus().length - 1 - parallel: true, - // Enable file caching - cache: true, - sourceMap: shouldUseSourceMap, - }), - new OptimizeCSSAssetsPlugin({ - cssProcessorOptions: { - parser: safePostCssParser, - map: shouldUseSourceMap - ? { - // `inline: false` forces the sourcemap to be output into a - // separate file - inline: false, - // `annotation: true` appends the sourceMappingURL to the end of - // the css file, helping the browser find the sourcemap - annotation: true, - } - : false, + }, + ].filter(Boolean); + if (preProcessor) { + loaders.push({ + loader: require.resolve(preProcessor), + options: { + sourceMap: isEnvProduction && shouldUseSourceMap, }, - }), - ], - // Automatically split vendor and commons - // https://twitter.com/wSokra/status/969633336732905474 - // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 - splitChunks: { + }); + } + return loaders; + }; + + return { + mode: 'production', + // Stop compilation early in production + bail: isEnvProduction, + devtool: shouldUseSourceMap ? 'source-map' : false, + // These are the "entry points" to our application. + // This means they will be the "root" imports that are included in JS bundle. + entry: isEnvProduction ? [paths.appDemoIndexJs] : [ + // Finally, this is your app's code: + paths.appDemoIndexJs, + // We include the app code last so that if there is a runtime error during + // initialization, it doesn't blow up the WebpackDevServer client, and + // changing JS code would still trigger a refresh. + ].filter(Boolean), + output: { + // The build folder. + path: isEnvProduction ? paths.appDemo : undefined, + // Add /* filename */ comments to generated require()s in the output. + // There will be one main bundle, and one file per asynchronous chunk. + // In development, it does not produce real files. + filename: 'index.js', + // TODO: remove this when upgrading to webpack 5 + futureEmitAssets: true, + // There are also additional JS chunk files if you use code splitting. + chunkFilename: 'static/js/[name].[contenthash:8].chunk.js', + // We inferred the "public path" (such as / or /my-project) from homepage. + // We use "/" in development. + publicPath: publicPath, + // Point sourcemap entries to original disk location (format as URL on Windows) + devtoolModuleFilenameTemplate: isEnvProduction + ? info => + path + .relative(paths.appSrcDemo, info.absoluteResourcePath) + .replace(/\\/g, '/') + : null, + }, + optimization: { + minimize: isEnvProduction, + minimizer: [ + // This is only used in production mode + new TerserPlugin({ + terserOptions: { + parse: { + // we want terser to parse ecma 8 code. However, we don't want it + // to apply any minfication steps that turns valid ecma 5 code + // into invalid ecma 5 code. This is why the 'compress' and 'output' + // sections only apply transformations that are ecma 5 safe + // https://github.com/facebook/create-react-app/pull/4234 + ecma: 8, + }, + compress: { + ecma: 5, + warnings: false, + // Disabled because of an issue with Uglify breaking seemingly valid code: + // https://github.com/facebook/create-react-app/issues/2376 + // Pending further investigation: + // https://github.com/mishoo/UglifyJS2/issues/2011 + comparisons: false, + // Disabled because of an issue with Terser breaking valid code: + // https://github.com/facebook/create-react-app/issues/5250 + // Pending futher investigation: + // https://github.com/terser-js/terser/issues/120 + inline: 2, + }, + mangle: { + safari10: true, + keep_classnames: true, + keep_fnames: true, + module: true + }, + output: { + ecma: 5, + comments: false, + // Turned on because emoji and regex is not minified properly using default + // https://github.com/facebook/create-react-app/issues/2488 + ascii_only: true, + }, + }, + // Use multi-process parallel running to improve the build speed + // Default number of concurrent runs: os.cpus().length - 1 + // Disabled on WSL (Windows Subsystem for Linux) due to an issue with Terser + // https://github.com/webpack-contrib/terser-webpack-plugin/issues/21 + parallel: !isWsl, + // Enable file caching + cache: true, + sourceMap: shouldUseSourceMap, + }), + new OptimizeCSSAssetsPlugin({ + cssProcessorOptions: { + parser: safePostCssParser, + map: shouldUseSourceMap + ? { + // `inline: false` forces the sourcemap to be output into a + // separate file + inline: false, + // `annotation: true` appends the sourceMappingURL to the end of + // the css file, helping the browser find the sourcemap + annotation: true, + } + : false, + }, + }), + ], + // Automatically split vendor and commons + // https://twitter.com/wSokra/status/969633336732905474 + // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 + splitChunks: { /*chunks: 'all', name: false,*/ cacheGroups: { default: false, } - }, - // Keep the runtime chunk seperated to enable long term caching - // https://twitter.com/wSokra/status/969679223278505985 - runtimeChunk: false, - }, - 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.appSrc, [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.appSrcDemo, }, - { - // "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.appSrcDemo, + // Keep the runtime chunk separated to enable long term caching + // https://twitter.com/wSokra/status/969679223278505985 + runtimeChunk: false, + }, + 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', paths.appNodeModules].concat(modules.additionalModulePaths || []), + // 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.appSrc, [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 } }, - 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]', + // First, run the linter. + // It's important to do this before Babel processes the JS. + { + test: /\.(js|mjs|jsx|ts|tsx)$/, + enforce: 'pre', + use: [ + { + options: { + formatter: require.resolve('react-dev-utils/eslintFormatter'), + eslintPath: require.resolve('eslint'), + + }, + loader: require.resolve('eslint-loader'), + }, + ], + include: paths.appSrcDemo, + }, + { + // "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 like "file" loader except that it embeds assets + // smaller than specified limit in bytes as data URLs to avoid requests. + // A missing `test` is equivalent to a match. + { + 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.appSrcDemo, + 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,+ref![path]', + }, }, }, - }, + ], ], - ], - cacheDirectory: true, - // Save disk space when time isn't as important - cacheCompression: true, - compact: true, + // This is a feature of `babel-loader` for webpack (not Babel itself). + // It enables caching results in ./node_modules/.cache/babel-loader/ + // directory for faster rebuilds. + cacheDirectory: true, + cacheCompression: isEnvProduction, + compact: isEnvProduction, + }, }, - }, - // 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: [ - "@babel/preset-env", - "@babel/preset-react" - ], - plugins: [ + // 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 }, + ], + "@babel/preset-env", + "@babel/preset-react" + ], + plugins: [ [ "@babel/plugin-proposal-class-properties" ] - ], - 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, + ], + cacheDirectory: true, + cacheCompression: isEnvProduction, + + // 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, }, - '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, + }, + // "postcss" loader applies autoprefixer to our CSS. + // "css" loader resolves paths in CSS and adds assets as dependencies. + // "style" loader turns CSS into JS modules that inject