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