@wordpress/components
Version:
UI components for WordPress.
8 lines (7 loc) • 3.51 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/slot-fill/index.tsx"],
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Fill from './fill';\nimport BaseSlot from './slot';\nimport BubblesVirtuallySlot from './bubbles-virtually/slot';\nimport SlotFillProvider from './provider';\nimport SlotFillContext from './context';\nimport { jsx as _jsx, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport { default as useSlot } from './bubbles-virtually/use-slot';\nexport { default as useSlotFills } from './bubbles-virtually/use-slot-fills';\nexport { Fill };\nexport const Slot = forwardRef((props, ref) => {\n const {\n bubblesVirtually,\n ...restProps\n } = props;\n if (bubblesVirtually) {\n return /*#__PURE__*/_jsx(BubblesVirtuallySlot, {\n ...restProps,\n ref: ref\n });\n }\n return /*#__PURE__*/_jsx(BaseSlot, {\n ...restProps\n });\n});\nSlot.displayName = 'Slot';\nexport function Provider({\n children,\n passthrough = false\n}) {\n const parent = useContext(SlotFillContext);\n if (!parent.isDefault && passthrough) {\n return /*#__PURE__*/_jsx(_Fragment, {\n children: children\n });\n }\n return /*#__PURE__*/_jsx(SlotFillProvider, {\n children: children\n });\n}\nProvider.displayName = 'SlotFillProvider';\nexport function createSlotFill(key) {\n const baseName = typeof key === 'symbol' ? key.description : key;\n const FillComponent = props => /*#__PURE__*/_jsx(Fill, {\n name: key,\n ...props\n });\n FillComponent.displayName = `${baseName}Fill`;\n\n // Wrap SlotComponent with forwardRef to support ref forwarding\n const SlotComponent = forwardRef((props, ref) => /*#__PURE__*/_jsx(Slot, {\n name: key,\n ref: ref,\n ...props\n }));\n SlotComponent.displayName = `${baseName}Slot`;\n /**\n * @deprecated 6.8.0\n * Please use `slotFill.name` instead of `slotFill.Slot.__unstableName`.\n */\n SlotComponent.__unstableName = key;\n return {\n name: key,\n Fill: FillComponent,\n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