@likec4/diagram 1.27.2 → 1.28.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/bundle/index.js +715 -616
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeActionButton.d.ts +1 -2
- package/dist/base/primitives/edge/EdgeLabelContainer.js +3 -2
- package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
- package/dist/base/primitives/element/ElementActionButtons.d.ts +1 -1
- package/dist/base/primitives/element/ElementActionButtons.js +11 -7
- package/dist/base/primitives/element/ElementDetailsButton.js +5 -1
- package/dist/bundle/styles.css.js +2 -2
- package/dist/hooks/useDiagram.d.ts +2 -2
- package/dist/hooks/useDiagram.js +9 -20
- package/dist/hooks/useXYFlow.d.ts +2 -2
- package/dist/likec4diagram/DiagramXYFlow.js +6 -6
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +11 -1
- package/dist/likec4diagram/custom/index.d.ts +2 -1
- package/dist/likec4diagram/ui/notation/NotationPanel.js +0 -1
- package/dist/overlays/Overlays.js +2 -2
- package/dist/overlays/element-details/actor.d.ts +303 -303
- package/dist/overlays/overlay/Overlay.css.d.ts +2 -25
- package/dist/overlays/overlay/Overlay.css.js +3 -43
- package/dist/overlays/overlay/Overlay.d.ts +1 -1
- package/dist/overlays/overlay/Overlay.js +97 -90
- package/dist/overlays/overlaysActor.js +4 -1
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
- package/dist/overlays/relationship-details/actor.d.ts +16 -7
- package/dist/overlays/relationship-details/actor.js +1 -6
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationship-details/hooks.d.ts +2 -3
- package/dist/overlays/relationship-details/hooks.js +2 -5
- package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -4
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
- package/dist/overlays/relationships-browser/actor.d.ts +2 -3
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.d.ts +2 -3
- package/dist/overlays/relationships-browser/hooks.js +5 -8
- package/dist/overlays/relationships-browser/layout.d.ts +1 -1
- package/dist/overlays/relationships-browser/layout.js +2 -6
- package/dist/state/diagram-machine.d.ts +2 -2
- package/dist/state/hotkeyActor.js +12 -3
- package/dist/styles.css.js +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/package.json +10 -10
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -3
- package/src/base/primitives/edge/EdgeActionButton.tsx +1 -2
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +7 -5
- package/src/base/primitives/element/ElementActionButtons.tsx +11 -9
- package/src/base/primitives/element/ElementDetailsButton.tsx +4 -0
- package/src/base/primitives/element/ElementNodeContainer.css.ts +0 -18
- package/src/bundle/styles.css.ts +7 -2
- package/src/components/SearchControl.css.ts +4 -8
- package/src/hooks/useDiagram.ts +9 -20
- package/src/likec4diagram/DiagramXYFlow.tsx +6 -6
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +7 -1
- package/src/likec4diagram/custom/edges/edges.css.ts +0 -2
- package/src/likec4diagram/ui/notation/NotationPanel.css.ts +0 -4
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +0 -1
- package/src/likec4diagram/ui/search/ViewsColumn.css.ts +0 -4
- package/src/overlays/Overlays.tsx +3 -3
- package/src/overlays/overlay/Overlay.css.ts +3 -43
- package/src/overlays/overlay/Overlay.tsx +108 -101
- package/src/overlays/overlaysActor.ts +5 -1
- package/src/overlays/relationship-details/actor.ts +1 -6
- package/src/overlays/relationship-details/custom/nodeTypes.tsx +1 -1
- package/src/overlays/relationship-details/hooks.ts +2 -5
- package/src/overlays/relationship-details/layout-to-xyflow.ts +2 -25
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +1 -1
- package/src/overlays/relationships-browser/hooks.ts +5 -8
- package/src/overlays/relationships-browser/layout.ts +3 -20
- package/src/state/hotkeyActor.ts +13 -3
- package/src/utils/index.ts +0 -1
- package/dist/utils/types.d.ts +0 -8
- package/src/utils/types.ts +0 -6
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
} from '@mantine/core'
|
|
6
6
|
import { useMergedRef } from '@mantine/hooks'
|
|
7
7
|
import { useDebouncedCallback, useSyncedRef, useTimeoutEffect } from '@react-hookz/web'
|
|
8
|
-
import {
|
|
9
|
-
import { type PropsWithChildren, forwardRef,
|
|
8
|
+
import { m, useReducedMotionConfig } from 'framer-motion'
|
|
9
|
+
import { type PropsWithChildren, forwardRef, useEffect, useRef, useState } from 'react'
|
|
10
10
|
import { stopPropagation } from '../../utils'
|
|
11
|
-
import { backdropBlur, backdropOpacity, overlay as overlayCVA } from './Overlay.css'
|
|
11
|
+
import { backdropBlur, backdropOpacity, level as cssVarLevel, overlay as overlayCVA } from './Overlay.css'
|
|
12
12
|
|
|
13
13
|
type OverlayProps = PropsWithChildren<{
|
|
14
|
-
overlayLevel?:
|
|
14
|
+
overlayLevel?: number
|
|
15
15
|
className?: string
|
|
16
16
|
classes?: {
|
|
17
17
|
dialog?: string
|
|
@@ -21,110 +21,117 @@ type OverlayProps = PropsWithChildren<{
|
|
|
21
21
|
onClick?: never
|
|
22
22
|
}>
|
|
23
23
|
|
|
24
|
-
export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(({
|
|
25
|
+
onClose,
|
|
26
|
+
className,
|
|
27
|
+
classes,
|
|
28
|
+
overlayLevel = 0,
|
|
29
|
+
children,
|
|
30
|
+
...rest
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const [opened, setOpened] = useState(false)
|
|
33
|
+
const dialogRef = useRef<HTMLDialogElement>(null)
|
|
34
|
+
const isClosingRef = useRef(false)
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
const motionNotReduced = useReducedMotionConfig() !== true
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const onCloseRef = useSyncedRef(onClose)
|
|
39
|
+
const close = useDebouncedCallback(
|
|
40
|
+
() => {
|
|
41
|
+
if (isClosingRef.current) return
|
|
42
|
+
isClosingRef.current = true
|
|
43
|
+
onCloseRef.current()
|
|
44
|
+
},
|
|
45
|
+
[],
|
|
46
|
+
50,
|
|
47
|
+
)
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const cancel = (e: Event) => {
|
|
51
|
+
e.preventDefault()
|
|
52
|
+
close()
|
|
53
|
+
}
|
|
54
|
+
dialogRef.current?.addEventListener('cancel', cancel, { capture: true })
|
|
55
|
+
return () => {
|
|
56
|
+
dialogRef.current?.removeEventListener('cancel', cancel, { capture: true })
|
|
57
|
+
}
|
|
58
|
+
}, [])
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
useTimeoutEffect(() => {
|
|
61
|
+
if (!dialogRef.current?.open) {
|
|
62
|
+
// Move dialog to the top of the DOM
|
|
63
|
+
dialogRef.current?.showModal()
|
|
64
|
+
}
|
|
65
|
+
}, 30)
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
useTimeoutEffect(() => {
|
|
68
|
+
setOpened(true)
|
|
69
|
+
}, 120)
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
const styles = overlayCVA({
|
|
72
|
+
level: overlayLevel as 0 | 1 | 2 | 3,
|
|
73
|
+
})
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
scale: 1.3,
|
|
94
|
-
opacity: 0,
|
|
95
|
-
translateY: -10,
|
|
96
|
-
[backdropBlur]: '0px',
|
|
97
|
-
[backdropOpacity]: '0%',
|
|
75
|
+
return (
|
|
76
|
+
<m.dialog
|
|
77
|
+
ref={useMergedRef(dialogRef, ref)}
|
|
78
|
+
className={cx(RemoveScroll.classNames.fullWidth, styles.dialog, classes?.dialog, className)}
|
|
79
|
+
layout
|
|
80
|
+
style={{
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
[cssVarLevel]: overlayLevel,
|
|
83
|
+
}}
|
|
84
|
+
{...motionNotReduced
|
|
85
|
+
? ({
|
|
86
|
+
initial: {
|
|
87
|
+
[backdropBlur]: '0px',
|
|
88
|
+
[backdropOpacity]: '0%',
|
|
89
|
+
scale: overlayLevel > 0 ? 0.9 : 1.075,
|
|
90
|
+
opacity: 0,
|
|
91
|
+
},
|
|
92
|
+
animate: {
|
|
93
|
+
[backdropBlur]: overlayLevel > 0 ? '4px' : '8px',
|
|
94
|
+
[backdropOpacity]: overlayLevel > 0 ? '50%' : '60%',
|
|
95
|
+
scale: 1,
|
|
96
|
+
opacity: 1,
|
|
97
|
+
transition: {
|
|
98
|
+
delay: 0.075,
|
|
98
99
|
},
|
|
99
|
-
}
|
|
100
|
-
: {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
}}
|
|
113
|
-
onDoubleClick={stopPropagation}
|
|
114
|
-
onPointerDown={stopPropagation}
|
|
115
|
-
onClose={e => {
|
|
116
|
-
e.stopPropagation()
|
|
117
|
-
close()
|
|
100
|
+
},
|
|
101
|
+
exit: {
|
|
102
|
+
scale: 1.2,
|
|
103
|
+
opacity: 0,
|
|
104
|
+
[backdropBlur]: '0px',
|
|
105
|
+
[backdropOpacity]: '0%',
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
: {
|
|
109
|
+
initial: {
|
|
110
|
+
[backdropBlur]: '8px',
|
|
111
|
+
[backdropOpacity]: '60%',
|
|
112
|
+
},
|
|
118
113
|
}}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
114
|
+
onClick={e => {
|
|
115
|
+
e.stopPropagation()
|
|
116
|
+
if ((e.target as any)?.nodeName?.toUpperCase() === 'DIALOG') {
|
|
117
|
+
dialogRef.current?.close()
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
onDoubleClick={stopPropagation}
|
|
122
|
+
onPointerDown={stopPropagation}
|
|
123
|
+
onClose={e => {
|
|
124
|
+
e.stopPropagation()
|
|
125
|
+
close()
|
|
126
|
+
}}
|
|
127
|
+
{...rest}
|
|
128
|
+
>
|
|
129
|
+
<RemoveScroll forwardProps removeScrollBar={false}>
|
|
130
|
+
<Box className={cx(styles.body, 'overlay-body', classes?.body)}>
|
|
131
|
+
{opened && <>{children}</>}
|
|
132
|
+
</Box>
|
|
133
|
+
</RemoveScroll>
|
|
134
|
+
</m.dialog>
|
|
135
|
+
)
|
|
136
|
+
})
|
|
130
137
|
Overlay.displayName = 'Overlay'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Fqn } from '@likec4/core'
|
|
2
2
|
import { getHotkeyHandler } from '@mantine/hooks'
|
|
3
|
+
import type { KeyboardEvent } from 'react'
|
|
3
4
|
import { isString, last, reverse } from 'remeda'
|
|
4
5
|
import {
|
|
5
6
|
type ActorLogicFrom,
|
|
@@ -45,7 +46,10 @@ const hotkeyLogic = fromCallback(({ sendBack }: {
|
|
|
45
46
|
sendBack: (event: HotKeyEvent) => void
|
|
46
47
|
}) => {
|
|
47
48
|
const handler = getHotkeyHandler([
|
|
48
|
-
['Escape', () =>
|
|
49
|
+
['Escape', (event: KeyboardEvent) => {
|
|
50
|
+
event.stopPropagation()
|
|
51
|
+
sendBack({ type: 'close' })
|
|
52
|
+
}, {
|
|
49
53
|
preventDefault: true,
|
|
50
54
|
}],
|
|
51
55
|
])
|
|
@@ -321,12 +321,7 @@ export const relationshipDetailsLogic = setup({
|
|
|
321
321
|
actions: [
|
|
322
322
|
'updateLayoutData',
|
|
323
323
|
cancel('fitDiagram'),
|
|
324
|
-
{
|
|
325
|
-
type: 'xyflow:fitDiagram',
|
|
326
|
-
params: {
|
|
327
|
-
duration: 0,
|
|
328
|
-
},
|
|
329
|
-
},
|
|
324
|
+
raise({ type: 'fitDiagram', duration: 0 }, { id: 'fitDiagram', delay: 50 }),
|
|
330
325
|
raise({ type: 'xyflow.updateNodeInternals' }, { delay: 75 }),
|
|
331
326
|
],
|
|
332
327
|
},
|
|
@@ -33,7 +33,7 @@ export const ElementNode = customNode<RelationshipDetailsTypes.ElementNodeData>(
|
|
|
33
33
|
return (
|
|
34
34
|
<ElementNodeContainer nodeProps={props}>
|
|
35
35
|
<ElementShape {...props} />
|
|
36
|
-
<ElementTitle {...props}
|
|
36
|
+
<ElementTitle {...props} />
|
|
37
37
|
<ElementDetailsButtonWithHandler {...props} />
|
|
38
38
|
<ElementActions {...props} />
|
|
39
39
|
<ElementPorts {...props} />
|
|
@@ -2,7 +2,7 @@ import { type EdgeId, type Fqn, nonNullable } from '@likec4/core'
|
|
|
2
2
|
import { useCallbackRef } from '@mantine/hooks'
|
|
3
3
|
import { useSelector } from '@xstate/react'
|
|
4
4
|
import { shallowEqual } from 'fast-equals'
|
|
5
|
-
import { createContext, useContext, useMemo
|
|
5
|
+
import { createContext, useContext, useMemo } from 'react'
|
|
6
6
|
import type { OverlaysActorRef } from '../overlaysActor'
|
|
7
7
|
import type { RelationshipDetailsActorRef, RelationshipDetailsSnapshot } from './actor'
|
|
8
8
|
|
|
@@ -23,7 +23,6 @@ export function useRelationshipDetailsState<T = unknown>(
|
|
|
23
23
|
|
|
24
24
|
export function useRelationshipDetails() {
|
|
25
25
|
const actor = useRelationshipDetailsActor()
|
|
26
|
-
const [, startTransition] = useTransition()
|
|
27
26
|
return useMemo(() => ({
|
|
28
27
|
actor,
|
|
29
28
|
get rootElementId(): string {
|
|
@@ -39,9 +38,7 @@ export function useRelationshipDetails() {
|
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
fitDiagram: () => {
|
|
42
|
-
|
|
43
|
-
actor.send({ type: 'fitDiagram' })
|
|
44
|
-
})
|
|
41
|
+
actor.send({ type: 'fitDiagram' })
|
|
45
42
|
},
|
|
46
43
|
close: () => {
|
|
47
44
|
if (actor._parent) {
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import dagre, { type GraphLabel, type Label } from '@dagrejs/dagre'
|
|
2
1
|
import {
|
|
3
|
-
type AbstractRelation,
|
|
4
|
-
type DiagramEdge,
|
|
5
|
-
type DiagramView,
|
|
6
|
-
type EdgeId,
|
|
7
2
|
type Fqn,
|
|
8
|
-
type LikeC4Model,
|
|
9
|
-
type XYPoint,
|
|
10
|
-
compareFqnHierarchically,
|
|
11
|
-
compareRelations,
|
|
12
|
-
DiagramNode,
|
|
13
|
-
invariant,
|
|
14
|
-
isAncestor,
|
|
15
3
|
nonNullable,
|
|
16
4
|
Queue,
|
|
17
5
|
} from '@likec4/core'
|
|
18
|
-
import {
|
|
19
|
-
import { deepEqual } from 'fast-equals'
|
|
20
|
-
import { useMemo } from 'react'
|
|
21
|
-
import { filter, first, forEach, hasAtLeast, isTruthy, map, pipe, prop, reverse, sort, sortBy, takeWhile } from 'remeda'
|
|
6
|
+
import { hasAtLeast } from 'remeda'
|
|
22
7
|
import { ZIndexes } from '../../base/const'
|
|
23
|
-
import { useLikeC4Model } from '../../likec4model'
|
|
24
8
|
import type { RelationshipDetailsTypes } from './_types'
|
|
25
|
-
import type
|
|
26
|
-
import {
|
|
27
|
-
type RelationshipDetailsViewData,
|
|
28
|
-
computeEdgeDetailsViewData,
|
|
29
|
-
computeRelationshipDetailsViewData,
|
|
30
|
-
} from './compute'
|
|
31
|
-
import { useRelationshipDetailsActor, useRelationshipDetailsState } from './hooks'
|
|
32
|
-
import { type LayoutResult, layoutRelationshipDetails } from './layout'
|
|
9
|
+
import { type LayoutResult } from './layout'
|
|
33
10
|
|
|
34
11
|
// const nodeZIndex = (node: DiagramNode) => node.level - (node.children.length > 0 ? 1 : 0)
|
|
35
12
|
export function layoutResultToXYFlow(
|
|
@@ -36,7 +36,7 @@ export const ElementNode = customNode<RelationshipsBrowserTypes.ElementNodeData>
|
|
|
36
36
|
return (
|
|
37
37
|
<ElementNodeContainer key={props.id} component={m.div} layoutId={props.id} nodeProps={props}>
|
|
38
38
|
<ElementShape {...props} />
|
|
39
|
-
<ElementTitle {...props}
|
|
39
|
+
<ElementTitle {...props} />
|
|
40
40
|
<ElementDetailsButtonWithHandler {...props} />
|
|
41
41
|
<ElementActions {...props} />
|
|
42
42
|
<ElementPorts {...props} />
|
|
@@ -2,7 +2,7 @@ import { type Fqn, nonNullable } from '@likec4/core'
|
|
|
2
2
|
import { useCallbackRef } from '@mantine/hooks'
|
|
3
3
|
import { useSelector } from '@xstate/react'
|
|
4
4
|
import { shallowEqual } from 'fast-equals'
|
|
5
|
-
import { createContext, useContext, useMemo
|
|
5
|
+
import { createContext, useContext, useMemo } from 'react'
|
|
6
6
|
import type { OverlaysActorRef } from '../overlaysActor'
|
|
7
7
|
import type { RelationshipsBrowserActorRef, RelationshipsBrowserSnapshot } from './actor'
|
|
8
8
|
import type { LayoutRelationshipsViewResult } from './layout'
|
|
@@ -23,7 +23,6 @@ export function useRelationshipsBrowserState<T>(
|
|
|
23
23
|
|
|
24
24
|
export function useRelationshipsBrowser() {
|
|
25
25
|
const actor = useRelationshipsBrowserActor()
|
|
26
|
-
const [, startTransition] = useTransition()
|
|
27
26
|
return useMemo(() => ({
|
|
28
27
|
actor,
|
|
29
28
|
get rootElementId(): string {
|
|
@@ -44,12 +43,10 @@ export function useRelationshipsBrowser() {
|
|
|
44
43
|
})
|
|
45
44
|
},
|
|
46
45
|
navigateTo: (subject: Fqn, fromNode?: string) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
fromNode,
|
|
52
|
-
})
|
|
46
|
+
actor.send({
|
|
47
|
+
type: 'navigate.to',
|
|
48
|
+
subject,
|
|
49
|
+
fromNode,
|
|
53
50
|
})
|
|
54
51
|
},
|
|
55
52
|
fitDiagram: () => {
|
|
@@ -55,7 +55,7 @@ const Sizes = {
|
|
|
55
55
|
edgesep: 25,
|
|
56
56
|
} satisfies GraphLabel,
|
|
57
57
|
edgeLabel: {
|
|
58
|
-
width:
|
|
58
|
+
width: 140,
|
|
59
59
|
height: 10,
|
|
60
60
|
minlen: 1,
|
|
61
61
|
weight: 1,
|
|
@@ -97,19 +97,6 @@ function createGraph() {
|
|
|
97
97
|
g.setDefaultEdgeLabel(() => ({ ...Sizes.edgeLabel }))
|
|
98
98
|
g.setDefaultNodeLabel(() => ({}))
|
|
99
99
|
|
|
100
|
-
// columns.reduce((prev, column) => {
|
|
101
|
-
// const c = graphColumn(column)
|
|
102
|
-
// g.setNode(c.id, {})
|
|
103
|
-
// g.setNode(c.anchor, { width: 40, height: 2 })
|
|
104
|
-
// g.setParent(c.anchor, c.id)
|
|
105
|
-
// if (prev) {
|
|
106
|
-
// g.setEdge(prev, c.anchor, {
|
|
107
|
-
// width: 0
|
|
108
|
-
// })
|
|
109
|
-
// }
|
|
110
|
-
// return c.anchor
|
|
111
|
-
// }, null as string | null)
|
|
112
|
-
|
|
113
100
|
return g
|
|
114
101
|
}
|
|
115
102
|
type G = ReturnType<typeof createGraph>
|
|
@@ -212,7 +199,7 @@ export type LayoutRelationshipsViewResult = {
|
|
|
212
199
|
export namespace LayoutRelationshipsViewResult {
|
|
213
200
|
export const Empty = '@empty' as ElementKind
|
|
214
201
|
|
|
215
|
-
export type Node = DiagramNode & {
|
|
202
|
+
export type Node = Omit<DiagramNode, 'deploymentRef' | 'inEdges' | 'outEdges'> & {
|
|
216
203
|
column: RelationshipsBrowserTypes.Column
|
|
217
204
|
ports: RelationshipsBrowserTypes.Ports
|
|
218
205
|
existsInCurrentView: boolean
|
|
@@ -368,7 +355,7 @@ export function layoutRelationshipsView(
|
|
|
368
355
|
for (const edge of g.edges()) {
|
|
369
356
|
g.setEdge(edge, {
|
|
370
357
|
...Sizes.edgeLabel,
|
|
371
|
-
width: edgeCount >
|
|
358
|
+
width: edgeCount > 25 ? 800 : 400,
|
|
372
359
|
})
|
|
373
360
|
}
|
|
374
361
|
}
|
|
@@ -492,8 +479,6 @@ export function layoutRelationshipsView(
|
|
|
492
479
|
width: width,
|
|
493
480
|
height: height,
|
|
494
481
|
},
|
|
495
|
-
inEdges: [],
|
|
496
|
-
outEdges: [],
|
|
497
482
|
children: [],
|
|
498
483
|
width,
|
|
499
484
|
height,
|
|
@@ -546,8 +531,6 @@ export function layoutRelationshipsView(
|
|
|
546
531
|
...element.$element.style,
|
|
547
532
|
},
|
|
548
533
|
navigateTo,
|
|
549
|
-
inEdges: [],
|
|
550
|
-
outEdges: [],
|
|
551
534
|
...(children.length > 0 && { depth: nodeDepth(id) }),
|
|
552
535
|
children,
|
|
553
536
|
width,
|
package/src/state/hotkeyActor.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getHotkeyHandler } from '@mantine/hooks'
|
|
2
|
+
import type { KeyboardEvent } from 'react'
|
|
2
3
|
import { type AnyEventObject, type NonReducibleUnknown, fromCallback } from 'xstate'
|
|
3
4
|
|
|
4
5
|
export type HotKeyEvent = { type: 'key.esc' | `key.arrow.${'left' | 'right'}` }
|
|
@@ -7,16 +8,25 @@ export const hotkeyActorLogic = fromCallback<AnyEventObject, NonReducibleUnknown
|
|
|
7
8
|
sendBack: (event: HotKeyEvent) => void
|
|
8
9
|
}) => {
|
|
9
10
|
const escHandler = getHotkeyHandler([
|
|
10
|
-
['Escape', () =>
|
|
11
|
+
['Escape', (event: KeyboardEvent) => {
|
|
12
|
+
event.stopPropagation()
|
|
13
|
+
sendBack({ type: 'key.esc' })
|
|
14
|
+
}, {
|
|
11
15
|
preventDefault: true,
|
|
12
16
|
}],
|
|
13
17
|
])
|
|
14
18
|
|
|
15
19
|
const arrowshandler = getHotkeyHandler([
|
|
16
|
-
['ArrowLeft', () =>
|
|
20
|
+
['ArrowLeft', (event: KeyboardEvent) => {
|
|
21
|
+
event.stopPropagation()
|
|
22
|
+
sendBack({ type: 'key.arrow.left' })
|
|
23
|
+
}, {
|
|
17
24
|
preventDefault: true,
|
|
18
25
|
}],
|
|
19
|
-
['ArrowRight', () =>
|
|
26
|
+
['ArrowRight', (event: KeyboardEvent) => {
|
|
27
|
+
event.stopPropagation()
|
|
28
|
+
sendBack({ type: 'key.arrow.right' })
|
|
29
|
+
}, {
|
|
20
30
|
preventDefault: true,
|
|
21
31
|
}],
|
|
22
32
|
])
|
package/src/utils/index.ts
CHANGED
package/dist/utils/types.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Edge, Node } from '@xyflow/react';
|
|
2
|
-
import { Merge } from 'type-fest';
|
|
3
|
-
export type AddNodeData<T extends Node, Data> = Omit<T, 'data'> & {
|
|
4
|
-
data: Merge<T['data'], Data>;
|
|
5
|
-
};
|
|
6
|
-
export type AddEdgeData<T extends Edge, Data> = Omit<T, 'data'> & {
|
|
7
|
-
data: Merge<T['data'], Data>;
|
|
8
|
-
};
|
package/src/utils/types.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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> }
|