@sam-senior/virtual-keyboard 1.0.3 → 2.0.0
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/esm2022/lib/virtual-keyboard.directive.mjs +232 -0
- package/esm2022/lib/virtual-keyboard.module.mjs +16 -0
- package/esm2022/public_api.mjs +6 -0
- package/esm2022/sam-senior-virtual-keyboard.mjs +5 -0
- package/{fesm2015/sam-senior-virtual-keyboard.js → fesm2022/sam-senior-virtual-keyboard.mjs} +240 -332
- package/fesm2022/sam-senior-virtual-keyboard.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/virtual-keyboard.directive.d.ts +37 -33
- package/lib/virtual-keyboard.module.d.ts +7 -2
- package/package.json +18 -14
- package/public_api.d.ts +2 -1
- package/bundles/sam-senior-virtual-keyboard.umd.js +0 -412
- package/bundles/sam-senior-virtual-keyboard.umd.js.map +0 -1
- package/bundles/sam-senior-virtual-keyboard.umd.min.js +0 -2
- package/bundles/sam-senior-virtual-keyboard.umd.min.js.map +0 -1
- package/esm2015/lib/virtual-keyboard.directive.js +0 -368
- package/esm2015/lib/virtual-keyboard.module.js +0 -15
- package/esm2015/public_api.js +0 -9
- package/esm2015/sam-senior-virtual-keyboard.js +0 -10
- package/esm5/lib/virtual-keyboard.directive.js +0 -425
- package/esm5/lib/virtual-keyboard.module.js +0 -19
- package/esm5/public_api.js +0 -9
- package/esm5/sam-senior-virtual-keyboard.js +0 -10
- package/fesm2015/sam-senior-virtual-keyboard.js.map +0 -1
- package/fesm5/sam-senior-virtual-keyboard.js +0 -407
- package/fesm5/sam-senior-virtual-keyboard.js.map +0 -1
- package/sam-senior-virtual-keyboard.d.ts +0 -5
- package/sam-senior-virtual-keyboard.metadata.json +0 -1
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
import { Directive, ElementRef, Optional, Input, Output, EventEmitter, NgModule } from '@angular/core';
|
|
2
|
-
import { NgControl } from '@angular/forms';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview added by tsickle
|
|
6
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* ************************************************************
|
|
10
|
-
* Método que retonar instancia do elemento jQuery, pois
|
|
11
|
-
* o projeto que implementa esta diretiva fica fora da lib.
|
|
12
|
-
* Devido ficar fora, o webpack não ficará aqui, portando não
|
|
13
|
-
* tem jQuery na lib;
|
|
14
|
-
* **************************************************************
|
|
15
|
-
* @type {?}
|
|
16
|
-
*/
|
|
17
|
-
var jQueryInstance = (/**
|
|
18
|
-
* @param {?} element
|
|
19
|
-
* @return {?}
|
|
20
|
-
*/
|
|
21
|
-
function (element) {
|
|
22
|
-
/** @type {?} */
|
|
23
|
-
var windowInstance = (/** @type {?} */ (window));
|
|
24
|
-
return windowInstance.jQuery ? windowInstance.jQuery(element) : null;
|
|
25
|
-
});
|
|
26
|
-
var VirtualKeyboardDirective = /** @class */ (function () {
|
|
27
|
-
function VirtualKeyboardDirective(elementRef, fieldControl) {
|
|
28
|
-
this.elementRef = elementRef;
|
|
29
|
-
this.fieldControl = fieldControl;
|
|
30
|
-
this.keyboardPosition = 'bottom';
|
|
31
|
-
this.keyboardType = 'email';
|
|
32
|
-
this.showOnFocus = true;
|
|
33
|
-
this.keyboardValueAccepted = new EventEmitter();
|
|
34
|
-
this.showKeyboardChange = new EventEmitter();
|
|
35
|
-
this._showKeyboard = false;
|
|
36
|
-
this.value = '';
|
|
37
|
-
}
|
|
38
|
-
Object.defineProperty(VirtualKeyboardDirective.prototype, "activateKeyboard", {
|
|
39
|
-
set: /**
|
|
40
|
-
* @param {?} activateKeyboard
|
|
41
|
-
* @return {?}
|
|
42
|
-
*/
|
|
43
|
-
function (activateKeyboard) {
|
|
44
|
-
if (activateKeyboard) {
|
|
45
|
-
this.keyboardElement = (/** @type {?} */ (this.elementRef.nativeElement));
|
|
46
|
-
this.keyboardjQueryElement = jQueryInstance(this.keyboardElement);
|
|
47
|
-
if (this.keyboardjQueryElement) {
|
|
48
|
-
this.keyboardjQueryElement.keyboard(this.createKeyboardOptions());
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
enumerable: true,
|
|
53
|
-
configurable: true
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(VirtualKeyboardDirective.prototype, "showKeyboard", {
|
|
56
|
-
get: /**
|
|
57
|
-
* @return {?}
|
|
58
|
-
*/
|
|
59
|
-
function () {
|
|
60
|
-
return this._showKeyboard;
|
|
61
|
-
},
|
|
62
|
-
set: /**
|
|
63
|
-
* @param {?} revealKeyboard
|
|
64
|
-
* @return {?}
|
|
65
|
-
*/
|
|
66
|
-
function (revealKeyboard) {
|
|
67
|
-
this._showKeyboard = revealKeyboard;
|
|
68
|
-
this.showKeyboardChange.emit(this._showKeyboard);
|
|
69
|
-
},
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true
|
|
72
|
-
});
|
|
73
|
-
/**
|
|
74
|
-
* @return {?}
|
|
75
|
-
*/
|
|
76
|
-
VirtualKeyboardDirective.prototype.ngOnChanges = /**
|
|
77
|
-
* @return {?}
|
|
78
|
-
*/
|
|
79
|
-
function () {
|
|
80
|
-
if (this.showKeyboard && this.isKeyboardCreated()) {
|
|
81
|
-
this.keyboardjQueryElement.getkeyboard().reveal();
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* @return {?}
|
|
86
|
-
*/
|
|
87
|
-
VirtualKeyboardDirective.prototype.ngOnDestroy = /**
|
|
88
|
-
* @return {?}
|
|
89
|
-
*/
|
|
90
|
-
function () {
|
|
91
|
-
if (this.isKeyboardCreated()) {
|
|
92
|
-
this.keyboardjQueryElement
|
|
93
|
-
.keyboard()
|
|
94
|
-
.getkeyboard()
|
|
95
|
-
.destroy();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* @private
|
|
100
|
-
* @return {?}
|
|
101
|
-
*/
|
|
102
|
-
VirtualKeyboardDirective.prototype.isKeyboardCreated = /**
|
|
103
|
-
* @private
|
|
104
|
-
* @return {?}
|
|
105
|
-
*/
|
|
106
|
-
function () {
|
|
107
|
-
return (this.keyboardjQueryElement &&
|
|
108
|
-
this.keyboardjQueryElement.keyboard() &&
|
|
109
|
-
this.keyboardjQueryElement.keyboard().getkeyboard());
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* @private
|
|
113
|
-
* @return {?}
|
|
114
|
-
*/
|
|
115
|
-
VirtualKeyboardDirective.prototype.getDefaultKeyboardOptions = /**
|
|
116
|
-
* @private
|
|
117
|
-
* @return {?}
|
|
118
|
-
*/
|
|
119
|
-
function () {
|
|
120
|
-
/** @type {?} */
|
|
121
|
-
var keyboardOptions = (/** @type {?} */ ({}));
|
|
122
|
-
if (!this.showOnFocus) {
|
|
123
|
-
keyboardOptions.openOn = '';
|
|
124
|
-
}
|
|
125
|
-
keyboardOptions.usePreview = false;
|
|
126
|
-
keyboardOptions.accepted = this.onValueAccepted.bind(this);
|
|
127
|
-
keyboardOptions.visible = this.onKeyboardVisible.bind(this);
|
|
128
|
-
keyboardOptions.beforeClose = this.onBeforeClose.bind(this);
|
|
129
|
-
keyboardOptions.change = this.onChange.bind(this);
|
|
130
|
-
return keyboardOptions;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* @private
|
|
134
|
-
* @return {?}
|
|
135
|
-
*/
|
|
136
|
-
VirtualKeyboardDirective.prototype.getKeyboardDisplayOptions = /**
|
|
137
|
-
* @private
|
|
138
|
-
* @return {?}
|
|
139
|
-
*/
|
|
140
|
-
function () {
|
|
141
|
-
return {
|
|
142
|
-
bksp: '\u2190',
|
|
143
|
-
normal: 'ABC',
|
|
144
|
-
meta1: '%?@',
|
|
145
|
-
meta2: '#+=',
|
|
146
|
-
accept: 'OK'
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* @private
|
|
151
|
-
* @return {?}
|
|
152
|
-
*/
|
|
153
|
-
VirtualKeyboardDirective.prototype.getKeyboardLayout = /**
|
|
154
|
-
* @private
|
|
155
|
-
* @return {?}
|
|
156
|
-
*/
|
|
157
|
-
function () {
|
|
158
|
-
/** @type {?} */
|
|
159
|
-
var customLayout = {};
|
|
160
|
-
if (this.keyboardType === 'alphanumeric') {
|
|
161
|
-
customLayout = {
|
|
162
|
-
normal: [
|
|
163
|
-
'1 2 3 4 5 6 7 8 9 0',
|
|
164
|
-
'Q W E R T Y U I O P {bksp}',
|
|
165
|
-
'A S D F G H J K L Ç',
|
|
166
|
-
'Z X C V B N M {accept}'
|
|
167
|
-
]
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
else if (this.keyboardType === 'email') {
|
|
171
|
-
customLayout = this.getCustomKeyboardForEmail();
|
|
172
|
-
}
|
|
173
|
-
return customLayout;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* @private
|
|
177
|
-
* @return {?}
|
|
178
|
-
*/
|
|
179
|
-
VirtualKeyboardDirective.prototype.getCustomKeyboardForEmail = /**
|
|
180
|
-
* @private
|
|
181
|
-
* @return {?}
|
|
182
|
-
*/
|
|
183
|
-
function () {
|
|
184
|
-
return {
|
|
185
|
-
normal: [
|
|
186
|
-
'1 2 3 4 5 6 7 8 9 0',
|
|
187
|
-
'q w e r t y u i o p {bksp}',
|
|
188
|
-
'a s d f g h j k l ç',
|
|
189
|
-
'{s} z x c v b n m .',
|
|
190
|
-
'{meta1} {space} _ - {accept}'
|
|
191
|
-
],
|
|
192
|
-
shift: [
|
|
193
|
-
'1 2 3 4 5 6 7 8 9 0',
|
|
194
|
-
'Q W E R T Y U I O P {bksp}',
|
|
195
|
-
'A S D F G H J K L Ç',
|
|
196
|
-
'{s} Z X C V B N M .',
|
|
197
|
-
'{meta1} {space} _ - {accept}'
|
|
198
|
-
],
|
|
199
|
-
meta1: [
|
|
200
|
-
"` | { } % ^ * / ' {bksp}",
|
|
201
|
-
'{meta2} $ & ~ # = + @',
|
|
202
|
-
'{normal} {space} ! ? {accept}'
|
|
203
|
-
],
|
|
204
|
-
meta2: [
|
|
205
|
-
'[ ] { } \u2039 \u203a ^ * " , {bksp}',
|
|
206
|
-
'\\ | / < > $ \u00a3 \u00a5 \u2022',
|
|
207
|
-
'{meta1} \u20ac & ~ # = + .',
|
|
208
|
-
'{normal} {space} ! ? {accept}'
|
|
209
|
-
]
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* @private
|
|
214
|
-
* @return {?}
|
|
215
|
-
*/
|
|
216
|
-
VirtualKeyboardDirective.prototype.createKeyboardOptions = /**
|
|
217
|
-
* @private
|
|
218
|
-
* @return {?}
|
|
219
|
-
*/
|
|
220
|
-
function () {
|
|
221
|
-
/** @type {?} */
|
|
222
|
-
var keyboardOptions = this.getDefaultKeyboardOptions();
|
|
223
|
-
if (this.keyboardPosition !== 'relative') {
|
|
224
|
-
keyboardOptions.position = false;
|
|
225
|
-
}
|
|
226
|
-
if (this.keyboardPosition === 'bottom') {
|
|
227
|
-
this.addBottomKeyboardClass();
|
|
228
|
-
}
|
|
229
|
-
keyboardOptions.css = {
|
|
230
|
-
buttonDefault: 'keyboard-button-override'
|
|
231
|
-
};
|
|
232
|
-
keyboardOptions.display = this.getKeyboardDisplayOptions();
|
|
233
|
-
keyboardOptions.layout = 'custom';
|
|
234
|
-
keyboardOptions.customLayout = this.getKeyboardLayout();
|
|
235
|
-
return keyboardOptions;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* @private
|
|
239
|
-
* @return {?}
|
|
240
|
-
*/
|
|
241
|
-
VirtualKeyboardDirective.prototype.onKeyboardVisible = /**
|
|
242
|
-
* @private
|
|
243
|
-
* @return {?}
|
|
244
|
-
*/
|
|
245
|
-
function () {
|
|
246
|
-
this.addCustomKeyboardFocusClass();
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* @private
|
|
250
|
-
* @return {?}
|
|
251
|
-
*/
|
|
252
|
-
VirtualKeyboardDirective.prototype.onBeforeClose = /**
|
|
253
|
-
* @private
|
|
254
|
-
* @return {?}
|
|
255
|
-
*/
|
|
256
|
-
function () {
|
|
257
|
-
// O elemente do jQuery limpa tudo o que não passou pelo accept
|
|
258
|
-
// Necessário setar o valor quando somente fechado a modal.
|
|
259
|
-
/** @type {?} */
|
|
260
|
-
var formControl = this.fieldControl.control;
|
|
261
|
-
formControl.setValue(this.value);
|
|
262
|
-
this.showKeyboard = false;
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* @private
|
|
266
|
-
* @return {?}
|
|
267
|
-
*/
|
|
268
|
-
VirtualKeyboardDirective.prototype.onValueAccepted = /**
|
|
269
|
-
* @private
|
|
270
|
-
* @return {?}
|
|
271
|
-
*/
|
|
272
|
-
function () {
|
|
273
|
-
/** @type {?} */
|
|
274
|
-
var casted = (/** @type {?} */ (this.keyboardElement));
|
|
275
|
-
this.keyboardValueAccepted.emit(casted.value);
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* @private
|
|
279
|
-
* @param {?} event
|
|
280
|
-
* @return {?}
|
|
281
|
-
*/
|
|
282
|
-
VirtualKeyboardDirective.prototype.onChange = /**
|
|
283
|
-
* @private
|
|
284
|
-
* @param {?} event
|
|
285
|
-
* @return {?}
|
|
286
|
-
*/
|
|
287
|
-
function (event) {
|
|
288
|
-
/** @type {?} */
|
|
289
|
-
var virtualkeyboardevent = new CustomEvent('virtualkeyboardevent', event);
|
|
290
|
-
document.dispatchEvent(virtualkeyboardevent);
|
|
291
|
-
if (this.keyboardElement instanceof HTMLInputElement) {
|
|
292
|
-
/** @type {?} */
|
|
293
|
-
var keyboardElement_1 = (/** @type {?} */ (this.keyboardElement));
|
|
294
|
-
// Arquivo possui referecia do jQuery que é alterado ao fechar o teclado.
|
|
295
|
-
// Necessário clonar a string.
|
|
296
|
-
/** @type {?} */
|
|
297
|
-
var inputVal_1 = JSON.stringify(keyboardElement_1.value).replace('"', '').replace('"', '');
|
|
298
|
-
if (this.fieldControl) {
|
|
299
|
-
/** @type {?} */
|
|
300
|
-
var formControl = this.fieldControl.control;
|
|
301
|
-
this.value = inputVal_1;
|
|
302
|
-
formControl.setValue(inputVal_1);
|
|
303
|
-
formControl.markAsDirty();
|
|
304
|
-
formControl.updateValueAndValidity();
|
|
305
|
-
}
|
|
306
|
-
// Este setTimeout é necessário para fazer com que o
|
|
307
|
-
// cursor do input sempre esteja no final da string digitada
|
|
308
|
-
// e o final da string sempre esteja visivel.
|
|
309
|
-
setTimeout((/**
|
|
310
|
-
* @return {?}
|
|
311
|
-
*/
|
|
312
|
-
function () {
|
|
313
|
-
keyboardElement_1.value = inputVal_1;
|
|
314
|
-
keyboardElement_1.scrollLeft = keyboardElement_1.scrollWidth;
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
/**
|
|
319
|
-
* @private
|
|
320
|
-
* @return {?}
|
|
321
|
-
*/
|
|
322
|
-
VirtualKeyboardDirective.prototype.addBottomKeyboardClass = /**
|
|
323
|
-
* @private
|
|
324
|
-
* @return {?}
|
|
325
|
-
*/
|
|
326
|
-
function () {
|
|
327
|
-
this.injectCssRule(".ui-keyboard {\n border-radius: 0;\n left: 0;\n top: auto;\n bottom: 0;\n position: fixed;\n width: 100%;\n }");
|
|
328
|
-
};
|
|
329
|
-
/**
|
|
330
|
-
* @private
|
|
331
|
-
* @return {?}
|
|
332
|
-
*/
|
|
333
|
-
VirtualKeyboardDirective.prototype.addCustomKeyboardFocusClass = /**
|
|
334
|
-
* @private
|
|
335
|
-
* @return {?}
|
|
336
|
-
*/
|
|
337
|
-
function () {
|
|
338
|
-
this.injectCssRule(".ui-keyboard-has-focus {\n z-index: 900;\n }");
|
|
339
|
-
};
|
|
340
|
-
/**
|
|
341
|
-
* @private
|
|
342
|
-
* @param {?} rule
|
|
343
|
-
* @return {?}
|
|
344
|
-
*/
|
|
345
|
-
VirtualKeyboardDirective.prototype.injectCssRule = /**
|
|
346
|
-
* @private
|
|
347
|
-
* @param {?} rule
|
|
348
|
-
* @return {?}
|
|
349
|
-
*/
|
|
350
|
-
function (rule) {
|
|
351
|
-
/** @type {?} */
|
|
352
|
-
var style = (/** @type {?} */ (document.createElement('style')));
|
|
353
|
-
style.appendChild(document.createTextNode(''));
|
|
354
|
-
document.head.appendChild(style);
|
|
355
|
-
style.sheet.insertRule(rule);
|
|
356
|
-
};
|
|
357
|
-
VirtualKeyboardDirective.decorators = [
|
|
358
|
-
{ type: Directive, args: [{
|
|
359
|
-
selector: '[samVirtualKeyboard]'
|
|
360
|
-
},] }
|
|
361
|
-
];
|
|
362
|
-
/** @nocollapse */
|
|
363
|
-
VirtualKeyboardDirective.ctorParameters = function () { return [
|
|
364
|
-
{ type: ElementRef },
|
|
365
|
-
{ type: NgControl, decorators: [{ type: Optional }] }
|
|
366
|
-
]; };
|
|
367
|
-
VirtualKeyboardDirective.propDecorators = {
|
|
368
|
-
keyboardPosition: [{ type: Input }],
|
|
369
|
-
keyboardType: [{ type: Input }],
|
|
370
|
-
activateKeyboard: [{ type: Input }],
|
|
371
|
-
showOnFocus: [{ type: Input }],
|
|
372
|
-
showKeyboard: [{ type: Input }],
|
|
373
|
-
keyboardValueAccepted: [{ type: Output }],
|
|
374
|
-
showKeyboardChange: [{ type: Output }]
|
|
375
|
-
};
|
|
376
|
-
return VirtualKeyboardDirective;
|
|
377
|
-
}());
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* @fileoverview added by tsickle
|
|
381
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
382
|
-
*/
|
|
383
|
-
var VirtualKeyboardModule = /** @class */ (function () {
|
|
384
|
-
function VirtualKeyboardModule() {
|
|
385
|
-
}
|
|
386
|
-
VirtualKeyboardModule.decorators = [
|
|
387
|
-
{ type: NgModule, args: [{
|
|
388
|
-
declarations: [VirtualKeyboardDirective],
|
|
389
|
-
exports: [VirtualKeyboardDirective]
|
|
390
|
-
},] }
|
|
391
|
-
];
|
|
392
|
-
return VirtualKeyboardModule;
|
|
393
|
-
}());
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* @fileoverview added by tsickle
|
|
397
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
398
|
-
*/
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* @fileoverview added by tsickle
|
|
402
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
403
|
-
*/
|
|
404
|
-
|
|
405
|
-
export { VirtualKeyboardModule, VirtualKeyboardDirective as ɵa };
|
|
406
|
-
|
|
407
|
-
//# sourceMappingURL=sam-senior-virtual-keyboard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sam-senior-virtual-keyboard.js.map","sources":["ng://@sam-senior/virtual-keyboard/lib/virtual-keyboard.directive.ts","ng://@sam-senior/virtual-keyboard/lib/virtual-keyboard.module.ts"],"sourcesContent":["import { Directive, OnDestroy, OnChanges, ElementRef, Optional, Input, Output, EventEmitter } from '@angular/core';\r\nimport { NgControl } from '@angular/forms';\r\n\r\nimport { KeyboardOptions } from '../../node_modules/virtual-keyboard';\r\n\r\n/***************************************************************\r\n* Método que retonar instancia do elemento jQuery, pois\r\n* o projeto que implementa esta diretiva fica fora da lib.\r\n* Devido ficar fora, o webpack não ficará aqui, portando não\r\n* tem jQuery na lib;\r\n****************************************************************/\r\nconst jQueryInstance = (element) => {\r\n const windowInstance = window as any;\r\n return windowInstance.jQuery ? windowInstance.jQuery(element) : null;\r\n};\r\n\r\n@Directive({\r\n selector: '[samVirtualKeyboard]'\r\n})\r\nexport class VirtualKeyboardDirective\r\n implements OnDestroy, OnChanges {\r\n\r\n @Input() private keyboardPosition: 'relative' | 'bottom' = 'bottom';\r\n @Input() private keyboardType: 'email' | 'alphanumeric' = 'email';\r\n @Input() public set activateKeyboard(activateKeyboard: boolean) {\r\n if (activateKeyboard) {\r\n this.keyboardElement = this.elementRef.nativeElement as HTMLElement;\r\n this.keyboardjQueryElement = jQueryInstance(this.keyboardElement);\r\n if (this.keyboardjQueryElement) {\r\n this.keyboardjQueryElement.keyboard(this.createKeyboardOptions());\r\n }\r\n }\r\n }\r\n @Input() private showOnFocus = true;\r\n @Input()\r\n public get showKeyboard(): boolean {\r\n return this._showKeyboard;\r\n }\r\n public set showKeyboard(revealKeyboard: boolean) {\r\n this._showKeyboard = revealKeyboard;\r\n this.showKeyboardChange.emit(this._showKeyboard);\r\n }\r\n\r\n @Output() private keyboardValueAccepted = new EventEmitter();\r\n @Output() public showKeyboardChange = new EventEmitter<boolean>();\r\n\r\n public _showKeyboard = false;\r\n private keyboardElement: HTMLElement;\r\n private value = '';\r\n\r\n // Any devido a ser referência do jQuery;\r\n private keyboardjQueryElement: any;\r\n\r\n constructor(\r\n public elementRef: ElementRef,\r\n @Optional() public fieldControl: NgControl\r\n ) { }\r\n\r\n ngOnChanges() {\r\n if (this.showKeyboard && this.isKeyboardCreated()) {\r\n this.keyboardjQueryElement.getkeyboard().reveal();\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n if (this.isKeyboardCreated()) {\r\n this.keyboardjQueryElement\r\n .keyboard()\r\n .getkeyboard()\r\n .destroy();\r\n }\r\n }\r\n\r\n private isKeyboardCreated(): boolean {\r\n return (\r\n this.keyboardjQueryElement &&\r\n this.keyboardjQueryElement.keyboard() &&\r\n this.keyboardjQueryElement.keyboard().getkeyboard()\r\n );\r\n }\r\n\r\n private getDefaultKeyboardOptions() {\r\n const keyboardOptions = {} as KeyboardOptions;\r\n if (!this.showOnFocus) {\r\n keyboardOptions.openOn = '';\r\n }\r\n keyboardOptions.usePreview = false;\r\n keyboardOptions.accepted = this.onValueAccepted.bind(this);\r\n keyboardOptions.visible = this.onKeyboardVisible.bind(this);\r\n keyboardOptions.beforeClose = this.onBeforeClose.bind(this);\r\n keyboardOptions.change = this.onChange.bind(this);\r\n return keyboardOptions;\r\n }\r\n\r\n private getKeyboardDisplayOptions() {\r\n return {\r\n bksp: '\\u2190',\r\n normal: 'ABC',\r\n meta1: '%?@',\r\n meta2: '#+=',\r\n accept: 'OK'\r\n };\r\n }\r\n\r\n private getKeyboardLayout() {\r\n let customLayout = {};\r\n if (this.keyboardType === 'alphanumeric') {\r\n customLayout = {\r\n normal: [\r\n '1 2 3 4 5 6 7 8 9 0',\r\n 'Q W E R T Y U I O P {bksp}',\r\n 'A S D F G H J K L Ã',\r\n 'Z X C V B N M {accept}'\r\n ]\r\n };\r\n } else if (this.keyboardType === 'email') {\r\n customLayout = this.getCustomKeyboardForEmail();\r\n }\r\n return customLayout;\r\n }\r\n\r\n private getCustomKeyboardForEmail() {\r\n return {\r\n normal: [\r\n '1 2 3 4 5 6 7 8 9 0',\r\n 'q w e r t y u i o p {bksp}',\r\n 'a s d f g h j k l ç',\r\n '{s} z x c v b n m .',\r\n '{meta1} {space} _ - {accept}'\r\n ],\r\n shift: [\r\n '1 2 3 4 5 6 7 8 9 0',\r\n 'Q W E R T Y U I O P {bksp}',\r\n 'A S D F G H J K L Ã',\r\n '{s} Z X C V B N M .',\r\n '{meta1} {space} _ - {accept}'\r\n ],\r\n meta1: [\r\n \"` | { } % ^ * / ' {bksp}\",\r\n '{meta2} $ & ~ # = + @',\r\n '{normal} {space} ! ? {accept}'\r\n ],\r\n meta2: [\r\n '[ ] { } \\u2039 \\u203a ^ * \" , {bksp}',\r\n '\\\\ | / < > $ \\u00a3 \\u00a5 \\u2022',\r\n '{meta1} \\u20ac & ~ # = + .',\r\n '{normal} {space} ! ? {accept}'\r\n ]\r\n };\r\n }\r\n\r\n private createKeyboardOptions(): KeyboardOptions {\r\n const keyboardOptions = this.getDefaultKeyboardOptions();\r\n if (this.keyboardPosition !== 'relative') {\r\n keyboardOptions.position = false;\r\n }\r\n if (this.keyboardPosition === 'bottom') {\r\n this.addBottomKeyboardClass();\r\n }\r\n keyboardOptions.css = {\r\n buttonDefault: 'keyboard-button-override'\r\n };\r\n\r\n keyboardOptions.display = this.getKeyboardDisplayOptions();\r\n keyboardOptions.layout = 'custom';\r\n keyboardOptions.customLayout = this.getKeyboardLayout();\r\n\r\n return keyboardOptions;\r\n }\r\n\r\n private onKeyboardVisible() {\r\n this.addCustomKeyboardFocusClass();\r\n }\r\n\r\n private onBeforeClose() {\r\n // O elemente do jQuery limpa tudo o que não passou pelo accept\r\n // Necessário setar o valor quando somente fechado a modal.\r\n const formControl = this.fieldControl.control;\r\n formControl.setValue(this.value);\r\n this.showKeyboard = false;\r\n }\r\n\r\n private onValueAccepted() {\r\n const casted = this.keyboardElement as any;\r\n this.keyboardValueAccepted.emit(casted.value);\r\n }\r\n\r\n private onChange(event) {\r\n const virtualkeyboardevent = new CustomEvent('virtualkeyboardevent', event);\r\n document.dispatchEvent(virtualkeyboardevent);\r\n if (this.keyboardElement instanceof HTMLInputElement) {\r\n const keyboardElement = this.keyboardElement as HTMLInputElement;\r\n // Arquivo possui referecia do jQuery que é alterado ao fechar o teclado.\r\n // Necessário clonar a string.\r\n const inputVal = JSON.stringify(keyboardElement.value).replace('\"', '').replace('\"', '');\r\n if (this.fieldControl) {\r\n const formControl = this.fieldControl.control;\r\n this.value = inputVal;\r\n formControl.setValue(inputVal);\r\n formControl.markAsDirty();\r\n formControl.updateValueAndValidity();\r\n }\r\n // Este setTimeout é necessário para fazer com que o\r\n // cursor do input sempre esteja no final da string digitada\r\n // e o final da string sempre esteja visivel.\r\n setTimeout(() => {\r\n keyboardElement.value = inputVal;\r\n keyboardElement.scrollLeft = keyboardElement.scrollWidth;\r\n });\r\n }\r\n }\r\n\r\n private addBottomKeyboardClass() {\r\n this.injectCssRule(\r\n `.ui-keyboard {\r\n border-radius: 0;\r\n left: 0;\r\n top: auto;\r\n bottom: 0;\r\n position: fixed;\r\n width: 100%;\r\n }`\r\n );\r\n }\r\n\r\n private addCustomKeyboardFocusClass() {\r\n this.injectCssRule(\r\n `.ui-keyboard-has-focus {\r\n z-index: 900;\r\n }`\r\n );\r\n }\r\n\r\n private injectCssRule(rule) {\r\n const style = document.createElement('style') as any;\r\n style.appendChild(document.createTextNode(''));\r\n document.head.appendChild(style);\r\n style.sheet.insertRule(rule);\r\n }\r\n}\r\n\r\n","import { NgModule } from '@angular/core';\r\nimport { VirtualKeyboardDirective } from './virtual-keyboard.directive';\r\n\r\n@NgModule({\r\n declarations: [VirtualKeyboardDirective],\r\n exports: [VirtualKeyboardDirective]\r\n})\r\nexport class VirtualKeyboardModule { }\r\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;IAWM,cAAc;;;;AAAG,UAAC,OAAO;;QACvB,cAAc,sBAAG,MAAM,EAAO;IACpC,OAAO,cAAc,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CACtE,CAAA;;IAuCC,kCACS,UAAsB,EACV,YAAuB;QADnC,eAAU,GAAV,UAAU,CAAY;QACV,iBAAY,GAAZ,YAAY,CAAW;QAjC3B,qBAAgB,GAA0B,QAAQ,CAAC;QACnD,iBAAY,GAA6B,OAAO,CAAC;QAUjD,gBAAW,GAAG,IAAI,CAAC;QAUlB,0BAAqB,GAAG,IAAI,YAAY,EAAE,CAAC;QAC5C,uBAAkB,GAAG,IAAI,YAAY,EAAW,CAAC;QAE3D,kBAAa,GAAG,KAAK,CAAC;QAErB,UAAK,GAAG,EAAE,CAAC;KAQd;IAhCL,sBAAoB,sDAAgB;;;;;QAApC,UAAqC,gBAAyB;YAC5D,IAAI,gBAAgB,EAAE;gBACpB,IAAI,CAAC,eAAe,sBAAG,IAAI,CAAC,UAAU,CAAC,aAAa,EAAe,CAAC;gBACpE,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,qBAAqB,EAAE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Q,SAAC;oBACR,YAAY,EAAE,CAAC,wBAAwB,CAAC;oBACxC,OAAO,EAAE,CAAC,wBAAwB,CAAC;iBACpC;;IACoC,4BAAC;CAJtC;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"metadata":{"VirtualKeyboardModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"exports":[{"__symbolic":"reference","name":"ɵa"}]}]}],"members":{}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":16,"character":1},"arguments":[{"selector":"[samVirtualKeyboard]"}]}],"members":{"keyboardPosition":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":22,"character":3}}]}],"keyboardType":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":23,"character":3}}]}],"activateKeyboard":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":24,"character":3}}]}],"showOnFocus":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":33,"character":3}}]}],"showKeyboard":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":34,"character":3}}]}],"keyboardValueAccepted":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":43,"character":3}}]}],"showKeyboardChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":44,"character":3}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":55,"character":5}}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":54,"character":23},{"__symbolic":"reference","module":"@angular/forms","name":"NgControl","line":55,"character":37}]}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"isKeyboardCreated":[{"__symbolic":"method"}],"getDefaultKeyboardOptions":[{"__symbolic":"method"}],"getKeyboardDisplayOptions":[{"__symbolic":"method"}],"getKeyboardLayout":[{"__symbolic":"method"}],"getCustomKeyboardForEmail":[{"__symbolic":"method"}],"createKeyboardOptions":[{"__symbolic":"method"}],"onKeyboardVisible":[{"__symbolic":"method"}],"onBeforeClose":[{"__symbolic":"method"}],"onValueAccepted":[{"__symbolic":"method"}],"onChange":[{"__symbolic":"method"}],"addBottomKeyboardClass":[{"__symbolic":"method"}],"addCustomKeyboardFocusClass":[{"__symbolic":"method"}],"injectCssRule":[{"__symbolic":"method"}]}}},"origins":{"VirtualKeyboardModule":"./lib/virtual-keyboard.module","ɵa":"./lib/virtual-keyboard.directive"},"importAs":"@sam-senior/virtual-keyboard"}
|