{ "version": 3, "sources": ["../../../../src/lib/ui/components/BackToContent.tsx"], "sourcesContent": ["import { useEditor } from '@tldraw/editor'\nimport { useEffect, useState } from 'react'\nimport { useActions } from '../hooks/useActions'\nimport { Button } from './primitives/Button'\n\nexport function BackToContent() {\n\tconst editor = useEditor()\n\n\tconst actions = useActions()\n\tconst action = actions['back-to-content']\n\n\tconst [showBackToContent, setShowBackToContent] = useState(false)\n\n\tuseEffect(() => {\n\t\tlet showBackToContentPrev = false\n\n\t\tconst interval = setInterval(() => {\n\t\t\tconst { renderingShapes, renderingBounds } = editor\n\n\t\t\t// renderingShapes will also include shapes that have the canUnmount flag\n\t\t\t// set to true. These shapes will be on the canvas but may not be in the\n\t\t\t// viewport... so we also need to narrow down the list to only shapes that\n\t\t\t// are ALSO in the viewport.\n\t\t\tconst visibleShapes = renderingShapes.filter(\n\t\t\t\t(s) => s.maskedPageBounds && renderingBounds.includes(s.maskedPageBounds)\n\t\t\t)\n\t\t\tconst showBackToContentNow = visibleShapes.length === 0 && editor.currentPageShapes.length > 0\n\n\t\t\tif (showBackToContentPrev !== showBackToContentNow) {\n\t\t\t\tsetShowBackToContent(showBackToContentNow)\n\t\t\t\tshowBackToContentPrev = showBackToContentNow\n\t\t\t}\n\t\t}, 1000)\n\n\t\treturn () => {\n\t\t\tclearInterval(interval)\n\t\t}\n\t}, [editor])\n\n\tif (!showBackToContent) return null\n\n\treturn (\n\t\t {\n\t\t\t\taction.onSelect('helper-buttons')\n\t\t\t\tsetShowBackToContent(false)\n\t\t\t}}\n\t\t/>\n\t)\n}\n"], "mappings": "AA0CE;AA1CF,SAAS,iBAAiB;AAC1B,SAAS,WAAW,gBAAgB;AACpC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEhB,SAAS,gBAAgB;AAC/B,QAAM,SAAS,UAAU;AAEzB,QAAM,UAAU,WAAW;AAC3B,QAAM,SAAS,QAAQ,iBAAiB;AAExC,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,KAAK;AAEhE,YAAU,MAAM;AACf,QAAI,wBAAwB;AAE5B,UAAM,WAAW,YAAY,MAAM;AAClC,YAAM,EAAE,iBAAiB,gBAAgB,IAAI;AAM7C,YAAM,gBAAgB,gBAAgB;AAAA,QACrC,CAAC,MAAM,EAAE,oBAAoB,gBAAgB,SAAS,EAAE,gBAAgB;AAAA,MACzE;AACA,YAAM,uBAAuB,cAAc,WAAW,KAAK,OAAO,kBAAkB,SAAS;AAE7F,UAAI,0BAA0B,sBAAsB;AACnD,6BAAqB,oBAAoB;AACzC,gCAAwB;AAAA,MACzB;AAAA,IACD,GAAG,GAAI;AAEP,WAAO,MAAM;AACZ,oBAAc,QAAQ;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,MAAM,CAAC;AAEX,MAAI,CAAC;AAAmB,WAAO;AAE/B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAU,OAAO;AAAA,MACjB,OAAO,OAAO;AAAA,MACd,SAAS,MAAM;AACd,eAAO,SAAS,gBAAgB;AAChC,6BAAqB,KAAK;AAAA,MAC3B;AAAA;AAAA,EACD;AAEF;", "names": [] }