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

Function createAngularPanel

packages/devtools-utils/src/angular/panel.ts:28–71  ·  view source on GitHub ↗
(
  CoreClass:
    | CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass>
    | (() => Promise<
        CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass>
      >),
)

Source from the content-addressed store, hash-verified

26}
27
28export function createAngularPanel<
29 TComponentProps extends DevtoolsPanelProps,
30 TCoreDevtoolsClass extends BaseCorePanelClass,
31>(
32 CoreClass:
33 | CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass>
34 | (() => Promise<
35 CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass>
36 >),
37) {
38 return [
39 () =>
40 (inputs: () => TComponentProps, host: HTMLElement): (() => void) => {
41 const panel = host.ownerDocument.createElement('div')
42 panel.style.height = '100%'
43 let unmount: null | (() => void) = null
44
45 function mount(instance: TCoreDevtoolsClass) {
46 instance.mount(panel, inputs())
47 unmount = () => instance.unmount()
48 }
49
50 host.appendChild(panel)
51
52 const isConstructor = isPanelClassConstructor<
53 TComponentProps,
54 TCoreDevtoolsClass
55 >(CoreClass)
56
57 if (isConstructor) {
58 mount(new CoreClass(inputs()))
59 } else {
60 CoreClass()
61 .then((ResolvedCoreClass) => new ResolvedCoreClass(inputs()))
62 .then(mount)
63 }
64
65 return () => {
66 unmount?.()
67 }
68 },
69 () => null,
70 ] as const
71}

Callers 3

A11yDevtools.tsFile · 0.90
A11yDevtools.tsFile · 0.90

Calls 3

isPanelClassConstructorFunction · 0.85
mountFunction · 0.85
unmountFunction · 0.85

Tested by

no test coverage detected