MCPcopy Create free account
hub / github.com/TanStack/devtools / createVuePanel

Function createVuePanel

packages/devtools-utils/src/vue/panel.ts:7–70  ·  view source on GitHub ↗
(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass)

Source from the content-addressed store, hash-verified

5export interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {}
6
7export function createVuePanel<
8 TComponentProps extends DevtoolsPanelProps,
9 TCoreDevtoolsClass extends {
10 mount: (el: HTMLElement, props?: TanStackDevtoolsPluginProps) => void
11 unmount: () => void
12 },
13>(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass) {
14 const props = {
15 props: {
16 type: Object as () => DevtoolsPanelProps,
17 },
18 devtoolsProps: {
19 type: Object as () => TComponentProps,
20 },
21 }
22
23 const Panel = defineComponent({
24 props,
25 setup(config) {
26 const devToolRef = ref<HTMLElement | null>(null)
27 const devtools = ref<TCoreDevtoolsClass | null>(null)
28
29 onMounted(() => {
30 const instance = new CoreClass(config.devtoolsProps as TComponentProps)
31 devtools.value = instance
32
33 if (devToolRef.value) {
34 instance.mount(devToolRef.value, config.props)
35 }
36 })
37
38 onUnmounted(() => {
39 if (devToolRef.value && devtools.value) {
40 devtools.value.unmount()
41 }
42 })
43
44 return () => {
45 return h('div', {
46 style: { height: '100%' },
47 ref: devToolRef,
48 })
49 }
50 },
51 })
52
53 const NoOpPanel = defineComponent({
54 props,
55 setup() {
56 return () => null
57 },
58 })
59
60 return [Panel, NoOpPanel] as unknown as [
61 DefineComponent<{
62 theme?: DevtoolsPanelProps['theme']
63 devtoolsProps: TComponentProps
64 }>,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected