UNPKG

@wordpress/components

Version:
55 lines (50 loc) 1.71 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement, Fragment } from "@wordpress/element"; /** * Internal dependencies */ import BaseFill from './fill'; import BaseSlot from './slot'; import BubblesVirtuallyFill from './bubbles-virtually/fill'; import BubblesVirtuallySlot from './bubbles-virtually/slot'; import BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider'; import SlotFillProvider from './provider'; import useSlot from './bubbles-virtually/use-slot'; export function Fill(props) { // We're adding both Fills here so they can register themselves before // their respective slot has been registered. Only the Fill that has a slot // will render. The other one will return null. return createElement(Fragment, null, createElement(BaseFill, props), createElement(BubblesVirtuallyFill, props)); } export function Slot({ bubblesVirtually, ...props }) { if (bubblesVirtually) { return createElement(BubblesVirtuallySlot, props); } return createElement(BaseSlot, props); } export function Provider({ children, ...props }) { return createElement(SlotFillProvider, props, createElement(BubblesVirtuallySlotFillProvider, null, children)); } export function createSlotFill(name) { const FillComponent = props => createElement(Fill, _extends({ name: name }, props)); FillComponent.displayName = name + 'Fill'; const SlotComponent = props => createElement(Slot, _extends({ name: name }, props)); SlotComponent.displayName = name + 'Slot'; SlotComponent.__unstableName = name; return { Fill: FillComponent, Slot: SlotComponent }; } export { useSlot }; //# sourceMappingURL=index.js.map