summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/search/view.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wp-includes/blocks/search/view.js187
1 files changed, 99 insertions, 88 deletions
diff --git a/wp-includes/blocks/search/view.js b/wp-includes/blocks/search/view.js
index 9d18abf..2234847 100644
--- a/wp-includes/blocks/search/view.js
+++ b/wp-includes/blocks/search/view.js
@@ -1,101 +1,112 @@
-"use strict";
-(self["__WordPressPrivateInteractivityAPI__"] = self["__WordPressPrivateInteractivityAPI__"] || []).push([[222],{
+import * as __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__ from "@wordpress/interactivity";
+/******/ // The require scope
+/******/ var __webpack_require__ = {};
+/******/
+/************************************************************************/
+/******/ /* webpack/runtime/define property getters */
+/******/ (() => {
+/******/ // define getter functions for harmony exports
+/******/ __webpack_require__.d = (exports, definition) => {
+/******/ for(var key in definition) {
+/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
+/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
+/******/ }
+/******/ }
+/******/ };
+/******/ })();
+/******/
+/******/ /* webpack/runtime/hasOwnProperty shorthand */
+/******/ (() => {
+/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ })();
+/******/
+/************************************************************************/
+var __webpack_exports__ = {};
-/***/ 534:
-/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
-
-/* harmony import */ var _wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(754);
+;// CONCATENATED MODULE: external "@wordpress/interactivity"
+var x = (y) => {
+ var x = {}; __webpack_require__.d(x, y); return x
+}
+var y = (x) => (() => (x))
+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) });
+;// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/search/view.js
/**
* WordPress dependencies
*/
-(0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .store */ .h)({
- selectors: {
- core: {
- search: {
- ariaLabel: ({
- context
- }) => {
- const {
- ariaLabelCollapsed,
- ariaLabelExpanded
- } = context.core.search;
- return context.core.search.isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
- },
- ariaControls: ({
- context
- }) => {
- return context.core.search.isSearchInputVisible ? null : context.core.search.inputId;
- },
- type: ({
- context
- }) => {
- return context.core.search.isSearchInputVisible ? 'submit' : 'button';
- },
- tabindex: ({
- context
- }) => {
- return context.core.search.isSearchInputVisible ? '0' : '-1';
- }
- }
+const {
+ actions
+} = (0,interactivity_namespaceObject.store)('core/search', {
+ state: {
+ get ariaLabel() {
+ const {
+ isSearchInputVisible,
+ ariaLabelCollapsed,
+ ariaLabelExpanded
+ } = (0,interactivity_namespaceObject.getContext)();
+ return isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
+ },
+ get ariaControls() {
+ const {
+ isSearchInputVisible,
+ inputId
+ } = (0,interactivity_namespaceObject.getContext)();
+ return isSearchInputVisible ? null : inputId;
+ },
+ get type() {
+ const {
+ isSearchInputVisible
+ } = (0,interactivity_namespaceObject.getContext)();
+ return isSearchInputVisible ? 'submit' : 'button';
+ },
+ get tabindex() {
+ const {
+ isSearchInputVisible
+ } = (0,interactivity_namespaceObject.getContext)();
+ return isSearchInputVisible ? '0' : '-1';
}
},
actions: {
- core: {
- search: {
- openSearchInput: ({
- context,
- event,
- ref
- }) => {
- if (!context.core.search.isSearchInputVisible) {
- event.preventDefault();
- context.core.search.isSearchInputVisible = true;
- ref.parentElement.querySelector('input').focus();
- }
- },
- closeSearchInput: ({
- context
- }) => {
- context.core.search.isSearchInputVisible = false;
- },
- handleSearchKeydown: store => {
- const {
- actions,
- event,
- ref
- } = store;
- // If Escape close the menu.
- if (event?.key === 'Escape') {
- actions.core.search.closeSearchInput(store);
- ref.querySelector('button').focus();
- }
- },
- handleSearchFocusout: store => {
- const {
- actions,
- event,
- ref
- } = store;
- // If focus is outside search form, and in the document, close menu
- // event.target === The element losing focus
- // event.relatedTarget === The element receiving focus (if any)
- // When focusout is outside the document,
- // `window.document.activeElement` doesn't change.
- if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
- actions.core.search.closeSearchInput(store);
- }
- }
+ openSearchInput(event) {
+ const ctx = (0,interactivity_namespaceObject.getContext)();
+ const {
+ ref
+ } = (0,interactivity_namespaceObject.getElement)();
+ if (!ctx.isSearchInputVisible) {
+ event.preventDefault();
+ ctx.isSearchInputVisible = true;
+ ref.parentElement.querySelector('input').focus();
+ }
+ },
+ closeSearchInput() {
+ const ctx = (0,interactivity_namespaceObject.getContext)();
+ ctx.isSearchInputVisible = false;
+ },
+ handleSearchKeydown(event) {
+ const {
+ ref
+ } = (0,interactivity_namespaceObject.getElement)();
+ // If Escape close the menu.
+ if (event?.key === 'Escape') {
+ actions.closeSearchInput();
+ ref.querySelector('button').focus();
+ }
+ },
+ handleSearchFocusout(event) {
+ const {
+ ref
+ } = (0,interactivity_namespaceObject.getElement)();
+ // If focus is outside search form, and in the document, close menu
+ // event.target === The element losing focus
+ // event.relatedTarget === The element receiving focus (if any)
+ // When focusout is outside the document,
+ // `window.document.activeElement` doesn't change.
+ if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
+ actions.closeSearchInput();
}
}
}
+}, {
+ lock: true
});
-/***/ })
-
-},
-/******/ function(__webpack_require__) { // webpackRuntimeModules
-/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
-/******/ var __webpack_exports__ = (__webpack_exec__(534));
-/******/ }
-]); \ No newline at end of file