{ createInterpolateElement(
- __( '
Create a new post for this feed.' ),
+ __( '
Add new post' ),
// eslint-disable-next-line jsx-a11y/anchor-has-content
{ a:
}
) }
@@ -31,7 +37,7 @@ const CreateNewPostLink = ( {
* @param {Function} BlockEdit Original component
* @return {Function} Wrapped component
*/
-const queryTopInspectorControls = createHigherOrderComponent(
+const queryTopBlockInfo = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const { name, isSelected } = props;
if ( name !== 'core/query' || ! isSelected ) {
@@ -40,14 +46,14 @@ const queryTopInspectorControls = createHigherOrderComponent(
return (
<>
-
+
-
+
>
);
},
- 'withInspectorControls'
+ 'withBlockInfo'
);
-export default queryTopInspectorControls;
+export default queryTopBlockInfo;
diff --git a/packages/block-library/src/query/index.js b/packages/block-library/src/query/index.js
index baf58470b76ac..8d82391923603 100644
--- a/packages/block-library/src/query/index.js
+++ b/packages/block-library/src/query/index.js
@@ -2,7 +2,6 @@
* WordPress dependencies
*/
import { loop as icon } from '@wordpress/icons';
-import { addFilter } from '@wordpress/hooks';
/**
* Internal dependencies
@@ -13,7 +12,6 @@ import edit from './edit';
import save from './save';
import variations from './variations';
import deprecated from './deprecated';
-import queryInspectorControls from './hooks';
const { name } = metadata;
export { metadata, name };
@@ -26,8 +24,4 @@ export const settings = {
deprecated,
};
-export const init = () => {
- addFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls );
-
- return initBlock( { name, metadata, settings } );
-};
+export const init = () => initBlock( { name, metadata, settings } );
diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md
index 2566d6c4dc2c7..c92b198dff8f3 100644
--- a/packages/components/CHANGELOG.md
+++ b/packages/components/CHANGELOG.md
@@ -7,7 +7,7 @@
- `TreeGrid`: Modify keyboard navigation code to use a data-expanded attribute if aria-expanded is to be controlled outside of the TreeGrid component ([#48461](https://github.com/WordPress/gutenberg/pull/48461)).
- `Modal`: Equalize internal spacing ([#49890](https://github.com/WordPress/gutenberg/pull/49890)).
- `Modal`: Increased border radius ([#49870](https://github.com/WordPress/gutenberg/pull/49870)).
-
+- `SlotFill`: Added util for creating private SlotFills and supporting Symbol keys ([#49819](https://github.com/WordPress/gutenberg/pull/49819)).
### Documentation
diff --git a/packages/components/src/private-apis.ts b/packages/components/src/private-apis.ts
index 07efc6f6a039b..e114559e5088c 100644
--- a/packages/components/src/private-apis.ts
+++ b/packages/components/src/private-apis.ts
@@ -8,6 +8,7 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
*/
import { default as CustomSelectControl } from './custom-select-control';
import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';
+import { createPrivateSlotFill } from './slot-fill';
export const { lock, unlock } =
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
@@ -19,4 +20,5 @@ export const privateApis = {};
lock( privateApis, {
CustomSelectControl,
__experimentalPopoverLegacyPositionToPlacement,
+ createPrivateSlotFill,
} );
diff --git a/packages/components/src/slot-fill/index.js b/packages/components/src/slot-fill/index.js
index 18aea10467701..24e68aa887704 100644
--- a/packages/components/src/slot-fill/index.js
+++ b/packages/components/src/slot-fill/index.js
@@ -44,13 +44,14 @@ export function Provider( { children, ...props } ) {
);
}
-export function createSlotFill( name ) {
- const FillComponent = ( props ) =>
;
- FillComponent.displayName = name + 'Fill';
+export function createSlotFill( key ) {
+ const baseName = typeof key === 'symbol' ? key.description : key;
+ const FillComponent = ( props ) =>
;
+ FillComponent.displayName = `${ baseName }Fill`;
- const SlotComponent = ( props ) =>
;
- SlotComponent.displayName = name + 'Slot';
- SlotComponent.__unstableName = name;
+ const SlotComponent = ( props ) =>
;
+ SlotComponent.displayName = `${ baseName }Slot`;
+ SlotComponent.__unstableName = key;
return {
Fill: FillComponent,
@@ -58,4 +59,11 @@ export function createSlotFill( name ) {
};
}
+export const createPrivateSlotFill = ( name ) => {
+ const privateKey = Symbol( name );
+ const privateSlotFill = createSlotFill( privateKey );
+
+ return { privateKey, ...privateSlotFill };
+};
+
export { useSlot };