@firestitch/common 12.0.0 → 12.1.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/bundles/firestitch-common.umd.js +17 -0
- package/bundles/firestitch-common.umd.js.map +1 -1
- package/esm2015/libs/rxjs/keyboard-shortcut.js +18 -0
- package/esm2015/public_api.js +2 -1
- package/fesm2015/firestitch-common.js +19 -3
- package/fesm2015/firestitch-common.js.map +1 -1
- package/libs/rxjs/keyboard-shortcut.d.ts +2 -0
- package/package.json +1 -1
- package/public_api.d.ts +1 -0
|
@@ -1809,6 +1809,22 @@
|
|
|
1809
1809
|
}
|
|
1810
1810
|
};
|
|
1811
1811
|
|
|
1812
|
+
var keyboardShortcut = function (shortcut) {
|
|
1813
|
+
// Observables for all keydown and keyup events
|
|
1814
|
+
var keyDown$ = rxjs.fromEvent(document, 'keydown');
|
|
1815
|
+
var keyUp$ = rxjs.fromEvent(document, 'keyup');
|
|
1816
|
+
// All KeyboardEvents - emitted only when KeyboardEvent changes (key or type)
|
|
1817
|
+
var keyEvents$ = rxjs.merge(keyDown$, keyUp$).pipe(operators.distinctUntilChanged(function (a, b) { return a.code === b.code && a.type === b.type; }), operators.share());
|
|
1818
|
+
// Create KeyboardEvent Observable for specified KeyCode
|
|
1819
|
+
var createKeyPressStream = function (charCode) { return keyEvents$.pipe(operators.filter(function (event) { return event.keyCode === charCode; })); };
|
|
1820
|
+
// Create Event Stream for every KeyCode in shortcut
|
|
1821
|
+
var keyCodeEvents$ = shortcut.map(function (s) { return createKeyPressStream(s); });
|
|
1822
|
+
// Emit when specified keys are pressed (keydown).
|
|
1823
|
+
// Emit only when all specified keys are pressed at the same time.
|
|
1824
|
+
// More on combineLatest below
|
|
1825
|
+
return rxjs.combineLatest(keyCodeEvents$).pipe(operators.filter(function (arr) { return arr.every(function (a) { return a.type === 'keydown'; }); }));
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1812
1828
|
/*
|
|
1813
1829
|
* Public API Surface of fs-menu
|
|
1814
1830
|
*/
|
|
@@ -1891,6 +1907,7 @@
|
|
|
1891
1907
|
exports.isEmpty = isEmpty;
|
|
1892
1908
|
exports.isNumeric = isNumeric;
|
|
1893
1909
|
exports.keyExists = keyExists;
|
|
1910
|
+
exports.keyboardShortcut = keyboardShortcut;
|
|
1894
1911
|
exports.ksort = ksort;
|
|
1895
1912
|
exports.length = length;
|
|
1896
1913
|
exports.list = list;
|