UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 2.81 kB
import{jsx as c}from"react/jsx-runtime";import"./EntityList.scss";import{OverlayScrollContext as x,Spinner as v}from"@expofp/ui";import{observer as C}from"mobx-react-lite";import{lazy as T,Suspense as L,useCallback as E,useContext as w,useEffect as R,useRef as P}from"react";import e,{uiState as t}from"../store";import O from"../tools/settings";import{t as I}from"../utils/i18n";import H from"./EntityListRow";const S=()=>import("react-virtuoso").then(r=>({default:r.Virtuoso})).catch(()=>new Promise(r=>setTimeout(()=>r(S()),3e3))),V=T(S),_=["ipia2025"],z=({updatedScrollableRef:r,updateScroll:m})=>{const f=w(x),a=P(null),b=t.getListScrollItemId(t.list.type),g=_.includes(O.EXPO);R(()=>{const n=t.getListScrollTop(t.list.type),l=t.getListScrollItemId(t.list.type);(n>0||l)&&setTimeout(()=>{if(a.current){if(l){const o=t.listItems.findIndex(s=>s?.id?.toString()===l.toString());if(o!==-1){a.current.scrollToIndex({index:o,align:"center",behavior:"auto"});return}}n>0&&a.current.scrollTo({top:n,behavior:"auto"})}},100)},[t.list.type]);const u=t.showRouteInstantly,y=E((n,l)=>{const o=parseInt(l,10);switch(t.setListScrollItemId(t.list?.type,o),a.current?a.current.getState(s=>{const h=s?.scrollTop||0;t.setListScrollTop(t.list?.type,h)}):r.current&&t.setListScrollTop(t.list?.type,r.current.scrollTop||0),n){case"exhibitor":const s=e.exhibitorStore.exhibitors.find(i=>i.id===o);u?e.routeStore.clickRoute(null,e.routeStore.tempToBooth||s.booths[0]):e.clickExhibitor(s);break;case"booth":const h=e.boothStore.booths.find(i=>i.id===o);u?e.routeStore.clickRoute(null,h):e.clickBoothInList2(h);break;case"category":e.clickCategory(e.categoryStore.categories.find(i=>i.id===o));break;case"event":const d=e.eventStore.eventItems.find(i=>i.id===o);if(d){const i=e.boothStore.booths.find(p=>p.id===d.boothId);u&&i?e.routeStore.clickRoute(null,i):e.selectEventItem(d,!0)}break;case"speaker":{const i=e.speakerStore.speakers.find(p=>p.id===o);i&&e.selectSpeaker(i,!0);break}}},[u,r]),k=()=>c("div",{className:"list-empty",children:t.list.type==="search"?I("Oops, nothing found"):I("No items to show")});return f===null||t.setKioskModeEnabled?null:t.listItems.length?c("div",{style:{height:"100%",cursor:"pointer",resize:"both",minHeight:100},children:c(L,{fallback:c(v,{active:!0,isCenter:!0}),children:c(V,{ref:a,className:"list-virtual",style:{minHeight:t.listItems.length?"1px":0},data:t.listItems,itemContent:(n,l)=>{const o=l;if(!o)return null;const s=b?.toString()===o.id?.toString();return c(H,{item:o,index:n,current:s,compactDetails:g,onClick:y},o.id)},itemsRendered:()=>m&&setTimeout(m),totalListHeightChanged:()=>m&&m(),customScrollParent:f,totalCount:t.listItems.length,overscan:20,increaseViewportBy:200,initialItemCount:Math.min(t.listScrollIndex+30,t.listItems.length)})})}):c(k,{})};export default C(z);