From dbbc9136935845ae2eb13e97fdcd0b1e03903aab Mon Sep 17 00:00:00 2001 From: IlyaL Date: Fri, 25 Jul 2025 00:56:54 +0800 Subject: [PATCH 01/53] refactor(UseActiveElement): add props --- packages/core/useActiveElement/component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/core/useActiveElement/component.ts b/packages/core/useActiveElement/component.ts index 0399dd8626b..b62909ac88e 100644 --- a/packages/core/useActiveElement/component.ts +++ b/packages/core/useActiveElement/component.ts @@ -1,11 +1,18 @@ -import { useActiveElement } from '@vueuse/core' +import type { UseActiveElementOptions } from './index' import { defineComponent, reactive } from 'vue' +import { useActiveElement } from './index' -export const UseActiveElement = /* #__PURE__ */ defineComponent({ +export const UseActiveElement = /* #__PURE__ */ defineComponent({ name: 'UseActiveElement', + props: [ + 'deep', + 'triggerOnRemoval', + 'window', + 'document', + ] as unknown as undefined, setup(props, { slots }) { const data = reactive({ - element: useActiveElement(), + element: useActiveElement(props), }) return () => { From 61a484ff22db575bcbae719d65668cedc96a185c Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 18:14:44 +0800 Subject: [PATCH 02/53] refactor(UseBattery): enhance component with props and slots support --- packages/core/useBattery/component.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/core/useBattery/component.ts b/packages/core/useBattery/component.ts index beaadb602ef..bf9fd3f293f 100644 --- a/packages/core/useBattery/component.ts +++ b/packages/core/useBattery/component.ts @@ -1,9 +1,21 @@ +import type { UseBatteryReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' +import type { ConfigurableNavigator } from '../_configurable' import { useBattery } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseBattery = /* #__PURE__ */ defineComponent({ - name: 'UseBattery', - setup(props, { slots }) { +export interface UseBatteryProps extends ConfigurableNavigator {} +interface UseBatterySlots { + default: (data: Reactive) => any +} + +export const UseBattery = /* #__PURE__ */ defineComponent< + UseBatteryProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const data = reactive(useBattery(props)) return () => { @@ -11,4 +23,8 @@ export const UseBattery = /* #__PURE__ */ defineComponent({ return slots.default(data) } }, -}) + { + name: 'UseBattery', + props: ['navigator'], + }, +) From 5d186009fc5b07ee08146548faedea446f92ddec Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 18:38:56 +0800 Subject: [PATCH 03/53] refactor(UseBrowserLocation): add props and slots support --- packages/core/useBrowserLocation/component.ts | 25 +++++++++++++++---- packages/core/useBrowserLocation/index.md | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/core/useBrowserLocation/component.ts b/packages/core/useBrowserLocation/component.ts index 3c62a8a70f5..8eb8cb3a700 100644 --- a/packages/core/useBrowserLocation/component.ts +++ b/packages/core/useBrowserLocation/component.ts @@ -1,14 +1,29 @@ +import type { ConfigurableWindow, UseBrowserLocationReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useBrowserLocation } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseBrowserLocation = /* #__PURE__ */ defineComponent({ - name: 'UseBrowserLocation', - setup(props, { slots }) { - const data = reactive(useBrowserLocation()) +interface UseBrowserLocationProps extends ConfigurableWindow {} +interface UseBrowserLocationSlots { + default: (data: Reactive) => any +} + +export const UseBrowserLocation = /* #__PURE__ */ defineComponent< + UseBrowserLocationProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { + const data = reactive(useBrowserLocation(props)) return () => { if (slots.default) return slots.default(data) } }, -}) + { + name: 'UseBrowserLocation', + props: ['window'], + }, +) diff --git a/packages/core/useBrowserLocation/index.md b/packages/core/useBrowserLocation/index.md index 3ae85f35178..8338f229f46 100644 --- a/packages/core/useBrowserLocation/index.md +++ b/packages/core/useBrowserLocation/index.md @@ -19,7 +19,7 @@ const location = useBrowserLocation() ## Component Usage ```vue - + Browser Location: {{ location }} ``` From bd21313dd15b66698f519e1ff79d1042e8c6c308 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 18:54:36 +0800 Subject: [PATCH 04/53] refactor(UseClipboard): enhance component with props and slots support --- packages/core/useClipboard/component.ts | 43 ++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/packages/core/useClipboard/component.ts b/packages/core/useClipboard/component.ts index fc00627da54..dcf086c489f 100644 --- a/packages/core/useClipboard/component.ts +++ b/packages/core/useClipboard/component.ts @@ -1,22 +1,35 @@ -import type { UseClipboardOptions } from '@vueuse/core' +import type { UseClipboardOptions, UseClipboardReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useClipboard } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -interface UseClipboardProps extends UseClipboardOptions {} +export interface UseClipboardProps extends UseClipboardOptions {} +interface UseClipboardSlots { + default: (data: Reactive>) => any +} -export const UseClipboard = /* #__PURE__ */ defineComponent({ - name: 'UseClipboard', - props: [ - 'source', - 'read', - 'navigator', - 'copiedDuring', - 'legacy', - ] as unknown as undefined, - - setup(props, { slots }) { +export const UseClipboard = /* #__PURE__ */ defineComponent< + UseClipboardProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const data = reactive(useClipboard(props)) - return () => slots.default?.(data) + return () => { + if (slots.default) + return slots.default(data) + } + }, + { + name: 'UseClipboard', + props: [ + 'source', + 'read', + 'navigator', + 'copiedDuring', + 'legacy', + ], }, -}) +) From 6fd03a7d0beca10c0bd0dac6148c5f4ca3786ffb Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 19:25:03 +0800 Subject: [PATCH 05/53] refactor(OnClickOutside): enhance component with explicit emits type definition --- packages/core/onClickOutside/component.ts | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/core/onClickOutside/component.ts b/packages/core/onClickOutside/component.ts index acd72d59fd1..1a0cd6f9ad1 100644 --- a/packages/core/onClickOutside/component.ts +++ b/packages/core/onClickOutside/component.ts @@ -1,17 +1,20 @@ -import type { RenderableComponent } from '../types' -import type { OnClickOutsideOptions } from './index' +import type { OnClickOutsideOptions, RenderableComponent } from '@vueuse/core' import { onClickOutside } from '@vueuse/core' import { defineComponent, h, shallowRef } from 'vue' export interface OnClickOutsideProps extends RenderableComponent { options?: Omit } +// eslint-disable-next-line ts/consistent-type-definitions +export type OnClickOutsideEmits = { + trigger: (event: Event) => void +} -export const OnClickOutside = /* #__PURE__ */ defineComponent({ - name: 'OnClickOutside', - props: ['as', 'options'] as unknown as undefined, - emits: ['trigger'], - setup(props, { slots, emit }) { +export const OnClickOutside = /* #__PURE__ */ defineComponent< + OnClickOutsideProps, + OnClickOutsideEmits +>( + (props, { slots, emit }) => { const target = shallowRef() onClickOutside(target, (e) => { emit('trigger', e) @@ -22,4 +25,9 @@ export const OnClickOutside = /* #__PURE__ */ defineComponent Date: Sun, 27 Jul 2025 19:40:11 +0800 Subject: [PATCH 06/53] refactor(OnLongPress): add explicit emits type definition --- packages/core/onLongPress/component.ts | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/core/onLongPress/component.ts b/packages/core/onLongPress/component.ts index 561528bfed4..a3e5d535ceb 100644 --- a/packages/core/onLongPress/component.ts +++ b/packages/core/onLongPress/component.ts @@ -1,17 +1,20 @@ -import type { RenderableComponent } from '../types' -import type { OnLongPressOptions } from './index' +import type { OnLongPressOptions, RenderableComponent } from '@vueuse/core' +import { onLongPress } from '@vueuse/core' import { defineComponent, h, shallowRef } from 'vue' -import { onLongPress } from './index' export interface OnLongPressProps extends RenderableComponent { options?: OnLongPressOptions } +// eslint-disable-next-line ts/consistent-type-definitions +export type OnLongPressEmits = { + trigger: (event: PointerEvent) => void +} -export const OnLongPress = /* #__PURE__ */ defineComponent({ - name: 'OnLongPress', - props: ['as', 'options'] as unknown as undefined, - emits: ['trigger'], - setup(props, { slots, emit }) { +export const OnLongPress = /* #__PURE__ */ defineComponent< + OnLongPressProps, + OnLongPressEmits +>( + (props, { slots, emit }) => { const target = shallowRef() onLongPress( target, @@ -20,9 +23,15 @@ export const OnLongPress = /* #__PURE__ */ defineComponent({ }, props.options, ) + return () => { if (slots.default) return h(props.as || 'div', { ref: target }, slots.default()) } }, -}) + { + name: 'OnLongPress', + props: ['as', 'options'], + emits: ['trigger'], + }, +) From 4497e702f31ded019a84310813e3f154424fb916 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 19:53:03 +0800 Subject: [PATCH 07/53] refactor(UseActiveElement): enhance component with slots support --- packages/core/useActiveElement/component.ts | 37 ++++++++++++++------- packages/core/useActiveElement/index.md | 2 +- packages/core/useActiveElement/index.ts | 2 ++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/packages/core/useActiveElement/component.ts b/packages/core/useActiveElement/component.ts index b62909ac88e..0ddaeb74576 100644 --- a/packages/core/useActiveElement/component.ts +++ b/packages/core/useActiveElement/component.ts @@ -1,16 +1,20 @@ -import type { UseActiveElementOptions } from './index' +import type { UseActiveElementOptions, UseActiveElementReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' +import { useActiveElement } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -import { useActiveElement } from './index' -export const UseActiveElement = /* #__PURE__ */ defineComponent({ - name: 'UseActiveElement', - props: [ - 'deep', - 'triggerOnRemoval', - 'window', - 'document', - ] as unknown as undefined, - setup(props, { slots }) { +export interface UseActiveElementProps extends UseActiveElementOptions {} +interface UseActiveElementSlots { + default: (data: Reactive<{ element: UseActiveElementReturn }>) => any +} + +export const UseActiveElement = /* #__PURE__ */ defineComponent< + UseActiveElementProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const data = reactive({ element: useActiveElement(props), }) @@ -20,4 +24,13 @@ export const UseActiveElement = /* #__PURE__ */ defineComponent { ```vue ``` diff --git a/packages/core/useActiveElement/index.ts b/packages/core/useActiveElement/index.ts index 4b633483aa2..a74e08cc936 100644 --- a/packages/core/useActiveElement/index.ts +++ b/packages/core/useActiveElement/index.ts @@ -81,3 +81,5 @@ export function useActiveElement( return activeElement } + +export type UseActiveElementReturn = ReturnType From 743a7d6ff90b95fcf87af9bde7ddc4c64929c1a6 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 20:57:53 +0800 Subject: [PATCH 08/53] refactor(UseColorMode): enhance component with props and slots support --- packages/core/useColorMode/component.ts | 53 +++++++++++++++++++++---- packages/core/useColorMode/index.md | 6 +-- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/packages/core/useColorMode/component.ts b/packages/core/useColorMode/component.ts index d1d18a98be3..f2f277a91f0 100644 --- a/packages/core/useColorMode/component.ts +++ b/packages/core/useColorMode/component.ts @@ -1,11 +1,24 @@ -import type { UseColorModeOptions } from './index' +import type { BasicColorMode, UseColorModeOptions, UseColorModeReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' +import { useColorMode } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -import { useColorMode } from './index' -export const UseColorMode = /* #__PURE__ */ defineComponent({ - name: 'UseColorMode', - props: ['selector', 'attribute', 'modes', 'onChanged', 'storageKey', 'storage', 'emitAuto'] as unknown as undefined, - setup(props, { slots }) { +export interface UseColorModeProps extends UseColorModeOptions {} +interface UseColorModeSlots { + default: (data: Reactive<{ + mode: UseColorModeReturn + system: UseColorModeReturn['system'] + store: UseColorModeReturn['store'] + }>) => any +} + +export const UseColorMode = /* #__PURE__ */ defineComponent< + UseColorModeProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const mode = useColorMode(props) const data = reactive({ mode, @@ -18,4 +31,30 @@ export const UseColorMode = /* #__PURE__ */ defineComponent return slots.default(data) } }, -}) + { + name: 'UseColorMode', + props: [ + 'attribute', + 'deep', + 'disableTransition', + 'emitAuto', + 'eventFilter', + 'flush', + 'initOnMounted', + 'initialValue', + 'listenToStorageChanges', + 'mergeDefaults', + 'modes', + 'onChanged', + 'onError', + 'selector', + 'serializer', + 'shallow', + 'storage', + 'storageKey', + 'storageRef', + 'window', + 'writeDefaults', + ], + }, +) diff --git a/packages/core/useColorMode/index.md b/packages/core/useColorMode/index.md index 37834050076..8fc1c932d7d 100644 --- a/packages/core/useColorMode/index.md +++ b/packages/core/useColorMode/index.md @@ -62,9 +62,9 @@ const myColorMode = computed(() => store.value === 'auto' ? system.value : store ```vue From 705dbfdc7140bf12a78494bea094901b090bc710 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 21:22:54 +0800 Subject: [PATCH 09/53] refactor(UseDark): enhance component with extended props and slots support --- packages/core/useDark/component.ts | 52 ++++++++++++++++++++++++++---- packages/core/useDark/index.ts | 2 ++ packages/shared/useToggle/index.ts | 2 +- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/packages/core/useDark/component.ts b/packages/core/useDark/component.ts index fb822f6e966..b18a219217c 100644 --- a/packages/core/useDark/component.ts +++ b/packages/core/useDark/component.ts @@ -1,12 +1,25 @@ -import type { UseDarkOptions } from '@vueuse/core' +import type { UseDarkOptions, UseDarkReturn } from '@vueuse/core' +import type { ToggleFn } from '@vueuse/shared' +import type { Reactive, SlotsType } from 'vue' import { useDark } from '@vueuse/core' import { useToggle } from '@vueuse/shared' import { defineComponent, reactive } from 'vue' -export const UseDark = /* #__PURE__ */ defineComponent({ - name: 'UseDark', - props: ['selector', 'attribute', 'valueDark', 'valueLight', 'onChanged', 'storageKey', 'storage'] as unknown as undefined, - setup(props, { slots }) { +export interface UseDarkProps extends UseDarkOptions {} +interface UseDarkSlots { + default: (data: Reactive<{ + isDark: UseDarkReturn + toggleDark: ToggleFn + }>) => any +} + +export const UseDark = /* #__PURE__ */ defineComponent< + UseDarkProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const isDark = useDark(props) const data = reactive({ isDark, @@ -18,4 +31,31 @@ export const UseDark = /* #__PURE__ */ defineComponent({ return slots.default(data) } }, -}) + { + name: 'UseDark', + props: [ + 'attribute', + 'deep', + 'disableTransition', + 'emitAuto', + 'eventFilter', + 'flush', + 'initOnMounted', + 'initialValue', + 'listenToStorageChanges', + 'mergeDefaults', + 'onChanged', + 'onError', + 'selector', + 'serializer', + 'shallow', + 'storage', + 'storageKey', + 'storageRef', + 'valueDark', + 'valueLight', + 'window', + 'writeDefaults', + ], + }, +) diff --git a/packages/core/useDark/index.ts b/packages/core/useDark/index.ts index 3539825f301..6e2e60f4acf 100644 --- a/packages/core/useDark/index.ts +++ b/packages/core/useDark/index.ts @@ -69,3 +69,5 @@ export function useDark(options: UseDarkOptions = {}) { return isDark } + +export type UseDarkReturn = ReturnType diff --git a/packages/shared/useToggle/index.ts b/packages/shared/useToggle/index.ts index 907f908e693..afab1b8c1fa 100644 --- a/packages/shared/useToggle/index.ts +++ b/packages/shared/useToggle/index.ts @@ -1,7 +1,7 @@ import type { MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue' import { isRef, shallowRef, toValue } from 'vue' -type ToggleFn = (value?: boolean) => void +export type ToggleFn = (value?: boolean) => void export type UseToggleReturn = [ShallowRef, ToggleFn] | ToggleFn From 5b1a3830cbff13bde9f98f6b0193d12601ced456 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 21:32:21 +0800 Subject: [PATCH 10/53] refactor(UseDeviceMotion): enhance component with extended props and slots support --- packages/core/useDeviceMotion/component.ts | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/core/useDeviceMotion/component.ts b/packages/core/useDeviceMotion/component.ts index 1d7adc8455c..30c8b3b794f 100644 --- a/packages/core/useDeviceMotion/component.ts +++ b/packages/core/useDeviceMotion/component.ts @@ -1,14 +1,33 @@ +import type { DeviceMotionOptions, UseDeviceMotionReturn } from '@vueuse/core' +import type { SlotsType } from 'vue' import { useDeviceMotion } from '@vueuse/core' import { defineComponent } from 'vue' -export const UseDeviceMotion = /* #__PURE__ */ defineComponent({ - name: 'UseDeviceMotion', - setup(props, { slots }) { - const data = useDeviceMotion() +export interface UseDeviceMotionProps extends DeviceMotionOptions {} +interface UseDeviceMotionSlots { + default: (data: UseDeviceMotionReturn) => any +} + +export const UseDeviceMotion = /* #__PURE__ */ defineComponent< + UseDeviceMotionProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { + const data = useDeviceMotion(props) return () => { if (slots.default) return slots.default(data) } }, -}) + { + name: 'UseDeviceMotion', + props: [ + 'eventFilter', + 'requestPermissions', + 'window', + ], + }, +) From e862a6c40a71fe534bde409903ba5f6bacc3c359 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 21:36:57 +0800 Subject: [PATCH 11/53] refactor(UseDeviceOrientation): enhance component with extended props and slots support --- .../core/useDeviceOrientation/component.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/core/useDeviceOrientation/component.ts b/packages/core/useDeviceOrientation/component.ts index 5ccf58622e6..58b52cb8fc1 100644 --- a/packages/core/useDeviceOrientation/component.ts +++ b/packages/core/useDeviceOrientation/component.ts @@ -1,14 +1,29 @@ +import type { ConfigurableWindow, UseDeviceOrientationReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useDeviceOrientation } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseDeviceOrientation = /* #__PURE__ */ defineComponent({ - name: 'UseDeviceOrientation', - setup(props, { slots }) { - const data = reactive(useDeviceOrientation()) +export interface UseDeviceOrientationProps extends ConfigurableWindow {} +interface UseDeviceOrientationSlots { + default: (data: Reactive) => any +} + +export const UseDeviceOrientation = /* #__PURE__ */ defineComponent< + UseDeviceOrientationProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { + const data = reactive(useDeviceOrientation(props)) return () => { if (slots.default) return slots.default(data) } }, -}) + { + name: 'UseDeviceOrientation', + props: ['window'], + }, +) From e5ecaee570daf166b3a3dfdb8236ca9a823fbc32 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 21:48:42 +0800 Subject: [PATCH 12/53] refactor(UseDevicePixelRatio): enhance component with extended props and slots support --- .../core/useDevicePixelRatio/component.ts | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/core/useDevicePixelRatio/component.ts b/packages/core/useDevicePixelRatio/component.ts index 51114a08a14..c5c22f0dfe5 100644 --- a/packages/core/useDevicePixelRatio/component.ts +++ b/packages/core/useDevicePixelRatio/component.ts @@ -1,16 +1,29 @@ +import type { ConfigurableWindow, UseDevicePixelRatioReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useDevicePixelRatio } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseDevicePixelRatio = /* #__PURE__ */ defineComponent({ - name: 'UseDevicePixelRatio', - setup(props, { slots }) { - const data = reactive({ - pixelRatio: useDevicePixelRatio(), - }) +export interface UseDevicePixelRatioProps extends ConfigurableWindow {} +interface UseDevicePixelRatioSlots { + default: (data: Reactive) => any +} + +export const UseDevicePixelRatio = /* #__PURE__ */ defineComponent< + UseDevicePixelRatioProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { + const data = reactive(useDevicePixelRatio(props)) return () => { if (slots.default) return slots.default(data) } }, -}) + { + name: 'UseDevicePixelRatio', + props: ['window'], + }, +) From 13161edabfb18e61b7420c354bcabbac339c9c73 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 21:54:36 +0800 Subject: [PATCH 13/53] refactor(UseDevicesList): enhance component with extended props and slots support --- packages/core/useDevicesList/component.ts | 30 ++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/core/useDevicesList/component.ts b/packages/core/useDevicesList/component.ts index da449e9c48a..ac0667df128 100644 --- a/packages/core/useDevicesList/component.ts +++ b/packages/core/useDevicesList/component.ts @@ -1,11 +1,20 @@ -import type { UseDevicesListOptions } from '@vueuse/core' +import type { UseDevicesListOptions, UseDevicesListReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useDevicesList } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseDevicesList = /* #__PURE__ */ defineComponent({ - name: 'UseDevicesList', - props: ['onUpdated', 'requestPermissions', 'constraints'] as unknown as undefined, - setup(props, { slots }) { +export interface UseDevicesListProps extends UseDevicesListOptions {} +interface UseDevicesListSlots { + default: (data: Reactive) => any +} + +export const UseDevicesList = /* #__PURE__ */ defineComponent< + UseDevicesListProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const data = reactive(useDevicesList(props)) return () => { @@ -13,4 +22,13 @@ export const UseDevicesList = /* #__PURE__ */ defineComponent Date: Sun, 27 Jul 2025 22:08:34 +0800 Subject: [PATCH 14/53] refactor(UseDocumentVisibility): enhance component with props and slots support --- .../core/useDocumentVisibility/component.ts | 27 +++++++++++++++---- packages/core/useDocumentVisibility/index.ts | 5 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/core/useDocumentVisibility/component.ts b/packages/core/useDocumentVisibility/component.ts index 855edfade58..3f96df87daa 100644 --- a/packages/core/useDocumentVisibility/component.ts +++ b/packages/core/useDocumentVisibility/component.ts @@ -1,11 +1,24 @@ +import type { ConfigurableDocument, UseDocumentVisibilityReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useDocumentVisibility } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseDocumentVisibility = /* #__PURE__ */ defineComponent({ - name: 'UseDocumentVisibility', - setup(props, { slots }) { +export interface UseDocumentVisibilityProps extends ConfigurableDocument {} +interface UseDocumentVisibilitySlots { + default: (data: Reactive<{ + visibility: UseDocumentVisibilityReturn + }>) => any +} + +export const UseDocumentVisibility = /* #__PURE__ */ defineComponent< + UseDocumentVisibilityProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const data = reactive({ - visibility: useDocumentVisibility(), + visibility: useDocumentVisibility(props), }) return () => { @@ -13,4 +26,8 @@ export const UseDocumentVisibility = /* #__PURE__ */ defineComponent({ return slots.default(data) } }, -}) + { + name: 'UseDocumentVisibility', + props: ['document'], + }, +) diff --git a/packages/core/useDocumentVisibility/index.ts b/packages/core/useDocumentVisibility/index.ts index 3792de15584..a67c56c41b9 100644 --- a/packages/core/useDocumentVisibility/index.ts +++ b/packages/core/useDocumentVisibility/index.ts @@ -1,4 +1,3 @@ -import type { ShallowRef } from 'vue' import type { ConfigurableDocument } from '../_configurable' import { shallowRef } from 'vue' import { defaultDocument } from '../_configurable' @@ -9,7 +8,7 @@ import { useEventListener } from '../useEventListener' * * @see https://vueuse.org/useDocumentVisibility */ -export function useDocumentVisibility(options: ConfigurableDocument = {}): ShallowRef { +export function useDocumentVisibility(options: ConfigurableDocument = {}) { const { document = defaultDocument } = options if (!document) return shallowRef('visible') @@ -22,3 +21,5 @@ export function useDocumentVisibility(options: ConfigurableDocument = {}): Shall return visibility } + +export type UseDocumentVisibilityReturn = ReturnType From bc6ed23368900488518b73e6d3c6da6fc98c96a1 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 22:39:57 +0800 Subject: [PATCH 15/53] refactor(UseElementBounding): enhance component with extended props and slots support --- packages/core/useElementBounding/component.ts | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/core/useElementBounding/component.ts b/packages/core/useElementBounding/component.ts index 6451b141036..b2a046e9520 100644 --- a/packages/core/useElementBounding/component.ts +++ b/packages/core/useElementBounding/component.ts @@ -1,18 +1,37 @@ -import type { RenderableComponent } from '../types' -import type { UseResizeObserverOptions } from '../useResizeObserver' +import type { RenderableComponent, UseElementBoundingOptions, UseElementBoundingReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useElementBounding } from '@vueuse/core' import { defineComponent, h, reactive, shallowRef } from 'vue' -export const UseElementBounding = /* #__PURE__ */ defineComponent({ - name: 'UseElementBounding', - props: ['box', 'as'] as unknown as undefined, - setup(props, { slots }) { +export interface UseElementBoundingProps extends UseElementBoundingOptions, RenderableComponent {} +interface UseElementBoundingSlots { + default: (data: Reactive) => any +} + +export const UseElementBounding = /* #__PURE__ */ defineComponent< + UseElementBoundingProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const target = shallowRef() - const data = reactive(useElementBounding(target)) + const data = reactive(useElementBounding(target, props)) return () => { if (slots.default) return h(props.as || 'div', { ref: target }, slots.default(data)) } }, -}) + { + name: 'UseElementBounding', + props: [ + 'as', + 'immediate', + 'reset', + 'updateTiming', + 'windowResize', + 'windowScroll', + ], + }, +) From e80ba773f77bf04ee6752196f2ad0f67ad1a6964 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 23:00:30 +0800 Subject: [PATCH 16/53] refactor(UseElementSize): enhance component with extended props and slots support --- packages/core/useElementSize/component.ts | 41 +++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/core/useElementSize/component.ts b/packages/core/useElementSize/component.ts index f7aa05dff3c..4bf051cd86c 100644 --- a/packages/core/useElementSize/component.ts +++ b/packages/core/useElementSize/component.ts @@ -1,19 +1,40 @@ -import type { ElementSize } from '@vueuse/core' -import type { RenderableComponent } from '../types' -import type { UseResizeObserverOptions } from '../useResizeObserver' +import type { ElementSize, RenderableComponent, UseElementSizeReturn, UseResizeObserverOptions } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useElementSize } from '@vueuse/core' -import { defineComponent, h, reactive, shallowRef } from 'vue' +import { defineComponent, h, reactive, shallowRef, toRefs, toValue } from 'vue' -export const UseElementSize = /* #__PURE__ */ defineComponent & UseResizeObserverOptions & RenderableComponent>({ - name: 'UseElementSize', - props: ['width', 'height', 'box', 'as'] as unknown as undefined, - setup(props, { slots }) { +export interface UseElementSizeProps extends Partial, UseResizeObserverOptions, RenderableComponent {} +interface UseElementSizeSlots { + default: (data: Reactive) => any +} + +export const UseElementSize = /* #__PURE__ */ defineComponent< + UseElementSizeProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const target = shallowRef() - const data = reactive(useElementSize(target, { width: props.width ?? 0, height: props.height ?? 0 }, { box: props.box })) + const { width, height } = toRefs(props) + const data = reactive(useElementSize(target, { width: toValue(width) ?? 0, height: toValue(height) ?? 0 }, { + box: props.box, + window: props.window, + })) return () => { if (slots.default) return h(props.as || 'div', { ref: target }, slots.default(data)) } }, -}) + { + name: 'UseElementSize', + props: [ + 'as', + 'box', + 'height', + 'width', + 'window', + ], + }, +) From 5801189191befc7ec0b23b699cb7c50318e2c290 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 23:05:16 +0800 Subject: [PATCH 17/53] refactor(UseElementVisibility): enhance component with extended props and slots support --- .../core/useElementVisibility/component.ts | 36 +++++++++++++++---- packages/core/useElementVisibility/index.ts | 2 ++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/packages/core/useElementVisibility/component.ts b/packages/core/useElementVisibility/component.ts index be0691dcc83..e023ecc3baa 100644 --- a/packages/core/useElementVisibility/component.ts +++ b/packages/core/useElementVisibility/component.ts @@ -1,14 +1,25 @@ -import type { RenderableComponent } from '../types' +import type { RenderableComponent, UseElementVisibilityOptions, UseElementVisibilityReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useElementVisibility } from '@vueuse/core' import { defineComponent, h, reactive, shallowRef } from 'vue' -export const UseElementVisibility = /* #__PURE__ */ defineComponent({ - name: 'UseElementVisibility', - props: ['as'] as unknown as undefined, - setup(props, { slots }) { +export interface UseElementVisibilityProps extends UseElementVisibilityOptions, RenderableComponent {} +interface UseElementVisibilitySlots { + default: (data: Reactive<{ + isVisible: UseElementVisibilityReturn + }>) => any +} + +export const UseElementVisibility = /* #__PURE__ */ defineComponent< + UseElementVisibilityProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { const target = shallowRef() const data = reactive({ - isVisible: useElementVisibility(target), + isVisible: useElementVisibility(target, props), }) return () => { @@ -16,4 +27,15 @@ export const UseElementVisibility = /* #__PURE__ */ defineComponent From 541294e0b9859e74a3057e244bcef9307a3af20e Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sun, 27 Jul 2025 23:31:47 +0800 Subject: [PATCH 18/53] refactor(UseEyeDropper): enhance component with extended props and slots support --- packages/core/useEyeDropper/component.ts | 28 +++++++++++++++++------- packages/core/useEyeDropper/index.md | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/core/useEyeDropper/component.ts b/packages/core/useEyeDropper/component.ts index 45d78a3daa7..14fc288fa02 100644 --- a/packages/core/useEyeDropper/component.ts +++ b/packages/core/useEyeDropper/component.ts @@ -1,17 +1,29 @@ +import type { UseEyeDropperOptions, UseEyeDropperReturn } from '@vueuse/core' +import type { Reactive, SlotsType } from 'vue' import { useEyeDropper } from '@vueuse/core' import { defineComponent, reactive } from 'vue' -export const UseEyeDropper = /* #__PURE__ */ defineComponent({ - name: 'UseEyeDropper', - props: { - sRGBHex: String, - }, - setup(props, { slots }) { - const data = reactive(useEyeDropper()) +export interface UseEyeDropperProps extends UseEyeDropperOptions {} +interface UseEyeDropperSlots { + default: (data: Reactive) => any +} + +export const UseEyeDropper = /* #__PURE__ */ defineComponent< + UseEyeDropperProps, + Record, + string, + SlotsType +>( + (props, { slots }) => { + const data = reactive(useEyeDropper(props)) return () => { if (slots.default) return slots.default(data) } }, -}) + { + name: 'UseEyeDropper', + props: ['initialValue'], + }, +) diff --git a/packages/core/useEyeDropper/index.md b/packages/core/useEyeDropper/index.md index 1dfacc4823d..e4ea52c4e2d 100644 --- a/packages/core/useEyeDropper/index.md +++ b/packages/core/useEyeDropper/index.md @@ -19,7 +19,7 @@ const { isSupported, open, sRGBHex } = useEyeDropper() ```vue