element-vir 26.6.0 → 26.7.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,7 +1,15 @@
|
|
|
1
1
|
import { type MaybePromise } from '@augment-vir/common';
|
|
2
2
|
/**
|
|
3
|
-
* Listens to enter, return, and space key hits on an element.
|
|
3
|
+
* Listens to enter, return, and space key hits on an element. Similar to {@link listenToEnter} but
|
|
4
|
+
* includes space.
|
|
4
5
|
*
|
|
5
6
|
* @category Directives
|
|
6
7
|
*/
|
|
7
8
|
export declare function listenToActivate(callback: () => MaybePromise<void>): import("lit-html/directive.js").DirectiveResult<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Listens to enter and return key hits on an element. Similar to {@link listenToActivate} but
|
|
11
|
+
* doesn't include space.
|
|
12
|
+
*
|
|
13
|
+
* @category Directives
|
|
14
|
+
*/
|
|
15
|
+
export declare function listenToEnter(callback: () => MaybePromise<void>): import("lit-html/directive.js").DirectiveResult<any>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { listen } from './listen.directive.js';
|
|
2
2
|
/**
|
|
3
|
-
* Listens to enter, return, and space key hits on an element.
|
|
3
|
+
* Listens to enter, return, and space key hits on an element. Similar to {@link listenToEnter} but
|
|
4
|
+
* includes space.
|
|
4
5
|
*
|
|
5
6
|
* @category Directives
|
|
6
7
|
*/
|
|
@@ -14,3 +15,19 @@ export function listenToActivate(callback) {
|
|
|
14
15
|
}
|
|
15
16
|
});
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Listens to enter and return key hits on an element. Similar to {@link listenToActivate} but
|
|
20
|
+
* doesn't include space.
|
|
21
|
+
*
|
|
22
|
+
* @category Directives
|
|
23
|
+
*/
|
|
24
|
+
export function listenToEnter(callback) {
|
|
25
|
+
return listen('keydown', async (event) => {
|
|
26
|
+
const key = event.code.toLowerCase();
|
|
27
|
+
if (key.includes('enter') || key.includes('return')) {
|
|
28
|
+
event.stopImmediatePropagation();
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
await callback();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|