{ "version": 3, "sources": ["../../../src/lib/ui/TldrawUi.tsx"], "sourcesContent": ["import { ToastProvider } from '@radix-ui/react-toast'\nimport { useEditor, useValue } from '@tldraw/editor'\nimport classNames from 'classnames'\nimport React, { ReactNode } from 'react'\nimport { TldrawUiContextProvider, TldrawUiContextProviderProps } from './TldrawUiContextProvider'\nimport { BackToContent } from './components/BackToContent'\nimport { DebugPanel } from './components/DebugPanel'\nimport { Dialogs } from './components/Dialogs'\nimport { FollowingIndicator } from './components/FollowingIndicator'\nimport { HelpMenu } from './components/HelpMenu'\nimport { MenuZone } from './components/MenuZone'\nimport { NavigationZone } from './components/NavigationZone/NavigationZone'\nimport { ExitPenMode } from './components/PenModeToggle'\nimport { StopFollowing } from './components/StopFollowing'\nimport { StylePanel } from './components/StylePanel/StylePanel'\nimport { ToastViewport, Toasts } from './components/Toasts'\nimport { Toolbar } from './components/Toolbar/Toolbar'\nimport { Button } from './components/primitives/Button'\nimport { useActions } from './hooks/useActions'\nimport { useBreakpoint } from './hooks/useBreakpoint'\nimport { useNativeClipboardEvents } from './hooks/useClipboardEvents'\nimport { useEditorEvents } from './hooks/useEditorEvents'\nimport { useKeyboardShortcuts } from './hooks/useKeyboardShortcuts'\nimport { useTranslation } from './hooks/useTranslation/useTranslation'\n\n/**\n * Props for the {@link @tldraw/tldraw#Tldraw} and {@link TldrawUi} components.\n *\n * @public\n */\nexport type TldrawUiProps = TldrawUiBaseProps & TldrawUiContextProviderProps\n\n/**\n * Base props for the {@link @tldraw/tldraw#Tldraw} and {@link TldrawUi} components.\n *\n * @public\n */\nexport interface TldrawUiBaseProps {\n\t/**\n\t * The component's children.\n\t */\n\tchildren?: ReactNode\n\n\t/**\n\t * Whether to hide the user interface and only display the canvas.\n\t */\n\thideUi?: boolean\n\n\t/**\n\t * A component to use for the share zone (will be deprecated)\n\t */\n\tshareZone?: ReactNode\n\n\t/**\n\t * A component to use for the top zone (will be deprecated)\n\t * @internal\n\t */\n\ttopZone?: ReactNode\n\n\t/**\n\t * Additional items to add to the debug menu (will be deprecated)\n\t */\n\trenderDebugMenuItems?: () => React.ReactNode\n}\n\n/**\n * @public\n */\nexport const TldrawUi = React.memo(function TldrawUi({\n\tshareZone,\n\ttopZone,\n\trenderDebugMenuItems,\n\tchildren,\n\thideUi,\n\t...rest\n}: TldrawUiProps) {\n\treturn (\n\t\t\n\t\t\t\n\t\t\t\t{children}\n\t\t\t\n\t\t\n\t)\n})\n\ntype TldrawUiContentProps = {\n\thideUi?: boolean\n\tshareZone?: ReactNode\n\ttopZone?: ReactNode\n\trenderDebugMenuItems?: () => React.ReactNode\n}\n\nconst TldrawUiInner = React.memo(function TldrawUiInner({\n\tchildren,\n\thideUi,\n\t...rest\n}: TldrawUiContentProps & { children: ReactNode }) {\n\t// The hideUi prop should prevent the UI from mounting.\n\t// If we ever need want the UI to mount and preserve state, then\n\t// we should change this behavior and hide the UI via CSS instead.\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t{hideUi ? null : }\n\t\t\n\t)\n})\n\nconst TldrawUiContent = React.memo(function TldrawUI({\n\tshareZone,\n\ttopZone,\n\trenderDebugMenuItems,\n}: TldrawUiContentProps) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst breakpoint = useBreakpoint()\n\tconst isReadonlyMode = useValue('isReadonlyMode', () => editor.instanceState.isReadonly, [editor])\n\tconst isFocusMode = useValue('focus', () => editor.instanceState.isFocusMode, [editor])\n\tconst isDebugMode = useValue('debug', () => editor.instanceState.isDebugMode, [editor])\n\n\tuseKeyboardShortcuts()\n\tuseNativeClipboardEvents()\n\tuseEditorEvents()\n\n\tconst { 'toggle-focus-mode': toggleFocus } = useActions()\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\t\t{isFocusMode ? (\n\t\t\t\t\t
\n\t\t\t\t\t\t toggleFocus.onSelect('menu')}\n\t\t\t\t\t\t/>\n\t\t\t\t\t
\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t
\n\t\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