{
"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