UNPKG

@wordpress/components

Version:
8 lines (7 loc) 3.3 kB
{ "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 Slot: SlotComponent\n };\n}"],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