UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 892 B
import{jsx as e}from"react/jsx-runtime";import"./SearchSubButtons.scss";import i from"classnames";import{observer as c}from"mobx-react-lite";import{memo as a,useEffect as m,useMemo as d,useRef as h}from"react";import S from"../../store";import b from"./SearchSubButton";const s=a(c(()=>{const{searchButtonsStore:t}=S,u=h(null);m(()=>{const o=r=>{r.key==="Escape"&&t.shouldShowSubButtons&&t.hideSubButtons()};if(t.shouldShowSubButtons)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t.shouldShowSubButtons]);const n=d(()=>t.activeSubButtons,[t.activeSubButtons]);return t.shouldShowSubButtons?e("div",{ref:u,className:i("efp-search-sub-buttons",{"is-visible":t.shouldShowSubButtons}),children:e("div",{className:"efp-search-sub-buttons__container",children:n.map(o=>e(b,{...o},o.id))})}):null}));s.displayName="SearchSubButtons";export default s;