|
|
@ -1,5 +1,9 @@
|
|
|
|
import clsx from "clsx";
|
|
|
|
import clsx from "clsx";
|
|
|
|
import { DEFAULT_SIDEBAR, LIBRARY_SIDEBAR_TAB } from "../constants";
|
|
|
|
import {
|
|
|
|
|
|
|
|
CANVAS_SEARCH_TAB,
|
|
|
|
|
|
|
|
DEFAULT_SIDEBAR,
|
|
|
|
|
|
|
|
LIBRARY_SIDEBAR_TAB,
|
|
|
|
|
|
|
|
} from "../constants";
|
|
|
|
import { useTunnels } from "../context/tunnels";
|
|
|
|
import { useTunnels } from "../context/tunnels";
|
|
|
|
import { useUIAppState } from "../context/ui-appState";
|
|
|
|
import { useUIAppState } from "../context/ui-appState";
|
|
|
|
import type { MarkOptional, Merge } from "../utility-types";
|
|
|
|
import type { MarkOptional, Merge } from "../utility-types";
|
|
|
@ -10,7 +14,8 @@ import { LibraryMenu } from "./LibraryMenu";
|
|
|
|
import type { SidebarProps, SidebarTriggerProps } from "./Sidebar/common";
|
|
|
|
import type { SidebarProps, SidebarTriggerProps } from "./Sidebar/common";
|
|
|
|
import { Sidebar } from "./Sidebar/Sidebar";
|
|
|
|
import { Sidebar } from "./Sidebar/Sidebar";
|
|
|
|
import "../components/dropdownMenu/DropdownMenu.scss";
|
|
|
|
import "../components/dropdownMenu/DropdownMenu.scss";
|
|
|
|
import { t } from "../i18n";
|
|
|
|
import { SearchMenu } from "./SearchMenu";
|
|
|
|
|
|
|
|
import { LibraryIcon, searchIcon } from "./icons";
|
|
|
|
|
|
|
|
|
|
|
|
const DefaultSidebarTrigger = withInternalFallback(
|
|
|
|
const DefaultSidebarTrigger = withInternalFallback(
|
|
|
|
"DefaultSidebarTrigger",
|
|
|
|
"DefaultSidebarTrigger",
|
|
|
@ -66,16 +71,20 @@ export const DefaultSidebar = Object.assign(
|
|
|
|
|
|
|
|
|
|
|
|
const { DefaultSidebarTabTriggersTunnel } = useTunnels();
|
|
|
|
const { DefaultSidebarTabTriggersTunnel } = useTunnels();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isForceDocked = appState.openSidebar?.tab === CANVAS_SEARCH_TAB;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Sidebar
|
|
|
|
<Sidebar
|
|
|
|
{...rest}
|
|
|
|
{...rest}
|
|
|
|
name={"default"}
|
|
|
|
name={"default"}
|
|
|
|
className={clsx("default-sidebar", className)}
|
|
|
|
className={clsx("default-sidebar", className)}
|
|
|
|
docked={docked ?? appState.defaultSidebarDockedPreference}
|
|
|
|
docked={
|
|
|
|
|
|
|
|
isForceDocked || (docked ?? appState.defaultSidebarDockedPreference)
|
|
|
|
|
|
|
|
}
|
|
|
|
onDock={
|
|
|
|
onDock={
|
|
|
|
// `onDock=false` disables docking.
|
|
|
|
// `onDock=false` disables docking.
|
|
|
|
// if `docked` passed, but no onDock passed, disable manual docking.
|
|
|
|
// if `docked` passed, but no onDock passed, disable manual docking.
|
|
|
|
onDock === false || (!onDock && docked != null)
|
|
|
|
isForceDocked || onDock === false || (!onDock && docked != null)
|
|
|
|
? undefined
|
|
|
|
? undefined
|
|
|
|
: // compose to allow the host app to listen on default behavior
|
|
|
|
: // compose to allow the host app to listen on default behavior
|
|
|
|
composeEventHandlers(onDock, (docked) => {
|
|
|
|
composeEventHandlers(onDock, (docked) => {
|
|
|
@ -85,26 +94,22 @@ export const DefaultSidebar = Object.assign(
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Sidebar.Tabs>
|
|
|
|
<Sidebar.Tabs>
|
|
|
|
<Sidebar.Header>
|
|
|
|
<Sidebar.Header>
|
|
|
|
{rest.__fallback && (
|
|
|
|
<DefaultSidebar.TabTriggers>
|
|
|
|
<div
|
|
|
|
<Sidebar.TabTrigger tab={CANVAS_SEARCH_TAB}>
|
|
|
|
style={{
|
|
|
|
{searchIcon}
|
|
|
|
color: "var(--color-primary)",
|
|
|
|
</Sidebar.TabTrigger>
|
|
|
|
fontSize: "1.2em",
|
|
|
|
<Sidebar.TabTrigger tab={LIBRARY_SIDEBAR_TAB}>
|
|
|
|
fontWeight: "bold",
|
|
|
|
{LibraryIcon}
|
|
|
|
textOverflow: "ellipsis",
|
|
|
|
</Sidebar.TabTrigger>
|
|
|
|
overflow: "hidden",
|
|
|
|
</DefaultSidebar.TabTriggers>
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
{rest.__fallback && <DefaultSidebarTabTriggersTunnel.Out />}
|
|
|
|
paddingRight: "1em",
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{t("toolBar.library")}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<DefaultSidebarTabTriggersTunnel.Out />
|
|
|
|
|
|
|
|
</Sidebar.Header>
|
|
|
|
</Sidebar.Header>
|
|
|
|
<Sidebar.Tab tab={LIBRARY_SIDEBAR_TAB}>
|
|
|
|
<Sidebar.Tab tab={LIBRARY_SIDEBAR_TAB}>
|
|
|
|
<LibraryMenu />
|
|
|
|
<LibraryMenu />
|
|
|
|
</Sidebar.Tab>
|
|
|
|
</Sidebar.Tab>
|
|
|
|
|
|
|
|
<Sidebar.Tab tab={CANVAS_SEARCH_TAB}>
|
|
|
|
|
|
|
|
<SearchMenu />
|
|
|
|
|
|
|
|
</Sidebar.Tab>
|
|
|
|
{children}
|
|
|
|
{children}
|
|
|
|
</Sidebar.Tabs>
|
|
|
|
</Sidebar.Tabs>
|
|
|
|
</Sidebar>
|
|
|
|
</Sidebar>
|
|
|
|