You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.0 KiB

1 year ago
  1. "use strict";
  2. (self["__WordPressPrivateInteractivityAPI__"] = self["__WordPressPrivateInteractivityAPI__"] || []).push([[222],{
  3. /***/ 534:
  4. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  5. /* harmony import */ var _wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(754);
  6. /**
  7. * WordPress dependencies
  8. */
  9. (0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .store */ .h)({
  10. selectors: {
  11. core: {
  12. search: {
  13. ariaLabel: ({
  14. context
  15. }) => {
  16. const {
  17. ariaLabelCollapsed,
  18. ariaLabelExpanded
  19. } = context.core.search;
  20. return context.core.search.isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
  21. },
  22. ariaControls: ({
  23. context
  24. }) => {
  25. return context.core.search.isSearchInputVisible ? null : context.core.search.inputId;
  26. },
  27. type: ({
  28. context
  29. }) => {
  30. return context.core.search.isSearchInputVisible ? 'submit' : 'button';
  31. },
  32. tabindex: ({
  33. context
  34. }) => {
  35. return context.core.search.isSearchInputVisible ? '0' : '-1';
  36. }
  37. }
  38. }
  39. },
  40. actions: {
  41. core: {
  42. search: {
  43. openSearchInput: ({
  44. context,
  45. event,
  46. ref
  47. }) => {
  48. if (!context.core.search.isSearchInputVisible) {
  49. event.preventDefault();
  50. context.core.search.isSearchInputVisible = true;
  51. ref.parentElement.querySelector('input').focus();
  52. }
  53. },
  54. closeSearchInput: ({
  55. context
  56. }) => {
  57. context.core.search.isSearchInputVisible = false;
  58. },
  59. handleSearchKeydown: store => {
  60. const {
  61. actions,
  62. event,
  63. ref
  64. } = store;
  65. // If Escape close the menu.
  66. if (event?.key === 'Escape') {
  67. actions.core.search.closeSearchInput(store);
  68. ref.querySelector('button').focus();
  69. }
  70. },
  71. handleSearchFocusout: store => {
  72. const {
  73. actions,
  74. event,
  75. ref
  76. } = store;
  77. // If focus is outside search form, and in the document, close menu
  78. // event.target === The element losing focus
  79. // event.relatedTarget === The element receiving focus (if any)
  80. // When focusout is outside the document,
  81. // `window.document.activeElement` doesn't change.
  82. if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
  83. actions.core.search.closeSearchInput(store);
  84. }
  85. }
  86. }
  87. }
  88. }
  89. });
  90. /***/ })
  91. },
  92. /******/ function(__webpack_require__) { // webpackRuntimeModules
  93. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  94. /******/ var __webpack_exports__ = (__webpack_exec__(534));
  95. /******/ }
  96. ]);