/*! * * simple-keyboard v2.7.0 * 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 s=n[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,e),s.l=!0,s.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 s=n(3),o=(n.n(s),n(4)),a=n(5),r=n(6),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},c=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:"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 s=i[n];s?t.utilities.countInArray(s.split(" "),e.class)||(i[n]=s+" "+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 s=e.split(" "),o=document.createElement("div");o.className+="hg-row",s.forEach(function(e,s){var a=t.utilities.getButtonClass(e),r=i[e],u=t.utilities.getButtonDisplayName(e,t.options.display,t.options.mergeDisplay),c=document.createElement("div");c.className+="hg-button "+a+(r?" "+r:""),c.onclick=function(){return t.handleButtonClicked(e)},c.setAttribute("data-skBtn",e);var h=t.options.layoutName+"-r"+n+"b"+s;c.setAttribute("data-skBtnUID",h),c.setAttribute("data-displayLabel",u);var l=document.createElement("span");l.innerHTML=u,c.appendChild(l),t.buttonElements[e]||(t.buttonElements[e]=[]),t.buttonElements[e].push(c),o.appendChild(c)}),t.keyboardDOM.appendChild(o)}),this.onRender(),this.initialized||(this.initialized=!0,this.onInit())}}]),t}();e.a=h},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 s=function(){function t(t,e){for(var n=0;n ? {shift}",".com @ {space}"]}}}]),t}();e.a=o},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 s="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},o=function(){function t(t,e){for(var n=0;n0?s=this.removeAt(s,i):"{space}"===t?s=this.addStringAt(s," ",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],i):"{numpaddivide}"===t?s=this.addStringAt(s,"/",i):"{numpadmultiply}"===t?s=this.addStringAt(s,"*",i):"{numpadsubtract}"===t?s=this.addStringAt(s,"-",i):"{numpadadd}"===t?s=this.addStringAt(s,"+",i):"{numpaddecimal}"===t?s=this.addStringAt(s,".",i):"{"===t||"}"===t?s=this.addStringAt(s,t,i):t.includes("{")||t.includes("}")||(s=this.addStringAt(s,t,i)):s=this.addStringAt(s,"\n",i):s=this.addStringAt(s,"\t",i),s}},{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,s=void 0,o=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;return e&&e>=0?(i=t.substring(e-2,e),s=i.match(o),s?(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),s=i.match(o),s?(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,o=t[e.inputName],a=o.length===i;if(n.length<=o.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":s(i))){var r=o.length===i[e.inputName];return e.debug&&console.log("maxLength (obj) reached:",r),r?(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