@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.
- package/dist/App.d.ts +1 -0
- package/dist/api/client.d.ts +143 -0
- package/dist/api/transport-vscode.d.ts +8 -0
- package/dist/api/transport.d.ts +1 -0
- package/dist/components/CodePreviewPanel-vscode.d.ts +7 -0
- package/dist/components/CodePreviewPanel.d.ts +9 -0
- package/dist/components/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConnectorPanel.d.ts +21 -0
- package/dist/components/ContextBoundaryElement.d.ts +11 -0
- package/dist/components/ContextNeighborElement.d.ts +29 -0
- package/dist/components/ContextStraightConnector.d.ts +4 -0
- package/dist/components/CrossBranchControls.d.ts +9 -0
- package/dist/components/DependenciesOnboarding.d.ts +5 -0
- package/dist/components/DrawingCanvas.d.ts +39 -0
- package/dist/components/ElementLibrary-vscode.d.ts +7 -0
- package/dist/components/ElementLibrary.d.ts +22 -0
- package/dist/components/ElementNode.d.ts +36 -0
- package/dist/components/ElementPanel.d.ts +25 -0
- package/dist/components/ExploreOnboarding.d.ts +5 -0
- package/dist/components/ExplorePageOnboarding.d.ts +5 -0
- package/dist/components/ExportModal.d.ts +16 -0
- package/dist/components/FloatingEdge.d.ts +9 -0
- package/dist/components/GitSourceLinker.d.ts +8 -0
- package/dist/components/HeaderContext.d.ts +16 -0
- package/dist/components/Icons.d.ts +95 -0
- package/dist/components/ImportModal.d.ts +10 -0
- package/dist/components/InlineElementAdder.d.ts +17 -0
- package/dist/components/LayoutSection.d.ts +7 -0
- package/dist/components/LocalSourceLinker.d.ts +8 -0
- package/dist/components/MiniZoomOnboarding.d.ts +5 -0
- package/dist/components/NavBreadcrumb.d.ts +6 -0
- package/dist/components/NodeBody.d.ts +12 -0
- package/dist/components/NodeContainer.d.ts +8 -0
- package/dist/components/NodeHoverCard.d.ts +10 -0
- package/dist/components/PanelHeader.d.ts +8 -0
- package/dist/components/PanelUI.d.ts +3 -0
- package/dist/components/ProxyConnectorEdge.d.ts +4 -0
- package/dist/components/ProxyConnectorPanel.d.ts +9 -0
- package/dist/components/SafeBackground.d.ts +13 -0
- package/dist/components/ScrollIndicatorWrapper.d.ts +8 -0
- package/dist/components/SetChildModal.d.ts +10 -0
- package/dist/components/SetParentModal.d.ts +10 -0
- package/dist/components/SlidingPanel.d.ts +16 -0
- package/dist/components/TagUpsert.d.ts +8 -0
- package/dist/components/TopMenuBar.d.ts +8 -0
- package/dist/components/ViewBezierConnector.d.ts +4 -0
- package/dist/components/ViewDrawMenu.d.ts +22 -0
- package/dist/components/ViewEditorEdgeLabelLayout.d.ts +16 -0
- package/dist/components/ViewEditorOnboarding.d.ts +5 -0
- package/dist/components/ViewExplorer/TagManager/ColorPicker.d.ts +7 -0
- package/dist/components/ViewExplorer/TagManager/GroupNamingPopover.d.ts +10 -0
- package/dist/components/ViewExplorer/TagManager/LayerItem.d.ts +27 -0
- package/dist/components/ViewExplorer/TagManager/TagItem.d.ts +25 -0
- package/dist/components/ViewExplorer/TagManager/index.d.ts +21 -0
- package/dist/components/ViewExplorer/ViewNavigator.d.ts +11 -0
- package/dist/components/ViewExplorer/ViewSearch.d.ts +8 -0
- package/dist/components/ViewExplorer/ViewTree.d.ts +18 -0
- package/dist/components/ViewExplorer/index.d.ts +31 -0
- package/dist/components/ViewExplorer/types.d.ts +11 -0
- package/dist/components/ViewExplorer/utils.d.ts +6 -0
- package/dist/components/ViewExplorer-vscode.d.ts +6 -0
- package/dist/components/ViewFloatingMenu-vscode.d.ts +27 -0
- package/dist/components/ViewFloatingMenu.d.ts +39 -0
- package/dist/components/ViewGridNode.d.ts +29 -0
- package/dist/components/ViewHeaderButton.d.ts +11 -0
- package/dist/components/ViewPanel.d.ts +18 -0
- package/dist/components/ViewsGridOnboarding.d.ts +5 -0
- package/dist/components/ZUI/ZUICanvas.d.ts +18 -0
- package/dist/components/ZUI/index.d.ts +2 -0
- package/dist/components/ZUI/layout.d.ts +18 -0
- package/dist/components/ZUI/proxy.d.ts +25 -0
- package/dist/components/ZUI/renderer.d.ts +30 -0
- package/dist/components/ZUI/types.d.ts +140 -0
- package/dist/components/ZUI/useZUIInteraction.d.ts +21 -0
- package/dist/config/runtime-vscode.d.ts +22 -0
- package/dist/config/runtime.d.ts +5 -0
- package/dist/constants/colors.d.ts +27 -0
- package/dist/constants/diagramColors.d.ts +1 -0
- package/dist/context/ThemeContext.d.ts +27 -0
- package/dist/crossBranch/graph.d.ts +13 -0
- package/dist/crossBranch/resolve.d.ts +22 -0
- package/dist/crossBranch/settings.d.ts +6 -0
- package/dist/crossBranch/store.d.ts +11 -0
- package/dist/crossBranch/types.d.ts +96 -0
- package/dist/demo/DemoPage.d.ts +9 -0
- package/dist/demo/seed.d.ts +9 -0
- package/dist/demo/store.d.ts +137 -0
- package/dist/demo/viewEditor.d.ts +26 -0
- package/dist/favicon.svg +35 -0
- package/dist/hooks/useSafeFitView.d.ts +16 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +19966 -0
- package/dist/lib/vscodeBridge-vscode.d.ts +13 -0
- package/dist/lib/vscodeBridge.d.ts +5 -0
- package/dist/logo-120.png +0 -0
- package/dist/logo-bw.png +0 -0
- package/dist/logo-bw.svg +15 -0
- package/dist/logo-text.svg +51 -0
- package/dist/logo.svg +35 -0
- package/dist/pages/AppearanceSettings.d.ts +3 -0
- package/dist/pages/Dependencies.d.ts +1 -0
- package/dist/pages/InfiniteZoom.d.ts +7 -0
- package/dist/pages/Settings.d.ts +7 -0
- package/dist/pages/ViewEditor/components/EditorMenus.d.ts +24 -0
- package/dist/pages/ViewEditor/components/EditorOverlays.d.ts +30 -0
- package/dist/pages/ViewEditor/components/EmptyCanvasState.d.ts +7 -0
- package/dist/pages/ViewEditor/context.d.ts +13 -0
- package/dist/pages/ViewEditor/hooks/useCanvasInteractions.d.ts +201 -0
- package/dist/pages/ViewEditor/hooks/useDrawingEngine.d.ts +40 -0
- package/dist/pages/ViewEditor/hooks/useViewContextNeighbours.d.ts +20 -0
- package/dist/pages/ViewEditor/hooks/useViewData.d.ts +74 -0
- package/dist/pages/ViewEditor/index.d.ts +8 -0
- package/dist/pages/ViewEditor/utils.d.ts +14 -0
- package/dist/pages/Views.d.ts +6 -0
- package/dist/pages/ViewsGrid.d.ts +6 -0
- package/dist/pkg/importer/mermaid.d.ts +7 -0
- package/dist/pkg/importer/mermaid.test.d.ts +1 -0
- package/dist/platform/PlatformContext.d.ts +6 -0
- package/dist/platform/context.d.ts +3 -0
- package/dist/platform/local.d.ts +2 -0
- package/dist/platform/types.d.ts +17 -0
- package/dist/slots.d.ts +67 -0
- package/dist/theme.d.ts +2 -0
- package/dist/types/index.d.ts +193 -0
- package/dist/types/vscode-messages.d.ts +60 -0
- package/dist/utils/edgeDistribution.d.ts +34 -0
- package/dist/utils/githubApi.d.ts +4 -0
- package/dist/utils/githubCache.d.ts +17 -0
- package/dist/utils/ids.d.ts +2 -0
- package/dist/utils/technologyCatalog.d.ts +15 -0
- package/dist/utils/toast.d.ts +15 -0
- package/dist/utils/treesitter.d.ts +13 -0
- package/dist/utils/url.d.ts +12 -0
- package/package.json +159 -0
- package/src/App.tsx +141 -0
- package/src/api/client.ts +618 -0
- package/src/api/transport-vscode.ts +28 -0
- package/src/api/transport.ts +7 -0
- package/src/assets/logo-mark.svg +31 -0
- package/src/assets/logo-wordmark.svg +22 -0
- package/src/assets/logo.svg +35 -0
- package/src/components/CodePreviewPanel-vscode.tsx +85 -0
- package/src/components/CodePreviewPanel.tsx +384 -0
- package/src/components/ConfirmDialog.tsx +66 -0
- package/src/components/ConnectorPanel.tsx +403 -0
- package/src/components/ContextBoundaryElement.tsx +35 -0
- package/src/components/ContextNeighborElement.tsx +282 -0
- package/src/components/ContextStraightConnector.tsx +144 -0
- package/src/components/CrossBranchControls.tsx +105 -0
- package/src/components/DependenciesOnboarding.tsx +427 -0
- package/src/components/DrawingCanvas.tsx +391 -0
- package/src/components/ElementLibrary-vscode.tsx +9 -0
- package/src/components/ElementLibrary.tsx +512 -0
- package/src/components/ElementNode.tsx +1033 -0
- package/src/components/ElementPanel.tsx +928 -0
- package/src/components/ExploreOnboarding.tsx +347 -0
- package/src/components/ExplorePageOnboarding.tsx +383 -0
- package/src/components/ExportModal.tsx +132 -0
- package/src/components/FloatingEdge.tsx +115 -0
- package/src/components/GitSourceLinker.tsx +1053 -0
- package/src/components/HeaderContext.tsx +30 -0
- package/src/components/Icons.tsx +245 -0
- package/src/components/ImportModal.tsx +219 -0
- package/src/components/InlineElementAdder.tsx +216 -0
- package/src/components/LayoutSection.tsx +624 -0
- package/src/components/LocalSourceLinker.tsx +330 -0
- package/src/components/MiniZoomOnboarding.tsx +78 -0
- package/src/components/NavBreadcrumb.tsx +24 -0
- package/src/components/NodeBody.tsx +89 -0
- package/src/components/NodeContainer.tsx +58 -0
- package/src/components/NodeHoverCard.tsx +135 -0
- package/src/components/PanelHeader.tsx +36 -0
- package/src/components/PanelUI.tsx +24 -0
- package/src/components/ProxyConnectorEdge.tsx +169 -0
- package/src/components/ProxyConnectorPanel.tsx +130 -0
- package/src/components/SafeBackground.tsx +19 -0
- package/src/components/ScrollIndicatorWrapper.tsx +117 -0
- package/src/components/SetChildModal.tsx +191 -0
- package/src/components/SetParentModal.tsx +187 -0
- package/src/components/SlidingPanel.tsx +114 -0
- package/src/components/TagUpsert.tsx +142 -0
- package/src/components/TopMenuBar.tsx +380 -0
- package/src/components/ViewBezierConnector.tsx +143 -0
- package/src/components/ViewDrawMenu.tsx +270 -0
- package/src/components/ViewEditorEdgeLabelLayout.ts +189 -0
- package/src/components/ViewEditorOnboarding.tsx +445 -0
- package/src/components/ViewExplorer/TagManager/ColorPicker.tsx +49 -0
- package/src/components/ViewExplorer/TagManager/GroupNamingPopover.tsx +96 -0
- package/src/components/ViewExplorer/TagManager/LayerItem.tsx +228 -0
- package/src/components/ViewExplorer/TagManager/TagItem.tsx +242 -0
- package/src/components/ViewExplorer/TagManager/index.tsx +418 -0
- package/src/components/ViewExplorer/ViewNavigator.tsx +121 -0
- package/src/components/ViewExplorer/ViewSearch.tsx +33 -0
- package/src/components/ViewExplorer/ViewTree.tsx +98 -0
- package/src/components/ViewExplorer/index.tsx +384 -0
- package/src/components/ViewExplorer/types.ts +13 -0
- package/src/components/ViewExplorer/utils.ts +56 -0
- package/src/components/ViewExplorer-vscode.tsx +8 -0
- package/src/components/ViewFloatingMenu-vscode.tsx +248 -0
- package/src/components/ViewFloatingMenu.tsx +379 -0
- package/src/components/ViewGridNode.tsx +451 -0
- package/src/components/ViewHeaderButton.tsx +60 -0
- package/src/components/ViewPanel.tsx +162 -0
- package/src/components/ViewsGridOnboarding.tsx +400 -0
- package/src/components/ZUI/ZUICanvas.tsx +853 -0
- package/src/components/ZUI/index.ts +3 -0
- package/src/components/ZUI/layout.ts +323 -0
- package/src/components/ZUI/proxy.ts +278 -0
- package/src/components/ZUI/renderer.ts +1189 -0
- package/src/components/ZUI/types.ts +150 -0
- package/src/components/ZUI/useZUIInteraction.ts +720 -0
- package/src/config/runtime-vscode.ts +46 -0
- package/src/config/runtime.ts +30 -0
- package/src/constants/colors.ts +80 -0
- package/src/constants/diagramColors.ts +9 -0
- package/src/context/ThemeContext.tsx +158 -0
- package/src/crossBranch/graph.ts +207 -0
- package/src/crossBranch/resolve.ts +643 -0
- package/src/crossBranch/settings.ts +59 -0
- package/src/crossBranch/store.ts +71 -0
- package/src/crossBranch/types.ts +102 -0
- package/src/demo/DemoPage.tsx +184 -0
- package/src/demo/seed.ts +67 -0
- package/src/demo/store.ts +536 -0
- package/src/demo/viewEditor.ts +110 -0
- package/src/hooks/useSafeFitView.ts +60 -0
- package/src/index.css +309 -0
- package/src/index.ts +184 -0
- package/src/kafka-ss.png +0 -0
- package/src/lib/vscodeBridge-vscode.ts +27 -0
- package/src/lib/vscodeBridge.ts +7 -0
- package/src/main.tsx +46 -0
- package/src/pages/AppearanceSettings.tsx +135 -0
- package/src/pages/Dependencies.tsx +926 -0
- package/src/pages/InfiniteZoom.tsx +404 -0
- package/src/pages/Settings.tsx +91 -0
- package/src/pages/ViewEditor/EDGE_DISTRIBUTION.md +64 -0
- package/src/pages/ViewEditor/components/EditorMenus.tsx +112 -0
- package/src/pages/ViewEditor/components/EditorOverlays.tsx +172 -0
- package/src/pages/ViewEditor/components/EmptyCanvasState.tsx +42 -0
- package/src/pages/ViewEditor/context.tsx +21 -0
- package/src/pages/ViewEditor/hooks/useCanvasInteractions.ts +1349 -0
- package/src/pages/ViewEditor/hooks/useDrawingEngine.ts +127 -0
- package/src/pages/ViewEditor/hooks/useViewContextNeighbours.ts +501 -0
- package/src/pages/ViewEditor/hooks/useViewData.ts +491 -0
- package/src/pages/ViewEditor/index.tsx +1366 -0
- package/src/pages/ViewEditor/utils.ts +88 -0
- package/src/pages/Views.tsx +171 -0
- package/src/pages/ViewsGrid.tsx +1310 -0
- package/src/pkg/importer/mermaid.test.ts +141 -0
- package/src/pkg/importer/mermaid.ts +76 -0
- package/src/platform/PlatformContext.tsx +17 -0
- package/src/platform/context.ts +9 -0
- package/src/platform/local.tsx +15 -0
- package/src/platform/types.ts +19 -0
- package/src/slots.ts +92 -0
- package/src/styles/editor-panels.css +66 -0
- package/src/styles/theme.css +56 -0
- package/src/theme.ts +336 -0
- package/src/types/index.ts +234 -0
- package/src/types/offline-ambient.d.ts +14 -0
- package/src/types/vscode-messages.ts +32 -0
- package/src/utils/edgeDistribution.ts +103 -0
- package/src/utils/githubApi.ts +121 -0
- package/src/utils/githubCache.ts +108 -0
- package/src/utils/ids.ts +9 -0
- package/src/utils/technologyCatalog.ts +143 -0
- package/src/utils/toast.ts +100 -0
- package/src/utils/treesitter.ts +147 -0
- package/src/utils/url.ts +72 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
VStack,
|
|
5
|
+
HStack,
|
|
6
|
+
Text,
|
|
7
|
+
Wrap,
|
|
8
|
+
WrapItem,
|
|
9
|
+
IconButton,
|
|
10
|
+
Popover,
|
|
11
|
+
PopoverTrigger,
|
|
12
|
+
PopoverContent,
|
|
13
|
+
PopoverBody,
|
|
14
|
+
Input,
|
|
15
|
+
Button,
|
|
16
|
+
Divider,
|
|
17
|
+
useDisclosure,
|
|
18
|
+
} from '@chakra-ui/react'
|
|
19
|
+
import { AddIcon } from '@chakra-ui/icons'
|
|
20
|
+
import ScrollIndicatorWrapper from '../../ScrollIndicatorWrapper'
|
|
21
|
+
import { ViewLayer, LibraryElement, PlacedElement } from '../../../types'
|
|
22
|
+
import { TagItem } from './TagItem'
|
|
23
|
+
import { LayerItem } from './LayerItem'
|
|
24
|
+
import { ColorPicker } from './ColorPicker'
|
|
25
|
+
import { pickUnusedColor } from '../utils'
|
|
26
|
+
import { ChevronDownIcon } from '../../Icons'
|
|
27
|
+
|
|
28
|
+
interface Props {
|
|
29
|
+
availableTags: string[]
|
|
30
|
+
tagColors: Record<string, import('../../../types').Tag>
|
|
31
|
+
layers: ViewLayer[]
|
|
32
|
+
viewElements: PlacedElement[]
|
|
33
|
+
selectedElement: LibraryElement | null
|
|
34
|
+
hiddenLayerTags: string[]
|
|
35
|
+
setHiddenLayerTags: (tags: string[]) => void
|
|
36
|
+
onToggleTagOnElement: (tag: string) => void
|
|
37
|
+
onHoverLayer: (tags: string[] | null, color?: string | null) => void
|
|
38
|
+
onCreateLayer: (name: string, tags: string[], color: string) => Promise<void>
|
|
39
|
+
onUpdateLayer: (layer: ViewLayer) => Promise<void>
|
|
40
|
+
onDeleteLayer: (id: number) => Promise<void>
|
|
41
|
+
onCreateTag: (tag: string, color?: string, description?: string) => Promise<void>
|
|
42
|
+
tagCounts: Record<string, number>
|
|
43
|
+
layerCounts: Record<number, number>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const TagManager: React.FC<Props> = ({
|
|
47
|
+
availableTags,
|
|
48
|
+
tagColors,
|
|
49
|
+
layers,
|
|
50
|
+
selectedElement,
|
|
51
|
+
hiddenLayerTags,
|
|
52
|
+
setHiddenLayerTags,
|
|
53
|
+
onToggleTagOnElement,
|
|
54
|
+
onHoverLayer,
|
|
55
|
+
onCreateLayer,
|
|
56
|
+
onCreateTag,
|
|
57
|
+
onUpdateLayer,
|
|
58
|
+
onDeleteLayer,
|
|
59
|
+
tagCounts,
|
|
60
|
+
layerCounts,
|
|
61
|
+
}) => {
|
|
62
|
+
const [isCollapsed, setIsCollapsed] = useState(false)
|
|
63
|
+
const [expandedLayerIds, setExpandedLayerIds] = useState<Set<number>>(new Set())
|
|
64
|
+
const [namingPopover, setNamingPopover] = useState<{
|
|
65
|
+
isOpen: boolean;
|
|
66
|
+
tags: string[];
|
|
67
|
+
defaultName: string;
|
|
68
|
+
targetTag?: string | null;
|
|
69
|
+
targetLayerId?: number | null;
|
|
70
|
+
}>({
|
|
71
|
+
isOpen: false,
|
|
72
|
+
tags: [],
|
|
73
|
+
defaultName: '',
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const toggleLayerActive = (layer: ViewLayer) => {
|
|
77
|
+
const isActive = layer.tags.length === 0 || !layer.tags.some((t) => hiddenLayerTags.includes(t))
|
|
78
|
+
if (isActive) {
|
|
79
|
+
setHiddenLayerTags(Array.from(new Set([...hiddenLayerTags, ...layer.tags])))
|
|
80
|
+
} else {
|
|
81
|
+
setHiddenLayerTags(hiddenLayerTags.filter((t) => !layer.tags.includes(t)))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const toggleTagVisibility = (tag: string) => {
|
|
86
|
+
if (hiddenLayerTags.includes(tag)) {
|
|
87
|
+
setHiddenLayerTags(hiddenLayerTags.filter((t) => t !== tag))
|
|
88
|
+
} else {
|
|
89
|
+
setHiddenLayerTags([...hiddenLayerTags, tag])
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const toggleLayerExpanded = (id: number) => {
|
|
94
|
+
setExpandedLayerIds((prev) => {
|
|
95
|
+
const next = new Set(prev)
|
|
96
|
+
if (next.has(id)) next.delete(id)
|
|
97
|
+
else next.add(id)
|
|
98
|
+
return next
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const handleCreateGroup = (tagA: string, tagB: string, targetTag: string) => {
|
|
103
|
+
setNamingPopover({
|
|
104
|
+
isOpen: true,
|
|
105
|
+
tags: [tagA, tagB],
|
|
106
|
+
defaultName: `${tagA} & ${tagB}`,
|
|
107
|
+
targetTag,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const handleCreateGroupFromLayer = (targetTag: string, sourceLayerId: number) => {
|
|
112
|
+
const layer = layers.find(l => l.id === sourceLayerId)
|
|
113
|
+
if (!layer) return
|
|
114
|
+
setNamingPopover({
|
|
115
|
+
isOpen: true,
|
|
116
|
+
tags: Array.from(new Set([...layer.tags, targetTag])),
|
|
117
|
+
defaultName: `Group ${layer.name} & ${targetTag}`,
|
|
118
|
+
targetTag,
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const handleConfirmNaming = async (name: string) => {
|
|
123
|
+
const { tags } = namingPopover
|
|
124
|
+
if (!tags || tags.length === 0) return
|
|
125
|
+
|
|
126
|
+
const color = pickUnusedColor(Object.values(tagColors).map(t => t.color))
|
|
127
|
+
await onCreateLayer(name, tags, color)
|
|
128
|
+
setNamingPopover(prev => ({ ...prev, isOpen: false, targetTag: null, targetLayerId: null }))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const { isOpen: isTagOpen, onOpen: onTagOpen, onClose: onTagClose } = useDisclosure()
|
|
132
|
+
const { isOpen: isNewTagColorOpen, onOpen: onNewTagColorOpen, onClose: onNewTagColorClose } = useDisclosure()
|
|
133
|
+
const [newTagName, setNewTagName] = useState('')
|
|
134
|
+
const [newTagColor, setNewTagColor] = useState('#A0AEC0')
|
|
135
|
+
const [newTagDescription, setNewTagDescription] = useState('')
|
|
136
|
+
|
|
137
|
+
const handleOpenAddTag = () => {
|
|
138
|
+
setNewTagColor(pickUnusedColor(Object.values(tagColors).map(t => t.color)))
|
|
139
|
+
onTagOpen()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const handleAddTag = async () => {
|
|
143
|
+
const name = newTagName.trim()
|
|
144
|
+
if (!name) return
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await onCreateTag(name, newTagColor, newTagDescription)
|
|
148
|
+
if (selectedElement && !(selectedElement.tags || []).includes(name)) {
|
|
149
|
+
onToggleTagOnElement(name)
|
|
150
|
+
}
|
|
151
|
+
setNewTagName('')
|
|
152
|
+
setNewTagDescription('')
|
|
153
|
+
onTagClose()
|
|
154
|
+
} catch {
|
|
155
|
+
// Keep the popover open so the user can retry.
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const usedTags = availableTags.filter(tag => (tagCounts[tag] || 0) > 0)
|
|
160
|
+
const unusedTags = availableTags.filter(tag => (tagCounts[tag] || 0) === 0)
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Box
|
|
164
|
+
display="flex"
|
|
165
|
+
flexDirection="column"
|
|
166
|
+
overflow="hidden"
|
|
167
|
+
flex="1"
|
|
168
|
+
borderTop="1px solid"
|
|
169
|
+
borderColor="whiteAlpha.100"
|
|
170
|
+
>
|
|
171
|
+
<HStack px={4} py={2} spacing={1.5} flexShrink={0}>
|
|
172
|
+
<Text
|
|
173
|
+
fontSize="xs"
|
|
174
|
+
fontWeight="700"
|
|
175
|
+
color="white"
|
|
176
|
+
textTransform="uppercase"
|
|
177
|
+
letterSpacing="0.02em"
|
|
178
|
+
flex={1}
|
|
179
|
+
>
|
|
180
|
+
Tags
|
|
181
|
+
</Text>
|
|
182
|
+
|
|
183
|
+
<Popover isOpen={isTagOpen} onClose={onTagClose} placement="bottom-end">
|
|
184
|
+
<PopoverTrigger>
|
|
185
|
+
<IconButton
|
|
186
|
+
aria-label="Add Tag"
|
|
187
|
+
icon={<AddIcon boxSize="8px" />}
|
|
188
|
+
size="xs"
|
|
189
|
+
variant="ghost"
|
|
190
|
+
color="gray.600"
|
|
191
|
+
_hover={{ color: 'white', bg: 'whiteAlpha.100' }}
|
|
192
|
+
onClick={handleOpenAddTag}
|
|
193
|
+
/>
|
|
194
|
+
</PopoverTrigger>
|
|
195
|
+
<PopoverContent bg="gray.800" borderColor="whiteAlpha.200" w="240px" shadow="xl">
|
|
196
|
+
<PopoverBody p={2}>
|
|
197
|
+
<VStack spacing={2} align="stretch">
|
|
198
|
+
<HStack spacing={2}>
|
|
199
|
+
<Popover
|
|
200
|
+
isOpen={isNewTagColorOpen}
|
|
201
|
+
onClose={onNewTagColorClose}
|
|
202
|
+
placement="left"
|
|
203
|
+
closeOnBlur
|
|
204
|
+
>
|
|
205
|
+
<PopoverTrigger>
|
|
206
|
+
<Box
|
|
207
|
+
w="20px"
|
|
208
|
+
h="20px"
|
|
209
|
+
rounded="full"
|
|
210
|
+
bg={newTagColor}
|
|
211
|
+
cursor="pointer"
|
|
212
|
+
flexShrink={0}
|
|
213
|
+
onClick={onNewTagColorOpen}
|
|
214
|
+
/>
|
|
215
|
+
</PopoverTrigger>
|
|
216
|
+
<ColorPicker onSelect={setNewTagColor} onClose={onNewTagColorClose} />
|
|
217
|
+
</Popover>
|
|
218
|
+
<VStack spacing={2} flex={1}>
|
|
219
|
+
<Input
|
|
220
|
+
size="xs"
|
|
221
|
+
placeholder="Tag name..."
|
|
222
|
+
value={newTagName}
|
|
223
|
+
onChange={(e) => setNewTagName(e.target.value)}
|
|
224
|
+
onKeyDown={(e) => { if (e.key === 'Enter') { void handleAddTag() } }}
|
|
225
|
+
autoFocus
|
|
226
|
+
bg="whiteAlpha.50"
|
|
227
|
+
borderColor="whiteAlpha.100"
|
|
228
|
+
_focus={{ borderColor: 'var(--accent)' }}
|
|
229
|
+
/>
|
|
230
|
+
<Input
|
|
231
|
+
size="xs"
|
|
232
|
+
placeholder="Optional description..."
|
|
233
|
+
value={newTagDescription}
|
|
234
|
+
onChange={(e) => setNewTagDescription(e.target.value)}
|
|
235
|
+
onKeyDown={(e) => { if (e.key === 'Enter') { void handleAddTag() } }}
|
|
236
|
+
bg="whiteAlpha.50"
|
|
237
|
+
borderColor="whiteAlpha.100"
|
|
238
|
+
_focus={{ borderColor: 'var(--accent)' }}
|
|
239
|
+
/>
|
|
240
|
+
</VStack>
|
|
241
|
+
<Button size="xs" colorScheme="blue" h="auto" py={4} onClick={() => { void handleAddTag() }}>Add</Button>
|
|
242
|
+
</HStack>
|
|
243
|
+
</VStack>
|
|
244
|
+
</PopoverBody>
|
|
245
|
+
</PopoverContent>
|
|
246
|
+
</Popover>
|
|
247
|
+
|
|
248
|
+
<IconButton
|
|
249
|
+
aria-label="Toggle Section"
|
|
250
|
+
icon={<ChevronDownIcon size={12} />}
|
|
251
|
+
size="xs"
|
|
252
|
+
variant="ghost"
|
|
253
|
+
color="whiteAlpha.500"
|
|
254
|
+
_hover={{ color: 'white', bg: 'whiteAlpha.200' }}
|
|
255
|
+
onClick={() => setIsCollapsed(!isCollapsed)}
|
|
256
|
+
transform={isCollapsed ? 'rotate(-90deg)' : 'none'}
|
|
257
|
+
/>
|
|
258
|
+
</HStack>
|
|
259
|
+
|
|
260
|
+
{!isCollapsed && (
|
|
261
|
+
<ScrollIndicatorWrapper flex={1} minH={0}>
|
|
262
|
+
<VStack align="stretch" spacing={0} pb={3}>
|
|
263
|
+
{/* Active Element Section */}
|
|
264
|
+
{selectedElement && (
|
|
265
|
+
<Box px={3} py={2.5} bg="whiteAlpha.50" borderBottom="1px solid" borderColor="whiteAlpha.100">
|
|
266
|
+
<HStack mb={2} spacing={1.5}>
|
|
267
|
+
<Box w="5px" h="5px" rounded="full" bg="var(--accent)" flexShrink={0} />
|
|
268
|
+
<Text fontSize="9px" fontWeight="700" color="whiteAlpha.400" textTransform="uppercase" letterSpacing="0.08em" isTruncated>
|
|
269
|
+
{selectedElement.name}
|
|
270
|
+
</Text>
|
|
271
|
+
</HStack>
|
|
272
|
+
<VStack align="stretch" spacing={2.5}>
|
|
273
|
+
{usedTags.length > 0 && (
|
|
274
|
+
<Wrap spacing={1}>
|
|
275
|
+
{usedTags.map((tag) => (
|
|
276
|
+
<WrapItem key={tag}>
|
|
277
|
+
<TagItem
|
|
278
|
+
tag={tag}
|
|
279
|
+
color={tagColors[tag]?.color || '#A0AEC0'}
|
|
280
|
+
description={tagColors[tag]?.description || null}
|
|
281
|
+
isAssigned={(selectedElement.tags || []).includes(tag)}
|
|
282
|
+
tagCount={tagCounts[tag]}
|
|
283
|
+
onToggle={() => onToggleTagOnElement(tag)}
|
|
284
|
+
onHover={(active) => onHoverLayer(active ? [tag] : null, tagColors[tag]?.color)}
|
|
285
|
+
onDropTag={(dragged: string) => handleCreateGroup(tag, dragged, tag)}
|
|
286
|
+
onDropLayer={(draggedId: number) => handleCreateGroupFromLayer(tag, draggedId)}
|
|
287
|
+
namingPopover={namingPopover.targetTag === tag ? namingPopover : undefined}
|
|
288
|
+
onConfirmNaming={handleConfirmNaming}
|
|
289
|
+
onCloseNaming={() => setNamingPopover(prev => ({ ...prev, isOpen: false, targetTag: null }))}
|
|
290
|
+
isVisible={!hiddenLayerTags.includes(tag)}
|
|
291
|
+
onToggleVisibility={() => toggleTagVisibility(tag)}
|
|
292
|
+
onSetColor={(color) => onCreateTag(tag, color)}
|
|
293
|
+
onSetDescription={(desc) => onCreateTag(tag, tagColors[tag]?.color, desc)}
|
|
294
|
+
/>
|
|
295
|
+
</WrapItem>
|
|
296
|
+
))}
|
|
297
|
+
</Wrap>
|
|
298
|
+
)}
|
|
299
|
+
{usedTags.length > 0 && unusedTags.length > 0 && (
|
|
300
|
+
<Divider borderColor="whiteAlpha.100" />
|
|
301
|
+
)}
|
|
302
|
+
{unusedTags.length > 0 && (
|
|
303
|
+
<Wrap spacing={1} opacity={0.6}>
|
|
304
|
+
{unusedTags.map((tag) => (
|
|
305
|
+
<WrapItem key={tag}>
|
|
306
|
+
<TagItem
|
|
307
|
+
tag={tag}
|
|
308
|
+
color={tagColors[tag]?.color || '#A0AEC0'}
|
|
309
|
+
description={tagColors[tag]?.description || null}
|
|
310
|
+
isAssigned={(selectedElement.tags || []).includes(tag)}
|
|
311
|
+
tagCount={tagCounts[tag]}
|
|
312
|
+
onToggle={() => onToggleTagOnElement(tag)}
|
|
313
|
+
onHover={(active) => onHoverLayer(active ? [tag] : null, tagColors[tag]?.color)}
|
|
314
|
+
onDropTag={(dragged: string) => handleCreateGroup(tag, dragged, tag)}
|
|
315
|
+
onDropLayer={(draggedId: number) => handleCreateGroupFromLayer(tag, draggedId)}
|
|
316
|
+
namingPopover={namingPopover.targetTag === tag ? namingPopover : undefined}
|
|
317
|
+
onConfirmNaming={handleConfirmNaming}
|
|
318
|
+
onCloseNaming={() => setNamingPopover(prev => ({ ...prev, isOpen: false, targetTag: null }))}
|
|
319
|
+
onSetColor={(color) => onCreateTag(tag, color)}
|
|
320
|
+
onSetDescription={(desc) => onCreateTag(tag, tagColors[tag]?.color, desc)}
|
|
321
|
+
/>
|
|
322
|
+
</WrapItem>
|
|
323
|
+
))}
|
|
324
|
+
</Wrap>
|
|
325
|
+
)}
|
|
326
|
+
</VStack>
|
|
327
|
+
</Box>
|
|
328
|
+
)}
|
|
329
|
+
|
|
330
|
+
{/* Layers (Groups) List */}
|
|
331
|
+
{layers.map((layer) => (
|
|
332
|
+
<LayerItem
|
|
333
|
+
key={layer.id}
|
|
334
|
+
layer={layer}
|
|
335
|
+
isActive={layer.tags.length === 0 || !layer.tags.some((t) => hiddenLayerTags.includes(t))}
|
|
336
|
+
isExpanded={expandedLayerIds.has(layer.id)}
|
|
337
|
+
tagCount={layerCounts[layer.id] || 0}
|
|
338
|
+
tagColors={tagColors}
|
|
339
|
+
onToggleActive={() => toggleLayerActive(layer)}
|
|
340
|
+
onToggleExpanded={() => toggleLayerExpanded(layer.id)}
|
|
341
|
+
onDelete={() => onDeleteLayer(layer.id)}
|
|
342
|
+
onSetColor={(color) => onUpdateLayer({ ...layer, color })}
|
|
343
|
+
onSetTagColor={onCreateTag}
|
|
344
|
+
onAddTag={(tag) => onUpdateLayer({ ...layer, tags: Array.from(new Set([...layer.tags, tag])) })}
|
|
345
|
+
onRemoveTag={(tag) => onUpdateLayer({ ...layer, tags: layer.tags.filter((existingTag) => existingTag !== tag) })}
|
|
346
|
+
onHover={(active) => onHoverLayer(active ? layer.tags : null, layer.color)}
|
|
347
|
+
selectedElementTags={selectedElement?.tags}
|
|
348
|
+
onToggleTagOnElement={onToggleTagOnElement}
|
|
349
|
+
namingPopover={namingPopover.targetLayerId === layer.id ? namingPopover : undefined}
|
|
350
|
+
onConfirmNaming={handleConfirmNaming}
|
|
351
|
+
onCloseNaming={() => setNamingPopover(prev => ({ ...prev, isOpen: false, targetLayerId: null }))}
|
|
352
|
+
/>
|
|
353
|
+
))}
|
|
354
|
+
|
|
355
|
+
{/* All Tags (if no element selected or just as library) */}
|
|
356
|
+
{!selectedElement && (
|
|
357
|
+
<Box px={4} py={3}>
|
|
358
|
+
<Text fontSize="10px" fontWeight="bold" color="gray.600" mb={2} textTransform="uppercase">Drag & Drop to tag elements</Text>
|
|
359
|
+
<VStack align="stretch" spacing={3}>
|
|
360
|
+
{usedTags.length > 0 && (
|
|
361
|
+
<Wrap spacing={2}>
|
|
362
|
+
{usedTags.map((tag) => (
|
|
363
|
+
<WrapItem key={tag}>
|
|
364
|
+
<TagItem
|
|
365
|
+
tag={tag}
|
|
366
|
+
color={tagColors[tag]?.color || '#A0AEC0'}
|
|
367
|
+
description={tagColors[tag]?.description || null}
|
|
368
|
+
tagCount={tagCounts[tag]}
|
|
369
|
+
onHover={(active) => onHoverLayer(active ? [tag] : null, tagColors[tag]?.color)}
|
|
370
|
+
onDropTag={(dragged: string) => handleCreateGroup(tag, dragged, tag)}
|
|
371
|
+
onDropLayer={(draggedId: number) => handleCreateGroupFromLayer(tag, draggedId)}
|
|
372
|
+
namingPopover={namingPopover.targetTag === tag ? namingPopover : undefined}
|
|
373
|
+
onConfirmNaming={handleConfirmNaming}
|
|
374
|
+
onCloseNaming={() => setNamingPopover(prev => ({ ...prev, isOpen: false, targetTag: null }))}
|
|
375
|
+
isVisible={!hiddenLayerTags.includes(tag)}
|
|
376
|
+
onToggleVisibility={() => toggleTagVisibility(tag)}
|
|
377
|
+
onSetColor={(color) => onCreateTag(tag, color)}
|
|
378
|
+
onSetDescription={(desc) => onCreateTag(tag, tagColors[tag]?.color, desc)}
|
|
379
|
+
/>
|
|
380
|
+
</WrapItem>
|
|
381
|
+
))}
|
|
382
|
+
</Wrap>
|
|
383
|
+
)}
|
|
384
|
+
{usedTags.length > 0 && unusedTags.length > 0 && (
|
|
385
|
+
<Divider borderColor="whiteAlpha.100" />
|
|
386
|
+
)}
|
|
387
|
+
{unusedTags.length > 0 && (
|
|
388
|
+
<Wrap spacing={2} opacity={0.6}>
|
|
389
|
+
{unusedTags.map((tag) => (
|
|
390
|
+
<WrapItem key={tag}>
|
|
391
|
+
<TagItem
|
|
392
|
+
tag={tag}
|
|
393
|
+
color={tagColors[tag]?.color || '#A0AEC0'}
|
|
394
|
+
description={tagColors[tag]?.description || null}
|
|
395
|
+
tagCount={tagCounts[tag]}
|
|
396
|
+
onHover={(active) => onHoverLayer(active ? [tag] : null, tagColors[tag]?.color)}
|
|
397
|
+
onDropTag={(dragged: string) => handleCreateGroup(tag, dragged, tag)}
|
|
398
|
+
onDropLayer={(draggedId: number) => handleCreateGroupFromLayer(tag, draggedId)}
|
|
399
|
+
namingPopover={namingPopover.targetTag === tag ? namingPopover : undefined}
|
|
400
|
+
onConfirmNaming={handleConfirmNaming}
|
|
401
|
+
onCloseNaming={() => setNamingPopover(prev => ({ ...prev, isOpen: false, targetTag: null }))}
|
|
402
|
+
onSetColor={(color) => onCreateTag(tag, color)}
|
|
403
|
+
onSetDescription={(desc) => onCreateTag(tag, tagColors[tag]?.color, desc)}
|
|
404
|
+
/>
|
|
405
|
+
</WrapItem>
|
|
406
|
+
))}
|
|
407
|
+
</Wrap>
|
|
408
|
+
)}
|
|
409
|
+
</VStack>
|
|
410
|
+
</Box>
|
|
411
|
+
)}
|
|
412
|
+
</VStack>
|
|
413
|
+
</ScrollIndicatorWrapper>
|
|
414
|
+
)}
|
|
415
|
+
|
|
416
|
+
</Box>
|
|
417
|
+
)
|
|
418
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Box, Tooltip, VStack, Text, Divider } from '@chakra-ui/react'
|
|
3
|
+
import { ZoomInIcon, ZoomOutIcon, ChevronDownIcon } from '../Icons'
|
|
4
|
+
import { KbdHint } from '../PanelUI'
|
|
5
|
+
import { NavItem } from './types'
|
|
6
|
+
import { PARENT_VIEW_COLOR, CHILD_VIEW_COLOR } from '../../constants/colors'
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
parents: NavItem[]
|
|
10
|
+
children: NavItem[]
|
|
11
|
+
activeFilter: 'out' | 'in' | null
|
|
12
|
+
onFilterToggle: (type: 'out' | 'in', items: NavItem[]) => void
|
|
13
|
+
onHoverZoom?: (elementId: number | null, type: 'in' | 'out' | null) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ViewNavigator: React.FC<Props> = ({
|
|
17
|
+
parents,
|
|
18
|
+
children,
|
|
19
|
+
activeFilter,
|
|
20
|
+
onFilterToggle,
|
|
21
|
+
onHoverZoom,
|
|
22
|
+
}) => {
|
|
23
|
+
const renderNavButton = (type: 'out' | 'in', items: NavItem[]) => {
|
|
24
|
+
const isOut = type === 'out'
|
|
25
|
+
const label = isOut ? 'Zoom Out' : 'Zoom In'
|
|
26
|
+
const IconCmp = isOut ? ZoomOutIcon : ZoomInIcon
|
|
27
|
+
const shortcut = isOut ? 'W' : 'S'
|
|
28
|
+
const disabled = items.length === 0
|
|
29
|
+
const isActive = activeFilter === type
|
|
30
|
+
const accentColor = isOut ? PARENT_VIEW_COLOR : CHILD_VIEW_COLOR
|
|
31
|
+
|
|
32
|
+
const subtitle = disabled
|
|
33
|
+
? isOut
|
|
34
|
+
? 'No parent views'
|
|
35
|
+
: 'No child views'
|
|
36
|
+
: items.length === 1
|
|
37
|
+
? items[0].name
|
|
38
|
+
: `Select from ${items.length} options`
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Tooltip
|
|
42
|
+
label={
|
|
43
|
+
disabled
|
|
44
|
+
? isOut
|
|
45
|
+
? 'No parent views'
|
|
46
|
+
: 'No child views'
|
|
47
|
+
: `Navigate to ${isOut ? 'Parent' : 'Child'} View [${shortcut}]`
|
|
48
|
+
}
|
|
49
|
+
placement="left"
|
|
50
|
+
openDelay={400}
|
|
51
|
+
>
|
|
52
|
+
<Box
|
|
53
|
+
as="button"
|
|
54
|
+
role="group"
|
|
55
|
+
className={`panel-action-button ${isActive ? 'is-active' : ''}`}
|
|
56
|
+
disabled={disabled}
|
|
57
|
+
onClick={() => onFilterToggle(type, items)}
|
|
58
|
+
onMouseEnter={() => {
|
|
59
|
+
if (disabled || items.length !== 1) return
|
|
60
|
+
onHoverZoom?.(items[0].elementId ?? null, type)
|
|
61
|
+
}}
|
|
62
|
+
onMouseLeave={() => {
|
|
63
|
+
if (disabled || items.length !== 1) return
|
|
64
|
+
onHoverZoom?.(null, null)
|
|
65
|
+
}}
|
|
66
|
+
opacity={disabled ? 0.4 : 1}
|
|
67
|
+
>
|
|
68
|
+
<Box className="panel-action-icon-container" color={disabled ? 'gray.600' : accentColor}>
|
|
69
|
+
<IconCmp />
|
|
70
|
+
</Box>
|
|
71
|
+
<VStack align="start" spacing={0} flex={1} minW={0}>
|
|
72
|
+
<Text
|
|
73
|
+
fontSize="sm"
|
|
74
|
+
color={disabled ? 'gray.500' : 'white'}
|
|
75
|
+
fontWeight="medium"
|
|
76
|
+
isTruncated
|
|
77
|
+
w="full"
|
|
78
|
+
textAlign="left"
|
|
79
|
+
>
|
|
80
|
+
{label}
|
|
81
|
+
</Text>
|
|
82
|
+
<Text
|
|
83
|
+
fontSize="xs"
|
|
84
|
+
color={disabled ? 'gray.600' : isActive ? accentColor : 'gray.400'}
|
|
85
|
+
isTruncated
|
|
86
|
+
w="full"
|
|
87
|
+
transition="color 0.15s"
|
|
88
|
+
textAlign="left"
|
|
89
|
+
>
|
|
90
|
+
{subtitle}
|
|
91
|
+
</Text>
|
|
92
|
+
</VStack>
|
|
93
|
+
{items.length > 1 && (
|
|
94
|
+
<Box
|
|
95
|
+
color="whiteAlpha.400"
|
|
96
|
+
_groupHover={{ color: 'white' }}
|
|
97
|
+
flexShrink={0}
|
|
98
|
+
transform={isActive ? 'rotate(180deg)' : 'none'}
|
|
99
|
+
transition="all 0.25s cubic-bezier(0.25, 1, 0.5, 1)"
|
|
100
|
+
mx={1}
|
|
101
|
+
>
|
|
102
|
+
<ChevronDownIcon size={12} strokeWidth={3.5} />
|
|
103
|
+
</Box>
|
|
104
|
+
)}
|
|
105
|
+
{isActive && items.length <= 1 && (
|
|
106
|
+
<Box w="5px" h="5px" rounded="full" bg={accentColor} flexShrink={0} mx={1} />
|
|
107
|
+
)}
|
|
108
|
+
<KbdHint>{shortcut}</KbdHint>
|
|
109
|
+
</Box>
|
|
110
|
+
</Tooltip>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<VStack spacing={0} align="stretch" flexShrink={0} py={1}>
|
|
116
|
+
<Box>{renderNavButton('out', parents)}</Box>
|
|
117
|
+
<Divider borderColor="whiteAlpha.100" />
|
|
118
|
+
<Box>{renderNavButton('in', children)}</Box>
|
|
119
|
+
</VStack>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Box, Input, InputGroup, InputLeftElement } from '@chakra-ui/react'
|
|
3
|
+
import { SearchIcon } from '@chakra-ui/icons'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
query: string
|
|
7
|
+
setQuery: (q: string) => void
|
|
8
|
+
activeFilter: 'out' | 'in' | null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ViewSearch: React.FC<Props> = ({ query, setQuery, activeFilter }) => {
|
|
12
|
+
return (
|
|
13
|
+
<Box className="panel-search-container">
|
|
14
|
+
<InputGroup size="sm">
|
|
15
|
+
<InputLeftElement pointerEvents="none">
|
|
16
|
+
<SearchIcon color="gray.500" />
|
|
17
|
+
</InputLeftElement>
|
|
18
|
+
<Input
|
|
19
|
+
className="panel-search-input"
|
|
20
|
+
placeholder={
|
|
21
|
+
activeFilter === 'out'
|
|
22
|
+
? 'Search parents…'
|
|
23
|
+
: activeFilter === 'in'
|
|
24
|
+
? 'Search children…'
|
|
25
|
+
: 'Search views…'
|
|
26
|
+
}
|
|
27
|
+
value={query}
|
|
28
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
29
|
+
/>
|
|
30
|
+
</InputGroup>
|
|
31
|
+
</Box>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { VStack, HStack, Box, Text } from '@chakra-ui/react'
|
|
3
|
+
import ScrollIndicatorWrapper from '../ScrollIndicatorWrapper'
|
|
4
|
+
import { TreeNode } from './types'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
filtered: TreeNode[]
|
|
8
|
+
viewId: number | null
|
|
9
|
+
focusedIdx: number
|
|
10
|
+
itemRefs: React.MutableRefObject<(HTMLDivElement | null)[]>
|
|
11
|
+
handleNavigate: (id: number) => void
|
|
12
|
+
onHoverZoom?: (elementId: number | null, type: 'in' | 'out' | null) => void
|
|
13
|
+
viewHoverMap: Map<number, { elementId: number | undefined; type: 'in' | 'out' }>
|
|
14
|
+
handleKeyDown: (e: React.KeyboardEvent) => void
|
|
15
|
+
listRef: React.RefObject<HTMLDivElement>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ViewTree: React.FC<Props> = ({
|
|
19
|
+
filtered,
|
|
20
|
+
viewId,
|
|
21
|
+
focusedIdx,
|
|
22
|
+
itemRefs,
|
|
23
|
+
handleNavigate,
|
|
24
|
+
onHoverZoom,
|
|
25
|
+
viewHoverMap,
|
|
26
|
+
handleKeyDown,
|
|
27
|
+
listRef,
|
|
28
|
+
}) => {
|
|
29
|
+
return (
|
|
30
|
+
<ScrollIndicatorWrapper
|
|
31
|
+
ref={listRef}
|
|
32
|
+
flex={1}
|
|
33
|
+
minH={0}
|
|
34
|
+
px={3}
|
|
35
|
+
pb={4}
|
|
36
|
+
tabIndex={-1}
|
|
37
|
+
outline="none"
|
|
38
|
+
onKeyDown={handleKeyDown}
|
|
39
|
+
>
|
|
40
|
+
<VStack spacing={0.5} mr={-1} align="stretch">
|
|
41
|
+
{filtered.map((node, idx) => {
|
|
42
|
+
const isCurrent = node.id === viewId
|
|
43
|
+
const isFocused = idx === focusedIdx
|
|
44
|
+
return (
|
|
45
|
+
<HStack
|
|
46
|
+
key={node.id}
|
|
47
|
+
ref={(el) => {
|
|
48
|
+
itemRefs.current[idx] = el as HTMLDivElement | null
|
|
49
|
+
}}
|
|
50
|
+
px={3}
|
|
51
|
+
py={2}
|
|
52
|
+
pl={3 + (node.depth * 3)}
|
|
53
|
+
rounded="lg"
|
|
54
|
+
cursor="pointer"
|
|
55
|
+
bg={
|
|
56
|
+
isCurrent
|
|
57
|
+
? 'rgba(var(--accent-rgb), 0.12)'
|
|
58
|
+
: isFocused
|
|
59
|
+
? 'whiteAlpha.150'
|
|
60
|
+
: 'transparent'
|
|
61
|
+
}
|
|
62
|
+
color={isCurrent ? 'var(--accent)' : 'gray.400'}
|
|
63
|
+
_hover={{
|
|
64
|
+
bg: isCurrent ? 'rgba(var(--accent-rgb), 0.18)' : 'whiteAlpha.100',
|
|
65
|
+
color: 'gray.100',
|
|
66
|
+
}}
|
|
67
|
+
onClick={() => handleNavigate(node.id)}
|
|
68
|
+
onMouseEnter={() => {
|
|
69
|
+
const item = viewHoverMap.get(node.id)
|
|
70
|
+
if (item) onHoverZoom?.(item.elementId ?? null, item.type)
|
|
71
|
+
}}
|
|
72
|
+
onMouseLeave={() => onHoverZoom?.(null, null)}
|
|
73
|
+
transition="all 0.15s"
|
|
74
|
+
spacing={1}
|
|
75
|
+
>
|
|
76
|
+
{node.depth > 0 && (
|
|
77
|
+
<HStack spacing="4px" mr={1}>
|
|
78
|
+
{Array.from({ length: node.depth }).map((_, i) => (
|
|
79
|
+
<Box
|
|
80
|
+
key={i}
|
|
81
|
+
w="3px"
|
|
82
|
+
h="3px"
|
|
83
|
+
rounded="full"
|
|
84
|
+
bg={isCurrent ? 'var(--accent)' : 'whiteAlpha.900'}
|
|
85
|
+
/>
|
|
86
|
+
))}
|
|
87
|
+
</HStack>
|
|
88
|
+
)}
|
|
89
|
+
<Text fontSize="xs" fontWeight={isCurrent ? 'bold' : 'medium'} noOfLines={1} isTruncated>
|
|
90
|
+
{node.name}
|
|
91
|
+
</Text>
|
|
92
|
+
</HStack>
|
|
93
|
+
)
|
|
94
|
+
})}
|
|
95
|
+
</VStack>
|
|
96
|
+
</ScrollIndicatorWrapper>
|
|
97
|
+
)
|
|
98
|
+
}
|