| 1 |
var wp; |
| 2 |
(wp ||= {}).patterns = (() => { |
| 3 |
var __create = Object.create; |
| 4 |
var __defProp = Object.defineProperty; |
| 5 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 6 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 7 |
var __getProtoOf = Object.getPrototypeOf; |
| 8 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 9 |
var __commonJS = (cb, mod) => function __require() { |
| 10 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 11 |
}; |
| 12 |
var __export = (target, all) => { |
| 13 |
for (var name in all) |
| 14 |
__defProp(target, name, { get: all[name], enumerable: true }); |
| 15 |
}; |
| 16 |
var __copyProps = (to, from, except, desc) => { |
| 17 |
if (from && typeof from === "object" || typeof from === "function") { |
| 18 |
for (let key of __getOwnPropNames(from)) |
| 19 |
if (!__hasOwnProp.call(to, key) && key !== except) |
| 20 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 21 |
} |
| 22 |
return to; |
| 23 |
}; |
| 24 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 25 |
// If the importer is in node compatibility mode or this is not an ESM |
| 26 |
// file that has been converted to a CommonJS file using a Babel- |
| 27 |
// compatible transform (i.e. "__esModule" has not been set), then set |
| 28 |
// "default" to the CommonJS "module.exports" for node compatibility. |
| 29 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 30 |
mod |
| 31 |
)); |
| 32 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 33 |
|
| 34 |
// package-external:@wordpress/data |
| 35 |
var require_data = __commonJS({ |
| 36 |
"package-external:@wordpress/data"(exports, module) { |
| 37 |
module.exports = window.wp.data; |
| 38 |
} |
| 39 |
}); |
| 40 |
|
| 41 |
// package-external:@wordpress/blocks |
| 42 |
var require_blocks = __commonJS({ |
| 43 |
"package-external:@wordpress/blocks"(exports, module) { |
| 44 |
module.exports = window.wp.blocks; |
| 45 |
} |
| 46 |
}); |
| 47 |
|
| 48 |
// package-external:@wordpress/core-data |
| 49 |
var require_core_data = __commonJS({ |
| 50 |
"package-external:@wordpress/core-data"(exports, module) { |
| 51 |
module.exports = window.wp.coreData; |
| 52 |
} |
| 53 |
}); |
| 54 |
|
| 55 |
// package-external:@wordpress/block-editor |
| 56 |
var require_block_editor = __commonJS({ |
| 57 |
"package-external:@wordpress/block-editor"(exports, module) { |
| 58 |
module.exports = window.wp.blockEditor; |
| 59 |
} |
| 60 |
}); |
| 61 |
|
| 62 |
// package-external:@wordpress/private-apis |
| 63 |
var require_private_apis = __commonJS({ |
| 64 |
"package-external:@wordpress/private-apis"(exports, module) { |
| 65 |
module.exports = window.wp.privateApis; |
| 66 |
} |
| 67 |
}); |
| 68 |
|
| 69 |
// package-external:@wordpress/components |
| 70 |
var require_components = __commonJS({ |
| 71 |
"package-external:@wordpress/components"(exports, module) { |
| 72 |
module.exports = window.wp.components; |
| 73 |
} |
| 74 |
}); |
| 75 |
|
| 76 |
// package-external:@wordpress/element |
| 77 |
var require_element = __commonJS({ |
| 78 |
"package-external:@wordpress/element"(exports, module) { |
| 79 |
module.exports = window.wp.element; |
| 80 |
} |
| 81 |
}); |
| 82 |
|
| 83 |
// package-external:@wordpress/i18n |
| 84 |
var require_i18n = __commonJS({ |
| 85 |
"package-external:@wordpress/i18n"(exports, module) { |
| 86 |
module.exports = window.wp.i18n; |
| 87 |
} |
| 88 |
}); |
| 89 |
|
| 90 |
// vendor-external:react/jsx-runtime |
| 91 |
var require_jsx_runtime = __commonJS({ |
| 92 |
"vendor-external:react/jsx-runtime"(exports, module) { |
| 93 |
module.exports = window.ReactJSXRuntime; |
| 94 |
} |
| 95 |
}); |
| 96 |
|
| 97 |
// vendor-external:react |
| 98 |
var require_react = __commonJS({ |
| 99 |
"vendor-external:react"(exports, module) { |
| 100 |
module.exports = window.React; |
| 101 |
} |
| 102 |
}); |
| 103 |
|
| 104 |
// package-external:@wordpress/a11y |
| 105 |
var require_a11y = __commonJS({ |
| 106 |
"package-external:@wordpress/a11y"(exports, module) { |
| 107 |
module.exports = window.wp.a11y; |
| 108 |
} |
| 109 |
}); |
| 110 |
|
| 111 |
// package-external:@wordpress/primitives |
| 112 |
var require_primitives = __commonJS({ |
| 113 |
"package-external:@wordpress/primitives"(exports, module) { |
| 114 |
module.exports = window.wp.primitives; |
| 115 |
} |
| 116 |
}); |
| 117 |
|
| 118 |
// package-external:@wordpress/compose |
| 119 |
var require_compose = __commonJS({ |
| 120 |
"package-external:@wordpress/compose"(exports, module) { |
| 121 |
module.exports = window.wp.compose; |
| 122 |
} |
| 123 |
}); |
| 124 |
|
| 125 |
// package-external:@wordpress/notices |
| 126 |
var require_notices = __commonJS({ |
| 127 |
"package-external:@wordpress/notices"(exports, module) { |
| 128 |
module.exports = window.wp.notices; |
| 129 |
} |
| 130 |
}); |
| 131 |
|
| 132 |
// package-external:@wordpress/html-entities |
| 133 |
var require_html_entities = __commonJS({ |
| 134 |
"package-external:@wordpress/html-entities"(exports, module) { |
| 135 |
module.exports = window.wp.htmlEntities; |
| 136 |
} |
| 137 |
}); |
| 138 |
|
| 139 |
// package-external:@wordpress/url |
| 140 |
var require_url = __commonJS({ |
| 141 |
"package-external:@wordpress/url"(exports, module) { |
| 142 |
module.exports = window.wp.url; |
| 143 |
} |
| 144 |
}); |
| 145 |
|
| 146 |
// packages/patterns/build-module/index.mjs |
| 147 |
var index_exports = {}; |
| 148 |
__export(index_exports, { |
| 149 |
privateApis: () => privateApis, |
| 150 |
store: () => store |
| 151 |
}); |
| 152 |
|
| 153 |
// packages/patterns/build-module/store/index.mjs |
| 154 |
var import_data2 = __toESM(require_data(), 1); |
| 155 |
|
| 156 |
// packages/patterns/build-module/store/reducer.mjs |
| 157 |
var import_data = __toESM(require_data(), 1); |
| 158 |
function isEditingPattern(state = {}, action) { |
| 159 |
if (action?.type === "SET_EDITING_PATTERN") { |
| 160 |
return { |
| 161 |
...state, |
| 162 |
[action.clientId]: action.isEditing |
| 163 |
}; |
| 164 |
} |
| 165 |
return state; |
| 166 |
} |
| 167 |
var reducer_default = (0, import_data.combineReducers)({ |
| 168 |
isEditingPattern |
| 169 |
}); |
| 170 |
|
| 171 |
// packages/patterns/build-module/store/actions.mjs |
| 172 |
var actions_exports = {}; |
| 173 |
__export(actions_exports, { |
| 174 |
convertSyncedPatternToStatic: () => convertSyncedPatternToStatic, |
| 175 |
createPattern: () => createPattern, |
| 176 |
createPatternFromFile: () => createPatternFromFile, |
| 177 |
setEditingPattern: () => setEditingPattern |
| 178 |
}); |
| 179 |
var import_blocks = __toESM(require_blocks(), 1); |
| 180 |
var import_core_data = __toESM(require_core_data(), 1); |
| 181 |
var import_block_editor = __toESM(require_block_editor(), 1); |
| 182 |
|
| 183 |
// packages/patterns/build-module/constants.mjs |
| 184 |
var PATTERN_TYPES = { |
| 185 |
theme: "pattern", |
| 186 |
user: "wp_block" |
| 187 |
}; |
| 188 |
var PATTERN_DEFAULT_CATEGORY = "all-patterns"; |
| 189 |
var PATTERN_USER_CATEGORY = "my-patterns"; |
| 190 |
var EXCLUDED_PATTERN_SOURCES = [ |
| 191 |
"core", |
| 192 |
"pattern-directory/core", |
| 193 |
"pattern-directory/featured" |
| 194 |
]; |
| 195 |
var PATTERN_SYNC_TYPES = { |
| 196 |
full: "fully", |
| 197 |
unsynced: "unsynced" |
| 198 |
}; |
| 199 |
var PATTERN_OVERRIDES_BINDING_SOURCE = "core/pattern-overrides"; |
| 200 |
|
| 201 |
// packages/patterns/build-module/store/actions.mjs |
| 202 |
var createPattern = (title, syncType, content, categories) => async ({ registry }) => { |
| 203 |
const meta = syncType === PATTERN_SYNC_TYPES.unsynced ? { |
| 204 |
wp_pattern_sync_status: syncType |
| 205 |
} : void 0; |
| 206 |
const reusableBlock = { |
| 207 |
title, |
| 208 |
content, |
| 209 |
status: "publish", |
| 210 |
meta, |
| 211 |
wp_pattern_category: categories |
| 212 |
}; |
| 213 |
const updatedRecord = await registry.dispatch(import_core_data.store).saveEntityRecord("postType", "wp_block", reusableBlock); |
| 214 |
return updatedRecord; |
| 215 |
}; |
| 216 |
var createPatternFromFile = (file, categories) => async ({ dispatch }) => { |
| 217 |
const fileContent = await file.text(); |
| 218 |
let parsedContent; |
| 219 |
try { |
| 220 |
parsedContent = JSON.parse(fileContent); |
| 221 |
} catch { |
| 222 |
throw new Error("Invalid JSON file"); |
| 223 |
} |
| 224 |
if (parsedContent.__file !== "wp_block" || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== "string" || typeof parsedContent.content !== "string" || parsedContent.syncStatus && typeof parsedContent.syncStatus !== "string") { |
| 225 |
throw new Error("Invalid pattern JSON file"); |
| 226 |
} |
| 227 |
const pattern = await dispatch.createPattern( |
| 228 |
parsedContent.title, |
| 229 |
parsedContent.syncStatus, |
| 230 |
parsedContent.content, |
| 231 |
categories |
| 232 |
); |
| 233 |
return pattern; |
| 234 |
}; |
| 235 |
var convertSyncedPatternToStatic = (clientId) => ({ registry }) => { |
| 236 |
const patternBlock = registry.select(import_block_editor.store).getBlock(clientId); |
| 237 |
const existingOverrides = patternBlock.attributes?.content; |
| 238 |
function cloneBlocksAndRemoveBindings(blocks) { |
| 239 |
return blocks.map((block) => { |
| 240 |
let metadata = block.attributes.metadata; |
| 241 |
if (metadata) { |
| 242 |
metadata = { ...metadata }; |
| 243 |
delete metadata.id; |
| 244 |
delete metadata.bindings; |
| 245 |
if (existingOverrides?.[metadata.name]) { |
| 246 |
for (const [attributeName, value] of Object.entries( |
| 247 |
existingOverrides[metadata.name] |
| 248 |
)) { |
| 249 |
if (!(0, import_blocks.getBlockType)(block.name)?.attributes[attributeName]) { |
| 250 |
continue; |
| 251 |
} |
| 252 |
block.attributes[attributeName] = value; |
| 253 |
} |
| 254 |
} |
| 255 |
} |
| 256 |
return (0, import_blocks.cloneBlock)( |
| 257 |
block, |
| 258 |
{ |
| 259 |
metadata: metadata && Object.keys(metadata).length > 0 ? metadata : void 0 |
| 260 |
}, |
| 261 |
cloneBlocksAndRemoveBindings(block.innerBlocks) |
| 262 |
); |
| 263 |
}); |
| 264 |
} |
| 265 |
const patternInnerBlocks = registry.select(import_block_editor.store).getBlocks(patternBlock.clientId); |
| 266 |
registry.dispatch(import_block_editor.store).replaceBlocks( |
| 267 |
patternBlock.clientId, |
| 268 |
cloneBlocksAndRemoveBindings(patternInnerBlocks) |
| 269 |
); |
| 270 |
}; |
| 271 |
function setEditingPattern(clientId, isEditing) { |
| 272 |
return { |
| 273 |
type: "SET_EDITING_PATTERN", |
| 274 |
clientId, |
| 275 |
isEditing |
| 276 |
}; |
| 277 |
} |
| 278 |
|
| 279 |
// packages/patterns/build-module/store/constants.mjs |
| 280 |
var STORE_NAME = "core/patterns"; |
| 281 |
|
| 282 |
// packages/patterns/build-module/store/selectors.mjs |
| 283 |
var selectors_exports = {}; |
| 284 |
__export(selectors_exports, { |
| 285 |
isEditingPattern: () => isEditingPattern2 |
| 286 |
}); |
| 287 |
function isEditingPattern2(state, clientId) { |
| 288 |
return state.isEditingPattern[clientId]; |
| 289 |
} |
| 290 |
|
| 291 |
// packages/patterns/build-module/lock-unlock.mjs |
| 292 |
var import_private_apis = __toESM(require_private_apis(), 1); |
| 293 |
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( |
| 294 |
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", |
| 295 |
"@wordpress/patterns" |
| 296 |
); |
| 297 |
|
| 298 |
// packages/patterns/build-module/store/index.mjs |
| 299 |
var storeConfig = { |
| 300 |
reducer: reducer_default |
| 301 |
}; |
| 302 |
var store = (0, import_data2.createReduxStore)(STORE_NAME, { |
| 303 |
...storeConfig |
| 304 |
}); |
| 305 |
(0, import_data2.register)(store); |
| 306 |
unlock(store).registerPrivateActions(actions_exports); |
| 307 |
unlock(store).registerPrivateSelectors(selectors_exports); |
| 308 |
|
| 309 |
// packages/patterns/build-module/components/overrides-panel.mjs |
| 310 |
var import_block_editor2 = __toESM(require_block_editor(), 1); |
| 311 |
var import_components = __toESM(require_components(), 1); |
| 312 |
var import_data3 = __toESM(require_data(), 1); |
| 313 |
var import_element = __toESM(require_element(), 1); |
| 314 |
var import_i18n = __toESM(require_i18n(), 1); |
| 315 |
|
| 316 |
// packages/patterns/build-module/api/index.mjs |
| 317 |
function isOverridableBlock(block) { |
| 318 |
return !!block.attributes.metadata?.name && !!block.attributes.metadata?.bindings && Object.values(block.attributes.metadata.bindings).some( |
| 319 |
(binding) => binding.source === "core/pattern-overrides" |
| 320 |
); |
| 321 |
} |
| 322 |
|
| 323 |
// packages/patterns/build-module/components/overrides-panel.mjs |
| 324 |
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); |
| 325 |
var { BlockQuickNavigation } = unlock(import_block_editor2.privateApis); |
| 326 |
function OverridesPanel() { |
| 327 |
const { allClientIds, supportedBlockTypesRaw } = (0, import_data3.useSelect)( |
| 328 |
(select) => ({ |
| 329 |
allClientIds: select(import_block_editor2.store).getClientIdsWithDescendants(), |
| 330 |
supportedBlockTypesRaw: select(import_block_editor2.store).getSettings()?.__experimentalBlockBindingsSupportedAttributes |
| 331 |
}), |
| 332 |
[] |
| 333 |
); |
| 334 |
const { getBlock } = (0, import_data3.useSelect)(import_block_editor2.store); |
| 335 |
const clientIdsWithOverrides = (0, import_element.useMemo)(() => { |
| 336 |
const supportedBlockTypes = Object.keys(supportedBlockTypesRaw ?? {}); |
| 337 |
return allClientIds.filter((clientId) => { |
| 338 |
const block = getBlock(clientId); |
| 339 |
return supportedBlockTypes.includes(block.name) && isOverridableBlock(block); |
| 340 |
}); |
| 341 |
}, [allClientIds, getBlock, supportedBlockTypesRaw]); |
| 342 |
if (!clientIdsWithOverrides?.length) { |
| 343 |
return null; |
| 344 |
} |
| 345 |
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.PanelBody, { title: (0, import_i18n.__)("Overrides"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockQuickNavigation, { clientIds: clientIdsWithOverrides }) }); |
| 346 |
} |
| 347 |
|
| 348 |
// packages/patterns/build-module/components/create-pattern-modal.mjs |
| 349 |
var import_components3 = __toESM(require_components(), 1); |
| 350 |
|
| 351 |
// node_modules/clsx/dist/clsx.mjs |
| 352 |
function r(e) { |
| 353 |
var t, f, n = ""; |
| 354 |
if ("string" == typeof e || "number" == typeof e) n += e; |
| 355 |
else if ("object" == typeof e) if (Array.isArray(e)) { |
| 356 |
var o = e.length; |
| 357 |
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f); |
| 358 |
} else for (f in e) e[f] && (n && (n += " "), n += f); |
| 359 |
return n; |
| 360 |
} |
| 361 |
function clsx() { |
| 362 |
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t); |
| 363 |
return n; |
| 364 |
} |
| 365 |
var clsx_default = clsx; |
| 366 |
|
| 367 |
// node_modules/@base-ui/utils/esm/useRefWithInit.js |
| 368 |
var React = __toESM(require_react(), 1); |
| 369 |
var UNINITIALIZED = {}; |
| 370 |
function useRefWithInit(init, initArg) { |
| 371 |
const ref = React.useRef(UNINITIALIZED); |
| 372 |
if (ref.current === UNINITIALIZED) { |
| 373 |
ref.current = init(initArg); |
| 374 |
} |
| 375 |
return ref; |
| 376 |
} |
| 377 |
|
| 378 |
// node_modules/@base-ui/utils/esm/warn.js |
| 379 |
var set; |
| 380 |
if (true) { |
| 381 |
set = /* @__PURE__ */ new Set(); |
| 382 |
} |
| 383 |
function warn(...messages) { |
| 384 |
if (true) { |
| 385 |
const messageKey = messages.join(" "); |
| 386 |
if (!set.has(messageKey)) { |
| 387 |
set.add(messageKey); |
| 388 |
console.warn(`Base UI: ${messageKey}`); |
| 389 |
} |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
// node_modules/@base-ui/react/esm/internals/useRenderElement.js |
| 394 |
var React4 = __toESM(require_react(), 1); |
| 395 |
|
| 396 |
// node_modules/@base-ui/utils/esm/useMergedRefs.js |
| 397 |
function useMergedRefs(a, b, c, d) { |
| 398 |
const forkRef = useRefWithInit(createForkRef).current; |
| 399 |
if (didChange(forkRef, a, b, c, d)) { |
| 400 |
update(forkRef, [a, b, c, d]); |
| 401 |
} |
| 402 |
return forkRef.callback; |
| 403 |
} |
| 404 |
function useMergedRefsN(refs) { |
| 405 |
const forkRef = useRefWithInit(createForkRef).current; |
| 406 |
if (didChangeN(forkRef, refs)) { |
| 407 |
update(forkRef, refs); |
| 408 |
} |
| 409 |
return forkRef.callback; |
| 410 |
} |
| 411 |
function createForkRef() { |
| 412 |
return { |
| 413 |
callback: null, |
| 414 |
cleanup: null, |
| 415 |
refs: [] |
| 416 |
}; |
| 417 |
} |
| 418 |
function didChange(forkRef, a, b, c, d) { |
| 419 |
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d; |
| 420 |
} |
| 421 |
function didChangeN(forkRef, newRefs) { |
| 422 |
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]); |
| 423 |
} |
| 424 |
function update(forkRef, refs) { |
| 425 |
forkRef.refs = refs; |
| 426 |
if (refs.every((ref) => ref == null)) { |
| 427 |
forkRef.callback = null; |
| 428 |
return; |
| 429 |
} |
| 430 |
forkRef.callback = (instance) => { |
| 431 |
if (forkRef.cleanup) { |
| 432 |
forkRef.cleanup(); |
| 433 |
forkRef.cleanup = null; |
| 434 |
} |
| 435 |
if (instance != null) { |
| 436 |
const cleanupCallbacks = Array(refs.length).fill(null); |
| 437 |
for (let i = 0; i < refs.length; i += 1) { |
| 438 |
const ref = refs[i]; |
| 439 |
if (ref == null) { |
| 440 |
continue; |
| 441 |
} |
| 442 |
switch (typeof ref) { |
| 443 |
case "function": { |
| 444 |
const refCleanup = ref(instance); |
| 445 |
if (typeof refCleanup === "function") { |
| 446 |
cleanupCallbacks[i] = refCleanup; |
| 447 |
} |
| 448 |
break; |
| 449 |
} |
| 450 |
case "object": { |
| 451 |
ref.current = instance; |
| 452 |
break; |
| 453 |
} |
| 454 |
default: |
| 455 |
} |
| 456 |
} |
| 457 |
forkRef.cleanup = () => { |
| 458 |
for (let i = 0; i < refs.length; i += 1) { |
| 459 |
const ref = refs[i]; |
| 460 |
if (ref == null) { |
| 461 |
continue; |
| 462 |
} |
| 463 |
switch (typeof ref) { |
| 464 |
case "function": { |
| 465 |
const cleanupCallback = cleanupCallbacks[i]; |
| 466 |
if (typeof cleanupCallback === "function") { |
| 467 |
cleanupCallback(); |
| 468 |
} else { |
| 469 |
ref(null); |
| 470 |
} |
| 471 |
break; |
| 472 |
} |
| 473 |
case "object": { |
| 474 |
ref.current = null; |
| 475 |
break; |
| 476 |
} |
| 477 |
default: |
| 478 |
} |
| 479 |
} |
| 480 |
}; |
| 481 |
} |
| 482 |
}; |
| 483 |
} |
| 484 |
|
| 485 |
// node_modules/@base-ui/utils/esm/getReactElementRef.js |
| 486 |
var React3 = __toESM(require_react(), 1); |
| 487 |
|
| 488 |
// node_modules/@base-ui/utils/esm/reactVersion.js |
| 489 |
var React2 = __toESM(require_react(), 1); |
| 490 |
var majorVersion = parseInt(React2.version, 10); |
| 491 |
function isReactVersionAtLeast(reactVersionToCheck) { |
| 492 |
return majorVersion >= reactVersionToCheck; |
| 493 |
} |
| 494 |
|
| 495 |
// node_modules/@base-ui/utils/esm/getReactElementRef.js |
| 496 |
function getReactElementRef(element) { |
| 497 |
if (!/* @__PURE__ */ React3.isValidElement(element)) { |
| 498 |
return null; |
| 499 |
} |
| 500 |
const reactElement = element; |
| 501 |
const propsWithRef = reactElement.props; |
| 502 |
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null; |
| 503 |
} |
| 504 |
|
| 505 |
// node_modules/@base-ui/utils/esm/mergeObjects.js |
| 506 |
function mergeObjects(a, b) { |
| 507 |
if (a && !b) { |
| 508 |
return a; |
| 509 |
} |
| 510 |
if (!a && b) { |
| 511 |
return b; |
| 512 |
} |
| 513 |
if (a || b) { |
| 514 |
return { |
| 515 |
...a, |
| 516 |
...b |
| 517 |
}; |
| 518 |
} |
| 519 |
return void 0; |
| 520 |
} |
| 521 |
|
| 522 |
// node_modules/@base-ui/utils/esm/empty.js |
| 523 |
var EMPTY_ARRAY = Object.freeze([]); |
| 524 |
var EMPTY_OBJECT = Object.freeze({}); |
| 525 |
|
| 526 |
// node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js |
| 527 |
function getStateAttributesProps(state, customMapping) { |
| 528 |
const props = {}; |
| 529 |
for (const key in state) { |
| 530 |
const value = state[key]; |
| 531 |
if (customMapping?.hasOwnProperty(key)) { |
| 532 |
const customProps = customMapping[key](value); |
| 533 |
if (customProps != null) { |
| 534 |
Object.assign(props, customProps); |
| 535 |
} |
| 536 |
continue; |
| 537 |
} |
| 538 |
if (value === true) { |
| 539 |
props[`data-${key.toLowerCase()}`] = ""; |
| 540 |
} else if (value) { |
| 541 |
props[`data-${key.toLowerCase()}`] = value.toString(); |
| 542 |
} |
| 543 |
} |
| 544 |
return props; |
| 545 |
} |
| 546 |
|
| 547 |
// node_modules/@base-ui/react/esm/utils/resolveClassName.js |
| 548 |
function resolveClassName(className, state) { |
| 549 |
return typeof className === "function" ? className(state) : className; |
| 550 |
} |
| 551 |
|
| 552 |
// node_modules/@base-ui/react/esm/utils/resolveStyle.js |
| 553 |
function resolveStyle(style, state) { |
| 554 |
return typeof style === "function" ? style(state) : style; |
| 555 |
} |
| 556 |
|
| 557 |
// node_modules/@base-ui/react/esm/merge-props/mergeProps.js |
| 558 |
var EMPTY_PROPS = {}; |
| 559 |
function mergeProps(a, b, c, d, e) { |
| 560 |
if (!c && !d && !e && !a) { |
| 561 |
return createInitialMergedProps(b); |
| 562 |
} |
| 563 |
let merged = createInitialMergedProps(a); |
| 564 |
if (b) { |
| 565 |
merged = mergeInto(merged, b); |
| 566 |
} |
| 567 |
if (c) { |
| 568 |
merged = mergeInto(merged, c); |
| 569 |
} |
| 570 |
if (d) { |
| 571 |
merged = mergeInto(merged, d); |
| 572 |
} |
| 573 |
if (e) { |
| 574 |
merged = mergeInto(merged, e); |
| 575 |
} |
| 576 |
return merged; |
| 577 |
} |
| 578 |
function mergePropsN(props) { |
| 579 |
if (props.length === 0) { |
| 580 |
return EMPTY_PROPS; |
| 581 |
} |
| 582 |
if (props.length === 1) { |
| 583 |
return createInitialMergedProps(props[0]); |
| 584 |
} |
| 585 |
let merged = createInitialMergedProps(props[0]); |
| 586 |
for (let i = 1; i < props.length; i += 1) { |
| 587 |
merged = mergeInto(merged, props[i]); |
| 588 |
} |
| 589 |
return merged; |
| 590 |
} |
| 591 |
function createInitialMergedProps(inputProps) { |
| 592 |
if (isPropsGetter(inputProps)) { |
| 593 |
return { |
| 594 |
...resolvePropsGetter(inputProps, EMPTY_PROPS) |
| 595 |
}; |
| 596 |
} |
| 597 |
return copyInitialProps(inputProps); |
| 598 |
} |
| 599 |
function mergeInto(merged, inputProps) { |
| 600 |
if (isPropsGetter(inputProps)) { |
| 601 |
return resolvePropsGetter(inputProps, merged); |
| 602 |
} |
| 603 |
return mutablyMergeInto(merged, inputProps); |
| 604 |
} |
| 605 |
function copyInitialProps(inputProps) { |
| 606 |
const copiedProps = { |
| 607 |
...inputProps |
| 608 |
}; |
| 609 |
for (const propName in copiedProps) { |
| 610 |
const propValue = copiedProps[propName]; |
| 611 |
if (isEventHandler(propName, propValue)) { |
| 612 |
copiedProps[propName] = wrapEventHandler(propValue); |
| 613 |
} |
| 614 |
} |
| 615 |
return copiedProps; |
| 616 |
} |
| 617 |
function mutablyMergeInto(mergedProps, externalProps) { |
| 618 |
if (!externalProps) { |
| 619 |
return mergedProps; |
| 620 |
} |
| 621 |
for (const propName in externalProps) { |
| 622 |
const externalPropValue = externalProps[propName]; |
| 623 |
switch (propName) { |
| 624 |
case "style": { |
| 625 |
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue); |
| 626 |
break; |
| 627 |
} |
| 628 |
case "className": { |
| 629 |
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue); |
| 630 |
break; |
| 631 |
} |
| 632 |
default: { |
| 633 |
if (isEventHandler(propName, externalPropValue)) { |
| 634 |
mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue); |
| 635 |
} else { |
| 636 |
mergedProps[propName] = externalPropValue; |
| 637 |
} |
| 638 |
} |
| 639 |
} |
| 640 |
} |
| 641 |
return mergedProps; |
| 642 |
} |
| 643 |
function isEventHandler(key, value) { |
| 644 |
const code0 = key.charCodeAt(0); |
| 645 |
const code1 = key.charCodeAt(1); |
| 646 |
const code2 = key.charCodeAt(2); |
| 647 |
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined"); |
| 648 |
} |
| 649 |
function isPropsGetter(inputProps) { |
| 650 |
return typeof inputProps === "function"; |
| 651 |
} |
| 652 |
function resolvePropsGetter(inputProps, previousProps) { |
| 653 |
if (isPropsGetter(inputProps)) { |
| 654 |
return inputProps(previousProps); |
| 655 |
} |
| 656 |
return inputProps ?? EMPTY_PROPS; |
| 657 |
} |
| 658 |
function mergeEventHandlers(ourHandler, theirHandler) { |
| 659 |
if (!theirHandler) { |
| 660 |
return ourHandler; |
| 661 |
} |
| 662 |
if (!ourHandler) { |
| 663 |
return wrapEventHandler(theirHandler); |
| 664 |
} |
| 665 |
return (...args) => { |
| 666 |
const event = args[0]; |
| 667 |
if (isSyntheticEvent(event)) { |
| 668 |
const baseUIEvent = event; |
| 669 |
makeEventPreventable(baseUIEvent); |
| 670 |
const result2 = theirHandler(...args); |
| 671 |
if (!baseUIEvent.baseUIHandlerPrevented) { |
| 672 |
ourHandler?.(...args); |
| 673 |
} |
| 674 |
return result2; |
| 675 |
} |
| 676 |
const result = theirHandler(...args); |
| 677 |
ourHandler?.(...args); |
| 678 |
return result; |
| 679 |
}; |
| 680 |
} |
| 681 |
function wrapEventHandler(handler) { |
| 682 |
if (!handler) { |
| 683 |
return handler; |
| 684 |
} |
| 685 |
return (...args) => { |
| 686 |
const event = args[0]; |
| 687 |
if (isSyntheticEvent(event)) { |
| 688 |
makeEventPreventable(event); |
| 689 |
} |
| 690 |
return handler(...args); |
| 691 |
}; |
| 692 |
} |
| 693 |
function makeEventPreventable(event) { |
| 694 |
event.preventBaseUIHandler = () => { |
| 695 |
event.baseUIHandlerPrevented = true; |
| 696 |
}; |
| 697 |
return event; |
| 698 |
} |
| 699 |
function mergeClassNames(ourClassName, theirClassName) { |
| 700 |
if (theirClassName) { |
| 701 |
if (ourClassName) { |
| 702 |
return theirClassName + " " + ourClassName; |
| 703 |
} |
| 704 |
return theirClassName; |
| 705 |
} |
| 706 |
return ourClassName; |
| 707 |
} |
| 708 |
function isSyntheticEvent(event) { |
| 709 |
return event != null && typeof event === "object" && "nativeEvent" in event; |
| 710 |
} |
| 711 |
|
| 712 |
// node_modules/@base-ui/react/esm/internals/useRenderElement.js |
| 713 |
var import_react = __toESM(require_react(), 1); |
| 714 |
function useRenderElement(element, componentProps, params = {}) { |
| 715 |
const renderProp = componentProps.render; |
| 716 |
const outProps = useRenderElementProps(componentProps, params); |
| 717 |
if (params.enabled === false) { |
| 718 |
return null; |
| 719 |
} |
| 720 |
const state = params.state ?? EMPTY_OBJECT; |
| 721 |
return evaluateRenderProp(element, renderProp, outProps, state); |
| 722 |
} |
| 723 |
function useRenderElementProps(componentProps, params = {}) { |
| 724 |
const { |
| 725 |
className: classNameProp, |
| 726 |
style: styleProp, |
| 727 |
render: renderProp |
| 728 |
} = componentProps; |
| 729 |
const { |
| 730 |
state = EMPTY_OBJECT, |
| 731 |
ref, |
| 732 |
props, |
| 733 |
stateAttributesMapping, |
| 734 |
enabled = true |
| 735 |
} = params; |
| 736 |
const className = enabled ? resolveClassName(classNameProp, state) : void 0; |
| 737 |
const style = enabled ? resolveStyle(styleProp, state) : void 0; |
| 738 |
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT; |
| 739 |
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0; |
| 740 |
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT; |
| 741 |
if (typeof document !== "undefined") { |
| 742 |
if (!enabled) { |
| 743 |
useMergedRefs(null, null); |
| 744 |
} else if (Array.isArray(ref)) { |
| 745 |
outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]); |
| 746 |
} else { |
| 747 |
outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref); |
| 748 |
} |
| 749 |
} |
| 750 |
if (!enabled) { |
| 751 |
return EMPTY_OBJECT; |
| 752 |
} |
| 753 |
if (className !== void 0) { |
| 754 |
outProps.className = mergeClassNames(outProps.className, className); |
| 755 |
} |
| 756 |
if (style !== void 0) { |
| 757 |
outProps.style = mergeObjects(outProps.style, style); |
| 758 |
} |
| 759 |
return outProps; |
| 760 |
} |
| 761 |
function resolveRenderFunctionProps(props) { |
| 762 |
if (Array.isArray(props)) { |
| 763 |
return mergePropsN(props); |
| 764 |
} |
| 765 |
return mergeProps(void 0, props); |
| 766 |
} |
| 767 |
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); |
| 768 |
var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/; |
| 769 |
var LOWERCASE_CHARACTER_PATTERN = /[a-z]/; |
| 770 |
function evaluateRenderProp(element, render, props, state) { |
| 771 |
if (render) { |
| 772 |
if (typeof render === "function") { |
| 773 |
if (true) { |
| 774 |
warnIfRenderPropLooksLikeComponent(render); |
| 775 |
} |
| 776 |
return render(props, state); |
| 777 |
} |
| 778 |
const mergedProps = mergeProps(props, render.props); |
| 779 |
mergedProps.ref = props.ref; |
| 780 |
let newElement = render; |
| 781 |
if (newElement?.$$typeof === REACT_LAZY_TYPE) { |
| 782 |
const children = React4.Children.toArray(render); |
| 783 |
newElement = children[0]; |
| 784 |
} |
| 785 |
if (true) { |
| 786 |
if (!/* @__PURE__ */ React4.isValidElement(newElement)) { |
| 787 |
throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n")); |
| 788 |
} |
| 789 |
} |
| 790 |
return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps); |
| 791 |
} |
| 792 |
if (element) { |
| 793 |
if (typeof element === "string") { |
| 794 |
return renderTag(element, props); |
| 795 |
} |
| 796 |
} |
| 797 |
throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8)); |
| 798 |
} |
| 799 |
function warnIfRenderPropLooksLikeComponent(renderFn) { |
| 800 |
const functionName = renderFn.name; |
| 801 |
if (functionName.length === 0) { |
| 802 |
return; |
| 803 |
} |
| 804 |
if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) { |
| 805 |
return; |
| 806 |
} |
| 807 |
if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) { |
| 808 |
return; |
| 809 |
} |
| 810 |
warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop"); |
| 811 |
} |
| 812 |
function renderTag(Tag, props) { |
| 813 |
if (Tag === "button") { |
| 814 |
return /* @__PURE__ */ (0, import_react.createElement)("button", { |
| 815 |
type: "button", |
| 816 |
...props, |
| 817 |
key: props.key |
| 818 |
}); |
| 819 |
} |
| 820 |
if (Tag === "img") { |
| 821 |
return /* @__PURE__ */ (0, import_react.createElement)("img", { |
| 822 |
alt: "", |
| 823 |
...props, |
| 824 |
key: props.key |
| 825 |
}); |
| 826 |
} |
| 827 |
return /* @__PURE__ */ React4.createElement(Tag, props); |
| 828 |
} |
| 829 |
|
| 830 |
// node_modules/@base-ui/react/esm/use-render/useRender.js |
| 831 |
function useRender(params) { |
| 832 |
return useRenderElement(params.defaultTagName ?? "div", params, params); |
| 833 |
} |
| 834 |
|
| 835 |
// packages/ui/build-module/text/text.mjs |
| 836 |
var import_element2 = __toESM(require_element(), 1); |
| 837 |
var STYLE_HASH_ATTRIBUTE = "data-wp-hash"; |
| 838 |
function getRuntime() { |
| 839 |
const globalScope = globalThis; |
| 840 |
if (globalScope.__wpStyleRuntime) { |
| 841 |
return globalScope.__wpStyleRuntime; |
| 842 |
} |
| 843 |
globalScope.__wpStyleRuntime = { |
| 844 |
documents: /* @__PURE__ */ new Map(), |
| 845 |
styles: /* @__PURE__ */ new Map(), |
| 846 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 847 |
}; |
| 848 |
if (typeof document !== "undefined") { |
| 849 |
registerDocument(document); |
| 850 |
} |
| 851 |
return globalScope.__wpStyleRuntime; |
| 852 |
} |
| 853 |
function documentContainsStyleHash(targetDocument, hash) { |
| 854 |
if (!targetDocument.head) { |
| 855 |
return false; |
| 856 |
} |
| 857 |
for (const style of targetDocument.head.querySelectorAll( |
| 858 |
`style[${STYLE_HASH_ATTRIBUTE}]` |
| 859 |
)) { |
| 860 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) { |
| 861 |
return true; |
| 862 |
} |
| 863 |
} |
| 864 |
return false; |
| 865 |
} |
| 866 |
function injectStyle(targetDocument, hash, css) { |
| 867 |
if (!targetDocument.head) { |
| 868 |
return; |
| 869 |
} |
| 870 |
const runtime = getRuntime(); |
| 871 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 872 |
if (!injectedStyles) { |
| 873 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 874 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 875 |
} |
| 876 |
if (injectedStyles.has(hash)) { |
| 877 |
return; |
| 878 |
} |
| 879 |
if (documentContainsStyleHash(targetDocument, hash)) { |
| 880 |
injectedStyles.add(hash); |
| 881 |
return; |
| 882 |
} |
| 883 |
const style = targetDocument.createElement("style"); |
| 884 |
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash); |
| 885 |
style.appendChild(targetDocument.createTextNode(css)); |
| 886 |
targetDocument.head.appendChild(style); |
| 887 |
injectedStyles.add(hash); |
| 888 |
} |
| 889 |
function registerDocument(targetDocument) { |
| 890 |
const runtime = getRuntime(); |
| 891 |
runtime.documents.set( |
| 892 |
targetDocument, |
| 893 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 894 |
); |
| 895 |
for (const [hash, css] of runtime.styles) { |
| 896 |
injectStyle(targetDocument, hash, css); |
| 897 |
} |
| 898 |
return () => { |
| 899 |
const count = runtime.documents.get(targetDocument); |
| 900 |
if (count === void 0) { |
| 901 |
return; |
| 902 |
} |
| 903 |
if (count <= 1) { |
| 904 |
runtime.documents.delete(targetDocument); |
| 905 |
return; |
| 906 |
} |
| 907 |
runtime.documents.set(targetDocument, count - 1); |
| 908 |
}; |
| 909 |
} |
| 910 |
function registerStyle(hash, css) { |
| 911 |
const runtime = getRuntime(); |
| 912 |
runtime.styles.set(hash, css); |
| 913 |
for (const targetDocument of runtime.documents.keys()) { |
| 914 |
injectStyle(targetDocument, hash, css); |
| 915 |
} |
| 916 |
} |
| 917 |
if (typeof process === "undefined" || true) { |
| 918 |
registerStyle("0c5702ddca", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}'); |
| 919 |
} |
| 920 |
var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" }; |
| 921 |
if (typeof process === "undefined" || true) { |
| 922 |
registerStyle("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}"); |
| 923 |
} |
| 924 |
var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" }; |
| 925 |
var Text = (0, import_element2.forwardRef)(function Text2({ variant = "body-md", render, className, ...props }, ref) { |
| 926 |
const element = useRender({ |
| 927 |
render, |
| 928 |
defaultTagName: "span", |
| 929 |
ref, |
| 930 |
props: mergeProps(props, { |
| 931 |
className: clsx_default( |
| 932 |
style_default.text, |
| 933 |
global_css_defense_default.heading, |
| 934 |
global_css_defense_default.p, |
| 935 |
style_default[variant], |
| 936 |
className |
| 937 |
) |
| 938 |
}) |
| 939 |
}); |
| 940 |
return element; |
| 941 |
}); |
| 942 |
|
| 943 |
// packages/icons/build-module/library/symbol.mjs |
| 944 |
var import_primitives = __toESM(require_primitives(), 1); |
| 945 |
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); |
| 946 |
var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.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" }) }); |
| 947 |
|
| 948 |
// packages/ui/build-module/stack/stack.mjs |
| 949 |
var import_element3 = __toESM(require_element(), 1); |
| 950 |
var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash"; |
| 951 |
function getRuntime2() { |
| 952 |
const globalScope = globalThis; |
| 953 |
if (globalScope.__wpStyleRuntime) { |
| 954 |
return globalScope.__wpStyleRuntime; |
| 955 |
} |
| 956 |
globalScope.__wpStyleRuntime = { |
| 957 |
documents: /* @__PURE__ */ new Map(), |
| 958 |
styles: /* @__PURE__ */ new Map(), |
| 959 |
injectedStyles: /* @__PURE__ */ new WeakMap() |
| 960 |
}; |
| 961 |
if (typeof document !== "undefined") { |
| 962 |
registerDocument2(document); |
| 963 |
} |
| 964 |
return globalScope.__wpStyleRuntime; |
| 965 |
} |
| 966 |
function documentContainsStyleHash2(targetDocument, hash) { |
| 967 |
if (!targetDocument.head) { |
| 968 |
return false; |
| 969 |
} |
| 970 |
for (const style of targetDocument.head.querySelectorAll( |
| 971 |
`style[${STYLE_HASH_ATTRIBUTE2}]` |
| 972 |
)) { |
| 973 |
if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) { |
| 974 |
return true; |
| 975 |
} |
| 976 |
} |
| 977 |
return false; |
| 978 |
} |
| 979 |
function injectStyle2(targetDocument, hash, css) { |
| 980 |
if (!targetDocument.head) { |
| 981 |
return; |
| 982 |
} |
| 983 |
const runtime = getRuntime2(); |
| 984 |
let injectedStyles = runtime.injectedStyles.get(targetDocument); |
| 985 |
if (!injectedStyles) { |
| 986 |
injectedStyles = /* @__PURE__ */ new Set(); |
| 987 |
runtime.injectedStyles.set(targetDocument, injectedStyles); |
| 988 |
} |
| 989 |
if (injectedStyles.has(hash)) { |
| 990 |
return; |
| 991 |
} |
| 992 |
if (documentContainsStyleHash2(targetDocument, hash)) { |
| 993 |
injectedStyles.add(hash); |
| 994 |
return; |
| 995 |
} |
| 996 |
const style = targetDocument.createElement("style"); |
| 997 |
style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash); |
| 998 |
style.appendChild(targetDocument.createTextNode(css)); |
| 999 |
targetDocument.head.appendChild(style); |
| 1000 |
injectedStyles.add(hash); |
| 1001 |
} |
| 1002 |
function registerDocument2(targetDocument) { |
| 1003 |
const runtime = getRuntime2(); |
| 1004 |
runtime.documents.set( |
| 1005 |
targetDocument, |
| 1006 |
(runtime.documents.get(targetDocument) ?? 0) + 1 |
| 1007 |
); |
| 1008 |
for (const [hash, css] of runtime.styles) { |
| 1009 |
injectStyle2(targetDocument, hash, css); |
| 1010 |
} |
| 1011 |
return () => { |
| 1012 |
const count = runtime.documents.get(targetDocument); |
| 1013 |
if (count === void 0) { |
| 1014 |
return; |
| 1015 |
} |
| 1016 |
if (count <= 1) { |
| 1017 |
runtime.documents.delete(targetDocument); |
| 1018 |
return; |
| 1019 |
} |
| 1020 |
runtime.documents.set(targetDocument, count - 1); |
| 1021 |
}; |
| 1022 |
} |
| 1023 |
function registerStyle2(hash, css) { |
| 1024 |
const runtime = getRuntime2(); |
| 1025 |
runtime.styles.set(hash, css); |
| 1026 |
for (const targetDocument of runtime.documents.keys()) { |
| 1027 |
injectStyle2(targetDocument, hash, css); |
| 1028 |
} |
| 1029 |
} |
| 1030 |
if (typeof process === "undefined" || true) { |
| 1031 |
registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}"); |
| 1032 |
} |
| 1033 |
var style_default2 = { "stack": "_19ce0419607e1896__stack" }; |
| 1034 |
var gapTokens = { |
| 1035 |
xs: "var(--wpds-dimension-gap-xs, 4px)", |
| 1036 |
sm: "var(--wpds-dimension-gap-sm, 8px)", |
| 1037 |
md: "var(--wpds-dimension-gap-md, 12px)", |
| 1038 |
lg: "var(--wpds-dimension-gap-lg, 16px)", |
| 1039 |
xl: "var(--wpds-dimension-gap-xl, 24px)", |
| 1040 |
"2xl": "var(--wpds-dimension-gap-2xl, 32px)", |
| 1041 |
"3xl": "var(--wpds-dimension-gap-3xl, 40px)" |
| 1042 |
}; |
| 1043 |
var Stack = (0, import_element3.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) { |
| 1044 |
const style = { |
| 1045 |
gap: gap && gapTokens[gap], |
| 1046 |
alignItems: align, |
| 1047 |
justifyContent: justify, |
| 1048 |
flexDirection: direction, |
| 1049 |
flexWrap: wrap |
| 1050 |
}; |
| 1051 |
const element = useRender({ |
| 1052 |
render, |
| 1053 |
ref, |
| 1054 |
props: mergeProps(props, { style, className: style_default2.stack }) |
| 1055 |
}); |
| 1056 |
return element; |
| 1057 |
}); |
| 1058 |
|
| 1059 |
// packages/patterns/build-module/components/create-pattern-modal.mjs |
| 1060 |
var import_i18n3 = __toESM(require_i18n(), 1); |
| 1061 |
var import_element6 = __toESM(require_element(), 1); |
| 1062 |
var import_data5 = __toESM(require_data(), 1); |
| 1063 |
var import_notices = __toESM(require_notices(), 1); |
| 1064 |
var import_core_data3 = __toESM(require_core_data(), 1); |
| 1065 |
|
| 1066 |
// packages/patterns/build-module/components/category-selector.mjs |
| 1067 |
var import_i18n2 = __toESM(require_i18n(), 1); |
| 1068 |
var import_element4 = __toESM(require_element(), 1); |
| 1069 |
var import_components2 = __toESM(require_components(), 1); |
| 1070 |
var import_compose = __toESM(require_compose(), 1); |
| 1071 |
var import_html_entities = __toESM(require_html_entities(), 1); |
| 1072 |
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); |
| 1073 |
var unescapeString = (arg) => { |
| 1074 |
return (0, import_html_entities.decodeEntities)(arg); |
| 1075 |
}; |
| 1076 |
var CATEGORY_SLUG = "wp_pattern_category"; |
| 1077 |
function CategorySelector({ |
| 1078 |
categoryTerms, |
| 1079 |
onChange, |
| 1080 |
categoryMap |
| 1081 |
}) { |
| 1082 |
const [search, setSearch] = (0, import_element4.useState)(""); |
| 1083 |
const debouncedSearch = (0, import_compose.useDebounce)(setSearch, 500); |
| 1084 |
const suggestions = (0, import_element4.useMemo)(() => { |
| 1085 |
return Array.from(categoryMap.values()).map((category) => unescapeString(category.label)).filter((category) => { |
| 1086 |
if (search !== "") { |
| 1087 |
return category.toLowerCase().includes(search.toLowerCase()); |
| 1088 |
} |
| 1089 |
return true; |
| 1090 |
}).sort((a, b) => a.localeCompare(b)); |
| 1091 |
}, [search, categoryMap]); |
| 1092 |
function handleChange(termNames) { |
| 1093 |
const uniqueTerms = termNames.reduce((terms, newTerm) => { |
| 1094 |
if (!terms.some( |
| 1095 |
(term) => term.toLowerCase() === newTerm.toLowerCase() |
| 1096 |
)) { |
| 1097 |
terms.push(newTerm); |
| 1098 |
} |
| 1099 |
return terms; |
| 1100 |
}, []); |
| 1101 |
onChange(uniqueTerms); |
| 1102 |
} |
| 1103 |
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( |
| 1104 |
import_components2.FormTokenField, |
| 1105 |
{ |
| 1106 |
className: "patterns-menu-items__convert-modal-categories", |
| 1107 |
value: categoryTerms, |
| 1108 |
suggestions, |
| 1109 |
onChange: handleChange, |
| 1110 |
onInputChange: debouncedSearch, |
| 1111 |
label: (0, import_i18n2.__)("Categories"), |
| 1112 |
tokenizeOnBlur: true, |
| 1113 |
__experimentalExpandOnFocus: true, |
| 1114 |
__next40pxDefaultSize: true |
| 1115 |
} |
| 1116 |
); |
| 1117 |
} |
| 1118 |
|
| 1119 |
// packages/patterns/build-module/private-hooks.mjs |
| 1120 |
var import_data4 = __toESM(require_data(), 1); |
| 1121 |
var import_core_data2 = __toESM(require_core_data(), 1); |
| 1122 |
var import_element5 = __toESM(require_element(), 1); |
| 1123 |
function useAddPatternCategory() { |
| 1124 |
const { saveEntityRecord, invalidateResolution } = (0, import_data4.useDispatch)(import_core_data2.store); |
| 1125 |
const { corePatternCategories, userPatternCategories } = (0, import_data4.useSelect)( |
| 1126 |
(select) => { |
| 1127 |
const { getUserPatternCategories, getBlockPatternCategories } = select(import_core_data2.store); |
| 1128 |
return { |
| 1129 |
corePatternCategories: getBlockPatternCategories(), |
| 1130 |
userPatternCategories: getUserPatternCategories() |
| 1131 |
}; |
| 1132 |
}, |
| 1133 |
[] |
| 1134 |
); |
| 1135 |
const categoryMap = (0, import_element5.useMemo)(() => { |
| 1136 |
const uniqueCategories = /* @__PURE__ */ new Map(); |
| 1137 |
userPatternCategories.forEach((category) => { |
| 1138 |
uniqueCategories.set(category.label.toLowerCase(), { |
| 1139 |
label: category.label, |
| 1140 |
name: category.name, |
| 1141 |
id: category.id |
| 1142 |
}); |
| 1143 |
}); |
| 1144 |
corePatternCategories.forEach((category) => { |
| 1145 |
if (!uniqueCategories.has(category.label.toLowerCase()) && // There are two core categories with `Post` label so explicitly remove the one with |
| 1146 |
// the `query` slug to avoid any confusion. |
| 1147 |
category.name !== "query") { |
| 1148 |
uniqueCategories.set(category.label.toLowerCase(), { |
| 1149 |
label: category.label, |
| 1150 |
name: category.name |
| 1151 |
}); |
| 1152 |
} |
| 1153 |
}); |
| 1154 |
return uniqueCategories; |
| 1155 |
}, [userPatternCategories, corePatternCategories]); |
| 1156 |
async function findOrCreateTerm(term) { |
| 1157 |
try { |
| 1158 |
const existingTerm = categoryMap.get(term.toLowerCase()); |
| 1159 |
if (existingTerm?.id) { |
| 1160 |
return existingTerm.id; |
| 1161 |
} |
| 1162 |
const termData = existingTerm ? { name: existingTerm.label, slug: existingTerm.name } : { name: term }; |
| 1163 |
const newTerm = await saveEntityRecord( |
| 1164 |
"taxonomy", |
| 1165 |
CATEGORY_SLUG, |
| 1166 |
termData, |
| 1167 |
{ throwOnError: true } |
| 1168 |
); |
| 1169 |
invalidateResolution("getUserPatternCategories"); |
| 1170 |
return newTerm.id; |
| 1171 |
} catch (error) { |
| 1172 |
if (error.code !== "term_exists") { |
| 1173 |
throw error; |
| 1174 |
} |
| 1175 |
return error.data.term_id; |
| 1176 |
} |
| 1177 |
} |
| 1178 |
return { categoryMap, findOrCreateTerm }; |
| 1179 |
} |
| 1180 |
|
| 1181 |
// packages/patterns/build-module/components/create-pattern-modal.mjs |
| 1182 |
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); |
| 1183 |
function CreatePatternModal({ |
| 1184 |
className = "patterns-menu-items__convert-modal", |
| 1185 |
modalTitle, |
| 1186 |
...restProps |
| 1187 |
}) { |
| 1188 |
const defaultModalTitle = (0, import_data5.useSelect)( |
| 1189 |
(select) => select(import_core_data3.store).getPostType(PATTERN_TYPES.user)?.labels?.add_new_item, |
| 1190 |
[] |
| 1191 |
); |
| 1192 |
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1193 |
import_components3.Modal, |
| 1194 |
{ |
| 1195 |
title: modalTitle || defaultModalTitle, |
| 1196 |
onRequestClose: restProps.onClose, |
| 1197 |
overlayClassName: className, |
| 1198 |
focusOnMount: "firstContentElement", |
| 1199 |
size: "small", |
| 1200 |
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CreatePatternModalContents, { ...restProps }) |
| 1201 |
} |
| 1202 |
); |
| 1203 |
} |
| 1204 |
function CreatePatternModalContents({ |
| 1205 |
confirmLabel = (0, import_i18n3.__)("Add"), |
| 1206 |
defaultCategories = [], |
| 1207 |
content, |
| 1208 |
onClose, |
| 1209 |
onError, |
| 1210 |
onSuccess, |
| 1211 |
defaultSyncType = PATTERN_SYNC_TYPES.full, |
| 1212 |
defaultTitle = "" |
| 1213 |
}) { |
| 1214 |
const [syncType, setSyncType] = (0, import_element6.useState)(defaultSyncType); |
| 1215 |
const [categoryTerms, setCategoryTerms] = (0, import_element6.useState)(defaultCategories); |
| 1216 |
const [title, setTitle] = (0, import_element6.useState)(defaultTitle); |
| 1217 |
const [isSaving, setIsSaving] = (0, import_element6.useState)(false); |
| 1218 |
const { createPattern: createPattern2 } = unlock((0, import_data5.useDispatch)(store)); |
| 1219 |
const { createErrorNotice } = (0, import_data5.useDispatch)(import_notices.store); |
| 1220 |
const { categoryMap, findOrCreateTerm } = useAddPatternCategory(); |
| 1221 |
async function onCreate(patternTitle, sync) { |
| 1222 |
if (!title || isSaving) { |
| 1223 |
return; |
| 1224 |
} |
| 1225 |
try { |
| 1226 |
setIsSaving(true); |
| 1227 |
const categories = await Promise.all( |
| 1228 |
categoryTerms.map( |
| 1229 |
(termName) => findOrCreateTerm(termName) |
| 1230 |
) |
| 1231 |
); |
| 1232 |
const newPattern = await createPattern2( |
| 1233 |
patternTitle, |
| 1234 |
sync, |
| 1235 |
typeof content === "function" ? content() : content, |
| 1236 |
categories |
| 1237 |
); |
| 1238 |
onSuccess({ |
| 1239 |
pattern: newPattern, |
| 1240 |
categoryId: PATTERN_DEFAULT_CATEGORY |
| 1241 |
}); |
| 1242 |
} catch (error) { |
| 1243 |
createErrorNotice(error.message, { |
| 1244 |
type: "snackbar", |
| 1245 |
id: "pattern-create" |
| 1246 |
}); |
| 1247 |
onError?.(); |
| 1248 |
} finally { |
| 1249 |
setIsSaving(false); |
| 1250 |
setCategoryTerms([]); |
| 1251 |
setTitle(""); |
| 1252 |
} |
| 1253 |
} |
| 1254 |
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1255 |
"form", |
| 1256 |
{ |
| 1257 |
onSubmit: (event) => { |
| 1258 |
event.preventDefault(); |
| 1259 |
onCreate(title, syncType); |
| 1260 |
}, |
| 1261 |
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Stack, { direction: "column", gap: "lg", children: [ |
| 1262 |
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1263 |
import_components3.TextControl, |
| 1264 |
{ |
| 1265 |
label: (0, import_i18n3.__)("Name"), |
| 1266 |
value: title, |
| 1267 |
onChange: setTitle, |
| 1268 |
placeholder: (0, import_i18n3.__)("My pattern"), |
| 1269 |
className: "patterns-create-modal__name-input" |
| 1270 |
} |
| 1271 |
), |
| 1272 |
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1273 |
CategorySelector, |
| 1274 |
{ |
| 1275 |
categoryTerms, |
| 1276 |
onChange: setCategoryTerms, |
| 1277 |
categoryMap |
| 1278 |
} |
| 1279 |
), |
| 1280 |
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1281 |
import_components3.ToggleControl, |
| 1282 |
{ |
| 1283 |
label: (0, import_i18n3._x)("Synced", "pattern (singular)"), |
| 1284 |
help: (0, import_i18n3.__)( |
| 1285 |
"Sync this pattern across multiple locations." |
| 1286 |
), |
| 1287 |
checked: syncType === PATTERN_SYNC_TYPES.full, |
| 1288 |
onChange: () => { |
| 1289 |
setSyncType( |
| 1290 |
syncType === PATTERN_SYNC_TYPES.full ? PATTERN_SYNC_TYPES.unsynced : PATTERN_SYNC_TYPES.full |
| 1291 |
); |
| 1292 |
} |
| 1293 |
} |
| 1294 |
), |
| 1295 |
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Stack, { gap: "sm", justify: "end", children: [ |
| 1296 |
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1297 |
import_components3.Button, |
| 1298 |
{ |
| 1299 |
__next40pxDefaultSize: true, |
| 1300 |
variant: "tertiary", |
| 1301 |
onClick: () => { |
| 1302 |
onClose(); |
| 1303 |
setTitle(""); |
| 1304 |
}, |
| 1305 |
children: (0, import_i18n3.__)("Cancel") |
| 1306 |
} |
| 1307 |
), |
| 1308 |
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)( |
| 1309 |
import_components3.Button, |
| 1310 |
{ |
| 1311 |
__next40pxDefaultSize: true, |
| 1312 |
variant: "primary", |
| 1313 |
type: "submit", |
| 1314 |
"aria-disabled": !title || isSaving, |
| 1315 |
isBusy: isSaving, |
| 1316 |
children: confirmLabel |
| 1317 |
} |
| 1318 |
) |
| 1319 |
] }) |
| 1320 |
] }) |
| 1321 |
} |
| 1322 |
); |
| 1323 |
} |
| 1324 |
|
| 1325 |
// packages/patterns/build-module/components/duplicate-pattern-modal.mjs |
| 1326 |
var import_core_data4 = __toESM(require_core_data(), 1); |
| 1327 |
var import_data6 = __toESM(require_data(), 1); |
| 1328 |
var import_i18n4 = __toESM(require_i18n(), 1); |
| 1329 |
var import_notices2 = __toESM(require_notices(), 1); |
| 1330 |
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); |
| 1331 |
function getTermLabels(pattern, categories) { |
| 1332 |
if (pattern.type !== PATTERN_TYPES.user) { |
| 1333 |
return categories.core?.filter( |
| 1334 |
(category) => pattern.categories?.includes(category.name) |
| 1335 |
).map((category) => category.label); |
| 1336 |
} |
| 1337 |
return categories.user?.filter( |
| 1338 |
(category) => pattern.wp_pattern_category?.includes(category.id) |
| 1339 |
).map((category) => category.label); |
| 1340 |
} |
| 1341 |
function useDuplicatePatternProps({ pattern, onSuccess }) { |
| 1342 |
const { createSuccessNotice } = (0, import_data6.useDispatch)(import_notices2.store); |
| 1343 |
const categories = (0, import_data6.useSelect)((select) => { |
| 1344 |
const { getUserPatternCategories, getBlockPatternCategories } = select(import_core_data4.store); |
| 1345 |
return { |
| 1346 |
core: getBlockPatternCategories(), |
| 1347 |
user: getUserPatternCategories() |
| 1348 |
}; |
| 1349 |
}); |
| 1350 |
if (!pattern) { |
| 1351 |
return null; |
| 1352 |
} |
| 1353 |
return { |
| 1354 |
content: pattern.content, |
| 1355 |
defaultCategories: getTermLabels(pattern, categories), |
| 1356 |
defaultSyncType: pattern.type !== PATTERN_TYPES.user ? PATTERN_SYNC_TYPES.unsynced : pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, |
| 1357 |
defaultTitle: (0, import_i18n4.sprintf)( |
| 1358 |
/* translators: %s: Existing pattern title */ |
| 1359 |
(0, import_i18n4._x)("%s (Copy)", "pattern"), |
| 1360 |
typeof pattern.title === "string" ? pattern.title : pattern.title.raw |
| 1361 |
), |
| 1362 |
onSuccess: ({ pattern: newPattern }) => { |
| 1363 |
createSuccessNotice( |
| 1364 |
(0, import_i18n4.sprintf)( |
| 1365 |
// translators: %s: The new pattern's title e.g. 'Call to action (copy)'. |
| 1366 |
(0, import_i18n4._x)('"%s" duplicated.', "pattern"), |
| 1367 |
newPattern.title.raw |
| 1368 |
), |
| 1369 |
{ |
| 1370 |
type: "snackbar", |
| 1371 |
id: "patterns-create" |
| 1372 |
} |
| 1373 |
); |
| 1374 |
onSuccess?.({ pattern: newPattern }); |
| 1375 |
} |
| 1376 |
}; |
| 1377 |
} |
| 1378 |
function DuplicatePatternModal({ |
| 1379 |
pattern, |
| 1380 |
onClose, |
| 1381 |
onSuccess |
| 1382 |
}) { |
| 1383 |
const duplicatedProps = useDuplicatePatternProps({ pattern, onSuccess }); |
| 1384 |
if (!pattern) { |
| 1385 |
return null; |
| 1386 |
} |
| 1387 |
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)( |
| 1388 |
CreatePatternModal, |
| 1389 |
{ |
| 1390 |
modalTitle: (0, import_i18n4.__)("Duplicate pattern"), |
| 1391 |
confirmLabel: (0, import_i18n4.__)("Duplicate"), |
| 1392 |
onClose, |
| 1393 |
onError: onClose, |
| 1394 |
...duplicatedProps |
| 1395 |
} |
| 1396 |
); |
| 1397 |
} |
| 1398 |
|
| 1399 |
// packages/patterns/build-module/components/rename-pattern-modal.mjs |
| 1400 |
var import_components4 = __toESM(require_components(), 1); |
| 1401 |
var import_core_data5 = __toESM(require_core_data(), 1); |
| 1402 |
var import_data7 = __toESM(require_data(), 1); |
| 1403 |
var import_element7 = __toESM(require_element(), 1); |
| 1404 |
var import_html_entities2 = __toESM(require_html_entities(), 1); |
| 1405 |
var import_i18n5 = __toESM(require_i18n(), 1); |
| 1406 |
var import_notices3 = __toESM(require_notices(), 1); |
| 1407 |
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); |
| 1408 |
function RenamePatternModal({ |
| 1409 |
onClose, |
| 1410 |
onError, |
| 1411 |
onSuccess, |
| 1412 |
pattern, |
| 1413 |
...props |
| 1414 |
}) { |
| 1415 |
const originalName = (0, import_html_entities2.decodeEntities)(pattern.title); |
| 1416 |
const [name, setName] = (0, import_element7.useState)(originalName); |
| 1417 |
const [isSaving, setIsSaving] = (0, import_element7.useState)(false); |
| 1418 |
const { |
| 1419 |
editEntityRecord, |
| 1420 |
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits |
| 1421 |
} = (0, import_data7.useDispatch)(import_core_data5.store); |
| 1422 |
const { createSuccessNotice, createErrorNotice } = (0, import_data7.useDispatch)(import_notices3.store); |
| 1423 |
const onRename = async (event) => { |
| 1424 |
event.preventDefault(); |
| 1425 |
if (!name || name === pattern.title || isSaving) { |
| 1426 |
return; |
| 1427 |
} |
| 1428 |
try { |
| 1429 |
await editEntityRecord("postType", pattern.type, pattern.id, { |
| 1430 |
title: name |
| 1431 |
}); |
| 1432 |
setIsSaving(true); |
| 1433 |
setName(""); |
| 1434 |
onClose?.(); |
| 1435 |
const savedRecord = await saveSpecifiedEntityEdits( |
| 1436 |
"postType", |
| 1437 |
pattern.type, |
| 1438 |
pattern.id, |
| 1439 |
["title"], |
| 1440 |
{ throwOnError: true } |
| 1441 |
); |
| 1442 |
onSuccess?.(savedRecord); |
| 1443 |
createSuccessNotice((0, import_i18n5.__)("Pattern renamed"), { |
| 1444 |
type: "snackbar", |
| 1445 |
id: "pattern-update" |
| 1446 |
}); |
| 1447 |
} catch (error) { |
| 1448 |
onError?.(); |
| 1449 |
const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n5.__)("An error occurred while renaming the pattern."); |
| 1450 |
createErrorNotice(errorMessage, { |
| 1451 |
type: "snackbar", |
| 1452 |
id: "pattern-update" |
| 1453 |
}); |
| 1454 |
} finally { |
| 1455 |
setIsSaving(false); |
| 1456 |
setName(""); |
| 1457 |
} |
| 1458 |
}; |
| 1459 |
const onRequestClose = () => { |
| 1460 |
onClose?.(); |
| 1461 |
setName(""); |
| 1462 |
}; |
| 1463 |
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)( |
| 1464 |
import_components4.Modal, |
| 1465 |
{ |
| 1466 |
title: (0, import_i18n5.__)("Rename"), |
| 1467 |
...props, |
| 1468 |
onRequestClose: onClose, |
| 1469 |
focusOnMount: "firstContentElement", |
| 1470 |
size: "small", |
| 1471 |
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("form", { onSubmit: onRename, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Stack, { direction: "column", gap: "lg", children: [ |
| 1472 |
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)( |
| 1473 |
import_components4.TextControl, |
| 1474 |
{ |
| 1475 |
label: (0, import_i18n5.__)("Name"), |
| 1476 |
value: name, |
| 1477 |
onChange: setName, |
| 1478 |
required: true |
| 1479 |
} |
| 1480 |
), |
| 1481 |
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Stack, { gap: "sm", justify: "end", children: [ |
| 1482 |
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)( |
| 1483 |
import_components4.Button, |
| 1484 |
{ |
| 1485 |
__next40pxDefaultSize: true, |
| 1486 |
variant: "tertiary", |
| 1487 |
onClick: onRequestClose, |
| 1488 |
children: (0, import_i18n5.__)("Cancel") |
| 1489 |
} |
| 1490 |
), |
| 1491 |
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)( |
| 1492 |
import_components4.Button, |
| 1493 |
{ |
| 1494 |
__next40pxDefaultSize: true, |
| 1495 |
variant: "primary", |
| 1496 |
type: "submit", |
| 1497 |
children: (0, import_i18n5.__)("Save") |
| 1498 |
} |
| 1499 |
) |
| 1500 |
] }) |
| 1501 |
] }) }) |
| 1502 |
} |
| 1503 |
); |
| 1504 |
} |
| 1505 |
|
| 1506 |
// packages/patterns/build-module/components/index.mjs |
| 1507 |
var import_block_editor5 = __toESM(require_block_editor(), 1); |
| 1508 |
|
| 1509 |
// packages/patterns/build-module/components/pattern-convert-button.mjs |
| 1510 |
var import_blocks2 = __toESM(require_blocks(), 1); |
| 1511 |
var import_block_editor3 = __toESM(require_block_editor(), 1); |
| 1512 |
var import_element8 = __toESM(require_element(), 1); |
| 1513 |
var import_components5 = __toESM(require_components(), 1); |
| 1514 |
var import_data8 = __toESM(require_data(), 1); |
| 1515 |
var import_core_data6 = __toESM(require_core_data(), 1); |
| 1516 |
var import_i18n6 = __toESM(require_i18n(), 1); |
| 1517 |
var import_notices4 = __toESM(require_notices(), 1); |
| 1518 |
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); |
| 1519 |
function PatternConvertButton({ |
| 1520 |
clientIds, |
| 1521 |
rootClientId, |
| 1522 |
closeBlockSettingsMenu |
| 1523 |
}) { |
| 1524 |
const { createSuccessNotice } = (0, import_data8.useDispatch)(import_notices4.store); |
| 1525 |
const { replaceBlocks, updateBlockAttributes } = (0, import_data8.useDispatch)(import_block_editor3.store); |
| 1526 |
const { setEditingPattern: setEditingPattern2 } = unlock((0, import_data8.useDispatch)(store)); |
| 1527 |
const [isModalOpen, setIsModalOpen] = (0, import_element8.useState)(false); |
| 1528 |
const { getBlockAttributes } = (0, import_data8.useSelect)(import_block_editor3.store); |
| 1529 |
const canConvert = (0, import_data8.useSelect)( |
| 1530 |
(select) => { |
| 1531 |
const { canUser } = select(import_core_data6.store); |
| 1532 |
const { |
| 1533 |
getBlocksByClientId: getBlocksByClientId2, |
| 1534 |
canInsertBlockType, |
| 1535 |
getBlockRootClientId |
| 1536 |
} = select(import_block_editor3.store); |
| 1537 |
const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : void 0); |
| 1538 |
const blocks = getBlocksByClientId2(clientIds) ?? []; |
| 1539 |
const hasReusableBlockSupport = (blockName) => { |
| 1540 |
const blockType = (0, import_blocks2.getBlockType)(blockName); |
| 1541 |
const hasParent = blockType && "parent" in blockType; |
| 1542 |
return (0, import_blocks2.hasBlockSupport)(blockName, "reusable", !hasParent); |
| 1543 |
}; |
| 1544 |
const isSyncedPattern = blocks.length === 1 && blocks[0] && (0, import_blocks2.isReusableBlock)(blocks[0]) && !!select(import_core_data6.store).getEntityRecord( |
| 1545 |
"postType", |
| 1546 |
"wp_block", |
| 1547 |
blocks[0].attributes.ref |
| 1548 |
); |
| 1549 |
const isUnsyncedPattern = blocks.length === 1 && blocks?.[0]?.attributes?.metadata?.patternName; |
| 1550 |
const _canConvert = ( |
| 1551 |
// Hide when this is already a pattern. |
| 1552 |
!isUnsyncedPattern && !isSyncedPattern && // Hide when patterns are disabled. |
| 1553 |
canInsertBlockType("core/block", rootId) && blocks.every( |
| 1554 |
(block) => ( |
| 1555 |
// Guard against the case where a regular block has *just* been converted. |
| 1556 |
!!block && // Hide on invalid blocks. |
| 1557 |
block.isValid && // Hide when block doesn't support being made into a pattern. |
| 1558 |
hasReusableBlockSupport(block.name) |
| 1559 |
) |
| 1560 |
) && // Hide when current doesn't have permission to do that. |
| 1561 |
// Blocks refers to the wp_block post type, this checks the ability to create a post of that type. |
| 1562 |
!!canUser("create", { |
| 1563 |
kind: "postType", |
| 1564 |
name: "wp_block" |
| 1565 |
}) |
| 1566 |
); |
| 1567 |
return _canConvert; |
| 1568 |
}, |
| 1569 |
[clientIds, rootClientId] |
| 1570 |
); |
| 1571 |
const { getBlocksByClientId } = (0, import_data8.useSelect)(import_block_editor3.store); |
| 1572 |
const getContent = (0, import_element8.useCallback)( |
| 1573 |
() => (0, import_blocks2.serialize)(getBlocksByClientId(clientIds)), |
| 1574 |
[getBlocksByClientId, clientIds] |
| 1575 |
); |
| 1576 |
if (!canConvert) { |
| 1577 |
return null; |
| 1578 |
} |
| 1579 |
const handleSuccess = ({ pattern }) => { |
| 1580 |
if (pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced) { |
| 1581 |
if (clientIds?.length === 1) { |
| 1582 |
const existingAttributes = getBlockAttributes(clientIds[0]); |
| 1583 |
updateBlockAttributes(clientIds[0], { |
| 1584 |
metadata: { |
| 1585 |
...existingAttributes?.metadata ? existingAttributes.metadata : {}, |
| 1586 |
patternName: `core/block/${pattern.id}`, |
| 1587 |
name: pattern.title.raw |
| 1588 |
} |
| 1589 |
}); |
| 1590 |
} |
| 1591 |
} else { |
| 1592 |
const newBlock = (0, import_blocks2.createBlock)("core/block", { |
| 1593 |
ref: pattern.id |
| 1594 |
}); |
| 1595 |
replaceBlocks(clientIds, newBlock); |
| 1596 |
setEditingPattern2(newBlock.clientId, true); |
| 1597 |
} |
| 1598 |
createSuccessNotice( |
| 1599 |
pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? (0, import_i18n6.sprintf)( |
| 1600 |
// translators: %s: the name the user has given to the pattern. |
| 1601 |
(0, import_i18n6.__)("Unsynced pattern created: %s"), |
| 1602 |
pattern.title.raw |
| 1603 |
) : (0, import_i18n6.sprintf)( |
| 1604 |
// translators: %s: the name the user has given to the pattern. |
| 1605 |
(0, import_i18n6.__)("Synced pattern created: %s"), |
| 1606 |
pattern.title.raw |
| 1607 |
), |
| 1608 |
{ |
| 1609 |
type: "snackbar", |
| 1610 |
id: "convert-to-pattern-success" |
| 1611 |
} |
| 1612 |
); |
| 1613 |
setIsModalOpen(false); |
| 1614 |
closeBlockSettingsMenu(); |
| 1615 |
}; |
| 1616 |
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [ |
| 1617 |
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)( |
| 1618 |
import_components5.MenuItem, |
| 1619 |
{ |
| 1620 |
icon: symbol_default, |
| 1621 |
onClick: () => setIsModalOpen(true), |
| 1622 |
"aria-expanded": isModalOpen, |
| 1623 |
"aria-haspopup": "dialog", |
| 1624 |
children: (0, import_i18n6.__)("Create pattern") |
| 1625 |
} |
| 1626 |
), |
| 1627 |
isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)( |
| 1628 |
CreatePatternModal, |
| 1629 |
{ |
| 1630 |
content: getContent, |
| 1631 |
onSuccess: (pattern) => { |
| 1632 |
handleSuccess(pattern); |
| 1633 |
}, |
| 1634 |
onError: () => { |
| 1635 |
setIsModalOpen(false); |
| 1636 |
}, |
| 1637 |
onClose: () => { |
| 1638 |
setIsModalOpen(false); |
| 1639 |
} |
| 1640 |
} |
| 1641 |
) |
| 1642 |
] }); |
| 1643 |
} |
| 1644 |
|
| 1645 |
// packages/patterns/build-module/components/patterns-manage-button.mjs |
| 1646 |
var import_components6 = __toESM(require_components(), 1); |
| 1647 |
var import_i18n7 = __toESM(require_i18n(), 1); |
| 1648 |
var import_blocks3 = __toESM(require_blocks(), 1); |
| 1649 |
var import_data9 = __toESM(require_data(), 1); |
| 1650 |
var import_element9 = __toESM(require_element(), 1); |
| 1651 |
var import_block_editor4 = __toESM(require_block_editor(), 1); |
| 1652 |
var import_url = __toESM(require_url(), 1); |
| 1653 |
var import_core_data7 = __toESM(require_core_data(), 1); |
| 1654 |
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); |
| 1655 |
function PatternsManageButton({ clientId, onClose }) { |
| 1656 |
const [showConfirmDialog, setShowConfirmDialog] = (0, import_element9.useState)(false); |
| 1657 |
const { |
| 1658 |
attributes, |
| 1659 |
canDetach, |
| 1660 |
isVisible, |
| 1661 |
managePatternsUrl, |
| 1662 |
isSyncedPattern, |
| 1663 |
isUnsyncedPattern, |
| 1664 |
canEdit |
| 1665 |
} = (0, import_data9.useSelect)( |
| 1666 |
(select) => { |
| 1667 |
const { canRemoveBlock, getBlock, canEditBlock } = select(import_block_editor4.store); |
| 1668 |
const { canUser } = select(import_core_data7.store); |
| 1669 |
const block = getBlock(clientId); |
| 1670 |
const _isUnsyncedPattern = !!block?.attributes?.metadata?.patternName; |
| 1671 |
const _isSyncedPattern = !!block && (0, import_blocks3.isReusableBlock)(block) && !!canUser("update", { |
| 1672 |
kind: "postType", |
| 1673 |
name: "wp_block", |
| 1674 |
id: block.attributes.ref |
| 1675 |
}); |
| 1676 |
return { |
| 1677 |
attributes: block.attributes, |
| 1678 |
canEdit: canEditBlock(clientId), |
| 1679 |
// For unsynced patterns, detaching is simply removing the `patternName` attribute. |
| 1680 |
// For synced patterns, the `core:block` block is replaced with its inner blocks, |
| 1681 |
// so checking whether `canRemoveBlock` is possible is required. |
| 1682 |
canDetach: _isUnsyncedPattern || _isSyncedPattern && canRemoveBlock(clientId), |
| 1683 |
isUnsyncedPattern: _isUnsyncedPattern, |
| 1684 |
isSyncedPattern: _isSyncedPattern, |
| 1685 |
isVisible: _isUnsyncedPattern || _isSyncedPattern, |
| 1686 |
// The site editor and templates both check whether the user |
| 1687 |
// has edit_theme_options capabilities. We can leverage that here |
| 1688 |
// and omit the manage patterns link if the user can't access it. |
| 1689 |
managePatternsUrl: canUser("create", { |
| 1690 |
kind: "postType", |
| 1691 |
name: "wp_template" |
| 1692 |
}) ? (0, import_url.addQueryArgs)("site-editor.php", { |
| 1693 |
p: "/pattern" |
| 1694 |
}) : (0, import_url.addQueryArgs)("edit.php", { |
| 1695 |
post_type: "wp_block" |
| 1696 |
}) |
| 1697 |
}; |
| 1698 |
}, |
| 1699 |
[clientId] |
| 1700 |
); |
| 1701 |
const { updateBlockAttributes } = (0, import_data9.useDispatch)(import_block_editor4.store); |
| 1702 |
const { convertSyncedPatternToStatic: convertSyncedPatternToStatic2 } = unlock( |
| 1703 |
(0, import_data9.useDispatch)(store) |
| 1704 |
); |
| 1705 |
if (!isVisible || !canEdit) { |
| 1706 |
return null; |
| 1707 |
} |
| 1708 |
const handleDetach = () => { |
| 1709 |
if (isSyncedPattern) { |
| 1710 |
convertSyncedPatternToStatic2(clientId); |
| 1711 |
} |
| 1712 |
if (isUnsyncedPattern) { |
| 1713 |
const { patternName, ...attributesWithoutPatternName } = attributes?.metadata ?? {}; |
| 1714 |
updateBlockAttributes(clientId, { |
| 1715 |
metadata: attributesWithoutPatternName |
| 1716 |
}); |
| 1717 |
} |
| 1718 |
onClose?.(); |
| 1719 |
setShowConfirmDialog(false); |
| 1720 |
}; |
| 1721 |
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [ |
| 1722 |
canDetach && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [ |
| 1723 |
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components6.MenuItem, { onClick: () => setShowConfirmDialog(true), children: (0, import_i18n7.__)("Detach") }), |
| 1724 |
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)( |
| 1725 |
import_components6.__experimentalConfirmDialog, |
| 1726 |
{ |
| 1727 |
isOpen: showConfirmDialog, |
| 1728 |
onConfirm: handleDetach, |
| 1729 |
onCancel: () => setShowConfirmDialog(false), |
| 1730 |
confirmButtonText: (0, import_i18n7.__)("Detach"), |
| 1731 |
size: "medium", |
| 1732 |
title: (0, import_i18n7.__)("Detach pattern?"), |
| 1733 |
__experimentalHideHeader: false, |
| 1734 |
children: isSyncedPattern ? (0, import_i18n7.__)( |
| 1735 |
"The blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here." |
| 1736 |
) : (0, import_i18n7.__)( |
| 1737 |
"Blocks will no longer be associated with this pattern and will be fully editable." |
| 1738 |
) |
| 1739 |
} |
| 1740 |
) |
| 1741 |
] }), |
| 1742 |
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components6.MenuItem, { href: managePatternsUrl, children: (0, import_i18n7.__)("Manage patterns") }) |
| 1743 |
] }); |
| 1744 |
} |
| 1745 |
var patterns_manage_button_default = PatternsManageButton; |
| 1746 |
|
| 1747 |
// packages/patterns/build-module/components/index.mjs |
| 1748 |
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); |
| 1749 |
function PatternsMenuItems({ rootClientId }) { |
| 1750 |
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_block_editor5.BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [ |
| 1751 |
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)( |
| 1752 |
PatternConvertButton, |
| 1753 |
{ |
| 1754 |
clientIds: selectedClientIds, |
| 1755 |
rootClientId, |
| 1756 |
closeBlockSettingsMenu: onClose |
| 1757 |
} |
| 1758 |
), |
| 1759 |
selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( |
| 1760 |
patterns_manage_button_default, |
| 1761 |
{ |
| 1762 |
clientId: selectedClientIds[0], |
| 1763 |
onClose |
| 1764 |
} |
| 1765 |
) |
| 1766 |
] }) }); |
| 1767 |
} |
| 1768 |
|
| 1769 |
// packages/patterns/build-module/components/rename-pattern-category-modal.mjs |
| 1770 |
var import_components7 = __toESM(require_components(), 1); |
| 1771 |
var import_core_data8 = __toESM(require_core_data(), 1); |
| 1772 |
var import_data10 = __toESM(require_data(), 1); |
| 1773 |
var import_element10 = __toESM(require_element(), 1); |
| 1774 |
var import_html_entities3 = __toESM(require_html_entities(), 1); |
| 1775 |
var import_i18n8 = __toESM(require_i18n(), 1); |
| 1776 |
var import_notices5 = __toESM(require_notices(), 1); |
| 1777 |
var import_a11y = __toESM(require_a11y(), 1); |
| 1778 |
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); |
| 1779 |
function RenamePatternCategoryModal({ |
| 1780 |
category, |
| 1781 |
existingCategories, |
| 1782 |
onClose, |
| 1783 |
onError, |
| 1784 |
onSuccess, |
| 1785 |
...props |
| 1786 |
}) { |
| 1787 |
const id = (0, import_element10.useId)(); |
| 1788 |
const textControlRef = (0, import_element10.useRef)(); |
| 1789 |
const [name, setName] = (0, import_element10.useState)((0, import_html_entities3.decodeEntities)(category.name)); |
| 1790 |
const [isSaving, setIsSaving] = (0, import_element10.useState)(false); |
| 1791 |
const [validationMessage, setValidationMessage] = (0, import_element10.useState)(false); |
| 1792 |
const validationMessageId = validationMessage ? `patterns-rename-pattern-category-modal__validation-message-${id}` : void 0; |
| 1793 |
const { saveEntityRecord, invalidateResolution } = (0, import_data10.useDispatch)(import_core_data8.store); |
| 1794 |
const { createErrorNotice, createSuccessNotice } = (0, import_data10.useDispatch)(import_notices5.store); |
| 1795 |
const onChange = (newName) => { |
| 1796 |
if (validationMessage) { |
| 1797 |
setValidationMessage(void 0); |
| 1798 |
} |
| 1799 |
setName(newName); |
| 1800 |
}; |
| 1801 |
const onSave = async (event) => { |
| 1802 |
event.preventDefault(); |
| 1803 |
if (isSaving) { |
| 1804 |
return; |
| 1805 |
} |
| 1806 |
if (!name || name === category.name) { |
| 1807 |
const message = (0, import_i18n8.__)("Please enter a new name for this category."); |
| 1808 |
(0, import_a11y.speak)(message, "assertive"); |
| 1809 |
setValidationMessage(message); |
| 1810 |
textControlRef.current?.focus(); |
| 1811 |
return; |
| 1812 |
} |
| 1813 |
if (existingCategories.patternCategories.find((existingCategory) => { |
| 1814 |
return existingCategory.id !== category.id && existingCategory.label.toLowerCase() === name.toLowerCase(); |
| 1815 |
})) { |
| 1816 |
const message = (0, import_i18n8.__)( |
| 1817 |
"This category already exists. Please use a different name." |
| 1818 |
); |
| 1819 |
(0, import_a11y.speak)(message, "assertive"); |
| 1820 |
setValidationMessage(message); |
| 1821 |
textControlRef.current?.focus(); |
| 1822 |
return; |
| 1823 |
} |
| 1824 |
try { |
| 1825 |
setIsSaving(true); |
| 1826 |
const savedRecord = await saveEntityRecord( |
| 1827 |
"taxonomy", |
| 1828 |
CATEGORY_SLUG, |
| 1829 |
{ |
| 1830 |
id: category.id, |
| 1831 |
slug: category.slug, |
| 1832 |
name |
| 1833 |
} |
| 1834 |
); |
| 1835 |
invalidateResolution("getUserPatternCategories"); |
| 1836 |
onSuccess?.(savedRecord); |
| 1837 |
onClose(); |
| 1838 |
createSuccessNotice((0, import_i18n8.__)("Pattern category renamed."), { |
| 1839 |
type: "snackbar", |
| 1840 |
id: "pattern-category-update" |
| 1841 |
}); |
| 1842 |
} catch (error) { |
| 1843 |
onError?.(); |
| 1844 |
createErrorNotice(error.message, { |
| 1845 |
type: "snackbar", |
| 1846 |
id: "pattern-category-update" |
| 1847 |
}); |
| 1848 |
} finally { |
| 1849 |
setIsSaving(false); |
| 1850 |
setName(""); |
| 1851 |
} |
| 1852 |
}; |
| 1853 |
const onRequestClose = () => { |
| 1854 |
onClose(); |
| 1855 |
setName(""); |
| 1856 |
}; |
| 1857 |
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( |
| 1858 |
import_components7.Modal, |
| 1859 |
{ |
| 1860 |
title: (0, import_i18n8.__)("Rename"), |
| 1861 |
onRequestClose, |
| 1862 |
...props, |
| 1863 |
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("form", { onSubmit: onSave, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Stack, { direction: "column", gap: "lg", children: [ |
| 1864 |
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Stack, { direction: "column", gap: "sm", children: [ |
| 1865 |
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)( |
| 1866 |
import_components7.TextControl, |
| 1867 |
{ |
| 1868 |
ref: textControlRef, |
| 1869 |
label: (0, import_i18n8.__)("Name"), |
| 1870 |
value: name, |
| 1871 |
onChange, |
| 1872 |
"aria-describedby": validationMessageId, |
| 1873 |
required: true |
| 1874 |
} |
| 1875 |
), |
| 1876 |
validationMessage && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( |
| 1877 |
"span", |
| 1878 |
{ |
| 1879 |
className: "patterns-rename-pattern-category-modal__validation-message", |
| 1880 |
id: validationMessageId, |
| 1881 |
children: validationMessage |
| 1882 |
} |
| 1883 |
) |
| 1884 |
] }), |
| 1885 |
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Stack, { gap: "sm", justify: "end", children: [ |
| 1886 |
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)( |
| 1887 |
import_components7.Button, |
| 1888 |
{ |
| 1889 |
__next40pxDefaultSize: true, |
| 1890 |
variant: "tertiary", |
| 1891 |
onClick: onRequestClose, |
| 1892 |
children: (0, import_i18n8.__)("Cancel") |
| 1893 |
} |
| 1894 |
), |
| 1895 |
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)( |
| 1896 |
import_components7.Button, |
| 1897 |
{ |
| 1898 |
__next40pxDefaultSize: true, |
| 1899 |
variant: "primary", |
| 1900 |
type: "submit", |
| 1901 |
"aria-disabled": !name || name === category.name || isSaving, |
| 1902 |
isBusy: isSaving, |
| 1903 |
children: (0, import_i18n8.__)("Save") |
| 1904 |
} |
| 1905 |
) |
| 1906 |
] }) |
| 1907 |
] }) }) |
| 1908 |
} |
| 1909 |
); |
| 1910 |
} |
| 1911 |
|
| 1912 |
// packages/patterns/build-module/components/pattern-overrides-controls.mjs |
| 1913 |
var import_element12 = __toESM(require_element(), 1); |
| 1914 |
var import_block_editor6 = __toESM(require_block_editor(), 1); |
| 1915 |
var import_components9 = __toESM(require_components(), 1); |
| 1916 |
var import_i18n10 = __toESM(require_i18n(), 1); |
| 1917 |
|
| 1918 |
// packages/patterns/build-module/components/allow-overrides-modal.mjs |
| 1919 |
var import_components8 = __toESM(require_components(), 1); |
| 1920 |
var import_i18n9 = __toESM(require_i18n(), 1); |
| 1921 |
var import_element11 = __toESM(require_element(), 1); |
| 1922 |
var import_a11y2 = __toESM(require_a11y(), 1); |
| 1923 |
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); |
| 1924 |
function AllowOverridesModal({ |
| 1925 |
placeholder, |
| 1926 |
initialName = "", |
| 1927 |
onClose, |
| 1928 |
onSave |
| 1929 |
}) { |
| 1930 |
const [editedBlockName, setEditedBlockName] = (0, import_element11.useState)(initialName); |
| 1931 |
const descriptionId = (0, import_element11.useId)(); |
| 1932 |
const isNameValid = !!editedBlockName.trim(); |
| 1933 |
const handleSubmit = () => { |
| 1934 |
if (editedBlockName !== initialName) { |
| 1935 |
const message = (0, import_i18n9.sprintf)( |
| 1936 |
/* translators: %s: new name/label for the block */ |
| 1937 |
(0, import_i18n9.__)('Block name changed to: "%s".'), |
| 1938 |
editedBlockName |
| 1939 |
); |
| 1940 |
(0, import_a11y2.speak)(message, "assertive"); |
| 1941 |
} |
| 1942 |
onSave(editedBlockName); |
| 1943 |
onClose(); |
| 1944 |
}; |
| 1945 |
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 1946 |
import_components8.Modal, |
| 1947 |
{ |
| 1948 |
title: (0, import_i18n9.__)("Enable overrides"), |
| 1949 |
onRequestClose: onClose, |
| 1950 |
focusOnMount: "firstContentElement", |
| 1951 |
aria: { describedby: descriptionId }, |
| 1952 |
size: "small", |
| 1953 |
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 1954 |
"form", |
| 1955 |
{ |
| 1956 |
onSubmit: (event) => { |
| 1957 |
event.preventDefault(); |
| 1958 |
if (!isNameValid) { |
| 1959 |
return; |
| 1960 |
} |
| 1961 |
handleSubmit(); |
| 1962 |
}, |
| 1963 |
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Stack, { direction: "column", gap: "xl", children: [ |
| 1964 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { id: descriptionId, children: (0, import_i18n9.__)( |
| 1965 |
"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." |
| 1966 |
) }), |
| 1967 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 1968 |
import_components8.TextControl, |
| 1969 |
{ |
| 1970 |
value: editedBlockName, |
| 1971 |
label: (0, import_i18n9.__)("Name"), |
| 1972 |
help: (0, import_i18n9.__)( |
| 1973 |
'For example, if you are creating a recipe pattern, you use "Recipe Title", "Recipe Description", etc.' |
| 1974 |
), |
| 1975 |
placeholder, |
| 1976 |
onChange: setEditedBlockName |
| 1977 |
} |
| 1978 |
), |
| 1979 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Stack, { gap: "sm", justify: "end", children: [ |
| 1980 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 1981 |
import_components8.Button, |
| 1982 |
{ |
| 1983 |
__next40pxDefaultSize: true, |
| 1984 |
variant: "tertiary", |
| 1985 |
onClick: onClose, |
| 1986 |
children: (0, import_i18n9.__)("Cancel") |
| 1987 |
} |
| 1988 |
), |
| 1989 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 1990 |
import_components8.Button, |
| 1991 |
{ |
| 1992 |
__next40pxDefaultSize: true, |
| 1993 |
"aria-disabled": !isNameValid, |
| 1994 |
variant: "primary", |
| 1995 |
type: "submit", |
| 1996 |
children: (0, import_i18n9.__)("Enable") |
| 1997 |
} |
| 1998 |
) |
| 1999 |
] }) |
| 2000 |
] }) |
| 2001 |
} |
| 2002 |
) |
| 2003 |
} |
| 2004 |
); |
| 2005 |
} |
| 2006 |
function DisallowOverridesModal({ onClose, onSave }) { |
| 2007 |
const descriptionId = (0, import_element11.useId)(); |
| 2008 |
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 2009 |
import_components8.Modal, |
| 2010 |
{ |
| 2011 |
title: (0, import_i18n9.__)("Disable overrides"), |
| 2012 |
onRequestClose: onClose, |
| 2013 |
aria: { describedby: descriptionId }, |
| 2014 |
size: "small", |
| 2015 |
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 2016 |
"form", |
| 2017 |
{ |
| 2018 |
onSubmit: (event) => { |
| 2019 |
event.preventDefault(); |
| 2020 |
onSave(); |
| 2021 |
onClose(); |
| 2022 |
}, |
| 2023 |
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Stack, { direction: "column", gap: "xl", children: [ |
| 2024 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { id: descriptionId, children: (0, import_i18n9.__)( |
| 2025 |
"Are you sure you want to disable overrides? Disabling overrides will revert all applied overrides for this block throughout instances of this pattern." |
| 2026 |
) }), |
| 2027 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Stack, { gap: "sm", justify: "end", children: [ |
| 2028 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 2029 |
import_components8.Button, |
| 2030 |
{ |
| 2031 |
__next40pxDefaultSize: true, |
| 2032 |
variant: "tertiary", |
| 2033 |
onClick: onClose, |
| 2034 |
children: (0, import_i18n9.__)("Cancel") |
| 2035 |
} |
| 2036 |
), |
| 2037 |
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)( |
| 2038 |
import_components8.Button, |
| 2039 |
{ |
| 2040 |
__next40pxDefaultSize: true, |
| 2041 |
variant: "primary", |
| 2042 |
type: "submit", |
| 2043 |
children: (0, import_i18n9.__)("Disable") |
| 2044 |
} |
| 2045 |
) |
| 2046 |
] }) |
| 2047 |
] }) |
| 2048 |
} |
| 2049 |
) |
| 2050 |
} |
| 2051 |
); |
| 2052 |
} |
| 2053 |
|
| 2054 |
// packages/patterns/build-module/components/pattern-overrides-controls.mjs |
| 2055 |
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); |
| 2056 |
function PatternOverridesControls({ |
| 2057 |
attributes, |
| 2058 |
setAttributes, |
| 2059 |
name: blockName |
| 2060 |
}) { |
| 2061 |
const controlId = (0, import_element12.useId)(); |
| 2062 |
const [showAllowOverridesModal, setShowAllowOverridesModal] = (0, import_element12.useState)(false); |
| 2063 |
const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0, import_element12.useState)(false); |
| 2064 |
const hasName = !!attributes.metadata?.name; |
| 2065 |
const defaultBindings = attributes.metadata?.bindings?.__default; |
| 2066 |
const hasOverrides = hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE; |
| 2067 |
const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== PATTERN_OVERRIDES_BINDING_SOURCE; |
| 2068 |
const { updateBlockBindings } = (0, import_block_editor6.useBlockBindingsUtils)(); |
| 2069 |
function updateBindings(isChecked, customName) { |
| 2070 |
if (customName) { |
| 2071 |
setAttributes({ |
| 2072 |
metadata: { |
| 2073 |
...attributes.metadata, |
| 2074 |
name: customName |
| 2075 |
} |
| 2076 |
}); |
| 2077 |
} |
| 2078 |
updateBlockBindings({ |
| 2079 |
__default: isChecked ? { source: PATTERN_OVERRIDES_BINDING_SOURCE } : void 0 |
| 2080 |
}); |
| 2081 |
} |
| 2082 |
if (isConnectedToOtherSources) { |
| 2083 |
return null; |
| 2084 |
} |
| 2085 |
const hasUnsupportedImageAttributes = blockName === "core/image" && !!attributes.href?.length; |
| 2086 |
const helpText = !hasOverrides && hasUnsupportedImageAttributes ? (0, import_i18n10.__)( |
| 2087 |
`Overrides currently don't support image links. Remove the link first before enabling overrides.` |
| 2088 |
) : (0, import_i18n10.__)( |
| 2089 |
"Allow changes to this block throughout instances of this pattern." |
| 2090 |
); |
| 2091 |
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [ |
| 2092 |
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_block_editor6.InspectorControls, { group: "advanced", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( |
| 2093 |
import_components9.BaseControl, |
| 2094 |
{ |
| 2095 |
id: controlId, |
| 2096 |
label: (0, import_i18n10.__)("Overrides"), |
| 2097 |
help: helpText, |
| 2098 |
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( |
| 2099 |
import_components9.Button, |
| 2100 |
{ |
| 2101 |
__next40pxDefaultSize: true, |
| 2102 |
className: "pattern-overrides-control__allow-overrides-button", |
| 2103 |
variant: "secondary", |
| 2104 |
"aria-haspopup": "dialog", |
| 2105 |
onClick: () => { |
| 2106 |
if (hasOverrides) { |
| 2107 |
setShowDisallowOverridesModal(true); |
| 2108 |
} else { |
| 2109 |
setShowAllowOverridesModal(true); |
| 2110 |
} |
| 2111 |
}, |
| 2112 |
disabled: !hasOverrides && hasUnsupportedImageAttributes, |
| 2113 |
accessibleWhenDisabled: true, |
| 2114 |
children: hasOverrides ? (0, import_i18n10.__)("Disable overrides") : (0, import_i18n10.__)("Enable overrides") |
| 2115 |
} |
| 2116 |
) |
| 2117 |
} |
| 2118 |
) }), |
| 2119 |
showAllowOverridesModal && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( |
| 2120 |
AllowOverridesModal, |
| 2121 |
{ |
| 2122 |
initialName: attributes.metadata?.name, |
| 2123 |
onClose: () => setShowAllowOverridesModal(false), |
| 2124 |
onSave: (newName) => { |
| 2125 |
updateBindings(true, newName); |
| 2126 |
} |
| 2127 |
} |
| 2128 |
), |
| 2129 |
showDisallowOverridesModal && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( |
| 2130 |
DisallowOverridesModal, |
| 2131 |
{ |
| 2132 |
onClose: () => setShowDisallowOverridesModal(false), |
| 2133 |
onSave: () => updateBindings(false) |
| 2134 |
} |
| 2135 |
) |
| 2136 |
] }); |
| 2137 |
} |
| 2138 |
var pattern_overrides_controls_default = PatternOverridesControls; |
| 2139 |
|
| 2140 |
// packages/patterns/build-module/components/reset-overrides-control.mjs |
| 2141 |
var import_block_editor7 = __toESM(require_block_editor(), 1); |
| 2142 |
var import_components10 = __toESM(require_components(), 1); |
| 2143 |
var import_data11 = __toESM(require_data(), 1); |
| 2144 |
var import_i18n11 = __toESM(require_i18n(), 1); |
| 2145 |
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); |
| 2146 |
var CONTENT = "content"; |
| 2147 |
function ResetOverridesControl(props) { |
| 2148 |
const name = props.attributes.metadata?.name; |
| 2149 |
const registry = (0, import_data11.useRegistry)(); |
| 2150 |
const isOverridden = (0, import_data11.useSelect)( |
| 2151 |
(select) => { |
| 2152 |
if (!name) { |
| 2153 |
return; |
| 2154 |
} |
| 2155 |
const { getBlockAttributes, getBlockParentsByBlockName } = select(import_block_editor7.store); |
| 2156 |
const [patternClientId] = getBlockParentsByBlockName( |
| 2157 |
props.clientId, |
| 2158 |
"core/block", |
| 2159 |
true |
| 2160 |
); |
| 2161 |
if (!patternClientId) { |
| 2162 |
return; |
| 2163 |
} |
| 2164 |
const overrides = getBlockAttributes(patternClientId)[CONTENT]; |
| 2165 |
if (!overrides) { |
| 2166 |
return; |
| 2167 |
} |
| 2168 |
return overrides.hasOwnProperty(name); |
| 2169 |
}, |
| 2170 |
[props.clientId, name] |
| 2171 |
); |
| 2172 |
function onClick() { |
| 2173 |
const { getBlockAttributes, getBlockParentsByBlockName } = registry.select(import_block_editor7.store); |
| 2174 |
const [patternClientId] = getBlockParentsByBlockName( |
| 2175 |
props.clientId, |
| 2176 |
"core/block", |
| 2177 |
true |
| 2178 |
); |
| 2179 |
if (!patternClientId) { |
| 2180 |
return; |
| 2181 |
} |
| 2182 |
const overrides = getBlockAttributes(patternClientId)[CONTENT]; |
| 2183 |
if (!overrides.hasOwnProperty(name)) { |
| 2184 |
return; |
| 2185 |
} |
| 2186 |
const { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } = registry.dispatch(import_block_editor7.store); |
| 2187 |
__unstableMarkLastChangeAsPersistent(); |
| 2188 |
let newOverrides = { ...overrides }; |
| 2189 |
delete newOverrides[name]; |
| 2190 |
if (!Object.keys(newOverrides).length) { |
| 2191 |
newOverrides = void 0; |
| 2192 |
} |
| 2193 |
updateBlockAttributes(patternClientId, { |
| 2194 |
[CONTENT]: newOverrides |
| 2195 |
}); |
| 2196 |
} |
| 2197 |
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_block_editor7.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components10.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components10.ToolbarButton, { onClick, disabled: !isOverridden, children: (0, import_i18n11.__)("Reset") }) }) }); |
| 2198 |
} |
| 2199 |
|
| 2200 |
// packages/patterns/build-module/private-apis.mjs |
| 2201 |
var privateApis = {}; |
| 2202 |
lock(privateApis, { |
| 2203 |
OverridesPanel, |
| 2204 |
CreatePatternModal, |
| 2205 |
CreatePatternModalContents, |
| 2206 |
DuplicatePatternModal, |
| 2207 |
isOverridableBlock, |
| 2208 |
useDuplicatePatternProps, |
| 2209 |
RenamePatternModal, |
| 2210 |
PatternsMenuItems, |
| 2211 |
RenamePatternCategoryModal, |
| 2212 |
PatternOverridesControls: pattern_overrides_controls_default, |
| 2213 |
ResetOverridesControl, |
| 2214 |
useAddPatternCategory, |
| 2215 |
PATTERN_TYPES, |
| 2216 |
PATTERN_DEFAULT_CATEGORY, |
| 2217 |
PATTERN_USER_CATEGORY, |
| 2218 |
EXCLUDED_PATTERN_SOURCES, |
| 2219 |
PATTERN_SYNC_TYPES |
| 2220 |
}); |
| 2221 |
return __toCommonJS(index_exports); |
| 2222 |
})(); |
| 2223 |
//# sourceMappingURL=index.js.map |
| 2224 |
|