2024-04-17 11:32:24 +02:00
/******/ ( ( ) => { // webpackBootstrap
2023-12-07 09:44:11 +01:00
/******/ "use strict" ;
/******/ // The require scope
/******/ var _ _webpack _require _ _ = { } ;
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
2023-12-07 09:44:11 +01:00
/******/ // define getter functions for harmony exports
2024-04-17 11:32:24 +02:00
/******/ _ _webpack _require _ _ . d = ( exports , definition ) => {
2023-12-07 09:44:11 +01:00
/******/ for ( var key in definition ) {
/******/ if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports , key ) ) {
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
/******/ } ;
2024-04-17 11:32:24 +02:00
/******/ } ) ( ) ;
2023-12-07 09:44:11 +01:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
/******/ _ _webpack _require _ _ . o = ( obj , prop ) => ( Object . prototype . hasOwnProperty . call ( obj , prop ) )
/******/ } ) ( ) ;
2023-12-07 09:44:11 +01:00
/******/
/******/ /* webpack/runtime/make namespace object */
2024-04-17 11:32:24 +02:00
/******/ ( ( ) => {
2023-12-07 09:44:11 +01:00
/******/ // define __esModule on exports
2024-04-17 11:32:24 +02:00
/******/ _ _webpack _require _ _ . r = ( exports ) => {
2023-12-07 09:44:11 +01:00
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
2024-04-17 11:32:24 +02:00
/******/ } ) ( ) ;
2023-12-07 09:44:11 +01:00
/******/
/************************************************************************/
var _ _webpack _exports _ _ = { } ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
2024-04-17 11:32:24 +02:00
privateApis : ( ) => ( /* reexport */ privateApis ) ,
store : ( ) => ( /* reexport */ store )
2023-12-07 09:44:11 +01:00
} ) ;
// NAMESPACE OBJECT: ./node_modules/@wordpress/patterns/build-module/store/actions.js
var actions _namespaceObject = { } ;
_ _webpack _require _ _ . r ( actions _namespaceObject ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , {
2024-04-17 11:32:24 +02:00
convertSyncedPatternToStatic : ( ) => ( convertSyncedPatternToStatic ) ,
createPattern : ( ) => ( createPattern ) ,
createPatternFromFile : ( ) => ( createPatternFromFile ) ,
setEditingPattern : ( ) => ( setEditingPattern )
2023-12-07 09:44:11 +01:00
} ) ;
// NAMESPACE OBJECT: ./node_modules/@wordpress/patterns/build-module/store/selectors.js
var selectors _namespaceObject = { } ;
_ _webpack _require _ _ . r ( selectors _namespaceObject ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , {
2024-04-17 11:32:24 +02:00
isEditingPattern : ( ) => ( selectors _isEditingPattern )
2023-12-07 09:44:11 +01:00
} ) ;
2025-04-25 12:30:07 +02:00
; // external ["wp","data"]
2024-04-17 11:32:24 +02:00
const external _wp _data _namespaceObject = window [ "wp" ] [ "data" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/store/reducer.js
2023-12-07 09:44:11 +01:00
function isEditingPattern ( state = { } , action ) {
2025-12-12 13:15:55 +01:00
if ( action ? . type === "SET_EDITING_PATTERN" ) {
2023-12-07 09:44:11 +01:00
return {
... state ,
[ action . clientId ] : action . isEditing
} ;
}
return state ;
}
2025-12-12 13:15:55 +01:00
var reducer _default = ( 0 , external _wp _data _namespaceObject . combineReducers ) ( {
2023-12-07 09:44:11 +01:00
isEditingPattern
2025-12-12 13:15:55 +01:00
} ) ;
2023-12-07 09:44:11 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","blocks"]
2024-04-17 11:32:24 +02:00
const external _wp _blocks _namespaceObject = window [ "wp" ] [ "blocks" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","coreData"]
2024-04-17 11:32:24 +02:00
const external _wp _coreData _namespaceObject = window [ "wp" ] [ "coreData" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","blockEditor"]
2024-04-17 11:32:24 +02:00
const external _wp _blockEditor _namespaceObject = window [ "wp" ] [ "blockEditor" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/constants.js
2023-12-07 09:44:11 +01:00
const PATTERN _TYPES = {
2025-12-12 13:15:55 +01:00
theme : "pattern" ,
user : "wp_block"
2023-12-07 09:44:11 +01:00
} ;
2025-12-12 13:15:55 +01:00
const PATTERN _DEFAULT _CATEGORY = "all-patterns" ;
const PATTERN _USER _CATEGORY = "my-patterns" ;
const EXCLUDED _PATTERN _SOURCES = [
"core" ,
"pattern-directory/core" ,
"pattern-directory/featured"
] ;
2023-12-07 09:44:11 +01:00
const PATTERN _SYNC _TYPES = {
2025-12-12 13:15:55 +01:00
full : "fully" ,
unsynced : "unsynced"
2023-12-07 09:44:11 +01:00
} ;
2024-04-17 11:32:24 +02:00
const PARTIAL _SYNCING _SUPPORTED _BLOCKS = {
2025-12-12 13:15:55 +01:00
"core/paragraph" : [ "content" ] ,
"core/heading" : [ "content" ] ,
"core/button" : [ "text" , "url" , "linkTarget" , "rel" ] ,
"core/image" : [ "id" , "url" , "title" , "alt" , "caption" ]
2024-04-17 11:32:24 +02:00
} ;
2025-12-12 13:15:55 +01:00
const PATTERN _OVERRIDES _BINDING _SOURCE = "core/pattern-overrides" ;
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/store/actions.js
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
const createPattern = ( title , syncType , content , categories ) => async ( { registry } ) => {
2023-12-07 09:44:11 +01:00
const meta = syncType === PATTERN _SYNC _TYPES . unsynced ? {
wp _pattern _sync _status : syncType
2025-12-12 13:15:55 +01:00
} : void 0 ;
2023-12-07 09:44:11 +01:00
const reusableBlock = {
title ,
content ,
2025-12-12 13:15:55 +01:00
status : "publish" ,
2023-12-07 09:44:11 +01:00
meta ,
wp _pattern _category : categories
} ;
2025-12-12 13:15:55 +01:00
const updatedRecord = await registry . dispatch ( external _wp _coreData _namespaceObject . store ) . saveEntityRecord ( "postType" , "wp_block" , reusableBlock ) ;
2023-12-07 09:44:11 +01:00
return updatedRecord ;
} ;
2025-12-12 13:15:55 +01:00
const createPatternFromFile = ( file , categories ) => async ( { dispatch } ) => {
2023-12-07 09:44:11 +01:00
const fileContent = await file . text ( ) ;
let parsedContent ;
try {
parsedContent = JSON . parse ( fileContent ) ;
} catch ( e ) {
2025-12-12 13:15:55 +01:00
throw new Error ( "Invalid JSON file" ) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
if ( parsedContent . _ _file !== "wp_block" || ! parsedContent . title || ! parsedContent . content || typeof parsedContent . title !== "string" || typeof parsedContent . content !== "string" || parsedContent . syncStatus && typeof parsedContent . syncStatus !== "string" ) {
throw new Error ( "Invalid pattern JSON file" ) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
const pattern = await dispatch . createPattern (
parsedContent . title ,
parsedContent . syncStatus ,
parsedContent . content ,
categories
) ;
2023-12-07 09:44:11 +01:00
return pattern ;
} ;
2025-12-12 13:15:55 +01:00
const convertSyncedPatternToStatic = ( clientId ) => ( { registry } ) => {
2024-04-17 11:32:24 +02:00
const patternBlock = registry . select ( external _wp _blockEditor _namespaceObject . store ) . getBlock ( clientId ) ;
2025-02-28 08:42:11 +01:00
const existingOverrides = patternBlock . attributes ? . content ;
2024-04-17 11:32:24 +02:00
function cloneBlocksAndRemoveBindings ( blocks ) {
2025-12-12 13:15:55 +01:00
return blocks . map ( ( block ) => {
2024-04-17 11:32:24 +02:00
let metadata = block . attributes . metadata ;
if ( metadata ) {
2025-12-12 13:15:55 +01:00
metadata = { ... metadata } ;
2024-04-17 11:32:24 +02:00
delete metadata . id ;
delete metadata . bindings ;
2025-02-28 08:42:11 +01:00
if ( existingOverrides ? . [ metadata . name ] ) {
2025-12-12 13:15:55 +01:00
for ( const [ attributeName , value ] of Object . entries (
existingOverrides [ metadata . name ]
) ) {
2025-02-28 08:42:11 +01:00
if ( ! ( 0 , external _wp _blocks _namespaceObject . getBlockType ) ( block . name ) ? . attributes [ attributeName ] ) {
continue ;
}
block . attributes [ attributeName ] = value ;
}
}
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
return ( 0 , external _wp _blocks _namespaceObject . cloneBlock ) (
block ,
{
metadata : metadata && Object . keys ( metadata ) . length > 0 ? metadata : void 0
} ,
cloneBlocksAndRemoveBindings ( block . innerBlocks )
) ;
2024-04-17 11:32:24 +02:00
} ) ;
}
2025-02-28 08:42:11 +01:00
const patternInnerBlocks = registry . select ( external _wp _blockEditor _namespaceObject . store ) . getBlocks ( patternBlock . clientId ) ;
2025-12-12 13:15:55 +01:00
registry . dispatch ( external _wp _blockEditor _namespaceObject . store ) . replaceBlocks (
patternBlock . clientId ,
cloneBlocksAndRemoveBindings ( patternInnerBlocks )
) ;
2023-12-07 09:44:11 +01:00
} ;
function setEditingPattern ( clientId , isEditing ) {
return {
2025-12-12 13:15:55 +01:00
type : "SET_EDITING_PATTERN" ,
2023-12-07 09:44:11 +01:00
clientId ,
isEditing
} ;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/store/constants.js
2025-12-12 13:15:55 +01:00
const STORE _NAME = "core/patterns" ;
2023-12-07 09:44:11 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/store/selectors.js
2023-12-07 09:44:11 +01:00
function selectors _isEditingPattern ( state , clientId ) {
return state . isEditingPattern [ clientId ] ;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","privateApis"]
2024-04-17 11:32:24 +02:00
const external _wp _privateApis _namespaceObject = window [ "wp" ] [ "privateApis" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/lock-unlock.js
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
const { lock , unlock } = ( 0 , external _wp _privateApis _namespaceObject . _ _dangerousOptInToUnstableAPIsOnlyForCoreModules ) (
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress." ,
"@wordpress/patterns"
) ;
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/store/index.js
2023-12-07 09:44:11 +01:00
const storeConfig = {
2025-12-12 13:15:55 +01:00
reducer : reducer _default
2023-12-07 09:44:11 +01:00
} ;
const store = ( 0 , external _wp _data _namespaceObject . createReduxStore ) ( STORE _NAME , {
... storeConfig
} ) ;
( 0 , external _wp _data _namespaceObject . register ) ( store ) ;
unlock ( store ) . registerPrivateActions ( actions _namespaceObject ) ;
unlock ( store ) . registerPrivateSelectors ( selectors _namespaceObject ) ;
2025-12-12 13:15:55 +01:00
; // external "ReactJSXRuntime"
const external _ReactJSXRuntime _namespaceObject = window [ "ReactJSXRuntime" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","components"]
2024-04-17 11:32:24 +02:00
const external _wp _components _namespaceObject = window [ "wp" ] [ "components" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","element"]
2024-04-17 11:32:24 +02:00
const external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","i18n"]
2025-02-28 08:42:11 +01:00
const external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/api/index.js
2025-12-12 13:15:55 +01:00
2025-02-28 08:42:11 +01:00
function isOverridableBlock ( block ) {
2025-12-12 13:15:55 +01:00
return Object . keys ( PARTIAL _SYNCING _SUPPORTED _BLOCKS ) . includes (
block . name
) && ! ! block . attributes . metadata ? . name && ! ! block . attributes . metadata ? . bindings && Object . values ( block . attributes . metadata . bindings ) . some (
( binding ) => binding . source === "core/pattern-overrides"
) ;
2025-02-28 08:42:11 +01:00
}
function hasOverridableBlocks ( blocks ) {
2025-12-12 13:15:55 +01:00
return blocks . some ( ( block ) => {
2025-02-28 08:42:11 +01:00
if ( isOverridableBlock ( block ) ) {
return true ;
}
return hasOverridableBlocks ( block . innerBlocks ) ;
} ) ;
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/overrides-panel.js
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
const { BlockQuickNavigation } = unlock ( external _wp _blockEditor _namespaceObject . privateApis ) ;
2025-02-28 08:42:11 +01:00
function OverridesPanel ( ) {
2025-12-12 13:15:55 +01:00
const allClientIds = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => select ( external _wp _blockEditor _namespaceObject . store ) . getClientIdsWithDescendants ( ) ,
[ ]
) ;
const { getBlock } = ( 0 , external _wp _data _namespaceObject . useSelect ) ( external _wp _blockEditor _namespaceObject . store ) ;
const clientIdsWithOverrides = ( 0 , external _wp _element _namespaceObject . useMemo ) (
( ) => allClientIds . filter ( ( clientId ) => {
const block = getBlock ( clientId ) ;
return isOverridableBlock ( block ) ;
} ) ,
[ allClientIds , getBlock ]
) ;
2025-02-28 08:42:11 +01:00
if ( ! clientIdsWithOverrides ? . length ) {
return null ;
}
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . PanelBody , { title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Overrides" ) , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( BlockQuickNavigation , { clientIds : clientIdsWithOverrides } ) } ) ;
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","notices"]
2024-04-17 11:32:24 +02:00
const external _wp _notices _namespaceObject = window [ "wp" ] [ "notices" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","compose"]
2024-04-17 11:32:24 +02:00
const external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
2025-04-25 12:30:07 +02:00
; // external ["wp","htmlEntities"]
2024-04-17 11:32:24 +02:00
const external _wp _htmlEntities _namespaceObject = window [ "wp" ] [ "htmlEntities" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/components/category-selector.js
2023-12-07 09:44:11 +01:00
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
const unescapeString = ( arg ) => {
2023-12-07 09:44:11 +01:00
return ( 0 , external _wp _htmlEntities _namespaceObject . decodeEntities ) ( arg ) ;
} ;
2025-12-12 13:15:55 +01:00
const CATEGORY _SLUG = "wp_pattern_category" ;
2023-12-07 09:44:11 +01:00
function CategorySelector ( {
categoryTerms ,
onChange ,
categoryMap
} ) {
2025-12-12 13:15:55 +01:00
const [ search , setSearch ] = ( 0 , external _wp _element _namespaceObject . useState ) ( "" ) ;
2023-12-07 09:44:11 +01:00
const debouncedSearch = ( 0 , external _wp _compose _namespaceObject . useDebounce ) ( setSearch , 500 ) ;
const suggestions = ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
2025-12-12 13:15:55 +01:00
return Array . from ( categoryMap . values ( ) ) . map ( ( category ) => unescapeString ( category . label ) ) . filter ( ( category ) => {
if ( search !== "" ) {
2023-12-07 09:44:11 +01:00
return category . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ;
}
return true ;
} ) . sort ( ( a , b ) => a . localeCompare ( b ) ) ;
} , [ search , categoryMap ] ) ;
function handleChange ( termNames ) {
const uniqueTerms = termNames . reduce ( ( terms , newTerm ) => {
2025-12-12 13:15:55 +01:00
if ( ! terms . some (
( term ) => term . toLowerCase ( ) === newTerm . toLowerCase ( )
) ) {
2023-12-07 09:44:11 +01:00
terms . push ( newTerm ) ;
}
return terms ;
} , [ ] ) ;
onChange ( uniqueTerms ) ;
}
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . FormTokenField ,
{
className : "patterns-menu-items__convert-modal-categories" ,
value : categoryTerms ,
suggestions ,
onChange : handleChange ,
onInputChange : debouncedSearch ,
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Categories" ) ,
tokenizeOnBlur : true ,
_ _experimentalExpandOnFocus : true ,
_ _next40pxDefaultSize : true ,
_ _nextHasNoMarginBottom : true
}
) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/private-hooks.js
2023-12-07 09:44:11 +01:00
2024-04-17 11:32:24 +02:00
function useAddPatternCategory ( ) {
2025-12-12 13:15:55 +01:00
const { saveEntityRecord , invalidateResolution } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _coreData _namespaceObject . store ) ;
const { corePatternCategories , userPatternCategories } = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => {
const { getUserPatternCategories , getBlockPatternCategories } = select ( external _wp _coreData _namespaceObject . store ) ;
return {
corePatternCategories : getBlockPatternCategories ( ) ,
userPatternCategories : getUserPatternCategories ( )
} ;
} ,
[ ]
) ;
2023-12-07 09:44:11 +01:00
const categoryMap = ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
2025-12-12 13:15:55 +01:00
const uniqueCategories = /* @__PURE__ */ new Map ( ) ;
userPatternCategories . forEach ( ( category ) => {
2024-04-17 11:32:24 +02:00
uniqueCategories . set ( category . label . toLowerCase ( ) , {
label : category . label ,
name : category . name ,
id : category . id
} ) ;
} ) ;
2025-12-12 13:15:55 +01:00
corePatternCategories . forEach ( ( category ) => {
if ( ! uniqueCategories . has ( category . label . toLowerCase ( ) ) && // There are two core categories with `Post` label so explicitly remove the one with
2023-12-07 09:44:11 +01:00
// the `query` slug to avoid any confusion.
2025-12-12 13:15:55 +01:00
category . name !== "query" ) {
2024-04-17 11:32:24 +02:00
uniqueCategories . set ( category . label . toLowerCase ( ) , {
2023-12-07 09:44:11 +01:00
label : category . label ,
name : category . name
} ) ;
}
} ) ;
return uniqueCategories ;
} , [ userPatternCategories , corePatternCategories ] ) ;
2024-04-17 11:32:24 +02:00
async function findOrCreateTerm ( term ) {
try {
const existingTerm = categoryMap . get ( term . toLowerCase ( ) ) ;
if ( existingTerm ? . id ) {
return existingTerm . id ;
}
2025-12-12 13:15:55 +01:00
const termData = existingTerm ? { name : existingTerm . label , slug : existingTerm . name } : { name : term } ;
const newTerm = await saveEntityRecord (
"taxonomy" ,
CATEGORY _SLUG ,
termData ,
{ throwOnError : true }
) ;
invalidateResolution ( "getUserPatternCategories" ) ;
2024-04-17 11:32:24 +02:00
return newTerm . id ;
} catch ( error ) {
2025-12-12 13:15:55 +01:00
if ( error . code !== "term_exists" ) {
2024-04-17 11:32:24 +02:00
throw error ;
}
return error . data . term _id ;
}
}
2025-12-12 13:15:55 +01:00
return { categoryMap , findOrCreateTerm } ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/create-pattern-modal.js
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
2024-04-17 11:32:24 +02:00
function CreatePatternModal ( {
2025-12-12 13:15:55 +01:00
className = "patterns-menu-items__convert-modal" ,
2025-02-28 08:42:11 +01:00
modalTitle ,
2024-04-17 11:32:24 +02:00
... restProps
} ) {
2025-12-12 13:15:55 +01:00
const defaultModalTitle = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => select ( external _wp _coreData _namespaceObject . store ) . getPostType ( PATTERN _TYPES . user ) ? . labels ? . add _new _item ,
[ ]
) ;
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Modal ,
{
title : modalTitle || defaultModalTitle ,
onRequestClose : restProps . onClose ,
overlayClassName : className ,
focusOnMount : "firstContentElement" ,
size : "small" ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( CreatePatternModalContents , { ... restProps } )
}
) ;
2024-04-17 11:32:24 +02:00
}
function CreatePatternModalContents ( {
2025-12-12 13:15:55 +01:00
confirmLabel = ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Add" ) ,
2024-04-17 11:32:24 +02:00
defaultCategories = [ ] ,
content ,
onClose ,
onError ,
onSuccess ,
defaultSyncType = PATTERN _SYNC _TYPES . full ,
2025-12-12 13:15:55 +01:00
defaultTitle = ""
2024-04-17 11:32:24 +02:00
} ) {
const [ syncType , setSyncType ] = ( 0 , external _wp _element _namespaceObject . useState ) ( defaultSyncType ) ;
const [ categoryTerms , setCategoryTerms ] = ( 0 , external _wp _element _namespaceObject . useState ) ( defaultCategories ) ;
const [ title , setTitle ] = ( 0 , external _wp _element _namespaceObject . useState ) ( defaultTitle ) ;
const [ isSaving , setIsSaving ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
2025-12-12 13:15:55 +01:00
const { createPattern } = unlock ( ( 0 , external _wp _data _namespaceObject . useDispatch ) ( store ) ) ;
const { createErrorNotice } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
const { categoryMap , findOrCreateTerm } = useAddPatternCategory ( ) ;
2023-12-07 09:44:11 +01:00
async function onCreate ( patternTitle , sync ) {
if ( ! title || isSaving ) {
return ;
}
try {
setIsSaving ( true ) ;
2025-12-12 13:15:55 +01:00
const categories = await Promise . all (
categoryTerms . map (
( termName ) => findOrCreateTerm ( termName )
)
) ;
const newPattern = await createPattern (
patternTitle ,
sync ,
typeof content === "function" ? content ( ) : content ,
categories
) ;
2023-12-07 09:44:11 +01:00
onSuccess ( {
pattern : newPattern ,
categoryId : PATTERN _DEFAULT _CATEGORY
} ) ;
} catch ( error ) {
createErrorNotice ( error . message , {
2025-12-12 13:15:55 +01:00
type : "snackbar" ,
id : "pattern-create"
2023-12-07 09:44:11 +01:00
} ) ;
2024-04-17 11:32:24 +02:00
onError ? . ( ) ;
2023-12-07 09:44:11 +01:00
} finally {
setIsSaving ( false ) ;
setCategoryTerms ( [ ] ) ;
2025-12-12 13:15:55 +01:00
setTitle ( "" ) ;
2023-12-07 09:44:11 +01:00
}
}
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
"form" ,
{
onSubmit : ( event ) => {
event . preventDefault ( ) ;
onCreate ( title , syncType ) ;
} ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalVStack , { spacing : "5" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . TextControl ,
{
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Name" ) ,
value : title ,
onChange : setTitle ,
placeholder : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "My pattern" ) ,
className : "patterns-create-modal__name-input" ,
_ _nextHasNoMarginBottom : true ,
_ _next40pxDefaultSize : true
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
CategorySelector ,
{
categoryTerms ,
onChange : setCategoryTerms ,
categoryMap
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . ToggleControl ,
{
_ _nextHasNoMarginBottom : true ,
label : ( 0 , external _wp _i18n _namespaceObject . _x ) ( "Synced" , "pattern (singular)" ) ,
help : ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
"Sync this pattern across multiple locations."
) ,
checked : syncType === PATTERN _SYNC _TYPES . full ,
onChange : ( ) => {
setSyncType (
syncType === PATTERN _SYNC _TYPES . full ? PATTERN _SYNC _TYPES . unsynced : PATTERN _SYNC _TYPES . full
) ;
}
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalHStack , { justify : "right" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "tertiary" ,
onClick : ( ) => {
onClose ( ) ;
setTitle ( "" ) ;
} ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Cancel" )
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "primary" ,
type : "submit" ,
"aria-disabled" : ! title || isSaving ,
isBusy : isSaving ,
children : confirmLabel
}
)
] } )
] } )
}
) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/duplicate-pattern-modal.js
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
2024-04-17 11:32:24 +02:00
function getTermLabels ( pattern , categories ) {
if ( pattern . type !== PATTERN _TYPES . user ) {
2025-12-12 13:15:55 +01:00
return categories . core ? . filter (
( category ) => pattern . categories ? . includes ( category . name )
) . map ( ( category ) => category . label ) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
return categories . user ? . filter (
( category ) => pattern . wp _pattern _category ? . includes ( category . id )
) . map ( ( category ) => category . label ) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
function useDuplicatePatternProps ( { pattern , onSuccess } ) {
const { createSuccessNotice } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
const categories = ( 0 , external _wp _data _namespaceObject . useSelect ) ( ( select ) => {
const { getUserPatternCategories , getBlockPatternCategories } = select ( external _wp _coreData _namespaceObject . store ) ;
2024-04-17 11:32:24 +02:00
return {
core : getBlockPatternCategories ( ) ,
user : getUserPatternCategories ( )
} ;
} ) ;
if ( ! pattern ) {
return null ;
}
return {
content : pattern . content ,
defaultCategories : getTermLabels ( pattern , categories ) ,
2025-12-12 13:15:55 +01:00
defaultSyncType : pattern . type !== PATTERN _TYPES . user ? PATTERN _SYNC _TYPES . unsynced : pattern . wp _pattern _sync _status || PATTERN _SYNC _TYPES . full ,
defaultTitle : ( 0 , external _wp _i18n _namespaceObject . sprintf ) (
/* translators: %s: Existing pattern title */
( 0 , external _wp _i18n _namespaceObject . _x ) ( "%s (Copy)" , "pattern" ) ,
typeof pattern . title === "string" ? pattern . title : pattern . title . raw
) ,
onSuccess : ( { pattern : newPattern } ) => {
createSuccessNotice (
( 0 , external _wp _i18n _namespaceObject . sprintf ) (
// translators: %s: The new pattern's title e.g. 'Call to action (copy)'.
( 0 , external _wp _i18n _namespaceObject . _x ) ( '"%s" duplicated.' , "pattern" ) ,
newPattern . title . raw
) ,
{
type : "snackbar" ,
id : "patterns-create"
}
) ;
onSuccess ? . ( { pattern : newPattern } ) ;
2024-04-17 11:32:24 +02:00
}
} ;
}
function DuplicatePatternModal ( {
pattern ,
onClose ,
onSuccess
} ) {
2025-12-12 13:15:55 +01:00
const duplicatedProps = useDuplicatePatternProps ( { pattern , onSuccess } ) ;
2024-04-17 11:32:24 +02:00
if ( ! pattern ) {
return null ;
}
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
CreatePatternModal ,
{
modalTitle : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Duplicate pattern" ) ,
confirmLabel : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Duplicate" ) ,
onClose ,
onError : onClose ,
... duplicatedProps
}
) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/components/rename-pattern-modal.js
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
2024-04-17 11:32:24 +02:00
function RenamePatternModal ( {
onClose ,
onError ,
onSuccess ,
pattern ,
... props
} ) {
const originalName = ( 0 , external _wp _htmlEntities _namespaceObject . decodeEntities ) ( pattern . title ) ;
const [ name , setName ] = ( 0 , external _wp _element _namespaceObject . useState ) ( originalName ) ;
const [ isSaving , setIsSaving ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const {
editEntityRecord ,
_ _experimentalSaveSpecifiedEntityEdits : saveSpecifiedEntityEdits
} = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _coreData _namespaceObject . store ) ;
2025-12-12 13:15:55 +01:00
const { createSuccessNotice , createErrorNotice } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
const onRename = async ( event ) => {
2024-04-17 11:32:24 +02:00
event . preventDefault ( ) ;
if ( ! name || name === pattern . title || isSaving ) {
return ;
}
try {
2025-12-12 13:15:55 +01:00
await editEntityRecord ( "postType" , pattern . type , pattern . id , {
2024-04-17 11:32:24 +02:00
title : name
} ) ;
setIsSaving ( true ) ;
2025-12-12 13:15:55 +01:00
setName ( "" ) ;
2024-04-17 11:32:24 +02:00
onClose ? . ( ) ;
2025-12-12 13:15:55 +01:00
const savedRecord = await saveSpecifiedEntityEdits (
"postType" ,
pattern . type ,
pattern . id ,
[ "title" ] ,
{ throwOnError : true }
) ;
2024-04-17 11:32:24 +02:00
onSuccess ? . ( savedRecord ) ;
2025-12-12 13:15:55 +01:00
createSuccessNotice ( ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Pattern renamed" ) , {
type : "snackbar" ,
id : "pattern-update"
2024-04-17 11:32:24 +02:00
} ) ;
} catch ( error ) {
onError ? . ( ) ;
2025-12-12 13:15:55 +01:00
const errorMessage = error . message && error . code !== "unknown_error" ? error . message : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "An error occurred while renaming the pattern." ) ;
2024-04-17 11:32:24 +02:00
createErrorNotice ( errorMessage , {
2025-12-12 13:15:55 +01:00
type : "snackbar" ,
id : "pattern-update"
2024-04-17 11:32:24 +02:00
} ) ;
} finally {
setIsSaving ( false ) ;
2025-12-12 13:15:55 +01:00
setName ( "" ) ;
2024-04-17 11:32:24 +02:00
}
} ;
const onRequestClose = ( ) => {
onClose ? . ( ) ;
2025-12-12 13:15:55 +01:00
setName ( "" ) ;
2024-04-17 11:32:24 +02:00
} ;
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Modal ,
{
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Rename" ) ,
... props ,
onRequestClose : onClose ,
focusOnMount : "firstContentElement" ,
size : "small" ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "form" , { onSubmit : onRename , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalVStack , { spacing : "5" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . TextControl ,
{
_ _nextHasNoMarginBottom : true ,
2025-02-28 08:42:11 +01:00
_ _next40pxDefaultSize : true ,
2025-12-12 13:15:55 +01:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Name" ) ,
value : name ,
onChange : setName ,
required : true
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalHStack , { justify : "right" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "tertiary" ,
onClick : onRequestClose ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Cancel" )
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "primary" ,
type : "submit" ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Save" )
}
)
] } )
] } ) } )
}
) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","primitives"]
2024-04-17 11:32:24 +02:00
const external _wp _primitives _namespaceObject = window [ "wp" ] [ "primitives" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/icons/build-module/library/symbol.js
2023-12-07 09:44:11 +01:00
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
var symbol _default = /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . SVG , { xmlns : "http://www.w3.org/2000/svg" , viewBox : "0 0 24 24" , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . Path , { d : "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" } ) } ) ;
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/pattern-convert-button.js
2023-12-07 09:44:11 +01:00
2025-02-28 08:42:11 +01:00
2023-12-07 09:44:11 +01:00
function PatternConvertButton ( {
clientIds ,
2024-04-17 11:32:24 +02:00
rootClientId ,
closeBlockSettingsMenu
2023-12-07 09:44:11 +01:00
} ) {
2025-12-12 13:15:55 +01:00
const { createSuccessNotice } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
const { replaceBlocks , updateBlockAttributes } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _blockEditor _namespaceObject . store ) ;
const { setEditingPattern } = unlock ( ( 0 , external _wp _data _namespaceObject . useDispatch ) ( store ) ) ;
2023-12-07 09:44:11 +01:00
const [ isModalOpen , setIsModalOpen ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
2025-12-12 13:15:55 +01:00
const { getBlockAttributes } = ( 0 , external _wp _data _namespaceObject . useSelect ) ( external _wp _blockEditor _namespaceObject . store ) ;
const canConvert = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => {
const { canUser } = select ( external _wp _coreData _namespaceObject . store ) ;
const {
getBlocksByClientId : getBlocksByClientId2 ,
canInsertBlockType ,
getBlockRootClientId
} = select ( external _wp _blockEditor _namespaceObject . store ) ;
const rootId = rootClientId || ( clientIds . length > 0 ? getBlockRootClientId ( clientIds [ 0 ] ) : void 0 ) ;
const blocks = getBlocksByClientId2 ( clientIds ) ? ? [ ] ;
const hasReusableBlockSupport = ( blockName ) => {
const blockType = ( 0 , external _wp _blocks _namespaceObject . getBlockType ) ( blockName ) ;
const hasParent = blockType && "parent" in blockType ;
return ( 0 , external _wp _blocks _namespaceObject . hasBlockSupport ) ( blockName , "reusable" , ! hasParent ) ;
} ;
const isSyncedPattern = blocks . length === 1 && blocks [ 0 ] && ( 0 , external _wp _blocks _namespaceObject . isReusableBlock ) ( blocks [ 0 ] ) && ! ! select ( external _wp _coreData _namespaceObject . store ) . getEntityRecord (
"postType" ,
"wp_block" ,
blocks [ 0 ] . attributes . ref
) ;
const isUnsyncedPattern = window ? . _ _experimentalContentOnlyPatternInsertion && blocks . length === 1 && blocks ? . [ 0 ] ? . attributes ? . metadata ? . patternName ;
const _canConvert = (
// Hide when this is already a pattern.
! isUnsyncedPattern && ! isSyncedPattern && // Hide when patterns are disabled.
canInsertBlockType ( "core/block" , rootId ) && blocks . every (
( block ) => (
// Guard against the case where a regular block has *just* been converted.
! ! block && // Hide on invalid blocks.
block . isValid && // Hide when block doesn't support being made into a pattern.
hasReusableBlockSupport ( block . name )
)
) && // Hide when current doesn't have permission to do that.
// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
! ! canUser ( "create" , {
kind : "postType" ,
name : "wp_block"
} )
) ;
return _canConvert ;
} ,
[ clientIds , rootClientId ]
) ;
const { getBlocksByClientId } = ( 0 , external _wp _data _namespaceObject . useSelect ) ( external _wp _blockEditor _namespaceObject . store ) ;
const getContent = ( 0 , external _wp _element _namespaceObject . useCallback ) (
( ) => ( 0 , external _wp _blocks _namespaceObject . serialize ) ( getBlocksByClientId ( clientIds ) ) ,
[ getBlocksByClientId , clientIds ]
) ;
2023-12-07 09:44:11 +01:00
if ( ! canConvert ) {
return null ;
}
2025-12-12 13:15:55 +01:00
const handleSuccess = ( { pattern } ) => {
if ( pattern . wp _pattern _sync _status === PATTERN _SYNC _TYPES . unsynced ) {
if ( clientIds ? . length === 1 ) {
const existingAttributes = getBlockAttributes ( clientIds [ 0 ] ) ;
updateBlockAttributes ( clientIds [ 0 ] , {
metadata : {
... existingAttributes ? . metadata ? existingAttributes . metadata : { } ,
patternName : ` core/block/ ${ pattern . id } ` ,
name : pattern . title . raw
}
} ) ;
}
} else {
const newBlock = ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( "core/block" , {
2023-12-07 09:44:11 +01:00
ref : pattern . id
} ) ;
replaceBlocks ( clientIds , newBlock ) ;
setEditingPattern ( newBlock . clientId , true ) ;
2024-04-17 11:32:24 +02:00
closeBlockSettingsMenu ( ) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
createSuccessNotice (
pattern . wp _pattern _sync _status === PATTERN _SYNC _TYPES . unsynced ? ( 0 , external _wp _i18n _namespaceObject . sprintf ) (
// translators: %s: the name the user has given to the pattern.
( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Unsynced pattern created: %s" ) ,
pattern . title . raw
) : ( 0 , external _wp _i18n _namespaceObject . sprintf ) (
// translators: %s: the name the user has given to the pattern.
( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Synced pattern created: %s" ) ,
pattern . title . raw
) ,
{
type : "snackbar" ,
id : "convert-to-pattern-success"
}
) ;
2023-12-07 09:44:11 +01:00
setIsModalOpen ( false ) ;
} ;
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , { children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . MenuItem ,
{
icon : symbol _default ,
onClick : ( ) => setIsModalOpen ( true ) ,
"aria-expanded" : isModalOpen ,
"aria-haspopup" : "dialog" ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Create pattern" )
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
) ,
isModalOpen && /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
CreatePatternModal ,
{
content : getContent ,
onSuccess : ( pattern ) => {
handleSuccess ( pattern ) ;
} ,
onError : ( ) => {
setIsModalOpen ( false ) ;
} ,
onClose : ( ) => {
setIsModalOpen ( false ) ;
}
}
)
] } ) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","url"]
2024-04-17 11:32:24 +02:00
const external _wp _url _namespaceObject = window [ "wp" ] [ "url" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/components/patterns-manage-button.js
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
function PatternsManageButton ( { clientId } ) {
2023-12-07 09:44:11 +01:00
const {
2025-12-12 13:15:55 +01:00
attributes ,
canDetach ,
2023-12-07 09:44:11 +01:00
isVisible ,
2025-12-12 13:15:55 +01:00
managePatternsUrl ,
isSyncedPattern ,
isUnsyncedPattern
} = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => {
const { canRemoveBlock , getBlock } = select ( external _wp _blockEditor _namespaceObject . store ) ;
const { canUser } = select ( external _wp _coreData _namespaceObject . store ) ;
const block = getBlock ( clientId ) ;
const _isUnsyncedPattern = window ? . _ _experimentalContentOnlyPatternInsertion && ! ! block ? . attributes ? . metadata ? . patternName ;
const _isSyncedPattern = ! ! block && ( 0 , external _wp _blocks _namespaceObject . isReusableBlock ) ( block ) && ! ! canUser ( "update" , {
kind : "postType" ,
name : "wp_block" ,
id : block . attributes . ref
} ) ;
return {
attributes : block . attributes ,
// For unsynced patterns, detaching is simply removing the `patternName` attribute.
// For synced patterns, the `core:block` block is replaced with its inner blocks,
// so checking whether `canRemoveBlock` is possible is required.
canDetach : _isUnsyncedPattern || _isSyncedPattern && canRemoveBlock ( clientId ) ,
isUnsyncedPattern : _isUnsyncedPattern ,
isSyncedPattern : _isSyncedPattern ,
isVisible : _isUnsyncedPattern || _isSyncedPattern ,
// The site editor and templates both check whether the user
// has edit_theme_options capabilities. We can leverage that here
// and omit the manage patterns link if the user can't access it.
managePatternsUrl : canUser ( "create" , {
kind : "postType" ,
name : "wp_template"
} ) ? ( 0 , external _wp _url _namespaceObject . addQueryArgs ) ( "site-editor.php" , {
p : "/pattern"
} ) : ( 0 , external _wp _url _namespaceObject . addQueryArgs ) ( "edit.php" , {
post _type : "wp_block"
} )
} ;
} ,
[ clientId ]
) ;
const { updateBlockAttributes } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _blockEditor _namespaceObject . store ) ;
const { convertSyncedPatternToStatic } = unlock (
( 0 , external _wp _data _namespaceObject . useDispatch ) ( store )
) ;
2023-12-07 09:44:11 +01:00
if ( ! isVisible ) {
return null ;
}
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , { children : [
canDetach && /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . MenuItem ,
{
onClick : ( ) => {
if ( isSyncedPattern ) {
convertSyncedPatternToStatic ( clientId ) ;
}
if ( isUnsyncedPattern ) {
const {
patternName ,
... attributesWithoutPatternName
} = attributes ? . metadata ? ? { } ;
updateBlockAttributes ( clientId , {
metadata : attributesWithoutPatternName
} ) ;
}
} ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Detach" )
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . MenuItem , { href : managePatternsUrl , children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Manage patterns" ) } )
] } ) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
var patterns _manage _button _default = PatternsManageButton ;
2023-12-07 09:44:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/index.js
2023-12-07 09:44:11 +01:00
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
function PatternsMenuItems ( { rootClientId } ) {
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . BlockSettingsMenuControls , { children : ( { selectedClientIds , onClose } ) => /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , { children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
PatternConvertButton ,
{
2025-02-28 08:42:11 +01:00
clientIds : selectedClientIds ,
2025-12-12 13:15:55 +01:00
rootClientId ,
2025-02-28 08:42:11 +01:00
closeBlockSettingsMenu : onClose
2025-12-12 13:15:55 +01:00
}
) ,
selectedClientIds . length === 1 && /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
patterns _manage _button _default ,
{
2025-02-28 08:42:11 +01:00
clientId : selectedClientIds [ 0 ]
2025-12-12 13:15:55 +01:00
}
)
] } ) } ) ;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // external ["wp","a11y"]
2024-04-17 11:32:24 +02:00
const external _wp _a11y _namespaceObject = window [ "wp" ] [ "a11y" ] ;
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/components/rename-pattern-category-modal.js
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
2024-04-17 11:32:24 +02:00
function RenamePatternCategoryModal ( {
category ,
existingCategories ,
onClose ,
onError ,
onSuccess ,
... props
} ) {
const id = ( 0 , external _wp _element _namespaceObject . useId ) ( ) ;
const textControlRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const [ name , setName ] = ( 0 , external _wp _element _namespaceObject . useState ) ( ( 0 , external _wp _htmlEntities _namespaceObject . decodeEntities ) ( category . name ) ) ;
const [ isSaving , setIsSaving ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const [ validationMessage , setValidationMessage ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
2025-12-12 13:15:55 +01:00
const validationMessageId = validationMessage ? ` patterns-rename-pattern-category-modal__validation-message- ${ id } ` : void 0 ;
const { saveEntityRecord , invalidateResolution } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _coreData _namespaceObject . store ) ;
const { createErrorNotice , createSuccessNotice } = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
const onChange = ( newName ) => {
2024-04-17 11:32:24 +02:00
if ( validationMessage ) {
2025-12-12 13:15:55 +01:00
setValidationMessage ( void 0 ) ;
2024-04-17 11:32:24 +02:00
}
setName ( newName ) ;
} ;
2025-12-12 13:15:55 +01:00
const onSave = async ( event ) => {
2024-04-17 11:32:24 +02:00
event . preventDefault ( ) ;
if ( isSaving ) {
return ;
}
if ( ! name || name === category . name ) {
2025-12-12 13:15:55 +01:00
const message = ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Please enter a new name for this category." ) ;
( 0 , external _wp _a11y _namespaceObject . speak ) ( message , "assertive" ) ;
2024-04-17 11:32:24 +02:00
setValidationMessage ( message ) ;
textControlRef . current ? . focus ( ) ;
return ;
}
2025-12-12 13:15:55 +01:00
if ( existingCategories . patternCategories . find ( ( existingCategory ) => {
2024-04-17 11:32:24 +02:00
return existingCategory . id !== category . id && existingCategory . label . toLowerCase ( ) === name . toLowerCase ( ) ;
} ) ) {
2025-12-12 13:15:55 +01:00
const message = ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
"This category already exists. Please use a different name."
) ;
( 0 , external _wp _a11y _namespaceObject . speak ) ( message , "assertive" ) ;
2024-04-17 11:32:24 +02:00
setValidationMessage ( message ) ;
textControlRef . current ? . focus ( ) ;
return ;
}
try {
setIsSaving ( true ) ;
2025-12-12 13:15:55 +01:00
const savedRecord = await saveEntityRecord (
"taxonomy" ,
CATEGORY _SLUG ,
{
id : category . id ,
slug : category . slug ,
name
}
) ;
invalidateResolution ( "getUserPatternCategories" ) ;
2024-04-17 11:32:24 +02:00
onSuccess ? . ( savedRecord ) ;
onClose ( ) ;
2025-12-12 13:15:55 +01:00
createSuccessNotice ( ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Pattern category renamed." ) , {
type : "snackbar" ,
id : "pattern-category-update"
2024-04-17 11:32:24 +02:00
} ) ;
} catch ( error ) {
onError ? . ( ) ;
createErrorNotice ( error . message , {
2025-12-12 13:15:55 +01:00
type : "snackbar" ,
id : "pattern-category-update"
2024-04-17 11:32:24 +02:00
} ) ;
} finally {
setIsSaving ( false ) ;
2025-12-12 13:15:55 +01:00
setName ( "" ) ;
2024-04-17 11:32:24 +02:00
}
} ;
const onRequestClose = ( ) => {
onClose ( ) ;
2025-12-12 13:15:55 +01:00
setName ( "" ) ;
2024-04-17 11:32:24 +02:00
} ;
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Modal ,
{
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Rename" ) ,
onRequestClose ,
... props ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "form" , { onSubmit : onSave , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalVStack , { spacing : "5" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalVStack , { spacing : "2" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . TextControl ,
{
ref : textControlRef ,
_ _nextHasNoMarginBottom : true ,
_ _next40pxDefaultSize : true ,
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Name" ) ,
value : name ,
onChange ,
"aria-describedby" : validationMessageId ,
required : true
}
) ,
validationMessage && /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
"span" ,
{
className : "patterns-rename-pattern-category-modal__validation-message" ,
id : validationMessageId ,
children : validationMessage
}
)
] } ) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalHStack , { justify : "right" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "tertiary" ,
onClick : onRequestClose ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Cancel" )
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "primary" ,
type : "submit" ,
"aria-disabled" : ! name || name === category . name || isSaving ,
isBusy : isSaving ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Save" )
}
)
] } )
] } ) } )
}
) ;
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/components/allow-overrides-modal.js
2025-02-28 08:42:11 +01:00
function AllowOverridesModal ( {
placeholder ,
2025-12-12 13:15:55 +01:00
initialName = "" ,
2025-02-28 08:42:11 +01:00
onClose ,
onSave
} ) {
const [ editedBlockName , setEditedBlockName ] = ( 0 , external _wp _element _namespaceObject . useState ) ( initialName ) ;
const descriptionId = ( 0 , external _wp _element _namespaceObject . useId ) ( ) ;
const isNameValid = ! ! editedBlockName . trim ( ) ;
const handleSubmit = ( ) => {
if ( editedBlockName !== initialName ) {
2025-12-12 13:15:55 +01:00
const message = ( 0 , external _wp _i18n _namespaceObject . sprintf ) (
/* translators: %s: new name/label for the block */
( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Block name changed to: "%s".' ) ,
editedBlockName
) ;
( 0 , external _wp _a11y _namespaceObject . speak ) ( message , "assertive" ) ;
2025-02-28 08:42:11 +01:00
}
onSave ( editedBlockName ) ;
onClose ( ) ;
} ;
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Modal ,
{
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Enable overrides" ) ,
onRequestClose : onClose ,
focusOnMount : "firstContentElement" ,
aria : { describedby : descriptionId } ,
size : "small" ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
"form" ,
{
onSubmit : ( event ) => {
event . preventDefault ( ) ;
if ( ! isNameValid ) {
return ;
}
handleSubmit ( ) ;
} ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalVStack , { spacing : "6" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . _ _experimentalText , { id : descriptionId , children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
"Overrides are changes you make to a block within a synced pattern instance. Use overrides to customize a synced pattern instance to suit its new context. Name this block to specify an override."
) } ) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . TextControl ,
{
_ _nextHasNoMarginBottom : true ,
_ _next40pxDefaultSize : true ,
value : editedBlockName ,
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Name" ) ,
help : ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
'For example, if you are creating a recipe pattern, you use "Recipe Title", "Recipe Description", etc.'
) ,
placeholder ,
onChange : setEditedBlockName
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalHStack , { justify : "right" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "tertiary" ,
onClick : onClose ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Cancel" )
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
"aria-disabled" : ! isNameValid ,
variant : "primary" ,
type : "submit" ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Enable" )
}
)
] } )
] } )
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
)
}
) ;
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
function DisallowOverridesModal ( { onClose , onSave } ) {
2025-02-28 08:42:11 +01:00
const descriptionId = ( 0 , external _wp _element _namespaceObject . useId ) ( ) ;
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Modal ,
{
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Disable overrides" ) ,
onRequestClose : onClose ,
aria : { describedby : descriptionId } ,
size : "small" ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
"form" ,
{
onSubmit : ( event ) => {
event . preventDefault ( ) ;
onSave ( ) ;
onClose ( ) ;
} ,
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalVStack , { spacing : "6" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . _ _experimentalText , { id : descriptionId , children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
"Are you sure you want to disable overrides? Disabling overrides will revert all applied overrides for this block throughout instances of this pattern."
) } ) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _wp _components _namespaceObject . _ _experimentalHStack , { justify : "right" , children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "tertiary" ,
onClick : onClose ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Cancel" )
}
) ,
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
variant : "primary" ,
type : "submit" ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Disable" )
}
)
] } )
] } )
}
)
}
) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/pattern-overrides-controls.js
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
function PatternOverridesControls ( {
attributes ,
setAttributes ,
name : blockName
} ) {
const controlId = ( 0 , external _wp _element _namespaceObject . useId ) ( ) ;
const [ showAllowOverridesModal , setShowAllowOverridesModal ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const [ showDisallowOverridesModal , setShowDisallowOverridesModal ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const hasName = ! ! attributes . metadata ? . name ;
const defaultBindings = attributes . metadata ? . bindings ? . _ _default ;
const hasOverrides = hasName && defaultBindings ? . source === PATTERN _OVERRIDES _BINDING _SOURCE ;
const isConnectedToOtherSources = defaultBindings ? . source && defaultBindings . source !== PATTERN _OVERRIDES _BINDING _SOURCE ;
2025-12-12 13:15:55 +01:00
const { updateBlockBindings } = ( 0 , external _wp _blockEditor _namespaceObject . useBlockBindingsUtils ) ( ) ;
2025-02-28 08:42:11 +01:00
function updateBindings ( isChecked , customName ) {
if ( customName ) {
2024-04-17 11:32:24 +02:00
setAttributes ( {
metadata : {
... attributes . metadata ,
2025-02-28 08:42:11 +01:00
name : customName
2024-04-17 11:32:24 +02:00
}
} ) ;
}
2025-02-28 08:42:11 +01:00
updateBlockBindings ( {
2025-12-12 13:15:55 +01:00
_ _default : isChecked ? { source : PATTERN _OVERRIDES _BINDING _SOURCE } : void 0
2025-02-28 08:42:11 +01:00
} ) ;
}
if ( isConnectedToOtherSources ) {
return null ;
}
2025-12-12 13:15:55 +01:00
const hasUnsupportedImageAttributes = blockName === "core/image" && ! ! attributes . href ? . length ;
const helpText = ! hasOverrides && hasUnsupportedImageAttributes ? ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
` Overrides currently don't support image links. Remove the link first before enabling overrides. `
) : ( 0 , external _wp _i18n _namespaceObject . _ _ ) (
"Allow changes to this block throughout instances of this pattern."
) ;
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , { children : [
/* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . InspectorControls , { group : "advanced" , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . BaseControl ,
{
2025-02-28 08:42:11 +01:00
_ _nextHasNoMarginBottom : true ,
id : controlId ,
2025-12-12 13:15:55 +01:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Overrides" ) ,
2025-02-28 08:42:11 +01:00
help : helpText ,
2025-12-12 13:15:55 +01:00
children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . Button ,
{
_ _next40pxDefaultSize : true ,
className : "pattern-overrides-control__allow-overrides-button" ,
variant : "secondary" ,
"aria-haspopup" : "dialog" ,
onClick : ( ) => {
if ( hasOverrides ) {
setShowDisallowOverridesModal ( true ) ;
} else {
setShowAllowOverridesModal ( true ) ;
}
} ,
disabled : ! hasOverrides && hasUnsupportedImageAttributes ,
accessibleWhenDisabled : true ,
children : hasOverrides ? ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Disable overrides" ) : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Enable overrides" )
}
)
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
) } ) ,
showAllowOverridesModal && /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
AllowOverridesModal ,
{
initialName : attributes . metadata ? . name ,
onClose : ( ) => setShowAllowOverridesModal ( false ) ,
onSave : ( newName ) => {
updateBindings ( true , newName ) ;
}
}
) ,
showDisallowOverridesModal && /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
DisallowOverridesModal ,
{
onClose : ( ) => setShowDisallowOverridesModal ( false ) ,
onSave : ( ) => updateBindings ( false )
}
)
] } ) ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
var pattern _overrides _controls _default = PatternOverridesControls ;
2024-04-17 11:32:24 +02:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/components/reset-overrides-control.js
2024-04-17 11:32:24 +02:00
2025-12-12 13:15:55 +01:00
const CONTENT = "content" ;
2024-04-17 11:32:24 +02:00
function ResetOverridesControl ( props ) {
const name = props . attributes . metadata ? . name ;
2025-02-28 08:42:11 +01:00
const registry = ( 0 , external _wp _data _namespaceObject . useRegistry ) ( ) ;
2025-12-12 13:15:55 +01:00
const isOverridden = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => {
if ( ! name ) {
return ;
}
const { getBlockAttributes , getBlockParentsByBlockName } = select ( external _wp _blockEditor _namespaceObject . store ) ;
const [ patternClientId ] = getBlockParentsByBlockName (
props . clientId ,
"core/block" ,
true
) ;
if ( ! patternClientId ) {
return ;
}
const overrides = getBlockAttributes ( patternClientId ) [ CONTENT ] ;
if ( ! overrides ) {
return ;
}
return overrides . hasOwnProperty ( name ) ;
} ,
[ props . clientId , name ]
) ;
2025-02-28 08:42:11 +01:00
function onClick ( ) {
2025-12-12 13:15:55 +01:00
const { getBlockAttributes , getBlockParentsByBlockName } = registry . select ( external _wp _blockEditor _namespaceObject . store ) ;
const [ patternClientId ] = getBlockParentsByBlockName (
props . clientId ,
"core/block" ,
true
) ;
2025-02-28 08:42:11 +01:00
if ( ! patternClientId ) {
return ;
}
const overrides = getBlockAttributes ( patternClientId ) [ CONTENT ] ;
if ( ! overrides . hasOwnProperty ( name ) ) {
return ;
}
2025-12-12 13:15:55 +01:00
const { updateBlockAttributes , _ _unstableMarkLastChangeAsPersistent } = registry . dispatch ( external _wp _blockEditor _namespaceObject . store ) ;
2025-02-28 08:42:11 +01:00
_ _unstableMarkLastChangeAsPersistent ( ) ;
2025-12-12 13:15:55 +01:00
let newOverrides = { ... overrides } ;
2025-02-28 08:42:11 +01:00
delete newOverrides [ name ] ;
if ( ! Object . keys ( newOverrides ) . length ) {
2025-12-12 13:15:55 +01:00
newOverrides = void 0 ;
2025-02-28 08:42:11 +01:00
}
updateBlockAttributes ( patternClientId , {
[ CONTENT ] : newOverrides
} ) ;
}
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . _ _unstableBlockToolbarLastItem , { children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . ToolbarGroup , { children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . ToolbarButton , { onClick , disabled : ! isOverridden , children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "Reset" ) } ) } ) } ) ;
2025-02-28 08:42:11 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/icons/build-module/library/copy.js
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
var copy _default = /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . SVG , { xmlns : "http://www.w3.org/2000/svg" , viewBox : "0 0 24 24" , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _primitives _namespaceObject . Path ,
{
2025-02-28 08:42:11 +01:00
fillRule : "evenodd" ,
clipRule : "evenodd" ,
d : "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"
2025-12-12 13:15:55 +01:00
}
) } ) ;
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
; // ./node_modules/@wordpress/patterns/build-module/components/pattern-overrides-block-controls.js
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
const { useBlockDisplayTitle } = unlock ( external _wp _blockEditor _namespaceObject . privateApis ) ;
function PatternOverridesToolbarIndicator ( { clientIds } ) {
2025-02-28 08:42:11 +01:00
const isSingleBlockSelected = clientIds . length === 1 ;
2025-12-12 13:15:55 +01:00
const { icon , firstBlockName } = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => {
const { getBlockAttributes , getBlockNamesByClientId } = select ( external _wp _blockEditor _namespaceObject . store ) ;
const { getBlockType , getActiveBlockVariation } = select ( external _wp _blocks _namespaceObject . store ) ;
const blockTypeNames = getBlockNamesByClientId ( clientIds ) ;
const _firstBlockTypeName = blockTypeNames [ 0 ] ;
const firstBlockType = getBlockType ( _firstBlockTypeName ) ;
let _icon ;
if ( isSingleBlockSelected ) {
const match = getActiveBlockVariation (
_firstBlockTypeName ,
getBlockAttributes ( clientIds [ 0 ] )
) ;
_icon = match ? . icon || firstBlockType . icon ;
} else {
const isSelectionOfSameType = new Set ( blockTypeNames ) . size === 1 ;
_icon = isSelectionOfSameType ? firstBlockType . icon : copy _default ;
}
return {
icon : _icon ,
firstBlockName : getBlockAttributes ( clientIds [ 0 ] ) . metadata . name
} ;
} ,
[ clientIds , isSingleBlockSelected ]
) ;
2025-02-28 08:42:11 +01:00
const firstBlockTitle = useBlockDisplayTitle ( {
clientId : clientIds [ 0 ] ,
maximumLength : 35
} ) ;
2025-12-12 13:15:55 +01:00
const blockDescription = isSingleBlockSelected ? ( 0 , external _wp _i18n _namespaceObject . sprintf ) (
/* translators: 1: The block type's name. 2: The block's user-provided name (the same as the override name). */
( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'This %1$s is editable using the "%2$s" override.' ) ,
firstBlockTitle . toLowerCase ( ) ,
firstBlockName
) : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( "These blocks are editable using overrides." ) ;
2025-02-28 08:42:11 +01:00
const descriptionId = ( 0 , external _wp _element _namespaceObject . useId ) ( ) ;
2025-12-12 13:15:55 +01:00
return /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . ToolbarItem , { children : ( toggleProps ) => /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _components _namespaceObject . DropdownMenu ,
{
2025-02-28 08:42:11 +01:00
className : "patterns-pattern-overrides-toolbar-indicator" ,
label : firstBlockTitle ,
popoverProps : {
2025-12-12 13:15:55 +01:00
placement : "bottom-start" ,
className : "patterns-pattern-overrides-toolbar-indicator__popover"
2025-02-28 08:42:11 +01:00
} ,
2025-12-12 13:15:55 +01:00
icon : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _ReactJSXRuntime _namespaceObject . Fragment , { children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) (
external _wp _blockEditor _namespaceObject . BlockIcon ,
{
icon ,
2025-02-28 08:42:11 +01:00
className : "patterns-pattern-overrides-toolbar-indicator-icon" ,
showColors : true
2025-12-12 13:15:55 +01:00
}
) } ) ,
2025-02-28 08:42:11 +01:00
toggleProps : {
description : blockDescription ,
... toggleProps
} ,
menuProps : {
2025-12-12 13:15:55 +01:00
orientation : "both" ,
"aria-describedby" : descriptionId
2025-02-28 08:42:11 +01:00
} ,
2025-12-12 13:15:55 +01:00
children : ( ) => /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . _ _experimentalText , { id : descriptionId , children : blockDescription } )
}
) } ) ;
2025-02-28 08:42:11 +01:00
}
function PatternOverridesBlockControls ( ) {
2025-12-12 13:15:55 +01:00
const { clientIds , hasPatternOverrides , hasParentPattern } = ( 0 , external _wp _data _namespaceObject . useSelect ) (
( select ) => {
const {
getBlockAttributes ,
getSelectedBlockClientIds ,
getBlockParentsByBlockName
} = select ( external _wp _blockEditor _namespaceObject . store ) ;
const selectedClientIds = getSelectedBlockClientIds ( ) ;
const _hasPatternOverrides = selectedClientIds . every (
( clientId ) => Object . values (
getBlockAttributes ( clientId ) ? . metadata ? . bindings ? ? { }
) . some (
( binding ) => binding ? . source === PATTERN _OVERRIDES _BINDING _SOURCE
)
) ;
const _hasParentPattern = selectedClientIds . every (
( clientId ) => getBlockParentsByBlockName ( clientId , "core/block" , true ) . length > 0
) ;
return {
clientIds : selectedClientIds ,
hasPatternOverrides : _hasPatternOverrides ,
hasParentPattern : _hasParentPattern
} ;
} ,
[ ]
) ;
return hasPatternOverrides && hasParentPattern ? /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . BlockControls , { group : "parent" , children : /* @__PURE__ */ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( PatternOverridesToolbarIndicator , { clientIds } ) } ) : null ;
2024-04-17 11:32:24 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/private-apis.js
2023-12-07 09:44:11 +01:00
2024-04-17 11:32:24 +02:00
2025-02-28 08:42:11 +01:00
2023-12-07 09:44:11 +01:00
const privateApis = { } ;
lock ( privateApis , {
2025-02-28 08:42:11 +01:00
OverridesPanel : OverridesPanel ,
2023-12-07 09:44:11 +01:00
CreatePatternModal : CreatePatternModal ,
2024-04-17 11:32:24 +02:00
CreatePatternModalContents : CreatePatternModalContents ,
DuplicatePatternModal : DuplicatePatternModal ,
2025-02-28 08:42:11 +01:00
isOverridableBlock : isOverridableBlock ,
hasOverridableBlocks : hasOverridableBlocks ,
2024-04-17 11:32:24 +02:00
useDuplicatePatternProps : useDuplicatePatternProps ,
RenamePatternModal : RenamePatternModal ,
2023-12-07 09:44:11 +01:00
PatternsMenuItems : PatternsMenuItems ,
2024-04-17 11:32:24 +02:00
RenamePatternCategoryModal : RenamePatternCategoryModal ,
2025-12-12 13:15:55 +01:00
PatternOverridesControls : pattern _overrides _controls _default ,
2024-04-17 11:32:24 +02:00
ResetOverridesControl : ResetOverridesControl ,
2025-02-28 08:42:11 +01:00
PatternOverridesBlockControls : PatternOverridesBlockControls ,
2024-04-17 11:32:24 +02:00
useAddPatternCategory : useAddPatternCategory ,
2023-12-07 09:44:11 +01:00
PATTERN _TYPES : PATTERN _TYPES ,
PATTERN _DEFAULT _CATEGORY : PATTERN _DEFAULT _CATEGORY ,
PATTERN _USER _CATEGORY : PATTERN _USER _CATEGORY ,
2024-04-17 11:32:24 +02:00
EXCLUDED _PATTERN _SOURCES : EXCLUDED _PATTERN _SOURCES ,
PATTERN _SYNC _TYPES : PATTERN _SYNC _TYPES ,
PARTIAL _SYNCING _SUPPORTED _BLOCKS : PARTIAL _SYNCING _SUPPORTED _BLOCKS
2023-12-07 09:44:11 +01:00
} ) ;
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
; // ./node_modules/@wordpress/patterns/build-module/index.js
2025-12-12 13:15:55 +01:00
2023-12-07 09:44:11 +01:00
( window . wp = window . wp || { } ) . patterns = _ _webpack _exports _ _ ;
/******/ } ) ( )
;