@tldiagram/core-ui 1.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/dist/App.d.ts +1 -0
  2. package/dist/api/client.d.ts +143 -0
  3. package/dist/api/transport-vscode.d.ts +8 -0
  4. package/dist/api/transport.d.ts +1 -0
  5. package/dist/components/CodePreviewPanel-vscode.d.ts +7 -0
  6. package/dist/components/CodePreviewPanel.d.ts +9 -0
  7. package/dist/components/ConfirmDialog.d.ts +12 -0
  8. package/dist/components/ConnectorPanel.d.ts +21 -0
  9. package/dist/components/ContextBoundaryElement.d.ts +11 -0
  10. package/dist/components/ContextNeighborElement.d.ts +29 -0
  11. package/dist/components/ContextStraightConnector.d.ts +4 -0
  12. package/dist/components/CrossBranchControls.d.ts +9 -0
  13. package/dist/components/DependenciesOnboarding.d.ts +5 -0
  14. package/dist/components/DrawingCanvas.d.ts +39 -0
  15. package/dist/components/ElementLibrary-vscode.d.ts +7 -0
  16. package/dist/components/ElementLibrary.d.ts +22 -0
  17. package/dist/components/ElementNode.d.ts +36 -0
  18. package/dist/components/ElementPanel.d.ts +25 -0
  19. package/dist/components/ExploreOnboarding.d.ts +5 -0
  20. package/dist/components/ExplorePageOnboarding.d.ts +5 -0
  21. package/dist/components/ExportModal.d.ts +16 -0
  22. package/dist/components/FloatingEdge.d.ts +9 -0
  23. package/dist/components/GitSourceLinker.d.ts +8 -0
  24. package/dist/components/HeaderContext.d.ts +16 -0
  25. package/dist/components/Icons.d.ts +95 -0
  26. package/dist/components/ImportModal.d.ts +10 -0
  27. package/dist/components/InlineElementAdder.d.ts +17 -0
  28. package/dist/components/LayoutSection.d.ts +7 -0
  29. package/dist/components/LocalSourceLinker.d.ts +8 -0
  30. package/dist/components/MiniZoomOnboarding.d.ts +5 -0
  31. package/dist/components/NavBreadcrumb.d.ts +6 -0
  32. package/dist/components/NodeBody.d.ts +12 -0
  33. package/dist/components/NodeContainer.d.ts +8 -0
  34. package/dist/components/NodeHoverCard.d.ts +10 -0
  35. package/dist/components/PanelHeader.d.ts +8 -0
  36. package/dist/components/PanelUI.d.ts +3 -0
  37. package/dist/components/ProxyConnectorEdge.d.ts +4 -0
  38. package/dist/components/ProxyConnectorPanel.d.ts +9 -0
  39. package/dist/components/SafeBackground.d.ts +13 -0
  40. package/dist/components/ScrollIndicatorWrapper.d.ts +8 -0
  41. package/dist/components/SetChildModal.d.ts +10 -0
  42. package/dist/components/SetParentModal.d.ts +10 -0
  43. package/dist/components/SlidingPanel.d.ts +16 -0
  44. package/dist/components/TagUpsert.d.ts +8 -0
  45. package/dist/components/TopMenuBar.d.ts +8 -0
  46. package/dist/components/ViewBezierConnector.d.ts +4 -0
  47. package/dist/components/ViewDrawMenu.d.ts +22 -0
  48. package/dist/components/ViewEditorEdgeLabelLayout.d.ts +16 -0
  49. package/dist/components/ViewEditorOnboarding.d.ts +5 -0
  50. package/dist/components/ViewExplorer/TagManager/ColorPicker.d.ts +7 -0
  51. package/dist/components/ViewExplorer/TagManager/GroupNamingPopover.d.ts +10 -0
  52. package/dist/components/ViewExplorer/TagManager/LayerItem.d.ts +27 -0
  53. package/dist/components/ViewExplorer/TagManager/TagItem.d.ts +25 -0
  54. package/dist/components/ViewExplorer/TagManager/index.d.ts +21 -0
  55. package/dist/components/ViewExplorer/ViewNavigator.d.ts +11 -0
  56. package/dist/components/ViewExplorer/ViewSearch.d.ts +8 -0
  57. package/dist/components/ViewExplorer/ViewTree.d.ts +18 -0
  58. package/dist/components/ViewExplorer/index.d.ts +31 -0
  59. package/dist/components/ViewExplorer/types.d.ts +11 -0
  60. package/dist/components/ViewExplorer/utils.d.ts +6 -0
  61. package/dist/components/ViewExplorer-vscode.d.ts +6 -0
  62. package/dist/components/ViewFloatingMenu-vscode.d.ts +27 -0
  63. package/dist/components/ViewFloatingMenu.d.ts +39 -0
  64. package/dist/components/ViewGridNode.d.ts +29 -0
  65. package/dist/components/ViewHeaderButton.d.ts +11 -0
  66. package/dist/components/ViewPanel.d.ts +18 -0
  67. package/dist/components/ViewsGridOnboarding.d.ts +5 -0
  68. package/dist/components/ZUI/ZUICanvas.d.ts +18 -0
  69. package/dist/components/ZUI/index.d.ts +2 -0
  70. package/dist/components/ZUI/layout.d.ts +18 -0
  71. package/dist/components/ZUI/proxy.d.ts +25 -0
  72. package/dist/components/ZUI/renderer.d.ts +30 -0
  73. package/dist/components/ZUI/types.d.ts +140 -0
  74. package/dist/components/ZUI/useZUIInteraction.d.ts +21 -0
  75. package/dist/config/runtime-vscode.d.ts +22 -0
  76. package/dist/config/runtime.d.ts +5 -0
  77. package/dist/constants/colors.d.ts +27 -0
  78. package/dist/constants/diagramColors.d.ts +1 -0
  79. package/dist/context/ThemeContext.d.ts +27 -0
  80. package/dist/crossBranch/graph.d.ts +13 -0
  81. package/dist/crossBranch/resolve.d.ts +22 -0
  82. package/dist/crossBranch/settings.d.ts +6 -0
  83. package/dist/crossBranch/store.d.ts +11 -0
  84. package/dist/crossBranch/types.d.ts +96 -0
  85. package/dist/demo/DemoPage.d.ts +9 -0
  86. package/dist/demo/seed.d.ts +9 -0
  87. package/dist/demo/store.d.ts +137 -0
  88. package/dist/demo/viewEditor.d.ts +26 -0
  89. package/dist/favicon.svg +35 -0
  90. package/dist/hooks/useSafeFitView.d.ts +16 -0
  91. package/dist/index.css +1 -0
  92. package/dist/index.d.ts +115 -0
  93. package/dist/index.js +19966 -0
  94. package/dist/lib/vscodeBridge-vscode.d.ts +13 -0
  95. package/dist/lib/vscodeBridge.d.ts +5 -0
  96. package/dist/logo-120.png +0 -0
  97. package/dist/logo-bw.png +0 -0
  98. package/dist/logo-bw.svg +15 -0
  99. package/dist/logo-text.svg +51 -0
  100. package/dist/logo.svg +35 -0
  101. package/dist/pages/AppearanceSettings.d.ts +3 -0
  102. package/dist/pages/Dependencies.d.ts +1 -0
  103. package/dist/pages/InfiniteZoom.d.ts +7 -0
  104. package/dist/pages/Settings.d.ts +7 -0
  105. package/dist/pages/ViewEditor/components/EditorMenus.d.ts +24 -0
  106. package/dist/pages/ViewEditor/components/EditorOverlays.d.ts +30 -0
  107. package/dist/pages/ViewEditor/components/EmptyCanvasState.d.ts +7 -0
  108. package/dist/pages/ViewEditor/context.d.ts +13 -0
  109. package/dist/pages/ViewEditor/hooks/useCanvasInteractions.d.ts +201 -0
  110. package/dist/pages/ViewEditor/hooks/useDrawingEngine.d.ts +40 -0
  111. package/dist/pages/ViewEditor/hooks/useViewContextNeighbours.d.ts +20 -0
  112. package/dist/pages/ViewEditor/hooks/useViewData.d.ts +74 -0
  113. package/dist/pages/ViewEditor/index.d.ts +8 -0
  114. package/dist/pages/ViewEditor/utils.d.ts +14 -0
  115. package/dist/pages/Views.d.ts +6 -0
  116. package/dist/pages/ViewsGrid.d.ts +6 -0
  117. package/dist/pkg/importer/mermaid.d.ts +7 -0
  118. package/dist/pkg/importer/mermaid.test.d.ts +1 -0
  119. package/dist/platform/PlatformContext.d.ts +6 -0
  120. package/dist/platform/context.d.ts +3 -0
  121. package/dist/platform/local.d.ts +2 -0
  122. package/dist/platform/types.d.ts +17 -0
  123. package/dist/slots.d.ts +67 -0
  124. package/dist/theme.d.ts +2 -0
  125. package/dist/types/index.d.ts +193 -0
  126. package/dist/types/vscode-messages.d.ts +60 -0
  127. package/dist/utils/edgeDistribution.d.ts +34 -0
  128. package/dist/utils/githubApi.d.ts +4 -0
  129. package/dist/utils/githubCache.d.ts +17 -0
  130. package/dist/utils/ids.d.ts +2 -0
  131. package/dist/utils/technologyCatalog.d.ts +15 -0
  132. package/dist/utils/toast.d.ts +15 -0
  133. package/dist/utils/treesitter.d.ts +13 -0
  134. package/dist/utils/url.d.ts +12 -0
  135. package/package.json +159 -0
  136. package/src/App.tsx +141 -0
  137. package/src/api/client.ts +618 -0
  138. package/src/api/transport-vscode.ts +28 -0
  139. package/src/api/transport.ts +7 -0
  140. package/src/assets/logo-mark.svg +31 -0
  141. package/src/assets/logo-wordmark.svg +22 -0
  142. package/src/assets/logo.svg +35 -0
  143. package/src/components/CodePreviewPanel-vscode.tsx +85 -0
  144. package/src/components/CodePreviewPanel.tsx +384 -0
  145. package/src/components/ConfirmDialog.tsx +66 -0
  146. package/src/components/ConnectorPanel.tsx +403 -0
  147. package/src/components/ContextBoundaryElement.tsx +35 -0
  148. package/src/components/ContextNeighborElement.tsx +282 -0
  149. package/src/components/ContextStraightConnector.tsx +144 -0
  150. package/src/components/CrossBranchControls.tsx +105 -0
  151. package/src/components/DependenciesOnboarding.tsx +427 -0
  152. package/src/components/DrawingCanvas.tsx +391 -0
  153. package/src/components/ElementLibrary-vscode.tsx +9 -0
  154. package/src/components/ElementLibrary.tsx +512 -0
  155. package/src/components/ElementNode.tsx +1033 -0
  156. package/src/components/ElementPanel.tsx +928 -0
  157. package/src/components/ExploreOnboarding.tsx +347 -0
  158. package/src/components/ExplorePageOnboarding.tsx +383 -0
  159. package/src/components/ExportModal.tsx +132 -0
  160. package/src/components/FloatingEdge.tsx +115 -0
  161. package/src/components/GitSourceLinker.tsx +1053 -0
  162. package/src/components/HeaderContext.tsx +30 -0
  163. package/src/components/Icons.tsx +245 -0
  164. package/src/components/ImportModal.tsx +219 -0
  165. package/src/components/InlineElementAdder.tsx +216 -0
  166. package/src/components/LayoutSection.tsx +624 -0
  167. package/src/components/LocalSourceLinker.tsx +330 -0
  168. package/src/components/MiniZoomOnboarding.tsx +78 -0
  169. package/src/components/NavBreadcrumb.tsx +24 -0
  170. package/src/components/NodeBody.tsx +89 -0
  171. package/src/components/NodeContainer.tsx +58 -0
  172. package/src/components/NodeHoverCard.tsx +135 -0
  173. package/src/components/PanelHeader.tsx +36 -0
  174. package/src/components/PanelUI.tsx +24 -0
  175. package/src/components/ProxyConnectorEdge.tsx +169 -0
  176. package/src/components/ProxyConnectorPanel.tsx +130 -0
  177. package/src/components/SafeBackground.tsx +19 -0
  178. package/src/components/ScrollIndicatorWrapper.tsx +117 -0
  179. package/src/components/SetChildModal.tsx +191 -0
  180. package/src/components/SetParentModal.tsx +187 -0
  181. package/src/components/SlidingPanel.tsx +114 -0
  182. package/src/components/TagUpsert.tsx +142 -0
  183. package/src/components/TopMenuBar.tsx +380 -0
  184. package/src/components/ViewBezierConnector.tsx +143 -0
  185. package/src/components/ViewDrawMenu.tsx +270 -0
  186. package/src/components/ViewEditorEdgeLabelLayout.ts +189 -0
  187. package/src/components/ViewEditorOnboarding.tsx +445 -0
  188. package/src/components/ViewExplorer/TagManager/ColorPicker.tsx +49 -0
  189. package/src/components/ViewExplorer/TagManager/GroupNamingPopover.tsx +96 -0
  190. package/src/components/ViewExplorer/TagManager/LayerItem.tsx +228 -0
  191. package/src/components/ViewExplorer/TagManager/TagItem.tsx +242 -0
  192. package/src/components/ViewExplorer/TagManager/index.tsx +418 -0
  193. package/src/components/ViewExplorer/ViewNavigator.tsx +121 -0
  194. package/src/components/ViewExplorer/ViewSearch.tsx +33 -0
  195. package/src/components/ViewExplorer/ViewTree.tsx +98 -0
  196. package/src/components/ViewExplorer/index.tsx +384 -0
  197. package/src/components/ViewExplorer/types.ts +13 -0
  198. package/src/components/ViewExplorer/utils.ts +56 -0
  199. package/src/components/ViewExplorer-vscode.tsx +8 -0
  200. package/src/components/ViewFloatingMenu-vscode.tsx +248 -0
  201. package/src/components/ViewFloatingMenu.tsx +379 -0
  202. package/src/components/ViewGridNode.tsx +451 -0
  203. package/src/components/ViewHeaderButton.tsx +60 -0
  204. package/src/components/ViewPanel.tsx +162 -0
  205. package/src/components/ViewsGridOnboarding.tsx +400 -0
  206. package/src/components/ZUI/ZUICanvas.tsx +853 -0
  207. package/src/components/ZUI/index.ts +3 -0
  208. package/src/components/ZUI/layout.ts +323 -0
  209. package/src/components/ZUI/proxy.ts +278 -0
  210. package/src/components/ZUI/renderer.ts +1189 -0
  211. package/src/components/ZUI/types.ts +150 -0
  212. package/src/components/ZUI/useZUIInteraction.ts +720 -0
  213. package/src/config/runtime-vscode.ts +46 -0
  214. package/src/config/runtime.ts +30 -0
  215. package/src/constants/colors.ts +80 -0
  216. package/src/constants/diagramColors.ts +9 -0
  217. package/src/context/ThemeContext.tsx +158 -0
  218. package/src/crossBranch/graph.ts +207 -0
  219. package/src/crossBranch/resolve.ts +643 -0
  220. package/src/crossBranch/settings.ts +59 -0
  221. package/src/crossBranch/store.ts +71 -0
  222. package/src/crossBranch/types.ts +102 -0
  223. package/src/demo/DemoPage.tsx +184 -0
  224. package/src/demo/seed.ts +67 -0
  225. package/src/demo/store.ts +536 -0
  226. package/src/demo/viewEditor.ts +110 -0
  227. package/src/hooks/useSafeFitView.ts +60 -0
  228. package/src/index.css +309 -0
  229. package/src/index.ts +184 -0
  230. package/src/kafka-ss.png +0 -0
  231. package/src/lib/vscodeBridge-vscode.ts +27 -0
  232. package/src/lib/vscodeBridge.ts +7 -0
  233. package/src/main.tsx +46 -0
  234. package/src/pages/AppearanceSettings.tsx +135 -0
  235. package/src/pages/Dependencies.tsx +926 -0
  236. package/src/pages/InfiniteZoom.tsx +404 -0
  237. package/src/pages/Settings.tsx +91 -0
  238. package/src/pages/ViewEditor/EDGE_DISTRIBUTION.md +64 -0
  239. package/src/pages/ViewEditor/components/EditorMenus.tsx +112 -0
  240. package/src/pages/ViewEditor/components/EditorOverlays.tsx +172 -0
  241. package/src/pages/ViewEditor/components/EmptyCanvasState.tsx +42 -0
  242. package/src/pages/ViewEditor/context.tsx +21 -0
  243. package/src/pages/ViewEditor/hooks/useCanvasInteractions.ts +1349 -0
  244. package/src/pages/ViewEditor/hooks/useDrawingEngine.ts +127 -0
  245. package/src/pages/ViewEditor/hooks/useViewContextNeighbours.ts +501 -0
  246. package/src/pages/ViewEditor/hooks/useViewData.ts +491 -0
  247. package/src/pages/ViewEditor/index.tsx +1366 -0
  248. package/src/pages/ViewEditor/utils.ts +88 -0
  249. package/src/pages/Views.tsx +171 -0
  250. package/src/pages/ViewsGrid.tsx +1310 -0
  251. package/src/pkg/importer/mermaid.test.ts +141 -0
  252. package/src/pkg/importer/mermaid.ts +76 -0
  253. package/src/platform/PlatformContext.tsx +17 -0
  254. package/src/platform/context.ts +9 -0
  255. package/src/platform/local.tsx +15 -0
  256. package/src/platform/types.ts +19 -0
  257. package/src/slots.ts +92 -0
  258. package/src/styles/editor-panels.css +66 -0
  259. package/src/styles/theme.css +56 -0
  260. package/src/theme.ts +336 -0
  261. package/src/types/index.ts +234 -0
  262. package/src/types/offline-ambient.d.ts +14 -0
  263. package/src/types/vscode-messages.ts +32 -0
  264. package/src/utils/edgeDistribution.ts +103 -0
  265. package/src/utils/githubApi.ts +121 -0
  266. package/src/utils/githubCache.ts +108 -0
  267. package/src/utils/ids.ts +9 -0
  268. package/src/utils/technologyCatalog.ts +143 -0
  269. package/src/utils/toast.ts +100 -0
  270. package/src/utils/treesitter.ts +147 -0
  271. package/src/utils/url.ts +72 -0
  272. package/src/vite-env.d.ts +1 -0
@@ -0,0 +1,88 @@
1
+ import type { Connector } from '../../types'
2
+ import type { Node as RFNode } from 'reactflow'
3
+
4
+ // ── Domain-model conversion ────────────────────────────────────────────────
5
+
6
+ /** Pass-through: the API already returns Connector in the canonical shape. */
7
+ export function connectorToConnector(connector: Connector): Connector {
8
+ return connector
9
+ }
10
+
11
+ // ── Handle geometry ────────────────────────────────────────────────────────
12
+
13
+ export function findClosestHandles(
14
+ sourceNode: RFNode,
15
+ targetNode: RFNode,
16
+ ): { sourceHandle: string; targetHandle: string } {
17
+ const w1 = sourceNode.width ?? 180
18
+ const h1 = sourceNode.height ?? 80
19
+ const w2 = targetNode.width ?? 180
20
+ const h2 = targetNode.height ?? 80
21
+ const sp = sourceNode.position
22
+ const tp = targetNode.position
23
+
24
+ const srcHandles: [string, number, number][] = [
25
+ ['top', sp.x + w1 / 2, sp.y],
26
+ ['bottom', sp.x + w1 / 2, sp.y + h1],
27
+ ['left', sp.x, sp.y + h1 / 2],
28
+ ['right', sp.x + w1, sp.y + h1 / 2],
29
+ ]
30
+ const tgtHandles: [string, number, number][] = [
31
+ ['top', tp.x + w2 / 2, tp.y],
32
+ ['bottom', tp.x + w2 / 2, tp.y + h2],
33
+ ['left', tp.x, tp.y + h2 / 2],
34
+ ['right', tp.x + w2, tp.y + h2 / 2],
35
+ ]
36
+
37
+ let minDist = Infinity
38
+ let bestSrc = 'right'
39
+ let bestTgt = 'left'
40
+ for (const [sid, sx, sy] of srcHandles) {
41
+ for (const [tid, tx, ty] of tgtHandles) {
42
+ const d = Math.hypot(tx - sx, ty - sy)
43
+ if (d < minDist) { minDist = d; bestSrc = sid; bestTgt = tid }
44
+ }
45
+ }
46
+ return { sourceHandle: bestSrc, targetHandle: bestTgt }
47
+ }
48
+
49
+ export function findClosestHandleToPoint(
50
+ sourceNode: RFNode,
51
+ tx: number,
52
+ ty: number,
53
+ ): { sourceHandle: string; targetHandle: string } {
54
+ const w = sourceNode.width ?? 180
55
+ const h = sourceNode.height ?? 80
56
+ const sp = sourceNode.position
57
+ const handles: [string, number, number][] = [
58
+ ['top', sp.x + w / 2, sp.y],
59
+ ['bottom', sp.x + w / 2, sp.y + h],
60
+ ['left', sp.x, sp.y + h / 2],
61
+ ['right', sp.x + w, sp.y + h / 2],
62
+ ]
63
+ let minDist = Infinity
64
+ let bestSrc = 'right'
65
+ for (const [sid, sx, sy] of handles) {
66
+ const d = Math.hypot(tx - sx, ty - sy)
67
+ if (d < minDist) { minDist = d; bestSrc = sid }
68
+ }
69
+ const opp: Record<string, string> = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' }
70
+ return { sourceHandle: bestSrc, targetHandle: opp[bestSrc] ?? 'left' }
71
+ }
72
+
73
+ // ── Export helpers ─────────────────────────────────────────────────────────
74
+
75
+ export function sanitizeExportFilename(value: string) {
76
+ const trimmed = value.trim()
77
+ if (!trimmed) return 'view-export'
78
+ return trimmed.replace(/[\\/:*?"<>|]+/g, '-').replace(/\s+/g, ' ')
79
+ }
80
+
81
+ export function triggerDownload(dataUrl: string, filename: string) {
82
+ const link = document.createElement('a')
83
+ link.href = dataUrl
84
+ link.download = filename
85
+ document.body.appendChild(link)
86
+ link.click()
87
+ document.body.removeChild(link)
88
+ }
@@ -0,0 +1,171 @@
1
+ import { useState, useEffect, useCallback } from 'react'
2
+ import { useSearchParams } from 'react-router-dom'
3
+ import { Box, Flex, Button, Text, Spinner, Center } from '@chakra-ui/react'
4
+ import { motion, AnimatePresence } from 'framer-motion'
5
+ import ViewsGrid from './ViewsGrid'
6
+ import InfiniteZoom from './InfiniteZoom'
7
+ import { api } from '../api/client'
8
+
9
+ interface Props {
10
+ shareSlot?: React.ReactNode
11
+ onShareView?: (viewId: number) => void
12
+ }
13
+
14
+ type ViewType = 'explore' | 'hierarchy'
15
+
16
+ const MotionBox = motion.create(Box)
17
+
18
+ export default function ViewsPage({ shareSlot, onShareView }: Props) {
19
+ const [searchParams, setSearchParams] = useSearchParams()
20
+ const requestedView = searchParams.get('view')
21
+ const initialView: ViewType = requestedView === 'edit' ? 'hierarchy' : ((requestedView as ViewType) || 'explore')
22
+ const [view, setView] = useState<ViewType>(initialView)
23
+ const [initializing, setInitializing] = useState(true)
24
+
25
+ const handleViewChange = useCallback((newView: ViewType) => {
26
+ setView(newView)
27
+ const newParams = new URLSearchParams(searchParams)
28
+ newParams.set('view', newView)
29
+ setSearchParams(newParams, { replace: true })
30
+ }, [searchParams, setSearchParams])
31
+
32
+ // Sync state with search params
33
+ useEffect(() => {
34
+ const v = searchParams.get('view')
35
+ if (v === 'explore' || v === 'hierarchy') {
36
+ setView(v)
37
+ }
38
+ if (v === 'edit') {
39
+ setView('hierarchy')
40
+ }
41
+ }, [searchParams])
42
+
43
+ useEffect(() => {
44
+ let mounted = true
45
+ api.workspace.views.tree()
46
+ .then((tree) => {
47
+ if (!mounted) return
48
+ if (!tree || tree.length === 0) {
49
+ // Only auto-switch to edit if no view is explicitly set in URL
50
+ if (!searchParams.get('view')) {
51
+ handleViewChange('hierarchy')
52
+ }
53
+ }
54
+ })
55
+ .catch(() => {
56
+ // Fallback to explore on error
57
+ })
58
+ .finally(() => {
59
+ if (mounted) setInitializing(false)
60
+ })
61
+ return () => { mounted = false }
62
+ }, [searchParams, handleViewChange])
63
+
64
+ // Colors for the switch
65
+ const bgColor = 'var(--bg)'
66
+ const activeColor = 'clay.bg'
67
+ const inactiveColor = 'gray.400'
68
+
69
+ if (initializing) {
70
+ return (
71
+ <Center h="full">
72
+ <Spinner size="xl" color="var(--accent)" />
73
+ </Center>
74
+ )
75
+ }
76
+
77
+ return (
78
+ <Box position="relative" w="full" h="full" overflow="hidden">
79
+ {/* Floating Switch */}
80
+ <Flex
81
+ position="absolute"
82
+ top={4}
83
+ left="50%"
84
+ transform="translateX(-50%)"
85
+ zIndex={1000}
86
+ bg={bgColor}
87
+ backdropFilter="blur(12px)"
88
+ border="1px solid"
89
+ borderColor="whiteAlpha.100"
90
+ borderRadius="full"
91
+ p={1}
92
+ gap={1}
93
+ boxShadow="0 4px 20px rgba(0, 0, 0, 0.4)"
94
+ >
95
+ <Button
96
+ size="sm"
97
+ variant="ghost"
98
+ borderRadius="full"
99
+ position="relative"
100
+ px={6}
101
+ h="32px"
102
+ onClick={() => handleViewChange('explore')}
103
+ _hover={{ bg: 'transparent' }}
104
+ _active={{ bg: 'transparent' }}
105
+ color={view === 'explore' ? 'white' : inactiveColor}
106
+ transition="color 0.2s"
107
+ >
108
+ {view === 'explore' && (
109
+ <MotionBox
110
+ layoutId="active-pill"
111
+ position="absolute"
112
+ inset={0}
113
+ bg={activeColor}
114
+ borderRadius="full"
115
+ zIndex={-1}
116
+ transition={{ type: 'spring', bounce: 0.2, duration: 0.6 }}
117
+ />
118
+ )}
119
+ <Text fontSize="xs" fontWeight="bold" zIndex={1}>Explore</Text>
120
+ </Button>
121
+ <Button
122
+ size="sm"
123
+ variant="ghost"
124
+ borderRadius="full"
125
+ position="relative"
126
+ px={6}
127
+ h="32px"
128
+ onClick={() => handleViewChange('hierarchy')}
129
+ _hover={{ bg: 'transparent' }}
130
+ _active={{
131
+ bg: 'transparent'
132
+ }}
133
+ color={view === 'hierarchy' ? 'white' : inactiveColor}
134
+ transition="color 0.2s"
135
+ >
136
+ {view === 'hierarchy' && (
137
+ <MotionBox
138
+ layoutId="active-pill"
139
+ position="absolute"
140
+ inset={0}
141
+ bg={activeColor}
142
+ borderRadius="full"
143
+ zIndex={-1}
144
+ transition={{ type: 'spring', bounce: 0.2, duration: 0.6 }}
145
+ />
146
+ )}
147
+ <Text fontSize="xs" fontWeight="bold" zIndex={1}>Hierarchy</Text>
148
+ </Button>
149
+ </Flex>
150
+
151
+ {/* Page Content */}
152
+ <AnimatePresence mode="wait">
153
+ <MotionBox
154
+ key={view}
155
+ initial={{ opacity: 0, scale: 0.98 }}
156
+ animate={{ opacity: 1, scale: 1 }}
157
+ exit={{ opacity: 0, scale: 1.02 }}
158
+ transition={{ duration: 0.3, ease: 'easeInOut' }}
159
+ w="full"
160
+ h="full"
161
+ >
162
+ {view === 'explore' ? (
163
+ <InfiniteZoom shareSlot={shareSlot} />
164
+ ) : (
165
+ <ViewsGrid onShare={onShareView} />
166
+ )}
167
+ </MotionBox>
168
+ </AnimatePresence>
169
+ </Box>
170
+ )
171
+ }