/*! * * simple-keyboard v2.7.3 * https://github.com/hodgef/simple-keyboard * * Copyright (c) Francisco Hodge (https://github.com/hodgef) * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ !function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(2);e.default=i.a},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=n(3),s=(n.n(o),n(4)),a=n(5),u=n(6),r="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},h=function(){function t(t,e){for(var n=0;n1?n:n[0]),e}},{key:"handleCaret",value:function(){this.options.debug&&console.log("Caret handling started"),document.addEventListener("keyup",this.caretEventHandler),document.addEventListener("mouseup",this.caretEventHandler),document.addEventListener("touchend",this.caretEventHandler)}},{key:"caretEventHandler",value:function(t){var e=t.target.tagName.toLowerCase();"textarea"!==e&&"input"!==e||(this.caretPosition=t.target.selectionStart,this.options.debug&&console.log("Caret at: ",t.target.selectionStart,t.target.tagName.toLowerCase()))}},{key:"onInit",value:function(){this.options.debug&&console.log("Initialized"),this.handleCaret(),"function"===typeof this.options.onInit&&this.options.onInit()}},{key:"onRender",value:function(){"function"===typeof this.options.onRender&&this.options.onRender()}},{key:"loadModules",value:function(){var t=this;Array.isArray(this.options.modules)&&this.options.modules.forEach(function(e){var n=new e;n.constructor.name&&"Function"!==n.constructor.name&&t.keyboardDOM.classList.add("module-"+t.utilities.camelCase(n.constructor.name)),n.init(t)})}},{key:"render",value:function(){var t=this;this.clear();var e=this.options.layout?"hg-layout-custom":"hg-layout-"+this.options.layoutName,n=this.options.layout||a.a.getDefaultLayout(),i={};Array.isArray(this.options.buttonTheme)&&this.options.buttonTheme.forEach(function(e){if(e.buttons&&e.class){var n=void 0;"string"===typeof e.buttons&&(n=e.buttons.split(" ")),n&&n.forEach(function(n){var o=i[n];o?t.utilities.countInArray(o.split(" "),e.class)||(i[n]=o+" "+e.class):i[n]=e.class})}else console.warn('buttonTheme row is missing the "buttons" or the "class". Please check the documentation.')}),this.keyboardDOM.className+=" "+this.options.theme+" "+e,n[this.options.layoutName].forEach(function(e,n){var o=e.split(" "),s=document.createElement("div");s.className+="hg-row",o.forEach(function(e,o){var a=t.utilities.getButtonClass(e),u=i[e],r=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),h=document.createElement("div");h.className+="hg-button "+a+(u?" "+u:""),h.onclick=function(){return t.handleButtonClicked(e)},h.onmousedown=function(n){return t.handleButtonMouseDown(e,n)},h.setAttribute("data-skBtn",e);var c=t.options.layoutName+"-r"+n+"b"+o;h.setAttribute("data-skBtnUID",c),h.setAttribute("data-displayLabel",r);var l=document.createElement("span");l.innerHTML=r,h.appendChild(l),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(h),s.appendChild(h)}),t.keyboardDOM.appendChild(s)}),this.onRender(),this.initialized||(this.initialized=!0,document.onmouseup=function(){return t.handleButtonMouseUp()},this.onInit())}}]),t}();e.a=c},function(t,e){},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}]),t}();e.a=s},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(){function t(t,e){for(var n=0;n0?o=this.removeAt(o,i):"{space}"===t?o=this.addStringAt(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]))?o=this.addStringAt(o,t[t.length-2],i):"{numpaddivide}"===t?o=this.addStringAt(o,"/",i):"{numpadmultiply}"===t?o=this.addStringAt(o,"*",i):"{numpadsubtract}"===t?o=this.addStringAt(o,"-",i):"{numpadadd}"===t?o=this.addStringAt(o,"+",i):"{numpaddecimal}"===t?o=this.addStringAt(o,".",i):"{"===t||"}"===t?o=this.addStringAt(o,t,i):t.includes("{")||t.includes("}")||(o=this.addStringAt(o,t,i)):o=this.addStringAt(o,"\n",i):o=this.addStringAt(o,"\t",i),o}},{key:"updateCaretPos",value:function(t,e){e?this.simpleKeyboardInstance.caretPosition>0&&(this.simpleKeyboardInstance.caretPosition=this.simpleKeyboardInstance.caretPosition-t):this.simpleKeyboardInstance.caretPosition=this.simpleKeyboardInstance.caretPosition+t}},{key:"addStringAt",value:function(t,e,n){var i=void 0;return this.simpleKeyboardInstance.options.debug&&console.log("Caret at:",n),n||0===n?(i=[t.slice(0,n),e,t.slice(n)].join(""),this.isMaxLengthReached()||this.updateCaretPos(e.length)):i=t+e,i}},{key:"removeAt",value:function(t,e){if(0===this.simpleKeyboardInstance.caretPosition)return t;var n=void 0,i=void 0,o=void 0,s=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?(i=t.substring(e-2,e),o=i.match(s),o?(n=t.substr(0,e-2)+t.substr(e),this.updateCaretPos(2,!0)):(n=t.substr(0,e-1)+t.substr(e),this.updateCaretPos(1,!0))):(i=t.slice(-2),o=i.match(s),o?(n=t.slice(0,-2),this.updateCaretPos(2,!0)):(n=t.slice(0,-1),this.updateCaretPos(1,!0))),n}},{key:"handleMaxLength",value:function(t,e,n){var i=e.maxLength,s=t[e.inputName],a=s.length===i;if(n.length<=s.length)return!1;if(Number.isInteger(i))return e.debug&&console.log("maxLength (num) reached:",a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if("object"===("undefined"===typeof i?"undefined":o(i))){var u=s.length===i[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",u),u?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return Boolean(this.maxLengthReached)}},{key:"camelCase",value:function(t){return t.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(t,e){return t+e[0].toUpperCase()+e.slice(1)})}},{key:"countInArray",value:function(t,e){return t.reduce(function(t,n){return t+(n===e)},0)}}]),t}();e.a=a}])}); //# sourceMappingURL=index.js.map