@likec4/diagram 1.17.1 → 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 +40 -31
- package/src/LikeC4Diagram.props.ts +21 -12
- package/src/LikeC4Diagram.tsx +8 -10
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +45 -93
- 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/useDiagramState.ts +8 -3
- package/src/hooks/useXYFlow.ts +9 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +6 -13
- package/src/likec4model/useLikeC4Model.ts +21 -11
- package/src/overlays/Overlays.tsx +96 -63
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -10
- package/src/overlays/edge-details/_types.ts +13 -33
- package/src/overlays/edge-details/use-layouted-edge-details.ts +35 -26
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +8 -13
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +7 -7
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/element-details/ElementDetailsCard.tsx +91 -78
- package/src/overlays/element-details/TabPanelDeployments.css.ts +69 -0
- package/src/overlays/element-details/TabPanelDeployments.tsx +217 -0
- package/src/overlays/element-details/TabPanelRelationships.tsx +8 -9
- package/src/overlays/element-details/TabPanelStructure.tsx +10 -10
- package/src/overlays/relationships-of/RelationshipsOverlay.tsx +1 -1
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +26 -34
- package/src/overlays/relationships-of/SelectElement.tsx +2 -2
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +54 -59
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +10 -16
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +24 -21
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -15
- 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 +63 -48
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +7 -34
- package/src/ui/Link.tsx +40 -0
- package/src/ui/notation/NotationPanel.tsx +4 -2
- package/src/ui/top-left/ChangeAutoLayoutButton.tsx +2 -2
- package/src/ui/top-left/TopLeftPanel.tsx +5 -5
- 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 +26 -19
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +23 -10
- 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 +27 -75
- package/src/xyflow/nodes/compound/CompoundNode.tsx +82 -163
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +73 -252
- package/src/xyflow/nodes/element/element.css.ts +40 -64
- package/src/xyflow/nodes/shared/ElementIcon.tsx +1 -1
- package/src/xyflow/nodes/shared/Toolbar.tsx +51 -35
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +10 -10
- package/src/xyflow/useXYFlowEvents.ts +31 -35
- package/src/xyflow/utils.ts +2 -2
- package/src/ui/OptionsPanel.css.ts +0 -9
- package/src/ui/OptionsPanel.tsx +0 -70
- package/src/ui/options/EdgeOptions.tsx +0 -142
- package/src/ui/options/NodeOptions.tsx +0 -362
- package/src/xyflow/nodes/element/ElementDetails.css.ts +0 -101
- package/src/xyflow/nodes/element/ElementDetails.tsx +0 -393
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
ComputedNode,
|
|
2
3
|
DiagramNode,
|
|
3
4
|
DiagramView,
|
|
4
5
|
EdgeId,
|
|
5
|
-
ElementKind,
|
|
6
6
|
ElementNotation,
|
|
7
7
|
Fqn,
|
|
8
8
|
NodeId,
|
|
9
9
|
ViewChange,
|
|
10
|
-
|
|
10
|
+
ViewId,
|
|
11
11
|
XYPoint
|
|
12
12
|
} from '@likec4/core'
|
|
13
13
|
import {
|
|
@@ -17,17 +17,16 @@ import {
|
|
|
17
17
|
isStepEdgeId,
|
|
18
18
|
nonexhaustive,
|
|
19
19
|
nonNullable,
|
|
20
|
-
StepEdgeId
|
|
20
|
+
type StepEdgeId
|
|
21
21
|
} from '@likec4/core'
|
|
22
22
|
import {
|
|
23
23
|
applyEdgeChanges,
|
|
24
24
|
applyNodeChanges,
|
|
25
25
|
getViewportForBounds,
|
|
26
|
-
type InternalNode,
|
|
27
26
|
type OnEdgesChange,
|
|
28
27
|
type OnNodesChange
|
|
29
28
|
} from '@xyflow/react'
|
|
30
|
-
import { boxToRect, getBoundsOfRects, getNodeDimensions
|
|
29
|
+
import { boxToRect, getBoundsOfRects, getNodeDimensions } from '@xyflow/system'
|
|
31
30
|
import { DEV } from 'esm-env'
|
|
32
31
|
import { deepEqual as eq, shallowEqual } from 'fast-equals'
|
|
33
32
|
import type { MouseEvent as ReactMouseEvent } from 'react'
|
|
@@ -43,10 +42,9 @@ import type {
|
|
|
43
42
|
LikeC4DiagramEventHandlers,
|
|
44
43
|
WhereOperator
|
|
45
44
|
} from '../LikeC4Diagram.props'
|
|
46
|
-
import { type Vector, vector } from '../utils/vector'
|
|
45
|
+
import { type Vector, vector, VectorImpl } from '../utils/vector'
|
|
47
46
|
import { MinZoom } from '../xyflow/const'
|
|
48
|
-
import type {
|
|
49
|
-
import { createLayoutConstraints } from '../xyflow/useLayoutConstraints'
|
|
47
|
+
import type { DiagramFlowTypes } from '../xyflow/types'
|
|
50
48
|
import { bezierControlPoints, isInside, isSamePoint, toDomPrecision } from '../xyflow/utils'
|
|
51
49
|
import { diagramViewToXYFlowData } from './diagram-to-xyflow'
|
|
52
50
|
import { align, type AlignmentMode } from './diagramStore.layout'
|
|
@@ -80,13 +78,15 @@ export type DiagramInitialState = {
|
|
|
80
78
|
// If Dynamic View
|
|
81
79
|
enableDynamicViewWalkthrough: boolean
|
|
82
80
|
|
|
83
|
-
xyflow: XYFlowInstance
|
|
81
|
+
xyflow: DiagramFlowTypes.XYFlowInstance
|
|
84
82
|
xystore: XYStoreApi
|
|
85
83
|
|
|
86
84
|
// Diagram Container, for Mantine Portal
|
|
87
85
|
getContainer: () => HTMLDivElement | null
|
|
88
86
|
} & RequiredOrNull<LikeC4DiagramEventHandlers>
|
|
89
87
|
|
|
88
|
+
type NodeKind = ComputedNode['kind']
|
|
89
|
+
|
|
90
90
|
const StringSet = Set<string>
|
|
91
91
|
|
|
92
92
|
export type DiagramState = Simplify<
|
|
@@ -94,8 +94,8 @@ export type DiagramState = Simplify<
|
|
|
94
94
|
readonly storeDevId: string
|
|
95
95
|
|
|
96
96
|
// Internal state
|
|
97
|
-
xynodes:
|
|
98
|
-
xyedges:
|
|
97
|
+
xynodes: DiagramFlowTypes.Node[]
|
|
98
|
+
xyedges: DiagramFlowTypes.Edge[]
|
|
99
99
|
viewSyncDebounceTimeout: number | null
|
|
100
100
|
viewportChanged: boolean
|
|
101
101
|
|
|
@@ -125,19 +125,18 @@ export type DiagramState = Simplify<
|
|
|
125
125
|
lastClickedNodeId: string | null
|
|
126
126
|
lastClickedEdgeId: string | null
|
|
127
127
|
focusedNodeId: string | null
|
|
128
|
-
hoveredNodeId: string | null
|
|
129
128
|
hoveredEdgeId: string | null
|
|
130
129
|
|
|
131
130
|
// id's of nodes / edges that
|
|
132
131
|
dimmed: ReadonlySet<string>
|
|
133
132
|
|
|
134
133
|
lastOnNavigate: null | {
|
|
135
|
-
fromView:
|
|
136
|
-
toView:
|
|
134
|
+
fromView: ViewId
|
|
135
|
+
toView: ViewId
|
|
137
136
|
fromNode: NodeId | null
|
|
138
137
|
}
|
|
139
138
|
navigationHistory: Array<{
|
|
140
|
-
viewId:
|
|
139
|
+
viewId: ViewId
|
|
141
140
|
nodeId: NodeId | null
|
|
142
141
|
}>
|
|
143
142
|
navigationHistoryIndex: number
|
|
@@ -151,7 +150,6 @@ export type DiagramState = Simplify<
|
|
|
151
150
|
*/
|
|
152
151
|
focusOnNode: (nodeId: string | false) => void
|
|
153
152
|
|
|
154
|
-
setHoveredNode: (nodeId: string | null) => void
|
|
155
153
|
setHoveredEdge: (edgeId: string | null) => void
|
|
156
154
|
|
|
157
155
|
setLastClickedNode: (nodeId: string | null) => void
|
|
@@ -176,20 +174,22 @@ export type DiagramState = Simplify<
|
|
|
176
174
|
goForward: () => void
|
|
177
175
|
|
|
178
176
|
nextDynamicStep: (increment?: number) => void
|
|
179
|
-
activateWalkthrough: (step: EdgeId |
|
|
177
|
+
activateWalkthrough: (step: EdgeId | DiagramFlowTypes.Edge) => void
|
|
180
178
|
stopWalkthrough: () => void
|
|
181
179
|
|
|
182
180
|
openOverlay: (overlay: NonNullable<DiagramState['activeOverlay']>) => void
|
|
183
181
|
closeOverlay: () => void
|
|
184
182
|
|
|
185
|
-
onInit: (xyflow: XYFlowInstance) => void
|
|
186
|
-
onNodesChange: OnNodesChange<
|
|
187
|
-
onEdgesChange: OnEdgesChange<
|
|
183
|
+
onInit: (xyflow: DiagramFlowTypes.XYFlowInstance) => void
|
|
184
|
+
onNodesChange: OnNodesChange<DiagramFlowTypes.Node>
|
|
185
|
+
onEdgesChange: OnEdgesChange<DiagramFlowTypes.Edge>
|
|
188
186
|
|
|
189
|
-
highlightByElementNotation: (notation: ElementNotation, onlyOfKind?:
|
|
187
|
+
highlightByElementNotation: (notation: ElementNotation, onlyOfKind?: NodeKind) => void
|
|
190
188
|
|
|
191
189
|
resetEdgeControlPoints: () => void
|
|
192
190
|
align: (mode: AlignmentMode) => void
|
|
191
|
+
|
|
192
|
+
onOpenSourceView: () => void
|
|
193
193
|
}
|
|
194
194
|
>
|
|
195
195
|
|
|
@@ -207,7 +207,6 @@ const DEFAULT_PROPS: Except<
|
|
|
207
207
|
activeOverlay: null,
|
|
208
208
|
activeWalkthrough: null,
|
|
209
209
|
focusedNodeId: null,
|
|
210
|
-
hoveredNodeId: null,
|
|
211
210
|
hoveredEdgeId: null,
|
|
212
211
|
lastClickedNodeId: null,
|
|
213
212
|
lastClickedEdgeId: null,
|
|
@@ -283,7 +282,6 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
283
282
|
nodesDraggable,
|
|
284
283
|
nodesSelectable,
|
|
285
284
|
hoveredEdgeId,
|
|
286
|
-
hoveredNodeId,
|
|
287
285
|
xyedges,
|
|
288
286
|
xynodes
|
|
289
287
|
} = get()
|
|
@@ -302,9 +300,6 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
302
300
|
if (lastClickedNodeId && !nodeIds.has(lastClickedNodeId)) {
|
|
303
301
|
lastClickedNodeId = null
|
|
304
302
|
}
|
|
305
|
-
if (hoveredNodeId && !nodeIds.has(hoveredNodeId)) {
|
|
306
|
-
hoveredNodeId = null
|
|
307
|
-
}
|
|
308
303
|
if (focusedNodeId && !nodeIds.has(focusedNodeId)) {
|
|
309
304
|
focusedNodeId = null
|
|
310
305
|
dimmed = EmptyStringSet
|
|
@@ -383,7 +378,6 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
383
378
|
lastClickedEdgeId = null
|
|
384
379
|
lastClickedNodeId = null
|
|
385
380
|
hoveredEdgeId = null
|
|
386
|
-
hoveredNodeId = null
|
|
387
381
|
focusedNodeId = null
|
|
388
382
|
activeWalkthrough = null
|
|
389
383
|
activeOverlay = null
|
|
@@ -415,14 +409,14 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
415
409
|
return {
|
|
416
410
|
...existing,
|
|
417
411
|
...update
|
|
418
|
-
} as
|
|
412
|
+
} as DiagramFlowTypes.Node
|
|
419
413
|
}
|
|
420
414
|
return update
|
|
421
415
|
})
|
|
422
416
|
// Merge with existing edges, but only if the view is the same
|
|
423
417
|
// and the edges have no layout drift
|
|
424
418
|
if (isSameView && !nextView.hasLayoutDrift) {
|
|
425
|
-
update.xyedges = update.xyedges.map((update):
|
|
419
|
+
update.xyedges = update.xyedges.map((update): DiagramFlowTypes.Edge => {
|
|
426
420
|
const existing = xyedges.find(n => n.id === update.id)
|
|
427
421
|
if (existing) {
|
|
428
422
|
if (
|
|
@@ -458,7 +452,6 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
458
452
|
lastClickedEdgeId,
|
|
459
453
|
focusedNodeId,
|
|
460
454
|
hoveredEdgeId,
|
|
461
|
-
hoveredNodeId,
|
|
462
455
|
navigationHistory,
|
|
463
456
|
navigationHistoryIndex,
|
|
464
457
|
dimmed,
|
|
@@ -516,12 +509,6 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
516
509
|
}
|
|
517
510
|
},
|
|
518
511
|
|
|
519
|
-
setHoveredNode: (nodeId) => {
|
|
520
|
-
if (nodeId !== get().hoveredNodeId) {
|
|
521
|
-
set({ hoveredNodeId: nodeId })
|
|
522
|
-
}
|
|
523
|
-
},
|
|
524
|
-
|
|
525
512
|
setHoveredEdge: (edgeId) => {
|
|
526
513
|
if (edgeId !== get().hoveredEdgeId) {
|
|
527
514
|
set({ hoveredEdgeId: edgeId })
|
|
@@ -850,10 +837,25 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
850
837
|
}
|
|
851
838
|
},
|
|
852
839
|
|
|
840
|
+
onOpenSourceView: () => {
|
|
841
|
+
const { view, onOpenSource } = get()
|
|
842
|
+
onOpenSource?.({
|
|
843
|
+
view: view.id
|
|
844
|
+
})
|
|
845
|
+
},
|
|
846
|
+
|
|
853
847
|
openOverlay: (overlay) => {
|
|
854
848
|
if (eq(overlay, get().activeOverlay)) {
|
|
855
849
|
return
|
|
856
850
|
}
|
|
851
|
+
if ('elementDetails' in overlay) {
|
|
852
|
+
const diagramNode = get().view.nodes.find(({ id }) => id === overlay.elementDetails)
|
|
853
|
+
if (!diagramNode || !diagramNode.modelRef) {
|
|
854
|
+
get().closeOverlay()
|
|
855
|
+
return
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
857
859
|
set(
|
|
858
860
|
{
|
|
859
861
|
activeWalkthrough: null,
|
|
@@ -902,7 +904,7 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
902
904
|
}
|
|
903
905
|
},
|
|
904
906
|
|
|
905
|
-
activateWalkthrough: (step: EdgeId |
|
|
907
|
+
activateWalkthrough: (step: EdgeId | DiagramFlowTypes.Edge) => {
|
|
906
908
|
const stepId = typeof step === 'string' ? step : step.data.edge.id
|
|
907
909
|
invariant(isStepEdgeId(stepId), `stepId ${stepId} is not a step edge id`)
|
|
908
910
|
let {
|
|
@@ -932,7 +934,7 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
932
934
|
)
|
|
933
935
|
.map(({ id }) => id)
|
|
934
936
|
)
|
|
935
|
-
const selected = [] as
|
|
937
|
+
const selected = [] as DiagramFlowTypes.Node[]
|
|
936
938
|
for (const n of xyflow.getNodes()) {
|
|
937
939
|
if (n.id === edge.source || n.id === edge.target) {
|
|
938
940
|
selected.push(n)
|
|
@@ -992,7 +994,7 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
992
994
|
}
|
|
993
995
|
},
|
|
994
996
|
|
|
995
|
-
highlightByElementNotation: (notation: ElementNotation, onlyOfKind?:
|
|
997
|
+
highlightByElementNotation: (notation: ElementNotation, onlyOfKind?: NodeKind) => {
|
|
996
998
|
const { xynodes, xyedges } = get()
|
|
997
999
|
const dimmed = new StringSet(map(xyedges, prop('id')))
|
|
998
1000
|
xynodes.forEach(({ id, data }) => {
|
|
@@ -1018,7 +1020,7 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
1018
1020
|
|
|
1019
1021
|
scheduleSaveManualLayout()
|
|
1020
1022
|
|
|
1021
|
-
function getNodeCenter(node:
|
|
1023
|
+
function getNodeCenter(node: DiagramFlowTypes.Node, nodes: DiagramFlowTypes.Node[]) {
|
|
1022
1024
|
const dimensions = vector({ x: node.width || 0, y: node.height || 0 })
|
|
1023
1025
|
let position = vector(node.position)
|
|
1024
1026
|
.add(dimensions.mul(0.5))
|
|
@@ -1038,7 +1040,7 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
1038
1040
|
return position
|
|
1039
1041
|
}
|
|
1040
1042
|
|
|
1041
|
-
function getControlPointForEdge(edge:
|
|
1043
|
+
function getControlPointForEdge(edge: DiagramFlowTypes.Edge): XYPoint[] {
|
|
1042
1044
|
const source = xynodes.find(x => x.id == edge.source)
|
|
1043
1045
|
const target = xynodes.find(x => x.id == edge.target)
|
|
1044
1046
|
if (!source || !target) {
|
|
@@ -1048,18 +1050,31 @@ export function createDiagramStore(props: DiagramInitialState) {
|
|
|
1048
1050
|
const sourceCenter = getNodeCenter(source, xynodes)
|
|
1049
1051
|
const targetCenter = getNodeCenter(target, xynodes)
|
|
1050
1052
|
|
|
1051
|
-
if (sourceCenter
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1053
|
+
if (!sourceCenter || !targetCenter) {
|
|
1054
|
+
return []
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// Edge is a loop
|
|
1058
|
+
if(source == target) {
|
|
1059
|
+
const loopSize = 80
|
|
1060
|
+
const centerOfTopBoundary = new VectorImpl(0, source.height || 0)
|
|
1061
|
+
.mul(-0.5)
|
|
1062
|
+
.add(sourceCenter)
|
|
1055
1063
|
|
|
1056
|
-
return [
|
|
1064
|
+
return [
|
|
1065
|
+
centerOfTopBoundary.add(new VectorImpl(-loopSize / 2.5, -loopSize)),
|
|
1066
|
+
centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -loopSize))
|
|
1067
|
+
]
|
|
1057
1068
|
}
|
|
1058
1069
|
|
|
1059
|
-
|
|
1070
|
+
const sourceToTargetVector = targetCenter.sub(sourceCenter)
|
|
1071
|
+
const sourceBorderPoint = getBorderPointOnVector(source, sourceCenter, sourceToTargetVector)
|
|
1072
|
+
const targetBorderPoint = getBorderPointOnVector(target, targetCenter, sourceToTargetVector.mul(-1))
|
|
1073
|
+
|
|
1074
|
+
return [sourceBorderPoint.add(targetBorderPoint.sub(sourceBorderPoint).mul(0.3))]
|
|
1060
1075
|
}
|
|
1061
1076
|
|
|
1062
|
-
function getBorderPointOnVector(node:
|
|
1077
|
+
function getBorderPointOnVector(node: DiagramFlowTypes.Node, nodeCenter: Vector, v: Vector) {
|
|
1063
1078
|
const xScale = (node.width || 0) / 2 / v.x
|
|
1064
1079
|
const yScale = (node.height || 0) / 2 / v.y
|
|
1065
1080
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createGlobalThemeContract } from '@vanilla-extract/css'
|
|
2
|
+
|
|
3
|
+
export const vars = createGlobalThemeContract({
|
|
4
|
+
safariAnimationHook: 'safari-animation-hook',
|
|
5
|
+
default: {
|
|
6
|
+
font: 'default-font-family',
|
|
7
|
+
},
|
|
8
|
+
likec4: {
|
|
9
|
+
font: 'font-family',
|
|
10
|
+
background: {
|
|
11
|
+
color: 'background-color',
|
|
12
|
+
pattern: {
|
|
13
|
+
color: 'background-pattern-color',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
compound: {
|
|
18
|
+
font: 'compound-font-family',
|
|
19
|
+
titleColor: 'compound-title-color',
|
|
20
|
+
},
|
|
21
|
+
element: {
|
|
22
|
+
font: 'element-font-family',
|
|
23
|
+
fill: 'element-fill',
|
|
24
|
+
stroke: 'element-stroke',
|
|
25
|
+
hiContrast: 'element-hiContrast',
|
|
26
|
+
loContrast: 'element-loContrast',
|
|
27
|
+
},
|
|
28
|
+
relation: {
|
|
29
|
+
lineColor: 'relation-lineColor',
|
|
30
|
+
labelColor: 'relation-labelColor',
|
|
31
|
+
labelBgColor: 'relation-labelBg',
|
|
32
|
+
},
|
|
33
|
+
optionsPanel: {
|
|
34
|
+
top: 'options-webview-top',
|
|
35
|
+
right: 'options-webview-right',
|
|
36
|
+
},
|
|
37
|
+
navigationPanel: {
|
|
38
|
+
top: 'navigation-webview-top',
|
|
39
|
+
left: 'navigation-webview-left',
|
|
40
|
+
},
|
|
41
|
+
}, (value) => `likec4-${value}`)
|
|
42
|
+
|
|
43
|
+
export const xyvars = createGlobalThemeContract({
|
|
44
|
+
background: {
|
|
45
|
+
color: 'background-color',
|
|
46
|
+
pattern: {
|
|
47
|
+
color: 'background-pattern-color',
|
|
48
|
+
// dots: 'background-pattern-dots-color',
|
|
49
|
+
// lines: 'background-pattern-lines-color',
|
|
50
|
+
// cross: 'background-pattern-cross-color'
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
edge: {
|
|
54
|
+
stroke: 'edge-stroke',
|
|
55
|
+
strokeSelected: 'edge-stroke-selected',
|
|
56
|
+
labelColor: 'edge-label-color',
|
|
57
|
+
labelBgColor: 'edge-label-background-color',
|
|
58
|
+
strokeWidth: 'edge-stroke-width',
|
|
59
|
+
},
|
|
60
|
+
node: {
|
|
61
|
+
color: 'node-color',
|
|
62
|
+
border: 'node-border',
|
|
63
|
+
backgroundColor: 'node-background-color',
|
|
64
|
+
groupBackgroundColor: 'node-group-background-color',
|
|
65
|
+
boxshadowHover: 'node-boxshadow-hover',
|
|
66
|
+
boxshadowSelected: 'node-boxshadow-selected',
|
|
67
|
+
borderRadius: 'node-border-radius',
|
|
68
|
+
},
|
|
69
|
+
}, (value) => `xy-${value}`)
|
|
70
|
+
|
|
71
|
+
export const whereLight = ':where([data-mantine-color-scheme="light"])'
|
|
72
|
+
export const whereDark = ':where([data-mantine-color-scheme="dark"])'
|
|
73
|
+
|
|
74
|
+
export const easings = {
|
|
75
|
+
out: 'cubic-bezier(0, 0, 0.40, 1)',
|
|
76
|
+
inOut: 'cubic-bezier(0.50, 0, 0.2, 1)',
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const transitions = {
|
|
80
|
+
fast: `all 130ms ${easings.inOut}`,
|
|
81
|
+
}
|
package/src/theme-vars.ts
CHANGED
|
@@ -1,85 +1,12 @@
|
|
|
1
1
|
import { themeToVars } from '@mantine/vanilla-extract'
|
|
2
|
-
import { createGlobalThemeContract } from '@vanilla-extract/css'
|
|
3
2
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
color: 'background-color',
|
|
13
|
-
pattern: {
|
|
14
|
-
color: 'background-pattern-color'
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
compound: {
|
|
19
|
-
font: 'compound-font-family',
|
|
20
|
-
titleColor: 'compound-title-color'
|
|
21
|
-
},
|
|
22
|
-
element: {
|
|
23
|
-
font: 'element-font-family',
|
|
24
|
-
fill: 'element-fill',
|
|
25
|
-
stroke: 'element-stroke',
|
|
26
|
-
hiContrast: 'element-hiContrast',
|
|
27
|
-
loContrast: 'element-loContrast'
|
|
28
|
-
},
|
|
29
|
-
relation: {
|
|
30
|
-
lineColor: 'relation-lineColor',
|
|
31
|
-
labelColor: 'relation-labelColor',
|
|
32
|
-
labelBgColor: 'relation-labelBg'
|
|
33
|
-
},
|
|
34
|
-
optionsPanel: {
|
|
35
|
-
top: 'options-webview-top',
|
|
36
|
-
right: 'options-webview-right'
|
|
37
|
-
},
|
|
38
|
-
navigationPanel: {
|
|
39
|
-
top: 'navigation-webview-top',
|
|
40
|
-
left: 'navigation-webview-left'
|
|
41
|
-
}
|
|
42
|
-
}, (value) => `likec4-${value}`)
|
|
3
|
+
export {
|
|
4
|
+
easings,
|
|
5
|
+
transitions,
|
|
6
|
+
vars,
|
|
7
|
+
whereDark,
|
|
8
|
+
whereLight,
|
|
9
|
+
xyvars,
|
|
10
|
+
} from './theme-vars.css'
|
|
43
11
|
|
|
44
|
-
export const xyvars = createGlobalThemeContract({
|
|
45
|
-
background: {
|
|
46
|
-
color: 'background-color',
|
|
47
|
-
pattern: {
|
|
48
|
-
color: 'background-pattern-color'
|
|
49
|
-
// dots: 'background-pattern-dots-color',
|
|
50
|
-
// lines: 'background-pattern-lines-color',
|
|
51
|
-
// cross: 'background-pattern-cross-color'
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
edge: {
|
|
55
|
-
stroke: 'edge-stroke',
|
|
56
|
-
strokeSelected: 'edge-stroke-selected',
|
|
57
|
-
labelColor: 'edge-label-color',
|
|
58
|
-
labelBgColor: 'edge-label-background-color',
|
|
59
|
-
strokeWidth: 'edge-stroke-width'
|
|
60
|
-
},
|
|
61
|
-
node: {
|
|
62
|
-
color: 'node-color',
|
|
63
|
-
border: 'node-border',
|
|
64
|
-
backgroundColor: 'node-background-color',
|
|
65
|
-
groupBackgroundColor: 'node-group-background-color',
|
|
66
|
-
boxshadowHover: 'node-boxshadow-hover',
|
|
67
|
-
boxshadowSelected: 'node-boxshadow-selected',
|
|
68
|
-
borderRadius: 'node-border-radius'
|
|
69
|
-
}
|
|
70
|
-
}, (value) => `xy-${value}`)
|
|
71
|
-
|
|
72
|
-
export const whereLight = ':where([data-mantine-color-scheme="light"])'
|
|
73
|
-
export const whereDark = ':where([data-mantine-color-scheme="dark"])'
|
|
74
|
-
|
|
75
|
-
export const easings = {
|
|
76
|
-
out: 'cubic-bezier(0, 0, 0.40, 1)',
|
|
77
|
-
inOut: 'cubic-bezier(0.50, 0, 0.2, 1)'
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const transitions = {
|
|
81
|
-
fast: `all 130ms ${easings.inOut}`
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// we need only variables names
|
|
85
12
|
export const mantine = themeToVars({})
|
|
@@ -5,19 +5,20 @@ import clsx from 'clsx'
|
|
|
5
5
|
import { AnimatePresence, m } from 'framer-motion'
|
|
6
6
|
import { type DiagramState, useDiagramState } from '../hooks'
|
|
7
7
|
import * as css from './DiagramTitlePanel.css'
|
|
8
|
+
import { Link } from './Link'
|
|
8
9
|
|
|
9
10
|
const selector = (s: DiagramState) => ({
|
|
10
11
|
id: s.view.id,
|
|
11
12
|
title: s.view.title ?? 'untitled',
|
|
12
13
|
description: s.view.description,
|
|
13
|
-
links: s.view.links
|
|
14
|
+
links: s.view.links,
|
|
14
15
|
})
|
|
15
16
|
|
|
16
17
|
export default function DiagramTitlePanel() {
|
|
17
18
|
const { id, title, description, links } = useDiagramState(selector)
|
|
18
19
|
const [isCollapsed, setCollapsed] = useLocalStorage({
|
|
19
20
|
key: 'diagram-title-webview-collapsed',
|
|
20
|
-
defaultValue: false
|
|
21
|
+
defaultValue: false,
|
|
21
22
|
})
|
|
22
23
|
const toggle = () => setCollapsed(v => !v)
|
|
23
24
|
|
|
@@ -45,11 +46,11 @@ export default function DiagramTitlePanel() {
|
|
|
45
46
|
animate={{ opacity: 1, scale: 1 }}
|
|
46
47
|
exit={{
|
|
47
48
|
opacity: 0.05,
|
|
48
|
-
scale: 0.6
|
|
49
|
+
scale: 0.6,
|
|
49
50
|
}}
|
|
50
51
|
className={clsx('react-flow__panel', css.container)}
|
|
51
52
|
style={{
|
|
52
|
-
transformOrigin: 'left center'
|
|
53
|
+
transformOrigin: 'left center',
|
|
53
54
|
}}
|
|
54
55
|
>
|
|
55
56
|
<Card
|
|
@@ -115,7 +116,7 @@ export default function DiagramTitlePanel() {
|
|
|
115
116
|
fw={500}
|
|
116
117
|
c={'dimmed'}
|
|
117
118
|
style={{
|
|
118
|
-
userSelect: 'all'
|
|
119
|
+
userSelect: 'all',
|
|
119
120
|
}}>
|
|
120
121
|
<span style={{ userSelect: 'none' }}>id:{' '}</span>
|
|
121
122
|
{id}
|
|
@@ -151,35 +152,7 @@ export default function DiagramTitlePanel() {
|
|
|
151
152
|
gap={3}
|
|
152
153
|
justify="stretch"
|
|
153
154
|
align="stretch">
|
|
154
|
-
{links.map((link) =>
|
|
155
|
-
<Group key={link.url} wrap="nowrap" align="center" gap={'sm'}>
|
|
156
|
-
<Box flex={'1'} style={{ overflow: 'hidden' }}>
|
|
157
|
-
<Anchor
|
|
158
|
-
href={link.url}
|
|
159
|
-
target="_blank"
|
|
160
|
-
fz="xs"
|
|
161
|
-
truncate="end"
|
|
162
|
-
display={'inline-block'}
|
|
163
|
-
w={'100%'}>
|
|
164
|
-
{link.title || link.url}
|
|
165
|
-
</Anchor>
|
|
166
|
-
</Box>
|
|
167
|
-
<CopyButton value={link.url}>
|
|
168
|
-
{({ copied, copy }) => (
|
|
169
|
-
<Button
|
|
170
|
-
size="compact-xs"
|
|
171
|
-
fz={'10'}
|
|
172
|
-
variant="light"
|
|
173
|
-
onClick={copy}
|
|
174
|
-
color={copied
|
|
175
|
-
? 'teal'
|
|
176
|
-
: 'gray'}>
|
|
177
|
-
{copied ? 'copied' : 'copy'}
|
|
178
|
-
</Button>
|
|
179
|
-
)}
|
|
180
|
-
</CopyButton>
|
|
181
|
-
</Group>
|
|
182
|
-
))}
|
|
155
|
+
{links.map((link) => <Link link={link} key={link.url} />)}
|
|
183
156
|
</Stack>
|
|
184
157
|
)}
|
|
185
158
|
</>
|
package/src/ui/Link.tsx
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Link } from '@likec4/core'
|
|
2
|
+
import { Anchor, Box, Button, CopyButton, Group } from '@mantine/core'
|
|
3
|
+
|
|
4
|
+
export function Link({ link }: { link: Link }) {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<Group key={link.url} wrap="nowrap" align="center" gap={'sm'}>
|
|
8
|
+
<Box flex={'1'} style={{ overflow: 'hidden' }}>
|
|
9
|
+
<Anchor
|
|
10
|
+
href={link.url}
|
|
11
|
+
target="_blank"
|
|
12
|
+
fz="xs"
|
|
13
|
+
truncate="end"
|
|
14
|
+
display={'inline-block'}
|
|
15
|
+
w={'100%'}
|
|
16
|
+
onClick={(e) => e.stopPropagation()}>
|
|
17
|
+
{link.title || link.url}
|
|
18
|
+
</Anchor>
|
|
19
|
+
</Box>
|
|
20
|
+
<CopyButton value={link.url}>
|
|
21
|
+
{({ copied, copy }) => (
|
|
22
|
+
<Button
|
|
23
|
+
size="compact-xs"
|
|
24
|
+
fz={'10'}
|
|
25
|
+
variant="light"
|
|
26
|
+
onClick={(e) => {
|
|
27
|
+
e.stopPropagation()
|
|
28
|
+
copy()
|
|
29
|
+
}}
|
|
30
|
+
color={copied
|
|
31
|
+
? 'teal'
|
|
32
|
+
: 'gray'}>
|
|
33
|
+
{copied ? 'copied' : 'copy'}
|
|
34
|
+
</Button>
|
|
35
|
+
)}
|
|
36
|
+
</CopyButton>
|
|
37
|
+
</Group>
|
|
38
|
+
</>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComputedNode, type ElementNotation as ElementNotationData } from '@likec4/core'
|
|
2
2
|
import {
|
|
3
3
|
ActionIcon,
|
|
4
4
|
Badge,
|
|
@@ -29,13 +29,15 @@ import { vars } from '../../theme-vars'
|
|
|
29
29
|
import { ElementShapeSvg } from '../../xyflow/nodes/element/ElementShapeSvg'
|
|
30
30
|
import * as css from './NotationPanel.css'
|
|
31
31
|
|
|
32
|
+
type NodeKind = ComputedNode['kind']
|
|
33
|
+
|
|
32
34
|
const ElementNotation = ({ value }: { value: ElementNotationData }) => {
|
|
33
35
|
const {
|
|
34
36
|
title,
|
|
35
37
|
color = 'primary',
|
|
36
38
|
shape = 'rectangle'
|
|
37
39
|
} = value
|
|
38
|
-
const [onlyKind, setOnlyKind] = useState<
|
|
40
|
+
const [onlyKind, setOnlyKind] = useState<NodeKind | null>(null)
|
|
39
41
|
const diagramStore = useDiagramStoreApi()
|
|
40
42
|
const w = 300
|
|
41
43
|
const h = 200
|
|
@@ -137,7 +137,7 @@ export const ChangeAutoLayoutButton = (props: PopoverProps) => {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
const MAX_SPACING = 400
|
|
140
|
-
const SpacingSliders = forwardRef<HTMLDivElement, {
|
|
140
|
+
const SpacingSliders = forwardRef<HTMLDivElement | null, {
|
|
141
141
|
isVertical: boolean
|
|
142
142
|
nodeSep: number | undefined
|
|
143
143
|
rankSep: number | undefined
|
|
@@ -160,7 +160,7 @@ const SpacingSliders = forwardRef<HTMLDivElement, {
|
|
|
160
160
|
onChange(Math.round(x * MAX_SPACING), Math.round(y * MAX_SPACING))
|
|
161
161
|
},
|
|
162
162
|
[onChange, isVertical],
|
|
163
|
-
|
|
163
|
+
250,
|
|
164
164
|
2000
|
|
165
165
|
)
|
|
166
166
|
|