11<script setup lang="ts">
2- import type { DocksContext } from ' ../state/dock '
2+ import type { DocksContext } from ' @vitejs/devtools-kit/client '
33import { useEventListener , useScreenSafeArea } from ' @vueuse/core'
44import { computed , onMounted , reactive , ref , useTemplateRef , watchEffect } from ' vue'
55import { useStateHandlers } from ' ../state/state'
@@ -8,13 +8,12 @@ import BracketLeft from './icons/BracketLeft.vue'
88import BracketRight from ' ./icons/BracketRight.vue'
99import VitePlusCore from ' ./icons/VitePlusCore.vue'
1010
11- // Here we directly destructure is as we don't expect context to be changed
1211const props = defineProps <{
1312 context: DocksContext
1413}>()
15- const context = props .context
1614
17- const isDragging = defineModel <boolean >(' isDragging' , { default: false })
15+ // Here we directly destructure is as we don't expect context to be changed
16+ const context = props .context
1817
1918const isSafari = navigator .userAgent .includes (' Safari' ) && ! navigator .userAgent .includes (' Chrome' )
2019
@@ -47,6 +46,9 @@ const SNAP_THRESHOLD = 2
4746const dockEl = useTemplateRef <HTMLDivElement >(' dockEl' )
4847const anchorEl = useTemplateRef <HTMLDivElement >(' anchorEl' )
4948
49+ const recalculateCounter = ref (0 )
50+ const isHovering = ref (false )
51+
5052const windowSize = reactive ({
5153 width: window .innerWidth ,
5254 height: window .innerHeight ,
@@ -57,7 +59,7 @@ const mousePosition = reactive({ x: 0, y: 0 })
5759function onPointerDown(e : PointerEvent ) {
5860 if (! dockEl .value )
5961 return
60- isDragging . value = true
62+ context . panel . isDragging = true
6163 const { left, top, width, height } = dockEl .value ! .getBoundingClientRect ()
6264 draggingOffset .x = e .clientX - left - width / 2
6365 draggingOffset .y = e .clientY - top - height / 2
@@ -73,7 +75,7 @@ onMounted(() => {
7375 })
7476
7577 useEventListener (window , ' pointermove' , (e : PointerEvent ) => {
76- if (! isDragging . value )
78+ if (! context . panel . isDragging )
7779 return
7880
7981 const store = context .panel .store
@@ -109,10 +111,10 @@ onMounted(() => {
109111 store .top = snapToPoints (y / window .innerHeight * 100 )
110112 })
111113 useEventListener (window , ' pointerup' , () => {
112- isDragging . value = false
114+ context . panel . isDragging = false
113115 })
114116 useEventListener (window , ' pointerleave' , () => {
115- isDragging . value = false
117+ context . panel . isDragging = false
116118 })
117119})
118120
@@ -130,9 +132,6 @@ function clamp(value: number, min: number, max: number) {
130132 return Math .min (Math .max (value , min ), max )
131133}
132134
133- const recalculateCounter = ref (0 )
134- const isHovering = ref (false )
135-
136135const anchorPos = computed (() => {
137136 // eslint-disable-next-line ts/no-unused-expressions
138137 recalculateCounter .value
@@ -191,7 +190,7 @@ const isMinimized = computed(() => {
191190 return true
192191 // @ts-expect-error compatibility
193192 const isTouchDevice = ' ontouchstart' in window || navigator .maxTouchPoints > 0 || navigator .msMaxTouchPoints > 0
194- return ! isDragging . value
193+ return ! context . panel . isDragging
195194 && ! context .panel .store .open
196195 && ! isHovering .value
197196 && ! isTouchDevice
@@ -216,7 +215,7 @@ const panelStyle = computed(() => {
216215 style .opacity = 0
217216 style .pointerEvents = ' none'
218217 }
219- if (isDragging . value )
218+ if (context . panel . isDragging )
220219 style .transition = ' none !important'
221220 return style
222221})
@@ -244,7 +243,7 @@ onMounted(() => {
244243 <div
245244 v-if =" !isSafari"
246245 id =" vite-devtools-glowing"
247- :class =" isDragging ? 'op60!' : ''"
246+ :class =" context.panel. isDragging ? 'op60!' : ''"
248247 />
249248 <div
250249 id =" vite-devtools-dock-container"
@@ -267,19 +266,19 @@ onMounted(() => {
267266 :class =" isMinimized ? 'op100' : 'op0'"
268267 />
269268 <DockEntries
270- :entries =" context.dockEntries "
269+ :entries =" context.docks.entries "
271270 class =" transition duration-200 flex items-center w-full h-full justify-center"
272271 :class =" isMinimized ? 'opacity-0 pointer-events-none' : 'opacity-100'"
273272 :is-vertical =" context.panel.isVertical"
274- :selected =" context.selected"
273+ :selected =" context.docks. selected"
275274 @select =" selectDockEntry"
276275 />
277276 </div >
278277 </div >
279278 <slot
280279 :context =" context"
281280 :dock-el =" dockEl"
282- :selected =" context.selected"
281+ :selected =" context.docks. selected"
283282 :panel-margins =" panelMargins"
284283 />
285284 </div >
0 commit comments