@neovici/cosmoz-utils 6.19.0 → 6.20.1
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/dist/haunted-polymer.js +2 -0
- package/dist/hooks/use-meta.d.ts +2 -5
- package/dist/hooks/use-meta.js +2 -5
- package/dist/keybindings/consts.d.ts +1 -0
- package/dist/keybindings/consts.js +1 -0
- package/dist/keybindings/index.d.ts +1 -0
- package/dist/keybindings/index.js +1 -0
- package/dist/keybindings/types.d.ts +6 -2
- package/dist/keybindings/use-keybindings.js +3 -2
- package/dist/keybindings/utils.js +2 -1
- package/package.json +1 -1
package/dist/haunted-polymer.js
CHANGED
|
@@ -36,10 +36,12 @@ export const hauntedPolymer = (outputPath, hook) => (base) => {
|
|
|
36
36
|
}
|
|
37
37
|
connectedCallback() {
|
|
38
38
|
super.connectedCallback();
|
|
39
|
+
this._scheduler.resume();
|
|
39
40
|
this._scheduler.update();
|
|
40
41
|
}
|
|
41
42
|
disconnectedCallback() {
|
|
42
43
|
super.disconnectedCallback();
|
|
44
|
+
this._scheduler.pause();
|
|
43
45
|
this._scheduler.teardown();
|
|
44
46
|
}
|
|
45
47
|
_propertiesChanged(currentProps, changedProps, oldProps) {
|
package/dist/hooks/use-meta.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Rec } from '../object';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} meta - The source object
|
|
7
|
-
* @returns {Object} The memoized object.
|
|
3
|
+
* Returns a stable object reference, mutated in-place with the
|
|
4
|
+
* latest properties of `meta`. The identity never changes (`===`).
|
|
8
5
|
*/
|
|
9
6
|
export declare const useMeta: <T extends Rec>(meta: T) => T;
|
package/dist/hooks/use-meta.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { useMemo } from '@pionjs/pion';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} meta - The source object
|
|
7
|
-
* @returns {Object} The memoized object.
|
|
3
|
+
* Returns a stable object reference, mutated in-place with the
|
|
4
|
+
* latest properties of `meta`. The identity never changes (`===`).
|
|
8
5
|
*/
|
|
9
6
|
export const useMeta = (meta) => {
|
|
10
7
|
const ref = useMemo(() => ({}), []);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ANY_KEY: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ANY_KEY = Symbol('any key');
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { ANY_KEY } from './consts';
|
|
1
2
|
export type Activity = symbol;
|
|
2
|
-
export type Matcher =
|
|
3
|
+
export type Matcher = Partial<Pick<KeyboardEvent, 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey'>> & {
|
|
4
|
+
key: KeyboardEvent['key'] | typeof ANY_KEY;
|
|
5
|
+
};
|
|
3
6
|
export type Info = {
|
|
4
7
|
title: string;
|
|
5
8
|
description: string;
|
|
@@ -10,8 +13,9 @@ export type BindingOptions = {
|
|
|
10
13
|
export type KeyBinding = readonly [Matcher, Activity[], Info, BindingOptions?];
|
|
11
14
|
export type ActivityHandler = {
|
|
12
15
|
activity: Activity;
|
|
13
|
-
callback: () => void;
|
|
16
|
+
callback: (e: KeyboardEvent) => void;
|
|
14
17
|
check?: () => boolean;
|
|
15
18
|
element?: () => Element | null | undefined;
|
|
19
|
+
allowDefault?: boolean;
|
|
16
20
|
};
|
|
17
21
|
export type RegisterFn = (handler: ActivityHandler) => () => void;
|
|
@@ -27,8 +27,9 @@ export const useKeybindings = (bindings) => {
|
|
|
27
27
|
});
|
|
28
28
|
if (!handler)
|
|
29
29
|
return;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (!handler.allowDefault)
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
handler.callback(e);
|
|
32
33
|
};
|
|
33
34
|
document.addEventListener('keydown', keyboardEventHandler, true);
|
|
34
35
|
return () => document.removeEventListener('keydown', keyboardEventHandler, true);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { ANY_KEY } from './consts';
|
|
2
|
+
export const matches = (e) => ([matcher]) => Object.entries(matcher).every(([key, value]) => e[key] === value || value === ANY_KEY);
|
|
2
3
|
export const isInteractive = (el) => {
|
|
3
4
|
if (el == null)
|
|
4
5
|
return false;
|