import type { PluginUIComponentProps, SupportedUISlot, } from '@zakodium/nmrium-core'; import { castSlotProps } from '@zakodium/nmrium-core'; import type { ReactNode } from 'react'; import { useCore } from '../../context/CoreContext.tsx'; type SlotProps = Omit, 'slot'> extends Record< string, never > ? object : Omit, 'slot'>; interface CoreSlotProps { slot: Slot; fallback?: ReactNode; } /** * Render all components registered in the given slot. */ export function CoreSlot( props: CoreSlotProps & SlotProps, ) { const { slot, fallback, ...slotProps } = props; castSlotProps(slotProps, slot); const core = useCore(); const jsx = Array.from(core.slot(slot), ([key, Component]) => ( )); return jsx.length > 0 ? jsx : fallback; }