[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 import * as __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__ from "@wordpress/interactivity"; 2 /******/ // The require scope 3 /******/ var __webpack_require__ = {}; 4 /******/ 5 /************************************************************************/ 6 /******/ /* webpack/runtime/define property getters */ 7 /******/ (() => { 8 /******/ // define getter functions for harmony exports 9 /******/ __webpack_require__.d = (exports, definition) => { 10 /******/ for(var key in definition) { 11 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 12 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 13 /******/ } 14 /******/ } 15 /******/ }; 16 /******/ })(); 17 /******/ 18 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 19 /******/ (() => { 20 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 21 /******/ })(); 22 /******/ 23 /************************************************************************/ 24 var __webpack_exports__ = {}; 25 26 ;// external "@wordpress/interactivity" 27 var x = (y) => { 28 var x = {}; __webpack_require__.d(x, y); return x 29 } 30 var y = (x) => (() => (x)) 31 const interactivity_namespaceObject = x({ ["getContext"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), ["getElement"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), ["store"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store), ["withSyncEvent"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.withSyncEvent) }); 32 ;// ./node_modules/@wordpress/block-library/build-module/navigation/view.js 33 34 const focusableSelectors = [ 35 "a[href]", 36 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', 37 "select:not([disabled]):not([aria-hidden])", 38 "textarea:not([disabled]):not([aria-hidden])", 39 "button:not([disabled]):not([aria-hidden])", 40 "[contenteditable]", 41 '[tabindex]:not([tabindex^="-"])' 42 ]; 43 document.addEventListener("click", () => { 44 }); 45 const { state, actions } = (0,interactivity_namespaceObject.store)( 46 "core/navigation", 47 { 48 state: { 49 get roleAttribute() { 50 const ctx = (0,interactivity_namespaceObject.getContext)(); 51 return ctx.type === "overlay" && state.isMenuOpen ? "dialog" : null; 52 }, 53 get ariaModal() { 54 const ctx = (0,interactivity_namespaceObject.getContext)(); 55 return ctx.type === "overlay" && state.isMenuOpen ? "true" : null; 56 }, 57 get ariaLabel() { 58 const ctx = (0,interactivity_namespaceObject.getContext)(); 59 return ctx.type === "overlay" && state.isMenuOpen ? ctx.ariaLabel : null; 60 }, 61 get isMenuOpen() { 62 return Object.values(state.menuOpenedBy).filter(Boolean).length > 0; 63 }, 64 get menuOpenedBy() { 65 const ctx = (0,interactivity_namespaceObject.getContext)(); 66 return ctx.type === "overlay" ? ctx.overlayOpenedBy : ctx.submenuOpenedBy; 67 } 68 }, 69 actions: { 70 openMenuOnHover() { 71 const { type, overlayOpenedBy } = (0,interactivity_namespaceObject.getContext)(); 72 if (type === "submenu" && // Only open on hover if the overlay is closed. 73 Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) { 74 actions.openMenu("hover"); 75 } 76 }, 77 closeMenuOnHover() { 78 const { type, overlayOpenedBy } = (0,interactivity_namespaceObject.getContext)(); 79 if (type === "submenu" && // Only close on hover if the overlay is closed. 80 Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) { 81 actions.closeMenu("hover"); 82 } 83 }, 84 openMenuOnClick() { 85 const ctx = (0,interactivity_namespaceObject.getContext)(); 86 const { ref } = (0,interactivity_namespaceObject.getElement)(); 87 ctx.previousFocus = ref; 88 actions.openMenu("click"); 89 }, 90 closeMenuOnClick() { 91 actions.closeMenu("click"); 92 actions.closeMenu("focus"); 93 }, 94 openMenuOnFocus() { 95 actions.openMenu("focus"); 96 }, 97 toggleMenuOnClick() { 98 const ctx = (0,interactivity_namespaceObject.getContext)(); 99 const { ref } = (0,interactivity_namespaceObject.getElement)(); 100 if (window.document.activeElement !== ref) { 101 ref.focus(); 102 } 103 const { menuOpenedBy } = state; 104 if (menuOpenedBy.click || menuOpenedBy.focus) { 105 actions.closeMenu("click"); 106 actions.closeMenu("focus"); 107 } else { 108 ctx.previousFocus = ref; 109 actions.openMenu("click"); 110 } 111 }, 112 handleMenuKeydown: (0,interactivity_namespaceObject.withSyncEvent)((event) => { 113 const { type, firstFocusableElement, lastFocusableElement } = (0,interactivity_namespaceObject.getContext)(); 114 if (state.menuOpenedBy.click) { 115 if (event.key === "Escape") { 116 event.stopPropagation(); 117 actions.closeMenu("click"); 118 actions.closeMenu("focus"); 119 return; 120 } 121 if (type === "overlay" && event.key === "Tab") { 122 if (event.shiftKey && window.document.activeElement === firstFocusableElement) { 123 event.preventDefault(); 124 lastFocusableElement.focus(); 125 } else if (!event.shiftKey && window.document.activeElement === lastFocusableElement) { 126 event.preventDefault(); 127 firstFocusableElement.focus(); 128 } 129 } 130 } 131 }), 132 handleMenuFocusout(event) { 133 const { modal, type } = (0,interactivity_namespaceObject.getContext)(); 134 if (event.relatedTarget === null || !modal?.contains(event.relatedTarget) && event.target !== window.document.activeElement && type === "submenu") { 135 actions.closeMenu("click"); 136 actions.closeMenu("focus"); 137 } 138 }, 139 openMenu(menuOpenedOn = "click") { 140 const { type } = (0,interactivity_namespaceObject.getContext)(); 141 state.menuOpenedBy[menuOpenedOn] = true; 142 if (type === "overlay") { 143 document.documentElement.classList.add("has-modal-open"); 144 } 145 }, 146 closeMenu(menuClosedOn = "click") { 147 const ctx = (0,interactivity_namespaceObject.getContext)(); 148 state.menuOpenedBy[menuClosedOn] = false; 149 if (!state.isMenuOpen) { 150 if (ctx.modal?.contains(window.document.activeElement)) { 151 ctx.previousFocus?.focus(); 152 } 153 ctx.modal = null; 154 ctx.previousFocus = null; 155 if (ctx.type === "overlay") { 156 document.documentElement.classList.remove( 157 "has-modal-open" 158 ); 159 } 160 } 161 } 162 }, 163 callbacks: { 164 initMenu() { 165 const ctx = (0,interactivity_namespaceObject.getContext)(); 166 const { ref } = (0,interactivity_namespaceObject.getElement)(); 167 if (state.isMenuOpen) { 168 const focusableElements = ref.querySelectorAll(focusableSelectors); 169 ctx.modal = ref; 170 ctx.firstFocusableElement = focusableElements[0]; 171 ctx.lastFocusableElement = focusableElements[focusableElements.length - 1]; 172 } 173 }, 174 focusFirstElement() { 175 const { ref } = (0,interactivity_namespaceObject.getElement)(); 176 if (state.isMenuOpen) { 177 const focusableElements = ref.querySelectorAll(focusableSelectors); 178 focusableElements?.[0]?.focus(); 179 } 180 } 181 } 182 }, 183 { lock: true } 184 ); 185
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Oct 23 08:20:05 2025 | Cross-referenced by PHPXref |