@likec4/diagram 1.35.0 → 1.36.1
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/bundle/{chunk-C0Eg81Gj.js → chunk-DHvr-RGh.js} +323 -311
- package/bundle/custom.js +52 -52
- package/bundle/index.js +1594 -749
- package/dist/LikeC4Diagram.js +6 -6
- package/dist/LikeC4Diagram.props.d.ts +2 -3
- package/dist/LikeC4ModelProvider.d.ts +3 -3
- package/dist/LikeC4ProjectsProvider.d.ts +17 -0
- package/dist/LikeC4ProjectsProvider.js +22 -0
- package/dist/LikeC4Styles.d.ts +1 -0
- package/dist/LikeC4Styles.js +94 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -3
- package/dist/base/BaseXYFlow.js +23 -26
- package/dist/base/primitives/MarkdownBlock.d.ts +7 -1
- package/dist/base/primitives/MarkdownBlock.js +1 -1
- package/dist/base/primitives/compound/CompoundActionButton.js +2 -2
- package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -2
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -4
- package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -4
- package/dist/base/primitives/compound/CompoundTitle.js +9 -8
- package/dist/base/primitives/compound/actionbtns.css.js +6 -6
- package/dist/base/primitives/edge/EdgeActionButton.js +2 -2
- package/dist/base/primitives/edge/EdgeContainer.js +4 -7
- package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -22
- package/dist/base/primitives/edge/EdgeLabel.css.js +6 -84
- package/dist/base/primitives/edge/EdgeLabel.js +16 -6
- package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -6
- package/dist/base/primitives/edge/EdgeMarkers.js +3 -3
- package/dist/base/primitives/edge/edge.css.d.ts +0 -2
- package/dist/base/primitives/edge/edge.css.js +1 -55
- package/dist/base/primitives/element/ElementActionButtons.js +2 -2
- package/dist/base/primitives/element/ElementDetailsButton.js +8 -7
- package/dist/base/primitives/element/ElementNodeContainer.css.js +4 -4
- package/dist/base/primitives/element/ElementNodeContainer.js +1 -4
- package/dist/base/primitives/element/ElementShape.css.js +11 -11
- package/dist/base/primitives/element/ElementTags.d.ts +1 -0
- package/dist/base/primitives/element/ElementTags.js +17 -14
- package/dist/bundle/LikeC4View.d.ts +1 -1
- package/dist/bundle/LikeC4View.js +7 -1
- package/dist/bundle/LikeC4View.props.d.ts +1 -2
- package/dist/bundle/ReactLikeC4.d.ts +1 -1
- package/dist/bundle/ViewNotFound.js +1 -1
- package/dist/bundle/index.d.ts +2 -1
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/styles.css.js +1 -1
- package/dist/components/ErrorFallback.js +1 -1
- package/dist/components/GithubIcon.d.ts +2 -0
- package/dist/components/GithubIcon.js +17 -0
- package/dist/components/Link.d.ts +4 -3
- package/dist/components/Link.js +84 -87
- package/dist/components/NavigationLink.d.ts +2 -2
- package/dist/components/SearchControl.css.js +6 -5
- package/dist/context/DiagramEventHandlers.d.ts +6 -6
- package/dist/context/DiagramEventHandlers.js +4 -7
- package/dist/globals.css.js +3 -0
- package/dist/hooks/useXYFlow.d.ts +10 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/likec4diagram/DiagramUI.js +2 -1
- package/dist/likec4diagram/custom/edges/NotePopover.css.js +2 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.js +7 -7
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +3 -3
- package/dist/likec4diagram/custom/edges/edges.css.js +4 -4
- package/dist/likec4diagram/custom/index.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -2
- package/dist/likec4diagram/ui/controls/styles.css.js +5 -5
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +4 -4
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +11 -11
- package/dist/likec4diagram/ui/notation/NotationPanel.js +2 -5
- package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.js +10 -10
- package/dist/likec4model/LikeC4ModelContext.d.ts +2 -1
- package/dist/likec4model/LikeC4ModelContext.js +10 -2
- package/dist/likec4model/LikeC4ProjectsContext.d.ts +7 -0
- package/dist/likec4model/LikeC4ProjectsContext.js +5 -0
- package/dist/likec4model/index.d.ts +1 -0
- package/dist/likec4model/useCurrentViewModel.d.ts +1 -0
- package/dist/likec4model/useCurrentViewModel.js +4 -1
- package/dist/likec4model/useLikeC4Project.d.ts +22 -0
- package/dist/likec4model/useLikeC4Project.js +23 -0
- package/dist/navigationpanel/NavigationPanel.js +15 -17
- package/dist/navigationpanel/NavigationPanelControls.js +34 -21
- package/dist/navigationpanel/NavigationPanelDropdown.js +33 -17
- package/dist/navigationpanel/_common.js +4 -1
- package/dist/navigationpanel/actor.d.ts +11 -15
- package/dist/navigationpanel/actor.js +14 -15
- package/dist/navigationpanel/controls/BurgerButton.js +5 -7
- package/dist/navigationpanel/controls/NavigationButtons.js +37 -24
- package/dist/navigationpanel/controls/OpenSource.js +1 -1
- package/dist/navigationpanel/controls/SearchControl.js +6 -4
- package/dist/navigationpanel/controls/ToggleReadonly.js +3 -3
- package/dist/navigationpanel/controls/ViewDetailsCard.d.ts +2 -0
- package/dist/navigationpanel/controls/ViewDetailsCard.js +232 -0
- package/dist/navigationpanel/controls/index.d.ts +1 -0
- package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -0
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +75 -0
- package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +19 -20
- package/dist/navigationpanel/editorpanel/styles.js +5 -5
- package/dist/navigationpanel/hooks.d.ts +2 -2
- package/dist/navigationpanel/styles.css.js +0 -2
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +12 -7
- package/dist/node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +14 -0
- package/dist/node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +14 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +18 -17
- package/dist/overlays/element-details/ElementDetailsCard.js +8 -13
- package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -4
- package/dist/overlays/element-details/TabPanelRelationships.css.js +7 -7
- package/dist/overlays/overlay/Overlay.css.d.ts +3 -3
- package/dist/overlays/overlay/Overlay.css.js +8 -7
- package/dist/overlays/relationship-details/SelectEdge.css.js +8 -8
- package/dist/overlays/relationships-browser/SelectElement.css.js +1 -1
- package/dist/search/Search.js +6 -6
- package/dist/search/components/ElementsColumn.css.js +5 -5
- package/dist/search/components/SearchByTags.js +3 -2
- package/dist/search/components/ViewsColum.js +1 -1
- package/dist/search/components/ViewsColumn.css.js +1 -1
- package/dist/search/components/_shared.css.js +3 -3
- package/dist/search/components/styles.css.js +5 -5
- package/dist/state/DiagramActorProvider.js +43 -25
- package/dist/state/diagram-machine.d.ts +29 -247
- package/dist/state/diagram-machine.js +16 -16
- package/dist/styles-min.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/package.json +10 -8
- package/panda.buildinfo.json +254 -326
- package/src/LikeC4Diagram.props.ts +2 -2
- package/src/LikeC4Diagram.tsx +2 -2
- package/src/LikeC4ModelProvider.tsx +4 -4
- package/src/LikeC4ProjectsProvider.tsx +41 -0
- package/src/LikeC4Styles.tsx +107 -0
- package/src/StaticLikeC4Diagram.tsx +3 -3
- package/src/base/BaseXYFlow.tsx +24 -29
- package/src/base/primitives/MarkdownBlock.tsx +11 -3
- package/src/base/primitives/compound/CompoundActionButton.tsx +2 -2
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -2
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +4 -13
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +0 -3
- package/src/base/primitives/compound/CompoundTitle.tsx +8 -8
- package/src/base/primitives/compound/actionbtns.css.ts +6 -6
- package/src/base/primitives/edge/EdgeActionButton.tsx +2 -2
- package/src/base/primitives/edge/EdgeContainer.tsx +3 -6
- package/src/base/primitives/edge/EdgeLabel.css.ts +4 -83
- package/src/base/primitives/edge/EdgeLabel.tsx +16 -10
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -6
- package/src/base/primitives/edge/EdgeMarkers.tsx +3 -3
- package/src/base/primitives/edge/edge.css.ts +0 -60
- package/src/base/primitives/element/ElementActionButtons.tsx +2 -2
- package/src/base/primitives/element/ElementDetailsButton.tsx +7 -7
- package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -4
- package/src/base/primitives/element/ElementNodeContainer.tsx +0 -3
- package/src/base/primitives/element/ElementShape.css.ts +11 -11
- package/src/base/primitives/element/ElementTags.tsx +17 -14
- package/src/bundle/LikeC4View.props.ts +1 -2
- package/src/bundle/LikeC4View.tsx +10 -3
- package/src/bundle/ReactLikeC4.tsx +1 -2
- package/src/bundle/ViewNotFound.tsx +1 -1
- package/src/bundle/index.ts +2 -1
- package/src/bundle/styles.css.ts +1 -1
- package/src/components/ErrorFallback.tsx +1 -1
- package/src/components/GithubIcon.tsx +16 -0
- package/src/components/Link.tsx +102 -113
- package/src/components/NavigationLink.tsx +2 -1
- package/src/components/SearchControl.css.ts +5 -5
- package/src/context/DiagramEventHandlers.tsx +12 -12
- package/src/globals.css +71 -0
- package/src/index.ts +5 -0
- package/src/likec4diagram/DiagramUI.tsx +8 -2
- package/src/likec4diagram/custom/edges/NotePopover.css.ts +2 -2
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +7 -7
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -3
- package/src/likec4diagram/custom/edges/edges.css.ts +4 -4
- package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +2 -2
- package/src/likec4diagram/ui/controls/styles.css.ts +5 -5
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +4 -5
- package/src/likec4diagram/ui/notation/NotationPanel.css.ts +11 -11
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +1 -4
- package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.ts +10 -10
- package/src/likec4model/{LikeC4ModelContext.ts → LikeC4ModelContext.tsx} +9 -1
- package/src/likec4model/LikeC4ProjectsContext.ts +9 -0
- package/src/likec4model/index.ts +8 -0
- package/src/likec4model/useCurrentViewModel.ts +4 -0
- package/src/likec4model/useLikeC4Project.ts +61 -0
- package/src/navigationpanel/NavigationPanel.tsx +16 -17
- package/src/navigationpanel/NavigationPanelControls.tsx +24 -46
- package/src/navigationpanel/NavigationPanelDropdown.tsx +32 -16
- package/src/navigationpanel/_common.tsx +4 -1
- package/src/navigationpanel/actor.ts +14 -15
- package/src/navigationpanel/controls/BurgerButton.tsx +5 -7
- package/src/navigationpanel/controls/NavigationButtons.tsx +9 -1
- package/src/navigationpanel/controls/OpenSource.tsx +1 -1
- package/src/navigationpanel/controls/SearchControl.tsx +6 -4
- package/src/navigationpanel/controls/ToggleReadonly.tsx +3 -3
- package/src/navigationpanel/controls/ViewDetailsCard.tsx +244 -0
- package/src/navigationpanel/controls/index.ts +1 -0
- package/src/navigationpanel/dropdown/ProjectsMenu.tsx +74 -0
- package/src/navigationpanel/editorpanel/EditorPanel.tsx +3 -3
- package/src/navigationpanel/editorpanel/ManualLayoutToolsButton.tsx +19 -22
- package/src/navigationpanel/editorpanel/styles.ts +5 -5
- package/src/navigationpanel/hooks.tsx +2 -2
- package/src/navigationpanel/styles.css.ts +0 -2
- package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +9 -4
- package/src/overlays/element-details/ElementDetailsCard.css.ts +17 -17
- package/src/overlays/element-details/ElementDetailsCard.tsx +8 -13
- package/src/overlays/element-details/TabPanelDeployments.css.ts +4 -4
- package/src/overlays/element-details/TabPanelRelationships.css.ts +7 -7
- package/src/overlays/overlay/Overlay.css.ts +7 -7
- package/src/overlays/relationship-details/SelectEdge.css.ts +8 -8
- package/src/overlays/relationships-browser/SelectElement.css.ts +1 -1
- package/src/search/Search.tsx +6 -6
- package/src/search/components/ElementsColumn.css.ts +5 -5
- package/src/search/components/SearchByTags.tsx +2 -2
- package/src/search/components/ViewsColum.tsx +1 -1
- package/src/search/components/ViewsColumn.css.ts +1 -1
- package/src/search/components/_shared.css.ts +3 -3
- package/src/search/components/styles.css.ts +5 -5
- package/src/state/DiagramActorProvider.tsx +56 -30
- package/src/state/diagram-machine.ts +22 -16
- package/dist/LikeC4CustomColors.d.ts +0 -2
- package/dist/LikeC4CustomColors.js +0 -45
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +0 -45
- package/src/LikeC4CustomColors.tsx +0 -85
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { DiagramView, WhereOperator } from '@likec4/core/types'
|
|
2
|
-
import { useCustomCompareEffect
|
|
1
|
+
import type { DiagramView, ViewId, WhereOperator } from '@likec4/core/types'
|
|
2
|
+
import { useCustomCompareEffect } from '@react-hookz/web'
|
|
3
3
|
import { useActorRef, useSelector } from '@xstate/react'
|
|
4
4
|
import { useStoreApi } from '@xyflow/react'
|
|
5
5
|
import { deepEqual, shallowEqual } from 'fast-equals'
|
|
6
6
|
import { type PropsWithChildren, useEffect, useRef, useState } from 'react'
|
|
7
7
|
import { ErrorBoundary } from '../components/ErrorFallback'
|
|
8
|
-
import {
|
|
8
|
+
import { useDiagramEventHandlers } from '../context/DiagramEventHandlers'
|
|
9
9
|
import { DiagramFeatures, useEnabledFeatures } from '../context/DiagramFeatures'
|
|
10
10
|
import { DiagramActorContextProvider } from '../hooks/safeContext'
|
|
11
|
-
import { useCurrentViewId } from '../hooks/useCurrentViewId'
|
|
12
11
|
import type { ViewPadding } from '../LikeC4Diagram.props'
|
|
13
12
|
import type { Types } from '../likec4diagram/types'
|
|
14
13
|
import { useViewToNodesEdges } from '../likec4diagram/useViewToNodesEdges'
|
|
@@ -16,7 +15,7 @@ import { CurrentViewModelContext } from '../likec4model/LikeC4ModelContext'
|
|
|
16
15
|
import { useLikeC4Model } from '../likec4model/useLikeC4Model'
|
|
17
16
|
import { type DiagramMachine, diagramMachine } from './diagram-machine'
|
|
18
17
|
import { syncManualLayoutActorLogic } from './syncManualLayoutActor'
|
|
19
|
-
import type { DiagramActorSnapshot } from './types'
|
|
18
|
+
import type { DiagramActorRef, DiagramActorSnapshot } from './types'
|
|
20
19
|
|
|
21
20
|
const selectToggledFeatures = (state: DiagramActorSnapshot) => {
|
|
22
21
|
if (state.context.features.enableReadOnly || state.context.activeWalkthrough) {
|
|
@@ -44,28 +43,12 @@ export function DiagramActorProvider({
|
|
|
44
43
|
nodesSelectable: boolean
|
|
45
44
|
where: WhereOperator | null
|
|
46
45
|
}>) {
|
|
47
|
-
const handlersRef =
|
|
46
|
+
const { handlersRef } = useDiagramEventHandlers()
|
|
48
47
|
const xystore = useStoreApi<Types.Node, Types.Edge>()
|
|
49
48
|
|
|
50
49
|
const machineRef = useRef<DiagramMachine | null>(null)
|
|
51
50
|
if (!machineRef.current) {
|
|
52
51
|
machineRef.current = diagramMachine.provide({
|
|
53
|
-
actions: {
|
|
54
|
-
'trigger:NavigateTo': ((_, { viewId }) => {
|
|
55
|
-
// Slightly defer callback for better responsiveness
|
|
56
|
-
setTimeout(() => {
|
|
57
|
-
handlersRef.current.onNavigateTo?.(viewId)
|
|
58
|
-
}, 40)
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
'trigger:OnChange': ((_, params) => {
|
|
62
|
-
handlersRef.current.onChange?.(params)
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
'trigger:OpenSource': ((_, params) => {
|
|
66
|
-
handlersRef.current.onOpenSource?.(params)
|
|
67
|
-
}),
|
|
68
|
-
},
|
|
69
52
|
actors: {
|
|
70
53
|
syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
|
|
71
54
|
actions: {
|
|
@@ -95,6 +78,8 @@ export function DiagramActorProvider({
|
|
|
95
78
|
},
|
|
96
79
|
)
|
|
97
80
|
|
|
81
|
+
useActorEventHandlers(actorRef)
|
|
82
|
+
|
|
98
83
|
const features = useEnabledFeatures()
|
|
99
84
|
useCustomCompareEffect(
|
|
100
85
|
() => {
|
|
@@ -128,7 +113,7 @@ export function DiagramActorProvider({
|
|
|
128
113
|
<DiagramActorContextProvider value={actorRef}>
|
|
129
114
|
<DiagramFeatures overrides={toggledFeatures}>
|
|
130
115
|
<ErrorBoundary>
|
|
131
|
-
<CurrentViewModelProvider>
|
|
116
|
+
<CurrentViewModelProvider viewId={view.id}>
|
|
132
117
|
{children}
|
|
133
118
|
</CurrentViewModelProvider>
|
|
134
119
|
</ErrorBoundary>
|
|
@@ -139,31 +124,72 @@ export function DiagramActorProvider({
|
|
|
139
124
|
|
|
140
125
|
function CurrentViewModelProvider({
|
|
141
126
|
children,
|
|
142
|
-
|
|
143
|
-
|
|
127
|
+
viewId,
|
|
128
|
+
}: PropsWithChildren<{
|
|
129
|
+
viewId: ViewId
|
|
130
|
+
}>) {
|
|
144
131
|
const likec4model = useLikeC4Model()
|
|
145
|
-
const [viewmodel, setViewmodel] = useState(() => likec4model.
|
|
132
|
+
const [viewmodel, setViewmodel] = useState(() => likec4model.findView(viewId))
|
|
146
133
|
|
|
147
134
|
useEffect(() => {
|
|
148
135
|
setViewmodel(current => {
|
|
149
136
|
const nextviewmodel = likec4model.findView(viewId)
|
|
150
137
|
if (!nextviewmodel) {
|
|
151
|
-
console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current
|
|
138
|
+
console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current?.id}`, {
|
|
152
139
|
currentViewModel: current,
|
|
153
140
|
likec4model,
|
|
154
141
|
})
|
|
155
142
|
return current
|
|
156
143
|
}
|
|
144
|
+
if (!nextviewmodel.isDiagram()) {
|
|
145
|
+
console.warn(`View "${viewId}" is not diagram.\nMake sure you have LikeC4ModelProvider with layouted model.`)
|
|
146
|
+
}
|
|
157
147
|
return nextviewmodel
|
|
158
148
|
})
|
|
159
149
|
}, [likec4model, viewId])
|
|
160
150
|
|
|
161
|
-
if (!viewmodel.isDiagram()) {
|
|
162
|
-
console.warn(`View "${viewId}" is not diagram.\nMake sure you have LikeC4ModelProvider with layouted model.`)
|
|
163
|
-
}
|
|
164
151
|
return (
|
|
165
152
|
<CurrentViewModelContext.Provider value={viewmodel}>
|
|
166
153
|
{children}
|
|
167
154
|
</CurrentViewModelContext.Provider>
|
|
168
155
|
)
|
|
169
156
|
}
|
|
157
|
+
|
|
158
|
+
function useActorEventHandlers(
|
|
159
|
+
actorRef: DiagramActorRef,
|
|
160
|
+
) {
|
|
161
|
+
const {
|
|
162
|
+
onChange,
|
|
163
|
+
onNavigateTo,
|
|
164
|
+
onOpenSource,
|
|
165
|
+
} = useDiagramEventHandlers()
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (!onChange) return
|
|
169
|
+
const subscription = actorRef.on('viewChange', ({ change }) => onChange({ change }))
|
|
170
|
+
return () => subscription.unsubscribe()
|
|
171
|
+
}, [actorRef, onChange])
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (!onNavigateTo) return
|
|
175
|
+
let frame: number
|
|
176
|
+
|
|
177
|
+
const subscription = actorRef.on('navigateTo', ({ viewId }) => {
|
|
178
|
+
cancelAnimationFrame(frame)
|
|
179
|
+
// Slightly defer callback for better responsiveness
|
|
180
|
+
frame = requestAnimationFrame(() => {
|
|
181
|
+
onNavigateTo(viewId)
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
return () => {
|
|
185
|
+
cancelAnimationFrame(frame)
|
|
186
|
+
subscription.unsubscribe()
|
|
187
|
+
}
|
|
188
|
+
}, [actorRef, onNavigateTo])
|
|
189
|
+
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (!onOpenSource) return
|
|
192
|
+
const subscription = actorRef.on('openSource', ({ params }) => onOpenSource(params))
|
|
193
|
+
return () => subscription.unsubscribe()
|
|
194
|
+
}, [actorRef, onOpenSource])
|
|
195
|
+
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
assertEvent,
|
|
36
36
|
assign,
|
|
37
37
|
cancel,
|
|
38
|
+
emit,
|
|
38
39
|
enqueueActions,
|
|
39
40
|
or,
|
|
40
41
|
raise,
|
|
@@ -179,6 +180,11 @@ export type Events =
|
|
|
179
180
|
| { type: 'tag.unhighlight' }
|
|
180
181
|
| { type: 'toggle.feature'; feature: FeatureName; forceValue?: boolean }
|
|
181
182
|
|
|
183
|
+
export type EmittedEvents =
|
|
184
|
+
| { type: 'navigateTo'; viewId: ViewId }
|
|
185
|
+
| { type: 'viewChange'; change: ViewChange }
|
|
186
|
+
| { type: 'openSource'; params: OpenSourceParams }
|
|
187
|
+
|
|
182
188
|
export type ActionArg = { context: Context; event: Events }
|
|
183
189
|
|
|
184
190
|
// TODO: naming convention for actors
|
|
@@ -193,6 +199,7 @@ const _diagramMachine = setup({
|
|
|
193
199
|
search: 'searchActorLogic'
|
|
194
200
|
},
|
|
195
201
|
events: {} as Events,
|
|
202
|
+
emitted: {} as EmittedEvents,
|
|
196
203
|
},
|
|
197
204
|
actors: {
|
|
198
205
|
syncManualLayoutActorLogic,
|
|
@@ -241,14 +248,20 @@ const _diagramMachine = setup({
|
|
|
241
248
|
},
|
|
242
249
|
},
|
|
243
250
|
actions: {
|
|
244
|
-
'trigger:NavigateTo': (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
'trigger:NavigateTo': emit(({ context }) => ({
|
|
252
|
+
type: 'navigateTo',
|
|
253
|
+
viewId: nonNullable(context.lastOnNavigate, 'Invalid state, lastOnNavigate is null').toView,
|
|
254
|
+
})),
|
|
255
|
+
|
|
256
|
+
'trigger:OnChange': emit((_, _params: { change: ViewChange }) => ({
|
|
257
|
+
type: 'viewChange',
|
|
258
|
+
change: _params.change,
|
|
259
|
+
})),
|
|
260
|
+
|
|
261
|
+
'trigger:OpenSource': emit((_, _params: OpenSourceParams) => ({
|
|
262
|
+
type: 'openSource',
|
|
263
|
+
params: _params,
|
|
264
|
+
})),
|
|
252
265
|
|
|
253
266
|
'assign lastClickedNode': assign(({ context, event }) => {
|
|
254
267
|
assertEvent(event, 'xyflow.nodeClick')
|
|
@@ -1023,14 +1036,7 @@ const _diagramMachine = setup({
|
|
|
1023
1036
|
'closeAllOverlays',
|
|
1024
1037
|
'closeSearch',
|
|
1025
1038
|
'stopSyncLayout',
|
|
1026
|
-
|
|
1027
|
-
enqueue({
|
|
1028
|
-
type: 'trigger:NavigateTo',
|
|
1029
|
-
params: {
|
|
1030
|
-
viewId: nonNullable(context.lastOnNavigate, 'Invalid state, lastOnNavigate is null').toView,
|
|
1031
|
-
},
|
|
1032
|
-
})
|
|
1033
|
-
}),
|
|
1039
|
+
'trigger:NavigateTo',
|
|
1034
1040
|
],
|
|
1035
1041
|
on: {
|
|
1036
1042
|
'update.view': {
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import '@likec4/core';
|
|
3
|
-
import { useMantineStyleNonce } from '@mantine/core';
|
|
4
|
-
import { memo, useState } from 'react';
|
|
5
|
-
import { isEmpty, entries } from 'remeda';
|
|
6
|
-
import { useLikeC4Specification } from './likec4model/useLikeC4Model.js';
|
|
7
|
-
import { useUpdateEffect } from './hooks/useUpdateEffect.js';
|
|
8
|
-
|
|
9
|
-
function toStyle(name, colors) {
|
|
10
|
-
const darken = (color) => `color-mix(in srgb, ${color} 80%, black)`;
|
|
11
|
-
return `
|
|
12
|
-
:where([data-likec4-color=${name}]) {
|
|
13
|
-
--colors-likec4-palette-hi-contrast: ${colors.elements.hiContrast};
|
|
14
|
-
--colors-likec4-palette-lo-contrast: ${colors.elements.loContrast};
|
|
15
|
-
--colors-likec4-palette-fill: ${colors.elements.fill};
|
|
16
|
-
--colors-likec4-palette-stroke: ${colors.elements.stroke};
|
|
17
|
-
--colors-likec4-relation-stroke: ${colors.relationships.lineColor};
|
|
18
|
-
--colors-likec4-relation-stroke-selected: color-mix(in srgb, ${colors.relationships.lineColor}, var(--colors-likec4-mix-color) 20%);
|
|
19
|
-
--colors-likec4-relation-label: ${colors.relationships.labelColor};
|
|
20
|
-
--colors-likec4-relation-label-bg: ${colors.relationships.labelBgColor};
|
|
21
|
-
}
|
|
22
|
-
:where(.likec4-compound-node[data-likec4-color=${name}]) {
|
|
23
|
-
--colors-likec4-palette-fill: ${darken(colors.elements.fill)};
|
|
24
|
-
--colors-likec4-palette-stroke: ${darken(colors.elements.stroke)};
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
28
|
-
function generateCustomColorStyles(customColors) {
|
|
29
|
-
return entries(customColors).map(([name, color]) => toStyle(name, color)).join("\n").trim();
|
|
30
|
-
}
|
|
31
|
-
const LikeC4CustomColors = memo(() => {
|
|
32
|
-
const customColors = useLikeC4Specification().customColors ?? {};
|
|
33
|
-
const [styles, setStyles] = useState(() => generateCustomColorStyles(customColors));
|
|
34
|
-
useUpdateEffect(() => {
|
|
35
|
-
setStyles(generateCustomColorStyles(customColors));
|
|
36
|
-
}, [customColors]);
|
|
37
|
-
const nonce = useMantineStyleNonce()?.();
|
|
38
|
-
if (isEmpty(customColors)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("style", { type: "text/css", dangerouslySetInnerHTML: { __html: styles }, nonce }) });
|
|
42
|
-
});
|
|
43
|
-
LikeC4CustomColors.displayName = "LikeC4CustomColors";
|
|
44
|
-
|
|
45
|
-
export { LikeC4CustomColors };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { NodeProps } from '../../../base';
|
|
2
|
-
import { RelationshipsBrowserTypes } from '../_types';
|
|
3
|
-
import { MemoExoticComponent } from 'react';
|
|
4
|
-
import { Dimmed } from '../../../base/types.Base';
|
|
5
|
-
import { ElementStyle, Color, Any, ViewId, Fqn, RichTextOrEmpty, IconUrl } from '@likec4/core';
|
|
6
|
-
import { Tags } from '@likec4/core/types/_aux';
|
|
7
|
-
export declare const ElementNode: MemoExoticComponent<(props: NodeProps<{
|
|
8
|
-
hovered?: boolean;
|
|
9
|
-
dimmed?: Dimmed;
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
style: ElementStyle;
|
|
13
|
-
color: Color;
|
|
14
|
-
title: string;
|
|
15
|
-
shape: "rectangle" | "person" | "browser" | "mobile" | "cylinder" | "storage" | "queue";
|
|
16
|
-
tags: Tags<Any>;
|
|
17
|
-
technology: string | null | undefined;
|
|
18
|
-
navigateTo: ViewId<string> | null | undefined;
|
|
19
|
-
column: RelationshipsBrowserTypes.Column;
|
|
20
|
-
fqn: Fqn;
|
|
21
|
-
icon: string | null;
|
|
22
|
-
ports: RelationshipsBrowserTypes.Ports;
|
|
23
|
-
existsInCurrentView: boolean;
|
|
24
|
-
description: RichTextOrEmpty;
|
|
25
|
-
}, string>) => import("react/jsx-runtime").JSX.Element>;
|
|
26
|
-
export declare const CompoundNode: MemoExoticComponent<(props: NodeProps<{
|
|
27
|
-
hovered?: boolean;
|
|
28
|
-
dimmed?: Dimmed;
|
|
29
|
-
style: ElementStyle;
|
|
30
|
-
color: Color;
|
|
31
|
-
title: string;
|
|
32
|
-
shape: "rectangle" | "person" | "browser" | "mobile" | "cylinder" | "storage" | "queue";
|
|
33
|
-
column: RelationshipsBrowserTypes.Column;
|
|
34
|
-
fqn: Fqn;
|
|
35
|
-
depth: number;
|
|
36
|
-
icon: IconUrl;
|
|
37
|
-
ports: RelationshipsBrowserTypes.Ports;
|
|
38
|
-
existsInCurrentView: boolean;
|
|
39
|
-
}, string>) => import("react/jsx-runtime").JSX.Element>;
|
|
40
|
-
export declare const EmptyNode: MemoExoticComponent<(props: NodeProps<RelationshipsBrowserTypes.EmptyNodeData, string>) => import("react/jsx-runtime").JSX.Element>;
|
|
41
|
-
type ElementPortsProps = NodeProps<Pick<RelationshipsBrowserTypes.ElementNodeData, 'ports' | 'height'>>;
|
|
42
|
-
export declare const ElementPorts: ({ data: { ports, height: h } }: ElementPortsProps) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
-
type CompoundPortsProps = NodeProps<Pick<RelationshipsBrowserTypes.CompoundNodeData, 'ports'>>;
|
|
44
|
-
export declare const CompoundPorts: ({ data }: CompoundPortsProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CustomColorDefinitions,
|
|
3
|
-
type ElementThemeColorValues,
|
|
4
|
-
type RelationshipThemeColorValues,
|
|
5
|
-
type ThemeColorValues,
|
|
6
|
-
nonexhaustive,
|
|
7
|
-
} from '@likec4/core'
|
|
8
|
-
import { useMantineStyleNonce } from '@mantine/core'
|
|
9
|
-
import { memo, useState } from 'react'
|
|
10
|
-
import { entries, isEmpty } from 'remeda'
|
|
11
|
-
import { useUpdateEffect } from './hooks'
|
|
12
|
-
import { useLikeC4Specification } from './likec4model/useLikeC4Model'
|
|
13
|
-
|
|
14
|
-
interface LikeC4CustomColorsProperties {
|
|
15
|
-
customColors: CustomColorDefinitions
|
|
16
|
-
}
|
|
17
|
-
function keyToCssVar(key: keyof RelationshipThemeColorValues | keyof ElementThemeColorValues): string {
|
|
18
|
-
switch (key) {
|
|
19
|
-
case 'lineColor':
|
|
20
|
-
return 'line'
|
|
21
|
-
case 'labelBgColor':
|
|
22
|
-
return 'label-bg'
|
|
23
|
-
case 'labelColor':
|
|
24
|
-
return 'label'
|
|
25
|
-
case 'fill':
|
|
26
|
-
return 'fill'
|
|
27
|
-
case 'stroke':
|
|
28
|
-
return 'stroke'
|
|
29
|
-
case 'hiContrast':
|
|
30
|
-
return 'hi-contrast'
|
|
31
|
-
case 'loContrast':
|
|
32
|
-
return 'lo-contrast'
|
|
33
|
-
default:
|
|
34
|
-
nonexhaustive(key)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function toStyle(name: String, colors: ThemeColorValues): String {
|
|
39
|
-
const darken = (color: string) => `color-mix(in srgb, ${color} 80%, black)`
|
|
40
|
-
return `
|
|
41
|
-
:where([data-likec4-color=${name}]) {
|
|
42
|
-
--colors-likec4-palette-hi-contrast: ${colors.elements.hiContrast};
|
|
43
|
-
--colors-likec4-palette-lo-contrast: ${colors.elements.loContrast};
|
|
44
|
-
--colors-likec4-palette-fill: ${colors.elements.fill};
|
|
45
|
-
--colors-likec4-palette-stroke: ${colors.elements.stroke};
|
|
46
|
-
--colors-likec4-relation-stroke: ${colors.relationships.lineColor};
|
|
47
|
-
--colors-likec4-relation-stroke-selected: color-mix(in srgb, ${colors.relationships.lineColor}, var(--colors-likec4-mix-color) 20%);
|
|
48
|
-
--colors-likec4-relation-label: ${colors.relationships.labelColor};
|
|
49
|
-
--colors-likec4-relation-label-bg: ${colors.relationships.labelBgColor};
|
|
50
|
-
}
|
|
51
|
-
:where(.likec4-compound-node[data-likec4-color=${name}]) {
|
|
52
|
-
--colors-likec4-palette-fill: ${darken(colors.elements.fill)};
|
|
53
|
-
--colors-likec4-palette-stroke: ${darken(colors.elements.stroke)};
|
|
54
|
-
}
|
|
55
|
-
`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function generateCustomColorStyles(customColors: CustomColorDefinitions) {
|
|
59
|
-
return entries(customColors)
|
|
60
|
-
.map(([name, color]) => toStyle(name, color))
|
|
61
|
-
.join('\n')
|
|
62
|
-
.trim()
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const LikeC4CustomColors = memo(() => {
|
|
66
|
-
const customColors = useLikeC4Specification().customColors ?? {}
|
|
67
|
-
const [styles, setStyles] = useState(() => generateCustomColorStyles(customColors))
|
|
68
|
-
|
|
69
|
-
useUpdateEffect(() => {
|
|
70
|
-
setStyles(generateCustomColorStyles(customColors))
|
|
71
|
-
}, [customColors])
|
|
72
|
-
|
|
73
|
-
const nonce = useMantineStyleNonce()?.()
|
|
74
|
-
|
|
75
|
-
if (isEmpty(customColors)) {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
<style type="text/css" dangerouslySetInnerHTML={{ __html: styles }} nonce={nonce} />
|
|
82
|
-
</>
|
|
83
|
-
)
|
|
84
|
-
})
|
|
85
|
-
LikeC4CustomColors.displayName = 'LikeC4CustomColors'
|