@n8n/composables 1.2.0 → 1.3.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.
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/useShortKeyPress.ts
2
+ var _core = require('@vueuse/core');
3
+ var _vue = require('vue');
4
+ function useShortKeyPress(key, fn, {
5
+ dedupe = true,
6
+ threshold = 300,
7
+ disabled = false
8
+ }) {
9
+ const keyDownTime = _vue.ref.call(void 0, null);
10
+ _core.onKeyDown.call(void 0,
11
+ key,
12
+ () => {
13
+ if (_vue.unref.call(void 0, disabled)) return;
14
+ keyDownTime.value = Date.now();
15
+ },
16
+ {
17
+ dedupe
18
+ }
19
+ );
20
+ _core.onKeyUp.call(void 0, key, () => {
21
+ if (_vue.unref.call(void 0, disabled) || !keyDownTime.value) return;
22
+ const isShortPress = Date.now() - keyDownTime.value < threshold;
23
+ if (isShortPress) {
24
+ fn();
25
+ }
26
+ });
27
+ }
28
+
29
+
30
+ exports.useShortKeyPress = useShortKeyPress;
31
+ //# sourceMappingURL=useShortKeyPress.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/n8n/n8n/packages/frontend/@n8n/composables/dist/useShortKeyPress.cjs","../src/useShortKeyPress.ts"],"names":[],"mappings":"AAAA;ACAA,oCAAmC;AAEnC,0BAA2B;AAGpB,SAAS,gBAAA,CACf,GAAA,EACA,EAAA,EACA;AAAA,EACC,OAAA,EAAS,IAAA;AAAA,EACT,UAAA,EAAY,GAAA;AAAA,EACZ,SAAA,EAAW;AACZ,CAAA,EAKC;AACD,EAAA,MAAM,YAAA,EAAc,sBAAA,IAAuB,CAAA;AAE3C,EAAA,6BAAA;AAAA,IACC,GAAA;AAAA,IACA,CAAA,EAAA,GAAM;AACL,MAAA,GAAA,CAAI,wBAAA,QAAc,CAAA,EAAG,MAAA;AAErB,MAAA,WAAA,CAAY,MAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,CAAA;AAAA,IAC9B,CAAA;AAAA,IACA;AAAA,MACC;AAAA,IACD;AAAA,EACD,CAAA;AAEA,EAAA,2BAAA,GAAQ,EAAK,CAAA,EAAA,GAAM;AAClB,IAAA,GAAA,CAAI,wBAAA,QAAc,EAAA,GAAK,CAAC,WAAA,CAAY,KAAA,EAAO,MAAA;AAE3C,IAAA,MAAM,aAAA,EAAe,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,WAAA,CAAY,MAAA,EAAQ,SAAA;AACtD,IAAA,GAAA,CAAI,YAAA,EAAc;AACjB,MAAA,EAAA,CAAG,CAAA;AAAA,IACJ;AAAA,EACD,CAAC,CAAA;AACF;ADbA;AACE;AACF,4CAAC","file":"/home/runner/work/n8n/n8n/packages/frontend/@n8n/composables/dist/useShortKeyPress.cjs","sourcesContent":[null,"import { onKeyDown, onKeyUp } from '@vueuse/core';\nimport type { KeyFilter } from '@vueuse/core';\nimport { ref, unref } from 'vue';\nimport type { MaybeRefOrGetter } from 'vue';\n\nexport function useShortKeyPress(\n\tkey: KeyFilter,\n\tfn: () => void,\n\t{\n\t\tdedupe = true,\n\t\tthreshold = 300,\n\t\tdisabled = false,\n\t}: {\n\t\tdedupe?: boolean;\n\t\tthreshold?: number;\n\t\tdisabled?: MaybeRefOrGetter<boolean>;\n\t},\n) {\n\tconst keyDownTime = ref<number | null>(null);\n\n\tonKeyDown(\n\t\tkey,\n\t\t() => {\n\t\t\tif (unref(disabled)) return;\n\n\t\t\tkeyDownTime.value = Date.now();\n\t\t},\n\t\t{\n\t\t\tdedupe,\n\t\t},\n\t);\n\n\tonKeyUp(key, () => {\n\t\tif (unref(disabled) || !keyDownTime.value) return;\n\n\t\tconst isShortPress = Date.now() - keyDownTime.value < threshold;\n\t\tif (isShortPress) {\n\t\t\tfn();\n\t\t}\n\t});\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { KeyFilter } from '@vueuse/core';
2
+ import { MaybeRefOrGetter } from 'vue';
3
+
4
+ declare function useShortKeyPress(key: KeyFilter, fn: () => void, { dedupe, threshold, disabled, }: {
5
+ dedupe?: boolean;
6
+ threshold?: number;
7
+ disabled?: MaybeRefOrGetter<boolean>;
8
+ }): void;
9
+
10
+ export { useShortKeyPress };
@@ -0,0 +1,10 @@
1
+ import { KeyFilter } from '@vueuse/core';
2
+ import { MaybeRefOrGetter } from 'vue';
3
+
4
+ declare function useShortKeyPress(key: KeyFilter, fn: () => void, { dedupe, threshold, disabled, }: {
5
+ dedupe?: boolean;
6
+ threshold?: number;
7
+ disabled?: MaybeRefOrGetter<boolean>;
8
+ }): void;
9
+
10
+ export { useShortKeyPress };
@@ -0,0 +1,31 @@
1
+ // src/useShortKeyPress.ts
2
+ import { onKeyDown, onKeyUp } from "@vueuse/core";
3
+ import { ref, unref } from "vue";
4
+ function useShortKeyPress(key, fn, {
5
+ dedupe = true,
6
+ threshold = 300,
7
+ disabled = false
8
+ }) {
9
+ const keyDownTime = ref(null);
10
+ onKeyDown(
11
+ key,
12
+ () => {
13
+ if (unref(disabled)) return;
14
+ keyDownTime.value = Date.now();
15
+ },
16
+ {
17
+ dedupe
18
+ }
19
+ );
20
+ onKeyUp(key, () => {
21
+ if (unref(disabled) || !keyDownTime.value) return;
22
+ const isShortPress = Date.now() - keyDownTime.value < threshold;
23
+ if (isShortPress) {
24
+ fn();
25
+ }
26
+ });
27
+ }
28
+ export {
29
+ useShortKeyPress
30
+ };
31
+ //# sourceMappingURL=useShortKeyPress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/useShortKeyPress.ts"],"sourcesContent":["import { onKeyDown, onKeyUp } from '@vueuse/core';\nimport type { KeyFilter } from '@vueuse/core';\nimport { ref, unref } from 'vue';\nimport type { MaybeRefOrGetter } from 'vue';\n\nexport function useShortKeyPress(\n\tkey: KeyFilter,\n\tfn: () => void,\n\t{\n\t\tdedupe = true,\n\t\tthreshold = 300,\n\t\tdisabled = false,\n\t}: {\n\t\tdedupe?: boolean;\n\t\tthreshold?: number;\n\t\tdisabled?: MaybeRefOrGetter<boolean>;\n\t},\n) {\n\tconst keyDownTime = ref<number | null>(null);\n\n\tonKeyDown(\n\t\tkey,\n\t\t() => {\n\t\t\tif (unref(disabled)) return;\n\n\t\t\tkeyDownTime.value = Date.now();\n\t\t},\n\t\t{\n\t\t\tdedupe,\n\t\t},\n\t);\n\n\tonKeyUp(key, () => {\n\t\tif (unref(disabled) || !keyDownTime.value) return;\n\n\t\tconst isShortPress = Date.now() - keyDownTime.value < threshold;\n\t\tif (isShortPress) {\n\t\t\tfn();\n\t\t}\n\t});\n}\n"],"mappings":";AAAA,SAAS,WAAW,eAAe;AAEnC,SAAS,KAAK,aAAa;AAGpB,SAAS,iBACf,KACA,IACA;AAAA,EACC,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AACZ,GAKC;AACD,QAAM,cAAc,IAAmB,IAAI;AAE3C;AAAA,IACC;AAAA,IACA,MAAM;AACL,UAAI,MAAM,QAAQ,EAAG;AAErB,kBAAY,QAAQ,KAAK,IAAI;AAAA,IAC9B;AAAA,IACA;AAAA,MACC;AAAA,IACD;AAAA,EACD;AAEA,UAAQ,KAAK,MAAM;AAClB,QAAI,MAAM,QAAQ,KAAK,CAAC,YAAY,MAAO;AAE3C,UAAM,eAAe,KAAK,IAAI,IAAI,YAAY,QAAQ;AACtD,QAAI,cAAc;AACjB,SAAG;AAAA,IACJ;AAAA,EACD,CAAC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@n8n/composables",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "LICENSE.md",
@@ -28,9 +28,9 @@
28
28
  "vite-plugin-dts": "^4.3.0",
29
29
  "vitest": "^3.0.5",
30
30
  "vue-tsc": "^2.1.10",
31
- "@n8n/frontend-eslint-config": "1.1.0",
32
- "@n8n/frontend-typescript-config": "1.1.0",
33
- "@n8n/frontend-vitest-config": "1.1.0"
31
+ "@n8n/eslint-config": "0.0.1",
32
+ "@n8n/vitest-config": "1.2.0",
33
+ "@n8n/typescript-config": "1.2.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@vueuse/core": "^10.11.0",