Skip to content

Commit 6305838

Browse files
committed
refactor(UseGeolocation): enhance component with extended props and slots support
1 parent 79c8924 commit 6305838

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1-
import type { UseGeolocationOptions } from '@vueuse/core'
1+
import type { UseGeolocationOptions, UseGeolocationReturn } from '@vueuse/core'
2+
import type { Reactive, SlotsType } from 'vue'
23
import { useGeolocation } from '@vueuse/core'
34
import { defineComponent, reactive } from 'vue'
45

5-
export const UseGeolocation = /* #__PURE__ */ defineComponent<UseGeolocationOptions>({
6-
name: 'UseGeolocation',
7-
props: ['enableHighAccuracy', 'maximumAge', 'timeout', 'navigator'] as unknown as undefined,
8-
setup(props, { slots }) {
6+
export interface UseGeolocationProps extends UseGeolocationOptions {}
7+
interface UseGeolocationSlots {
8+
default: (data: Reactive<UseGeolocationReturn>) => any
9+
}
10+
11+
export const UseGeolocation = /* #__PURE__ */ defineComponent<
12+
UseGeolocationProps,
13+
Record<string, never>,
14+
string,
15+
SlotsType<UseGeolocationSlots>
16+
>(
17+
(props, { slots }) => {
918
const data = reactive(useGeolocation(props))
19+
1020
return () => {
1121
if (slots.default)
1222
return slots.default(data)
1323
}
1424
},
15-
})
25+
{
26+
name: 'UseGeolocation',
27+
props: [
28+
'enableHighAccuracy',
29+
'immediate',
30+
'maximumAge',
31+
'navigator',
32+
'timeout',
33+
],
34+
},
35+
)

0 commit comments

Comments
 (0)