Skip to content

Commit 7cdda22

Browse files
committed
Squashed commit of the following:
commit 417d6cf Merge: d83c1cb f22680d Author: David Enke <post@davidenke.de> Date: Thu Feb 22 00:36:05 2018 +0100
1 parent feef701 commit 7cdda22

24 files changed

+6274
-5939
lines changed

.angular-cli.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"testTsconfig": "tsconfig.spec.json",
2121
"prefix": "mat-keyboard-demo",
2222
"styles": [
23+
"../../node_modules/reset-css/_reset.scss",
24+
"../../node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
2325
"styles.scss"
2426
],
2527
"scripts": [],

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
build/
33
dist/
44
docs/
5+
src/core/.ng_pkg_build
56
target/
67

78
.classpath

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.9.1
1+
8.9.4

package-lock.json

Lines changed: 5891 additions & 5589 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
"description": "Onscreen virtual keyboard for Angular ≥ 5 (https://angular.io/) using Material 2 (https://material.angular.io/).",
55
"repository": {
66
"type": "git",
7-
"url": "git+https://github.com/ngx-material-keyboard/ngx-material-keyboard.git"
7+
"url": "git+https://github.com/ngx-material-keyboard/core.git"
88
},
99
"author": "David Enke <post@davidenke.de>",
1010
"license": "MIT",
1111
"bugs": {
12-
"url": "https://github.com/ngx-material-keyboard/ngx-material-keyboard/issues"
12+
"url": "https://github.com/ngx-material-keyboard/core/issues"
1313
},
14-
"homepage": "https://github.com/ngx-material-keyboard/ngx-material-keyboard.git#readme",
14+
"homepage": "https://github.com/ngx-material-keyboard/core",
1515
"scripts": {
1616
"ng": "ng",
1717
"start": "npm run start:demo",
1818
"start:demo": "ng serve --host 0.0.0.0 --disable-host-check",
1919
"build": "npm run build:core && npm run build:demo && npm run build:docs",
20-
"build:core": "ng-packagr && cpx -p README.md dist/core",
20+
"build:core": "ng-packagr -p ./src/core/package.json && cpx -p README.md dist/core",
2121
"build:demo": "ng build --prod --locale=de --progress=false --base-href=/demo/",
2222
"build:docs": "compodoc ./src/core -p ./tsconfig.json --silent --disableCoverage --disablePrivateOrInternalSupport --theme readthedocs --output ./dist/docs",
2323
"test": "ng test",
@@ -27,49 +27,39 @@
2727
"postinstall": "npm rebuild node-sass"
2828
},
2929
"dependencies": {
30-
"@angular/animations": "5.0.2",
31-
"@angular/cdk": "5.0.0-rc.1",
32-
"@angular/common": "5.0.2",
33-
"@angular/compiler": "5.0.2",
34-
"@angular/core": "5.0.2",
35-
"@angular/forms": "5.0.2",
36-
"@angular/http": "5.0.2",
37-
"@angular/material": "5.0.0-rc.1",
38-
"@angular/platform-browser": "5.0.2",
39-
"@angular/platform-browser-dynamic": "5.0.2",
40-
"@angular/router": "5.0.2",
30+
"@angular/animations": "5.2.5",
31+
"@angular/cdk": "5.2.2",
32+
"@angular/common": "5.2.5",
33+
"@angular/compiler": "5.2.5",
34+
"@angular/core": "5.2.5",
35+
"@angular/forms": "5.2.5",
36+
"@angular/http": "5.2.5",
37+
"@angular/material": "5.2.2",
38+
"@angular/platform-browser": "5.2.5",
39+
"@angular/platform-browser-dynamic": "5.2.5",
40+
"@angular/router": "5.2.5",
4141
"classlist.js": "1.1.20150312",
42-
"core-js": "2.5.1",
42+
"core-js": "2.5.3",
4343
"hammerjs": "2.0.8",
44-
"reset.scss": "1.0.0",
45-
"rxjs": "5.5.2",
44+
"reset-css": "2.2.1",
45+
"rxjs": "5.5.6",
4646
"web-animations-js": "2.3.1",
47-
"zone.js": "0.8.18"
47+
"zone.js": "0.8.20"
4848
},
4949
"devDependencies": {
50-
"@angular/cli": "1.5.3",
51-
"@angular/compiler-cli": "5.0.2",
52-
"@angular/language-service": "5.0.2",
53-
"@angular/tsc-wrapped": "4.4.6",
54-
"@compodoc/compodoc": "1.0.4",
55-
"@types/jasmine": "2.8.2",
56-
"@types/node": "8.0.53",
57-
"codelyzer": "4.0.1",
50+
"@angular/cli": "1.7.0",
51+
"@angular/compiler-cli": "5.2.5",
52+
"@angular/language-service": "5.2.5",
53+
"@compodoc/compodoc": "1.0.7",
54+
"@types/jasmine": "2.8.6",
55+
"@types/node": "9.4.6",
56+
"codelyzer": "4.1.0",
5857
"cpx": "1.5.0",
59-
"jasmine-core": "2.8.0",
60-
"jasmine-spec-reporter": "4.2.1",
61-
"karma": "1.7.1",
62-
"karma-chrome-launcher": "2.2.0",
63-
"karma-cli": "1.0.1",
64-
"karma-coverage-istanbul-reporter": "1.3.0",
65-
"karma-jasmine": "1.1.0",
66-
"karma-jasmine-html-reporter": "0.2.2",
67-
"ng-packagr": "2.0.0-rc.2",
68-
"protractor": "5.2.0",
69-
"rxjs-tslint-rules": "3.1.1",
58+
"ng-packagr": "2.1.0",
59+
"rxjs-tslint-rules": "3.14.0",
7060
"sass-lint": "1.12.1",
71-
"ts-node": "3.3.0",
72-
"tslint": "5.8.0",
73-
"typescript": "2.6.1"
61+
"ts-node": "5.0.0",
62+
"tslint": "5.9.1",
63+
"typescript": "2.6.2"
7464
}
7565
}

src/core/package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
23
"name": "@ngx-material-keyboard/core",
34
"version": "0.0.12-SNAPSHOT",
4-
"description": "Onscreen virtual keyboard for Angular ≥ 5 (https://angular.io/) using Material 2 (https://material.angular.io/).",
5+
"description": "Onscreen virtual keyboard for Angular ≥ 5 (https://angular.io/) using Material 5 (https://material.angular.io/).",
56
"repository": {
67
"type": "git",
78
"url": "git+https://github.com/ngx-material-keyboard/core.git"
@@ -11,16 +12,23 @@
1112
"bugs": {
1213
"url": "https://github.com/ngx-material-keyboard/core/issues"
1314
},
14-
"homepage": "https://github.com/ngx-material-keyboard/core#readme",
15+
"homepage": "https://github.com/ngx-material-keyboard/core",
1516
"publishConfig": {
1617
"access": "public"
1718
},
1819
"peerDependencies": {
1920
"@angular/animations": "^5.0.0",
20-
"@angular/cdk": "5.0.0-rc.1",
21+
"@angular/cdk": "5.2.2",
2122
"@angular/common": "^5.0.0",
2223
"@angular/core": "^5.0.0",
23-
"@angular/material": "5.0.0-rc.1",
24+
"@angular/forms": "^5.0.0",
25+
"@angular/material": "5.2.2",
2426
"rxjs": "^5.5.2"
27+
},
28+
"ngPackage": {
29+
"dest": "../../dist/core",
30+
"lib": {
31+
"entryFile": "src/public_api.ts"
32+
}
2533
}
2634
}

src/core/src/components/keyboard-key/keyboard-key.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[class.mat-keyboard-key-active]="active$ | async"
55
[class.mat-keyboard-key-pressed]="pressed$ | async"
66
[ngClass]="cssClass"
7-
(click)="onClick()"
7+
(click)="onClick($event)"
88
>
99
<mat-icon *ngIf="hasIcon">{{ icon }}</mat-icon>
1010
<ng-container *ngIf="!hasIcon">{{ key }}</ng-container>

src/core/src/components/keyboard-key/keyboard-key.component.ts

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core';
2-
import { MatInput } from '@angular/material/input';
2+
import { FormControl } from '@angular/forms';
33

44
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
55

66
import { MAT_KEYBOARD_DEADKEYS } from '../../configs/keyboard-deadkey.config';
77
import { MAT_KEYBOARD_ICONS } from '../../configs/keyboard-icons.config';
88
import { KeyboardClassKey } from '../../enums/keyboard-class-key.enum';
9+
import { IKeyboardDeadkeys } from '../../interfaces/keyboard-deadkeys.interface';
10+
import { IKeyboardIcons } from '../../interfaces/keyboard-icons.interface';
911

1012
export const VALUE_NEWLINE = '\n\r';
1113
export const VALUE_SPACE = ' ';
@@ -53,19 +55,34 @@ export class MatKeyboardKeyComponent implements OnInit {
5355
input?: ElementRef;
5456

5557
@Input()
56-
control?: MatInput;
58+
control?: FormControl;
5759

5860
@Output()
59-
enterClick = new EventEmitter<void>();
61+
genericClick = new EventEmitter<MouseEvent>();
6062

6163
@Output()
62-
capsClick = new EventEmitter<void>();
64+
enterClick = new EventEmitter<MouseEvent>();
6365

6466
@Output()
65-
altClick = new EventEmitter<void>();
67+
bkspClick = new EventEmitter<MouseEvent>();
6668

6769
@Output()
68-
shiftClick = new EventEmitter<void>();
70+
capsClick = new EventEmitter<MouseEvent>();
71+
72+
@Output()
73+
altClick = new EventEmitter<MouseEvent>();
74+
75+
@Output()
76+
shiftClick = new EventEmitter<MouseEvent>();
77+
78+
@Output()
79+
spaceClick = new EventEmitter<MouseEvent>();
80+
81+
@Output()
82+
tabClick = new EventEmitter<MouseEvent>();
83+
84+
@Output()
85+
keyClick = new EventEmitter<MouseEvent>();
6986

7087
get lowerKey(): string {
7188
return `${this.key}`.toLowerCase();
@@ -118,15 +135,15 @@ export class MatKeyboardKeyComponent implements OnInit {
118135

119136
set inputValue(inputValue: string) {
120137
if (this.control) {
121-
this.control.value = inputValue;
122-
} else if (this.input) {
138+
this.control.setValue(inputValue);
139+
} else if (this.input && this.input.nativeElement) {
123140
this.input.nativeElement.value = inputValue;
124141
}
125142
}
126143

127144
// Inject dependencies
128-
constructor(@Inject(MAT_KEYBOARD_DEADKEYS) private _deadkeys,
129-
@Inject(MAT_KEYBOARD_ICONS) private _icons) {}
145+
constructor(@Inject(MAT_KEYBOARD_DEADKEYS) private _deadkeys: IKeyboardDeadkeys,
146+
@Inject(MAT_KEYBOARD_ICONS) private _icons: IKeyboardIcons) {}
130147

131148
ngOnInit() {
132149
// read the deadkeys
@@ -136,11 +153,14 @@ export class MatKeyboardKeyComponent implements OnInit {
136153
this._iconKeys = Object.keys(this._icons);
137154
}
138155

139-
onClick() {
156+
onClick(event: MouseEvent) {
140157
// Trigger a global key event
141-
// TODO: determine whether an output should bubble the pressed key similar to the keybboard action or not
158+
// TODO: investigate
142159
this._triggerKeyEvent();
143160

161+
// Trigger generic click event
162+
this.genericClick.emit(event);
163+
144164
// Manipulate the focused input / textarea value
145165
const value = this.inputValue;
146166
const caret = this.input ? this._getCursorPosition() : 0;
@@ -152,44 +172,48 @@ export class MatKeyboardKeyComponent implements OnInit {
152172
case KeyboardClassKey.Alt:
153173
case KeyboardClassKey.AltGr:
154174
case KeyboardClassKey.AltLk:
155-
this.altClick.next();
175+
this.altClick.emit(event);
156176
break;
157177

158178
case KeyboardClassKey.Bksp:
159179
this.inputValue = [value.slice(0, caret - 1), value.slice(caret)].join('');
160180
this._setCursorPosition(caret - 1);
181+
this.bkspClick.emit(event);
161182
break;
162183

163184
case KeyboardClassKey.Caps:
164-
this.capsClick.next();
185+
this.capsClick.emit(event);
165186
break;
166187

167188
case KeyboardClassKey.Enter:
168189
if (this._isTextarea()) {
169190
char = VALUE_NEWLINE;
170191
} else {
171-
this.enterClick.next();
192+
this.enterClick.emit(event);
172193
// TODO: trigger submit / onSubmit / ngSubmit properly (for the time being this has to be handled by the user himself)
173194
// console.log(this.control.ngControl.control.root)
174195
// this.input.nativeElement.form.submit();
175196
}
176197
break;
177198

178199
case KeyboardClassKey.Shift:
179-
this.shiftClick.next();
200+
this.shiftClick.emit(event);
180201
break;
181202

182203
case KeyboardClassKey.Space:
183204
char = VALUE_SPACE;
205+
this.spaceClick.emit(event);
184206
break;
185207

186208
case KeyboardClassKey.Tab:
187209
char = VALUE_TAB;
210+
this.tabClick.emit(event);
188211
break;
189212

190213
default:
191214
// the key is not mapped or a string
192215
char = `${this.key}`;
216+
this.keyClick.emit(event);
193217
break;
194218
}
195219

@@ -229,7 +253,7 @@ export class MatKeyboardKeyComponent implements OnInit {
229253
if ('selectionStart' in this.input.nativeElement) {
230254
// Standard-compliant browsers
231255
return this.input.nativeElement.selectionStart;
232-
} else if (window.document['selection']) {
256+
} else if ('selection' in window.document) {
233257
// IE
234258
this.input.nativeElement.focus();
235259
const sel = window.document['selection'].createRange();

0 commit comments

Comments
 (0)