"use client" /** * Library hub — ListPageTemplate + KeyMetrics + LibraryTable (Team / Compliance pattern). * URL hash syncs the active view tab; `?scope=` + `folderId=` sync with the secondary nav (`lib/library-nav.ts`). * (Primary sidebar “Library” must not treat that hash as “off-route” — `app-sidebar` `isNavActive` ignores hash for `href` without `#…`.) */ import * as React from "react" import { useNavigate, useSearchParams } from "react-router" import { ListPageTemplate, type ViewTab, dataListViewIcon, type DataListViewType, VIEW_TYPES, seedTableStateLifecycle, } from "@/components/data-views" import type { ViewType, CreatedViewSpec } from "@/components/data-views" import { LIBRARY_SUPPORTED_VIEWS } from "@/lib/library-supported-views" import { LibraryPageHeader } from "@/components/library-page-header" import { LibraryNewFolderSheet } from "@/components/library-new-folder-sheet" import { CollaborationAccessFlow } from "@/components/collaboration-access-flow" import { LibraryTable, type LibraryTableHandle } from "@/components/library-table" import { LibraryRecordRail } from "@/components/library-record-rail" import type { BulkAction } from "@/components/data-views" import { SecondaryPanelHubTemplate } from "@/components/templates/secondary-panel-hub-template" import { LibraryAccessBridge, LibraryFolderBridge } from "@/components/panel-bridges" import { KeyMetrics } from "@/components/key-metrics" import { useSidebar } from "@/components/ui/sidebar" import { useModKeyLabel, useAltKeyLabel } from "@/hooks/use-mod-key-label" import type { ResponsiveAction } from "@/components/ui/responsive-action-row" import { useProduct } from "@/contexts/product-context" import { productPersistKey } from "@/stores/app-store" import { useSecondaryPanelHubNav } from "@/hooks/use-secondary-panel-hub-nav" import { LIBRARY_ITEMS, type LibraryItem } from "@/lib/mock/library" import { LIBRARY_HEADER_COLLABORATORS } from "@/lib/mock/library-header-collaborators" import { DEFAULT_LIBRARY_FOLDERS, type LibraryFolder } from "@/lib/mock/library-folders" import { libraryKpiMetrics } from "@/lib/mock/library-kpi" import { applyLibraryHubDisplayFilters, isLibraryDefaultNav, isLibraryDedicatedSearchPathname, parseLibraryNav, LIBRARY_HUB_BREADCRUMB, LIBRARY_HUB_FIND_PATH, LIBRARY_ALL_PATH, LIBRARY_LIBRARY_HUB_PATHS, LIBRARY_LIST_PATH, libraryCanonicalNavHref, libraryHubHeaderModel, libraryHubTextMatchesNothing, libraryRouteHref, type LibraryLandingFilterState, type LibraryNavState, } from "@/lib/library-nav" import { patchLibraryDedicatedSearchParams, LIBRARY_DEDICATED_SEARCH_PLACEHOLDERS, } from "@/lib/library-dedicated-search" import { recordLibraryRecentSearch, libraryDedicatedSearchRecents } from "@/lib/library-recent-searches" import { DedicatedSearchRecents } from "@/components/dedicated-search-recents" import { DedicatedSearchUrlComposer } from "@/components/dedicated-search-url-composer" import { DedicatedSearchLandingTemplate } from "@/components/templates/dedicated-search-landing-template" import { DedicatedSearchResultsHeaderChrome, DEDICATED_SEARCH_RESULTS_OUTER_CONTENT_CLASSNAME, } from "@/components/templates/dedicated-search-results-template" import { usePersistedState } from "@exxatdesignux/ui/lib/persisted-state" const DEFAULT_TABS: ViewTab[] = [ { id: "questions", label: "Questions", viewType: "table", icon: "fa-table", filterId: "all", }, ] const SEARCH_LANDING_TABS: ViewTab[] = [DEFAULT_TABS[0]] /** Module scope so the panel-nav hook's deps don't churn on every render. */ const REOPEN_PANEL_PATHNAMES = [LIBRARY_ALL_PATH] function ignoreLibraryTabsUpdate(_next: ViewTab[]) {} function ignoreLibraryTabActivation(_id: string) {} /** Stable no-op for search-landing branch where manage-access is not available. */ function noopManageAccess() {} function libraryQueryPrefixFromSearchString(qs: string) { return qs ? `?${qs}` : "" } type LibrarySetState = React.Dispatch> // ── Pure helpers ────────────────────────────────────────────────────────────── const EMPTY_STEP = { previous: null, next: null, position: null } as const type RecordStep = { previous: string | null next: string | null position: string | null } /** Neighbours of `openRecordId` within the rows the hub is currently showing. */ function computeRecordStep(rows: LibraryItem[], openRecordId: string | null): RecordStep { if (!openRecordId) return EMPTY_STEP const index = rows.findIndex(row => row.id === openRecordId) if (index < 0) return EMPTY_STEP return { previous: index > 0 ? rows[index - 1].id : null, next: index < rows.length - 1 ? rows[index + 1].id : null, position: `${index + 1} of ${rows.length}`, } } function currentHashTab(): string { return typeof window !== "undefined" ? window.location.hash.slice(1) : "" } function folderScopeId(navState: LibraryNavState): string | null { return navState.scope === "folder" && navState.folderId ? navState.folderId : null } function newQuestionFolderQuery(navState: LibraryNavState): string { const folderId = folderScopeId(navState) return folderId ? `?folderId=${encodeURIComponent(folderId)}` : "" } function nextViewName(label: string, existingCount: number): string { return existingCount === 0 ? label : `${label} ${existingCount + 1}` } function parseLandingFilters(searchParamsKey: string): LibraryLandingFilterState { const sp = new URLSearchParams(searchParamsKey) return { hubFreeText: sp.get("q") ?? "", favOnly: sp.get("fav") === "1", clinicalDeck: sp.get("deck") === "clinical", } } function hasActiveUrlSearch( isDedicatedSearch: boolean, landingFilters: LibraryLandingFilterState | null, urlToolbarSearch: string, ): boolean { const text = isDedicatedSearch ? landingFilters?.hubFreeText : urlToolbarSearch return Boolean(text?.trim()) } function resolveHubHeader(folders: LibraryFolder[], navState: LibraryNavState, libraryBasePath: string) { const model = libraryHubHeaderModel(folders, navState) return { ...model, breadcrumbs: model.breadcrumbs?.map(crumb => ({ ...crumb, href: crumb.href ? libraryRouteHref(crumb.href, libraryBasePath) : crumb.href, })), } } function toggleStarred(rows: LibraryItem[], items: LibraryItem[]): LibraryItem[] { return items.map(r => (rows.some(s => s.id === r.id) ? { ...r, isStarred: !r.isStarred } : r)) } function applyFolderCustomization( folders: LibraryFolder[], targetId: string, next: Pick, ): LibraryFolder[] { return folders.map(f => f.id === targetId ? { ...f, name: next.name, icon: next.icon, colorKey: next.colorKey } : f, ) } // ── Hooks ───────────────────────────────────────────────────────────────────── /** The 2-step "Add view" creation flow. See `LibraryTable` → `HubTable`. */ function useLibraryViewCreation(opts: { tabs: ViewTab[] setTabs: LibrarySetState setActiveTabId: LibrarySetState libraryPersistKey: string }) { const { tabs, setTabs, setActiveTabId, libraryPersistKey } = opts const [creatingViewType, setCreatingViewType] = React.useState(null) const [creatingName, setCreatingName] = React.useState("") const handleRequestCreateView = React.useCallback((type: ViewType) => { setCreatingViewType(type) const def = VIEW_TYPES.find(v => v.type === type)! const existingCount = tabs.filter(t => t.viewType === type).length setCreatingName(nextViewName(def.label, existingCount)) }, [tabs]) const handleCancelCreation = React.useCallback(() => { setCreatingViewType(null) setCreatingName("") }, []) const handleCommitCreation = React.useCallback((spec: CreatedViewSpec) => { const def = VIEW_TYPES.find(v => v.type === spec.viewType)! const newTabId = `${spec.viewType}-${Date.now().toString(36)}` seedTableStateLifecycle(libraryPersistKey, newTabId, { activeFilters: spec.filters, sortRules: spec.sortRules, colOrder: spec.colOrder, hiddenCols: spec.hiddenCols, groupBy: spec.groupBy, conditionalRules: spec.conditionalRules, displayOptions: spec.displayOptions, }) const newTab: ViewTab = { id: newTabId, label: spec.name || def.label, viewType: spec.viewType, icon: def.icon, filterId: "all", } setTabs(prev => [...prev, newTab]) setActiveTabId(newTab.id) setCreatingViewType(null) setCreatingName("") }, [libraryPersistKey, setActiveTabId, setTabs]) return { creatingViewType, creatingName, setCreatingName, handleRequestCreateView, handleCancelCreation, handleCommitCreation, } } /** Keeps the URL hash and the active view tab in step with each other. */ function useLibraryHashSync(opts: { isHubPath: boolean isDedicatedSearch: boolean pathname: string searchParamsKey: string hubBasePath: string tabIds: Set activeTabId: string setActiveTabId: LibrarySetState }) { const { isHubPath, isDedicatedSearch, pathname, searchParamsKey, hubBasePath, tabIds, activeTabId, setActiveTabId } = opts const navigate = useNavigate() // Keep the latest pathname / searchParamsKey / tabIds available to the (stable) hashchange // listener via refs, so we don't re-subscribe a window listener on every URL change. const navRef = React.useRef({ pathname, searchParamsKey, tabIds, hubBasePath }) React.useEffect(() => { navRef.current = { pathname, searchParamsKey, tabIds, hubBasePath } }, [pathname, searchParamsKey, tabIds, hubBasePath]) React.useEffect(() => { if (!isHubPath || isDedicatedSearch) return const apply = () => { const current = navRef.current if (!LIBRARY_LIBRARY_HUB_PATHS.includes(current.pathname)) return const raw = currentHashTab() if (raw && current.tabIds.has(raw)) { setActiveTabId(raw) } else if (raw) { // Stale hash (tab removed) — fall back to default and strip the fragment. setActiveTabId("questions") const prefix = libraryQueryPrefixFromSearchString(current.searchParamsKey) navigate(`${current.hubBasePath}${prefix}`, { replace: true }) } // No hash: keep persisted activeTabId from localStorage. } apply() window.addEventListener("hashchange", apply) return () => window.removeEventListener("hashchange", apply) // Re-run on pathname changes (mount/unmount); URL search-param changes are read from the ref. }, [isHubPath, isDedicatedSearch, navigate, setActiveTabId]) // When the URL has no hash but a custom tab is active (restored from storage), sync the hash. React.useEffect(() => { if (!isHubPath || isDedicatedSearch) return if (!LIBRARY_LIBRARY_HUB_PATHS.includes(pathname)) return if (currentHashTab() || activeTabId === "questions") return if (!tabIds.has(activeTabId)) return const prefix = libraryQueryPrefixFromSearchString(searchParamsKey) navigate(`${hubBasePath}${prefix}#${activeTabId}`, { replace: true }) }, [ activeTabId, hubBasePath, isDedicatedSearch, isHubPath, navigate, pathname, searchParamsKey, tabIds, ]) return React.useCallback( (id: string) => { if (isDedicatedSearch) return setActiveTabId(id) if (!isHubPath) return const prefix = libraryQueryPrefixFromSearchString(searchParamsKey) const hash = id === "questions" ? "" : `#${id}` navigate(`${hubBasePath}${prefix}${hash}`, { replace: true }) }, [hubBasePath, isHubPath, isDedicatedSearch, navigate, searchParamsKey, setActiveTabId], ) } /** * Record peek rail. The open record lives in the URL so a peek is a link a * coordinator can send ("look at this one") and survives a reload. It replaces * rather than pushes: peeking down a list would otherwise bury the page the * user arrived from under a dozen history entries, and Escape or a click in * the hub is the way out, not Back. */ function useLibraryRecordPeek(opts: { items: LibraryItem[] navState: LibraryNavState urlToolbarSearchSync: string tableRef: React.RefObject }) { const { items, navState, urlToolbarSearchSync, tableRef } = opts const [searchParams, setSearchParams] = useSearchParams() const openRecordId = searchParams.get("record") const openRecord = React.useMemo( () => (openRecordId ? items.find(item => item.id === openRecordId) ?? null : null), [items, openRecordId], ) const setOpenRecord = React.useCallback( (id: string | null) => { setSearchParams( prev => { const next = new URLSearchParams(prev) if (id) next.set("record", id) else next.delete("record") return next }, { replace: true }, ) }, [setSearchParams], ) // Stepping follows what the hub is showing, not the unfiltered bank, so the // rail walks the same order the user is reading. The neighbours are resolved // from the table's visible rows after each commit; both ends leave their // handler undefined, which is what disables that chevron. const [step, setStep] = React.useState(EMPTY_STEP) React.useEffect(() => { setStep(computeRecordStep(tableRef.current?.visibleRows ?? [], openRecordId)) }, [openRecordId, items, navState, urlToolbarSearchSync, tableRef]) return { openRecordId, openRecord, setOpenRecord, step } } function useHubFolderCustomize( folders: LibraryFolder[], navState: LibraryNavState, setFolders: LibrarySetState, ) { const [sheetOpen, setSheetOpen] = React.useState(false) const [target, setTarget] = React.useState(null) const folderId = folderScopeId(navState) const openCustomize = React.useCallback(() => { const f = folderId ? folders.find(x => x.id === folderId) : undefined if (!f) return setTarget(f) setSheetOpen(true) }, [folders, folderId]) const handleOpenChange = (open: boolean) => { setSheetOpen(open) if (!open) setTarget(null) } const handleCreated = (newFolder: Pick) => { if (!target) return setFolders(prev => applyFolderCustomization(prev, target.id, newFolder)) setTarget(null) } return { sheetOpen, target, openCustomize, handleOpenChange, handleCreated } } /** New question / bulk / toolbar commands for the hub table. */ function useLibraryCommands(opts: { navState: LibraryNavState libraryBasePath: string setItems: LibrarySetState }) { const { navState, libraryBasePath, setItems } = opts const navigate = useNavigate() /** * Open the full-page authoring composer (`/library/new`). * Pre-collapses the main sidebar (Placements pattern) so the user sees one * smooth animation into the focused authoring flow. Folder scope, when * present, is forwarded as `?folderId=` so the destination dropdown lands * pre-selected on the right rail. */ const { setOpen: setMainSidebarOpen } = useSidebar() const folderQuery = newQuestionFolderQuery(navState) const handleNewQuestion = React.useCallback(() => { setMainSidebarOpen(false) window.setTimeout( () => navigate(`${libraryRouteHref("/library/new", libraryBasePath)}${folderQuery}`), 260, ) }, [libraryBasePath, folderQuery, navigate, setMainSidebarOpen]) // ── Polaris-style structured bulk actions (HubTable demo) ────────────── // Selecting one or more rows reveals the floating bulk-action bar with // Favorite + Archive buttons; `onSelect` receives the actual `LibraryItem[]`. // Esc clears the selection (handled inside `DataTable`). The bar is // `role="status"` `aria-live="polite"` so AT announces "N rows selected". const handleBulkFavorite = React.useCallback( (rows: LibraryItem[]) => { console.info("[Library] bulk favorite", rows.map(r => r.id)) setItems(prev => toggleStarred(rows, prev)) }, [setItems], ) const handleBulkArchive = React.useCallback( (rows: LibraryItem[]) => { console.info("[Library] bulk archive (demo only — no removal)", rows.map(r => r.id)) }, [], ) // Per `exxat-ux-principles.mdc` P3 the bar has no single primary action — // both Favorite and Archive render as `outline`. Archive is a soft-state // change, NOT destructive; only a real "Delete" callback would warrant // `variant: "destructive"`. Shortcuts required — see // `exxat-bulk-action-shortcuts.mdc`. const mod = useModKeyLabel() const alt = useAltKeyLabel() const bulkActions = React.useMemo[]>( () => [ { id: "favorite", label: "Favorite", icon: "fa-star", ariaLabel: "Toggle favorite on selected questions", shortcut: `${mod}${alt}F`, onSelect: handleBulkFavorite, }, { id: "archive", label: "Archive", icon: "fa-box-archive", ariaLabel: "Archive selected questions", shortcut: `${mod}${alt}A`, onSelect: handleBulkArchive, }, ], [alt, handleBulkFavorite, handleBulkArchive, mod], ) // Toolbar commands act on the hub, not on a selection, so they sit on the // toolbar row rather than in the selection bar. // // **New question** is the page's filled primary and it lives here rather than // in the header, because it is the list's own command: it lands beside Import // and one row above the questions it adds to. The header is told to drop it // (`newQuestionPlacement="toolbar"`) so the page still has exactly one primary // (P3) and the chord is bound exactly once. // // Export is deliberately absent: the header's More menu already owns it, wired // to the real `ExportDrawer`. The archive is a place you go rarely, so it // declares `overflow` and stops competing for a row slot. const toolbarActions = React.useMemo( () => [ { id: "new-question", label: "New question", icon: "fa-plus", variant: "default", shortcut: `${mod}${alt}N`, onSelect: handleNewQuestion, }, { id: "import", label: "Import", icon: "fa-file-import", shortcut: `${mod}${alt}I`, onSelect: () => { console.info("[Library] import questions (demo only)") }, }, { id: "view-archive", label: "View archive", icon: "fa-box-archive", placement: "overflow", shortcut: `${mod}${alt}R`, onSelect: () => { console.info("[Library] view archive (demo only)") }, }, ], [alt, handleNewQuestion, mod], ) return { handleNewQuestion, bulkActions, toolbarActions } } // ── Dedicated search surface ────────────────────────────────────────────────── const DEDICATED_COMPOSER_SHARED = { animatedPlaceholders: LIBRARY_DEDICATED_SEARCH_PLACEHOLDERS, animatedPlaceholderIntervalMs: 4800, animatedPlaceholderMaxLines: 2, placeholder: "Search the bank…", inputLabel: "AI search", submitAppearance: "search", submitButtonAriaLabel: "Run AI search", srOnlyDescription: ( <> Type a plain-language request, then press Enter to filter the question list. This control does not open Ask Leo. ), } as const function LibraryDedicatedComposer(props: { layout: "default" | "hero" searchParamsKey: string replacePath: string }) { return ( ) } function NoMatchesNote({ show }: { show: boolean }) { if (!show) return null return (

No questions matched that wording for this scope — showing the list without that text filter.

) } interface LibraryDedicatedSearchViewProps { folders: LibraryFolder[] setFolders: LibrarySetState items: LibraryItem[] setItems: LibrarySetState navState: LibraryNavState landingFilters: LibraryLandingFilterState | null isHubFindSurface: boolean libraryBasePath: string searchParamsKey: string showResults: boolean count: number hubTextHadNoMatches: boolean onNewQuestion: () => void exportOpen: boolean setExportOpen: (open: boolean) => void tableRef: React.RefObject persistKey: string showViewCounts: boolean setShowViewCounts: (show: boolean) => void } function LibraryDedicatedSearchResults(props: LibraryDedicatedSearchViewProps & { title: string; replacePath: string }) { return ( props.count} tablePropertiesRef={props.tableRef} header={( props.setExportOpen(true)} /> )} exportOpen={props.exportOpen} onExportOpenChange={props.setExportOpen} exportTotalRows={props.count} renderContent={(tab, updateTab) => ( updateTab({ viewType: v, icon: dataListViewIcon(v) })} viewName={tab.label} onViewNameChange={(name: string) => updateTab({ label: name })} persistKey={props.persistKey} persistTabId={tab.id} showViewCounts={props.showViewCounts} onShowViewCountsChange={props.setShowViewCounts} /> )} /> ) } function LibraryDedicatedSearchLanding(props: { isHubFindSurface: boolean searchParamsKey: string replacePath: string }) { return ( )} trailing={( )} /> ) } function LibraryDedicatedSearchView(props: LibraryDedicatedSearchViewProps) { const { isHubFindSurface, libraryBasePath } = props const title = isHubFindSurface ? "Discovery search" : "Search Questions" const replacePath = libraryRouteHref( isHubFindSurface ? LIBRARY_HUB_FIND_PATH : LIBRARY_LIST_PATH, libraryBasePath, ) return ( <> {props.showResults ? ( ) : ( )} ) } // ── Component ───────────────────────────────────────────────────────────────── export function LibraryClient() { const [searchParams] = useSearchParams() const { product, customProducts, activeCustomIndex } = useProduct() const libraryPersistKey = productPersistKey(product, "library", customProducts, activeCustomIndex) const librarySearchPersistKey = productPersistKey(product, "library:search", customProducts, activeCustomIndex) const [items, setItems] = React.useState(() => LIBRARY_ITEMS.map(q => ({ ...q }))) const [folders, setFolders] = React.useState(() => DEFAULT_LIBRARY_FOLDERS.map(f => ({ ...f }))) const canonicalLibraryNavHref = React.useCallback( (sp: URLSearchParams) => libraryCanonicalNavHref(sp, folders), [folders], ) const { navState, searchParamsKey, pathname, isHubPath, hubBasePath, libraryBasePath } = useSecondaryPanelHubNav({ hubPathname: LIBRARY_ALL_PATH, hubPathnames: LIBRARY_LIBRARY_HUB_PATHS, panelId: "library", parseNav: parseLibraryNav, canonicalHref: canonicalLibraryNavHref, shouldReopenPanel: isLibraryDefaultNav, /** Hub/find + list are full-width — layout closes the panel; do not fight it with `openPanel`. */ reopenPanelOnPathnames: REOPEN_PANEL_PATHNAMES, }) const isDedicatedSearch = isLibraryDedicatedSearchPathname(pathname) const isHubFindSurface = pathname === LIBRARY_HUB_FIND_PATH const landingFilters = React.useMemo( () => (isDedicatedSearch ? parseLandingFilters(searchParamsKey) : null), [isDedicatedSearch, searchParamsKey], ) const urlToolbarSearchSync = searchParams.get("q") ?? "" const hasUrlSearch = hasActiveUrlSearch(isDedicatedSearch, landingFilters, urlToolbarSearchSync) const [tabs, setTabs] = usePersistedState( `${libraryPersistKey}:listpage:tabs:v1`, DEFAULT_TABS, ) const [activeTabId, setActiveTabId] = usePersistedState( `${libraryPersistKey}:listpage:active-tab:v1`, DEFAULT_TABS[0].id, ) const [showViewCounts, setShowViewCounts] = React.useState(true) const creation = useLibraryViewCreation({ tabs, setTabs, setActiveTabId, libraryPersistKey }) // Stable Set of tab ids — defaults are constant so this only updates if tabs change. const tabIds = React.useMemo(() => new Set(tabs.map(t => t.id)), [tabs]) const onActiveTabChange = useLibraryHashSync({ isHubPath, isDedicatedSearch, pathname, searchParamsKey, hubBasePath, tabIds, activeTabId, setActiveTabId, }) const [exportOpen, setExportOpen] = React.useState(false) const [showMetrics, setShowMetrics] = React.useState(true) React.useLayoutEffect(() => { if (hasUrlSearch) setShowMetrics(false) }, [hasUrlSearch]) const tableRef = React.useRef(null) const peek = useLibraryRecordPeek({ items, navState, urlToolbarSearchSync, tableRef }) const folderCustomize = useHubFolderCustomize(folders, navState, setFolders) const commands = useLibraryCommands({ navState, libraryBasePath, setItems }) const filteredItems = React.useMemo( () => applyLibraryHubDisplayFilters(items, folders, navState, landingFilters), [items, folders, landingFilters, navState], ) const count = filteredItems.length const metrics = React.useMemo(() => libraryKpiMetrics(filteredItems), [filteredItems]) const activeViewType = React.useMemo( () => tabs.find(t => t.id === activeTabId)?.viewType ?? "table", [tabs, activeTabId], ) /** Dashboard view renders KPIs inside the canvas key-metrics card — hide the header strip. */ const showHeaderMetrics = showMetrics && activeViewType !== "dashboard" const hubHeader = React.useMemo( () => resolveHubHeader(folders, navState, libraryBasePath), [folders, libraryBasePath, navState], ) const hubTextHadNoMatches = React.useMemo( () => isDedicatedSearch && landingFilters != null && libraryHubTextMatchesNothing(items, folders, navState, landingFilters), [folders, isDedicatedSearch, items, landingFilters, navState], ) if (isDedicatedSearch) { return ( ) } return ( {({ collaborators, openInvite }) => ( <> )} siteHeader={{ title: hubHeader.title, breadcrumbs: hubHeader.breadcrumbs, }} > count} tablePropertiesRef={tableRef} onRequestCreateView={creation.handleRequestCreateView} showViewCounts={showViewCounts} onShowViewCountsChange={setShowViewCounts} header={( setExportOpen(true)} onAddCollaborator={openInvite} onCollaboratorsOpen={openInvite} showMetrics={showHeaderMetrics} onToggleMetrics={() => setShowMetrics(v => !v)} onCustomizeFolder={folderScopeId(navState) ? folderCustomize.openCustomize : undefined} /> )} metrics={( )} showMetrics={showHeaderMetrics} exportOpen={exportOpen} onExportOpenChange={setExportOpen} exportTotalRows={count} renderContent={(tab, updateTab) => ( updateTab({ viewType: v, icon: dataListViewIcon(v) })} viewName={tab.label} onViewNameChange={(name: string) => updateTab({ label: name })} persistKey={libraryPersistKey} persistTabId={tab.id} showViewCounts={showViewCounts} onShowViewCountsChange={setShowViewCounts} bulkActions={commands.bulkActions} toolbarActions={commands.toolbarActions} onRowClick={row => peek.setOpenRecord(row.id)} openRowId={peek.openRecordId} creatingViewType={creation.creatingViewType} creatingViewName={creation.creatingName} onCreatingViewNameChange={creation.setCreatingName} onCancelCreation={creation.handleCancelCreation} onCommitCreation={creation.handleCommitCreation} /> )} /> { if (!open) peek.setOpenRecord(null) }} onPrevious={peek.step.previous ? () => peek.setOpenRecord(peek.step.previous) : undefined} onNext={peek.step.next ? () => peek.setOpenRecord(peek.step.next) : undefined} positionLabel={peek.step.position ?? undefined} /> )} ) }