@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,141 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { parseMermaid } from './mermaid'
|
|
3
|
+
|
|
4
|
+
describe('Mermaid Importer Compliance', () => {
|
|
5
|
+
it('should parse a simple left-right graph (Example 1)', () => {
|
|
6
|
+
const code = `
|
|
7
|
+
graph LR;
|
|
8
|
+
A-->B;
|
|
9
|
+
A-->C;
|
|
10
|
+
B-->D;
|
|
11
|
+
C-->D;
|
|
12
|
+
`
|
|
13
|
+
const result = parseMermaid(code)
|
|
14
|
+
expect(result.elements.length).toBeGreaterThanOrEqual(4)
|
|
15
|
+
expect(result.connectors.length).toBe(4)
|
|
16
|
+
expect(result.warnings).toHaveLength(0)
|
|
17
|
+
|
|
18
|
+
const ids = result.elements.map(o => o.ref)
|
|
19
|
+
expect(ids).toContain('A')
|
|
20
|
+
expect(ids).toContain('B')
|
|
21
|
+
expect(ids).toContain('C')
|
|
22
|
+
expect(ids).toContain('D')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should parse a flowchart with labels (Example 2)', () => {
|
|
26
|
+
const code = `
|
|
27
|
+
flowchart LR
|
|
28
|
+
a[Chapter 1] --> b[Chapter 2] --> c[Chapter 3]
|
|
29
|
+
c-->d[Using Ledger]
|
|
30
|
+
c-->e[Using Trezor]
|
|
31
|
+
d-->f[Chapter 4]
|
|
32
|
+
e-->f
|
|
33
|
+
`
|
|
34
|
+
const result = parseMermaid(code)
|
|
35
|
+
expect(result.elements.length).toBe(6)
|
|
36
|
+
expect(result.connectors.length).toBe(6)
|
|
37
|
+
|
|
38
|
+
const chapter1 = result.elements.find(o => o.ref === 'a')
|
|
39
|
+
expect(chapter1?.name).toBe('Chapter 1')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should parse a graph with dependency sets (Example 4)', () => {
|
|
43
|
+
const code = `
|
|
44
|
+
graph TB
|
|
45
|
+
A & B--> C & D
|
|
46
|
+
`
|
|
47
|
+
const result = parseMermaid(code)
|
|
48
|
+
// A->C, A->D, B->C, B->D = 4 edges
|
|
49
|
+
expect(result.connectors.length).toBe(4)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should parse a flowchart with shapes and link variants (Example 6)', () => {
|
|
53
|
+
const code = `
|
|
54
|
+
graph LR
|
|
55
|
+
A[Square Rect] -- Link text --> B((Circle))
|
|
56
|
+
A --> C(Round Rect)
|
|
57
|
+
B --> D{Rhombus}
|
|
58
|
+
C --> D
|
|
59
|
+
`
|
|
60
|
+
const result = parseMermaid(code)
|
|
61
|
+
expect(result.elements.length).toBe(4)
|
|
62
|
+
expect(result.connectors.length).toBe(4)
|
|
63
|
+
|
|
64
|
+
const edgeWithText = result.connectors.find(e => e.sourceElementRef === 'A' && e.targetElementRef === 'B')
|
|
65
|
+
expect(edgeWithText?.label).toBe('Link text')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('should parse a top-down graph (Example 3)', () => {
|
|
69
|
+
const code = `
|
|
70
|
+
graph TD;
|
|
71
|
+
A-->B;
|
|
72
|
+
A-->C;
|
|
73
|
+
B-->D;
|
|
74
|
+
C-->D;
|
|
75
|
+
`
|
|
76
|
+
const result = parseMermaid(code)
|
|
77
|
+
expect(result.connectors.length).toBe(4)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('should parse a binary tree (Example 5)', () => {
|
|
81
|
+
const code = `
|
|
82
|
+
graph TB
|
|
83
|
+
A((1))-->B((2))
|
|
84
|
+
A-->C((3))
|
|
85
|
+
B-->D((4))
|
|
86
|
+
B-->E((5))
|
|
87
|
+
C-->F((6))
|
|
88
|
+
C-->G((7))
|
|
89
|
+
D-->H((8))
|
|
90
|
+
D-->I((9))
|
|
91
|
+
E-->J((10))
|
|
92
|
+
`
|
|
93
|
+
const result = parseMermaid(code)
|
|
94
|
+
expect(result.elements.length).toBe(10)
|
|
95
|
+
expect(result.connectors.length).toBe(9)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('should parse a flowchart with subgraphs (Example 11)', () => {
|
|
99
|
+
const code = `
|
|
100
|
+
graph TB
|
|
101
|
+
c1-->a2
|
|
102
|
+
subgraph one
|
|
103
|
+
a1-->a2
|
|
104
|
+
end
|
|
105
|
+
subgraph two
|
|
106
|
+
b1-->b2
|
|
107
|
+
end
|
|
108
|
+
subgraph three
|
|
109
|
+
c1-->c2
|
|
110
|
+
end
|
|
111
|
+
`
|
|
112
|
+
const result = parseMermaid(code)
|
|
113
|
+
expect(result.elements.length).toBeGreaterThanOrEqual(6)
|
|
114
|
+
expect(result.connectors.length).toBe(4)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should parse a decision tree (Example 14 simplified)', () => {
|
|
118
|
+
const code = `
|
|
119
|
+
graph TB
|
|
120
|
+
A[Do you think online service learning is right for you?]
|
|
121
|
+
B[Do you have time to design a service learning component?]
|
|
122
|
+
C[What is the civic or public purpose of your discipline?]
|
|
123
|
+
D[Do you have departmental or school support?]
|
|
124
|
+
E[Are you willing to be a trailblazer?]
|
|
125
|
+
F[What type of service learning to you want to plan?]
|
|
126
|
+
|
|
127
|
+
A==Yes==>B
|
|
128
|
+
A--No-->C
|
|
129
|
+
B==Yes==>D
|
|
130
|
+
B--No-->E
|
|
131
|
+
D==Yes==>F
|
|
132
|
+
D--No-->E
|
|
133
|
+
E==Yes==>F
|
|
134
|
+
E--No-->C
|
|
135
|
+
`
|
|
136
|
+
const result = parseMermaid(code)
|
|
137
|
+
const ids = result.elements.map(o => o.ref)
|
|
138
|
+
expect(result.elements.length, `IDs found: ${ids.join(', ')}`).toBe(6)
|
|
139
|
+
expect(result.connectors.length).toBe(8)
|
|
140
|
+
})
|
|
141
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { C4, Flowchart, isC4Diagram, isFlowchartDiagram, parseC4, parseFlowchart } from 'mermaid-ast'
|
|
2
|
+
import type { PlanConnector, PlanElement } from '@buf/tldiagramcom_diagram.bufbuild_es/diag/v1/workspace_service_pb'
|
|
3
|
+
|
|
4
|
+
export interface ParsedImport {
|
|
5
|
+
elements: PlanElement[]
|
|
6
|
+
connectors: PlanConnector[]
|
|
7
|
+
warnings: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function toPlanConnector(connector: Record<string, unknown>): PlanConnector {
|
|
11
|
+
return connector as unknown as PlanConnector
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function parseMermaid(code: string): ParsedImport {
|
|
15
|
+
const viewRef = 'root'
|
|
16
|
+
const result: ParsedImport = {
|
|
17
|
+
elements: [],
|
|
18
|
+
connectors: [],
|
|
19
|
+
warnings: [],
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (isFlowchartDiagram(code)) {
|
|
23
|
+
const diagram = Flowchart.from(parseFlowchart(code))
|
|
24
|
+
|
|
25
|
+
for (const node of diagram.nodes) {
|
|
26
|
+
result.elements.push({
|
|
27
|
+
ref: node.id,
|
|
28
|
+
name: node.text?.text || node.id,
|
|
29
|
+
kind: 'system',
|
|
30
|
+
placements: [{ parentRef: viewRef }],
|
|
31
|
+
} as PlanElement)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const link of diagram.links) {
|
|
35
|
+
result.connectors.push(toPlanConnector({
|
|
36
|
+
ref: `${link.source}:${link.target}`,
|
|
37
|
+
viewRef,
|
|
38
|
+
sourceElementRef: link.source,
|
|
39
|
+
targetElementRef: link.target,
|
|
40
|
+
label: link.text?.text || '',
|
|
41
|
+
}))
|
|
42
|
+
}
|
|
43
|
+
} else if (isC4Diagram(code)) {
|
|
44
|
+
const diagram = C4.from(parseC4(code))
|
|
45
|
+
|
|
46
|
+
const collectElements = (elements: typeof diagram.elements) => {
|
|
47
|
+
for (const el of elements) {
|
|
48
|
+
result.elements.push({
|
|
49
|
+
ref: el.alias,
|
|
50
|
+
name: el.label || el.alias,
|
|
51
|
+
kind: 'system',
|
|
52
|
+
placements: [{ parentRef: viewRef }],
|
|
53
|
+
} as PlanElement)
|
|
54
|
+
if ('children' in el && el.children) {
|
|
55
|
+
collectElements(el.children as typeof diagram.elements)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
collectElements(diagram.elements)
|
|
61
|
+
|
|
62
|
+
for (const rel of diagram.relationships) {
|
|
63
|
+
result.connectors.push(toPlanConnector({
|
|
64
|
+
ref: `${rel.from}:${rel.to}`,
|
|
65
|
+
viewRef,
|
|
66
|
+
sourceElementRef: rel.from,
|
|
67
|
+
targetElementRef: rel.to,
|
|
68
|
+
label: rel.label || '',
|
|
69
|
+
}))
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
result.warnings.push(`Unsupported diagram type`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return result
|
|
76
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react'
|
|
2
|
+
import type { PlatformFeatures } from './types'
|
|
3
|
+
import { PlatformContext } from './context'
|
|
4
|
+
|
|
5
|
+
export const PlatformProvider = ({
|
|
6
|
+
platform,
|
|
7
|
+
children
|
|
8
|
+
}: {
|
|
9
|
+
platform: PlatformFeatures<unknown>;
|
|
10
|
+
children: ReactNode
|
|
11
|
+
}) => {
|
|
12
|
+
return (
|
|
13
|
+
<PlatformContext.Provider value={platform}>
|
|
14
|
+
{children}
|
|
15
|
+
</PlatformContext.Provider>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { PlatformFeatures } from './types'
|
|
3
|
+
import { platform as localPlatform } from './local'
|
|
4
|
+
|
|
5
|
+
export const PlatformContext = createContext<PlatformFeatures<unknown>>(localPlatform)
|
|
6
|
+
|
|
7
|
+
export function usePlatform() {
|
|
8
|
+
return useContext(PlatformContext)
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Navigate, Route } from 'react-router-dom'
|
|
2
|
+
import type { PlatformFeatures } from './types'
|
|
3
|
+
|
|
4
|
+
export const platform: PlatformFeatures = {
|
|
5
|
+
hasAuth: false,
|
|
6
|
+
hasBilling: false,
|
|
7
|
+
initPlatform: async () => {},
|
|
8
|
+
getUpgradePath: () => null,
|
|
9
|
+
getRoutes: () => [],
|
|
10
|
+
getAuthenticatedRoutes: () => [],
|
|
11
|
+
getSettingsRoutes: () => [
|
|
12
|
+
<Route key="api-keys" path="api-keys" element={<Navigate to="/settings/appearance" replace />} />,
|
|
13
|
+
],
|
|
14
|
+
AuthLayout: () => null,
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface PlatformRouteContext<User = unknown> {
|
|
4
|
+
user: User | null
|
|
5
|
+
onLogin?: (user: User) => void
|
|
6
|
+
onLogout?: () => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PlatformFeatures<User = unknown> {
|
|
10
|
+
hasAuth?: boolean
|
|
11
|
+
hasBilling?: boolean
|
|
12
|
+
initPlatform: (orgId?: string) => Promise<void>
|
|
13
|
+
getUpgradePath?: () => string | null
|
|
14
|
+
getRoutes: (context: PlatformRouteContext<User>) => ReactNode[]
|
|
15
|
+
getAuthenticatedRoutes: (context: PlatformRouteContext<User>) => ReactNode[]
|
|
16
|
+
getSettingsRoutes: (context: PlatformRouteContext<User>) => ReactNode[]
|
|
17
|
+
AuthLayout: ComponentType<unknown>
|
|
18
|
+
connectRealtime?: (...args: unknown[]) => unknown
|
|
19
|
+
}
|
package/src/slots.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tldiagram/core-ui Extension Point Slots
|
|
3
|
+
*
|
|
4
|
+
* Slots are React.ReactNode props that host applications inject into core
|
|
5
|
+
* components to layer in optional host-app features (sharing, extra tools, etc.)
|
|
6
|
+
* without modifying the core library.
|
|
7
|
+
*
|
|
8
|
+
* Naming convention: `<area>Slot` describes WHERE the content renders.
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactNode } from 'react'
|
|
11
|
+
|
|
12
|
+
// ─── TopMenuBar ──────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
export interface TopMenuBarSlots {
|
|
15
|
+
/**
|
|
16
|
+
* Rendered in the right section of the desktop top bar, before the
|
|
17
|
+
* settings / user controls. Use for share buttons,
|
|
18
|
+
* buttons, notification bells, etc.
|
|
19
|
+
*
|
|
20
|
+
* @example <AvatarGroup /> or <ShareButton />
|
|
21
|
+
*/
|
|
22
|
+
rightSlot?: ReactNode
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Rendered inside the mobile "Options" bottom-nav menu, after the
|
|
26
|
+
* default settings items. Use for custom menu items, links, etc.
|
|
27
|
+
*
|
|
28
|
+
* @example <MenuItem>My Custom Action</MenuItem>
|
|
29
|
+
*/
|
|
30
|
+
mobileMenuSlot?: ReactNode
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Overrides the default user profile / settings controls.
|
|
34
|
+
* If provided, the default user avatar will be hidden.
|
|
35
|
+
*/
|
|
36
|
+
userControlsSlot?: ReactNode
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ─── ElementPanel ────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
export interface ElementPanelSlots {
|
|
42
|
+
/**
|
|
43
|
+
* Rendered at the bottom of the ElementPanel body.
|
|
44
|
+
*/
|
|
45
|
+
elementPanelAfterContentSlot?: ReactNode
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ─── ConnectorPanel ──────────────────────────────────────────────────────────
|
|
49
|
+
|
|
50
|
+
export interface ConnectorPanelSlots {
|
|
51
|
+
/**
|
|
52
|
+
* Rendered at the bottom of the ConnectorPanel body.
|
|
53
|
+
*/
|
|
54
|
+
connectorPanelAfterContentSlot?: ReactNode
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ─── ViewFloatingMenu ────────────────────────────────────────────────────────
|
|
58
|
+
|
|
59
|
+
export interface ViewFloatingMenuSlots {
|
|
60
|
+
/**
|
|
61
|
+
* Overrides or wraps the default Share button.
|
|
62
|
+
*/
|
|
63
|
+
shareSlot?: ReactNode
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Rendered inside the ViewFloatingMenu, after the existing toolbar
|
|
67
|
+
* buttons. Use for extra buttons, export to SaaS, etc.
|
|
68
|
+
*/
|
|
69
|
+
toolbarSlot?: ReactNode
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ─── ViewEditor ──────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
export interface ViewEditorSlots {
|
|
75
|
+
/**
|
|
76
|
+
* Rendered as a fixed overlay on top of the ReactFlow canvas.
|
|
77
|
+
*/
|
|
78
|
+
canvasOverlaySlot?: ReactNode
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ─── Combined ────────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* All extension points collected. Host apps can build a single
|
|
85
|
+
* "slots" object and pass it down via context or props.
|
|
86
|
+
*/
|
|
87
|
+
export interface CoreUISlots
|
|
88
|
+
extends TopMenuBarSlots,
|
|
89
|
+
ElementPanelSlots,
|
|
90
|
+
ConnectorPanelSlots,
|
|
91
|
+
ViewFloatingMenuSlots,
|
|
92
|
+
ViewEditorSlots { }
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.panel-search-container {
|
|
2
|
+
padding: 0.75rem;
|
|
3
|
+
/* 12px */
|
|
4
|
+
flex-shrink: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.panel-search-input {
|
|
8
|
+
background-color: rgba(255, 255, 255, 0.04) !important;
|
|
9
|
+
border: 1px solid rgba(255, 255, 255, 0.08) !important;
|
|
10
|
+
border-radius: 10px !important;
|
|
11
|
+
font-size: 0.75rem !important;
|
|
12
|
+
/* 12px / xs */
|
|
13
|
+
transition: all 0.2s ease !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.panel-search-input:focus {
|
|
17
|
+
background-color: rgba(255, 255, 255, 0.08) !important;
|
|
18
|
+
border-color: var(--accent) !important;
|
|
19
|
+
box-shadow: none !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.panel-action-button {
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
padding: 8px 12px;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
transition: all 0.2s ease;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.panel-action-button:hover:not(:disabled) {
|
|
33
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.panel-action-button:active:not(:disabled) {
|
|
37
|
+
transform: translateY(1px);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
.panel-action-icon-container {
|
|
42
|
+
width: 32px;
|
|
43
|
+
height: 32px;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
border-radius: 8px;
|
|
48
|
+
background-color: rgba(255, 255, 255, 0.06);
|
|
49
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
50
|
+
margin-right: 0.75rem;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
transition: all 0.2s ease;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.panel-action-button:hover .panel-action-icon-container {
|
|
56
|
+
color: var(--accent);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.panel-section-title {
|
|
60
|
+
font-size: 0.7rem;
|
|
61
|
+
font-weight: 700;
|
|
62
|
+
color: rgba(255, 255, 255, 0.9);
|
|
63
|
+
letter-spacing: 0.02em;
|
|
64
|
+
text-transform: uppercase;
|
|
65
|
+
padding: 1rem 1rem 0.75rem 1rem;
|
|
66
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* Base background color - dark blue/purplish */
|
|
3
|
+
--bg-main: #0d121e;
|
|
4
|
+
--bg-main-rgb: 13, 18, 30;
|
|
5
|
+
|
|
6
|
+
/* Element background color */
|
|
7
|
+
--bg-element: #2d3748;
|
|
8
|
+
--bg-element-rgb: 45, 55, 72;
|
|
9
|
+
|
|
10
|
+
/* Derived background colors */
|
|
11
|
+
--bg-canvas: color-mix(in srgb, var(--bg-main), black 15%);
|
|
12
|
+
--bg-header: rgba(var(--bg-main-rgb), 0.96);
|
|
13
|
+
--bg-menu: rgba(var(--bg-main-rgb), 0.98);
|
|
14
|
+
--bg-panel: rgba(var(--bg-main-rgb), 0.96);
|
|
15
|
+
--bg-card: rgba(var(--bg-main-rgb), 0.4);
|
|
16
|
+
--bg-card-solid: var(--bg-element);
|
|
17
|
+
--bg-dots: rgba(var(--bg-main-rgb), 0.6);
|
|
18
|
+
--bg-hover: rgba(255, 255, 255, 0.05);
|
|
19
|
+
|
|
20
|
+
/* Borders */
|
|
21
|
+
--border-main: rgba(255, 255, 255, 0.08);
|
|
22
|
+
|
|
23
|
+
/* Gradients */
|
|
24
|
+
--grad-header: linear-gradient(180deg, rgba(var(--bg-main-rgb), 0.96) 0%, rgba(var(--bg-main-rgb), 0.92) 100%);
|
|
25
|
+
--grad-panel: radial-gradient(circle at 50% -20%, rgba(var(--accent-rgb, 99, 179, 237), 0.15), transparent 80%);
|
|
26
|
+
--grad-card: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.05) 8%, rgba(255, 255, 255, 0.05) 92%, transparent 100%);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Chakra theme overrides or extensions can go here if needed */
|
|
30
|
+
.bg-main {
|
|
31
|
+
background-color: var(--bg-main);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.bg-element {
|
|
35
|
+
background-color: var(--bg-element);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.bg-canvas {
|
|
39
|
+
background-color: var(--bg-canvas);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.bg-header {
|
|
43
|
+
background-color: var(--bg-header);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.bg-menu {
|
|
47
|
+
background-color: var(--bg-menu);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.bg-panel {
|
|
51
|
+
background-color: var(--bg-panel);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.bg-card {
|
|
55
|
+
background-color: var(--bg-card);
|
|
56
|
+
}
|