// Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import { Block } from "@/app/block/block"; import { CenteredDiv } from "@/element/quickelems"; import { ContentRenderer, NodeModel, PreviewRenderer, TileLayout } from "@/layout/index"; import { TileLayoutContents } from "@/layout/lib/types"; import { atoms, getApi } from "@/store/global"; import * as services from "@/store/services"; import * as WOS from "@/store/wos"; import { atom, useAtomValue } from "jotai"; import * as React from "react"; import { useMemo } from "react"; import "./tabcontent.less"; const tileGapSizeAtom = atom((get) => { const settings = get(atoms.settingsAtom); return settings["window:tilegapsize"]; }); 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 tabData = useAtomValue(tabAtom); const tileGapSize = useAtomValue(tileGapSizeAtom); const tileLayoutContents = useMemo(() => { const renderContent: ContentRenderer = (nodeModel: NodeModel) => { return ; }; const renderPreview: PreviewRenderer = (nodeModel: NodeModel) => { return ; }; function onNodeDelete(data: TabLayoutData) { return services.ObjectService.DeleteBlock(data.blockId); } return { renderContent, renderPreview, tabId, onNodeDelete, gapSizePx: tileGapSize, } as TileLayoutContents; }, [tabId, tileGapSize]); if (tabLoading) { return (
Tab Loading
); } if (!tabData) { return (
Tab Not Found
); } if (tabData?.blockids?.length == 0) { return
; } return (
); }); export { TabContent };