@likec4/diagram 1.18.0 → 1.19.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/LICENSE +1 -1
- package/dist/LikeC4CustomColors.d.ts +7 -0
- package/dist/LikeC4CustomColors.js +30 -0
- package/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +13 -0
- package/dist/LikeC4Diagram.d.ts +6 -0
- package/dist/LikeC4Diagram.js +194 -0
- package/dist/LikeC4Diagram.props.d.ts +166 -0
- package/dist/LikeC4ModelProvider.d.ts +9 -0
- package/dist/LikeC4ModelProvider.js +12 -0
- package/dist/LikeC4Search.css.d.ts +1 -0
- package/dist/LikeC4Search.css.js +5 -0
- package/dist/LikeC4Search.d.ts +2 -0
- package/dist/LikeC4Search.js +96 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -0
- package/dist/StaticLikeC4Diagram.js +41 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/controls/Text.d.ts +2 -0
- package/dist/controls/Text.js +7 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
- package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
- package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
- package/dist/controls/action-buttons/ActionButton.css.js +5 -0
- package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
- package/dist/controls/action-buttons/ActionButton.js +66 -0
- package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
- package/dist/controls/action-buttons/ActionButtons.js +99 -0
- package/dist/globals.css.d.ts +1 -0
- package/dist/globals.css.js +92 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDiagramState.d.ts +6 -0
- package/dist/hooks/useDiagramState.js +27 -0
- package/dist/hooks/useMantinePortalProps.d.ts +9 -0
- package/dist/hooks/useMantinePortalProps.js +9 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSetState.js +19 -0
- package/dist/hooks/useUpdateEffect.d.ts +4 -0
- package/dist/hooks/useUpdateEffect.js +32 -0
- package/dist/hooks/useXYFlow.d.ts +270 -0
- package/dist/hooks/useXYFlow.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
- package/dist/likec4model/LikeC4ModelContext.js +5 -0
- package/dist/likec4model/index.d.ts +2 -0
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
- package/dist/likec4model/useLikeC4Model.d.ts +20 -0
- package/dist/likec4model/useLikeC4Model.js +55 -0
- package/dist/overlays/OverlayContext.d.ts +10 -0
- package/dist/overlays/OverlayContext.js +9 -0
- package/dist/overlays/Overlays.css.d.ts +3 -0
- package/dist/overlays/Overlays.css.js +7 -0
- package/dist/overlays/Overlays.d.ts +2 -0
- package/dist/overlays/Overlays.js +137 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
- package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
- package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
- package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
- package/dist/overlays/edge-details/SelectEdge.js +129 -0
- package/dist/overlays/edge-details/_types.d.ts +14 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
- package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
- package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
- package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
- package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
- package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
- package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
- package/dist/overlays/element-details/TabPanelStructure.js +91 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
- package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
- package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
- package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
- package/dist/overlays/relationships-of/SelectElement.js +126 -0
- package/dist/overlays/relationships-of/_types.d.ts +28 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
- package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
- package/dist/state/DiagramContext.d.ts +1609 -0
- package/dist/state/DiagramContext.js +101 -0
- package/dist/state/aligners.d.ts +42 -0
- package/dist/state/aligners.js +349 -0
- package/dist/state/diagram-to-xyflow.d.ts +11 -0
- package/dist/state/diagram-to-xyflow.js +113 -0
- package/dist/state/diagramStore.d.ts +1705 -0
- package/dist/state/diagramStore.js +808 -0
- package/dist/state/diagramStore.layout.d.ts +4 -0
- package/dist/state/diagramStore.layout.js +56 -0
- package/dist/style.css +1 -0
- package/dist/theme-vars.css.d.ts +72 -0
- package/dist/theme-vars.css.js +6 -0
- package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
- package/dist/theme-vars.d.ts +3 -0
- package/dist/theme-vars.js +5 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.css.js +11 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.js +159 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
- package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.js +156 -0
- package/dist/ui/EnsureMantine.d.ts +7 -0
- package/dist/ui/EnsureMantine.js +14 -0
- package/dist/ui/FramerMotionConfig.d.ts +2 -0
- package/dist/ui/FramerMotionConfig.js +14 -0
- package/dist/ui/Link.d.ts +4 -0
- package/dist/ui/Link.js +36 -0
- package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
- package/dist/ui/notation/NotationPanel.css.js +16 -0
- package/dist/ui/notation/NotationPanel.d.ts +1 -0
- package/dist/ui/notation/NotationPanel.js +250 -0
- package/dist/ui/notation/index.d.ts +1 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
- package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
- package/dist/ui/top-left/TopLeftPanel.js +211 -0
- package/dist/ui/top-left/_shared.d.ts +7 -0
- package/dist/ui/top-left/_shared.js +22 -0
- package/dist/ui/top-left/styles.css.d.ts +8 -0
- package/dist/ui/top-left/styles.css.js +17 -0
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/vector.d.ts +24 -0
- package/dist/utils/vector.js +55 -0
- package/dist/xyflow/EdgeMarkers.d.ts +12 -0
- package/dist/xyflow/EdgeMarkers.js +192 -0
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
- package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
- package/dist/xyflow/XYFlow.d.ts +8 -0
- package/dist/xyflow/XYFlow.js +145 -0
- package/dist/xyflow/XYFlowBackground.d.ts +10 -0
- package/dist/xyflow/XYFlowBackground.js +25 -0
- package/dist/xyflow/XYFlowInner.d.ts +8 -0
- package/dist/xyflow/XYFlowInner.js +41 -0
- package/dist/xyflow/const.d.ts +7 -0
- package/dist/xyflow/const.js +12 -0
- package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
- package/dist/xyflow/edges/EdgeLabel.js +160 -0
- package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
- package/dist/xyflow/edges/RelationshipEdge.js +443 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
- package/dist/xyflow/edges/edges.css.d.ts +17 -0
- package/dist/xyflow/edges/edges.css.js +37 -0
- package/dist/xyflow/edges/utils.d.ts +16 -0
- package/dist/xyflow/edges/utils.js +24 -0
- package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
- package/dist/xyflow/nodes/AnimateVariants.js +123 -0
- package/dist/xyflow/nodes/Node.css.d.ts +3 -0
- package/dist/xyflow/nodes/Node.css.js +9 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
- package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
- package/dist/xyflow/nodes/compound/index.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
- package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.js +190 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
- package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
- package/dist/xyflow/nodes/element/element.css.js +31 -0
- package/dist/xyflow/nodes/element/index.d.ts +1 -0
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
- package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
- package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
- package/dist/xyflow/types.d.ts +36 -0
- package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
- package/dist/xyflow/useLayoutConstraints.js +226 -0
- package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
- package/dist/xyflow/useXYFlowEvents.js +275 -0
- package/dist/xyflow/utils.d.ts +22 -0
- package/dist/xyflow/utils.js +72 -0
- package/package.json +34 -27
- package/src/LikeC4Diagram.tsx +4 -4
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +39 -90
- package/src/controls/Text.ts +5 -0
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
- package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
- package/src/controls/action-buttons/ActionButton.css.ts +29 -0
- package/src/controls/action-buttons/ActionButton.tsx +66 -0
- package/src/controls/action-buttons/ActionButtons.tsx +138 -0
- package/src/hooks/useXYFlow.ts +8 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
- package/src/overlays/edge-details/_types.ts +13 -37
- package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
- package/src/overlays/shared/xyflow/_types.ts +87 -0
- package/src/state/diagram-to-xyflow.ts +6 -7
- package/src/state/diagramStore.layout.ts +3 -4
- package/src/state/diagramStore.ts +35 -37
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +6 -6
- package/src/utils/types.ts +6 -0
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
- package/src/xyflow/XYFlow.tsx +2 -2
- package/src/xyflow/edges/EdgeLabel.tsx +25 -18
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
- package/src/xyflow/edges/edges.css.ts +68 -74
- package/src/xyflow/edges/utils.ts +6 -6
- package/src/xyflow/nodes/AnimateVariants.ts +143 -0
- package/src/xyflow/nodes/Node.css.ts +44 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
- package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
- package/src/xyflow/nodes/element/element.css.ts +0 -57
- package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +9 -9
- package/src/xyflow/useXYFlowEvents.ts +13 -30
- package/src/xyflow/utils.ts +2 -2
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -11,14 +11,14 @@ const selector = (s: DiagramState) => ({
|
|
|
11
11
|
id: s.view.id,
|
|
12
12
|
title: s.view.title ?? 'untitled',
|
|
13
13
|
description: s.view.description,
|
|
14
|
-
links: s.view.links
|
|
14
|
+
links: s.view.links,
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
export default function DiagramTitlePanel() {
|
|
18
18
|
const { id, title, description, links } = useDiagramState(selector)
|
|
19
19
|
const [isCollapsed, setCollapsed] = useLocalStorage({
|
|
20
20
|
key: 'diagram-title-webview-collapsed',
|
|
21
|
-
defaultValue: false
|
|
21
|
+
defaultValue: false,
|
|
22
22
|
})
|
|
23
23
|
const toggle = () => setCollapsed(v => !v)
|
|
24
24
|
|
|
@@ -46,11 +46,11 @@ export default function DiagramTitlePanel() {
|
|
|
46
46
|
animate={{ opacity: 1, scale: 1 }}
|
|
47
47
|
exit={{
|
|
48
48
|
opacity: 0.05,
|
|
49
|
-
scale: 0.6
|
|
49
|
+
scale: 0.6,
|
|
50
50
|
}}
|
|
51
51
|
className={clsx('react-flow__panel', css.container)}
|
|
52
52
|
style={{
|
|
53
|
-
transformOrigin: 'left center'
|
|
53
|
+
transformOrigin: 'left center',
|
|
54
54
|
}}
|
|
55
55
|
>
|
|
56
56
|
<Card
|
|
@@ -116,7 +116,7 @@ export default function DiagramTitlePanel() {
|
|
|
116
116
|
fw={500}
|
|
117
117
|
c={'dimmed'}
|
|
118
118
|
style={{
|
|
119
|
-
userSelect: 'all'
|
|
119
|
+
userSelect: 'all',
|
|
120
120
|
}}>
|
|
121
121
|
<span style={{ userSelect: 'none' }}>id:{' '}</span>
|
|
122
122
|
{id}
|
|
@@ -152,7 +152,7 @@ export default function DiagramTitlePanel() {
|
|
|
152
152
|
gap={3}
|
|
153
153
|
justify="stretch"
|
|
154
154
|
align="stretch">
|
|
155
|
-
{links.map((link) => <Link link={link} />)}
|
|
155
|
+
{links.map((link) => <Link link={link} key={link.url} />)}
|
|
156
156
|
</Stack>
|
|
157
157
|
)}
|
|
158
158
|
</>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Edge, Node } from '@xyflow/react'
|
|
2
|
+
import type { Merge } from 'type-fest'
|
|
3
|
+
|
|
4
|
+
export type AddNodeData<T extends Node, Data> = Omit<T, 'data'> & { data: Merge<T['data'], Data> }
|
|
5
|
+
|
|
6
|
+
export type AddEdgeData<T extends Edge, Data> = Omit<T, 'data'> & { data: Merge<T['data'], Data> }
|
|
@@ -5,7 +5,7 @@ import { getBoundsOfRects, getViewportForBounds } from '@xyflow/system'
|
|
|
5
5
|
import { useUpdateEffect } from '../hooks'
|
|
6
6
|
import { useDiagramState, useDiagramStoreApi } from '../hooks/useDiagramState'
|
|
7
7
|
import { MinZoom } from './const'
|
|
8
|
-
import type {
|
|
8
|
+
import type { DiagramFlowTypes } from './types'
|
|
9
9
|
import { nodeToRect } from './utils'
|
|
10
10
|
|
|
11
11
|
export function SelectEdgesOnNodeFocus() {
|
|
@@ -22,8 +22,8 @@ export function SelectEdgesOnNodeFocus() {
|
|
|
22
22
|
return
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const edgeChanges = [] as EdgeChange<
|
|
26
|
-
const nodeChanges = [] as NodeChange<
|
|
25
|
+
const edgeChanges = [] as EdgeChange<DiagramFlowTypes.Edge>[]
|
|
26
|
+
const nodeChanges = [] as NodeChange<DiagramFlowTypes.Node>[]
|
|
27
27
|
const {
|
|
28
28
|
edgeLookup,
|
|
29
29
|
nodeLookup,
|
package/src/xyflow/XYFlow.tsx
CHANGED
|
@@ -8,9 +8,9 @@ import { MaxZoom, MinZoom } from './const'
|
|
|
8
8
|
import { RelationshipEdge } from './edges/RelationshipEdge'
|
|
9
9
|
import { CompoundNode } from './nodes/compound'
|
|
10
10
|
import { ElementNode } from './nodes/element'
|
|
11
|
-
import { XYFlowEdge, XYFlowNode } from './types'
|
|
12
11
|
import { useLayoutConstraints } from './useLayoutConstraints'
|
|
13
12
|
import { useXYFlowEvents } from './useXYFlowEvents'
|
|
13
|
+
import type { DiagramFlowTypes } from './types'
|
|
14
14
|
|
|
15
15
|
const nodeTypes = {
|
|
16
16
|
element: ElementNode,
|
|
@@ -117,7 +117,7 @@ export function XYFlow({
|
|
|
117
117
|
// }, [])
|
|
118
118
|
|
|
119
119
|
return (
|
|
120
|
-
<ReactFlow<
|
|
120
|
+
<ReactFlow<DiagramFlowTypes.Node, DiagramFlowTypes.Edge>
|
|
121
121
|
className={className}
|
|
122
122
|
style={style}
|
|
123
123
|
{...colorMode && { colorMode }}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { extractStep, isStepEdgeId
|
|
1
|
+
import { type ViewId, extractStep, isStepEdgeId } from '@likec4/core'
|
|
2
2
|
import {
|
|
3
|
+
type BoxProps,
|
|
3
4
|
ActionIcon,
|
|
4
5
|
Box,
|
|
5
|
-
type BoxProps,
|
|
6
6
|
Button,
|
|
7
7
|
CloseButton,
|
|
8
8
|
Group,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
PopoverTarget,
|
|
12
12
|
ScrollAreaAutosize,
|
|
13
13
|
Stack,
|
|
14
|
-
Text
|
|
14
|
+
Text,
|
|
15
15
|
} from '@mantine/core'
|
|
16
16
|
import { useDebouncedEffect } from '@react-hookz/web'
|
|
17
17
|
import { IconZoomScan } from '@tabler/icons-react'
|
|
@@ -21,21 +21,21 @@ import { type PropsWithChildren, type ReactNode, useState } from 'react'
|
|
|
21
21
|
import { isTruthy } from 'remeda'
|
|
22
22
|
import { useDiagramState, useDiagramStoreApi, useMantinePortalProps } from '../../hooks'
|
|
23
23
|
import { useLikeC4Model } from '../../likec4model/useLikeC4Model'
|
|
24
|
-
import type {
|
|
24
|
+
import type { DiagramFlowTypes } from '../types'
|
|
25
25
|
import { stopPropagation } from '../utils'
|
|
26
26
|
import * as edgesCss from './edges.css'
|
|
27
27
|
import { RelationshipsDropdownMenu } from './RelationshipsDropdownMenu'
|
|
28
28
|
|
|
29
29
|
export interface EdgeLabelProps extends Omit<BoxProps, 'label'> {
|
|
30
30
|
isDimmed: boolean
|
|
31
|
-
edgeData:
|
|
31
|
+
edgeData: DiagramFlowTypes.DiagramEdgeData
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const EdgeLabel = ({
|
|
35
35
|
isDimmed,
|
|
36
36
|
edgeData: {
|
|
37
37
|
label,
|
|
38
|
-
edge
|
|
38
|
+
edge,
|
|
39
39
|
},
|
|
40
40
|
...props
|
|
41
41
|
}: EdgeLabelProps) => {
|
|
@@ -43,11 +43,11 @@ export const EdgeLabel = ({
|
|
|
43
43
|
const {
|
|
44
44
|
enableRelationshipDetails,
|
|
45
45
|
isActiveWalkthroughStep,
|
|
46
|
-
hasOnNavigateTo
|
|
46
|
+
hasOnNavigateTo,
|
|
47
47
|
} = useDiagramState(s => ({
|
|
48
48
|
enableRelationshipDetails: s.enableRelationshipDetails,
|
|
49
49
|
isActiveWalkthroughStep: s.activeWalkthrough?.stepId === edge.id,
|
|
50
|
-
hasOnNavigateTo: !!s.onNavigateTo
|
|
50
|
+
hasOnNavigateTo: !!s.onNavigateTo,
|
|
51
51
|
}))
|
|
52
52
|
const notes = isActiveWalkthroughStep ? (edge.notes ?? null) : null
|
|
53
53
|
const stepNum = isStepEdgeId(edge.id) ? extractStep(edge.id) : null
|
|
@@ -79,13 +79,20 @@ export const EdgeLabel = ({
|
|
|
79
79
|
{stepNum}
|
|
80
80
|
</Box>
|
|
81
81
|
)}
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
<Stack gap={4} align="center">
|
|
83
|
+
{isTruthy(label?.text) && (
|
|
84
|
+
<Text component="div" className={edgesCss.edgeLabelText} lineClamp={5}>
|
|
85
|
+
{label.text}
|
|
86
|
+
</Text>
|
|
87
|
+
)}
|
|
88
|
+
{isTruthy(edge.technology) && (
|
|
89
|
+
<Text component="div" className={edgesCss.edgeLabelTechnology}>
|
|
90
|
+
{'[ ' + edge.technology + ' ]'}
|
|
91
|
+
</Text>
|
|
92
|
+
)}
|
|
93
|
+
{navigateTo && <NavigateToBtn viewId={navigateTo} />}
|
|
94
|
+
</Stack>
|
|
95
|
+
</Box>,
|
|
89
96
|
)}
|
|
90
97
|
</EdgeLabelRenderer>
|
|
91
98
|
)
|
|
@@ -95,11 +102,11 @@ const NotePopover = ({ notes, children }: PropsWithChildren<{ notes: string }>)
|
|
|
95
102
|
const {
|
|
96
103
|
nextDynamicStep,
|
|
97
104
|
hasNext,
|
|
98
|
-
hasPrevious
|
|
105
|
+
hasPrevious,
|
|
99
106
|
} = useDiagramState(s => ({
|
|
100
107
|
nextDynamicStep: s.nextDynamicStep,
|
|
101
108
|
hasNext: s.activeWalkthrough?.hasNext ?? false,
|
|
102
|
-
hasPrevious: s.activeWalkthrough?.hasPrevious ?? false
|
|
109
|
+
hasPrevious: s.activeWalkthrough?.hasPrevious ?? false,
|
|
103
110
|
}))
|
|
104
111
|
|
|
105
112
|
const [isOpened, setIsOpened] = useState(false)
|
|
@@ -110,7 +117,7 @@ const NotePopover = ({ notes, children }: PropsWithChildren<{ notes: string }>)
|
|
|
110
117
|
setIsOpened(true)
|
|
111
118
|
},
|
|
112
119
|
[],
|
|
113
|
-
300
|
|
120
|
+
300,
|
|
114
121
|
)
|
|
115
122
|
|
|
116
123
|
return (
|
|
@@ -20,11 +20,11 @@ import { useXYStoreApi } from '../../hooks/useXYFlow'
|
|
|
20
20
|
import { vector, VectorImpl } from '../../utils/vector'
|
|
21
21
|
import { ZIndexes } from '../const'
|
|
22
22
|
import { EdgeMarkers, type EdgeMarkerType } from '../EdgeMarkers'
|
|
23
|
-
import { type XYFlowEdge } from '../types'
|
|
24
23
|
import { bezierControlPoints } from '../utils'
|
|
25
24
|
import { EdgeLabel } from './EdgeLabel'
|
|
26
25
|
import * as edgesCss from './edges.css'
|
|
27
26
|
import { getNodeIntersectionFromCenterToPoint } from './utils'
|
|
27
|
+
import type { DiagramFlowTypes } from '../types'
|
|
28
28
|
// import { getEdgeParams } from './utils'
|
|
29
29
|
|
|
30
30
|
// function getBend(a: XYPosition, b: XYPosition, c: XYPosition, size = 8): string {
|
|
@@ -115,7 +115,9 @@ const sameControlPoints = (a: XYPosition[] | null, b: XYPosition[] | null) => {
|
|
|
115
115
|
return a.every((ap, i) => isSamePoint(ap, b[i]!))
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
type DiagramEdgeProps = EdgeProps<DiagramFlowTypes.Edge>
|
|
119
|
+
|
|
120
|
+
const isEqualProps = (prev: DiagramEdgeProps, next: DiagramEdgeProps) => (
|
|
119
121
|
prev.id === next.id
|
|
120
122
|
&& eq(prev.source, next.source)
|
|
121
123
|
&& eq(prev.target, next.target)
|
|
@@ -134,7 +136,7 @@ const curve = d3line<XYPosition>()
|
|
|
134
136
|
.x(d => d.x)
|
|
135
137
|
.y(d => d.y)
|
|
136
138
|
|
|
137
|
-
export const RelationshipEdge = memo<
|
|
139
|
+
export const RelationshipEdge = memo<DiagramEdgeProps>(function RelationshipEdgeR({
|
|
138
140
|
id,
|
|
139
141
|
data,
|
|
140
142
|
sourceX,
|
|
@@ -22,8 +22,8 @@ import { forwardRef, Fragment, type MouseEventHandler, type PropsWithChildren, u
|
|
|
22
22
|
import { filter, isTruthy, map, partition, pick, pipe } from 'remeda'
|
|
23
23
|
import { useDiagramState, useDiagramStoreApi, useMantinePortalProps, useXYNodesData } from '../../hooks'
|
|
24
24
|
import { Link } from '../../ui/Link'
|
|
25
|
-
import type { RelationshipData } from '../types'
|
|
26
25
|
import * as css from './RelationshipsDropdownMenu.css'
|
|
26
|
+
import type { DiagramFlowTypes } from '../types'
|
|
27
27
|
|
|
28
28
|
const stopPropagation: MouseEventHandler = (e) => e.stopPropagation()
|
|
29
29
|
|
|
@@ -44,7 +44,7 @@ export function RelationshipsDropdownMenu({
|
|
|
44
44
|
likec4model,
|
|
45
45
|
children
|
|
46
46
|
}: PropsWithChildren<{
|
|
47
|
-
edge:
|
|
47
|
+
edge: DiagramFlowTypes.DiagramEdgeData['edge']
|
|
48
48
|
disabled?: boolean | undefined
|
|
49
49
|
likec4model: LikeC4Model
|
|
50
50
|
}>) {
|
|
@@ -157,7 +157,7 @@ const Relationship = forwardRef<
|
|
|
157
157
|
HTMLDivElement,
|
|
158
158
|
StackProps & {
|
|
159
159
|
relationship: LikeC4Model.AnyRelation
|
|
160
|
-
edge:
|
|
160
|
+
edge: DiagramFlowTypes.DiagramEdgeData['edge']
|
|
161
161
|
sourceNode: DiagramNode
|
|
162
162
|
targetNode: DiagramNode
|
|
163
163
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rem } from '@mantine/core'
|
|
2
2
|
import { createVar, fallbackVar, globalStyle, keyframes, style } from '@vanilla-extract/css'
|
|
3
|
-
import { mantine, vars, xyvars } from '../../theme-vars'
|
|
3
|
+
import { mantine, transitions, vars, xyvars } from '../../theme-vars'
|
|
4
4
|
|
|
5
5
|
const mixColor = createVar('mix-color')
|
|
6
6
|
|
|
@@ -11,16 +11,16 @@ export const container = style({
|
|
|
11
11
|
[xyvars.edge.strokeSelected]: `color-mix(in srgb, ${vars.relation.lineColor}, ${mixColor} 35%)`,
|
|
12
12
|
[xyvars.edge.labelColor]: `color-mix(in srgb, ${vars.relation.labelColor}, rgba(255 255 255 / 0.85) 40%)`,
|
|
13
13
|
[xyvars.edge.labelBgColor]: `color-mix(in srgb, ${vars.relation.labelBgColor}, transparent 40%)`,
|
|
14
|
-
[xyvars.edge.strokeWidth]: '3'
|
|
15
|
-
}
|
|
14
|
+
[xyvars.edge.strokeWidth]: '3',
|
|
15
|
+
},
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
globalStyle(`:where([data-mantine-color-scheme="dark"]) ${container}`, {
|
|
19
19
|
vars: {
|
|
20
20
|
[mixColor]: `white`,
|
|
21
21
|
[xyvars.edge.labelColor]: vars.relation.labelColor,
|
|
22
|
-
[xyvars.edge.labelBgColor]: `color-mix(in srgb, ${vars.relation.labelBgColor}, transparent 50%)
|
|
23
|
-
}
|
|
22
|
+
[xyvars.edge.labelBgColor]: `color-mix(in srgb, ${vars.relation.labelBgColor}, transparent 50%)`,
|
|
23
|
+
},
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
const isSelected = '.react-flow__edge.selected'
|
|
@@ -28,29 +28,29 @@ const isSelected = '.react-flow__edge.selected'
|
|
|
28
28
|
globalStyle(`:where(${isSelected}) ${container}`, {
|
|
29
29
|
vars: {
|
|
30
30
|
[xyvars.edge.stroke]: xyvars.edge.strokeSelected,
|
|
31
|
-
[xyvars.edge.strokeWidth]: '3'
|
|
32
|
-
}
|
|
31
|
+
[xyvars.edge.strokeWidth]: '3',
|
|
32
|
+
},
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
globalStyle(`${container}:is([data-edge-hovered='true'],[data-edge-active='true'])`, {
|
|
36
36
|
vars: {
|
|
37
37
|
// [xyvars.edge.stroke]: `color-mix(in srgb, ${vars.relation.lineColor}, ${mixColor} 35%)`,
|
|
38
38
|
[xyvars.edge.stroke]: xyvars.edge.strokeSelected,
|
|
39
|
-
[xyvars.edge.strokeWidth]: '3'
|
|
40
|
-
}
|
|
39
|
+
[xyvars.edge.strokeWidth]: '3',
|
|
40
|
+
},
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
globalStyle(`:where(${isSelected}) ${container}[data-edge-hovered='true']`, {
|
|
44
44
|
vars: {
|
|
45
|
-
[xyvars.edge.strokeWidth]: '4'
|
|
46
|
-
}
|
|
45
|
+
[xyvars.edge.strokeWidth]: '4',
|
|
46
|
+
},
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
globalStyle(`.likec4-diagram .react-flow__edges > svg`, {
|
|
50
|
-
mixBlendMode: 'plus-lighter'
|
|
50
|
+
mixBlendMode: 'plus-lighter',
|
|
51
51
|
})
|
|
52
52
|
globalStyle(`:where([data-mantine-color-scheme="light"]) .likec4-diagram .react-flow__edges > svg`, {
|
|
53
|
-
mixBlendMode: 'screen'
|
|
53
|
+
mixBlendMode: 'screen',
|
|
54
54
|
})
|
|
55
55
|
|
|
56
56
|
export const dimmed = style({})
|
|
@@ -60,7 +60,7 @@ globalStyle(`.likec4-diagram .react-flow__edges > svg:has(${dimmed})`, {
|
|
|
60
60
|
transition: 'opacity 600ms ease-in-out, filter 600ms ease-in-out',
|
|
61
61
|
transitionDelay: '200ms',
|
|
62
62
|
filter: `grayscale(0.85) ${fallbackVar(vars.safariAnimationHook, 'blur(1px)')}`,
|
|
63
|
-
willChange: 'opacity, filter'
|
|
63
|
+
willChange: 'opacity, filter',
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
export const edgePathBg = style({
|
|
@@ -74,15 +74,15 @@ export const edgePathBg = style({
|
|
|
74
74
|
selectors: {
|
|
75
75
|
[`:where(${isSelected}, [data-edge-active='true'], [data-edge-hovered='true']) &`]: {
|
|
76
76
|
strokeWidth: `calc(${xyvars.edge.strokeWidth} + 8)`,
|
|
77
|
-
strokeOpacity: 0.15
|
|
78
|
-
}
|
|
79
|
-
}
|
|
77
|
+
strokeOpacity: 0.15,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
80
|
})
|
|
81
81
|
|
|
82
82
|
// To fix issue with marker not inheriting color from path - we need to create container
|
|
83
83
|
export const markerContext = style({
|
|
84
84
|
fill: xyvars.edge.stroke,
|
|
85
|
-
stroke: xyvars.edge.stroke
|
|
85
|
+
stroke: xyvars.edge.stroke,
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
export const controlPoint = style({
|
|
@@ -96,7 +96,7 @@ export const controlPoint = style({
|
|
|
96
96
|
':hover': {
|
|
97
97
|
stroke: mantine.colors.primaryColors.filledHover,
|
|
98
98
|
strokeWidth: 9,
|
|
99
|
-
transition: 'stroke 100ms ease-out, stroke-width 100ms ease-out'
|
|
99
|
+
transition: 'stroke 100ms ease-out, stroke-width 100ms ease-out',
|
|
100
100
|
},
|
|
101
101
|
selectors: {
|
|
102
102
|
[`:where(${isSelected}, [data-edge-hovered='true']) &`]: {
|
|
@@ -104,26 +104,26 @@ export const controlPoint = style({
|
|
|
104
104
|
transition: 'fill-opacity 150ms ease-out, stroke 150ms ease-out, stroke-width 150ms ease-out',
|
|
105
105
|
transitionDelay: '50ms',
|
|
106
106
|
fillOpacity: 1,
|
|
107
|
-
strokeWidth: 5
|
|
108
|
-
}
|
|
109
|
-
}
|
|
107
|
+
strokeWidth: 5,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
110
|
})
|
|
111
111
|
|
|
112
112
|
export const controlDragging = style({
|
|
113
|
-
cursor: 'grabbing'
|
|
113
|
+
cursor: 'grabbing',
|
|
114
114
|
})
|
|
115
115
|
|
|
116
116
|
globalStyle(`${controlDragging} *`, {
|
|
117
|
-
cursor: 'grabbing !important'
|
|
117
|
+
cursor: 'grabbing !important',
|
|
118
118
|
})
|
|
119
119
|
|
|
120
120
|
const strokeKeyframes = keyframes({
|
|
121
121
|
'from': {
|
|
122
|
-
strokeDashoffset: 18 * 2 + 10
|
|
122
|
+
strokeDashoffset: 18 * 2 + 10,
|
|
123
123
|
},
|
|
124
124
|
'to': {
|
|
125
|
-
strokeDashoffset: 10
|
|
126
|
-
}
|
|
125
|
+
strokeDashoffset: 10,
|
|
126
|
+
},
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
export const cssEdgePath = style({
|
|
@@ -136,20 +136,20 @@ export const cssEdgePath = style({
|
|
|
136
136
|
[`:where([data-edge-hovered='true']) &`]: {
|
|
137
137
|
animationName: strokeKeyframes,
|
|
138
138
|
animationDelay: '450ms',
|
|
139
|
-
transition: 'stroke 130ms ease-out,stroke-width 130ms ease-out'
|
|
139
|
+
transition: 'stroke 130ms ease-out,stroke-width 130ms ease-out',
|
|
140
140
|
},
|
|
141
141
|
[`:where(${isSelected}, [data-edge-active='true'], [data-edge-animated='true']) &`]: {
|
|
142
142
|
animationName: strokeKeyframes,
|
|
143
143
|
animationDelay: '0ms',
|
|
144
|
-
transition: 'stroke 130ms ease-out,stroke-width 130ms ease-out'
|
|
144
|
+
transition: 'stroke 130ms ease-out,stroke-width 130ms ease-out',
|
|
145
145
|
},
|
|
146
146
|
[`:where([data-edge-dir='back']) &`]: {
|
|
147
|
-
animationDirection: 'reverse'
|
|
147
|
+
animationDirection: 'reverse',
|
|
148
148
|
},
|
|
149
149
|
[`${dimmed} &`]: {
|
|
150
|
-
animationPlayState: 'paused'
|
|
151
|
-
}
|
|
152
|
-
}
|
|
150
|
+
animationPlayState: 'paused',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
153
|
})
|
|
154
154
|
|
|
155
155
|
const labelBorderRadius = 2
|
|
@@ -167,12 +167,12 @@ export const stepEdgeNumber = style({
|
|
|
167
167
|
fontVariantNumeric: 'tabular-nums',
|
|
168
168
|
selectors: {
|
|
169
169
|
[`:where([data-mantine-color-scheme="dark"]) :where([data-likec4-color="gray"]) &`]: {
|
|
170
|
-
backgroundColor: `color-mix(in srgb, ${vars.relation.labelBgColor}, ${mixColor} 15%)
|
|
170
|
+
backgroundColor: `color-mix(in srgb, ${vars.relation.labelBgColor}, ${mixColor} 15%)`,
|
|
171
171
|
},
|
|
172
172
|
[`:where([data-edge-active='true']) &`]: {
|
|
173
|
-
backgroundColor: 'transparent'
|
|
174
|
-
}
|
|
175
|
-
}
|
|
173
|
+
backgroundColor: 'transparent',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
176
|
})
|
|
177
177
|
|
|
178
178
|
export const varLabelX = createVar('label-x')
|
|
@@ -197,43 +197,50 @@ export const edgeLabel = style({
|
|
|
197
197
|
borderRadius: labelBorderRadius,
|
|
198
198
|
transform: varTranslate,
|
|
199
199
|
vars: {
|
|
200
|
-
[varTranslate]: `translate(${fallbackVar(varLabelX, '-50%')}, ${fallbackVar(varLabelY, '-50%')})
|
|
200
|
+
[varTranslate]: `translate(${fallbackVar(varLabelX, '-50%')}, ${fallbackVar(varLabelY, '-50%')})`,
|
|
201
201
|
},
|
|
202
202
|
selectors: {
|
|
203
203
|
'&[data-edge-hovered="true"]': {
|
|
204
204
|
transition: 'all 140ms ease-in-out',
|
|
205
|
-
transform: `${varTranslate} scale(1.12)
|
|
205
|
+
transform: `${varTranslate} scale(1.12)`,
|
|
206
206
|
},
|
|
207
207
|
[`&:has(${stepEdgeNumber})`]: {
|
|
208
208
|
padding: 0,
|
|
209
|
-
gap: 2
|
|
209
|
+
gap: 2,
|
|
210
210
|
},
|
|
211
211
|
[`&:is(${dimmed})`]: {
|
|
212
212
|
opacity: 0.3,
|
|
213
213
|
transition: 'opacity 600ms ease-in-out, filter 600ms ease-in-out',
|
|
214
214
|
transitionDelay: '200ms',
|
|
215
215
|
filter: `grayscale(0.85) ${fallbackVar(vars.safariAnimationHook, 'blur(1px)')}`,
|
|
216
|
-
willChange: 'opacity, filter'
|
|
217
|
-
}
|
|
218
|
-
}
|
|
216
|
+
willChange: 'opacity, filter',
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
219
|
})
|
|
220
220
|
|
|
221
221
|
export const edgeLabelText = style({
|
|
222
|
-
textAlign: 'center',
|
|
223
222
|
whiteSpaceCollapse: 'preserve-breaks',
|
|
224
223
|
fontSize: rem(14),
|
|
225
|
-
lineHeight: 1.185
|
|
224
|
+
lineHeight: 1.185,
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
export const edgeLabelTechnology = style({
|
|
228
|
+
textAlign: 'center',
|
|
229
|
+
whiteSpaceCollapse: 'preserve-breaks',
|
|
230
|
+
fontSize: rem(11),
|
|
231
|
+
lineHeight: 1,
|
|
232
|
+
opacity: 0.75,
|
|
226
233
|
})
|
|
227
234
|
|
|
228
235
|
globalStyle(`${edgeLabel}:has(${stepEdgeNumber}) ${edgeLabelText}`, {
|
|
229
|
-
padding: '2px 5px 4px 2px'
|
|
236
|
+
padding: '2px 5px 4px 2px',
|
|
230
237
|
})
|
|
231
238
|
|
|
232
239
|
export const edgeNoteCloseButton = style({
|
|
233
240
|
position: 'absolute',
|
|
234
241
|
top: 4,
|
|
235
242
|
right: 4,
|
|
236
|
-
zIndex: 9
|
|
243
|
+
zIndex: 9,
|
|
237
244
|
})
|
|
238
245
|
|
|
239
246
|
export const edgeNoteText = style({
|
|
@@ -243,52 +250,39 @@ export const edgeNoteText = style({
|
|
|
243
250
|
textWrap: 'pretty',
|
|
244
251
|
lineHeight: 1.25,
|
|
245
252
|
vars: {
|
|
246
|
-
'--text-fz': mantine.fontSizes.sm
|
|
253
|
+
'--text-fz': mantine.fontSizes.sm,
|
|
247
254
|
},
|
|
248
255
|
'@media': {
|
|
249
256
|
[mantine.largerThan('md')]: {
|
|
250
257
|
vars: {
|
|
251
|
-
'--text-fz': mantine.fontSizes.md
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
258
|
+
'--text-fz': mantine.fontSizes.md,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
255
262
|
})
|
|
256
263
|
|
|
257
264
|
export const cssNavigateBtn = style({
|
|
258
265
|
zIndex: 'calc(var(--layer-overlays, 1) + 1)',
|
|
259
|
-
position: 'absolute',
|
|
260
266
|
pointerEvents: 'all',
|
|
261
|
-
left: '50%',
|
|
262
|
-
top: 'calc(100% + 1px)',
|
|
263
267
|
color: xyvars.edge.labelColor,
|
|
264
268
|
cursor: 'pointer',
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
transition: 'all 150ms ease-in-out',
|
|
268
|
-
transform: 'translate(-50%, 0)',
|
|
269
|
-
transitionDelay: '0ms',
|
|
269
|
+
opacity: 1,
|
|
270
|
+
transition: transitions.fast,
|
|
270
271
|
backgroundColor: 'var(--ai-bg)',
|
|
271
272
|
vars: {
|
|
272
273
|
'--ai-bg': vars.relation.labelBgColor,
|
|
273
|
-
'--ai-hover': `color-mix(in srgb , ${vars.relation.labelBgColor}, ${mixColor} 10%)
|
|
274
|
-
},
|
|
275
|
-
selectors: {
|
|
276
|
-
[`:is(${dimmed}) &`]: {
|
|
277
|
-
display: 'none'
|
|
278
|
-
}
|
|
274
|
+
'--ai-hover': `color-mix(in srgb , ${vars.relation.labelBgColor}, ${mixColor} 10%)`,
|
|
279
275
|
},
|
|
280
276
|
':hover': {
|
|
281
|
-
|
|
282
|
-
transform: 'translate(-50%, 0) scale(1.3)',
|
|
283
|
-
opacity: 1
|
|
277
|
+
transform: 'translateY(1px) scale(1.15)',
|
|
284
278
|
},
|
|
285
279
|
':active': {
|
|
286
|
-
transform: '
|
|
287
|
-
}
|
|
280
|
+
transform: 'translateY(-1px) scale(0.9)',
|
|
281
|
+
},
|
|
288
282
|
})
|
|
289
283
|
globalStyle(`${cssNavigateBtn} .tabler-icon`, {
|
|
290
|
-
width: '
|
|
291
|
-
height: '
|
|
292
|
-
strokeWidth: 2
|
|
284
|
+
width: '80%',
|
|
285
|
+
height: '80%',
|
|
286
|
+
strokeWidth: 2,
|
|
293
287
|
})
|
|
294
288
|
export const cssNavigateBtnIcon = style({})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Position, type XYPosition } from '@xyflow/react'
|
|
2
2
|
import { getNodeDimensions } from '@xyflow/system'
|
|
3
|
-
import type {
|
|
3
|
+
import type { DiagramFlowTypes } from '../types'
|
|
4
4
|
|
|
5
|
-
export function getNodeCenter(node:
|
|
5
|
+
export function getNodeCenter(node: DiagramFlowTypes.InternalNode): XYPosition {
|
|
6
6
|
const { width, height } = getNodeDimensions(node)
|
|
7
7
|
const { x, y } = node.internals.positionAbsolute
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ export function getNodeCenter(node: InternalXYFlowNode): XYPosition {
|
|
|
15
15
|
// this helper function returns the intersection point
|
|
16
16
|
// of the line between the center of the intersectionNode and the target node
|
|
17
17
|
export function getNodeIntersectionFromCenterToPoint(
|
|
18
|
-
intersectionNode:
|
|
18
|
+
intersectionNode: DiagramFlowTypes.InternalNode,
|
|
19
19
|
{ x: x1, y: y1 }: XYPosition
|
|
20
20
|
) {
|
|
21
21
|
// https://math.stackexchange.com/questions/1724792/an-algorithm-for-finding-the-intersection-point-between-a-center-of-vision-and-a
|
|
@@ -47,7 +47,7 @@ export function getNodeIntersectionFromCenterToPoint(
|
|
|
47
47
|
|
|
48
48
|
// this helper function returns the intersection point
|
|
49
49
|
// of the line between the center of the intersectionNode and the target node
|
|
50
|
-
function getNodeIntersection(intersectionNode:
|
|
50
|
+
function getNodeIntersection(intersectionNode: DiagramFlowTypes.InternalNode, targetNode: DiagramFlowTypes.InternalNode): XYPosition {
|
|
51
51
|
// https://math.stackexchange.com/questions/1724792/an-algorithm-for-finding-the-intersection-point-between-a-center-of-vision-and-a
|
|
52
52
|
const {
|
|
53
53
|
width: intersectionNodeWidth,
|
|
@@ -81,7 +81,7 @@ function getNodeIntersection(intersectionNode: InternalXYFlowNode, targetNode: I
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// returns the position (top,right,bottom or right) passed node compared to the intersection point
|
|
84
|
-
export function getPointPosition(node:
|
|
84
|
+
export function getPointPosition(node: DiagramFlowTypes.InternalNode, intersectionPoint: XYPosition) {
|
|
85
85
|
const n = {
|
|
86
86
|
// x: node.data.element.position[0],
|
|
87
87
|
// y: node.data.element.position[1],
|
|
@@ -135,7 +135,7 @@ export function getPointPosition(node: InternalXYFlowNode, intersectionPoint: XY
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// returns the parameters (sx, sy, tx, ty, sourcePos, targetPos) you need to create an edge
|
|
138
|
-
export function getEdgeParams(source:
|
|
138
|
+
export function getEdgeParams(source: DiagramFlowTypes.InternalNode, target: DiagramFlowTypes.InternalNode) {
|
|
139
139
|
const sourceIntersectionPoint = getNodeIntersection(source, target)
|
|
140
140
|
const targetIntersectionPoint = getNodeIntersection(target, source)
|
|
141
141
|
|