x4js 2.0.35 → 2.1.0-manual
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -21
- package/package.json +39 -26
- package/src/components/base.scss +25 -89
- package/src/components/boxes/boxes.module.scss +54 -54
- package/src/components/boxes/boxes.ts +513 -513
- package/src/components/breadcrumb/breadcrumb.scss +56 -56
- package/src/components/breadcrumb/breadcrumb.ts +93 -93
- package/src/components/btngroup/btngroup.module.scss +40 -40
- package/src/components/btngroup/btngroup.ts +152 -152
- package/src/components/button/button.module.scss +172 -172
- package/src/components/button/button.ts +232 -232
- package/src/components/calendar/calendar.module.scss +162 -162
- package/src/components/calendar/calendar.ts +326 -326
- package/src/components/canvas/canvas.module.scss +24 -24
- package/src/components/canvas/canvas.ts +195 -195
- package/src/components/canvas/canvas_ex.ts +275 -275
- package/src/components/checkbox/check.svg +3 -3
- package/src/components/checkbox/checkbox.module.scss +141 -141
- package/src/components/checkbox/checkbox.ts +139 -139
- package/src/components/colorinput/colorinput.module.scss +64 -64
- package/src/components/colorinput/colorinput.ts +90 -90
- package/src/components/colorpicker/colorpicker.module.scss +132 -132
- package/src/components/colorpicker/colorpicker.ts +481 -481
- package/src/components/combobox/combobox.module.scss +145 -145
- package/src/components/combobox/combobox.ts +282 -282
- package/src/components/combobox/updown.svg +3 -3
- package/src/components/components.ts +45 -44
- package/src/components/dialog/dialog.module.scss +103 -105
- package/src/components/dialog/dialog.ts +233 -233
- package/src/components/filedrop/filedrop.module.scss +69 -69
- package/src/components/filedrop/filedrop.ts +130 -130
- package/src/components/form/form.module.scss +38 -38
- package/src/components/form/form.ts +172 -172
- package/src/components/gridview/gridview.module.scss +323 -337
- package/src/components/gridview/gridview.ts +1276 -1316
- package/src/components/header/header.module.scss +40 -40
- package/src/components/header/header.ts +141 -141
- package/src/components/icon/icon.module.scss +32 -32
- package/src/components/icon/icon.ts +165 -165
- package/src/components/image/image.module.scss +27 -27
- package/src/components/image/image.ts +168 -168
- package/src/components/input/input.module.scss +74 -74
- package/src/components/input/input.ts +537 -537
- package/src/components/keyboard/keyboard.module.scss +136 -136
- package/src/components/keyboard/keyboard.ts +549 -549
- package/src/components/label/label.module.scss +90 -91
- package/src/components/label/label.ts +101 -101
- package/src/components/link/link.module.scss +44 -44
- package/src/components/link/link.ts +87 -87
- package/src/components/listbox/listbox.module.scss +179 -179
- package/src/components/listbox/listbox.ts +596 -596
- package/src/components/menu/menu.module.scss +128 -128
- package/src/components/menu/menu.ts +174 -174
- package/src/components/messages/messages.module.scss +92 -146
- package/src/components/messages/messages.ts +237 -303
- package/src/components/normalize.scss +391 -391
- package/src/components/notification/notification.module.scss +83 -83
- package/src/components/notification/notification.ts +107 -107
- package/src/components/panel/panel.module.scss +66 -71
- package/src/components/panel/panel.ts +57 -57
- package/src/components/popup/popup.module.scss +51 -51
- package/src/components/popup/popup.ts +457 -457
- package/src/components/progress/progress.module.scss +56 -56
- package/src/components/progress/progress.ts +43 -43
- package/src/components/propgrid/progrid.module.scss +111 -111
- package/src/components/propgrid/propgrid.ts +300 -300
- package/src/components/propgrid/updown.svg +3 -3
- package/src/components/radio/radio.module.scss +163 -163
- package/src/components/radio/radio.svg +3 -3
- package/src/components/radio/radio.ts +141 -141
- package/src/components/rating/rating.module.scss +22 -22
- package/src/components/rating/rating.ts +131 -131
- package/src/components/select/select.module.scss +8 -8
- package/src/components/select/select.ts +134 -134
- package/src/components/shared.scss +141 -71
- package/src/components/sizers/sizer.module.scss +90 -112
- package/src/components/sizers/sizer.ts +131 -155
- package/src/components/slider/slider.module.scss +117 -117
- package/src/components/slider/slider.ts +197 -197
- package/src/components/spreadsheet/spreadsheet.module.scss +307 -307
- package/src/components/spreadsheet/spreadsheet.ts +1223 -1223
- package/src/components/switch/switch.module.scss +126 -126
- package/src/components/switch/switch.ts +61 -61
- package/src/components/tabs/tabs.module.scss +46 -67
- package/src/components/tabs/tabs.ts +229 -234
- package/src/components/textarea/textarea.module.scss +63 -63
- package/src/components/textarea/textarea.ts +131 -131
- package/src/components/textedit/textedit.module.scss +115 -115
- package/src/components/textedit/textedit.ts +122 -122
- package/src/components/themes.scss +90 -90
- package/src/components/tickline/tickline.module.scss +25 -25
- package/src/components/tickline/tickline.ts +81 -81
- package/src/components/tooltips/tooltips.scss +71 -71
- package/src/components/tooltips/tooltips.ts +120 -120
- package/src/components/treeview/treeview.module.scss +192 -192
- package/src/components/treeview/treeview.ts +484 -484
- package/src/components/viewport/viewport.module.scss +31 -31
- package/src/components/viewport/viewport.ts +41 -41
- package/src/core/component.ts +1299 -1299
- package/src/core/core_application.ts +361 -361
- package/src/core/core_colors.ts +512 -512
- package/src/core/core_data.ts +1297 -1310
- package/src/core/core_dom.ts +481 -481
- package/src/core/core_dragdrop.ts +225 -225
- package/src/core/core_element.ts +221 -221
- package/src/core/core_events.ts +214 -214
- package/src/core/core_i18n.ts +395 -395
- package/src/core/core_pdf.ts +454 -454
- package/src/core/core_react.ts +78 -78
- package/src/core/core_router.ts +296 -296
- package/src/core/core_state.ts +62 -62
- package/src/core/core_styles.ts +213 -213
- package/src/core/core_svg.ts +1042 -1042
- package/src/core/core_tools.ts +996 -996
- package/src/types/scss.d.ts +4 -4
- package/src/types/x4react.d.ts +8 -8
- package/src/x4.scss +19 -19
- package/src/x4.ts +36 -36
- package/src/x4tsx.d.ts +26 -26
- package/.vscode/launch.json +0 -14
- package/.vscode/settings.json +0 -2
- package/demo/assets/house-light.svg +0 -1
- package/demo/assets/radio.svg +0 -4
- package/demo/index.html +0 -12
- package/demo/main.scss +0 -23
- package/demo/main.ts +0 -324
- package/demo/package.json +0 -26
- package/demo/scss.d.ts +0 -4
- package/demo/svg.d.ts +0 -1
- package/demo/tsconfig.json +0 -14
- package/src/components/gridview/folder-open.svg +0 -1
- package/src/components/messages/spinner.svg +0 -1
- package/src/x4.d.ts +0 -10
- package/tsconfig.json +0 -11
|
@@ -1,550 +1,550 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file keyboard.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import { Component } from '../../core/component';
|
|
18
|
-
import { Box, BoxProps, Button, HBox, VBox } from '../components';
|
|
19
|
-
import { _tr } from '../../core/core_i18n';
|
|
20
|
-
|
|
21
|
-
import "./keyboard.module.scss"
|
|
22
|
-
import { class_ns } from '../../core/core_tools';
|
|
23
|
-
import { Application } from '../../core/core_application';
|
|
24
|
-
|
|
25
|
-
import icon_bksp from "./delete-left.svg";
|
|
26
|
-
import icon_shift from "./arrow-up.svg";
|
|
27
|
-
import icon_hide from "./eye-slash.svg";
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const kb_def: any = {
|
|
32
|
-
'fr-FR': {
|
|
33
|
-
lines: {
|
|
34
|
-
lower: [
|
|
35
|
-
"1 2 3 4 5 6 7 8 9 0",
|
|
36
|
-
"a z e r t y u i o p {2}",
|
|
37
|
-
"q s d f g h j k l m {3}",
|
|
38
|
-
"{4} w x c v b n , . {4}",
|
|
39
|
-
"{5} {6} ' {7}"
|
|
40
|
-
],
|
|
41
|
-
upper: [
|
|
42
|
-
"! @ # $ % ^ & * ( ) _ +",
|
|
43
|
-
"A Z E R T Y U I O P {2}",
|
|
44
|
-
"Q S D F G H J K L M {3}",
|
|
45
|
-
"{4} W X C V B N ? : {4}",
|
|
46
|
-
"{5} {6} ' {7}",
|
|
47
|
-
],
|
|
48
|
-
number: [
|
|
49
|
-
"1 2 3 {2}",
|
|
50
|
-
"4 5 6 {8}",
|
|
51
|
-
"7 8 9 {9}",
|
|
52
|
-
"0 . {3} {9}"
|
|
53
|
-
],
|
|
54
|
-
date: [
|
|
55
|
-
"1 2 3 {2}",
|
|
56
|
-
"4 5 6 {8}",
|
|
57
|
-
"7 8 9 {9}",
|
|
58
|
-
"0 / {3} {9}"
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
'en-GB': {
|
|
63
|
-
lines: {
|
|
64
|
-
lower: [
|
|
65
|
-
"1 2 3 4 5 6 7 8 9 0",
|
|
66
|
-
"a z e r t y u i o p {2}",
|
|
67
|
-
"q s d f g h j k l m {3}",
|
|
68
|
-
"{4} w x c v b n , . {4}",
|
|
69
|
-
"{5} {6} ' {7}"
|
|
70
|
-
],
|
|
71
|
-
upper: [
|
|
72
|
-
"! @ # $ % ^ & * ( ) _ +",
|
|
73
|
-
"A Z E R T Y U I O P {2}",
|
|
74
|
-
"Q S D F G H J K L M {3}",
|
|
75
|
-
"{4} W X C V B N ? : {4}",
|
|
76
|
-
"{5} {6} ' {7}",
|
|
77
|
-
],
|
|
78
|
-
number: [
|
|
79
|
-
"1 2 3 {2}",
|
|
80
|
-
"4 5 6 {8}",
|
|
81
|
-
"7 8 9 {9}",
|
|
82
|
-
"0 . {3} {9}"
|
|
83
|
-
],
|
|
84
|
-
date: [
|
|
85
|
-
"1 2 3 {2}",
|
|
86
|
-
"4 5 6 {8}",
|
|
87
|
-
"7 8 9 {9}",
|
|
88
|
-
"0 / {3} {9}"
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
'en-US': 'en-GB'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const RE_sel = /text|password|search|tel|url/i;
|
|
97
|
-
|
|
98
|
-
interface KeyboardProps extends BoxProps {
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@class_ns( "x4" )
|
|
103
|
-
export class Keyboard extends HBox<KeyboardProps>
|
|
104
|
-
{
|
|
105
|
-
mode: "lower" | "upper" | "number" | "date";
|
|
106
|
-
locale: string;
|
|
107
|
-
keyboard: Box;
|
|
108
|
-
visible: boolean;
|
|
109
|
-
input: HTMLInputElement;
|
|
110
|
-
|
|
111
|
-
constructor( props: KeyboardProps ) {
|
|
112
|
-
super( { ...props, id: 'v-keyboard' } );
|
|
113
|
-
|
|
114
|
-
this.mode = 'lower';
|
|
115
|
-
this.locale = 'fr-FR';
|
|
116
|
-
this.visible = false;
|
|
117
|
-
|
|
118
|
-
document.addEventListener( 'focusin', (e) => this.handleFocus(e.target as Element,true), false );
|
|
119
|
-
document.addEventListener( 'focusout', (e) => this.handleFocus(e.target as Element,false), false );
|
|
120
|
-
|
|
121
|
-
this.hide( );
|
|
122
|
-
|
|
123
|
-
this.addDOMEvent( "mousedown", (e) => {
|
|
124
|
-
this.handleKeyEvent( e );
|
|
125
|
-
e.preventDefault( );
|
|
126
|
-
e.stopPropagation( );
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// for rapid people
|
|
130
|
-
this.addDOMEvent( "dblclick", (e) => {
|
|
131
|
-
this.handleKeyEvent( e );
|
|
132
|
-
e.preventDefault( );
|
|
133
|
-
e.stopPropagation( );
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// for slow people
|
|
137
|
-
this.addDOMEvent( "contextmenu", (e) => {
|
|
138
|
-
e.preventDefault( );
|
|
139
|
-
e.stopPropagation( );
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
setZoom( perc: number ) {
|
|
144
|
-
this.setStyleVariable( '--keyboard-zoom', perc+'%' );
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
*
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
private handleKeyEvent( e: UIEvent ) {
|
|
152
|
-
let target = e.target as HTMLElement;
|
|
153
|
-
let key;
|
|
154
|
-
|
|
155
|
-
while( target!==this.dom ) {
|
|
156
|
-
if( target.hasAttribute('data-key') ) {
|
|
157
|
-
key = parseInt(target.getAttribute('data-key'), 10);
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
target = target.parentNode as HTMLElement;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if( !key ) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this._handleKey( key );
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
private _handleKey( key: number ) {
|
|
172
|
-
switch( key ) {
|
|
173
|
-
// bk space
|
|
174
|
-
case 2: {
|
|
175
|
-
this.fireKey( 0, this._backspace );
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// return
|
|
180
|
-
case 3: {
|
|
181
|
-
this._focusNext( );
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// shift
|
|
186
|
-
case 4: {
|
|
187
|
-
if( this.mode=='lower' ) {
|
|
188
|
-
this.mode = 'upper';
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
this.mode = 'lower';
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this._redraw( );
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// num + sym
|
|
199
|
-
case 5: {
|
|
200
|
-
this._switchMode( "number" );
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// space
|
|
205
|
-
case 6: {
|
|
206
|
-
this.fireKey( 32, this._insertChar );
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// hide
|
|
211
|
-
case 7: {
|
|
212
|
-
this.hide( );
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
case 8: {
|
|
217
|
-
this._switchMode( "lower" );
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
default: {
|
|
222
|
-
this.fireKey( key, this._insertChar );
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
*
|
|
230
|
-
*/
|
|
231
|
-
|
|
232
|
-
private _focusNext( ) {
|
|
233
|
-
Application.instance().focusNext( true );
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
*
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
private _switchMode( m: "lower" | "upper" | "number" | "date" ) {
|
|
241
|
-
this.mode = m;
|
|
242
|
-
this._redraw( );
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
*
|
|
247
|
-
*/
|
|
248
|
-
|
|
249
|
-
private _redraw( ) {
|
|
250
|
-
this.setContent( [
|
|
251
|
-
this.keyboard = new VBox( {
|
|
252
|
-
id: "kb",
|
|
253
|
-
cls: this.mode,
|
|
254
|
-
content: this._createContent( ),
|
|
255
|
-
}),
|
|
256
|
-
] );
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
private _scrollIntoView( el: HTMLElement ) {
|
|
260
|
-
|
|
261
|
-
let parent = el.parentElement ;
|
|
262
|
-
|
|
263
|
-
while( parent!=document.body ) {
|
|
264
|
-
|
|
265
|
-
if( parent.style.overflowY!=='' ) {
|
|
266
|
-
let targ = el.getBoundingClientRect( );
|
|
267
|
-
let bound = parent.getBoundingClientRect( );
|
|
268
|
-
|
|
269
|
-
if( targ.top<bound.top ) {
|
|
270
|
-
el.scrollIntoView( true );
|
|
271
|
-
}
|
|
272
|
-
else if( targ.bottom>bound.bottom ) {
|
|
273
|
-
el.scrollIntoView( false );
|
|
274
|
-
}
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
parent = parent.parentElement;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
//el.scrollIntoView( false );
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
private _updateVis = ( ) => {
|
|
285
|
-
|
|
286
|
-
if( this.visible ) {
|
|
287
|
-
if( this.input ) {
|
|
288
|
-
const type = this.input.type;
|
|
289
|
-
|
|
290
|
-
if( type=='check' || type=="radio" ) {
|
|
291
|
-
this.hide( );
|
|
292
|
-
this.input = null;
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
this.show( );
|
|
296
|
-
this._scrollIntoView( this.input );
|
|
297
|
-
|
|
298
|
-
const dtype = this.input.getAttribute( "data-type" );
|
|
299
|
-
|
|
300
|
-
if( type==='number' || dtype==='number' ) {
|
|
301
|
-
this._switchMode( "number" )
|
|
302
|
-
}
|
|
303
|
-
else if( type==='date' || dtype==='date' ) {
|
|
304
|
-
this._switchMode( "date");
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
this._switchMode( "lower" );
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
this.hide( );
|
|
314
|
-
this.input = null;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
*
|
|
320
|
-
*/
|
|
321
|
-
|
|
322
|
-
showOn( el: Component ) {
|
|
323
|
-
this.handleFocus( el.dom, true );
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
*
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
private handleFocus( target: Element, enter: boolean ) {
|
|
331
|
-
|
|
332
|
-
if( enter ) {
|
|
333
|
-
if( target.tagName=='INPUT' ) {
|
|
334
|
-
const input = target as HTMLInputElement;
|
|
335
|
-
if( !input.readOnly &&
|
|
336
|
-
input.type!='checkbox' && input.type!='radio' &&
|
|
337
|
-
input.type!='range' && input.type!='file' ) {
|
|
338
|
-
this.input = input;
|
|
339
|
-
this.visible = true;
|
|
340
|
-
this.setTimeout( "vis", 200, this._updateVis );
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
this.visible = false;
|
|
347
|
-
this.setTimeout( "vis", 200, this._updateVis );
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
*
|
|
352
|
-
*/
|
|
353
|
-
|
|
354
|
-
private _insertChar(caret: any, text: string, ch: string ) {
|
|
355
|
-
text = text.substring(0, caret.start) + ch.toString() + text.substring(caret.end);
|
|
356
|
-
caret.start += ch.length;
|
|
357
|
-
caret.end = caret.start;
|
|
358
|
-
return text;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
*
|
|
363
|
-
*/
|
|
364
|
-
|
|
365
|
-
private _backspace(caret: any, text: string ) {
|
|
366
|
-
text = text.substring(0, caret.start - 1) + text.substring(caret.start);
|
|
367
|
-
caret.start -= 1;
|
|
368
|
-
caret.end = caret.start;
|
|
369
|
-
return text;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
*
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
private _getCaret( ) {
|
|
377
|
-
|
|
378
|
-
if( this.input && RE_sel.test(this.input.type) ) {
|
|
379
|
-
let pos = {
|
|
380
|
-
start: this.input.selectionStart || 0,
|
|
381
|
-
end: this.input.selectionEnd || 0
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
if (pos.end < pos.start) {
|
|
385
|
-
pos.end = pos.start;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return pos;
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
let length = this.input.value.length;
|
|
392
|
-
return {
|
|
393
|
-
start: length,
|
|
394
|
-
end: length
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
*
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
|
-
private _restoreCaretPos( caret: any ) {
|
|
404
|
-
if( RE_sel.test(this.input.type) ) {
|
|
405
|
-
this.input.selectionStart = caret.start;
|
|
406
|
-
this.input.selectionEnd = caret.end;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
*
|
|
412
|
-
*/
|
|
413
|
-
|
|
414
|
-
private fireKey( key: number, cb: Function ) {
|
|
415
|
-
let caret = this._getCaret( );
|
|
416
|
-
let text = this.input.value;
|
|
417
|
-
text = cb.call( this, caret, text, String.fromCharCode(key) );
|
|
418
|
-
this.input.value = text;
|
|
419
|
-
this._restoreCaretPos(caret);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
*
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
private _createContent( ) {
|
|
427
|
-
let lines = kb_def[this.locale].lines[this.mode];
|
|
428
|
-
let result: Box[] = [];
|
|
429
|
-
|
|
430
|
-
for( let j=0; j<lines.length; j++ ) {
|
|
431
|
-
|
|
432
|
-
const line = lines[j].split(' ');
|
|
433
|
-
|
|
434
|
-
let tl: Component[] = [];
|
|
435
|
-
|
|
436
|
-
for( let i=0; i<line.length; i++ ) {
|
|
437
|
-
|
|
438
|
-
let cls = 'tch c'+i;
|
|
439
|
-
let content = line[i];
|
|
440
|
-
let key;
|
|
441
|
-
let icon = null;
|
|
442
|
-
let repeat = false;
|
|
443
|
-
|
|
444
|
-
if( content.length>2 && content[0]=='{' && content[content.length-1]=='}') {
|
|
445
|
-
|
|
446
|
-
let c = parseInt(content.substring(1, content.length - 1), 10 );
|
|
447
|
-
|
|
448
|
-
switch( c ) {
|
|
449
|
-
default:
|
|
450
|
-
case 0:
|
|
451
|
-
{
|
|
452
|
-
content = '';
|
|
453
|
-
cls += ' x4hidden';
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
case 1:
|
|
458
|
-
{
|
|
459
|
-
content = '';
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
case 2:
|
|
464
|
-
{
|
|
465
|
-
repeat = true;
|
|
466
|
-
content = undefined;
|
|
467
|
-
icon = icon_bksp;
|
|
468
|
-
cls += ' cdel';
|
|
469
|
-
break;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
case 3:
|
|
473
|
-
{
|
|
474
|
-
content = _tr.global.keyboard.next;
|
|
475
|
-
cls += ' cret';
|
|
476
|
-
break;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
case 4:
|
|
480
|
-
{
|
|
481
|
-
content = undefined;
|
|
482
|
-
icon = icon_shift;
|
|
483
|
-
cls += ' cshift';
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
case 5:
|
|
488
|
-
{
|
|
489
|
-
content = _tr.global.keyboard.numeric;
|
|
490
|
-
cls += ' cnum';
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
case 6:
|
|
495
|
-
{
|
|
496
|
-
content = '\u00a0';
|
|
497
|
-
cls += ' cspace';
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
case 7:
|
|
502
|
-
{
|
|
503
|
-
content = undefined;
|
|
504
|
-
icon = icon_hide;
|
|
505
|
-
cls += ' chide';
|
|
506
|
-
break;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
case 8:
|
|
510
|
-
{
|
|
511
|
-
content = _tr.global.keyboard.alpha;
|
|
512
|
-
cls += ' calpha';
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
case 9:
|
|
517
|
-
{
|
|
518
|
-
content = '';
|
|
519
|
-
cls += ' cplace';
|
|
520
|
-
break;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
key = c;
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
key = line[i].charCodeAt(0);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
let el = new Button( {
|
|
531
|
-
cls,
|
|
532
|
-
label: content,
|
|
533
|
-
attrs: {'data-key': key},
|
|
534
|
-
icon,
|
|
535
|
-
autorepeat: repeat,
|
|
536
|
-
click: ( e ) => {
|
|
537
|
-
if( e.repeat ) {
|
|
538
|
-
this._handleKey( key )
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
} );
|
|
542
|
-
tl.push( el );
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
result.push( new HBox( { cls: 'line', content: tl } ) );
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
return result;
|
|
549
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file keyboard.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license
|
|
14
|
+
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
import { Component } from '../../core/component';
|
|
18
|
+
import { Box, BoxProps, Button, HBox, VBox } from '../components';
|
|
19
|
+
import { _tr } from '../../core/core_i18n';
|
|
20
|
+
|
|
21
|
+
import "./keyboard.module.scss"
|
|
22
|
+
import { class_ns } from '../../core/core_tools';
|
|
23
|
+
import { Application } from '../../core/core_application';
|
|
24
|
+
|
|
25
|
+
import icon_bksp from "./delete-left.svg";
|
|
26
|
+
import icon_shift from "./arrow-up.svg";
|
|
27
|
+
import icon_hide from "./eye-slash.svg";
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const kb_def: any = {
|
|
32
|
+
'fr-FR': {
|
|
33
|
+
lines: {
|
|
34
|
+
lower: [
|
|
35
|
+
"1 2 3 4 5 6 7 8 9 0",
|
|
36
|
+
"a z e r t y u i o p {2}",
|
|
37
|
+
"q s d f g h j k l m {3}",
|
|
38
|
+
"{4} w x c v b n , . {4}",
|
|
39
|
+
"{5} {6} ' {7}"
|
|
40
|
+
],
|
|
41
|
+
upper: [
|
|
42
|
+
"! @ # $ % ^ & * ( ) _ +",
|
|
43
|
+
"A Z E R T Y U I O P {2}",
|
|
44
|
+
"Q S D F G H J K L M {3}",
|
|
45
|
+
"{4} W X C V B N ? : {4}",
|
|
46
|
+
"{5} {6} ' {7}",
|
|
47
|
+
],
|
|
48
|
+
number: [
|
|
49
|
+
"1 2 3 {2}",
|
|
50
|
+
"4 5 6 {8}",
|
|
51
|
+
"7 8 9 {9}",
|
|
52
|
+
"0 . {3} {9}"
|
|
53
|
+
],
|
|
54
|
+
date: [
|
|
55
|
+
"1 2 3 {2}",
|
|
56
|
+
"4 5 6 {8}",
|
|
57
|
+
"7 8 9 {9}",
|
|
58
|
+
"0 / {3} {9}"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
'en-GB': {
|
|
63
|
+
lines: {
|
|
64
|
+
lower: [
|
|
65
|
+
"1 2 3 4 5 6 7 8 9 0",
|
|
66
|
+
"a z e r t y u i o p {2}",
|
|
67
|
+
"q s d f g h j k l m {3}",
|
|
68
|
+
"{4} w x c v b n , . {4}",
|
|
69
|
+
"{5} {6} ' {7}"
|
|
70
|
+
],
|
|
71
|
+
upper: [
|
|
72
|
+
"! @ # $ % ^ & * ( ) _ +",
|
|
73
|
+
"A Z E R T Y U I O P {2}",
|
|
74
|
+
"Q S D F G H J K L M {3}",
|
|
75
|
+
"{4} W X C V B N ? : {4}",
|
|
76
|
+
"{5} {6} ' {7}",
|
|
77
|
+
],
|
|
78
|
+
number: [
|
|
79
|
+
"1 2 3 {2}",
|
|
80
|
+
"4 5 6 {8}",
|
|
81
|
+
"7 8 9 {9}",
|
|
82
|
+
"0 . {3} {9}"
|
|
83
|
+
],
|
|
84
|
+
date: [
|
|
85
|
+
"1 2 3 {2}",
|
|
86
|
+
"4 5 6 {8}",
|
|
87
|
+
"7 8 9 {9}",
|
|
88
|
+
"0 / {3} {9}"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
'en-US': 'en-GB'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
const RE_sel = /text|password|search|tel|url/i;
|
|
97
|
+
|
|
98
|
+
interface KeyboardProps extends BoxProps {
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@class_ns( "x4" )
|
|
103
|
+
export class Keyboard extends HBox<KeyboardProps>
|
|
104
|
+
{
|
|
105
|
+
mode: "lower" | "upper" | "number" | "date";
|
|
106
|
+
locale: string;
|
|
107
|
+
keyboard: Box;
|
|
108
|
+
visible: boolean;
|
|
109
|
+
input: HTMLInputElement;
|
|
110
|
+
|
|
111
|
+
constructor( props: KeyboardProps ) {
|
|
112
|
+
super( { ...props, id: 'v-keyboard' } );
|
|
113
|
+
|
|
114
|
+
this.mode = 'lower';
|
|
115
|
+
this.locale = 'fr-FR';
|
|
116
|
+
this.visible = false;
|
|
117
|
+
|
|
118
|
+
document.addEventListener( 'focusin', (e) => this.handleFocus(e.target as Element,true), false );
|
|
119
|
+
document.addEventListener( 'focusout', (e) => this.handleFocus(e.target as Element,false), false );
|
|
120
|
+
|
|
121
|
+
this.hide( );
|
|
122
|
+
|
|
123
|
+
this.addDOMEvent( "mousedown", (e) => {
|
|
124
|
+
this.handleKeyEvent( e );
|
|
125
|
+
e.preventDefault( );
|
|
126
|
+
e.stopPropagation( );
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// for rapid people
|
|
130
|
+
this.addDOMEvent( "dblclick", (e) => {
|
|
131
|
+
this.handleKeyEvent( e );
|
|
132
|
+
e.preventDefault( );
|
|
133
|
+
e.stopPropagation( );
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// for slow people
|
|
137
|
+
this.addDOMEvent( "contextmenu", (e) => {
|
|
138
|
+
e.preventDefault( );
|
|
139
|
+
e.stopPropagation( );
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
setZoom( perc: number ) {
|
|
144
|
+
this.setStyleVariable( '--keyboard-zoom', perc+'%' );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
private handleKeyEvent( e: UIEvent ) {
|
|
152
|
+
let target = e.target as HTMLElement;
|
|
153
|
+
let key;
|
|
154
|
+
|
|
155
|
+
while( target!==this.dom ) {
|
|
156
|
+
if( target.hasAttribute('data-key') ) {
|
|
157
|
+
key = parseInt(target.getAttribute('data-key'), 10);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
target = target.parentNode as HTMLElement;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if( !key ) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
this._handleKey( key );
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private _handleKey( key: number ) {
|
|
172
|
+
switch( key ) {
|
|
173
|
+
// bk space
|
|
174
|
+
case 2: {
|
|
175
|
+
this.fireKey( 0, this._backspace );
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// return
|
|
180
|
+
case 3: {
|
|
181
|
+
this._focusNext( );
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// shift
|
|
186
|
+
case 4: {
|
|
187
|
+
if( this.mode=='lower' ) {
|
|
188
|
+
this.mode = 'upper';
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
this.mode = 'lower';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this._redraw( );
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// num + sym
|
|
199
|
+
case 5: {
|
|
200
|
+
this._switchMode( "number" );
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// space
|
|
205
|
+
case 6: {
|
|
206
|
+
this.fireKey( 32, this._insertChar );
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// hide
|
|
211
|
+
case 7: {
|
|
212
|
+
this.hide( );
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
case 8: {
|
|
217
|
+
this._switchMode( "lower" );
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
default: {
|
|
222
|
+
this.fireKey( key, this._insertChar );
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
private _focusNext( ) {
|
|
233
|
+
Application.instance().focusNext( true );
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
*
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
private _switchMode( m: "lower" | "upper" | "number" | "date" ) {
|
|
241
|
+
this.mode = m;
|
|
242
|
+
this._redraw( );
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
private _redraw( ) {
|
|
250
|
+
this.setContent( [
|
|
251
|
+
this.keyboard = new VBox( {
|
|
252
|
+
id: "kb",
|
|
253
|
+
cls: this.mode,
|
|
254
|
+
content: this._createContent( ),
|
|
255
|
+
}),
|
|
256
|
+
] );
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private _scrollIntoView( el: HTMLElement ) {
|
|
260
|
+
|
|
261
|
+
let parent = el.parentElement ;
|
|
262
|
+
|
|
263
|
+
while( parent!=document.body ) {
|
|
264
|
+
|
|
265
|
+
if( parent.style.overflowY!=='' ) {
|
|
266
|
+
let targ = el.getBoundingClientRect( );
|
|
267
|
+
let bound = parent.getBoundingClientRect( );
|
|
268
|
+
|
|
269
|
+
if( targ.top<bound.top ) {
|
|
270
|
+
el.scrollIntoView( true );
|
|
271
|
+
}
|
|
272
|
+
else if( targ.bottom>bound.bottom ) {
|
|
273
|
+
el.scrollIntoView( false );
|
|
274
|
+
}
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
parent = parent.parentElement;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
//el.scrollIntoView( false );
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private _updateVis = ( ) => {
|
|
285
|
+
|
|
286
|
+
if( this.visible ) {
|
|
287
|
+
if( this.input ) {
|
|
288
|
+
const type = this.input.type;
|
|
289
|
+
|
|
290
|
+
if( type=='check' || type=="radio" ) {
|
|
291
|
+
this.hide( );
|
|
292
|
+
this.input = null;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
this.show( );
|
|
296
|
+
this._scrollIntoView( this.input );
|
|
297
|
+
|
|
298
|
+
const dtype = this.input.getAttribute( "data-type" );
|
|
299
|
+
|
|
300
|
+
if( type==='number' || dtype==='number' ) {
|
|
301
|
+
this._switchMode( "number" )
|
|
302
|
+
}
|
|
303
|
+
else if( type==='date' || dtype==='date' ) {
|
|
304
|
+
this._switchMode( "date");
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this._switchMode( "lower" );
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
this.hide( );
|
|
314
|
+
this.input = null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
*
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
showOn( el: Component ) {
|
|
323
|
+
this.handleFocus( el.dom, true );
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
*
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
private handleFocus( target: Element, enter: boolean ) {
|
|
331
|
+
|
|
332
|
+
if( enter ) {
|
|
333
|
+
if( target.tagName=='INPUT' ) {
|
|
334
|
+
const input = target as HTMLInputElement;
|
|
335
|
+
if( !input.readOnly &&
|
|
336
|
+
input.type!='checkbox' && input.type!='radio' &&
|
|
337
|
+
input.type!='range' && input.type!='file' ) {
|
|
338
|
+
this.input = input;
|
|
339
|
+
this.visible = true;
|
|
340
|
+
this.setTimeout( "vis", 200, this._updateVis );
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
this.visible = false;
|
|
347
|
+
this.setTimeout( "vis", 200, this._updateVis );
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
*
|
|
352
|
+
*/
|
|
353
|
+
|
|
354
|
+
private _insertChar(caret: any, text: string, ch: string ) {
|
|
355
|
+
text = text.substring(0, caret.start) + ch.toString() + text.substring(caret.end);
|
|
356
|
+
caret.start += ch.length;
|
|
357
|
+
caret.end = caret.start;
|
|
358
|
+
return text;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
*
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
private _backspace(caret: any, text: string ) {
|
|
366
|
+
text = text.substring(0, caret.start - 1) + text.substring(caret.start);
|
|
367
|
+
caret.start -= 1;
|
|
368
|
+
caret.end = caret.start;
|
|
369
|
+
return text;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
*
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
private _getCaret( ) {
|
|
377
|
+
|
|
378
|
+
if( this.input && RE_sel.test(this.input.type) ) {
|
|
379
|
+
let pos = {
|
|
380
|
+
start: this.input.selectionStart || 0,
|
|
381
|
+
end: this.input.selectionEnd || 0
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
if (pos.end < pos.start) {
|
|
385
|
+
pos.end = pos.start;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return pos;
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
let length = this.input.value.length;
|
|
392
|
+
return {
|
|
393
|
+
start: length,
|
|
394
|
+
end: length
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
*
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
private _restoreCaretPos( caret: any ) {
|
|
404
|
+
if( RE_sel.test(this.input.type) ) {
|
|
405
|
+
this.input.selectionStart = caret.start;
|
|
406
|
+
this.input.selectionEnd = caret.end;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
*
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
private fireKey( key: number, cb: Function ) {
|
|
415
|
+
let caret = this._getCaret( );
|
|
416
|
+
let text = this.input.value;
|
|
417
|
+
text = cb.call( this, caret, text, String.fromCharCode(key) );
|
|
418
|
+
this.input.value = text;
|
|
419
|
+
this._restoreCaretPos(caret);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
*
|
|
424
|
+
*/
|
|
425
|
+
|
|
426
|
+
private _createContent( ) {
|
|
427
|
+
let lines = kb_def[this.locale].lines[this.mode];
|
|
428
|
+
let result: Box[] = [];
|
|
429
|
+
|
|
430
|
+
for( let j=0; j<lines.length; j++ ) {
|
|
431
|
+
|
|
432
|
+
const line = lines[j].split(' ');
|
|
433
|
+
|
|
434
|
+
let tl: Component[] = [];
|
|
435
|
+
|
|
436
|
+
for( let i=0; i<line.length; i++ ) {
|
|
437
|
+
|
|
438
|
+
let cls = 'tch c'+i;
|
|
439
|
+
let content = line[i];
|
|
440
|
+
let key;
|
|
441
|
+
let icon = null;
|
|
442
|
+
let repeat = false;
|
|
443
|
+
|
|
444
|
+
if( content.length>2 && content[0]=='{' && content[content.length-1]=='}') {
|
|
445
|
+
|
|
446
|
+
let c = parseInt(content.substring(1, content.length - 1), 10 );
|
|
447
|
+
|
|
448
|
+
switch( c ) {
|
|
449
|
+
default:
|
|
450
|
+
case 0:
|
|
451
|
+
{
|
|
452
|
+
content = '';
|
|
453
|
+
cls += ' x4hidden';
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
case 1:
|
|
458
|
+
{
|
|
459
|
+
content = '';
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
case 2:
|
|
464
|
+
{
|
|
465
|
+
repeat = true;
|
|
466
|
+
content = undefined;
|
|
467
|
+
icon = icon_bksp;
|
|
468
|
+
cls += ' cdel';
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
case 3:
|
|
473
|
+
{
|
|
474
|
+
content = _tr.global.keyboard.next;
|
|
475
|
+
cls += ' cret';
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
case 4:
|
|
480
|
+
{
|
|
481
|
+
content = undefined;
|
|
482
|
+
icon = icon_shift;
|
|
483
|
+
cls += ' cshift';
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
case 5:
|
|
488
|
+
{
|
|
489
|
+
content = _tr.global.keyboard.numeric;
|
|
490
|
+
cls += ' cnum';
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
case 6:
|
|
495
|
+
{
|
|
496
|
+
content = '\u00a0';
|
|
497
|
+
cls += ' cspace';
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
case 7:
|
|
502
|
+
{
|
|
503
|
+
content = undefined;
|
|
504
|
+
icon = icon_hide;
|
|
505
|
+
cls += ' chide';
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
case 8:
|
|
510
|
+
{
|
|
511
|
+
content = _tr.global.keyboard.alpha;
|
|
512
|
+
cls += ' calpha';
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
case 9:
|
|
517
|
+
{
|
|
518
|
+
content = '';
|
|
519
|
+
cls += ' cplace';
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
key = c;
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
key = line[i].charCodeAt(0);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
let el = new Button( {
|
|
531
|
+
cls,
|
|
532
|
+
label: content,
|
|
533
|
+
attrs: {'data-key': key},
|
|
534
|
+
icon,
|
|
535
|
+
autorepeat: repeat,
|
|
536
|
+
click: ( e ) => {
|
|
537
|
+
if( e.repeat ) {
|
|
538
|
+
this._handleKey( key )
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
} );
|
|
542
|
+
tl.push( el );
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
result.push( new HBox( { cls: 'line', content: tl } ) );
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return result;
|
|
549
|
+
}
|
|
550
550
|
}
|