@n8n/composables 1.11.0 → 1.13.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.
- package/dist/useDeviceSupport.cjs +33 -32
- package/dist/useDeviceSupport.cjs.map +1 -1
- package/dist/useDeviceSupport.d.cts +13 -11
- package/dist/useDeviceSupport.d.mts +17 -0
- package/dist/useDeviceSupport.mjs +38 -0
- package/dist/useDeviceSupport.mjs.map +1 -0
- package/dist/useShortKeyPress.cjs +15 -27
- package/dist/useShortKeyPress.cjs.map +1 -1
- package/dist/useShortKeyPress.d.cts +13 -7
- package/dist/useShortKeyPress.d.mts +16 -0
- package/dist/useShortKeyPress.mjs +19 -0
- package/dist/useShortKeyPress.mjs.map +1 -0
- package/dist/useThrottleWithReactiveDelay.cjs +13 -18
- package/dist/useThrottleWithReactiveDelay.cjs.map +1 -1
- package/dist/useThrottleWithReactiveDelay.d.cts +4 -2
- package/dist/useThrottleWithReactiveDelay.d.mts +7 -0
- package/dist/useThrottleWithReactiveDelay.mjs +18 -0
- package/dist/useThrottleWithReactiveDelay.mjs.map +1 -0
- package/package.json +7 -7
- package/dist/useDeviceSupport.d.ts +0 -15
- package/dist/useDeviceSupport.js +0 -37
- package/dist/useDeviceSupport.js.map +0 -1
- package/dist/useShortKeyPress.d.ts +0 -10
- package/dist/useShortKeyPress.js +0 -31
- package/dist/useShortKeyPress.js.map +0 -1
- package/dist/useThrottleWithReactiveDelay.d.ts +0 -5
- package/dist/useThrottleWithReactiveDelay.js +0 -23
- package/dist/useThrottleWithReactiveDelay.js.map +0 -1
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
|
|
3
|
+
//#region src/useDeviceSupport.ts
|
|
3
4
|
function useDeviceSupport() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Check if the device is a touch device but exclude devices that have a fine pointer (mouse or track-pad)
|
|
7
|
+
* - `fine` will check for an accurate pointing device. Examples include mice, touch-pads, and drawing styluses
|
|
8
|
+
* - `coarse` will check for a pointing device of limited accuracy. Examples include touchscreens and motion-detection sensors
|
|
9
|
+
* - `any-pointer` will check for the presence of any pointing device, if there are multiple of them
|
|
10
|
+
*/
|
|
11
|
+
const isTouchDevice = (0, vue.ref)(window.matchMedia("(any-pointer: coarse)").matches && !window.matchMedia("(any-pointer: fine)").matches);
|
|
12
|
+
const userAgent = (0, vue.ref)(navigator.userAgent.toLowerCase());
|
|
13
|
+
const isIOs = (0, vue.ref)(userAgent.value.includes("iphone") || userAgent.value.includes("ipad") || userAgent.value.includes("ipod"));
|
|
14
|
+
const isAndroidOs = (0, vue.ref)(userAgent.value.includes("android"));
|
|
15
|
+
const isMacOs = (0, vue.ref)(userAgent.value.includes("macintosh") || isIOs.value);
|
|
16
|
+
const isMobileDevice = (0, vue.ref)(isIOs.value || isAndroidOs.value);
|
|
17
|
+
const controlKeyCode = (0, vue.ref)(isMacOs.value ? "Meta" : "Control");
|
|
18
|
+
const controlKeyText = (0, vue.computed)(() => isMacOs.value ? "⌘" : "Ctrl");
|
|
19
|
+
function isCtrlKeyPressed(e) {
|
|
20
|
+
if (isMacOs.value) return e.metaKey;
|
|
21
|
+
return e.ctrlKey;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
userAgent: userAgent.value,
|
|
25
|
+
isTouchDevice: isTouchDevice.value,
|
|
26
|
+
isAndroidOs: isAndroidOs.value,
|
|
27
|
+
isIOs: isIOs.value,
|
|
28
|
+
isMacOs: isMacOs.value,
|
|
29
|
+
isMobileDevice: isMobileDevice.value,
|
|
30
|
+
controlKeyCode: controlKeyCode.value,
|
|
31
|
+
controlKeyText,
|
|
32
|
+
isCtrlKeyPressed
|
|
33
|
+
};
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
//#endregion
|
|
36
37
|
exports.useDeviceSupport = useDeviceSupport;
|
|
37
38
|
//# sourceMappingURL=useDeviceSupport.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useDeviceSupport.cjs","names":[],"sources":["../src/useDeviceSupport.ts"],"sourcesContent":["import { computed, ref } from 'vue';\n\nexport function useDeviceSupport() {\n\t/**\n\t * Check if the device is a touch device but exclude devices that have a fine pointer (mouse or track-pad)\n\t * - `fine` will check for an accurate pointing device. Examples include mice, touch-pads, and drawing styluses\n\t * - `coarse` will check for a pointing device of limited accuracy. Examples include touchscreens and motion-detection sensors\n\t * - `any-pointer` will check for the presence of any pointing device, if there are multiple of them\n\t */\n\tconst isTouchDevice = ref(\n\t\twindow.matchMedia('(any-pointer: coarse)').matches &&\n\t\t\t!window.matchMedia('(any-pointer: fine)').matches,\n\t);\n\tconst userAgent = ref(navigator.userAgent.toLowerCase());\n\n\tconst isIOs = ref(\n\t\tuserAgent.value.includes('iphone') ||\n\t\t\tuserAgent.value.includes('ipad') ||\n\t\t\tuserAgent.value.includes('ipod'),\n\t);\n\tconst isAndroidOs = ref(userAgent.value.includes('android'));\n\tconst isMacOs = ref(userAgent.value.includes('macintosh') || isIOs.value);\n\tconst isMobileDevice = ref(isIOs.value || isAndroidOs.value);\n\n\tconst controlKeyCode = ref(isMacOs.value ? 'Meta' : 'Control');\n\tconst controlKeyText = computed(() => (isMacOs.value ? '⌘' : 'Ctrl'));\n\n\tfunction isCtrlKeyPressed(e: MouseEvent | KeyboardEvent): boolean {\n\t\tif (isMacOs.value) {\n\t\t\treturn (e as KeyboardEvent).metaKey;\n\t\t}\n\t\treturn (e as KeyboardEvent).ctrlKey;\n\t}\n\n\treturn {\n\t\tuserAgent: userAgent.value,\n\t\tisTouchDevice: isTouchDevice.value,\n\t\tisAndroidOs: isAndroidOs.value,\n\t\tisIOs: isIOs.value,\n\t\tisMacOs: isMacOs.value,\n\t\tisMobileDevice: isMobileDevice.value,\n\t\tcontrolKeyCode: controlKeyCode.value,\n\t\tcontrolKeyText,\n\t\tisCtrlKeyPressed,\n\t};\n}\n"],"mappings":";;;AAEA,SAAgB,mBAAmB;;;;;;;CAOlC,MAAM,6BACL,OAAO,WAAW,wBAAwB,CAAC,WAC1C,CAAC,OAAO,WAAW,sBAAsB,CAAC,QAC3C;CACD,MAAM,yBAAgB,UAAU,UAAU,aAAa,CAAC;CAExD,MAAM,qBACL,UAAU,MAAM,SAAS,SAAS,IACjC,UAAU,MAAM,SAAS,OAAO,IAChC,UAAU,MAAM,SAAS,OAAO,CACjC;CACD,MAAM,2BAAkB,UAAU,MAAM,SAAS,UAAU,CAAC;CAC5D,MAAM,uBAAc,UAAU,MAAM,SAAS,YAAY,IAAI,MAAM,MAAM;CACzE,MAAM,8BAAqB,MAAM,SAAS,YAAY,MAAM;CAE5D,MAAM,8BAAqB,QAAQ,QAAQ,SAAS,UAAU;CAC9D,MAAM,yCAAiC,QAAQ,QAAQ,MAAM,OAAQ;CAErE,SAAS,iBAAiB,GAAwC;AACjE,MAAI,QAAQ,MACX,QAAQ,EAAoB;AAE7B,SAAQ,EAAoB;;AAG7B,QAAO;EACN,WAAW,UAAU;EACrB,eAAe,cAAc;EAC7B,aAAa,YAAY;EACzB,OAAO,MAAM;EACb,SAAS,QAAQ;EACjB,gBAAgB,eAAe;EAC/B,gBAAgB,eAAe;EAC/B;EACA;EACA"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue0 from "vue";
|
|
2
2
|
|
|
3
|
+
//#region src/useDeviceSupport.d.ts
|
|
3
4
|
declare function useDeviceSupport(): {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
userAgent: string;
|
|
6
|
+
isTouchDevice: boolean;
|
|
7
|
+
isAndroidOs: boolean;
|
|
8
|
+
isIOs: boolean;
|
|
9
|
+
isMacOs: boolean;
|
|
10
|
+
isMobileDevice: boolean;
|
|
11
|
+
controlKeyCode: string;
|
|
12
|
+
controlKeyText: vue0.ComputedRef<"⌘" | "Ctrl">;
|
|
13
|
+
isCtrlKeyPressed: (e: MouseEvent | KeyboardEvent) => boolean;
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
//#endregion
|
|
15
16
|
export { useDeviceSupport };
|
|
17
|
+
//# sourceMappingURL=useDeviceSupport.d.cts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as vue0 from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/useDeviceSupport.d.ts
|
|
4
|
+
declare function useDeviceSupport(): {
|
|
5
|
+
userAgent: string;
|
|
6
|
+
isTouchDevice: boolean;
|
|
7
|
+
isAndroidOs: boolean;
|
|
8
|
+
isIOs: boolean;
|
|
9
|
+
isMacOs: boolean;
|
|
10
|
+
isMobileDevice: boolean;
|
|
11
|
+
controlKeyCode: string;
|
|
12
|
+
controlKeyText: vue0.ComputedRef<"⌘" | "Ctrl">;
|
|
13
|
+
isCtrlKeyPressed: (e: MouseEvent | KeyboardEvent) => boolean;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { useDeviceSupport };
|
|
17
|
+
//# sourceMappingURL=useDeviceSupport.d.mts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/useDeviceSupport.ts
|
|
4
|
+
function useDeviceSupport() {
|
|
5
|
+
/**
|
|
6
|
+
* Check if the device is a touch device but exclude devices that have a fine pointer (mouse or track-pad)
|
|
7
|
+
* - `fine` will check for an accurate pointing device. Examples include mice, touch-pads, and drawing styluses
|
|
8
|
+
* - `coarse` will check for a pointing device of limited accuracy. Examples include touchscreens and motion-detection sensors
|
|
9
|
+
* - `any-pointer` will check for the presence of any pointing device, if there are multiple of them
|
|
10
|
+
*/
|
|
11
|
+
const isTouchDevice = ref(window.matchMedia("(any-pointer: coarse)").matches && !window.matchMedia("(any-pointer: fine)").matches);
|
|
12
|
+
const userAgent = ref(navigator.userAgent.toLowerCase());
|
|
13
|
+
const isIOs = ref(userAgent.value.includes("iphone") || userAgent.value.includes("ipad") || userAgent.value.includes("ipod"));
|
|
14
|
+
const isAndroidOs = ref(userAgent.value.includes("android"));
|
|
15
|
+
const isMacOs = ref(userAgent.value.includes("macintosh") || isIOs.value);
|
|
16
|
+
const isMobileDevice = ref(isIOs.value || isAndroidOs.value);
|
|
17
|
+
const controlKeyCode = ref(isMacOs.value ? "Meta" : "Control");
|
|
18
|
+
const controlKeyText = computed(() => isMacOs.value ? "⌘" : "Ctrl");
|
|
19
|
+
function isCtrlKeyPressed(e) {
|
|
20
|
+
if (isMacOs.value) return e.metaKey;
|
|
21
|
+
return e.ctrlKey;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
userAgent: userAgent.value,
|
|
25
|
+
isTouchDevice: isTouchDevice.value,
|
|
26
|
+
isAndroidOs: isAndroidOs.value,
|
|
27
|
+
isIOs: isIOs.value,
|
|
28
|
+
isMacOs: isMacOs.value,
|
|
29
|
+
isMobileDevice: isMobileDevice.value,
|
|
30
|
+
controlKeyCode: controlKeyCode.value,
|
|
31
|
+
controlKeyText,
|
|
32
|
+
isCtrlKeyPressed
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useDeviceSupport };
|
|
38
|
+
//# sourceMappingURL=useDeviceSupport.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeviceSupport.mjs","names":[],"sources":["../src/useDeviceSupport.ts"],"sourcesContent":["import { computed, ref } from 'vue';\n\nexport function useDeviceSupport() {\n\t/**\n\t * Check if the device is a touch device but exclude devices that have a fine pointer (mouse or track-pad)\n\t * - `fine` will check for an accurate pointing device. Examples include mice, touch-pads, and drawing styluses\n\t * - `coarse` will check for a pointing device of limited accuracy. Examples include touchscreens and motion-detection sensors\n\t * - `any-pointer` will check for the presence of any pointing device, if there are multiple of them\n\t */\n\tconst isTouchDevice = ref(\n\t\twindow.matchMedia('(any-pointer: coarse)').matches &&\n\t\t\t!window.matchMedia('(any-pointer: fine)').matches,\n\t);\n\tconst userAgent = ref(navigator.userAgent.toLowerCase());\n\n\tconst isIOs = ref(\n\t\tuserAgent.value.includes('iphone') ||\n\t\t\tuserAgent.value.includes('ipad') ||\n\t\t\tuserAgent.value.includes('ipod'),\n\t);\n\tconst isAndroidOs = ref(userAgent.value.includes('android'));\n\tconst isMacOs = ref(userAgent.value.includes('macintosh') || isIOs.value);\n\tconst isMobileDevice = ref(isIOs.value || isAndroidOs.value);\n\n\tconst controlKeyCode = ref(isMacOs.value ? 'Meta' : 'Control');\n\tconst controlKeyText = computed(() => (isMacOs.value ? '⌘' : 'Ctrl'));\n\n\tfunction isCtrlKeyPressed(e: MouseEvent | KeyboardEvent): boolean {\n\t\tif (isMacOs.value) {\n\t\t\treturn (e as KeyboardEvent).metaKey;\n\t\t}\n\t\treturn (e as KeyboardEvent).ctrlKey;\n\t}\n\n\treturn {\n\t\tuserAgent: userAgent.value,\n\t\tisTouchDevice: isTouchDevice.value,\n\t\tisAndroidOs: isAndroidOs.value,\n\t\tisIOs: isIOs.value,\n\t\tisMacOs: isMacOs.value,\n\t\tisMobileDevice: isMobileDevice.value,\n\t\tcontrolKeyCode: controlKeyCode.value,\n\t\tcontrolKeyText,\n\t\tisCtrlKeyPressed,\n\t};\n}\n"],"mappings":";;;AAEA,SAAgB,mBAAmB;;;;;;;CAOlC,MAAM,gBAAgB,IACrB,OAAO,WAAW,wBAAwB,CAAC,WAC1C,CAAC,OAAO,WAAW,sBAAsB,CAAC,QAC3C;CACD,MAAM,YAAY,IAAI,UAAU,UAAU,aAAa,CAAC;CAExD,MAAM,QAAQ,IACb,UAAU,MAAM,SAAS,SAAS,IACjC,UAAU,MAAM,SAAS,OAAO,IAChC,UAAU,MAAM,SAAS,OAAO,CACjC;CACD,MAAM,cAAc,IAAI,UAAU,MAAM,SAAS,UAAU,CAAC;CAC5D,MAAM,UAAU,IAAI,UAAU,MAAM,SAAS,YAAY,IAAI,MAAM,MAAM;CACzE,MAAM,iBAAiB,IAAI,MAAM,SAAS,YAAY,MAAM;CAE5D,MAAM,iBAAiB,IAAI,QAAQ,QAAQ,SAAS,UAAU;CAC9D,MAAM,iBAAiB,eAAgB,QAAQ,QAAQ,MAAM,OAAQ;CAErE,SAAS,iBAAiB,GAAwC;AACjE,MAAI,QAAQ,MACX,QAAQ,EAAoB;AAE7B,SAAQ,EAAoB;;AAG7B,QAAO;EACN,WAAW,UAAU;EACrB,eAAe,cAAc;EAC7B,aAAa,YAAY;EACzB,OAAO,MAAM;EACb,SAAS,QAAQ;EACjB,gBAAgB,eAAe;EAC/B,gBAAgB,eAAe;EAC/B;EACA;EACA"}
|
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
}
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
let __vueuse_core = require("@vueuse/core");
|
|
28
3
|
|
|
4
|
+
//#region src/useShortKeyPress.ts
|
|
5
|
+
function useShortKeyPress(key, fn, { dedupe = true, threshold = 300, disabled = false }) {
|
|
6
|
+
const keyDownTime = (0, vue.ref)(null);
|
|
7
|
+
(0, __vueuse_core.onKeyDown)(key, () => {
|
|
8
|
+
if ((0, vue.unref)(disabled)) return;
|
|
9
|
+
keyDownTime.value = Date.now();
|
|
10
|
+
}, { dedupe });
|
|
11
|
+
(0, __vueuse_core.onKeyUp)(key, () => {
|
|
12
|
+
if ((0, vue.unref)(disabled) || !keyDownTime.value) return;
|
|
13
|
+
if (Date.now() - keyDownTime.value < threshold) fn();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
29
16
|
|
|
17
|
+
//#endregion
|
|
30
18
|
exports.useShortKeyPress = useShortKeyPress;
|
|
31
19
|
//# sourceMappingURL=useShortKeyPress.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useShortKeyPress.cjs","names":[],"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":";;;;AAKA,SAAgB,iBACf,KACA,IACA,EACC,SAAS,MACT,YAAY,KACZ,WAAW,SAMX;CACD,MAAM,2BAAiC,KAAK;AAE5C,8BACC,WACM;AACL,qBAAU,SAAS,CAAE;AAErB,cAAY,QAAQ,KAAK,KAAK;IAE/B,EACC,QACA,CACD;AAED,4BAAQ,WAAW;AAClB,qBAAU,SAAS,IAAI,CAAC,YAAY,MAAO;AAG3C,MADqB,KAAK,KAAK,GAAG,YAAY,QAAQ,UAErD,KAAI;GAEJ"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { MaybeRefOrGetter } from "vue";
|
|
2
|
+
import { KeyFilter } from "@vueuse/core";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
//#region src/useShortKeyPress.d.ts
|
|
5
|
+
declare function useShortKeyPress(key: KeyFilter, fn: () => void, {
|
|
6
|
+
dedupe,
|
|
7
|
+
threshold,
|
|
8
|
+
disabled
|
|
9
|
+
}: {
|
|
10
|
+
dedupe?: boolean;
|
|
11
|
+
threshold?: number;
|
|
12
|
+
disabled?: MaybeRefOrGetter<boolean>;
|
|
8
13
|
}): void;
|
|
9
|
-
|
|
14
|
+
//#endregion
|
|
10
15
|
export { useShortKeyPress };
|
|
16
|
+
//# sourceMappingURL=useShortKeyPress.d.cts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from "vue";
|
|
2
|
+
import { KeyFilter } from "@vueuse/core";
|
|
3
|
+
|
|
4
|
+
//#region src/useShortKeyPress.d.ts
|
|
5
|
+
declare function useShortKeyPress(key: KeyFilter, fn: () => void, {
|
|
6
|
+
dedupe,
|
|
7
|
+
threshold,
|
|
8
|
+
disabled
|
|
9
|
+
}: {
|
|
10
|
+
dedupe?: boolean;
|
|
11
|
+
threshold?: number;
|
|
12
|
+
disabled?: MaybeRefOrGetter<boolean>;
|
|
13
|
+
}): void;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useShortKeyPress };
|
|
16
|
+
//# sourceMappingURL=useShortKeyPress.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ref, unref } from "vue";
|
|
2
|
+
import { onKeyDown, onKeyUp } from "@vueuse/core";
|
|
3
|
+
|
|
4
|
+
//#region src/useShortKeyPress.ts
|
|
5
|
+
function useShortKeyPress(key, fn, { dedupe = true, threshold = 300, disabled = false }) {
|
|
6
|
+
const keyDownTime = ref(null);
|
|
7
|
+
onKeyDown(key, () => {
|
|
8
|
+
if (unref(disabled)) return;
|
|
9
|
+
keyDownTime.value = Date.now();
|
|
10
|
+
}, { dedupe });
|
|
11
|
+
onKeyUp(key, () => {
|
|
12
|
+
if (unref(disabled) || !keyDownTime.value) return;
|
|
13
|
+
if (Date.now() - keyDownTime.value < threshold) fn();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { useShortKeyPress };
|
|
19
|
+
//# sourceMappingURL=useShortKeyPress.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShortKeyPress.mjs","names":[],"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":";;;;AAKA,SAAgB,iBACf,KACA,IACA,EACC,SAAS,MACT,YAAY,KACZ,WAAW,SAMX;CACD,MAAM,cAAc,IAAmB,KAAK;AAE5C,WACC,WACM;AACL,MAAI,MAAM,SAAS,CAAE;AAErB,cAAY,QAAQ,KAAK,KAAK;IAE/B,EACC,QACA,CACD;AAED,SAAQ,WAAW;AAClB,MAAI,MAAM,SAAS,IAAI,CAAC,YAAY,MAAO;AAG3C,MADqB,KAAK,KAAK,GAAG,YAAY,QAAQ,UAErD,KAAI;GAEJ"}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
let __vueuse_core = require("@vueuse/core");
|
|
3
|
+
|
|
4
|
+
//#region src/useThrottleWithReactiveDelay.ts
|
|
5
|
+
/**
|
|
6
|
+
* Similar to `useThrottle` from @vueuse/core, but with changeable delay
|
|
7
|
+
*/
|
|
4
8
|
function useThrottleWithReactiveDelay(state, delay) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
throttled.value = latest;
|
|
11
|
-
},
|
|
12
|
-
delay,
|
|
13
|
-
true,
|
|
14
|
-
true
|
|
15
|
-
),
|
|
16
|
-
{ immediate: true }
|
|
17
|
-
);
|
|
18
|
-
return throttled;
|
|
9
|
+
const throttled = (0, vue.shallowRef)(state.value);
|
|
10
|
+
(0, vue.watch)(state, (0, __vueuse_core.useThrottleFn)((latest) => {
|
|
11
|
+
throttled.value = latest;
|
|
12
|
+
}, delay, true, true), { immediate: true });
|
|
13
|
+
return throttled;
|
|
19
14
|
}
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
//#endregion
|
|
22
17
|
exports.useThrottleWithReactiveDelay = useThrottleWithReactiveDelay;
|
|
23
18
|
//# sourceMappingURL=useThrottleWithReactiveDelay.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useThrottleWithReactiveDelay.cjs","names":[],"sources":["../src/useThrottleWithReactiveDelay.ts"],"sourcesContent":["import { useThrottleFn } from '@vueuse/core';\nimport { shallowRef, watch, type Ref, type ShallowRef } from 'vue';\n\n/**\n * Similar to `useThrottle` from @vueuse/core, but with changeable delay\n */\nexport function useThrottleWithReactiveDelay<T>(state: Ref<T>, delay: Ref<number>): ShallowRef<T> {\n\tconst throttled = shallowRef(state.value);\n\n\twatch(\n\t\tstate,\n\t\tuseThrottleFn(\n\t\t\t(latest: T) => {\n\t\t\t\tthrottled.value = latest;\n\t\t\t},\n\t\t\tdelay,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t),\n\t\t{ immediate: true },\n\t);\n\n\treturn throttled;\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,6BAAgC,OAAe,OAAmC;CACjG,MAAM,gCAAuB,MAAM,MAAM;AAEzC,gBACC,yCAEE,WAAc;AACd,YAAU,QAAQ;IAEnB,OACA,MACA,KACA,EACD,EAAE,WAAW,MAAM,CACnB;AAED,QAAO"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Ref, ShallowRef } from
|
|
1
|
+
import { Ref, ShallowRef } from "vue";
|
|
2
2
|
|
|
3
|
+
//#region src/useThrottleWithReactiveDelay.d.ts
|
|
3
4
|
declare function useThrottleWithReactiveDelay<T>(state: Ref<T>, delay: Ref<number>): ShallowRef<T>;
|
|
4
|
-
|
|
5
|
+
//#endregion
|
|
5
6
|
export { useThrottleWithReactiveDelay };
|
|
7
|
+
//# sourceMappingURL=useThrottleWithReactiveDelay.d.cts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ref, ShallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/useThrottleWithReactiveDelay.d.ts
|
|
4
|
+
declare function useThrottleWithReactiveDelay<T>(state: Ref<T>, delay: Ref<number>): ShallowRef<T>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { useThrottleWithReactiveDelay };
|
|
7
|
+
//# sourceMappingURL=useThrottleWithReactiveDelay.d.mts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { shallowRef, watch } from "vue";
|
|
2
|
+
import { useThrottleFn } from "@vueuse/core";
|
|
3
|
+
|
|
4
|
+
//#region src/useThrottleWithReactiveDelay.ts
|
|
5
|
+
/**
|
|
6
|
+
* Similar to `useThrottle` from @vueuse/core, but with changeable delay
|
|
7
|
+
*/
|
|
8
|
+
function useThrottleWithReactiveDelay(state, delay) {
|
|
9
|
+
const throttled = shallowRef(state.value);
|
|
10
|
+
watch(state, useThrottleFn((latest) => {
|
|
11
|
+
throttled.value = latest;
|
|
12
|
+
}, delay, true, true), { immediate: true });
|
|
13
|
+
return throttled;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useThrottleWithReactiveDelay };
|
|
18
|
+
//# sourceMappingURL=useThrottleWithReactiveDelay.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThrottleWithReactiveDelay.mjs","names":[],"sources":["../src/useThrottleWithReactiveDelay.ts"],"sourcesContent":["import { useThrottleFn } from '@vueuse/core';\nimport { shallowRef, watch, type Ref, type ShallowRef } from 'vue';\n\n/**\n * Similar to `useThrottle` from @vueuse/core, but with changeable delay\n */\nexport function useThrottleWithReactiveDelay<T>(state: Ref<T>, delay: Ref<number>): ShallowRef<T> {\n\tconst throttled = shallowRef(state.value);\n\n\twatch(\n\t\tstate,\n\t\tuseThrottleFn(\n\t\t\t(latest: T) => {\n\t\t\t\tthrottled.value = latest;\n\t\t\t},\n\t\t\tdelay,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t),\n\t\t{ immediate: true },\n\t);\n\n\treturn throttled;\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,6BAAgC,OAAe,OAAmC;CACjG,MAAM,YAAY,WAAW,MAAM,MAAM;AAEzC,OACC,OACA,eACE,WAAc;AACd,YAAU,QAAQ;IAEnB,OACA,MACA,KACA,EACD,EAAE,WAAW,MAAM,CACnB;AAED,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/composables",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.13.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"LICENSE.md",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
],
|
|
10
10
|
"exports": {
|
|
11
11
|
"./*": {
|
|
12
|
-
"types": "./dist/*.d.
|
|
13
|
-
"import": "./dist/*.
|
|
12
|
+
"types": "./dist/*.d.mts",
|
|
13
|
+
"import": "./dist/*.mjs",
|
|
14
14
|
"require": "./dist/*.cjs"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"@vue/tsconfig": "^0.7.0",
|
|
23
23
|
"@vueuse/core": "^10.11.0",
|
|
24
24
|
"vue": "^3.5.13",
|
|
25
|
-
"
|
|
25
|
+
"tsdown": "^0.16.5",
|
|
26
26
|
"typescript": "5.9.2",
|
|
27
|
-
"vite": "
|
|
27
|
+
"vite": "npm:rolldown-vite@latest",
|
|
28
28
|
"vitest": "^3.1.3",
|
|
29
29
|
"vue-tsc": "^2.2.8",
|
|
30
30
|
"@n8n/eslint-config": "0.0.1",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"url": "git+https://github.com/n8n-io/n8n.git"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
|
-
"dev": "
|
|
50
|
-
"build": "
|
|
49
|
+
"dev": "tsdown --watch",
|
|
50
|
+
"build": "tsdown",
|
|
51
51
|
"preview": "vite preview",
|
|
52
52
|
"typecheck": "vue-tsc --noEmit",
|
|
53
53
|
"test": "vitest run",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
|
|
3
|
-
declare function useDeviceSupport(): {
|
|
4
|
-
userAgent: string;
|
|
5
|
-
isTouchDevice: boolean;
|
|
6
|
-
isAndroidOs: boolean;
|
|
7
|
-
isIOs: boolean;
|
|
8
|
-
isMacOs: boolean;
|
|
9
|
-
isMobileDevice: boolean;
|
|
10
|
-
controlKeyCode: string;
|
|
11
|
-
controlKeyText: vue.ComputedRef<"⌘" | "Ctrl">;
|
|
12
|
-
isCtrlKeyPressed: (e: MouseEvent | KeyboardEvent) => boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { useDeviceSupport };
|
package/dist/useDeviceSupport.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/useDeviceSupport.ts
|
|
2
|
-
import { computed, ref } from "vue";
|
|
3
|
-
function useDeviceSupport() {
|
|
4
|
-
const isTouchDevice = ref(
|
|
5
|
-
window.matchMedia("(any-pointer: coarse)").matches && !window.matchMedia("(any-pointer: fine)").matches
|
|
6
|
-
);
|
|
7
|
-
const userAgent = ref(navigator.userAgent.toLowerCase());
|
|
8
|
-
const isIOs = ref(
|
|
9
|
-
userAgent.value.includes("iphone") || userAgent.value.includes("ipad") || userAgent.value.includes("ipod")
|
|
10
|
-
);
|
|
11
|
-
const isAndroidOs = ref(userAgent.value.includes("android"));
|
|
12
|
-
const isMacOs = ref(userAgent.value.includes("macintosh") || isIOs.value);
|
|
13
|
-
const isMobileDevice = ref(isIOs.value || isAndroidOs.value);
|
|
14
|
-
const controlKeyCode = ref(isMacOs.value ? "Meta" : "Control");
|
|
15
|
-
const controlKeyText = computed(() => isMacOs.value ? "\u2318" : "Ctrl");
|
|
16
|
-
function isCtrlKeyPressed(e) {
|
|
17
|
-
if (isMacOs.value) {
|
|
18
|
-
return e.metaKey;
|
|
19
|
-
}
|
|
20
|
-
return e.ctrlKey;
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
userAgent: userAgent.value,
|
|
24
|
-
isTouchDevice: isTouchDevice.value,
|
|
25
|
-
isAndroidOs: isAndroidOs.value,
|
|
26
|
-
isIOs: isIOs.value,
|
|
27
|
-
isMacOs: isMacOs.value,
|
|
28
|
-
isMobileDevice: isMobileDevice.value,
|
|
29
|
-
controlKeyCode: controlKeyCode.value,
|
|
30
|
-
controlKeyText,
|
|
31
|
-
isCtrlKeyPressed
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
useDeviceSupport
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=useDeviceSupport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useDeviceSupport.ts"],"sourcesContent":["import { computed, ref } from 'vue';\n\nexport function useDeviceSupport() {\n\t/**\n\t * Check if the device is a touch device but exclude devices that have a fine pointer (mouse or track-pad)\n\t * - `fine` will check for an accurate pointing device. Examples include mice, touch-pads, and drawing styluses\n\t * - `coarse` will check for a pointing device of limited accuracy. Examples include touchscreens and motion-detection sensors\n\t * - `any-pointer` will check for the presence of any pointing device, if there are multiple of them\n\t */\n\tconst isTouchDevice = ref(\n\t\twindow.matchMedia('(any-pointer: coarse)').matches &&\n\t\t\t!window.matchMedia('(any-pointer: fine)').matches,\n\t);\n\tconst userAgent = ref(navigator.userAgent.toLowerCase());\n\n\tconst isIOs = ref(\n\t\tuserAgent.value.includes('iphone') ||\n\t\t\tuserAgent.value.includes('ipad') ||\n\t\t\tuserAgent.value.includes('ipod'),\n\t);\n\tconst isAndroidOs = ref(userAgent.value.includes('android'));\n\tconst isMacOs = ref(userAgent.value.includes('macintosh') || isIOs.value);\n\tconst isMobileDevice = ref(isIOs.value || isAndroidOs.value);\n\n\tconst controlKeyCode = ref(isMacOs.value ? 'Meta' : 'Control');\n\tconst controlKeyText = computed(() => (isMacOs.value ? '⌘' : 'Ctrl'));\n\n\tfunction isCtrlKeyPressed(e: MouseEvent | KeyboardEvent): boolean {\n\t\tif (isMacOs.value) {\n\t\t\treturn (e as KeyboardEvent).metaKey;\n\t\t}\n\t\treturn (e as KeyboardEvent).ctrlKey;\n\t}\n\n\treturn {\n\t\tuserAgent: userAgent.value,\n\t\tisTouchDevice: isTouchDevice.value,\n\t\tisAndroidOs: isAndroidOs.value,\n\t\tisIOs: isIOs.value,\n\t\tisMacOs: isMacOs.value,\n\t\tisMobileDevice: isMobileDevice.value,\n\t\tcontrolKeyCode: controlKeyCode.value,\n\t\tcontrolKeyText,\n\t\tisCtrlKeyPressed,\n\t};\n}\n"],"mappings":";AAAA,SAAS,UAAU,WAAW;AAEvB,SAAS,mBAAmB;AAOlC,QAAM,gBAAgB;AAAA,IACrB,OAAO,WAAW,uBAAuB,EAAE,WAC1C,CAAC,OAAO,WAAW,qBAAqB,EAAE;AAAA,EAC5C;AACA,QAAM,YAAY,IAAI,UAAU,UAAU,YAAY,CAAC;AAEvD,QAAM,QAAQ;AAAA,IACb,UAAU,MAAM,SAAS,QAAQ,KAChC,UAAU,MAAM,SAAS,MAAM,KAC/B,UAAU,MAAM,SAAS,MAAM;AAAA,EACjC;AACA,QAAM,cAAc,IAAI,UAAU,MAAM,SAAS,SAAS,CAAC;AAC3D,QAAM,UAAU,IAAI,UAAU,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK;AACxE,QAAM,iBAAiB,IAAI,MAAM,SAAS,YAAY,KAAK;AAE3D,QAAM,iBAAiB,IAAI,QAAQ,QAAQ,SAAS,SAAS;AAC7D,QAAM,iBAAiB,SAAS,MAAO,QAAQ,QAAQ,WAAM,MAAO;AAEpE,WAAS,iBAAiB,GAAwC;AACjE,QAAI,QAAQ,OAAO;AAClB,aAAQ,EAAoB;AAAA,IAC7B;AACA,WAAQ,EAAoB;AAAA,EAC7B;AAEA,SAAO;AAAA,IACN,WAAW,UAAU;AAAA,IACrB,eAAe,cAAc;AAAA,IAC7B,aAAa,YAAY;AAAA,IACzB,OAAO,MAAM;AAAA,IACb,SAAS,QAAQ;AAAA,IACjB,gBAAgB,eAAe;AAAA,IAC/B,gBAAgB,eAAe;AAAA,IAC/B;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|
package/dist/useShortKeyPress.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/useThrottleWithReactiveDelay.ts
|
|
2
|
-
import { useThrottleFn } from "@vueuse/core";
|
|
3
|
-
import { shallowRef, watch } from "vue";
|
|
4
|
-
function useThrottleWithReactiveDelay(state, delay) {
|
|
5
|
-
const throttled = shallowRef(state.value);
|
|
6
|
-
watch(
|
|
7
|
-
state,
|
|
8
|
-
useThrottleFn(
|
|
9
|
-
(latest) => {
|
|
10
|
-
throttled.value = latest;
|
|
11
|
-
},
|
|
12
|
-
delay,
|
|
13
|
-
true,
|
|
14
|
-
true
|
|
15
|
-
),
|
|
16
|
-
{ immediate: true }
|
|
17
|
-
);
|
|
18
|
-
return throttled;
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
useThrottleWithReactiveDelay
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=useThrottleWithReactiveDelay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useThrottleWithReactiveDelay.ts"],"sourcesContent":["import { useThrottleFn } from '@vueuse/core';\nimport { shallowRef, watch, type Ref, type ShallowRef } from 'vue';\n\n/**\n * Similar to `useThrottle` from @vueuse/core, but with changeable delay\n */\nexport function useThrottleWithReactiveDelay<T>(state: Ref<T>, delay: Ref<number>): ShallowRef<T> {\n\tconst throttled = shallowRef(state.value);\n\n\twatch(\n\t\tstate,\n\t\tuseThrottleFn(\n\t\t\t(latest: T) => {\n\t\t\t\tthrottled.value = latest;\n\t\t\t},\n\t\t\tdelay,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t),\n\t\t{ immediate: true },\n\t);\n\n\treturn throttled;\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,YAAY,aAAwC;AAKtD,SAAS,6BAAgC,OAAe,OAAmC;AACjG,QAAM,YAAY,WAAW,MAAM,KAAK;AAExC;AAAA,IACC;AAAA,IACA;AAAA,MACC,CAAC,WAAc;AACd,kBAAU,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACnB;AAEA,SAAO;AACR;","names":[]}
|