@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.
@@ -1,33 +1,37 @@
1
- import { OnDestroy, OnChanges, ElementRef, EventEmitter } from '@angular/core';
2
- import { NgControl } from '@angular/forms';
3
- export declare class VirtualKeyboardDirective implements OnDestroy, OnChanges {
4
- elementRef: ElementRef;
5
- fieldControl: NgControl;
6
- private keyboardPosition;
7
- private keyboardType;
8
- activateKeyboard: boolean;
9
- private showOnFocus;
10
- showKeyboard: boolean;
11
- private keyboardValueAccepted;
12
- showKeyboardChange: EventEmitter<boolean>;
13
- _showKeyboard: boolean;
14
- private keyboardElement;
15
- private value;
16
- private keyboardjQueryElement;
17
- constructor(elementRef: ElementRef, fieldControl: NgControl);
18
- ngOnChanges(): void;
19
- ngOnDestroy(): void;
20
- private isKeyboardCreated;
21
- private getDefaultKeyboardOptions;
22
- private getKeyboardDisplayOptions;
23
- private getKeyboardLayout;
24
- private getCustomKeyboardForEmail;
25
- private createKeyboardOptions;
26
- private onKeyboardVisible;
27
- private onBeforeClose;
28
- private onValueAccepted;
29
- private onChange;
30
- private addBottomKeyboardClass;
31
- private addCustomKeyboardFocusClass;
32
- private injectCssRule;
33
- }
1
+ import { OnDestroy, OnChanges, ElementRef, EventEmitter } from '@angular/core';
2
+ import { NgControl } from '@angular/forms';
3
+ import * as i0 from "@angular/core";
4
+ export declare class VirtualKeyboardDirective implements OnDestroy, OnChanges {
5
+ elementRef: ElementRef;
6
+ fieldControl: NgControl;
7
+ private keyboardPosition;
8
+ private keyboardType;
9
+ set activateKeyboard(activateKeyboard: boolean);
10
+ private showOnFocus;
11
+ get showKeyboard(): boolean;
12
+ set showKeyboard(revealKeyboard: boolean);
13
+ private keyboardValueAccepted;
14
+ showKeyboardChange: EventEmitter<boolean>;
15
+ _showKeyboard: boolean;
16
+ private keyboardElement;
17
+ private value;
18
+ private keyboardjQueryElement;
19
+ constructor(elementRef: ElementRef, fieldControl: NgControl);
20
+ ngOnChanges(): void;
21
+ ngOnDestroy(): void;
22
+ private isKeyboardCreated;
23
+ private getDefaultKeyboardOptions;
24
+ private getKeyboardDisplayOptions;
25
+ private getKeyboardLayout;
26
+ private getCustomKeyboardForEmail;
27
+ private createKeyboardOptions;
28
+ private onKeyboardVisible;
29
+ private onBeforeClose;
30
+ private onValueAccepted;
31
+ private onChange;
32
+ private addBottomKeyboardClass;
33
+ private addCustomKeyboardFocusClass;
34
+ private injectCssRule;
35
+ static ɵfac: i0.ɵɵFactoryDeclaration<VirtualKeyboardDirective, [null, { optional: true; }]>;
36
+ static ɵdir: i0.ɵɵDirectiveDeclaration<VirtualKeyboardDirective, "[samVirtualKeyboard]", never, { "keyboardPosition": { "alias": "keyboardPosition"; "required": false; }; "keyboardType": { "alias": "keyboardType"; "required": false; }; "activateKeyboard": { "alias": "activateKeyboard"; "required": false; }; "showOnFocus": { "alias": "showOnFocus"; "required": false; }; "showKeyboard": { "alias": "showKeyboard"; "required": false; }; }, { "keyboardValueAccepted": "keyboardValueAccepted"; "showKeyboardChange": "showKeyboardChange"; }, never, never, false, never>;
37
+ }
@@ -1,2 +1,7 @@
1
- export declare class VirtualKeyboardModule {
2
- }
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./virtual-keyboard.directive";
3
+ export declare class VirtualKeyboardModule {
4
+ static ɵfac: i0.ɵɵFactoryDeclaration<VirtualKeyboardModule, never>;
5
+ static ɵmod: i0.ɵɵNgModuleDeclaration<VirtualKeyboardModule, [typeof i1.VirtualKeyboardDirective], never, [typeof i1.VirtualKeyboardDirective]>;
6
+ static ɵinj: i0.ɵɵInjectorDeclaration<VirtualKeyboardModule>;
7
+ }
package/package.json CHANGED
@@ -1,22 +1,26 @@
1
1
  {
2
2
  "name": "@sam-senior/virtual-keyboard",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "peerDependencies": {
5
- "@angular/common": "^7.2.0",
6
- "@angular/core": "^7.2.0"
5
+ "@angular/common": "^18.0.0",
6
+ "@angular/core": "^18.0.0"
7
7
  },
8
8
  "dependencies": {
9
9
  "virtual-keyboard": "^1.28.1",
10
- "tslib": "^1.9.0"
10
+ "tslib": "^2.3.0"
11
+ },
12
+ "module": "fesm2022/sam-senior-virtual-keyboard.mjs",
13
+ "typings": "index.d.ts",
14
+ "exports": {
15
+ "./package.json": {
16
+ "default": "./package.json"
17
+ },
18
+ ".": {
19
+ "types": "./index.d.ts",
20
+ "esm2022": "./esm2022/sam-senior-virtual-keyboard.mjs",
21
+ "esm": "./esm2022/sam-senior-virtual-keyboard.mjs",
22
+ "default": "./fesm2022/sam-senior-virtual-keyboard.mjs"
23
+ }
11
24
  },
12
- "main": "bundles/sam-senior-virtual-keyboard.umd.js",
13
- "module": "fesm5/sam-senior-virtual-keyboard.js",
14
- "es2015": "fesm2015/sam-senior-virtual-keyboard.js",
15
- "esm5": "esm5/sam-senior-virtual-keyboard.js",
16
- "esm2015": "esm2015/sam-senior-virtual-keyboard.js",
17
- "fesm5": "fesm5/sam-senior-virtual-keyboard.js",
18
- "fesm2015": "fesm2015/sam-senior-virtual-keyboard.js",
19
- "typings": "sam-senior-virtual-keyboard.d.ts",
20
- "metadata": "sam-senior-virtual-keyboard.metadata.json",
21
25
  "sideEffects": false
22
- }
26
+ }
package/public_api.d.ts CHANGED
@@ -1 +1,2 @@
1
- export * from './lib/virtual-keyboard.module';
1
+ export * from './lib/virtual-keyboard.directive';
2
+ export * from './lib/virtual-keyboard.module';
@@ -1,412 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms')) :
3
- typeof define === 'function' && define.amd ? define('@sam-senior/virtual-keyboard', ['exports', '@angular/core', '@angular/forms'], factory) :
4
- (factory((global['sam-senior'] = global['sam-senior'] || {}, global['sam-senior']['virtual-keyboard'] = {}),global.ng.core,global.ng.forms));
5
- }(this, (function (exports,core,forms) { 'use strict';
6
-
7
- /**
8
- * @fileoverview added by tsickle
9
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
10
- */
11
- /**
12
- * ************************************************************
13
- * Método que retonar instancia do elemento jQuery, pois
14
- * o projeto que implementa esta diretiva fica fora da lib.
15
- * Devido ficar fora, o webpack não ficará aqui, portando não
16
- * tem jQuery na lib;
17
- * **************************************************************
18
- * @type {?}
19
- */
20
- var jQueryInstance = ( /**
21
- * @param {?} element
22
- * @return {?}
23
- */function (element) {
24
- /** @type {?} */
25
- var windowInstance = ( /** @type {?} */(window));
26
- return windowInstance.jQuery ? windowInstance.jQuery(element) : null;
27
- });
28
- var VirtualKeyboardDirective = /** @class */ (function () {
29
- function VirtualKeyboardDirective(elementRef, fieldControl) {
30
- this.elementRef = elementRef;
31
- this.fieldControl = fieldControl;
32
- this.keyboardPosition = 'bottom';
33
- this.keyboardType = 'email';
34
- this.showOnFocus = true;
35
- this.keyboardValueAccepted = new core.EventEmitter();
36
- this.showKeyboardChange = new core.EventEmitter();
37
- this._showKeyboard = false;
38
- this.value = '';
39
- }
40
- Object.defineProperty(VirtualKeyboardDirective.prototype, "activateKeyboard", {
41
- set: /**
42
- * @param {?} activateKeyboard
43
- * @return {?}
44
- */ function (activateKeyboard) {
45
- if (activateKeyboard) {
46
- this.keyboardElement = ( /** @type {?} */(this.elementRef.nativeElement));
47
- this.keyboardjQueryElement = jQueryInstance(this.keyboardElement);
48
- if (this.keyboardjQueryElement) {
49
- this.keyboardjQueryElement.keyboard(this.createKeyboardOptions());
50
- }
51
- }
52
- },
53
- enumerable: true,
54
- configurable: true
55
- });
56
- Object.defineProperty(VirtualKeyboardDirective.prototype, "showKeyboard", {
57
- get: /**
58
- * @return {?}
59
- */ function () {
60
- return this._showKeyboard;
61
- },
62
- set: /**
63
- * @param {?} revealKeyboard
64
- * @return {?}
65
- */ function (revealKeyboard) {
66
- this._showKeyboard = revealKeyboard;
67
- this.showKeyboardChange.emit(this._showKeyboard);
68
- },
69
- enumerable: true,
70
- configurable: true
71
- });
72
- /**
73
- * @return {?}
74
- */
75
- VirtualKeyboardDirective.prototype.ngOnChanges = /**
76
- * @return {?}
77
- */
78
- function () {
79
- if (this.showKeyboard && this.isKeyboardCreated()) {
80
- this.keyboardjQueryElement.getkeyboard().reveal();
81
- }
82
- };
83
- /**
84
- * @return {?}
85
- */
86
- VirtualKeyboardDirective.prototype.ngOnDestroy = /**
87
- * @return {?}
88
- */
89
- function () {
90
- if (this.isKeyboardCreated()) {
91
- this.keyboardjQueryElement
92
- .keyboard()
93
- .getkeyboard()
94
- .destroy();
95
- }
96
- };
97
- /**
98
- * @private
99
- * @return {?}
100
- */
101
- VirtualKeyboardDirective.prototype.isKeyboardCreated = /**
102
- * @private
103
- * @return {?}
104
- */
105
- function () {
106
- return (this.keyboardjQueryElement &&
107
- this.keyboardjQueryElement.keyboard() &&
108
- this.keyboardjQueryElement.keyboard().getkeyboard());
109
- };
110
- /**
111
- * @private
112
- * @return {?}
113
- */
114
- VirtualKeyboardDirective.prototype.getDefaultKeyboardOptions = /**
115
- * @private
116
- * @return {?}
117
- */
118
- function () {
119
- /** @type {?} */
120
- var keyboardOptions = ( /** @type {?} */({}));
121
- if (!this.showOnFocus) {
122
- keyboardOptions.openOn = '';
123
- }
124
- keyboardOptions.usePreview = false;
125
- keyboardOptions.accepted = this.onValueAccepted.bind(this);
126
- keyboardOptions.visible = this.onKeyboardVisible.bind(this);
127
- keyboardOptions.beforeClose = this.onBeforeClose.bind(this);
128
- keyboardOptions.change = this.onChange.bind(this);
129
- return keyboardOptions;
130
- };
131
- /**
132
- * @private
133
- * @return {?}
134
- */
135
- VirtualKeyboardDirective.prototype.getKeyboardDisplayOptions = /**
136
- * @private
137
- * @return {?}
138
- */
139
- function () {
140
- return {
141
- bksp: '\u2190',
142
- normal: 'ABC',
143
- meta1: '%?@',
144
- meta2: '#+=',
145
- accept: 'OK'
146
- };
147
- };
148
- /**
149
- * @private
150
- * @return {?}
151
- */
152
- VirtualKeyboardDirective.prototype.getKeyboardLayout = /**
153
- * @private
154
- * @return {?}
155
- */
156
- function () {
157
- /** @type {?} */
158
- var customLayout = {};
159
- if (this.keyboardType === 'alphanumeric') {
160
- customLayout = {
161
- normal: [
162
- '1 2 3 4 5 6 7 8 9 0',
163
- 'Q W E R T Y U I O P {bksp}',
164
- 'A S D F G H J K L Ç',
165
- 'Z X C V B N M {accept}'
166
- ]
167
- };
168
- }
169
- else if (this.keyboardType === 'email') {
170
- customLayout = this.getCustomKeyboardForEmail();
171
- }
172
- return customLayout;
173
- };
174
- /**
175
- * @private
176
- * @return {?}
177
- */
178
- VirtualKeyboardDirective.prototype.getCustomKeyboardForEmail = /**
179
- * @private
180
- * @return {?}
181
- */
182
- function () {
183
- return {
184
- normal: [
185
- '1 2 3 4 5 6 7 8 9 0',
186
- 'q w e r t y u i o p {bksp}',
187
- 'a s d f g h j k l ç',
188
- '{s} z x c v b n m .',
189
- '{meta1} {space} _ - {accept}'
190
- ],
191
- shift: [
192
- '1 2 3 4 5 6 7 8 9 0',
193
- 'Q W E R T Y U I O P {bksp}',
194
- 'A S D F G H J K L Ç',
195
- '{s} Z X C V B N M .',
196
- '{meta1} {space} _ - {accept}'
197
- ],
198
- meta1: [
199
- "` | { } % ^ * / ' {bksp}",
200
- '{meta2} $ & ~ # = + @',
201
- '{normal} {space} ! ? {accept}'
202
- ],
203
- meta2: [
204
- '[ ] { } \u2039 \u203a ^ * " , {bksp}',
205
- '\\ | / < > $ \u00a3 \u00a5 \u2022',
206
- '{meta1} \u20ac & ~ # = + .',
207
- '{normal} {space} ! ? {accept}'
208
- ]
209
- };
210
- };
211
- /**
212
- * @private
213
- * @return {?}
214
- */
215
- VirtualKeyboardDirective.prototype.createKeyboardOptions = /**
216
- * @private
217
- * @return {?}
218
- */
219
- function () {
220
- /** @type {?} */
221
- var keyboardOptions = this.getDefaultKeyboardOptions();
222
- if (this.keyboardPosition !== 'relative') {
223
- keyboardOptions.position = false;
224
- }
225
- if (this.keyboardPosition === 'bottom') {
226
- this.addBottomKeyboardClass();
227
- }
228
- keyboardOptions.css = {
229
- buttonDefault: 'keyboard-button-override'
230
- };
231
- keyboardOptions.display = this.getKeyboardDisplayOptions();
232
- keyboardOptions.layout = 'custom';
233
- keyboardOptions.customLayout = this.getKeyboardLayout();
234
- return keyboardOptions;
235
- };
236
- /**
237
- * @private
238
- * @return {?}
239
- */
240
- VirtualKeyboardDirective.prototype.onKeyboardVisible = /**
241
- * @private
242
- * @return {?}
243
- */
244
- function () {
245
- this.addCustomKeyboardFocusClass();
246
- };
247
- /**
248
- * @private
249
- * @return {?}
250
- */
251
- VirtualKeyboardDirective.prototype.onBeforeClose = /**
252
- * @private
253
- * @return {?}
254
- */
255
- function () {
256
- // O elemente do jQuery limpa tudo o que não passou pelo accept
257
- // Necessário setar o valor quando somente fechado a modal.
258
- /** @type {?} */
259
- var formControl = this.fieldControl.control;
260
- formControl.setValue(this.value);
261
- this.showKeyboard = false;
262
- };
263
- /**
264
- * @private
265
- * @return {?}
266
- */
267
- VirtualKeyboardDirective.prototype.onValueAccepted = /**
268
- * @private
269
- * @return {?}
270
- */
271
- function () {
272
- /** @type {?} */
273
- var casted = ( /** @type {?} */(this.keyboardElement));
274
- this.keyboardValueAccepted.emit(casted.value);
275
- };
276
- /**
277
- * @private
278
- * @param {?} event
279
- * @return {?}
280
- */
281
- VirtualKeyboardDirective.prototype.onChange = /**
282
- * @private
283
- * @param {?} event
284
- * @return {?}
285
- */
286
- function (event) {
287
- /** @type {?} */
288
- var virtualkeyboardevent = new CustomEvent('virtualkeyboardevent', event);
289
- document.dispatchEvent(virtualkeyboardevent);
290
- if (this.keyboardElement instanceof HTMLInputElement) {
291
- /** @type {?} */
292
- var keyboardElement_1 = ( /** @type {?} */(this.keyboardElement));
293
- // Arquivo possui referecia do jQuery que é alterado ao fechar o teclado.
294
- // Necessário clonar a string.
295
- /** @type {?} */
296
- var inputVal_1 = JSON.stringify(keyboardElement_1.value).replace('"', '').replace('"', '');
297
- if (this.fieldControl) {
298
- /** @type {?} */
299
- var formControl = this.fieldControl.control;
300
- this.value = inputVal_1;
301
- formControl.setValue(inputVal_1);
302
- formControl.markAsDirty();
303
- formControl.updateValueAndValidity();
304
- }
305
- // Este setTimeout é necessário para fazer com que o
306
- // cursor do input sempre esteja no final da string digitada
307
- // e o final da string sempre esteja visivel.
308
- setTimeout(( /**
309
- * @return {?}
310
- */function () {
311
- keyboardElement_1.value = inputVal_1;
312
- keyboardElement_1.scrollLeft = keyboardElement_1.scrollWidth;
313
- }));
314
- }
315
- };
316
- /**
317
- * @private
318
- * @return {?}
319
- */
320
- VirtualKeyboardDirective.prototype.addBottomKeyboardClass = /**
321
- * @private
322
- * @return {?}
323
- */
324
- function () {
325
- this.injectCssRule(".ui-keyboard {\n border-radius: 0;\n left: 0;\n top: auto;\n bottom: 0;\n position: fixed;\n width: 100%;\n }");
326
- };
327
- /**
328
- * @private
329
- * @return {?}
330
- */
331
- VirtualKeyboardDirective.prototype.addCustomKeyboardFocusClass = /**
332
- * @private
333
- * @return {?}
334
- */
335
- function () {
336
- this.injectCssRule(".ui-keyboard-has-focus {\n z-index: 900;\n }");
337
- };
338
- /**
339
- * @private
340
- * @param {?} rule
341
- * @return {?}
342
- */
343
- VirtualKeyboardDirective.prototype.injectCssRule = /**
344
- * @private
345
- * @param {?} rule
346
- * @return {?}
347
- */
348
- function (rule) {
349
- /** @type {?} */
350
- var style = ( /** @type {?} */(document.createElement('style')));
351
- style.appendChild(document.createTextNode(''));
352
- document.head.appendChild(style);
353
- style.sheet.insertRule(rule);
354
- };
355
- VirtualKeyboardDirective.decorators = [
356
- { type: core.Directive, args: [{
357
- selector: '[samVirtualKeyboard]'
358
- },] }
359
- ];
360
- /** @nocollapse */
361
- VirtualKeyboardDirective.ctorParameters = function () {
362
- return [
363
- { type: core.ElementRef },
364
- { type: forms.NgControl, decorators: [{ type: core.Optional }] }
365
- ];
366
- };
367
- VirtualKeyboardDirective.propDecorators = {
368
- keyboardPosition: [{ type: core.Input }],
369
- keyboardType: [{ type: core.Input }],
370
- activateKeyboard: [{ type: core.Input }],
371
- showOnFocus: [{ type: core.Input }],
372
- showKeyboard: [{ type: core.Input }],
373
- keyboardValueAccepted: [{ type: core.Output }],
374
- showKeyboardChange: [{ type: core.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: core.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
- exports.VirtualKeyboardModule = VirtualKeyboardModule;
406
- exports.ɵa = VirtualKeyboardDirective;
407
-
408
- Object.defineProperty(exports, '__esModule', { value: true });
409
-
410
- })));
411
-
412
- //# sourceMappingURL=sam-senior-virtual-keyboard.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sam-senior-virtual-keyboard.umd.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":["EventEmitter","Directive","ElementRef","NgControl","Optional","Input","Output","NgModule"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;QAWM,cAAc;;;OAAG,UAAC,OAAO;;YACvB,cAAc,sBAAG,MAAM,EAAO;QACpC,OAAO,cAAc,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACvE,CAAC,CAAA;;QAuCC,kCACS,UAAsB,EACV,YAAuB;YADnC,eAAU,GAAV,UAAU,CAAY;YACV,iBAAY,GAAZ,YAAY,CAAW;YAjC3B,qBAAgB,GAA0B,QAAQ,CAAC;YACnD,iBAAY,GAA6B,OAAO,CAAC;YAUjD,gBAAW,GAAG,IAAI,CAAC;YA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BAClB,KAAK,sBAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,EAAO;gBACpD,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC/C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBACjC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;aAC9B;;oBA9NFC,cAAS,SAAC;wBACT,QAAQ,EAAE,sBAAsB;qBACjC;;;;;wBAlByCC,eAAU;wBAC3CC,eAAS,uBAsDbC,aAAQ;;;;uCAjCVC,UAAK;mCACLA,UAAK;uCACLA,UAAK;kCASLA,UAAK;mCACLA,UAAK;4CASLC,WAAM;yCACNA,WAAM;;QAmMT,+BAAC;KA/ND;;;;;;AChBA;QAGA;SAIsC;;oBAJrCC,aAAQ,SAAC;wBACR,YAAY,EAAE,CAAC,wBAAwB,CAAC;wBACxC,OAAO,EAAE,CAAC,wBAAwB,CAAC;qBACpC;;QACoC,4BAAC;KAJtC;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/forms")):"function"==typeof define&&define.amd?define("@sam-senior/virtual-keyboard",["exports","@angular/core","@angular/forms"],t):t((e["sam-senior"]=e["sam-senior"]||{},e["sam-senior"]["virtual-keyboard"]={}),e.ng.core,e.ng.forms)}(this,function(e,o,t){"use strict";var r=function(){function e(e,t){this.elementRef=e,this.fieldControl=t,this.keyboardPosition="bottom",this.keyboardType="email",this.showOnFocus=!0,this.keyboardValueAccepted=new o.EventEmitter,this.showKeyboardChange=new o.EventEmitter,this._showKeyboard=!1,this.value=""}return Object.defineProperty(e.prototype,"activateKeyboard",{set:function(e){var t,o;e&&(this.keyboardElement=this.elementRef.nativeElement,this.keyboardjQueryElement=(t=this.keyboardElement,(o=window).jQuery?o.jQuery(t):null),this.keyboardjQueryElement&&this.keyboardjQueryElement.keyboard(this.createKeyboardOptions()))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showKeyboard",{get:function(){return this._showKeyboard},set:function(e){this._showKeyboard=e,this.showKeyboardChange.emit(this._showKeyboard)},enumerable:!0,configurable:!0}),e.prototype.ngOnChanges=function(){this.showKeyboard&&this.isKeyboardCreated()&&this.keyboardjQueryElement.getkeyboard().reveal()},e.prototype.ngOnDestroy=function(){this.isKeyboardCreated()&&this.keyboardjQueryElement.keyboard().getkeyboard().destroy()},e.prototype.isKeyboardCreated=function(){return this.keyboardjQueryElement&&this.keyboardjQueryElement.keyboard()&&this.keyboardjQueryElement.keyboard().getkeyboard()},e.prototype.getDefaultKeyboardOptions=function(){var e={};return this.showOnFocus||(e.openOn=""),e.usePreview=!1,e.accepted=this.onValueAccepted.bind(this),e.visible=this.onKeyboardVisible.bind(this),e.beforeClose=this.onBeforeClose.bind(this),e.change=this.onChange.bind(this),e},e.prototype.getKeyboardDisplayOptions=function(){return{bksp:"←",normal:"ABC",meta1:"%?@",meta2:"#+=",accept:"OK"}},e.prototype.getKeyboardLayout=function(){var e={};return"alphanumeric"===this.keyboardType?e={normal:["1 2 3 4 5 6 7 8 9 0","Q W E R T Y U I O P {bksp}","A S D F G H J K L Ç","Z X C V B N M {accept}"]}:"email"===this.keyboardType&&(e=this.getCustomKeyboardForEmail()),e},e.prototype.getCustomKeyboardForEmail=function(){return{normal:["1 2 3 4 5 6 7 8 9 0","q w e r t y u i o p {bksp}","a s d f g h j k l ç","{s} z x c v b n m .","{meta1} {space} _ - {accept}"],shift:["1 2 3 4 5 6 7 8 9 0","Q W E R T Y U I O P {bksp}","A S D F G H J K L Ç","{s} Z X C V B N M .","{meta1} {space} _ - {accept}"],meta1:["` | { } % ^ * / ' {bksp}","{meta2} $ & ~ # = + @","{normal} {space} ! ? {accept}"],meta2:['[ ] { } ‹ › ^ * " , {bksp}',"\\ | / < > $ £ ¥ •","{meta1} € & ~ # = + .","{normal} {space} ! ? {accept}"]}},e.prototype.createKeyboardOptions=function(){var e=this.getDefaultKeyboardOptions();return"relative"!==this.keyboardPosition&&(e.position=!1),"bottom"===this.keyboardPosition&&this.addBottomKeyboardClass(),e.css={buttonDefault:"keyboard-button-override"},e.display=this.getKeyboardDisplayOptions(),e.layout="custom",e.customLayout=this.getKeyboardLayout(),e},e.prototype.onKeyboardVisible=function(){this.addCustomKeyboardFocusClass()},e.prototype.onBeforeClose=function(){this.fieldControl.control.setValue(this.value),this.showKeyboard=!1},e.prototype.onValueAccepted=function(){var e=this.keyboardElement;this.keyboardValueAccepted.emit(e.value)},e.prototype.onChange=function(e){var t=new CustomEvent("virtualkeyboardevent",e);if(document.dispatchEvent(t),this.keyboardElement instanceof HTMLInputElement){var o=this.keyboardElement,r=JSON.stringify(o.value).replace('"',"").replace('"',"");if(this.fieldControl){var a=this.fieldControl.control;this.value=r,a.setValue(r),a.markAsDirty(),a.updateValueAndValidity()}setTimeout(function(){o.value=r,o.scrollLeft=o.scrollWidth})}},e.prototype.addBottomKeyboardClass=function(){this.injectCssRule(".ui-keyboard {\n border-radius: 0;\n left: 0;\n top: auto;\n bottom: 0;\n position: fixed;\n width: 100%;\n }")},e.prototype.addCustomKeyboardFocusClass=function(){this.injectCssRule(".ui-keyboard-has-focus {\n z-index: 900;\n }")},e.prototype.injectCssRule=function(e){var t=document.createElement("style");t.appendChild(document.createTextNode("")),document.head.appendChild(t),t.sheet.insertRule(e)},e.decorators=[{type:o.Directive,args:[{selector:"[samVirtualKeyboard]"}]}],e.ctorParameters=function(){return[{type:o.ElementRef},{type:t.NgControl,decorators:[{type:o.Optional}]}]},e.propDecorators={keyboardPosition:[{type:o.Input}],keyboardType:[{type:o.Input}],activateKeyboard:[{type:o.Input}],showOnFocus:[{type:o.Input}],showKeyboard:[{type:o.Input}],keyboardValueAccepted:[{type:o.Output}],showKeyboardChange:[{type:o.Output}]},e}(),a=function(){function e(){}return e.decorators=[{type:o.NgModule,args:[{declarations:[r],exports:[r]}]}],e}();e.VirtualKeyboardModule=a,e.ɵa=r,Object.defineProperty(e,"__esModule",{value:!0})});
2
- //# sourceMappingURL=sam-senior-virtual-keyboard.umd.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["ng://@sam-senior/virtual-keyboard/lib/virtual-keyboard.directive.ts","ng://@sam-senior/virtual-keyboard/lib/virtual-keyboard.module.ts"],"names":["VirtualKeyboardDirective","elementRef","fieldControl","this","keyboardPosition","keyboardType","showOnFocus","keyboardValueAccepted","EventEmitter","showKeyboardChange","_showKeyboard","value","Object","defineProperty","prototype","activateKeyboard","element","windowInstance","keyboardElement","keyboardjQueryElement","jQuery","keyboard","createKeyboardOptions","revealKeyboard","emit","ngOnChanges","showKeyboard","isKeyboardCreated","getkeyboard","reveal","ngOnDestroy","destroy","getDefaultKeyboardOptions","keyboardOptions","openOn","usePreview","accepted","onValueAccepted","bind","visible","onKeyboardVisible","beforeClose","onBeforeClose","change","onChange","getKeyboardDisplayOptions","bksp","normal","meta1","meta2","accept","getKeyboardLayout","customLayout","getCustomKeyboardForEmail","shift","position","addBottomKeyboardClass","css","buttonDefault","display","layout","addCustomKeyboardFocusClass","control","setValue","casted","event","virtualkeyboardevent","CustomEvent","document","dispatchEvent","HTMLInputElement","keyboardElement_1","inputVal_1","JSON","stringify","replace","formControl","markAsDirty","updateValueAndValidity","setTimeout","scrollLeft","scrollWidth","injectCssRule","rule","style","createElement","appendChild","createTextNode","head","sheet","insertRule","Directive","args","selector","ElementRef","NgControl","decorators","type","Optional","Input","Output","VirtualKeyboardModule","NgModule","declarations","exports"],"mappings":"uZAqDE,SAAAA,EACSC,EACYC,GADZC,KAAAF,WAAAA,EACYE,KAAAD,aAAAA,EAjCJC,KAAAC,iBAA0C,SAC1CD,KAAAE,aAAyC,QAUzCF,KAAAG,aAAc,EAUbH,KAAAI,sBAAwB,IAAIC,EAAAA,aAC7BL,KAAAM,mBAAqB,IAAID,EAAAA,aAEnCL,KAAAO,eAAgB,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cACZD,EAAYE,yBAKdC,WAAU,WACRR,EAAgB5D,MAAQ6D,EACxBD,EAAgBS,WAAaT,EAAgBU,gBAK3CjF,EAAAc,UAAA0C,uBAAR,WACErD,KAAK+E,cACH,iKAWIlF,EAAAc,UAAA+C,4BAAR,WACE1D,KAAK+E,cACH,6DAMIlF,EAAAc,UAAAoE,cAAR,SAAsBC,OACdC,EAAQhB,SAASiB,cAAc,SACrCD,EAAME,YAAYlB,SAASmB,eAAe,KAC1CnB,SAASoB,KAAKF,YAAYF,GAC1BA,EAAMK,MAAMC,WAAWP,wBA7N1BQ,EAAAA,UAASC,KAAA,CAAC,CACTC,SAAU,oEAjB8BC,EAAAA,kBACjCC,EAAAA,UAASC,WAAA,CAAA,CAAAC,KAsDbC,EAAAA,wDAjCFC,EAAAA,4BACAA,EAAAA,gCACAA,EAAAA,2BASAA,EAAAA,4BACAA,EAAAA,qCASAC,EAAAA,mCACAA,EAAAA,UAmMHpG,KC/OAqG,EAAA,WAGA,SAAAA,KAIqC,2BAJpCC,EAAAA,SAAQV,KAAA,CAAC,CACRW,aAAc,CAACvG,GACfwG,QAAS,CAACxG,OAEyBqG,EAPrC","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"]}