(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass)
| 5 | export interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {} |
| 6 | |
| 7 | export 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 | }>, |
nothing calls this directly
no outgoing calls
no test coverage detected