Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-virtual-keyboard

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-virtual-keyboard - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

tests/unit/button.ts

2

build/index.js

@@ -1,1 +0,1 @@

define("simple-virtual-keyboard",[],(function(){return function(){"use strict";var o={d:function(n,t){for(var e in t)o.o(t,e)&&!o.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:t[e]})},o:function(o,n){return Object.prototype.hasOwnProperty.call(o,n)},r:function(o){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},n={};o.r(n),o.d(n,{DefaultKeyboardLayout:function(){return m},RussianLanguage:function(){return h},default:function(){return f}});var t=function(o,n){o&&Object.assign(o.style,n)};function e(o,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(o,e.key,e)}}var i=function(){function o(n,t){!function(o,n){if(!(o instanceof n))throw new TypeError("Cannot call a class as a function")}(this,o),this.config=n,this.style=t,this.element=null,this.handler=null}var n,i;return n=o,(i=[{key:"code",get:function(){return this.config.code}},{key:"content",get:function(){return this.config.content}},{key:"shiftContent",get:function(){var o;return null!==(o=this.config.shiftContent)&&void 0!==o?o:null}},{key:"isBackspace",get:function(){var o;return null!==(o=this.config.isBackspace)&&void 0!==o&&o}},{key:"isTab",get:function(){var o;return null!==(o=this.config.isTab)&&void 0!==o&&o}},{key:"isCaps",get:function(){var o;return null!==(o=this.config.isCaps)&&void 0!==o&&o}},{key:"isEnter",get:function(){var o;return null!==(o=this.config.isEnter)&&void 0!==o&&o}},{key:"isShift",get:function(){var o;return null!==(o=this.config.isShift)&&void 0!==o&&o}},{key:"isSpace",get:function(){var o;return null!==(o=this.config.isSpace)&&void 0!==o&&o}},{key:"isMeta",get:function(){return this.isBackspace||this.isTab||this.isCaps||this.isEnter||this.isShift||this.isSpace}},{key:"setHandler",value:function(o){this.handler=o}},{key:"toggleCase",value:function(o){this.isMeta||(this.config.content=o?this.content.toUpperCase():this.content.toLowerCase())}},{key:"render",value:function(){var o=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=document.createElement("div");return n.classList.add("a-virtual-keyboard__button"),n.innerText=o&&this.config.shiftContent||this.config.content,t(n,{gridColumn:"".concat(this.config.columnPosition," / span ").concat(this.config.columnSize),gridRow:"".concat(this.config.rowPosition," / span ").concat(this.config.rowSize),justifySelf:"center",alignSelf:"center",background:this.style.background,borderRadius:this.style.borderRadius}),this.element=n,n}},{key:"press",value:function(){var o=this;if(!this.element)throw new Error("Button is not rendered");this.push(),window.setTimeout((function(){return o.unPush()}),this.style.pressDuration)}},{key:"push",value:function(){t(this.element,{background:this.style.pressBackground})}},{key:"unPush",value:function(){t(this.element,{background:this.style.background})}}])&&e(n.prototype,i),o}();function c(o,n){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(o);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),t.push.apply(t,e)}return t}function r(o,n,t){return n in o?Object.defineProperty(o,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[n]=t,o}function s(o,n){if(!(o instanceof n))throw new TypeError("Cannot call a class as a function")}function u(o,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(o,e.key,e)}}function l(o,n){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(o);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),t.push.apply(t,e)}return t}function a(o){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?l(Object(t),!0).forEach((function(n){d(o,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))}))}return o}function d(o,n,t){return n in o?Object.defineProperty(o,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[n]=t,o}var m=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a({columnsCount:15,rowsCount:5,columnGap:"5px",rowGap:"8px",additionalStyles:{maxWidth:"1300px"},onButtonClick:o,style:{padding:"10px",background:"#4cbefa",borderTop:"1px solid #7acffb",borderBottom:"1px solid #49a9db",button:{minWidth:"35px",minHeight:"50px",background:"#78e2aa",border:"1px solid #a1ebc4",borderRadius:"5px",pressDuration:150,pressBackground:"blue"}},buttons:[{columnSize:1,rowSize:1,columnPosition:1,rowPosition:1,code:"Backquote",content:"`",shiftContent:"~"},{columnSize:1,rowSize:1,columnPosition:2,rowPosition:1,code:"Digit1",content:"1",shiftContent:"!"},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:1,code:"Digit2",content:"2",shiftContent:"@"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:1,code:"Digit3",content:"3",shiftContent:"#"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:1,code:"Digit4",content:"4",shiftContent:"$"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:1,code:"Digit5",content:"5",shiftContent:"%"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:1,code:"Digit6",content:"6",shiftContent:"^"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:1,code:"Digit7",content:"7",shiftContent:"7"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:1,code:"Digit8",content:"8",shiftContent:"*"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:1,code:"Digit9",content:"9",shiftContent:"("},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:1,code:"Digit0",content:"0",shiftContent:")"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:1,code:"Minus",content:"-",shiftContent:"_"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:1,code:"Equal",content:"=",shiftContent:"+"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:1,code:"Backspace",content:"<-",isBackspace:!0},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:2,code:"Tab",content:"TAB",isTab:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:2,code:"KeyQ",content:"Q"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:2,code:"KeyW",content:"W"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:2,code:"KeyE",content:"E"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:2,code:"KeyR",content:"R"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:2,code:"KeyT",content:"T"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:2,code:"KeyY",content:"Y"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:2,code:"KeyU",content:"U"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:2,code:"KeyI",content:"I"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:2,code:"KeyO",content:"O"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:2,code:"KeyP",content:"P"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:2,code:"BracketLeft",content:"[",shiftContent:"{"},{columnSize:1,rowSize:1,columnPosition:14,rowPosition:2,code:"BracketRight",content:"]",shiftContent:"}"},{columnSize:1,rowSize:1,columnPosition:15,rowPosition:2,code:"Backslash",content:"\\",shiftContent:"|"},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:3,code:"CapsLock",content:"CAPS",isCaps:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:3,code:"KeyA",content:"A"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:3,code:"KeyS",content:"S"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:3,code:"KeyD",content:"D"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:3,code:"KeyF",content:"F"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:3,code:"KeyG",content:"G"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:3,code:"KeyH",content:"H"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:3,code:"KeyJ",content:"J"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:3,code:"KeyK",content:"K"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:3,code:"KeyL",content:"L"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:3,code:"Semicolon",content:";",shiftContent:":"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:3,code:"Quote",content:"'",shiftContent:'"'},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:3,code:"Enter",content:"ENTER",isEnter:!0},{columnSize:3,rowSize:1,columnPosition:1,rowPosition:4,code:"ShiftLeft",content:"SHIFT",isShift:!0},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:4,code:"KeyZ",content:"Z"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:4,code:"KeyX",content:"X"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:4,code:"KeyC",content:"C"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:4,code:"KeyV",content:"V"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:4,code:"KeyB",content:"B"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:4,code:"KeyN",content:"N"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:4,code:"KeyM",content:"M"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:4,code:"Comma",content:",",shiftContent:"<"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:4,code:"Period",content:".",shiftContent:">"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:4,code:"Slash",content:"/",shiftContent:"?"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:4,code:"ShiftRight",content:"SHIFT",isShift:!0},{columnSize:8,rowSize:1,columnPosition:5,rowPosition:5,code:"Space",content:"",isSpace:!0}]},n)};function S(o,n){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(o);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),t.push.apply(t,e)}return t}function w(o){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?S(Object(t),!0).forEach((function(n){P(o,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):S(Object(t)).forEach((function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))}))}return o}function P(o,n,t){return n in o?Object.defineProperty(o,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[n]=t,o}var h=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return w({columnsCount:15,rowsCount:5,columnGap:"5px",rowGap:"8px",additionalStyles:{maxWidth:"1300px"},onButtonClick:o,style:{padding:"10px",background:"#4cbefa",borderTop:"1px solid #7acffb",borderBottom:"1px solid #49a9db",button:{minWidth:"35px",minHeight:"50px",background:"#78e2aa",border:"1px solid #a1ebc4",borderRadius:"5px",pressDuration:150,pressBackground:"blue"}},buttons:[{columnSize:1,rowSize:1,columnPosition:1,rowPosition:1,code:"Backquote",content:"Ё"},{columnSize:1,rowSize:1,columnPosition:2,rowPosition:1,code:"Digit1",content:"1",shiftContent:"!"},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:1,code:"Digit2",content:"2",shiftContent:"@"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:1,code:"Digit3",content:"3",shiftContent:"#"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:1,code:"Digit4",content:"4",shiftContent:"$"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:1,code:"Digit5",content:"5",shiftContent:"%"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:1,code:"Digit6",content:"6",shiftContent:"^"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:1,code:"Digit7",content:"7",shiftContent:"7"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:1,code:"Digit8",content:"8",shiftContent:"*"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:1,code:"Digit9",content:"9",shiftContent:"("},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:1,code:"Digit0",content:"0",shiftContent:")"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:1,code:"Minus",content:"-",shiftContent:"_"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:1,code:"Equal",content:"=",shiftContent:"+"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:1,code:"Backspace",content:"<-",isBackspace:!0},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:2,code:"Tab",content:"TAB",isTab:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:2,code:"KeyQ",content:"Й"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:2,code:"KeyW",content:"Ц"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:2,code:"KeyE",content:"У"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:2,code:"KeyR",content:"К"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:2,code:"KeyT",content:"Е"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:2,code:"KeyY",content:"Н"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:2,code:"KeyU",content:"Г"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:2,code:"KeyI",content:"Ш"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:2,code:"KeyO",content:"Щ"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:2,code:"KeyP",content:"З"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:2,code:"BracketLeft",content:"Х"},{columnSize:1,rowSize:1,columnPosition:14,rowPosition:2,code:"BracketRight",content:"Ъ"},{columnSize:1,rowSize:1,columnPosition:15,rowPosition:2,code:"Backslash",content:"\\",shiftContent:"/"},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:3,code:"CapsLock",content:"CAPS",isCaps:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:3,code:"KeyA",content:"Ф"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:3,code:"KeyS",content:"Ы"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:3,code:"KeyD",content:"В"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:3,code:"KeyF",content:"А"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:3,code:"KeyG",content:"П"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:3,code:"KeyH",content:"Р"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:3,code:"KeyJ",content:"О"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:3,code:"KeyK",content:"Л"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:3,code:"KeyL",content:"Д"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:3,code:"Semicolon",content:"Ж"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:3,code:"Quote",content:"Э"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:3,code:"Enter",content:"ENTER",isEnter:!0},{columnSize:3,rowSize:1,columnPosition:1,rowPosition:4,code:"ShiftLeft",content:"SHIFT",isShift:!0},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:4,code:"KeyZ",content:"Я"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:4,code:"KeyX",content:"Ч"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:4,code:"KeyC",content:"С"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:4,code:"KeyV",content:"М"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:4,code:"KeyB",content:"И"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:4,code:"KeyN",content:"Т"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:4,code:"KeyM",content:"Ь"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:4,code:"Comma",content:"Б"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:4,code:"Period",content:"Ю"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:4,code:"Slash",content:".",shiftContent:","},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:4,code:"ShiftRight",content:"SHIFT",isShift:!0},{columnSize:8,rowSize:1,columnPosition:5,rowPosition:5,code:"Space",content:"",isSpace:!0}]},n)},f=function(){function o(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];s(this,o),this.languages=[n.layout].concat(t),this.config=n,this.currentLanguageIndex=0,this.rendered=document.createElement("div"),this.renderedButtons=[],this.capsMode=!1,this.init()}var n,e;return n=o,(e=[{key:"layout",get:function(){return this.languages[this.currentLanguageIndex%this.languages.length]}},{key:"addLanguage",value:function(o){this.languages.push(o)}},{key:"changeLanguage",value:function(){this.currentLanguageIndex++,this.rerenderButtons(this.capsMode)}},{key:"init",value:function(){this.rendered.classList.add("a-virtual-keyboard"),t(this.rendered,{width:this.config.width,height:this.config.height}),this.renderLayout(),this.renderButtons(),this.initKeyDown(),this.initShiftChange(),this.initLanguageChange()}},{key:"initKeyDown",value:function(){document.addEventListener("keydown",this.onButtonAction(void 0))}},{key:"initShiftChange",value:function(){var o=this;document.addEventListener("keydown",(function(n){n.shiftKey&&o.enableShiftMode(n.code)})),document.addEventListener("keyup",(function(n){"ShiftRight"!==n.code&&"ShiftLeft"!==n.code||o.disableShiftMode(n.code)}))}},{key:"initLanguageChange",value:function(){var o=this;window.addEventListener("keydown",(function(n){n.ctrlKey&&n.altKey&&o.changeLanguage()}))}},{key:"mount",value:function(o){var n=document.querySelector(o);n&&n.appendChild(this.rendered)}},{key:"destroy",value:function(){this.destroyButtons(),this.rendered.remove()}},{key:"renderLayout",value:function(){t(this.rendered,function(o){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?c(Object(t),!0).forEach((function(n){r(o,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))}))}return o}({display:"grid",gridTemplateColumns:"repeat(".concat(this.layout.columnsCount,", minmax(").concat(this.layout.style.button.minWidth,", 1fr))"),gridTemplateRows:"repeat(".concat(this.layout.rowsCount,", minmax(").concat(this.layout.style.button.minHeight,", 1fr))"),rowGap:this.layout.rowGap,columnGap:this.layout.columnGap,padding:this.layout.style.padding,background:this.layout.style.background,borderTop:this.layout.style.borderTop,borderBottom:this.layout.style.borderBottom,borderLeft:this.layout.style.borderLeft,borderRight:this.layout.style.borderRight,border:this.layout.style.border},this.layout.additionalStyles))}},{key:"enableShiftMode",value:function(o){this.renderedButtons.forEach((function(n){n.isShift&&o===n.code&&n.push()})),this.enableCapsMode()}},{key:"disableShiftMode",value:function(o){this.renderedButtons.forEach((function(n){n.isShift&&o===n.code&&n.unPush()})),this.capsMode&&this.disableCapsMode()}},{key:"onButtonAction",value:function(o){var n=this;return function(t){var e=o;t instanceof KeyboardEvent&&(e=null==t?void 0:t.code);var i=n.renderedButtons.find((function(o){return o.code===e}));if(i){if(null==t||t.preventDefault(),i.isCaps)return void n.toggleCapsMode();i.isShift||i.press(),t instanceof KeyboardEvent&&i.content.toLowerCase()!==i.content.toUpperCase()&&!i.isMeta&&((null==t?void 0:t.key)===i.content.toLowerCase()&&n.disableCapsMode(),(null==t?void 0:t.key)===i.content.toUpperCase()&&n.enableCapsMode());var c=i.content;null!=t&&t.shiftKey&&i.shiftContent&&(c=i.shiftContent),n.layout.onButtonClick(i.code,c,i.isBackspace,i.isTab,i.isEnter,i.isSpace,i.isShift)}}}},{key:"toggleCapsMode",value:function(){this.capsMode=!this.capsMode,this.rerenderButtons()}},{key:"enableCapsMode",value:function(){this.capsMode||(this.capsMode=!0,this.rerenderButtons(!1,!0))}},{key:"disableCapsMode",value:function(){this.capsMode&&(this.capsMode=!1,this.rerenderButtons(!1))}},{key:"rerenderButtons",value:function(){var o=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.destroyButtons(),this.renderButtons(o,n)}},{key:"destroyButtons",value:function(){this.renderedButtons.map((function(o){var n;return null===(n=o.element)||void 0===n?void 0:n.removeEventListener("click",o.handler)})),this.renderedButtons=[],this.rendered.innerHTML=""}},{key:"renderButtons",value:function(){var o=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.layout.buttons.forEach((function(e){var c=new i(e,o.layout.style.button);c.toggleCase(o.capsMode);var r=c.render(t);if(!o.config.listenMode){var s=o.onButtonAction(c.code);c.setHandler(s),r.addEventListener("click",s)}n&&c.isCaps&&c.press(),o.renderedButtons.push(c),o.rendered.appendChild(r)}))}}])&&u(n.prototype,e),o}();return n}()}));
define("simple-virtual-keyboard",[],(function(){return function(){"use strict";var o={d:function(n,t){for(var e in t)o.o(t,e)&&!o.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:t[e]})},o:function(o,n){return Object.prototype.hasOwnProperty.call(o,n)},r:function(o){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},n={};o.r(n),o.d(n,{DefaultKeyboardLayout:function(){return m},RussianLanguage:function(){return h},default:function(){return f}});var t=function(o,n){if(o)try{Object.assign(o.style,n)}catch(o){}};function e(o,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(o,e.key,e)}}var i=function(){function o(n,t){!function(o,n){if(!(o instanceof n))throw new TypeError("Cannot call a class as a function")}(this,o),this.config=n,this.style=t,this.element=null,this.handler=null}var n,i;return n=o,(i=[{key:"code",get:function(){return this.config.code}},{key:"content",get:function(){return this.config.content}},{key:"shiftContent",get:function(){var o;return null!==(o=this.config.shiftContent)&&void 0!==o?o:null}},{key:"isBackspace",get:function(){var o;return null!==(o=this.config.isBackspace)&&void 0!==o&&o}},{key:"isTab",get:function(){var o;return null!==(o=this.config.isTab)&&void 0!==o&&o}},{key:"isCaps",get:function(){var o;return null!==(o=this.config.isCaps)&&void 0!==o&&o}},{key:"isEnter",get:function(){var o;return null!==(o=this.config.isEnter)&&void 0!==o&&o}},{key:"isShift",get:function(){var o;return null!==(o=this.config.isShift)&&void 0!==o&&o}},{key:"isSpace",get:function(){var o;return null!==(o=this.config.isSpace)&&void 0!==o&&o}},{key:"isMeta",get:function(){return this.isBackspace||this.isTab||this.isCaps||this.isEnter||this.isShift||this.isSpace}},{key:"setHandler",value:function(o){this.handler=o}},{key:"toggleCase",value:function(o){this.isMeta||(this.config.content=o?this.content.toUpperCase():this.content.toLowerCase())}},{key:"render",value:function(){var o=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=document.createElement("div");return n.classList.add("a-virtual-keyboard__button"),n.innerText=o&&this.config.shiftContent||this.config.content,t(n,{gridColumn:"".concat(this.config.columnPosition," / span ").concat(this.config.columnSize),gridRow:"".concat(this.config.rowPosition," / span ").concat(this.config.rowSize),justifySelf:"center",alignSelf:"center",background:this.style.background,borderRadius:this.style.borderRadius}),this.element=n,n}},{key:"press",value:function(){var o=this;if(!this.element)throw new Error("Button is not rendered");this.push(),window.setTimeout((function(){return o.unPush()}),this.style.pressDuration)}},{key:"push",value:function(){t(this.element,{background:this.style.pressBackground})}},{key:"unPush",value:function(){t(this.element,{background:this.style.background})}}])&&e(n.prototype,i),o}();function c(o,n){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(o);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),t.push.apply(t,e)}return t}function r(o,n,t){return n in o?Object.defineProperty(o,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[n]=t,o}function s(o,n){if(!(o instanceof n))throw new TypeError("Cannot call a class as a function")}function u(o,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(o,e.key,e)}}function l(o,n){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(o);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),t.push.apply(t,e)}return t}function a(o){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?l(Object(t),!0).forEach((function(n){d(o,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))}))}return o}function d(o,n,t){return n in o?Object.defineProperty(o,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[n]=t,o}var m=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a({columnsCount:15,rowsCount:5,columnGap:"5px",rowGap:"8px",additionalStyles:{maxWidth:"1300px"},onButtonClick:o,style:{padding:"10px",background:"#4cbefa",borderTop:"1px solid #7acffb",borderBottom:"1px solid #49a9db",button:{minWidth:"35px",minHeight:"50px",background:"#78e2aa",border:"1px solid #a1ebc4",borderRadius:"5px",pressDuration:150,pressBackground:"blue"}},buttons:[{columnSize:1,rowSize:1,columnPosition:1,rowPosition:1,code:"Backquote",content:"`",shiftContent:"~"},{columnSize:1,rowSize:1,columnPosition:2,rowPosition:1,code:"Digit1",content:"1",shiftContent:"!"},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:1,code:"Digit2",content:"2",shiftContent:"@"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:1,code:"Digit3",content:"3",shiftContent:"#"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:1,code:"Digit4",content:"4",shiftContent:"$"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:1,code:"Digit5",content:"5",shiftContent:"%"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:1,code:"Digit6",content:"6",shiftContent:"^"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:1,code:"Digit7",content:"7",shiftContent:"7"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:1,code:"Digit8",content:"8",shiftContent:"*"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:1,code:"Digit9",content:"9",shiftContent:"("},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:1,code:"Digit0",content:"0",shiftContent:")"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:1,code:"Minus",content:"-",shiftContent:"_"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:1,code:"Equal",content:"=",shiftContent:"+"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:1,code:"Backspace",content:"<-",isBackspace:!0},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:2,code:"Tab",content:"TAB",isTab:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:2,code:"KeyQ",content:"Q"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:2,code:"KeyW",content:"W"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:2,code:"KeyE",content:"E"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:2,code:"KeyR",content:"R"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:2,code:"KeyT",content:"T"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:2,code:"KeyY",content:"Y"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:2,code:"KeyU",content:"U"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:2,code:"KeyI",content:"I"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:2,code:"KeyO",content:"O"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:2,code:"KeyP",content:"P"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:2,code:"BracketLeft",content:"[",shiftContent:"{"},{columnSize:1,rowSize:1,columnPosition:14,rowPosition:2,code:"BracketRight",content:"]",shiftContent:"}"},{columnSize:1,rowSize:1,columnPosition:15,rowPosition:2,code:"Backslash",content:"\\",shiftContent:"|"},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:3,code:"CapsLock",content:"CAPS",isCaps:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:3,code:"KeyA",content:"A"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:3,code:"KeyS",content:"S"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:3,code:"KeyD",content:"D"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:3,code:"KeyF",content:"F"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:3,code:"KeyG",content:"G"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:3,code:"KeyH",content:"H"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:3,code:"KeyJ",content:"J"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:3,code:"KeyK",content:"K"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:3,code:"KeyL",content:"L"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:3,code:"Semicolon",content:";",shiftContent:":"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:3,code:"Quote",content:"'",shiftContent:'"'},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:3,code:"Enter",content:"ENTER",isEnter:!0},{columnSize:3,rowSize:1,columnPosition:1,rowPosition:4,code:"ShiftLeft",content:"SHIFT",isShift:!0},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:4,code:"KeyZ",content:"Z"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:4,code:"KeyX",content:"X"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:4,code:"KeyC",content:"C"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:4,code:"KeyV",content:"V"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:4,code:"KeyB",content:"B"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:4,code:"KeyN",content:"N"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:4,code:"KeyM",content:"M"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:4,code:"Comma",content:",",shiftContent:"<"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:4,code:"Period",content:".",shiftContent:">"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:4,code:"Slash",content:"/",shiftContent:"?"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:4,code:"ShiftRight",content:"SHIFT",isShift:!0},{columnSize:8,rowSize:1,columnPosition:5,rowPosition:5,code:"Space",content:"",isSpace:!0}]},n)};function S(o,n){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(o);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),t.push.apply(t,e)}return t}function w(o){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?S(Object(t),!0).forEach((function(n){P(o,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):S(Object(t)).forEach((function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))}))}return o}function P(o,n,t){return n in o?Object.defineProperty(o,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[n]=t,o}var h=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return w({columnsCount:15,rowsCount:5,columnGap:"5px",rowGap:"8px",additionalStyles:{maxWidth:"1300px"},onButtonClick:o,style:{padding:"10px",background:"#4cbefa",borderTop:"1px solid #7acffb",borderBottom:"1px solid #49a9db",button:{minWidth:"35px",minHeight:"50px",background:"#78e2aa",border:"1px solid #a1ebc4",borderRadius:"5px",pressDuration:150,pressBackground:"blue"}},buttons:[{columnSize:1,rowSize:1,columnPosition:1,rowPosition:1,code:"Backquote",content:"Ё"},{columnSize:1,rowSize:1,columnPosition:2,rowPosition:1,code:"Digit1",content:"1",shiftContent:"!"},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:1,code:"Digit2",content:"2",shiftContent:"@"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:1,code:"Digit3",content:"3",shiftContent:"#"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:1,code:"Digit4",content:"4",shiftContent:"$"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:1,code:"Digit5",content:"5",shiftContent:"%"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:1,code:"Digit6",content:"6",shiftContent:"^"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:1,code:"Digit7",content:"7",shiftContent:"7"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:1,code:"Digit8",content:"8",shiftContent:"*"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:1,code:"Digit9",content:"9",shiftContent:"("},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:1,code:"Digit0",content:"0",shiftContent:")"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:1,code:"Minus",content:"-",shiftContent:"_"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:1,code:"Equal",content:"=",shiftContent:"+"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:1,code:"Backspace",content:"<-",isBackspace:!0},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:2,code:"Tab",content:"TAB",isTab:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:2,code:"KeyQ",content:"Й"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:2,code:"KeyW",content:"Ц"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:2,code:"KeyE",content:"У"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:2,code:"KeyR",content:"К"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:2,code:"KeyT",content:"Е"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:2,code:"KeyY",content:"Н"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:2,code:"KeyU",content:"Г"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:2,code:"KeyI",content:"Ш"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:2,code:"KeyO",content:"Щ"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:2,code:"KeyP",content:"З"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:2,code:"BracketLeft",content:"Х"},{columnSize:1,rowSize:1,columnPosition:14,rowPosition:2,code:"BracketRight",content:"Ъ"},{columnSize:1,rowSize:1,columnPosition:15,rowPosition:2,code:"Backslash",content:"\\",shiftContent:"/"},{columnSize:2,rowSize:1,columnPosition:1,rowPosition:3,code:"CapsLock",content:"CAPS",isCaps:!0},{columnSize:1,rowSize:1,columnPosition:3,rowPosition:3,code:"KeyA",content:"Ф"},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:3,code:"KeyS",content:"Ы"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:3,code:"KeyD",content:"В"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:3,code:"KeyF",content:"А"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:3,code:"KeyG",content:"П"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:3,code:"KeyH",content:"Р"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:3,code:"KeyJ",content:"О"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:3,code:"KeyK",content:"Л"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:3,code:"KeyL",content:"Д"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:3,code:"Semicolon",content:"Ж"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:3,code:"Quote",content:"Э"},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:3,code:"Enter",content:"ENTER",isEnter:!0},{columnSize:3,rowSize:1,columnPosition:1,rowPosition:4,code:"ShiftLeft",content:"SHIFT",isShift:!0},{columnSize:1,rowSize:1,columnPosition:4,rowPosition:4,code:"KeyZ",content:"Я"},{columnSize:1,rowSize:1,columnPosition:5,rowPosition:4,code:"KeyX",content:"Ч"},{columnSize:1,rowSize:1,columnPosition:6,rowPosition:4,code:"KeyC",content:"С"},{columnSize:1,rowSize:1,columnPosition:7,rowPosition:4,code:"KeyV",content:"М"},{columnSize:1,rowSize:1,columnPosition:8,rowPosition:4,code:"KeyB",content:"И"},{columnSize:1,rowSize:1,columnPosition:9,rowPosition:4,code:"KeyN",content:"Т"},{columnSize:1,rowSize:1,columnPosition:10,rowPosition:4,code:"KeyM",content:"Ь"},{columnSize:1,rowSize:1,columnPosition:11,rowPosition:4,code:"Comma",content:"Б"},{columnSize:1,rowSize:1,columnPosition:12,rowPosition:4,code:"Period",content:"Ю"},{columnSize:1,rowSize:1,columnPosition:13,rowPosition:4,code:"Slash",content:".",shiftContent:","},{columnSize:2,rowSize:1,columnPosition:14,rowPosition:4,code:"ShiftRight",content:"SHIFT",isShift:!0},{columnSize:8,rowSize:1,columnPosition:5,rowPosition:5,code:"Space",content:"",isSpace:!0}]},n)},f=function(){function o(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];s(this,o),this.languages=[n.layout].concat(t),this.config=n,this.currentLanguageIndex=0,this.rendered=document.createElement("div"),this.renderedButtons=[],this.capsMode=!1,this.init()}var n,e;return n=o,(e=[{key:"languagesList",get:function(){return this.languages}},{key:"layout",get:function(){return this.languages[this.currentLanguageIndex%this.languages.length]}},{key:"addLanguage",value:function(o){this.languages.push(o)}},{key:"changeLanguage",value:function(){this.currentLanguageIndex++,this.rerenderButtons(this.capsMode)}},{key:"init",value:function(){this.rendered.classList.add("a-virtual-keyboard"),t(this.rendered,{width:this.config.width,height:this.config.height}),this.renderLayout(),this.renderButtons(),this.initKeyDown(),this.initShiftChange(),this.initLanguageChange()}},{key:"initKeyDown",value:function(){document.addEventListener("keydown",this.onButtonAction(void 0))}},{key:"initShiftChange",value:function(){var o=this;document.addEventListener("keydown",(function(n){n.shiftKey&&o.enableShiftMode(n.code)})),document.addEventListener("keyup",(function(n){"ShiftRight"!==n.code&&"ShiftLeft"!==n.code||o.disableShiftMode(n.code)}))}},{key:"initLanguageChange",value:function(){var o=this;window.addEventListener("keydown",(function(n){n.ctrlKey&&n.altKey&&o.changeLanguage()}))}},{key:"mount",value:function(o){var n=document.querySelector(o);n&&n.appendChild(this.rendered)}},{key:"destroy",value:function(){this.destroyButtons(),this.rendered.remove()}},{key:"renderLayout",value:function(){t(this.rendered,function(o){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?c(Object(t),!0).forEach((function(n){r(o,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))}))}return o}({display:"grid",gridTemplateColumns:"repeat(".concat(this.layout.columnsCount,", minmax(").concat(this.layout.style.button.minWidth,", 1fr))"),gridTemplateRows:"repeat(".concat(this.layout.rowsCount,", minmax(").concat(this.layout.style.button.minHeight,", 1fr))"),rowGap:this.layout.rowGap,columnGap:this.layout.columnGap,padding:this.layout.style.padding,background:this.layout.style.background,borderTop:this.layout.style.borderTop,borderBottom:this.layout.style.borderBottom,borderLeft:this.layout.style.borderLeft,borderRight:this.layout.style.borderRight,border:this.layout.style.border},this.layout.additionalStyles))}},{key:"enableShiftMode",value:function(o){this.renderedButtons.forEach((function(n){n.isShift&&o===n.code&&n.push()})),this.enableCapsMode()}},{key:"disableShiftMode",value:function(o){this.renderedButtons.forEach((function(n){n.isShift&&o===n.code&&n.unPush()})),this.capsMode&&this.disableCapsMode()}},{key:"onButtonAction",value:function(o){var n=this;return function(t){var e=o;t instanceof KeyboardEvent&&(e=null==t?void 0:t.code);var i=n.renderedButtons.find((function(o){return o.code===e}));if(i){if(null==t||t.preventDefault(),i.isCaps)return void n.toggleCapsMode();i.isShift||i.press(),t instanceof KeyboardEvent&&i.content.toLowerCase()!==i.content.toUpperCase()&&!i.isMeta&&((null==t?void 0:t.key)===i.content.toLowerCase()&&n.disableCapsMode(),(null==t?void 0:t.key)===i.content.toUpperCase()&&n.enableCapsMode());var c=i.content;null!=t&&t.shiftKey&&i.shiftContent&&(c=i.shiftContent),n.layout.onButtonClick(i.code,c,i.isBackspace,i.isTab,i.isEnter,i.isSpace,i.isShift)}}}},{key:"toggleCapsMode",value:function(){this.capsMode=!this.capsMode,this.rerenderButtons()}},{key:"enableCapsMode",value:function(){this.capsMode||(this.capsMode=!0,this.rerenderButtons(!1,!0))}},{key:"disableCapsMode",value:function(){this.capsMode&&(this.capsMode=!1,this.rerenderButtons(!1))}},{key:"rerenderButtons",value:function(){var o=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.destroyButtons(),this.renderButtons(o,n)}},{key:"destroyButtons",value:function(){this.renderedButtons.map((function(o){var n;return null===(n=o.element)||void 0===n?void 0:n.removeEventListener("click",o.handler)})),this.renderedButtons=[],this.rendered.innerHTML=""}},{key:"renderButtons",value:function(){var o=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.layout.buttons.forEach((function(e){var c=new i(e,o.layout.style.button);c.toggleCase(o.capsMode);var r=c.render(t);if(!o.config.listenMode){var s=o.onButtonAction(c.code);c.setHandler(s),r.addEventListener("click",s)}n&&c.isCaps&&c.press(),o.renderedButtons.push(c),o.rendered.appendChild(r)}))}}])&&u(n.prototype,e),o}();return n}()}));

@@ -10,2 +10,3 @@ import { KeyboardConfig, KeyboardLayoutInterface } from "../types";

constructor(config: KeyboardConfig, languages?: KeyboardLayoutInterface[]);
get languagesList(): KeyboardLayoutInterface[];
get layout(): KeyboardLayoutInterface;

@@ -12,0 +13,0 @@ addLanguage(layout: KeyboardLayoutInterface): void;

import "./index.scss"
import Keyboard, { DefaultKeyboardLayout, RussianLanguage } from "../src/index"
import {KeyboardLayoutInterface} from "../src/types";
import { KeyboardLayoutInterface } from "../src/types"

@@ -50,3 +50,3 @@ const writeText = (

const keyboard = new Keyboard({
layout: DefaultKeyboardLayout(writeText, layoutConfig),
layout: DefaultKeyboardLayout(writeText, layoutConfig),
width: "100%"

@@ -53,0 +53,0 @@ },

@@ -5,3 +5,3 @@ module.exports = {

preset: "ts-jest",
testEnvironment: "node",
testEnvironment: "jsdom",

@@ -16,2 +16,3 @@ globals: {

"^.+\\.tsx?$": "ts-jest",
".+\\.(css|sass|scss)$": "jest-transform-stub"
},

@@ -18,0 +19,0 @@

{
"name": "simple-virtual-keyboard",
"version": "0.2.1",
"version": "0.2.2",
"description": "Virtual keyboard",

@@ -27,2 +27,3 @@ "main": "./build/index.js",

"jest": "^26.6.3",
"jest-transform-stub": "^2.0.0",
"mini-css-extract-plugin": "^1.5.1",

@@ -29,0 +30,0 @@ "sass": "^1.32.12",

@@ -1,1 +0,48 @@

# virtual-keyboard
# Simple Virtual Keyboard
Install:
npm i -S simple-virtual-keyboard
Setup:
const keyboard = new Keyboard({
layout: DefaultKeyboardLayout(handler, layoutConfig)
})
Add languages (en and ru built-in):
const keyboard = new Keyboard({
layout: DefaultKeyboardLayout(handler, layoutConfig),
width: "100%" // ...layout additional settings
}, [
// Languages list
RussianLanguage(writeText, layoutConfig)
])
Custom layout and languages:
const Language/Layout = (
onPress: (
code: string,
content: string,
isBackspace: boolean,
isTab: boolean,
isEnter: boolean,
isSpace: boolean,
isShift: boolean
) => void = () => {},
additionalSettings: Partial<KeyboardLayoutInterface> = {}
): KeyboardLayoutInterface => {
return {
...your language/layout config
}
)
## Demo
git clone https://github.com/Arslanoov/virtual-keyboard.git
npm i
npm run demo

@@ -24,2 +24,6 @@ import { KeyboardConfig, KeyboardLayoutInterface } from "../types"

public get languagesList(): KeyboardLayoutInterface[] {
return this.languages
}
public get layout(): KeyboardLayoutInterface {

@@ -26,0 +30,0 @@ return this.languages[this.currentLanguageIndex % this.languages.length]

@@ -5,4 +5,7 @@ import * as CSS from "csstype"

if (element) {
Object.assign(element.style, styles)
// TODO: Remove try catch
try {
Object.assign(element.style, styles)
} catch (e) { }
}
}
import { KeyboardLayoutInterface } from "../../types"
import { DefaultKeyboardLayout } from "../default"
const RussianLanguage = (

@@ -6,0 +4,0 @@ onPress: (

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc