@nemigo/helpers 0.11.0 → 0.11.2

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 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 usePreventStop Условие для вызова {@link preventStop}
37
- * @param condition Условие для вызова основного коллбэка
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 KeyboardEvent = KeyboardEvent>(call?: CanBeNullable<(e: T) => CanBePromise>, { usePreventStop, condition, }?: {
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 usePreventStop Условие для вызова {@link preventStop}
41
- * @param condition Условие для вызова основного коллбэка
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 && useConditionGuard(condition))
54
- call?.(e);
54
+ if (isEnter) {
55
+ if (useConditionGuard(condition))
56
+ call?.(e);
57
+ }
58
+ else {
59
+ onkeydown?.(e);
60
+ }
55
61
  };
56
62
  /**
57
63
  * Проверяет, является ли событие клавиатурным.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/helpers",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",
@@ -141,7 +141,7 @@
141
141
  }
142
142
  },
143
143
  "peerDependencies": {
144
- "@std/msgpack": "jsr:^1.0.0",
144
+ "@std/msgpack": ">=1.0.0",
145
145
  "zod": ">=4.0.0"
146
146
  },
147
147
  "peerDependenciesMeta": {