@nemigo/helpers 0.11.0 → 0.11.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/html.d.ts +6 -4
- package/dist/html.js +12 -6
- package/package.json +1 -1
package/dist/html.d.ts
CHANGED
|
@@ -32,11 +32,13 @@ export declare const preventStopHook: <T extends Event = Event>(call?: CanBeNull
|
|
|
32
32
|
* 3. Если нажата Enter и `condition` → true, вызовется основной коллбэк.
|
|
33
33
|
*
|
|
34
34
|
* @template T Тип события клавиатуры
|
|
35
|
-
* @param call Основной коллбэк, вызываемый при Enter
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
35
|
+
* @param call - Основной коллбэк, вызываемый при Enter
|
|
36
|
+
* @param onkeydown - Для иных клавиш вызывается всегда, кроме `"Enter`
|
|
37
|
+
* @param usePreventStop - Условие для вызова {@link preventStop}
|
|
38
|
+
* @param condition - Условие для вызова основного коллбэка
|
|
38
39
|
*/
|
|
39
|
-
export declare const enterKeyHook: <T extends
|
|
40
|
+
export declare const enterKeyHook: <T extends TargetKeyboardEvent = TargetKeyboardEvent>(call?: CanBeNullable<(e: T) => CanBePromise>, { onkeydown, usePreventStop, condition, }?: {
|
|
41
|
+
onkeydown?: (e: T) => void;
|
|
40
42
|
usePreventStop?: "enter" | unknown | ((e: T, isEnter: boolean) => unknown);
|
|
41
43
|
condition?: ((e: T) => unknown) | unknown;
|
|
42
44
|
}) => (e: T) => void;
|
package/dist/html.js
CHANGED
|
@@ -36,11 +36,12 @@ export const preventStopHook = (call, { usePreventStop = true, condition = true,
|
|
|
36
36
|
* 3. Если нажата Enter и `condition` → true, вызовется основной коллбэк.
|
|
37
37
|
*
|
|
38
38
|
* @template T Тип события клавиатуры
|
|
39
|
-
* @param call Основной коллбэк, вызываемый при Enter
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
39
|
+
* @param call - Основной коллбэк, вызываемый при Enter
|
|
40
|
+
* @param onkeydown - Для иных клавиш вызывается всегда, кроме `"Enter`
|
|
41
|
+
* @param usePreventStop - Условие для вызова {@link preventStop}
|
|
42
|
+
* @param condition - Условие для вызова основного коллбэка
|
|
42
43
|
*/
|
|
43
|
-
export const enterKeyHook = (call, { usePreventStop = "enter", condition = true, } = {}) => (e) => {
|
|
44
|
+
export const enterKeyHook = (call, { onkeydown, usePreventStop = "enter", condition = true, } = {}) => (e) => {
|
|
44
45
|
const isEnter = e.key === "Enter";
|
|
45
46
|
if (usePreventStop === "enter") {
|
|
46
47
|
if (isEnter)
|
|
@@ -50,8 +51,13 @@ export const enterKeyHook = (call, { usePreventStop = "enter", condition = true,
|
|
|
50
51
|
if (useConditionGuard(usePreventStop, e, isEnter))
|
|
51
52
|
preventStop(e);
|
|
52
53
|
}
|
|
53
|
-
if (isEnter
|
|
54
|
-
|
|
54
|
+
if (isEnter) {
|
|
55
|
+
if (useConditionGuard(condition))
|
|
56
|
+
call?.(e);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
onkeydown?.(e);
|
|
60
|
+
}
|
|
55
61
|
};
|
|
56
62
|
/**
|
|
57
63
|
* Проверяет, является ли событие клавиатурным.
|