mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-02-03 00:06:50 +08:00
Compare commits
396 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
067e263996 | ||
|
|
a6c5e82abd | ||
|
|
3bb940ee27 | ||
|
|
816f4c7e2c | ||
|
|
b53ff0af0a | ||
|
|
e190285635 | ||
|
|
a8e7a5ce7c | ||
|
|
fb4760da9c | ||
|
|
615ac63476 | ||
|
|
15a15d46de | ||
|
|
bcd76de6d3 | ||
|
|
ed0abfeea6 | ||
|
|
1a5d917a7d | ||
|
|
304f47701e | ||
|
|
7fd757cd02 | ||
|
|
042ba7fc5c | ||
|
|
6938d4b00d | ||
|
|
d2880e8322 | ||
|
|
e2b702e063 | ||
|
|
d7567c3aea | ||
|
|
bf958ba4f2 | ||
|
|
3e465b9193 | ||
|
|
dabf471a8f | ||
|
|
4f644d19e0 | ||
|
|
aa4a262d79 | ||
|
|
5ef6f640c4 | ||
|
|
33b9a70bf6 | ||
|
|
c7226298ab | ||
|
|
580662fced | ||
|
|
31cfd468eb | ||
|
|
31a55dd8f0 | ||
|
|
5429193def | ||
|
|
08e178129f | ||
|
|
1b53dfbbd5 | ||
|
|
58c7b04920 | ||
|
|
fb22ecb989 | ||
|
|
bc45759719 | ||
|
|
5e072db2d0 | ||
|
|
2582b646fe | ||
|
|
39cad2bf91 | ||
|
|
ba01a6a7ae | ||
|
|
c4f7a8ae00 | ||
|
|
bab6f45da4 | ||
|
|
447dd76da3 | ||
|
|
73da0d0fae | ||
|
|
10bf33aa74 | ||
|
|
5bedce1b5e | ||
|
|
74e7d2897b | ||
|
|
c00206311b | ||
|
|
51e8670bdc | ||
|
|
f6913455d1 | ||
|
|
f740cb0099 | ||
|
|
c57c9b90c0 | ||
|
|
ad23041c3e | ||
|
|
b696846d15 | ||
|
|
78516edc92 | ||
|
|
6fefde3c16 | ||
|
|
930426d909 | ||
|
|
ba7b99bcd5 | ||
|
|
efa83a6c5e | ||
|
|
b54e70d0ab | ||
|
|
470170678c | ||
|
|
ddccc24d77 | ||
|
|
a80d78da9a | ||
|
|
33140ccd91 | ||
|
|
3129cd4123 | ||
|
|
90c0969db5 | ||
|
|
9862a66384 | ||
|
|
e7496e124f | ||
|
|
a7c14502e5 | ||
|
|
152a7e3535 | ||
|
|
4986d616c4 | ||
|
|
ff35c2ce9d | ||
|
|
e415e93f71 | ||
|
|
cafe4550c3 | ||
|
|
ded2173743 | ||
|
|
ba21a94cd3 | ||
|
|
6481b486ae | ||
|
|
3346506b1c | ||
|
|
c5b7793a5c | ||
|
|
11738a5ad6 | ||
|
|
40553f2201 | ||
|
|
b800ea17f9 | ||
|
|
055dffbcad | ||
|
|
5e136a133f | ||
|
|
c3ea9e2d52 | ||
|
|
27e432a0be | ||
|
|
bd0125c735 | ||
|
|
b5a3e63e65 | ||
|
|
ed3ba17d9c | ||
|
|
fa97d4d1ed | ||
|
|
81d2db7a35 | ||
|
|
a1fdbd540f | ||
|
|
43720df656 | ||
|
|
b85684a25b | ||
|
|
27910f25eb | ||
|
|
5f390a4a31 | ||
|
|
63fa6471e1 | ||
|
|
c4d27dc670 | ||
|
|
e490029c0c | ||
|
|
fda25e37e6 | ||
|
|
564694e88a | ||
|
|
5195f3de97 | ||
|
|
21926a9e71 | ||
|
|
aa200d6d01 | ||
|
|
3c3bd6c096 | ||
|
|
8272f2501e | ||
|
|
9b06121360 | ||
|
|
cacc2b3f5e | ||
|
|
d7eec56879 | ||
|
|
ba8663b2cc | ||
|
|
5474f93af0 | ||
|
|
577919fbe3 | ||
|
|
5ab3f9bbb8 | ||
|
|
9eee8b22ff | ||
|
|
5b32ed7b4b | ||
|
|
5a45ecc6c2 | ||
|
|
e08e17f42e | ||
|
|
d67461f602 | ||
|
|
26cb250af3 | ||
|
|
e97888bb55 | ||
|
|
e829181ff1 | ||
|
|
2dfaeaa352 | ||
|
|
fa252e673c | ||
|
|
e19e825c7f | ||
|
|
fd72f373b3 | ||
|
|
5cdfdfcdac | ||
|
|
5e70c0039f | ||
|
|
171bec5152 | ||
|
|
c100f15011 | ||
|
|
469d71948d | ||
|
|
bcf303cf8c | ||
|
|
c7504ec8c4 | ||
|
|
9c00c3b8f0 | ||
|
|
eb80655d4d | ||
|
|
333f970bb7 | ||
|
|
6fab38a8ba | ||
|
|
73d25710d3 | ||
|
|
e98d6ac70e | ||
|
|
8a8634f8f7 | ||
|
|
a42416b656 | ||
|
|
ed1f133847 | ||
|
|
499ddaf1a2 | ||
|
|
751b576eb6 | ||
|
|
da05617dbd | ||
|
|
a46a47266a | ||
|
|
6d9983698c | ||
|
|
477b5ebf89 | ||
|
|
ecaa9e957e | ||
|
|
e6f1b10380 | ||
|
|
d771bdfaac | ||
|
|
48077022e9 | ||
|
|
73ca8ad39b | ||
|
|
0cdb9f3aa3 | ||
|
|
957eb1eb81 | ||
|
|
a3557928f2 | ||
|
|
da7a38aebb | ||
|
|
f6e8ee2aed | ||
|
|
c6fb63ed79 | ||
|
|
574d3745da | ||
|
|
f61f6b63d8 | ||
|
|
b48b5343f3 | ||
|
|
d44191ed8f | ||
|
|
6a0a34fff2 | ||
|
|
21fe8fe6f5 | ||
|
|
1def9346d1 | ||
|
|
2c27b29bba | ||
|
|
27e316bc85 | ||
|
|
49e292c38b | ||
|
|
722da50075 | ||
|
|
81bab0cc7f | ||
|
|
25d81255a6 | ||
|
|
5a4b450424 | ||
|
|
4b1d916ead | ||
|
|
1931f7d586 | ||
|
|
de79e024c4 | ||
|
|
c100d8f121 | ||
|
|
0dde36cd40 | ||
|
|
cf373f96f1 | ||
|
|
159ecab351 | ||
|
|
cec0939258 | ||
|
|
ffacdc5a18 | ||
|
|
6c21740033 | ||
|
|
99f57474ef | ||
|
|
ce31e09de5 | ||
|
|
7a8f6c820c | ||
|
|
df055ca208 | ||
|
|
def4992ceb | ||
|
|
2ef451cd07 | ||
|
|
c77f8373b7 | ||
|
|
942fcd816f | ||
|
|
9a6b835a4d | ||
|
|
b8006a49b4 | ||
|
|
a22cef5acc | ||
|
|
2721107490 | ||
|
|
6cf8acc200 | ||
|
|
bc95a52bd7 | ||
|
|
aa2d6e2cdd | ||
|
|
2c037fc3a6 | ||
|
|
5ccb748bb5 | ||
|
|
4586780312 | ||
|
|
aff7c2ec2e | ||
|
|
995e0749be | ||
|
|
d001d305c8 | ||
|
|
6244c1a59f | ||
|
|
5289c873b2 | ||
|
|
2af73414be | ||
|
|
2f57368cd0 | ||
|
|
0a9944bfd7 | ||
|
|
c774a39bba | ||
|
|
c555b11c05 | ||
|
|
684698f0f6 | ||
|
|
116edf3d82 | ||
|
|
f43aa20056 | ||
|
|
40814c74c7 | ||
|
|
70e5db4ff8 | ||
|
|
8a0002b126 | ||
|
|
453efa1e47 | ||
|
|
dded50fde7 | ||
|
|
e7edbcc7c9 | ||
|
|
786198724f | ||
|
|
060f57bfd7 | ||
|
|
ef67533fac | ||
|
|
05d39f7ab6 | ||
|
|
171ff97a06 | ||
|
|
27bb6bca8b | ||
|
|
ebef626bb5 | ||
|
|
ac23908870 | ||
|
|
f1f97cd768 | ||
|
|
2bf20c133f | ||
|
|
67a4806268 | ||
|
|
ffd1d98ebe | ||
|
|
c9d1dd666e | ||
|
|
a6a2ed0d08 | ||
|
|
f9f82e8102 | ||
|
|
e1ec7d2144 | ||
|
|
df8ecc9b63 | ||
|
|
402bfe5c74 | ||
|
|
faf3590cfc | ||
|
|
3c3c300d65 | ||
|
|
32880a914f | ||
|
|
d31612f01b | ||
|
|
eddd2c4349 | ||
|
|
d81b0dc253 | ||
|
|
6d6111da98 | ||
|
|
ed5c00fa3f | ||
|
|
d69a7fe928 | ||
|
|
7acc785637 | ||
|
|
b92e732045 | ||
|
|
8fd20caa6c | ||
|
|
4be2e97851 | ||
|
|
b98dcdfc45 | ||
|
|
ea218c6827 | ||
|
|
5cc57cb96e | ||
|
|
f8f963e4ac | ||
|
|
6dc4c6514c | ||
|
|
9eb7982c90 | ||
|
|
1f83c23af9 | ||
|
|
32b2bf1e1e | ||
|
|
2f1db1b0cc | ||
|
|
548261320a | ||
|
|
0a7ca1b9e7 | ||
|
|
ea9eb80221 | ||
|
|
0ef76329d1 | ||
|
|
ba0791069c | ||
|
|
eaecfa4efc | ||
|
|
a94c43c6f0 | ||
|
|
ba5559927d | ||
|
|
51e9b7b6af | ||
|
|
6b02948345 | ||
|
|
af372680ea | ||
|
|
dd515e3391 | ||
|
|
a5aa4eb259 | ||
|
|
4a97b1763f | ||
|
|
3d5443f537 | ||
|
|
c0bfe1108f | ||
|
|
beb33c187b | ||
|
|
e773509fd6 | ||
|
|
e50f7fc7f4 | ||
|
|
5f7fb53701 | ||
|
|
b53dd26c8e | ||
|
|
918bc466f8 | ||
|
|
a6bae74706 | ||
|
|
e5c84a43f8 | ||
|
|
63f3b829b6 | ||
|
|
97a1d42616 | ||
|
|
86f322f08b | ||
|
|
e1655ac0f7 | ||
|
|
883a53af96 | ||
|
|
0deeda65d0 | ||
|
|
27c5da0098 | ||
|
|
e0fd3e22e1 | ||
|
|
5ba1c707eb | ||
|
|
39889d8de5 | ||
|
|
b270a3f159 | ||
|
|
31a05d6a3a | ||
|
|
ed52635e09 | ||
|
|
9f88495a7a | ||
|
|
a899c8ea77 | ||
|
|
d7168c6f70 | ||
|
|
d8bed21bcc | ||
|
|
d91a72aa7a | ||
|
|
23bffd56d7 | ||
|
|
37a031b92d | ||
|
|
0dfcf5df20 | ||
|
|
079205c548 | ||
|
|
73850b2554 | ||
|
|
ae077121bf | ||
|
|
0b303679b0 | ||
|
|
e312456091 | ||
|
|
2e1f87d1d0 | ||
|
|
b55d488b36 | ||
|
|
0963ec7551 | ||
|
|
4a3c4f9fa6 | ||
|
|
ed2c793268 | ||
|
|
d77279b011 | ||
|
|
b21ccd1331 | ||
|
|
2def3368a7 | ||
|
|
169c5d82bc | ||
|
|
e5fd8d9f61 | ||
|
|
7ad9a0702f | ||
|
|
509120f1f4 | ||
|
|
d38bc780e9 | ||
|
|
711664207c | ||
|
|
53866824d7 | ||
|
|
6b79175dc0 | ||
|
|
ff59420b4a | ||
|
|
3992909e14 | ||
|
|
7627bc3706 | ||
|
|
f66b973b46 | ||
|
|
b547622202 | ||
|
|
413680bcaa | ||
|
|
613e0a9325 | ||
|
|
628d66cf6a | ||
|
|
5bcb6b71ba | ||
|
|
e21629c99d | ||
|
|
8f7b0695fb | ||
|
|
bf97fa5b63 | ||
|
|
a7ff8661e2 | ||
|
|
3f3af0e074 | ||
|
|
1966887fc0 | ||
|
|
7f5a604d50 | ||
|
|
abc8ea5b38 | ||
|
|
a78ffbbfb3 | ||
|
|
570cf9196e | ||
|
|
200e9154e6 | ||
|
|
3e5d9b3adb | ||
|
|
a2e9445de1 | ||
|
|
e66e5aefa5 | ||
|
|
23c23c2a8d | ||
|
|
fbc809edda | ||
|
|
c9d3070d42 | ||
|
|
48439af6f4 | ||
|
|
0571fb7780 | ||
|
|
de177c62fc | ||
|
|
b185fd8b4f | ||
|
|
0b6a740cba | ||
|
|
adac01f05b | ||
|
|
45b1611fe3 | ||
|
|
01cae8beeb | ||
|
|
a1d3821fa3 | ||
|
|
c6dbaafd89 | ||
|
|
7a77b19650 | ||
|
|
1ceacc753e | ||
|
|
7bea4b8d63 | ||
|
|
da74a396d0 | ||
|
|
4aa998fcbf | ||
|
|
46224baa72 | ||
|
|
b72085e5b8 | ||
|
|
9f761fc8ba | ||
|
|
b4b33ac3ec | ||
|
|
1d7a85e34b | ||
|
|
eb35fc174d | ||
|
|
6b7844b9f4 | ||
|
|
ec1be1a988 | ||
|
|
38fd4fcab1 | ||
|
|
51a4f6d2a1 | ||
|
|
9273f3320e | ||
|
|
53b1ee6e09 | ||
|
|
d10f3c72ba | ||
|
|
3ab228cddf | ||
|
|
c36acbb5f6 | ||
|
|
ad1e93c75b | ||
|
|
ce4dbb68c0 | ||
|
|
656c201f9b | ||
|
|
5c6a83acc0 | ||
|
|
dc58bf92d3 | ||
|
|
04ccc4903c | ||
|
|
07a42bb541 | ||
|
|
358e6e17a0 | ||
|
|
0d94d065b4 | ||
|
|
28e787e79d | ||
|
|
13ac4b77f7 | ||
|
|
4bb99fab9b | ||
|
|
021f3294f4 | ||
|
|
3b985eeb5a |
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
build/*
|
||||
34
.eslintrc.json
Normal file
34
.eslintrc.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"modules": true,
|
||||
"experimentalObjectRestSpread": true
|
||||
}
|
||||
},
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"extends": ["eslint:recommended", "plugin:react/recommended"],
|
||||
"rules": {
|
||||
"comma-dangle": 0,
|
||||
"no-unused-vars": "warn",
|
||||
"no-unexpected-multiline": "warn",
|
||||
"prefer-const": "warn"
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"pragma": "React",
|
||||
"version": "15.6.1"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"jasmine": true,
|
||||
"jest": true
|
||||
}
|
||||
}
|
||||
1
.github/workflows/publish.yml
vendored
1
.github/workflows/publish.yml
vendored
@@ -18,6 +18,7 @@ jobs:
|
||||
|
||||
- name: Setup GIT
|
||||
run: |
|
||||
git reset --hard
|
||||
git config --local --list
|
||||
git checkout master
|
||||
git config user.email "$GH_EMAIL"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v2.27.1
|
||||
* simple-keyboard v2.28.1
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
||||
@@ -8,5 +8,5 @@
|
||||
* 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: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:flex}.simple-keyboard .hg-button{display:inline-block;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:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:rgba(0,0,0,0)}.simple-keyboard.hg-theme-default .hg-button.hg-activeButton{background:#efefef}.simple-keyboard button.hg-button{border-width:0;outline:0;font-size:inherit}.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;align-items:center;display:flex;justify-content:center}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd,.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}
|
||||
*/.hg-theme-default{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}.hg-theme-default .hg-button span{pointer-events:none}.hg-theme-default button.hg-button{border-width:0;outline:0;font-size:inherit}.hg-theme-default{font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;background-color:rgba(0,0,0,.1);padding:5px;border-radius:5px}.hg-theme-default .hg-button{display:inline-block;flex-grow:1}.hg-theme-default .hg-row{display:flex}.hg-theme-default .hg-row:not(:last-child){margin-bottom:5px}.hg-theme-default .hg-row .hg-button-container,.hg-theme-default .hg-row .hg-button:not(:last-child){margin-right:5px}.hg-theme-default .hg-row>div:last-child{margin-right:0}.hg-theme-default .hg-row .hg-button-container{display:flex}.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:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:rgba(0,0,0,0)}.hg-theme-default .hg-button.hg-activeButton{background:#efefef}.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;align-items:center;display:flex;justify-content:center}.hg-theme-default .hg-button.hg-button-numpadadd,.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.hg-theme-default .hg-button.hg-button-com{max-width:85px}.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.hg-theme-default .hg-button.hg-selectedButton{background:rgba(5,25,70,.53);color:#fff}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}
|
||||
/*# sourceMappingURL=index.css.map */
|
||||
File diff suppressed because one or more lines are too long
5
build/index.d.ts
vendored
5
build/index.d.ts
vendored
@@ -93,6 +93,11 @@ declare module 'simple-keyboard' {
|
||||
* Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||
*/
|
||||
preventMouseDownDefault?: boolean;
|
||||
|
||||
/**
|
||||
* Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
|
||||
*/
|
||||
stopMouseDownPropagation?: boolean;
|
||||
|
||||
/**
|
||||
* Define the text color that the physical keyboard highlighted key should have.
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,5 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const isWsl = require('is-wsl');
|
||||
const path = require('path');
|
||||
@@ -13,9 +11,7 @@ const TerserPlugin = require('terser-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||
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');
|
||||
@@ -28,10 +24,7 @@ const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const getPackageJson = require('./getPackageJson');
|
||||
const PrettierPlugin = require("prettier-webpack-plugin");
|
||||
const eslint = require('eslint');
|
||||
|
||||
const postcssNormalize = require('postcss-normalize');
|
||||
|
||||
const appPackageJson = require(paths.appPackageJson);
|
||||
|
||||
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
||||
@@ -65,7 +58,7 @@ const banner = `
|
||||
${name} v${version}
|
||||
${repository.url}
|
||||
|
||||
Copyright (c) ${author.replace(/ *\<[^)]*\> */g, " ")}
|
||||
Copyright (c) ${author.replace(/ *<[^)]*> */g, " ")}
|
||||
|
||||
This source code is licensed under the ${license} license found in the
|
||||
LICENSE file in the root directory of this source tree.
|
||||
|
||||
16049
package-lock.json
generated
16049
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
94
package.json
94
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-keyboard",
|
||||
"version": "2.27.1",
|
||||
"version": "2.28.1",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -40,68 +40,72 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.7.2",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.0",
|
||||
"@babel/preset-env": "^7.7.1",
|
||||
"@babel/preset-react": "^7.7.0",
|
||||
"@svgr/webpack": "4.3.3",
|
||||
"@babel/core": "7.8.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"@babel/preset-react": "^7.8.3",
|
||||
"@svgr/webpack": "5.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "1.13.0",
|
||||
"@typescript-eslint/parser": "1.13.0",
|
||||
"babel-eslint": "10.0.3",
|
||||
"babel-jest": "^24.8.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"babel-jest": "^25.1.0",
|
||||
"babel-loader": "8.0.6",
|
||||
"babel-plugin-named-asset-import": "^0.3.3",
|
||||
"babel-preset-react-app": "^9.0.1",
|
||||
"babel-plugin-named-asset-import": "^0.3.6",
|
||||
"babel-preset-react-app": "^9.1.1",
|
||||
"camelcase": "^5.2.0",
|
||||
"case-sensitive-paths-webpack-plugin": "2.2.0",
|
||||
"copy-webpack-plugin": "^5.0.5",
|
||||
"css-loader": "3.2.0",
|
||||
"case-sensitive-paths-webpack-plugin": "2.3.0",
|
||||
"copy-webpack-plugin": "^5.1.1",
|
||||
"css-loader": "3.4.2",
|
||||
"dotenv": "8.2.0",
|
||||
"dotenv-expand": "5.1.0",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-react-app": "^5.0.1",
|
||||
"eslint-loader": "3.0.2",
|
||||
"eslint-loader": "3.0.3",
|
||||
"eslint-plugin-flowtype": "3.13.0",
|
||||
"eslint-plugin-import": "2.18.2",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||
"eslint-plugin-react": "7.16.0",
|
||||
"eslint-plugin-react-hooks": "^2.2.0",
|
||||
"file-loader": "4.2.0",
|
||||
"eslint-plugin-react": "7.18.3",
|
||||
"eslint-plugin-react-hooks": "^2.3.0",
|
||||
"file-loader": "5.0.2",
|
||||
"fs-extra": "8.1.0",
|
||||
"html-webpack-plugin": "4.0.0-beta.8",
|
||||
"html-webpack-plugin": "4.0.0-beta.11",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"is-wsl": "^2.1.0",
|
||||
"jest": "24.9.0",
|
||||
"jest-environment-jsdom-fourteen": "0.1.0",
|
||||
"jest-resolve": "24.9.0",
|
||||
"jest-watch-typeahead": "0.4.0",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
"jest": "25.1.0",
|
||||
"jest-environment-jsdom-fourteen": "1.0.1",
|
||||
"jest-resolve": "25.1.0",
|
||||
"jest-watch-typeahead": "0.4.2",
|
||||
"mini-css-extract-plugin": "0.9.0",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.3",
|
||||
"pnp-webpack-plugin": "1.5.0",
|
||||
"prettier": "^1.17.0",
|
||||
"prettier-webpack-plugin": "^1.2.0",
|
||||
"postcss-flexbugs-fixes": "4.1.0",
|
||||
"pnp-webpack-plugin": "1.6.0",
|
||||
"postcss-flexbugs-fixes": "4.2.0",
|
||||
"postcss-loader": "3.0.0",
|
||||
"postcss-normalize": "8.0.1",
|
||||
"postcss-preset-env": "6.7.0",
|
||||
"postcss-safe-parser": "4.0.1",
|
||||
"react": "^16.11.0",
|
||||
"react-app-polyfill": "^1.0.2",
|
||||
"react-dev-utils": "^9.0.3",
|
||||
"react-dom": "^16.11.0",
|
||||
"resolve": "1.12.0",
|
||||
"resolve-url-loader": "3.1.0",
|
||||
"sass-loader": "7.3.1",
|
||||
"semver": "6.3.0",
|
||||
"style-loader": "1.0.0",
|
||||
"terser-webpack-plugin": "2.2.1",
|
||||
"ts-pnp": "1.1.4",
|
||||
"uglifyjs-webpack-plugin": "^2.1.2",
|
||||
"url-loader": "2.2.0",
|
||||
"webpack": "4.41.2",
|
||||
"webpack-dev-server": "3.9.0",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier-webpack-plugin": "^1.2.0",
|
||||
"react": "^16.12.0",
|
||||
"react-app-polyfill": "^1.0.6",
|
||||
"react-dev-utils": "^10.1.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"resolve": "1.15.1",
|
||||
"resolve-url-loader": "3.1.1",
|
||||
"sass-loader": "8.0.2",
|
||||
"semver": "7.1.2",
|
||||
"simple-keyboard-autocorrect": "^2.1.3",
|
||||
"simple-keyboard-input-mask": "^2.2.3",
|
||||
"simple-keyboard-key-navigation": "^2.1.1",
|
||||
"style-loader": "1.1.3",
|
||||
"swipe-keyboard": "^2.1.4",
|
||||
"terser-webpack-plugin": "2.3.4",
|
||||
"ts-pnp": "1.1.5",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"url-loader": "3.0.0",
|
||||
"webpack": "4.41.5",
|
||||
"webpack-dev-server": "3.10.3",
|
||||
"webpack-manifest-plugin": "2.2.0",
|
||||
"workbox-webpack-plugin": "4.3.1"
|
||||
"workbox-webpack-plugin": "5.0.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
|
||||
@@ -43,8 +43,8 @@ class Demo {
|
||||
}
|
||||
|
||||
handleShift() {
|
||||
let currentLayout = this.keyboard.options.layoutName;
|
||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
const currentLayout = this.keyboard.options.layoutName;
|
||||
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
|
||||
this.keyboard.setOptions({
|
||||
layoutName: shiftToggle
|
||||
|
||||
@@ -61,8 +61,8 @@ class Demo {
|
||||
}
|
||||
|
||||
handleShift() {
|
||||
let currentLayout = this.keyboard.options.layoutName;
|
||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
const currentLayout = this.keyboard.options.layoutName;
|
||||
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
|
||||
this.keyboard.setOptions({
|
||||
layoutName: shiftToggle
|
||||
|
||||
31
src/demo/DOMElementDemo.js
Normal file
31
src/demo/DOMElementDemo.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import Keyboard from "../lib";
|
||||
import "./css/DOMElementDemo.css";
|
||||
|
||||
class Demo {
|
||||
constructor() {
|
||||
const rootDOM =
|
||||
document.querySelector("#root") || document.createElement("div");
|
||||
|
||||
const keyboard1DOM = document.createElement("div");
|
||||
keyboard1DOM.className = "my-keyboard";
|
||||
|
||||
const keyboard2DOM = document.createElement("div");
|
||||
keyboard2DOM.className = "my-keyboard2";
|
||||
|
||||
/**
|
||||
* Demo Start
|
||||
*/
|
||||
this.keyboard1 = new Keyboard(keyboard1DOM, {
|
||||
onChange: input => console.log(this.keyboard1.keyboardDOMClass, input)
|
||||
});
|
||||
|
||||
this.keyboard2 = new Keyboard(keyboard2DOM, {
|
||||
onChange: input => console.log(this.keyboard2.keyboardDOMClass, input)
|
||||
});
|
||||
|
||||
rootDOM.appendChild(keyboard1DOM);
|
||||
rootDOM.appendChild(keyboard2DOM);
|
||||
}
|
||||
}
|
||||
|
||||
export default Demo;
|
||||
@@ -27,7 +27,7 @@ class Demo {
|
||||
/**
|
||||
* Demo Start
|
||||
*/
|
||||
let commonKeyboardOptions = {
|
||||
const commonKeyboardOptions = {
|
||||
onChange: input => this.onChange(input),
|
||||
onKeyPress: button => this.onKeyPress(button),
|
||||
theme: "simple-keyboard hg-theme-default hg-layout-default",
|
||||
@@ -116,8 +116,8 @@ class Demo {
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector(".input").addEventListener("input", event => {
|
||||
let input = document.querySelector(".input").value;
|
||||
document.querySelector(".input").addEventListener("input", () => {
|
||||
const input = document.querySelector(".input").value;
|
||||
this.keyboard.setInput(input);
|
||||
});
|
||||
}
|
||||
@@ -145,8 +145,8 @@ class Demo {
|
||||
}
|
||||
|
||||
handleShift() {
|
||||
let currentLayout = this.keyboard.options.layoutName;
|
||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
const currentLayout = this.keyboard.options.layoutName;
|
||||
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
|
||||
this.keyboard.setOptions({
|
||||
layoutName: shiftToggle
|
||||
|
||||
@@ -33,6 +33,20 @@ class Demo {
|
||||
|
||||
console.log(this.keyboard);
|
||||
setTimeout(this.keyboard.destroy, 10000);
|
||||
setTimeout(() => {
|
||||
this.keyboard = new Keyboard({
|
||||
theme: "hg-theme-default myTheme",
|
||||
onChange: input => this.onChange(input),
|
||||
onKeyPress: button => this.onKeyPress(button),
|
||||
debug: true,
|
||||
onInit: () => {
|
||||
console.log(
|
||||
"Reinitialized simple-keyboard instance:",
|
||||
this.keyboard.keyboardDOMClass
|
||||
);
|
||||
}
|
||||
});
|
||||
}, 15000);
|
||||
|
||||
/**
|
||||
* Update simple-keyboard when input is changed directly
|
||||
@@ -62,9 +76,9 @@ class Demo {
|
||||
}
|
||||
|
||||
handleShift(keyboardInstanceKey) {
|
||||
let keyboard = this[keyboardInstanceKey || "keyboard"];
|
||||
let currentLayout = keyboard.options.layoutName;
|
||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
const keyboard = this[keyboardInstanceKey || "keyboard"];
|
||||
const currentLayout = keyboard.options.layoutName;
|
||||
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||
|
||||
keyboard.setOptions({
|
||||
layoutName: shiftToggle
|
||||
|
||||
14
src/demo/css/DOMElementDemo.css
Normal file
14
src/demo/css/DOMElementDemo.css
Normal file
@@ -0,0 +1,14 @@
|
||||
input {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
padding: 20px;
|
||||
font-size: 20px;
|
||||
border: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.my-keyboard,
|
||||
.my-keyboard2 {
|
||||
max-width: 850px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
@@ -10,3 +10,7 @@ input {
|
||||
.simple-keyboard {
|
||||
max-width: 850px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default.myTheme {
|
||||
background-color: #bde6c6;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ import "./css/index.css";
|
||||
* Demos
|
||||
*/
|
||||
import BasicDemo from "./BasicDemo";
|
||||
//import FullKeyboardDemo from "./FullKeyboardDemo";
|
||||
//import ButtonThemeDemo from "./ButtonThemeDemo";
|
||||
//import MultipleKeyboardsDemo from "./MultipleKeyboardsDestroyDemo";
|
||||
// import ButtonThemeDemo from "./ButtonThemeDemo";
|
||||
// import DOMElementDemo from "./DOMElementDemo";
|
||||
// import FullKeyboardDemo from "./FullKeyboardDemo";
|
||||
// import MultipleKeyboardsDemo from "./MultipleKeyboardsDestroyDemo";
|
||||
|
||||
/**
|
||||
* Selected demo
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import TestUtility from '../../utils/TestUtility';
|
||||
import BasicDemo from '../BasicDemo';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('Demo will load', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new BasicDemo();
|
||||
new BasicDemo();
|
||||
});
|
||||
|
||||
it('Demo onDOMLoaded will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new BasicDemo();
|
||||
const demo = new BasicDemo();
|
||||
|
||||
expect(demo.keyboard).toBeTruthy();
|
||||
});
|
||||
@@ -20,7 +20,7 @@ it('Demo onDOMLoaded will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new BasicDemo();
|
||||
const demo = new BasicDemo();
|
||||
|
||||
demo.onChange("test");
|
||||
|
||||
@@ -30,7 +30,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new BasicDemo();
|
||||
const demo = new BasicDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("q").onclick();
|
||||
|
||||
@@ -40,7 +40,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo input change will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new BasicDemo();
|
||||
const demo = new BasicDemo();
|
||||
|
||||
document.body.querySelector('.input').value = "test";
|
||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||
@@ -51,7 +51,7 @@ it('Demo input change will work', () => {
|
||||
it('Demo handleShiftButton will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new BasicDemo();
|
||||
const demo = new BasicDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import TestUtility from '../../utils/TestUtility';
|
||||
import ButtonThemeDemo from '../ButtonThemeDemo';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('Demo will load', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
new ButtonThemeDemo();
|
||||
});
|
||||
|
||||
it('Demo onDOMLoaded will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
const demo = new ButtonThemeDemo();
|
||||
|
||||
expect(demo.keyboard).toBeTruthy();
|
||||
});
|
||||
@@ -20,7 +20,7 @@ it('Demo onDOMLoaded will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
const demo = new ButtonThemeDemo();
|
||||
|
||||
demo.onChange("test");
|
||||
|
||||
@@ -30,7 +30,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
const demo = new ButtonThemeDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("q").onclick();
|
||||
|
||||
@@ -40,7 +40,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo input change will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
const demo = new ButtonThemeDemo();
|
||||
|
||||
document.body.querySelector('.input').value = "test";
|
||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||
@@ -51,7 +51,7 @@ it('Demo input change will work', () => {
|
||||
it('Demo handleShiftButton will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
const demo = new ButtonThemeDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||
@@ -63,15 +63,15 @@ it('Demo handleShiftButton will work', () => {
|
||||
it('Demo buttons will have proper attributes and classes', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new ButtonThemeDemo();
|
||||
const demo = new ButtonThemeDemo();
|
||||
|
||||
let buttonDOM = demo.keyboard.getButtonElement("b");
|
||||
const buttonDOM = demo.keyboard.getButtonElement("b");
|
||||
|
||||
console.log("buttonDOM", buttonDOM.outerHTML);
|
||||
|
||||
let hasAttribute = buttonDOM.hasAttribute("aria-label");
|
||||
const hasAttribute = buttonDOM.hasAttribute("aria-label");
|
||||
expect(hasAttribute).toBeTruthy();
|
||||
|
||||
let hasClass = buttonDOM.classList.contains("my-button-outline");
|
||||
const hasClass = buttonDOM.classList.contains("my-button-outline");
|
||||
expect(hasClass).toBeTruthy();
|
||||
});
|
||||
22
src/demo/tests/DOMElementDemo.test.js
Normal file
22
src/demo/tests/DOMElementDemo.test.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import DOMElementDemo from '../DOMElementDemo';
|
||||
import Keyboard from '../../lib/components/Keyboard';
|
||||
|
||||
it('Demo will load', () => {
|
||||
new DOMElementDemo();
|
||||
});
|
||||
|
||||
it('Demo keyboards will be instantiated', () => {
|
||||
const demo = new DOMElementDemo();
|
||||
expect(demo.keyboard1).toBeInstanceOf(Keyboard);
|
||||
expect(demo.keyboard2).toBeInstanceOf(Keyboard);
|
||||
});
|
||||
|
||||
it('Demo input change will work', () => {
|
||||
const demo = new DOMElementDemo();
|
||||
|
||||
demo.keyboard1.getButtonElement("q").onclick();
|
||||
demo.keyboard2.getButtonElement("e").onclick();
|
||||
|
||||
expect(demo.keyboard1.getInput()).toBe("q");
|
||||
expect(demo.keyboard2.getInput()).toBe("e");
|
||||
});
|
||||
@@ -1,18 +1,17 @@
|
||||
import TestUtility from '../../utils/TestUtility';
|
||||
import FullKeyboardDemo from '../FullKeyboardDemo';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('Demo will load', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new FullKeyboardDemo();
|
||||
new FullKeyboardDemo();
|
||||
});
|
||||
|
||||
it('Demo onDOMLoaded will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new FullKeyboardDemo();
|
||||
const demo = new FullKeyboardDemo();
|
||||
|
||||
expect(demo.keyboard).toBeTruthy();
|
||||
});
|
||||
@@ -20,7 +19,7 @@ it('Demo onDOMLoaded will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new FullKeyboardDemo();
|
||||
const demo = new FullKeyboardDemo();
|
||||
|
||||
demo.onChange("test");
|
||||
|
||||
@@ -30,7 +29,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new FullKeyboardDemo();
|
||||
const demo = new FullKeyboardDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("q").onclick();
|
||||
|
||||
@@ -40,7 +39,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo input change will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new FullKeyboardDemo();
|
||||
const demo = new FullKeyboardDemo();
|
||||
|
||||
document.body.querySelector('.input').value = "test";
|
||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||
@@ -52,7 +51,7 @@ it('Demo input change will work', () => {
|
||||
it('Demo handleShiftButton will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new FullKeyboardDemo();
|
||||
const demo = new FullKeyboardDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("{shiftleft}").onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||
|
||||
28
src/demo/tests/ModuleSimpleKeyboardAutocorrect.test.js
Normal file
28
src/demo/tests/ModuleSimpleKeyboardAutocorrect.test.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import Keyboard from '../../lib';
|
||||
import SimpleKeyboardAutocorrect from 'simple-keyboard-autocorrect';
|
||||
|
||||
test('Module simple-keyboard-autocorrect runs without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
|
||||
div.className = "simple-keyboard";
|
||||
document.body.appendChild(div);
|
||||
|
||||
const keyboard = new Keyboard({
|
||||
debug: true,
|
||||
onChange: input => input,
|
||||
onKeyPress: button => button,
|
||||
newLineOnEnter: true,
|
||||
useMouseEvents: true,
|
||||
autocorrectDict: ["dog", "house"],
|
||||
modules: [
|
||||
SimpleKeyboardAutocorrect
|
||||
]
|
||||
});
|
||||
|
||||
keyboard.getButtonElement("d").onclick();
|
||||
keyboard.getButtonElement("o").onclick();
|
||||
keyboard.getButtonElement("{space}").onclick();
|
||||
keyboard.getButtonElement("{bksp}").onclick();
|
||||
|
||||
expect(keyboard.getInput()).toBe("dog");
|
||||
});
|
||||
37
src/demo/tests/ModuleSimpleKeyboardInputMask.test.js
Normal file
37
src/demo/tests/ModuleSimpleKeyboardInputMask.test.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import Keyboard from '../../lib';
|
||||
import SimpleKeyboardInputMask from 'simple-keyboard-input-mask';
|
||||
|
||||
test('Module simple-keyboard-input-mask runs without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
|
||||
div.className += "simple-keyboard";
|
||||
document.body.appendChild(div);
|
||||
|
||||
const keyboard = new Keyboard({
|
||||
debug: true,
|
||||
onChange: input => input,
|
||||
onKeyPress: button => button,
|
||||
inputMask: "(99) 9999-9999",
|
||||
useMouseEvents: true,
|
||||
modules: [
|
||||
SimpleKeyboardInputMask
|
||||
],
|
||||
});
|
||||
|
||||
keyboard.getButtonElement("d").onclick();
|
||||
keyboard.getButtonElement("o").onclick();
|
||||
keyboard.getButtonElement("{space}").onclick();
|
||||
keyboard.getButtonElement("1").onclick();
|
||||
keyboard.getButtonElement("2").onclick();
|
||||
keyboard.getButtonElement("3").onclick();
|
||||
keyboard.getButtonElement("c").onclick();
|
||||
keyboard.getButtonElement("4").onclick();
|
||||
keyboard.getButtonElement("5").onclick();
|
||||
keyboard.getButtonElement("6").onclick();
|
||||
keyboard.getButtonElement("7").onclick();
|
||||
keyboard.getButtonElement("8").onclick();
|
||||
keyboard.getButtonElement("9").onclick();
|
||||
keyboard.getButtonElement("0").onclick();
|
||||
|
||||
expect(keyboard.getInput()).toBe("(12) 3456-7890");
|
||||
});
|
||||
25
src/demo/tests/ModuleSimpleKeyboardKeyNavigation.test.js
Normal file
25
src/demo/tests/ModuleSimpleKeyboardKeyNavigation.test.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Keyboard from '../../lib';
|
||||
import SimpleKeyboardKeyNavigation from 'simple-keyboard-key-navigation';
|
||||
|
||||
test('Module simple-keyboard-key-navigation runs without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
|
||||
div.className = "simple-keyboard";
|
||||
document.body.appendChild(div);
|
||||
|
||||
const keyboard = new Keyboard({
|
||||
debug: true,
|
||||
onChange: input => input,
|
||||
onKeyPress: button => button,
|
||||
enableKeyNavigation: true,
|
||||
modules: [
|
||||
SimpleKeyboardKeyNavigation
|
||||
]
|
||||
});
|
||||
|
||||
keyboard.modules.keyNavigation.right();
|
||||
keyboard.modules.keyNavigation.down();
|
||||
keyboard.modules.keyNavigation.press();
|
||||
|
||||
expect(keyboard.getInput()).toBe("q");
|
||||
});
|
||||
23
src/demo/tests/ModuleSimpleKeyboardSwipe.test.js
Normal file
23
src/demo/tests/ModuleSimpleKeyboardSwipe.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import Keyboard from '../../lib';
|
||||
import SimpleKeyboardSwipe from 'swipe-keyboard';
|
||||
|
||||
test('Module swipe-keyboard runs without crashing', () => {
|
||||
const containerDiv = document.createElement('div');
|
||||
containerDiv.className = "keyboardContainer";
|
||||
|
||||
const keyboardDiv = document.createElement('div');
|
||||
keyboardDiv.className = "simple-keyboard";
|
||||
|
||||
containerDiv.appendChild(keyboardDiv);
|
||||
document.body.appendChild(containerDiv);
|
||||
|
||||
new Keyboard({
|
||||
debug: true,
|
||||
onChange: input => input,
|
||||
onKeyPress: button => button,
|
||||
useMouseEvents: true,
|
||||
modules: [
|
||||
SimpleKeyboardSwipe
|
||||
]
|
||||
});
|
||||
});
|
||||
@@ -1,18 +1,20 @@
|
||||
import TestUtility from '../../utils/TestUtility';
|
||||
import MultipleKeyboardsDestroyDemo from '../MultipleKeyboardsDestroyDemo';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
jest.useFakeTimers();
|
||||
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('Demo will load', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
new MultipleKeyboardsDestroyDemo();
|
||||
});
|
||||
|
||||
it('Demo onDOMLoaded will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
const demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
expect(demo.keyboard).toBeTruthy();
|
||||
});
|
||||
@@ -20,7 +22,7 @@ it('Demo onDOMLoaded will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
const demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
demo.onChange("test");
|
||||
demo.keyboard2.getButtonElement("q").click();
|
||||
@@ -32,7 +34,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
const demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("q").onclick();
|
||||
|
||||
@@ -42,7 +44,7 @@ it('Demo onChange will work', () => {
|
||||
it('Demo input change will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
const demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
document.body.querySelector('.input').value = "test";
|
||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||
@@ -57,11 +59,26 @@ it('Demo input change will work', () => {
|
||||
it('Demo handleShiftButton will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
const demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("default");
|
||||
});
|
||||
|
||||
it('MultipleKeyboardsDestroyDemo will run all timers', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
const demo = new MultipleKeyboardsDestroyDemo();
|
||||
jest.runAllTimers();
|
||||
|
||||
expect(demo.keyboard.options.theme).toBe("hg-theme-default myTheme");
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||
|
||||
demo.keyboard.getButtonElement("A").onclick();
|
||||
expect(demo.keyboard.input.default).toBe("A");
|
||||
});
|
||||
5
src/lib/@types/index.d.ts
vendored
5
src/lib/@types/index.d.ts
vendored
@@ -93,6 +93,11 @@ declare module 'simple-keyboard' {
|
||||
* Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||
*/
|
||||
preventMouseDownDefault?: boolean;
|
||||
|
||||
/**
|
||||
* Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
|
||||
*/
|
||||
stopMouseDownPropagation?: boolean;
|
||||
|
||||
/**
|
||||
* Define the text color that the physical keyboard highlighted key should have.
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
body,
|
||||
html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.simple-keyboard {
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue",
|
||||
Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
/**
|
||||
* simple-keyboard
|
||||
* Theme: hg-theme-default
|
||||
*/
|
||||
.hg-theme-default {
|
||||
width: 100%;
|
||||
user-select: none;
|
||||
box-sizing: border-box;
|
||||
@@ -14,50 +10,56 @@ html {
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
.simple-keyboard .hg-row {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.simple-keyboard .hg-row:not(:last-child) {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.simple-keyboard .hg-row .hg-button:not(:last-child) {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.simple-keyboard .hg-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: flex;
|
||||
}
|
||||
|
||||
.simple-keyboard .hg-button {
|
||||
display: inline-block;
|
||||
flex-grow: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.simple-keyboard .hg-button span {
|
||||
.hg-theme-default .hg-button span {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* hg-theme-default theme
|
||||
*/
|
||||
.simple-keyboard.hg-theme-default {
|
||||
/* When using option "useButtonTag" */
|
||||
.hg-theme-default button.hg-button {
|
||||
border-width: 0;
|
||||
outline: 0;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.hg-theme-default {
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue",
|
||||
Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
padding: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button {
|
||||
.hg-theme-default .hg-button {
|
||||
display: inline-block;
|
||||
flex-grow: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-row {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-row:not(:last-child) {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-row .hg-button:not(:last-child) {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-row .hg-button-container {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-row > div:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-row .hg-button-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.hg-theme-default .hg-button {
|
||||
box-shadow: 0px 0px 3px -1px rgba(0, 0, 0, 0.3);
|
||||
height: 40px;
|
||||
border-radius: 5px;
|
||||
@@ -72,18 +74,11 @@ html {
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-activeButton {
|
||||
.hg-theme-default .hg-button.hg-activeButton {
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
/* When using option "useButtonTag" */
|
||||
.simple-keyboard button.hg-button {
|
||||
border-width: 0;
|
||||
outline: 0;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button {
|
||||
.hg-theme-default.hg-layout-numeric .hg-button {
|
||||
width: 33.3%;
|
||||
height: 60px;
|
||||
align-items: center;
|
||||
@@ -91,35 +86,35 @@ html {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd {
|
||||
.hg-theme-default .hg-button.hg-button-numpadadd {
|
||||
height: 85px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter {
|
||||
.hg-theme-default .hg-button.hg-button-numpadenter {
|
||||
height: 85px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0 {
|
||||
.hg-theme-default .hg-button.hg-button-numpad0 {
|
||||
width: 105px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-button-com {
|
||||
.hg-theme-default .hg-button.hg-button-com {
|
||||
max-width: 85px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {
|
||||
.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {
|
||||
max-width: 45px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton {
|
||||
.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"] {
|
||||
.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"] {
|
||||
max-width: 82px;
|
||||
}
|
||||
|
||||
.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"] {
|
||||
.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"] {
|
||||
max-width: 60px;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import "./Keyboard.css";
|
||||
|
||||
// Services
|
||||
import { getDefaultLayout } from "../services/KeyboardLayout";
|
||||
import PhysicalKeyboard from "../services/PhysicalKeyboard";
|
||||
import KeyboardLayout from "../services/KeyboardLayout";
|
||||
import Utilities from "../services/Utilities";
|
||||
|
||||
/**
|
||||
@@ -18,11 +18,9 @@ class SimpleKeyboard {
|
||||
* @param {Array} params If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.
|
||||
*/
|
||||
constructor(...params) {
|
||||
let keyboardDOMQuery =
|
||||
typeof params[0] === "string" ? params[0] : ".simple-keyboard";
|
||||
let options = typeof params[0] === "object" ? params[0] : params[1];
|
||||
|
||||
if (!options) options = {};
|
||||
const { keyboardDOMClass, keyboardDOM, options = {} } = this.handleParams(
|
||||
params
|
||||
);
|
||||
|
||||
/**
|
||||
* Initializing Utilities
|
||||
@@ -41,7 +39,7 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* Processing options
|
||||
*/
|
||||
this.keyboardDOM = document.querySelector(keyboardDOMQuery);
|
||||
this.keyboardDOM = keyboardDOM;
|
||||
|
||||
/**
|
||||
* @type {object}
|
||||
@@ -61,6 +59,7 @@ class SimpleKeyboard {
|
||||
* @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.
|
||||
* @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.
|
||||
* @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||
* @property {boolean} stopMouseDownPropagation Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
|
||||
* @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.
|
||||
* @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.
|
||||
* @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).
|
||||
@@ -100,7 +99,7 @@ class SimpleKeyboard {
|
||||
* This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.
|
||||
* @example
|
||||
* // To get entered input
|
||||
* let input = keyboard.getInput();
|
||||
* const input = keyboard.getInput();
|
||||
*
|
||||
* // To clear entered input.
|
||||
* keyboard.clearInput();
|
||||
@@ -115,7 +114,7 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* @type {string} DOM class of the keyboard wrapper, normally "simple-keyboard" by default.
|
||||
*/
|
||||
this.keyboardDOMClass = keyboardDOMQuery.split(".").join("");
|
||||
this.keyboardDOMClass = keyboardDOMClass;
|
||||
|
||||
/**
|
||||
* @type {object} Contains the DOM elements of every rendered button, the key being the button's layout name (e.g.: "{enter}").
|
||||
@@ -153,7 +152,7 @@ class SimpleKeyboard {
|
||||
*/
|
||||
if (this.keyboardDOM) this.render();
|
||||
else {
|
||||
console.warn(`"${keyboardDOMQuery}" was not found in the DOM.`);
|
||||
console.warn(`".${keyboardDOMClass}" was not found in the DOM.`);
|
||||
throw new Error("KEYBOARD_DOM_ERROR");
|
||||
}
|
||||
|
||||
@@ -164,6 +163,56 @@ class SimpleKeyboard {
|
||||
this.loadModules();
|
||||
}
|
||||
|
||||
/**
|
||||
* parseParams
|
||||
*/
|
||||
handleParams = params => {
|
||||
let keyboardDOMClass;
|
||||
let keyboardDOM;
|
||||
let options;
|
||||
|
||||
/**
|
||||
* If first parameter is a string:
|
||||
* Consider it as an element's class
|
||||
*/
|
||||
if (typeof params[0] === "string") {
|
||||
keyboardDOMClass = params[0].split(".").join("");
|
||||
keyboardDOM = document.querySelector(`.${keyboardDOMClass}`);
|
||||
options = params[1];
|
||||
|
||||
/**
|
||||
* If first parameter is an HTMLDivElement
|
||||
* Consider it as the keyboard DOM element
|
||||
*/
|
||||
} else if (params[0] instanceof HTMLDivElement) {
|
||||
/**
|
||||
* This element must have a class, otherwise throw
|
||||
*/
|
||||
if (!params[0].className) {
|
||||
console.warn("Any DOM element passed as parameter must have a class.");
|
||||
throw new Error("KEYBOARD_DOM_CLASS_ERROR");
|
||||
}
|
||||
|
||||
keyboardDOMClass = params[0].className.split(" ")[0];
|
||||
keyboardDOM = params[0];
|
||||
options = params[1];
|
||||
|
||||
/**
|
||||
* Otherwise, search for .simple-keyboard DOM element
|
||||
*/
|
||||
} else {
|
||||
keyboardDOMClass = "simple-keyboard";
|
||||
keyboardDOM = document.querySelector(`.${keyboardDOMClass}`);
|
||||
options = params[0];
|
||||
}
|
||||
|
||||
return {
|
||||
keyboardDOMClass,
|
||||
keyboardDOM,
|
||||
options
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Getters
|
||||
*/
|
||||
@@ -175,7 +224,7 @@ class SimpleKeyboard {
|
||||
* @param {string} button The button's layout name.
|
||||
*/
|
||||
handleButtonClicked(button) {
|
||||
let debug = this.options.debug;
|
||||
const debug = this.options.debug;
|
||||
|
||||
/**
|
||||
* Ignoring placeholder buttons
|
||||
@@ -191,7 +240,7 @@ class SimpleKeyboard {
|
||||
if (!this.input[this.options.inputName])
|
||||
this.input[this.options.inputName] = "";
|
||||
|
||||
let updatedInput = this.utilities.getUpdatedInput(
|
||||
const updatedInput = this.utilities.getUpdatedInput(
|
||||
button,
|
||||
this.input[this.options.inputName],
|
||||
this.caretPosition
|
||||
@@ -498,7 +547,7 @@ class SimpleKeyboard {
|
||||
if (buttonTheme.class.split(" ").includes(classNameItem)) {
|
||||
classNameFound = true;
|
||||
|
||||
let buttonThemeArray = buttonTheme.buttons.split(" ");
|
||||
const buttonThemeArray = buttonTheme.buttons.split(" ");
|
||||
if (!buttonThemeArray.includes(button)) {
|
||||
classNameFound = true;
|
||||
buttonThemeArray.push(button);
|
||||
@@ -546,8 +595,8 @@ class SimpleKeyboard {
|
||||
Array.isArray(this.options.buttonTheme) &&
|
||||
this.options.buttonTheme.length
|
||||
) {
|
||||
let buttonArray = buttons.split(" ");
|
||||
buttonArray.forEach((button, key) => {
|
||||
const buttonArray = buttons.split(" ");
|
||||
buttonArray.forEach(button => {
|
||||
this.options.buttonTheme.map((buttonTheme, index) => {
|
||||
/**
|
||||
* If className is set, we affect the buttons only for that class
|
||||
@@ -557,7 +606,7 @@ class SimpleKeyboard {
|
||||
(className && className.includes(buttonTheme.class)) ||
|
||||
!className
|
||||
) {
|
||||
let filteredButtonArray = buttonTheme.buttons
|
||||
const filteredButtonArray = buttonTheme.buttons
|
||||
.split(" ")
|
||||
.filter(item => item !== button);
|
||||
|
||||
@@ -587,7 +636,7 @@ class SimpleKeyboard {
|
||||
getButtonElement(button) {
|
||||
let output;
|
||||
|
||||
let buttonArr = this.buttonElements[button];
|
||||
const buttonArr = this.buttonElements[button];
|
||||
if (buttonArr) {
|
||||
if (buttonArr.length > 1) {
|
||||
output = buttonArr;
|
||||
@@ -604,7 +653,7 @@ class SimpleKeyboard {
|
||||
* by checking if the provided inputPattern passes
|
||||
*/
|
||||
inputPatternIsValid(inputVal) {
|
||||
let inputPatternRaw = this.options.inputPattern;
|
||||
const inputPatternRaw = this.options.inputPattern;
|
||||
let inputPattern;
|
||||
|
||||
/**
|
||||
@@ -617,7 +666,7 @@ class SimpleKeyboard {
|
||||
}
|
||||
|
||||
if (inputPattern && inputVal) {
|
||||
let didInputMatch = inputPattern.test(inputVal);
|
||||
const didInputMatch = inputPattern.test(inputVal);
|
||||
|
||||
if (this.options.debug) {
|
||||
console.log(
|
||||
@@ -785,7 +834,6 @@ class SimpleKeyboard {
|
||||
|
||||
this.recurseButtons(deleteButton);
|
||||
|
||||
this.buttonElements = null;
|
||||
this.recurseButtons = null;
|
||||
deleteButton = null;
|
||||
|
||||
@@ -796,21 +844,28 @@ class SimpleKeyboard {
|
||||
this.keyboardDOM.ontouchstart = null;
|
||||
this.keyboardDOM.onmousedown = null;
|
||||
|
||||
this.keyboardDOM.remove();
|
||||
this.keyboardDOM = null;
|
||||
/**
|
||||
* Clearing keyboard wrapper
|
||||
*/
|
||||
this.clear();
|
||||
|
||||
/**
|
||||
* Remove instance
|
||||
*/
|
||||
window["SimpleKeyboardInstances"][this.currentInstanceName] = null;
|
||||
delete window["SimpleKeyboardInstances"][this.currentInstanceName];
|
||||
|
||||
/**
|
||||
* Reset initialized flag
|
||||
*/
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process buttonTheme option
|
||||
*/
|
||||
getButtonThemeClasses(button) {
|
||||
let buttonTheme = this.options.buttonTheme;
|
||||
const buttonTheme = this.options.buttonTheme;
|
||||
let buttonClasses = [];
|
||||
|
||||
if (Array.isArray(buttonTheme)) {
|
||||
@@ -818,10 +873,11 @@ class SimpleKeyboard {
|
||||
if (
|
||||
themeObj.class &&
|
||||
typeof themeObj.class === "string" &&
|
||||
(themeObj.buttons && typeof themeObj.buttons === "string")
|
||||
themeObj.buttons &&
|
||||
typeof themeObj.buttons === "string"
|
||||
) {
|
||||
let themeObjClasses = themeObj.class.split(" ");
|
||||
let themeObjButtons = themeObj.buttons.split(" ");
|
||||
const themeObjClasses = themeObj.class.split(" ");
|
||||
const themeObjButtons = themeObj.buttons.split(" ");
|
||||
|
||||
if (themeObjButtons.includes(button)) {
|
||||
buttonClasses = [...buttonClasses, ...themeObjClasses];
|
||||
@@ -842,17 +898,19 @@ class SimpleKeyboard {
|
||||
* Process buttonAttributes option
|
||||
*/
|
||||
setDOMButtonAttributes(button, callback) {
|
||||
let buttonAttributes = this.options.buttonAttributes;
|
||||
const buttonAttributes = this.options.buttonAttributes;
|
||||
|
||||
if (Array.isArray(buttonAttributes)) {
|
||||
buttonAttributes.forEach(attrObj => {
|
||||
if (
|
||||
attrObj.attribute &&
|
||||
typeof attrObj.attribute === "string" &&
|
||||
(attrObj.value && typeof attrObj.value === "string") &&
|
||||
(attrObj.buttons && typeof attrObj.buttons === "string")
|
||||
attrObj.value &&
|
||||
typeof attrObj.value === "string" &&
|
||||
attrObj.buttons &&
|
||||
typeof attrObj.buttons === "string"
|
||||
) {
|
||||
let attrObjButtons = attrObj.buttons.split(" ");
|
||||
const attrObjButtons = attrObj.buttons.split(" ");
|
||||
|
||||
if (attrObjButtons.includes(button)) {
|
||||
callback(attrObj.attribute, attrObj.value);
|
||||
@@ -1001,19 +1059,22 @@ class SimpleKeyboard {
|
||||
*/
|
||||
loadModules() {
|
||||
if (Array.isArray(this.options.modules)) {
|
||||
this.options.modules.forEach(Module => {
|
||||
let module = new Module();
|
||||
this.options.modules.forEach(KeyboardModule => {
|
||||
const keyboardModule = new KeyboardModule();
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (module.constructor.name && module.constructor.name !== "Function") {
|
||||
let classStr = `module-${this.utilities.camelCase(
|
||||
module.constructor.name
|
||||
if (
|
||||
keyboardModule.constructor.name &&
|
||||
keyboardModule.constructor.name !== "Function"
|
||||
) {
|
||||
const classStr = `module-${this.utilities.camelCase(
|
||||
keyboardModule.constructor.name
|
||||
)}`;
|
||||
this.keyboardPluginClasses =
|
||||
this.keyboardPluginClasses + ` ${classStr}`;
|
||||
}
|
||||
|
||||
module.init(this);
|
||||
keyboardModule.init(this);
|
||||
});
|
||||
|
||||
this.keyboardPluginClasses =
|
||||
@@ -1049,12 +1110,12 @@ class SimpleKeyboard {
|
||||
containerStartIndexes,
|
||||
containerEndIndexes
|
||||
) {
|
||||
let rowDOMArray = Array.from(rowDOM.children);
|
||||
const rowDOMArray = Array.from(rowDOM.children);
|
||||
let removedElements = 0;
|
||||
|
||||
if (rowDOMArray.length) {
|
||||
containerStartIndexes.forEach((startIndex, arrIndex) => {
|
||||
let endIndex = containerEndIndexes[arrIndex];
|
||||
const endIndex = containerEndIndexes[arrIndex];
|
||||
|
||||
/**
|
||||
* If there exists a respective end index
|
||||
@@ -1069,21 +1130,21 @@ class SimpleKeyboard {
|
||||
* This is since the removal of buttons to place a single button container
|
||||
* results in a modified array size
|
||||
*/
|
||||
let updated_startIndex = startIndex - removedElements;
|
||||
let updated_endIndex = endIndex - removedElements;
|
||||
const updated_startIndex = startIndex - removedElements;
|
||||
const updated_endIndex = endIndex - removedElements;
|
||||
|
||||
/**
|
||||
* Create button container
|
||||
*/
|
||||
let containerDOM = document.createElement("div");
|
||||
const containerDOM = document.createElement("div");
|
||||
containerDOM.className += "hg-button-container";
|
||||
let containerUID = `${this.options.layoutName}-r${rowIndex}c${arrIndex}`;
|
||||
const containerUID = `${this.options.layoutName}-r${rowIndex}c${arrIndex}`;
|
||||
containerDOM.setAttribute("data-skUID", containerUID);
|
||||
|
||||
/**
|
||||
* Taking elements due to be inserted into container
|
||||
*/
|
||||
let containedElements = rowDOMArray.splice(
|
||||
const containedElements = rowDOMArray.splice(
|
||||
updated_startIndex,
|
||||
updated_endIndex - updated_startIndex + 1
|
||||
);
|
||||
@@ -1124,6 +1185,17 @@ class SimpleKeyboard {
|
||||
return rowDOM;
|
||||
}
|
||||
|
||||
/**
|
||||
* getKeyboardClassString
|
||||
*/
|
||||
getKeyboardClassString = (...baseDOMClasses) => {
|
||||
const keyboardClasses = [this.keyboardDOMClass, ...baseDOMClasses].filter(
|
||||
DOMClass => !!DOMClass
|
||||
);
|
||||
|
||||
return keyboardClasses.join(" ");
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders rows and buttons as per options
|
||||
*/
|
||||
@@ -1145,23 +1217,28 @@ class SimpleKeyboard {
|
||||
*/
|
||||
this.beforeRender();
|
||||
|
||||
let layoutClass = `hg-layout-${this.options.layoutName}`;
|
||||
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
|
||||
let useTouchEvents = this.options.useTouchEvents || false;
|
||||
let useTouchEventsClass = useTouchEvents ? "hg-touch-events" : "";
|
||||
let useMouseEvents = this.options.useMouseEvents || false;
|
||||
let disableRowButtonContainers = this.options.disableRowButtonContainers;
|
||||
const layoutClass = `hg-layout-${this.options.layoutName}`;
|
||||
const layout = this.options.layout || getDefaultLayout();
|
||||
const useTouchEvents = this.options.useTouchEvents || false;
|
||||
const useTouchEventsClass = useTouchEvents ? "hg-touch-events" : "";
|
||||
const useMouseEvents = this.options.useMouseEvents || false;
|
||||
const disableRowButtonContainers = this.options.disableRowButtonContainers;
|
||||
|
||||
/**
|
||||
* Adding themeClass, layoutClass to keyboardDOM
|
||||
*/
|
||||
this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses} ${useTouchEventsClass}`;
|
||||
this.keyboardDOM.className = this.getKeyboardClassString(
|
||||
this.options.theme,
|
||||
layoutClass,
|
||||
this.keyboardPluginClasses,
|
||||
useTouchEventsClass
|
||||
);
|
||||
|
||||
/**
|
||||
* Iterating through each row
|
||||
*/
|
||||
layout[this.options.layoutName].forEach((row, rIndex) => {
|
||||
let rowArray = row.split(" ");
|
||||
const rowArray = row.split(" ");
|
||||
|
||||
/**
|
||||
* Creating empty row
|
||||
@@ -1172,8 +1249,8 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* Tracking container indicators in rows
|
||||
*/
|
||||
let containerStartIndexes = [];
|
||||
let containerEndIndexes = [];
|
||||
const containerStartIndexes = [];
|
||||
const containerEndIndexes = [];
|
||||
|
||||
/**
|
||||
* Iterating through each button in row
|
||||
@@ -1182,11 +1259,11 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* Check if button has a container indicator
|
||||
*/
|
||||
let buttonHasContainerStart =
|
||||
const buttonHasContainerStart =
|
||||
!disableRowButtonContainers &&
|
||||
button.includes("[") &&
|
||||
button.length > 1;
|
||||
let buttonHasContainerEnd =
|
||||
const buttonHasContainerEnd =
|
||||
!disableRowButtonContainers &&
|
||||
button.includes("]") &&
|
||||
button.length > 1;
|
||||
@@ -1215,8 +1292,8 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* Processing button options
|
||||
*/
|
||||
let fctBtnClass = this.utilities.getButtonClass(button);
|
||||
let buttonDisplayName = this.utilities.getButtonDisplayName(
|
||||
const fctBtnClass = this.utilities.getButtonClass(button);
|
||||
const buttonDisplayName = this.utilities.getButtonDisplayName(
|
||||
button,
|
||||
this.options.display,
|
||||
this.options.mergeDisplay
|
||||
@@ -1225,8 +1302,8 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* Creating button
|
||||
*/
|
||||
let buttonType = this.options.useButtonTag ? "button" : "div";
|
||||
let buttonDOM = document.createElement(buttonType);
|
||||
const buttonType = this.options.useButtonTag ? "button" : "div";
|
||||
const buttonDOM = document.createElement(buttonType);
|
||||
buttonDOM.className += `hg-button ${fctBtnClass}`;
|
||||
|
||||
/**
|
||||
@@ -1309,13 +1386,13 @@ class SimpleKeyboard {
|
||||
* Adding unique id
|
||||
* Since there's no limit on spawning same buttons, the unique id ensures you can style every button
|
||||
*/
|
||||
let buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;
|
||||
const buttonUID = `${this.options.layoutName}-r${rIndex}b${bIndex}`;
|
||||
buttonDOM.setAttribute("data-skBtnUID", buttonUID);
|
||||
|
||||
/**
|
||||
* Adding button label to button
|
||||
*/
|
||||
let buttonSpanDOM = document.createElement("span");
|
||||
const buttonSpanDOM = document.createElement("span");
|
||||
buttonSpanDOM.innerHTML = buttonDisplayName;
|
||||
buttonDOM.appendChild(buttonSpanDOM);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Keyboard from '../Keyboard';
|
||||
import TestUtility from '../../../utils/TestUtility';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('Keyboard will not render without target element', () => {
|
||||
try {
|
||||
@@ -38,7 +38,7 @@ it('Keyboard will run with custom DOM target', () => {
|
||||
it('Keyboard will run with debug option set', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true
|
||||
});
|
||||
|
||||
@@ -51,10 +51,10 @@ it('Keyboard will use touch events', () => {
|
||||
testUtil.clear()
|
||||
|
||||
document.body.innerHTML = `
|
||||
<div id="keyboard"></div>
|
||||
<div class="keyboard"></div>
|
||||
`;
|
||||
|
||||
const keyboard = new Keyboard('#keyboard', {
|
||||
const keyboard = new Keyboard('.keyboard', {
|
||||
useTouchEvents: true,
|
||||
onChange: () => touched = true,
|
||||
layout: {
|
||||
@@ -73,7 +73,7 @@ it('Keyboard will use touch events', () => {
|
||||
|
||||
it('Keyboard standard buttons will work', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: {
|
||||
"default": 10
|
||||
}
|
||||
@@ -85,7 +85,7 @@ it('Keyboard standard buttons will work', () => {
|
||||
|
||||
it('Keyboard shift buttons will work', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.setOptions({
|
||||
layoutName: "shift",
|
||||
@@ -97,7 +97,7 @@ it('Keyboard shift buttons will work', () => {
|
||||
|
||||
it('Keyboard setOptions will work without a param', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.setOptions();
|
||||
});
|
||||
@@ -105,7 +105,7 @@ it('Keyboard setOptions will work without a param', () => {
|
||||
it('Keyboard empty buttons wont do anything as expected', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
layout: {
|
||||
default: [
|
||||
"{//} {button} d",
|
||||
@@ -122,7 +122,7 @@ it('Keyboard onKeyPress will work', () => {
|
||||
|
||||
let pressed = false;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
onKeyPress: () => {
|
||||
pressed = true;
|
||||
},
|
||||
@@ -137,7 +137,7 @@ it('Keyboard onKeyPress will work', () => {
|
||||
it('Keyboard standard function buttons will not change input', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
useButtonTag: true
|
||||
});
|
||||
|
||||
@@ -158,7 +158,7 @@ it('Keyboard syncInstanceInputs will work', () => {
|
||||
<div class="keyboard2"></div>
|
||||
`;
|
||||
|
||||
let sharedOptions = {
|
||||
const sharedOptions = {
|
||||
syncInstanceInputs: true
|
||||
};
|
||||
|
||||
@@ -195,7 +195,7 @@ it('Keyboard onChange will work', () => {
|
||||
|
||||
let output = false;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
onChange: (input) => {
|
||||
output = input;
|
||||
},
|
||||
@@ -212,7 +212,7 @@ it('Keyboard onChangeAll will work', () => {
|
||||
|
||||
let output;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
onChangeAll: (input) => {
|
||||
output = input ? input.default : null;
|
||||
},
|
||||
@@ -227,7 +227,7 @@ it('Keyboard onChangeAll will work', () => {
|
||||
it('Keyboard clearInput will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
/**
|
||||
* Avoid setInput for this test
|
||||
@@ -249,12 +249,12 @@ it('Keyboard clearInput will work with syncInstanceInputs', () => {
|
||||
<div class="keyboard2"></div>
|
||||
`;
|
||||
|
||||
let sharedOptions = {
|
||||
const sharedOptions = {
|
||||
syncInstanceInputs: true
|
||||
};
|
||||
|
||||
let keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
||||
let keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
||||
const keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
||||
const keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
||||
|
||||
/**
|
||||
* Avoid setInput for this test
|
||||
@@ -271,7 +271,7 @@ it('Keyboard clearInput will work with syncInstanceInputs', () => {
|
||||
it('Keyboard setInput will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.setInput("hello");
|
||||
|
||||
@@ -286,12 +286,12 @@ it('Keyboard setInput will work with syncInstanceInputs', () => {
|
||||
<div class="keyboard2"></div>
|
||||
`;
|
||||
|
||||
let sharedOptions = {
|
||||
const sharedOptions = {
|
||||
syncInstanceInputs: true
|
||||
};
|
||||
|
||||
let keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
||||
let keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
||||
const keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
||||
const keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
||||
|
||||
keyboard1.setInput("hello");
|
||||
|
||||
@@ -306,8 +306,8 @@ it('Keyboard dispatch will work', () => {
|
||||
<div class="keyboard2"></div>
|
||||
`;
|
||||
|
||||
let keyboard1 = new Keyboard(".keyboard1");
|
||||
let keyboard2 = new Keyboard(".keyboard2");
|
||||
const keyboard1 = new Keyboard(".keyboard1");
|
||||
const keyboard2 = new Keyboard(".keyboard2");
|
||||
|
||||
keyboard1.dispatch(instance => {
|
||||
instance.setOptions({
|
||||
@@ -331,8 +331,8 @@ it('Keyboard dispatch will not work without SimpleKeyboardInstances', () => {
|
||||
<div class="keyboard2"></div>
|
||||
`;
|
||||
|
||||
let keyboard1 = new Keyboard(".keyboard1");
|
||||
let keyboard2 = new Keyboard(".keyboard2");
|
||||
const keyboard1 = new Keyboard(".keyboard1");
|
||||
new Keyboard(".keyboard2");
|
||||
|
||||
window['SimpleKeyboardInstances'] = null;
|
||||
|
||||
@@ -357,8 +357,8 @@ it('Keyboard dispatch will not work without SimpleKeyboardInstances', () => {
|
||||
it('Keyboard addButtonTheme will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
let returnVal = keyboard.addButtonTheme("q", "test");
|
||||
const keyboard = new Keyboard();
|
||||
keyboard.addButtonTheme("q", "test");
|
||||
|
||||
expect(keyboard.options.buttonTheme[0].class).toBe("test");
|
||||
});
|
||||
@@ -366,8 +366,8 @@ it('Keyboard addButtonTheme will work', () => {
|
||||
it('Keyboard addButtonTheme will not work without params', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
let returnVal = keyboard.addButtonTheme();
|
||||
const keyboard = new Keyboard();
|
||||
const returnVal = keyboard.addButtonTheme();
|
||||
|
||||
expect(returnVal).toBeFalsy();
|
||||
});
|
||||
@@ -375,7 +375,7 @@ it('Keyboard addButtonTheme will not work without params', () => {
|
||||
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -392,7 +392,7 @@ it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
||||
it('Keyboard addButtonTheme will create a buttonTheme', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "blurb",
|
||||
@@ -409,7 +409,7 @@ it('Keyboard addButtonTheme will create a buttonTheme', () => {
|
||||
it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -426,7 +426,7 @@ it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
|
||||
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -444,7 +444,7 @@ it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
||||
it('Keyboard removeButtonTheme without params will remove all button themes', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -462,7 +462,7 @@ it('Keyboard removeButtonTheme without params will remove all button themes', ()
|
||||
it('Keyboard removeButtonTheme will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -479,7 +479,7 @@ it('Keyboard removeButtonTheme will work', () => {
|
||||
it('Keyboard removeButtonTheme will work wihtout a class', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -496,7 +496,7 @@ it('Keyboard removeButtonTheme will work wihtout a class', () => {
|
||||
it('Keyboard removeButtonTheme will do nothing without a button param', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -513,7 +513,7 @@ it('Keyboard removeButtonTheme will do nothing without a button param', () => {
|
||||
it('Keyboard removeButtonTheme does nothing if req button doesnt have a buttonTheme', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -530,7 +530,7 @@ it('Keyboard removeButtonTheme does nothing if req button doesnt have a buttonTh
|
||||
it('Keyboard removeButtonTheme does nothing if buttonTheme class does not exist', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "testy",
|
||||
@@ -547,7 +547,7 @@ it('Keyboard removeButtonTheme does nothing if buttonTheme class does not exist'
|
||||
it('Keyboard removeButtonTheme does nothing if buttonTheme doesnt have the requested buttons', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -564,7 +564,7 @@ it('Keyboard removeButtonTheme does nothing if buttonTheme doesnt have the reque
|
||||
it('Keyboard getButtonElement will not return anything if empty match', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
layout: {
|
||||
default: [
|
||||
"{//} {button} d",
|
||||
@@ -579,7 +579,7 @@ it('Keyboard getButtonElement will not return anything if empty match', () => {
|
||||
it('Keyboard getButtonElement will return multiple matched buttons', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
expect(keyboard.getButtonElement("{shift}").length).toBe(2);
|
||||
});
|
||||
@@ -606,7 +606,7 @@ it('Keyboard will receive physical keyboard events', () => {
|
||||
it('Keyboard caretEventHandler will detect input, textarea focus', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.caretEventHandler({
|
||||
charCode: 0,
|
||||
@@ -625,7 +625,7 @@ it('Keyboard caretEventHandler will detect input, textarea focus', () => {
|
||||
it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositioning', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.caretEventHandler({
|
||||
charCode: 0,
|
||||
@@ -661,7 +661,7 @@ it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositio
|
||||
it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.isMouseHold = true;
|
||||
|
||||
@@ -682,7 +682,7 @@ it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', (
|
||||
it('Keyboard caretEventHandler will work with debug', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true
|
||||
});
|
||||
|
||||
@@ -705,7 +705,7 @@ it('Keyboard onInit will work', () => {
|
||||
|
||||
let passed = false;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
onInit: () => {
|
||||
passed = true
|
||||
}
|
||||
@@ -719,7 +719,7 @@ it('Keyboard onRender will work', () => {
|
||||
|
||||
let passed = false;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
onRender: () => {
|
||||
passed = true
|
||||
}
|
||||
@@ -731,7 +731,7 @@ it('Keyboard onRender will work', () => {
|
||||
it('Keyboard buttonTheme that is invalid will be ignored and not throw', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: null,
|
||||
@@ -744,7 +744,7 @@ it('Keyboard buttonTheme that is invalid will be ignored and not throw', () => {
|
||||
it('Keyboard buttonTheme buttons that are invalid will be ignored and not throw', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: null,
|
||||
@@ -772,7 +772,7 @@ it('Keyboard buttonTheme will be ignored if buttons param not a string', () => {
|
||||
it('Keyboard buttonTheme will be ignored if already added', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
buttonTheme: [
|
||||
{
|
||||
class: "test",
|
||||
@@ -801,7 +801,7 @@ it('Keyboard buttonTheme will be ignored if already added', () => {
|
||||
it('Keyboard can set a module', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.registerModule(
|
||||
"test",
|
||||
@@ -816,7 +816,7 @@ it('Keyboard can set a module', () => {
|
||||
it('Keyboard registerModule will return current module tree', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.modules.test = {
|
||||
testy: "test"
|
||||
@@ -836,7 +836,7 @@ it('Keyboard registerModule will return current module tree', () => {
|
||||
it('Keyboard can set a module by amending the modules tree', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.modules = {
|
||||
testman: {
|
||||
@@ -857,7 +857,7 @@ it('Keyboard can set a module by amending the modules tree', () => {
|
||||
it('Keyboard will not retrieve an option for an inexistent module', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
expect(keyboard.getModuleProp("test", "foo")).toBeFalsy();
|
||||
});
|
||||
@@ -865,7 +865,7 @@ it('Keyboard will not retrieve an option for an inexistent module', () => {
|
||||
it('Keyboard will get a list of modules', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.registerModule(
|
||||
"test",
|
||||
@@ -886,7 +886,7 @@ it('Keyboard loadModules will load a simple module', () => {
|
||||
};
|
||||
}
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
modules: [
|
||||
myClass
|
||||
]
|
||||
@@ -896,7 +896,7 @@ it('Keyboard loadModules will load a simple module', () => {
|
||||
it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.isMouseHold = true;
|
||||
|
||||
@@ -908,7 +908,7 @@ it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
|
||||
it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.isMouseHold = true;
|
||||
keyboard.holdInteractionTimeout = setTimeout(() => {}, 10000);
|
||||
@@ -919,7 +919,7 @@ it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
|
||||
it('Keyboard handleButtonMouseDown will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.handleButtonMouseDown("q", {
|
||||
target: keyboard.getButtonElement("q"),
|
||||
@@ -937,7 +937,7 @@ it('Keyboard handleButtonMouseDown will work', () => {
|
||||
it('Keyboard handleButtonMouseDown will work with preventMouseDownDefault', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.options.preventMouseDownDefault = true;
|
||||
|
||||
@@ -965,7 +965,7 @@ it('Keyboard onModulesLoaded will work', () => {
|
||||
|
||||
let foo;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
modules: [
|
||||
myClass
|
||||
],
|
||||
@@ -980,7 +980,7 @@ it('Keyboard onModulesLoaded will work', () => {
|
||||
it('Keyboard inputPattern will work globally', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
inputPattern: /^\d+$/,
|
||||
useMouseEvents: true
|
||||
});
|
||||
@@ -997,7 +997,7 @@ it('Keyboard inputPattern will work globally', () => {
|
||||
it('Keyboard inputPattern will work by input name', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true,
|
||||
inputName: "test1",
|
||||
inputPattern: {
|
||||
@@ -1026,7 +1026,7 @@ it('Keyboard processAutoTouchEvents will work', () => {
|
||||
|
||||
navigator.maxTouchPoints = true;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
autoUseTouchEvents: true
|
||||
});
|
||||
|
||||
@@ -1038,7 +1038,7 @@ it('Keyboard processAutoTouchEvents will work with debugging enabled', () => {
|
||||
|
||||
navigator.maxTouchPoints = true;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
autoUseTouchEvents: true,
|
||||
debug: true
|
||||
});
|
||||
@@ -1051,7 +1051,7 @@ it('Keyboard beforeFirstRender method will work', () => {
|
||||
|
||||
let timesCalled = 0;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
beforeFirstRender: () => {
|
||||
timesCalled++;
|
||||
}
|
||||
@@ -1074,7 +1074,7 @@ it('Keyboard beforeFirstRender will show PointerEvents warning', () => {
|
||||
|
||||
window.PointerEvent = window.PointerEvent ? window.PointerEvent : () => {};
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
debug: true,
|
||||
beforeFirstRender: () => {
|
||||
timesCalled++;
|
||||
@@ -1089,7 +1089,7 @@ it('Keyboard beforeRender method will work', () => {
|
||||
|
||||
let timesCalled = 0;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
beforeRender: () => {
|
||||
timesCalled++;
|
||||
}
|
||||
@@ -1108,7 +1108,7 @@ it('Keyboard beforeRender method will work', () => {
|
||||
it('Keyboard parseRowDOMContainers will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
layout: {
|
||||
'default': [
|
||||
'` [1 2 3 4 5 6 7 8 9] 0 - = {bksp}',
|
||||
@@ -1127,7 +1127,7 @@ it('Keyboard parseRowDOMContainers will work', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let containers = Array.from(document.querySelectorAll(".hg-button-container"));
|
||||
const containers = Array.from(document.querySelectorAll(".hg-button-container"));
|
||||
|
||||
expect(containers.length).toBe(5);
|
||||
|
||||
@@ -1144,7 +1144,7 @@ it('Keyboard parseRowDOMContainers will ignore empty rows', () => {
|
||||
let failed = false;
|
||||
|
||||
try {
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
keyboard.parseRowDOMContainers({
|
||||
children: []
|
||||
});
|
||||
@@ -1159,7 +1159,7 @@ it('Keyboard parseRowDOMContainers will ignore empty rows', () => {
|
||||
it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex before startIndex', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
layout: {
|
||||
'default': [
|
||||
'` [1 2 3 4 5 6 7 8 9 0 - = {bksp}',
|
||||
@@ -1168,7 +1168,7 @@ it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex befo
|
||||
}
|
||||
});
|
||||
|
||||
let containers = Array.from(document.querySelectorAll(".hg-button-container"));
|
||||
const containers = Array.from(document.querySelectorAll(".hg-button-container"));
|
||||
|
||||
expect(containers.length).toBe(0);
|
||||
});
|
||||
@@ -1176,7 +1176,7 @@ it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex befo
|
||||
it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
disableRowButtonContainers: true,
|
||||
layout: {
|
||||
'default': [
|
||||
@@ -1196,7 +1196,7 @@ it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () =
|
||||
}
|
||||
});
|
||||
|
||||
let containers = Array.from(document.querySelectorAll(".hg-button-container"));
|
||||
const containers = Array.from(document.querySelectorAll(".hg-button-container"));
|
||||
|
||||
expect(containers.length).toBe(0);
|
||||
});
|
||||
@@ -1204,7 +1204,7 @@ it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () =
|
||||
it('Keyboard inputName change will trigget caretPosition reset', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.caretPosition = 0;
|
||||
|
||||
@@ -1227,23 +1227,23 @@ it('Keyboard inputName change will trigget caretPosition reset', () => {
|
||||
it('Keyboard destroy will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
keyboard.destroy();
|
||||
expect(keyboard.keyboardDOM).toBe(null);
|
||||
expect(keyboard.keyboardDOM.innerHTML).toBe("");
|
||||
});
|
||||
|
||||
it('Keyboard destroy will work with debug option', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({ debug: true });
|
||||
const keyboard = new Keyboard({ debug: true });
|
||||
keyboard.destroy();
|
||||
expect(keyboard.keyboardDOM).toBe(null);
|
||||
expect(keyboard.keyboardDOM.innerHTML).toBe("");
|
||||
});
|
||||
|
||||
it('Keyboard disableButtonHold will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
disableButtonHold: true
|
||||
});
|
||||
|
||||
@@ -1253,7 +1253,7 @@ it('Keyboard disableButtonHold will work', () => {
|
||||
it('Keyboard caretEventHandler will be triggered on mouseup and ontouchend', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
disableCaretPositioning: true
|
||||
});
|
||||
|
||||
@@ -1289,7 +1289,7 @@ it('Keyboard onKeyReleased will work', () => {
|
||||
let firedTimes = 0;
|
||||
let buttonPressed;
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
onKeyReleased: button => {
|
||||
pressed = true;
|
||||
buttonPressed = button;
|
||||
@@ -1309,7 +1309,7 @@ it('Keyboard onKeyReleased will work', () => {
|
||||
it('Keyboard buttonAttribute will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
buttonAttributes: [
|
||||
{
|
||||
attribute: "aria-label",
|
||||
@@ -1323,7 +1323,7 @@ it('Keyboard buttonAttribute will work', () => {
|
||||
it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
buttonAttributes: [
|
||||
{
|
||||
attribute: false,
|
||||
@@ -1335,6 +1335,29 @@ it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
||||
|
||||
it('Keyboard recurseButtons will not work without a valid param', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
expect(keyboard.recurseButtons()).toBe(false);
|
||||
});
|
||||
|
||||
it('Keyboard will not work with a DOM element param without class', () => {
|
||||
try {
|
||||
const keyboardDOM = document.createElement("div");
|
||||
new Keyboard(keyboardDOM);
|
||||
expect(true).toBe(false);
|
||||
} catch (e) {
|
||||
expect(e.message).toBe("KEYBOARD_DOM_CLASS_ERROR");
|
||||
}
|
||||
});
|
||||
|
||||
it('Keyboard will work with a DOM element param with class', () => {
|
||||
try {
|
||||
const keyboardClass = "my-keyboard";
|
||||
const keyboardDOM = document.createElement("div");
|
||||
keyboardDOM.className = keyboardClass;
|
||||
const keyboard = new Keyboard(keyboardDOM);
|
||||
|
||||
expect(keyboard.keyboardDOMClass).toBe(keyboardClass);
|
||||
} catch (e) {
|
||||
expect(true).toBe(false);
|
||||
}
|
||||
});
|
||||
@@ -1,29 +1,18 @@
|
||||
/**
|
||||
* Keyboard Layout Service
|
||||
*/
|
||||
class KeyboardLayout {
|
||||
/**
|
||||
* Get default simple-keyboard layout
|
||||
* @return {object} The default layout (US-QWERTY)
|
||||
*/
|
||||
static getDefaultLayout() {
|
||||
return {
|
||||
default: [
|
||||
"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
|
||||
"{tab} q w e r t y u i o p [ ] \\",
|
||||
"{lock} a s d f g h j k l ; ' {enter}",
|
||||
"{shift} z x c v b n m , . / {shift}",
|
||||
".com @ {space}"
|
||||
],
|
||||
shift: [
|
||||
"~ ! @ # $ % ^ & * ( ) _ + {bksp}",
|
||||
"{tab} Q W E R T Y U I O P { } |",
|
||||
'{lock} A S D F G H J K L : " {enter}',
|
||||
"{shift} Z X C V B N M < > ? {shift}",
|
||||
".com @ {space}"
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default KeyboardLayout;
|
||||
export const getDefaultLayout = () => {
|
||||
return {
|
||||
default: [
|
||||
"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
|
||||
"{tab} q w e r t y u i o p [ ] \\",
|
||||
"{lock} a s d f g h j k l ; ' {enter}",
|
||||
"{shift} z x c v b n m , . / {shift}",
|
||||
".com @ {space}"
|
||||
],
|
||||
shift: [
|
||||
"~ ! @ # $ % ^ & * ( ) _ + {bksp}",
|
||||
"{tab} Q W E R T Y U I O P { } |",
|
||||
'{lock} A S D F G H J K L : " {enter}',
|
||||
"{shift} Z X C V B N M < > ? {shift}",
|
||||
".com @ {space}"
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -21,11 +21,11 @@ class PhysicalKeyboard {
|
||||
}
|
||||
|
||||
handleHighlightKeyDown(event) {
|
||||
let options = this.getOptions();
|
||||
let buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||
const options = this.getOptions();
|
||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||
|
||||
this.dispatch(instance => {
|
||||
let buttonDOM =
|
||||
const buttonDOM =
|
||||
instance.getButtonElement(buttonPressed) ||
|
||||
instance.getButtonElement(`{${buttonPressed}}`);
|
||||
|
||||
@@ -39,10 +39,10 @@ class PhysicalKeyboard {
|
||||
}
|
||||
|
||||
handleHighlightKeyUp(event) {
|
||||
let buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||
|
||||
this.dispatch(instance => {
|
||||
let buttonDOM =
|
||||
const buttonDOM =
|
||||
instance.getButtonElement(buttonPressed) ||
|
||||
instance.getButtonElement(`{${buttonPressed}}`);
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ class Utilities {
|
||||
* @return {string} The classes to be added to the button
|
||||
*/
|
||||
getButtonClass(button) {
|
||||
let buttonTypeClass =
|
||||
const buttonTypeClass =
|
||||
button.includes("{") && button.includes("}") && button !== "{//}"
|
||||
? "functionBtn"
|
||||
: "standardBtn";
|
||||
let buttonWithoutBraces = button.replace("{", "").replace("}", "");
|
||||
const buttonWithoutBraces = button.replace("{", "").replace("}", "");
|
||||
let buttonNormalized = "";
|
||||
|
||||
if (buttonTypeClass !== "standardBtn")
|
||||
@@ -128,7 +128,7 @@ class Utilities {
|
||||
* @param {boolean} moveCaret Whether to update simple-keyboard's cursor
|
||||
*/
|
||||
getUpdatedInput(button, input, caretPos, moveCaret) {
|
||||
let options = this.getOptions();
|
||||
const options = this.getOptions();
|
||||
let output = input;
|
||||
|
||||
if (
|
||||
@@ -186,7 +186,7 @@ class Utilities {
|
||||
* @param {boolean} minus Whether the cursor should be moved to the left or not.
|
||||
*/
|
||||
updateCaretPos(length, minus) {
|
||||
let newCaretPos = this.updateCaretPosAction(length, minus);
|
||||
const newCaretPos = this.updateCaretPosAction(length, minus);
|
||||
|
||||
this.dispatch(instance => {
|
||||
instance.caretPosition = newCaretPos;
|
||||
@@ -200,7 +200,7 @@ class Utilities {
|
||||
* @param {boolean} minus Whether the cursor should be moved to the left or not.
|
||||
*/
|
||||
updateCaretPosAction(length, minus) {
|
||||
let options = this.getOptions();
|
||||
const options = this.getOptions();
|
||||
let caretPosition = this.getCaretPosition();
|
||||
|
||||
if (minus) {
|
||||
@@ -253,7 +253,7 @@ class Utilities {
|
||||
* @param {boolean} moveCaret Whether to update simple-keyboard's cursor
|
||||
*/
|
||||
removeAt(source, position, moveCaret) {
|
||||
let caretPosition = this.getCaretPosition();
|
||||
const caretPosition = this.getCaretPosition();
|
||||
|
||||
if (caretPosition === 0) {
|
||||
return source;
|
||||
@@ -262,7 +262,7 @@ class Utilities {
|
||||
let output;
|
||||
let prevTwoChars;
|
||||
let emojiMatched;
|
||||
let emojiMatchedReg = /([\uD800-\uDBFF][\uDC00-\uDFFF])/g;
|
||||
const emojiMatchedReg = /([\uD800-\uDBFF][\uDC00-\uDFFF])/g;
|
||||
|
||||
/**
|
||||
* Emojis are made out of two characters, so we must take a custom approach to trim them.
|
||||
@@ -301,10 +301,10 @@ class Utilities {
|
||||
* @param {string} updatedInput
|
||||
*/
|
||||
handleMaxLength(inputObj, updatedInput) {
|
||||
let options = this.getOptions();
|
||||
let maxLength = options.maxLength;
|
||||
let currentInput = inputObj[options.inputName];
|
||||
let condition = updatedInput.length - 1 >= maxLength;
|
||||
const options = this.getOptions();
|
||||
const maxLength = options.maxLength;
|
||||
const currentInput = inputObj[options.inputName];
|
||||
const condition = updatedInput.length - 1 >= maxLength;
|
||||
|
||||
if (
|
||||
/**
|
||||
@@ -334,7 +334,7 @@ class Utilities {
|
||||
}
|
||||
|
||||
if (typeof maxLength === "object") {
|
||||
let condition = currentInput.length === maxLength[options.inputName];
|
||||
const condition = currentInput.length === maxLength[options.inputName];
|
||||
|
||||
if (options.debug) {
|
||||
console.log("maxLength (obj) reached:", condition);
|
||||
@@ -377,8 +377,8 @@ class Utilities {
|
||||
|
||||
static bindMethods(myClass, instance) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {
|
||||
let excludeMethod =
|
||||
for (const myMethod of Object.getOwnPropertyNames(myClass.prototype)) {
|
||||
const excludeMethod =
|
||||
myMethod === "constructor" || myMethod === "bindMethods";
|
||||
if (!excludeMethod) {
|
||||
instance[myMethod] = instance[myMethod].bind(instance);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Keyboard from '../../components/Keyboard';
|
||||
import TestUtility from '../../../utils/TestUtility';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: true
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', ()
|
||||
it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: false
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight',
|
||||
it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: true
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
|
||||
it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: true
|
||||
});
|
||||
|
||||
@@ -70,7 +70,7 @@ it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () =
|
||||
it('PhysicalKeyboard keyup will be handle special buttons', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: true
|
||||
});
|
||||
|
||||
@@ -86,7 +86,7 @@ it('PhysicalKeyboard keyup will be handle special buttons', () => {
|
||||
it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: true,
|
||||
debug: true
|
||||
});
|
||||
@@ -103,7 +103,7 @@ it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
|
||||
it('PhysicalKeyboard will work with F1-F12 keys', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
new Keyboard({
|
||||
physicalKeyboardHighlight: true,
|
||||
debug: true
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Keyboard from '../../components/Keyboard';
|
||||
import TestUtility from '../../../utils/TestUtility';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
const testUtil = new TestUtility();
|
||||
|
||||
it('Keyboard mergeDisplay will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
mergeDisplay: true,
|
||||
display: {
|
||||
"q": "qreplaced"
|
||||
@@ -29,9 +29,9 @@ it('Keyboard function buttons will work', () => {
|
||||
it('Keyboard {bksp} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{bksp}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{bksp}", "test");
|
||||
|
||||
expect(output).toBe("tes");
|
||||
});
|
||||
@@ -39,9 +39,9 @@ it('Keyboard {bksp} button will work', () => {
|
||||
it('Keyboard {space} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{space}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{space}", "test");
|
||||
|
||||
expect(output).toBe("test ");
|
||||
});
|
||||
@@ -49,9 +49,9 @@ it('Keyboard {space} button will work', () => {
|
||||
it('Keyboard {tab} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{tab}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{tab}", "test");
|
||||
|
||||
expect(output).toBe("test\t");
|
||||
});
|
||||
@@ -59,11 +59,11 @@ it('Keyboard {tab} button will work', () => {
|
||||
it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
tabCharOnTab: false
|
||||
});
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{tab}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{tab}", "test");
|
||||
|
||||
expect(output).toBe("test");
|
||||
});
|
||||
@@ -71,9 +71,9 @@ it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
|
||||
it('Keyboard {enter} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{enter}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{enter}", "test");
|
||||
|
||||
expect(output).toBe("test");
|
||||
});
|
||||
@@ -81,11 +81,11 @@ it('Keyboard {enter} button will work', () => {
|
||||
it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
newLineOnEnter: true
|
||||
});
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{enter}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{enter}", "test");
|
||||
|
||||
expect(output).toBe("test\n");
|
||||
});
|
||||
@@ -93,10 +93,10 @@ it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
|
||||
it('Keyboard {numpadX} buttons will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
for(let i = 0;i<=9;i++){
|
||||
let output = keyboard.utilities.getUpdatedInput(`{numpad${i}}`, "test");
|
||||
const output = keyboard.utilities.getUpdatedInput(`{numpad${i}}`, "test");
|
||||
expect(output).toBe(`test${i}`);
|
||||
}
|
||||
});
|
||||
@@ -104,9 +104,9 @@ it('Keyboard {numpadX} buttons will work', () => {
|
||||
it('Keyboard {numpaddivide} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{numpaddivide}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{numpaddivide}", "test");
|
||||
|
||||
expect(output).toBe("test/");
|
||||
});
|
||||
@@ -114,9 +114,9 @@ it('Keyboard {numpaddivide} button will work', () => {
|
||||
it('Keyboard {numpadmultiply} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{numpadmultiply}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{numpadmultiply}", "test");
|
||||
|
||||
expect(output).toBe("test*");
|
||||
});
|
||||
@@ -124,9 +124,9 @@ it('Keyboard {numpadmultiply} button will work', () => {
|
||||
it('Keyboard {numpadsubtract} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{numpadsubtract}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{numpadsubtract}", "test");
|
||||
|
||||
expect(output).toBe("test-");
|
||||
});
|
||||
@@ -134,9 +134,9 @@ it('Keyboard {numpadsubtract} button will work', () => {
|
||||
it('Keyboard {numpadadd} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
|
||||
|
||||
expect(output).toBe("test+");
|
||||
});
|
||||
@@ -144,9 +144,9 @@ it('Keyboard {numpadadd} button will work', () => {
|
||||
it('Keyboard {numpadadd} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
|
||||
|
||||
expect(output).toBe("test+");
|
||||
});
|
||||
@@ -154,9 +154,9 @@ it('Keyboard {numpadadd} button will work', () => {
|
||||
it('Keyboard {numpaddecimal} button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{numpaddecimal}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{numpaddecimal}", "test");
|
||||
|
||||
expect(output).toBe("test.");
|
||||
});
|
||||
@@ -164,7 +164,7 @@ it('Keyboard {numpaddecimal} button will work', () => {
|
||||
it('Keyboard custom function buttons will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
layout: {
|
||||
default: [
|
||||
"{randombuttontest}"
|
||||
@@ -172,7 +172,7 @@ it('Keyboard custom function buttons will work', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{randombuttontest}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{randombuttontest}", "test");
|
||||
|
||||
expect(output).toBe("test");
|
||||
expect(keyboard.getButtonElement("{randombuttontest}").onclick).toBeTruthy();
|
||||
@@ -181,9 +181,9 @@ it('Keyboard custom function buttons will work', () => {
|
||||
it('Keyboard "{" button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("{", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("{", "test");
|
||||
|
||||
expect(output).toBe("test{");
|
||||
});
|
||||
@@ -191,9 +191,9 @@ it('Keyboard "{" button will work', () => {
|
||||
it('Keyboard "}" button will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
let output = keyboard.utilities.getUpdatedInput("}", "test");
|
||||
const output = keyboard.utilities.getUpdatedInput("}", "test");
|
||||
|
||||
expect(output).toBe("test}");
|
||||
});
|
||||
@@ -201,11 +201,11 @@ it('Keyboard "}" button will work', () => {
|
||||
it('Keyboard standard button will affect input', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
for (let i = 65; i <= 90; i++) {
|
||||
let char = String.fromCharCode(i);
|
||||
let output = keyboard.utilities.getUpdatedInput(char, "test");
|
||||
const char = String.fromCharCode(i);
|
||||
const output = keyboard.utilities.getUpdatedInput(char, "test");
|
||||
expect(output).toBe(`test${char}`);
|
||||
}
|
||||
});
|
||||
@@ -213,7 +213,7 @@ it('Keyboard standard button will affect input', () => {
|
||||
it('Keyboard updateCaretPos will work with minus', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
syncInstanceInputs: true
|
||||
});
|
||||
|
||||
@@ -226,7 +226,7 @@ it('Keyboard updateCaretPos will work with minus', () => {
|
||||
it('Keyboard updateCaretPos will work with minus', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.caretPosition = 5;
|
||||
keyboard.utilities.updateCaretPos(2, true);
|
||||
@@ -237,7 +237,7 @@ it('Keyboard updateCaretPos will work with minus', () => {
|
||||
it('Keyboard updateCaretPos will work with plus', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.caretPosition = 5;
|
||||
keyboard.utilities.updateCaretPos(2);
|
||||
@@ -248,7 +248,7 @@ it('Keyboard updateCaretPos will work with plus', () => {
|
||||
it('Keyboard addStringAt will work with debug', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true
|
||||
});
|
||||
|
||||
@@ -260,7 +260,7 @@ it('Keyboard addStringAt will work with debug', () => {
|
||||
it('Keyboard addStringAt will work with position', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true
|
||||
});
|
||||
|
||||
@@ -275,7 +275,7 @@ it('Keyboard addStringAt will work with position', () => {
|
||||
it('Keyboard addStringAt will respect maxLength', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true,
|
||||
maxLength: 4
|
||||
});
|
||||
@@ -292,13 +292,13 @@ it('Keyboard addStringAt will respect maxLength', () => {
|
||||
it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true
|
||||
});
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "test")
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "test")
|
||||
|
||||
expect(output).toBeFalsy();
|
||||
});
|
||||
@@ -306,7 +306,7 @@ it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
|
||||
it('Keyboard handleMaxLength will work with object maxLength', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: {
|
||||
default: 4
|
||||
}
|
||||
@@ -314,7 +314,7 @@ it('Keyboard handleMaxLength will work with object maxLength', () => {
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBeTruthy();
|
||||
});
|
||||
@@ -322,7 +322,7 @@ it('Keyboard handleMaxLength will work with object maxLength', () => {
|
||||
it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: {
|
||||
default: 4
|
||||
},
|
||||
@@ -331,7 +331,7 @@ it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBeTruthy();
|
||||
});
|
||||
@@ -339,7 +339,7 @@ it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
|
||||
it('Keyboard handleMaxLength will return false if obj maxLength not reached', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: {
|
||||
default: 7
|
||||
}
|
||||
@@ -347,7 +347,7 @@ it('Keyboard handleMaxLength will return false if obj maxLength not reached', ()
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBeFalsy();
|
||||
});
|
||||
@@ -356,13 +356,13 @@ it('Keyboard handleMaxLength will return false if obj maxLength not reached', ()
|
||||
it('Keyboard handleMaxLength will work without debug', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: 4
|
||||
});
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBeTruthy();
|
||||
});
|
||||
@@ -371,13 +371,13 @@ it('Keyboard handleMaxLength will work without debug', () => {
|
||||
it('Keyboard handleMaxLength will work with numeric maxLength', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: 3
|
||||
});
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBe(true);
|
||||
});
|
||||
@@ -385,13 +385,13 @@ it('Keyboard handleMaxLength will work with numeric maxLength', () => {
|
||||
it('Keyboard handleMaxLength wont work with non numeric or object maxLength', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: "wrong"
|
||||
});
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBeFalsy();
|
||||
});
|
||||
@@ -399,14 +399,14 @@ it('Keyboard handleMaxLength wont work with non numeric or object maxLength', ()
|
||||
it('Keyboard handleMaxLength wont work with non numeric or object maxLength (with debug)', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: "wrong",
|
||||
debug: true
|
||||
});
|
||||
|
||||
keyboard.setInput("test");
|
||||
|
||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||
|
||||
expect(output).toBeFalsy();
|
||||
});
|
||||
@@ -414,11 +414,11 @@ it('Keyboard handleMaxLength wont work with non numeric or object maxLength (wit
|
||||
it('Keyboard isMaxLengthReached will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
maxLength: 5
|
||||
});
|
||||
|
||||
let output = keyboard.utilities.isMaxLengthReached();
|
||||
const output = keyboard.utilities.isMaxLengthReached();
|
||||
|
||||
expect(output).toBeFalsy();
|
||||
});
|
||||
@@ -426,7 +426,7 @@ it('Keyboard isMaxLengthReached will work', () => {
|
||||
it('Keyboard removeAt will exit out on caretPosition:0', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.setInput("test");
|
||||
keyboard.caretPosition = 0;
|
||||
@@ -442,7 +442,7 @@ it('Keyboard removeAt will exit out on caretPosition:0', () => {
|
||||
it('Keyboard removeAt will remove multi-byte unicodes with caretPos>0', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
|
||||
keyboard.caretPosition = 6;
|
||||
let output = keyboard.utilities.removeAt("test\uD83D\uDE00", 6);
|
||||
@@ -456,7 +456,7 @@ it('Keyboard removeAt will remove multi-byte unicodes with caretPos>0', () => {
|
||||
it('Keyboard removeAt will not remove multi-byte unicodes with caretPos:0', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
let output = keyboard.utilities.removeAt("\uD83D\uDE00");
|
||||
expect(output).toBeFalsy();
|
||||
|
||||
@@ -467,7 +467,7 @@ it('Keyboard removeAt will not remove multi-byte unicodes with caretPos:0', () =
|
||||
it('Keyboard removeAt will remove regular strings', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
const keyboard = new Keyboard({
|
||||
debug: true
|
||||
});
|
||||
|
||||
@@ -482,12 +482,12 @@ it('Keyboard removeAt will remove regular strings', () => {
|
||||
|
||||
it('Keyboard will work with custom (and weird) class', () => {
|
||||
testUtil.setDOM("my--weird--class");
|
||||
let keyboard = new Keyboard(".my--weird--class");
|
||||
const keyboard = new Keyboard(".my--weird--class");
|
||||
expect(keyboard.keyboardDOMClass).toBe("my--weird--class");
|
||||
});
|
||||
|
||||
it('Keyboard camelCase will work with empty strings', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard();
|
||||
const keyboard = new Keyboard();
|
||||
expect(keyboard.utilities.camelCase()).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
export default class TestUtility {
|
||||
/**
|
||||
* Set's a basic DOM structure to test in
|
||||
* Sets a basic DOM structure to test in
|
||||
*/
|
||||
setDOM = (divClass) => {
|
||||
this.clear();
|
||||
@@ -109,4 +109,4 @@ export default class TestUtility {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user