// Copyright 2023, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import { Block, LayoutComponentModel } from "@/app/block/block"; import { getApi } from "@/store/global"; import * as services from "@/store/services"; import * as WOS from "@/store/wos"; import * as React from "react"; import { CenteredDiv } from "@/element/quickelems"; import { TileLayout } from "frontend/layout/index"; import { getLayoutStateAtomForTab } from "frontend/layout/lib/layoutAtom"; import { useAtomValue } from "jotai"; import { useMemo } from "react"; import "./tabcontent.less"; const TabContent = React.memo(({ tabId }: { tabId: string }) => { const oref = useMemo(() => WOS.makeORef("tab", tabId), [tabId]); const loadingAtom = useMemo(() => WOS.getWaveObjectLoadingAtom(oref), [oref]); const tabLoading = useAtomValue(loadingAtom); const tabAtom = useMemo(() => WOS.getWaveObjectAtom(oref), [oref]); const layoutStateAtom = useMemo(() => getLayoutStateAtomForTab(tabId, tabAtom), [tabAtom, tabId]); const tabData = useAtomValue(tabAtom); const tileLayoutContents = useMemo(() => { function renderBlock( tabData: TabLayoutData, ready: boolean, onMagnifyToggle: () => void, onClose: () => void, dragHandleRef: React.RefObject ) { if (!tabData.blockId || !ready) { return null; } const layoutModel: LayoutComponentModel = { onClose: onClose, onMagnifyToggle: onMagnifyToggle, dragHandleRef: dragHandleRef, }; return ; } function renderPreview(tabData: TabLayoutData) { return ; } function onNodeDelete(data: TabLayoutData) { return services.ObjectService.DeleteBlock(data.blockId); } return { renderContent: renderBlock, renderPreview: renderPreview, tabId: tabId, onNodeDelete: onNodeDelete, }; }, []); if (tabLoading) { return (
Tab Loading
); } if (!tabData) { return (
Tab Not Found
); } if (tabData?.blockids?.length == 0) { return
; } return (
); }); export { TabContent };