@likec4/diagram 1.21.1 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LikeC4Diagram.js +9 -13
- package/dist/base/index.d.ts +0 -1
- package/dist/base/primitives/element/styles.css.js +1 -1
- package/dist/{base → components}/Link.css.js +3 -3
- package/dist/components/SearchControl.css.d.ts +2 -0
- package/dist/components/SearchControl.css.js +7 -0
- package/dist/components/SearchControl.d.ts +5 -0
- package/dist/components/SearchControl.js +17 -0
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/IconRenderer.d.ts +10 -0
- package/dist/context/IconRenderer.js +34 -0
- package/dist/hooks/useCurrentViewId.js +8 -0
- package/dist/hooks/useDiagram.d.ts +108 -72
- package/dist/hooks/useDiagram.js +3 -0
- package/dist/likec4diagram/DiagramActor.js +13 -2
- package/dist/likec4diagram/DiagramUI.js +0 -2
- package/dist/likec4diagram/XYFlow.d.ts +6 -1
- package/dist/likec4diagram/XYFlow.js +37 -31
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +2 -1
- package/dist/likec4diagram/state/actorContext.d.ts +620 -468
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/machine.d.ts +120 -74
- package/dist/likec4diagram/state/machine.js +32 -12
- package/dist/likec4diagram/state/syncManualLayoutActor.js +4 -8
- package/dist/likec4diagram/ui/controls/Controls.js +65 -48
- package/dist/likec4diagram/ui/controls/NavigationButtons.js +44 -69
- package/dist/likec4diagram/ui/controls/ToggleReadonly.d.ts +1 -0
- package/dist/likec4diagram/ui/controls/ToggleReadonly.js +29 -0
- package/dist/likec4diagram/ui/controls/_shared.js +1 -1
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +1 -1
- package/dist/likec4diagram/ui/search/ElementsColumn.css.d.ts +15 -0
- package/dist/likec4diagram/ui/search/ElementsColumn.css.js +30 -0
- package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +1 -0
- package/dist/likec4diagram/ui/search/ElementsColumn.js +243 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.css.d.ts +8 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.css.js +20 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +1 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.js +265 -0
- package/dist/likec4diagram/ui/search/SearchInput.d.ts +1 -0
- package/dist/likec4diagram/ui/search/SearchInput.js +196 -0
- package/dist/likec4diagram/ui/search/ViewsColum.d.ts +9 -0
- package/dist/likec4diagram/ui/search/ViewsColum.js +130 -0
- package/dist/likec4diagram/ui/search/ViewsColumn.css.d.ts +5 -0
- package/dist/likec4diagram/ui/search/ViewsColumn.css.js +12 -0
- package/dist/likec4diagram/ui/search/_shared.css.d.ts +16 -0
- package/dist/likec4diagram/ui/search/_shared.css.js +5 -0
- package/dist/likec4diagram/ui/search/state.d.ts +19 -0
- package/dist/likec4diagram/ui/search/state.js +72 -0
- package/dist/likec4diagram/ui/search/utils.d.ts +3 -0
- package/dist/likec4diagram/ui/search/utils.js +23 -0
- package/dist/likec4diagram/useLayoutConstraints.js +4 -5
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +1 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -0
- package/dist/overlays/Overlays.js +9 -9
- package/dist/overlays/element-details/ElementDetailsCard.js +20 -13
- package/dist/overlays/overlay/Overlay.d.ts +6 -2
- package/dist/overlays/overlay/Overlay.js +18 -29
- package/dist/overlays/relationship-details/SelectEdge.js +1 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -5
- package/dist/overlays/relationships-browser/SelectElement.js +10 -6
- package/dist/overlays/relationships-browser/actor.d.ts +2 -2
- package/dist/overlays/relationships-browser/actor.js +8 -8
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +13 -13
- package/src/LikeC4Diagram.tsx +0 -1
- package/src/base/index.ts +0 -2
- package/src/base/primitives/element/styles.css.ts +2 -2
- package/src/{base → components}/Link.css.ts +3 -3
- package/src/components/SearchControl.css.ts +69 -0
- package/src/components/SearchControl.tsx +33 -0
- package/src/context/DiagramFeatures.tsx +1 -1
- package/src/context/IconRenderer.tsx +54 -1
- package/src/globals.css.ts +0 -2
- package/src/hooks/useDiagram.ts +5 -0
- package/src/likec4diagram/DiagramActor.tsx +15 -2
- package/src/likec4diagram/DiagramUI.tsx +0 -4
- package/src/likec4diagram/XYFlow.tsx +39 -31
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +2 -1
- package/src/likec4diagram/state/assign.ts +1 -1
- package/src/likec4diagram/state/machine.ts +40 -14
- package/src/likec4diagram/state/syncManualLayoutActor.ts +6 -9
- package/src/likec4diagram/ui/controls/Controls.tsx +37 -25
- package/src/likec4diagram/ui/controls/NavigationButtons.tsx +36 -58
- package/src/likec4diagram/ui/controls/ToggleReadonly.tsx +31 -0
- package/src/likec4diagram/ui/controls/styles.css.ts +3 -1
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +1 -1
- package/src/likec4diagram/ui/search/ElementsColumn.css.ts +119 -0
- package/src/likec4diagram/ui/search/ElementsColumn.tsx +291 -0
- package/src/likec4diagram/ui/search/LikeC4Search.css.ts +117 -0
- package/src/likec4diagram/ui/search/LikeC4Search.tsx +312 -0
- package/src/likec4diagram/ui/search/SearchInput.tsx +235 -0
- package/src/likec4diagram/ui/search/ViewsColum.tsx +158 -0
- package/src/likec4diagram/ui/search/ViewsColumn.css.ts +37 -0
- package/src/likec4diagram/ui/search/_shared.css.ts +104 -0
- package/src/likec4diagram/ui/search/state.ts +76 -0
- package/src/likec4diagram/ui/search/utils.ts +20 -0
- package/src/likec4diagram/useLayoutConstraints.ts +4 -5
- package/src/likec4model/useLikeC4ElementsTree.ts +4 -4
- package/src/overlays/Overlays.tsx +31 -25
- package/src/overlays/element-details/ElementDetailsCard.css.ts +4 -4
- package/src/overlays/element-details/ElementDetailsCard.tsx +245 -240
- package/src/overlays/overlay/Overlay.css.ts +10 -9
- package/src/overlays/overlay/Overlay.tsx +38 -26
- package/src/overlays/relationship-details/SelectEdge.css.ts +1 -0
- package/src/overlays/relationship-details/SelectEdge.tsx +2 -4
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +10 -5
- package/src/overlays/relationships-browser/SelectElement.tsx +88 -82
- package/src/overlays/relationships-browser/actor.ts +10 -10
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +2 -2
- package/dist/LikeC4Search.css.d.ts +0 -1
- package/dist/LikeC4Search.css.js +0 -5
- package/dist/LikeC4Search.d.ts +0 -2
- package/dist/LikeC4Search.js +0 -88
- package/src/LikeC4Search.css.ts +0 -12
- package/src/LikeC4Search.tsx +0 -91
- /package/dist/{base → components}/Link.css.d.ts +0 -0
- /package/dist/{base → components}/Link.d.ts +0 -0
- /package/dist/{base → components}/Link.js +0 -0
- /package/src/{base → components}/Link.tsx +0 -0
|
@@ -2,27 +2,28 @@ import {
|
|
|
2
2
|
Box,
|
|
3
3
|
RemoveScroll,
|
|
4
4
|
} from '@mantine/core'
|
|
5
|
-
import {
|
|
6
|
-
import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web'
|
|
5
|
+
import { useDebouncedCallback, useSyncedRef, useTimeoutEffect } from '@react-hookz/web'
|
|
7
6
|
import clsx from 'clsx'
|
|
8
7
|
import { type HTMLMotionProps, m } from 'framer-motion'
|
|
9
|
-
import { type PropsWithChildren,
|
|
8
|
+
import { type PropsWithChildren, useRef, useState } from 'react'
|
|
10
9
|
import * as css from './Overlay.css'
|
|
11
10
|
|
|
12
11
|
type OverlayProps = PropsWithChildren<
|
|
13
12
|
HTMLMotionProps<'dialog'> & {
|
|
13
|
+
classes?: {
|
|
14
|
+
dialog?: string
|
|
15
|
+
body?: string
|
|
16
|
+
}
|
|
14
17
|
onClose: () => void
|
|
15
18
|
onClick?: never
|
|
16
19
|
}
|
|
17
20
|
>
|
|
18
21
|
|
|
19
|
-
export
|
|
22
|
+
export function Overlay({ children, onClose, className, classes, ...rest }: OverlayProps) {
|
|
20
23
|
const [opened, setOpened] = useState(false)
|
|
21
24
|
const dialogRef = useRef<HTMLDialogElement>(null)
|
|
22
25
|
|
|
23
26
|
// Move dialog to the top of the DOM
|
|
24
|
-
// useLayoutEffect(() => dialogRef.current?.showModal(), [])
|
|
25
|
-
|
|
26
27
|
const onCloseRef = useSyncedRef(onClose)
|
|
27
28
|
const close = useDebouncedCallback(
|
|
28
29
|
() => {
|
|
@@ -31,22 +32,37 @@ export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(({ children,
|
|
|
31
32
|
[],
|
|
32
33
|
50,
|
|
33
34
|
)
|
|
35
|
+
// const close = useCallbackRef(() => {
|
|
36
|
+
// if (isOpenedRef.current) {
|
|
37
|
+
// isOpenedRef.current = false
|
|
38
|
+
// requestAnimationFrame(() => {
|
|
39
|
+
// onClose()
|
|
40
|
+
// })
|
|
41
|
+
// }
|
|
42
|
+
// })
|
|
34
43
|
|
|
35
|
-
useLayoutEffect(() => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
// useLayoutEffect(() => {
|
|
45
|
+
// const cancel = (e: Event) => {
|
|
46
|
+
// e.preventDefault()
|
|
47
|
+
// close()
|
|
48
|
+
// }
|
|
49
|
+
// dialogRef.current?.addEventListener('cancel', cancel, { capture: true })
|
|
50
|
+
// return () => {
|
|
51
|
+
// dialogRef.current?.removeEventListener('cancel', cancel, { capture: true })
|
|
52
|
+
// }
|
|
53
|
+
// }, [])
|
|
54
|
+
|
|
55
|
+
useTimeoutEffect(() => {
|
|
56
|
+
if (!dialogRef.current?.open) {
|
|
57
|
+
dialogRef.current?.showModal()
|
|
43
58
|
}
|
|
44
|
-
|
|
59
|
+
setOpened(true)
|
|
60
|
+
}, 30)
|
|
45
61
|
|
|
46
62
|
return (
|
|
47
63
|
<m.dialog
|
|
48
|
-
ref={
|
|
49
|
-
className={clsx(css.dialog, className)}
|
|
64
|
+
ref={dialogRef}
|
|
65
|
+
className={clsx(css.dialog, classes?.dialog, className)}
|
|
50
66
|
initial={{
|
|
51
67
|
'--backdrop-blur': '0px',
|
|
52
68
|
'--backdrop-opacity': '5%',
|
|
@@ -63,12 +79,8 @@ export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(({ children,
|
|
|
63
79
|
// delay: 0.25,
|
|
64
80
|
// }
|
|
65
81
|
}}
|
|
66
|
-
onAnimationStart={() => {
|
|
67
|
-
dialogRef.current?.showModal()
|
|
68
|
-
setOpened(true)
|
|
69
|
-
}}
|
|
70
82
|
exit={{
|
|
71
|
-
opacity: 0
|
|
83
|
+
opacity: 0,
|
|
72
84
|
translateY: -10,
|
|
73
85
|
'--backdrop-blur': '0px',
|
|
74
86
|
'--backdrop-opacity': '0%',
|
|
@@ -79,21 +91,21 @@ export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(({ children,
|
|
|
79
91
|
onClick={e => {
|
|
80
92
|
if ((e.target as any)?.nodeName?.toUpperCase() === 'DIALOG') {
|
|
81
93
|
e.stopPropagation()
|
|
82
|
-
close()
|
|
94
|
+
dialogRef.current?.close()
|
|
95
|
+
return
|
|
83
96
|
}
|
|
84
97
|
}}
|
|
85
98
|
onClose={e => {
|
|
86
|
-
e.preventDefault()
|
|
87
99
|
e.stopPropagation()
|
|
88
100
|
close()
|
|
89
101
|
}}
|
|
90
102
|
{...rest}
|
|
91
103
|
>
|
|
92
104
|
<RemoveScroll forwardProps>
|
|
93
|
-
<Box className={css.body}>
|
|
105
|
+
<Box className={clsx(css.body, classes?.body)}>
|
|
94
106
|
{opened && <>{children}</>}
|
|
95
107
|
</Box>
|
|
96
108
|
</RemoveScroll>
|
|
97
109
|
</m.dialog>
|
|
98
110
|
)
|
|
99
|
-
}
|
|
111
|
+
}
|
|
@@ -104,9 +104,9 @@ export const SelectEdge = ({
|
|
|
104
104
|
</Box>
|
|
105
105
|
</Button>
|
|
106
106
|
</PopoverTarget>
|
|
107
|
-
<PopoverDropdown p={0} miw={250} maw={
|
|
107
|
+
<PopoverDropdown p={0} miw={250} maw={400}>
|
|
108
108
|
<ScrollAreaAutosize className={css.scrollArea} scrollbars="y" type="never" viewportRef={viewport}>
|
|
109
|
-
<Box className={css.edgeGrid} p="xs">
|
|
109
|
+
<Box className={css.edgeGrid} p="xs" maw={400}>
|
|
110
110
|
{edges.map(e => (
|
|
111
111
|
<div
|
|
112
112
|
key={e.id}
|
|
@@ -118,7 +118,6 @@ export const SelectEdge = ({
|
|
|
118
118
|
}}>
|
|
119
119
|
<Box
|
|
120
120
|
className={css.edgeSource}
|
|
121
|
-
maw={160}
|
|
122
121
|
mod={{
|
|
123
122
|
'edge-id': e.id,
|
|
124
123
|
'likec4-color': e.source.color,
|
|
@@ -133,7 +132,6 @@ export const SelectEdge = ({
|
|
|
133
132
|
</Box>
|
|
134
133
|
<Box
|
|
135
134
|
className={css.edgeTarget}
|
|
136
|
-
maw={160}
|
|
137
135
|
mod={{
|
|
138
136
|
'likec4-color': e.target.color,
|
|
139
137
|
}}
|
|
@@ -5,8 +5,8 @@ import { IconChevronLeft, IconChevronRight, IconX } from '@tabler/icons-react'
|
|
|
5
5
|
import { Panel, ReactFlowProvider, useStoreApi } from '@xyflow/react'
|
|
6
6
|
import clsx from 'clsx'
|
|
7
7
|
import { shallowEqual } from 'fast-equals'
|
|
8
|
-
import { AnimatePresence, m } from 'framer-motion'
|
|
9
|
-
import { memo, useEffect, useRef } from 'react'
|
|
8
|
+
import { AnimatePresence, LayoutGroup, m } from 'framer-motion'
|
|
9
|
+
import { memo, useEffect, useId, useRef } from 'react'
|
|
10
10
|
import type { SnapshotFrom } from 'xstate'
|
|
11
11
|
import { BaseXYFlow } from '../../base/BaseXYFlow'
|
|
12
12
|
import { useRelationshipsView } from './-useRelationshipsView'
|
|
@@ -26,6 +26,7 @@ export type RelationshipsBrowserProps = {
|
|
|
26
26
|
actorRef: RelationshipsBrowserActorRef
|
|
27
27
|
}
|
|
28
28
|
export function RelationshipsBrowser({ actorRef }: RelationshipsBrowserProps) {
|
|
29
|
+
const id = useId()
|
|
29
30
|
// const actorRef = useDiagramActorState(s => s.children.relationshipsBrowser)
|
|
30
31
|
// if (actorRef == null) {
|
|
31
32
|
// return null
|
|
@@ -45,7 +46,11 @@ export function RelationshipsBrowser({ actorRef }: RelationshipsBrowserProps) {
|
|
|
45
46
|
return (
|
|
46
47
|
<RelationshipsBrowserActorContext.Provider value={actorRef}>
|
|
47
48
|
<ReactFlowProvider {...initialRef.current}>
|
|
48
|
-
<
|
|
49
|
+
<AnimatePresence>
|
|
50
|
+
<LayoutGroup id={id}>
|
|
51
|
+
<RelationshipsBrowserXYFlow />
|
|
52
|
+
</LayoutGroup>
|
|
53
|
+
</AnimatePresence>
|
|
49
54
|
</ReactFlowProvider>
|
|
50
55
|
</RelationshipsBrowserActorContext.Provider>
|
|
51
56
|
)
|
|
@@ -114,10 +119,10 @@ const RelationshipsBrowserXYFlow = memo(() => {
|
|
|
114
119
|
browser.send({ type: 'xyflow.resized' })
|
|
115
120
|
})}
|
|
116
121
|
onNodesChange={useCallbackRef((changes) => {
|
|
117
|
-
browser.send({ type: 'xyflow.
|
|
122
|
+
browser.send({ type: 'xyflow.applyNodeChanges', changes })
|
|
118
123
|
})}
|
|
119
124
|
onEdgesChange={useCallbackRef((changes) => {
|
|
120
|
-
browser.send({ type: 'xyflow.
|
|
125
|
+
browser.send({ type: 'xyflow.applyEdgeChanges', changes })
|
|
121
126
|
})}
|
|
122
127
|
nodesDraggable={false}
|
|
123
128
|
fitView={false}
|
|
@@ -47,88 +47,94 @@ export const SelectElement = ({
|
|
|
47
47
|
const theme = useComputedColorScheme()
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
50
|
+
<Box pos={'relative'}>
|
|
51
|
+
<Popover
|
|
52
|
+
position="bottom-start"
|
|
53
|
+
shadow="md"
|
|
54
|
+
keepMounted={false}
|
|
55
|
+
withinPortal={false}
|
|
56
|
+
closeOnClickOutside
|
|
57
|
+
clickOutsideEvents={['pointerdown', 'mousedown', 'click']}
|
|
58
|
+
onOpen={() => {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
const item = viewport.current?.querySelector(`[data-value="${subjectId}"]`)
|
|
61
|
+
item?.scrollIntoView({ behavior: 'instant', block: 'nearest' })
|
|
62
|
+
}, 100)
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<PopoverTarget>
|
|
66
|
+
<Button
|
|
67
|
+
size="xs"
|
|
68
|
+
variant="light"
|
|
69
|
+
color={theme === 'light' ? 'dark' : 'gray'}
|
|
70
|
+
fw={'500'}
|
|
71
|
+
maw={250}
|
|
72
|
+
style={{ padding: '0.25rem 0.75rem' }}
|
|
73
|
+
rightSection={<IconSelector size={16} />}
|
|
74
|
+
>
|
|
75
|
+
{subject?.title ?? '???'}
|
|
76
|
+
</Button>
|
|
77
|
+
</PopoverTarget>
|
|
78
|
+
<PopoverDropdown p={0} miw={250} maw={400}>
|
|
79
|
+
<ScrollAreaAutosize scrollbars="y" type="never" viewportRef={viewport} className={classes.scrollArea}>
|
|
80
|
+
<Tree
|
|
81
|
+
allowRangeSelection={false}
|
|
82
|
+
selectOnClick={false}
|
|
83
|
+
tree={tree}
|
|
84
|
+
data={data}
|
|
85
|
+
classNames={classes}
|
|
86
|
+
levelOffset={8}
|
|
87
|
+
styles={{
|
|
88
|
+
root: {
|
|
89
|
+
maxWidth: 400,
|
|
90
|
+
overflow: 'hidden',
|
|
91
|
+
},
|
|
92
|
+
label: {
|
|
93
|
+
paddingTop: 5,
|
|
94
|
+
paddingBottom: 6,
|
|
95
|
+
},
|
|
96
|
+
}}
|
|
97
|
+
renderNode={({ node, selected, expanded, elementProps, hasChildren }) => (
|
|
98
|
+
<Group gap={2} wrap="nowrap" {...elementProps} py="3">
|
|
99
|
+
<ActionIcon
|
|
100
|
+
variant="subtle"
|
|
101
|
+
size={18}
|
|
102
|
+
// color={theme === 'light' ? 'gray' : 'gray'}
|
|
103
|
+
c={'dimmed'}
|
|
104
104
|
style={{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
105
|
+
visibility: hasChildren ? 'visible' : 'hidden',
|
|
106
|
+
}}>
|
|
107
|
+
<IconChevronRight
|
|
108
|
+
stroke={3.5}
|
|
109
|
+
style={{
|
|
110
|
+
transition: 'transform 150ms ease',
|
|
111
|
+
transform: `rotate(${expanded ? '90deg' : '0'})`,
|
|
112
|
+
width: '80%',
|
|
113
|
+
}} />
|
|
114
|
+
</ActionIcon>
|
|
115
|
+
<Box
|
|
116
|
+
flex={'1 1 100%'}
|
|
117
|
+
w={'100%'}
|
|
118
|
+
// gap={3}
|
|
119
|
+
onClick={e => {
|
|
120
|
+
e.stopPropagation()
|
|
121
|
+
onSelect(node.value as Fqn)
|
|
122
|
+
tree.select(node.value)
|
|
123
|
+
tree.expand(node.value)
|
|
124
|
+
}}>
|
|
125
|
+
<Text
|
|
126
|
+
fz="sm"
|
|
127
|
+
fw={selected ? '600' : '400'}
|
|
128
|
+
truncate="end">
|
|
129
|
+
{node.label}
|
|
130
|
+
</Text>
|
|
131
|
+
</Box>
|
|
132
|
+
</Group>
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
</ScrollAreaAutosize>
|
|
136
|
+
</PopoverDropdown>
|
|
137
|
+
</Popover>
|
|
138
|
+
</Box>
|
|
133
139
|
)
|
|
134
140
|
}
|
|
@@ -72,8 +72,8 @@ export type Events =
|
|
|
72
72
|
| { type: 'xyflow.init'; instance: XYFLowInstance; store: XYStoreApi }
|
|
73
73
|
| { type: 'xyflow.nodeClick'; node: RelationshipsBrowserTypes.Node }
|
|
74
74
|
| { type: 'xyflow.edgeClick'; edge: RelationshipsBrowserTypes.Edge }
|
|
75
|
-
| { type: 'xyflow.
|
|
76
|
-
| { type: 'xyflow.
|
|
75
|
+
| { type: 'xyflow.applyNodeChanges'; changes: NodeChange<RelationshipsBrowserTypes.Node>[] }
|
|
76
|
+
| { type: 'xyflow.applyEdgeChanges'; changes: EdgeChange<RelationshipsBrowserTypes.Edge>[] }
|
|
77
77
|
| { type: 'xyflow.paneClick' }
|
|
78
78
|
| { type: 'xyflow.paneDblClick' }
|
|
79
79
|
| { type: 'xyflow.resized' }
|
|
@@ -198,7 +198,7 @@ export const relationshipsBrowserActor = setup({
|
|
|
198
198
|
!nextSubjectNode || !existingNode || nextSubjectNode.type === 'empty' || !currentSubjectNode ||
|
|
199
199
|
nextSubjectNode.data.fqn === currentSubjectNode.data.fqn
|
|
200
200
|
) {
|
|
201
|
-
xyflow.setViewport(nextviewport)
|
|
201
|
+
await xyflow.setViewport(nextviewport)
|
|
202
202
|
return updateXYData()
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -280,7 +280,7 @@ export const relationshipsBrowserActor = setup({
|
|
|
280
280
|
return updateXYData()
|
|
281
281
|
}
|
|
282
282
|
await xyflow.setCenter(currentSubjectCenter.x, currentSubjectCenter.y, { zoom, duration: 350 })
|
|
283
|
-
xyflow.setCenter(nextSubjectCenter.x, nextSubjectCenter.y, { zoom })
|
|
283
|
+
await xyflow.setCenter(nextSubjectCenter.x, nextSubjectCenter.y, { zoom })
|
|
284
284
|
return updateXYData()
|
|
285
285
|
}),
|
|
286
286
|
},
|
|
@@ -372,11 +372,11 @@ export const relationshipsBrowserActor = setup({
|
|
|
372
372
|
xyedges: ({ event }) => event.xyedges,
|
|
373
373
|
}),
|
|
374
374
|
},
|
|
375
|
-
'xyflow.
|
|
376
|
-
// actions: log('layouting: ignore xyflow.
|
|
375
|
+
'xyflow.applyEdgeChanges': {
|
|
376
|
+
// actions: log('layouting: ignore xyflow.applyEdgeChanges'),
|
|
377
377
|
},
|
|
378
|
-
'xyflow.
|
|
379
|
-
// actions: log('layouting: ignore xyflow.
|
|
378
|
+
'xyflow.applyNodeChanges': {
|
|
379
|
+
// actions: log('layouting: ignore xyflow.applyNodeChanges'),
|
|
380
380
|
},
|
|
381
381
|
},
|
|
382
382
|
},
|
|
@@ -447,14 +447,14 @@ export const relationshipsBrowserActor = setup({
|
|
|
447
447
|
},
|
|
448
448
|
},
|
|
449
449
|
on: {
|
|
450
|
-
'xyflow.
|
|
450
|
+
'xyflow.applyNodeChanges': {
|
|
451
451
|
actions: assign({
|
|
452
452
|
xynodes: ({ context, event }) => {
|
|
453
453
|
return applyNodeChanges(event.changes, context.xynodes)
|
|
454
454
|
},
|
|
455
455
|
}),
|
|
456
456
|
},
|
|
457
|
-
'xyflow.
|
|
457
|
+
'xyflow.applyEdgeChanges': {
|
|
458
458
|
actions: assign({
|
|
459
459
|
xyedges: ({ context, event }) => {
|
|
460
460
|
return applyEdgeChanges(event.changes, context.xyedges)
|
|
@@ -17,7 +17,7 @@ import { EmptyNode } from './EmptyNode'
|
|
|
17
17
|
export const nodeTypes = {
|
|
18
18
|
element: customNode<RelationshipsBrowserTypes.ElementNodeData>((props) => {
|
|
19
19
|
return (
|
|
20
|
-
<ElementNodeContainer component={m.div} layoutId={props.id} nodeProps={props}>
|
|
20
|
+
<ElementNodeContainer key={props.id} component={m.div} layoutId={props.id} nodeProps={props}>
|
|
21
21
|
<ElementShape {...props} />
|
|
22
22
|
<ElementTitle {...props} iconSize={40} />
|
|
23
23
|
<ElementActions {...props} />
|
|
@@ -28,7 +28,7 @@ export const nodeTypes = {
|
|
|
28
28
|
|
|
29
29
|
compound: customNode<RelationshipsBrowserTypes.CompoundNodeData>((props) => {
|
|
30
30
|
return (
|
|
31
|
-
<CompoundNodeContainer component={m.div} layoutId={props.id} nodeProps={props}>
|
|
31
|
+
<CompoundNodeContainer key={props.id} component={m.div} layoutId={props.id} nodeProps={props}>
|
|
32
32
|
<CompoundTitle {...props} />
|
|
33
33
|
<CompoundPorts {...props} />
|
|
34
34
|
</CompoundNodeContainer>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const actionSection: string;
|
package/dist/LikeC4Search.css.js
DELETED
package/dist/LikeC4Search.d.ts
DELETED
package/dist/LikeC4Search.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { rem } from "@mantine/core";
|
|
3
|
-
import { Spotlight } from "@mantine/spotlight";
|
|
4
|
-
import { IconSearch, IconRectangularPrism, IconStack2, IconSitemap } from "@tabler/icons-react";
|
|
5
|
-
import { memo, useMemo } from "react";
|
|
6
|
-
import { pipe, filter, map } from "remeda";
|
|
7
|
-
import { useDiagram } from "./hooks/useDiagram.js";
|
|
8
|
-
import { useDiagramContext } from "./hooks/useDiagramContext.js";
|
|
9
|
-
import { actionSection } from "./LikeC4Search.css.js";
|
|
10
|
-
import { useLikeC4Model } from "./likec4model/useLikeC4Model.js";
|
|
11
|
-
import { useMantinePortalProps } from "./hooks/useMantinePortalProps.js";
|
|
12
|
-
const LikeC4Search = memo(() => {
|
|
13
|
-
const view = useDiagramContext((s) => s.view);
|
|
14
|
-
const model = useLikeC4Model(true);
|
|
15
|
-
const diagram = useDiagram();
|
|
16
|
-
const getNodeActionsData = () => {
|
|
17
|
-
return pipe(
|
|
18
|
-
view.nodes,
|
|
19
|
-
filter((n) => !!n.title),
|
|
20
|
-
map((n) => ({
|
|
21
|
-
id: n.id,
|
|
22
|
-
label: n.title,
|
|
23
|
-
...n.description && {
|
|
24
|
-
description: n.description
|
|
25
|
-
},
|
|
26
|
-
keywords: [
|
|
27
|
-
n.title,
|
|
28
|
-
...(n.tags ?? []).map((t) => `#${t}`),
|
|
29
|
-
...n.description ? [n.description] : []
|
|
30
|
-
].filter((k) => k.toLowerCase()),
|
|
31
|
-
onClick: () => diagram.focusNode(n.id),
|
|
32
|
-
leftSection: /* @__PURE__ */ jsx(IconRectangularPrism, {})
|
|
33
|
-
}))
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
const getViewActionsData = () => {
|
|
37
|
-
const views = [...model.views()];
|
|
38
|
-
return map(views, (v) => ({
|
|
39
|
-
id: v.id,
|
|
40
|
-
label: v.title ?? v.id,
|
|
41
|
-
...v.$view.description && {
|
|
42
|
-
description: v.$view.description
|
|
43
|
-
},
|
|
44
|
-
keywords: [
|
|
45
|
-
v.title ?? v.id,
|
|
46
|
-
...v.tags ?? [],
|
|
47
|
-
...v.$view.description ? [v.$view.description] : []
|
|
48
|
-
],
|
|
49
|
-
onClick: () => {
|
|
50
|
-
diagram.navigateTo(v.id);
|
|
51
|
-
},
|
|
52
|
-
leftSection: v.isDeploymentView() ? /* @__PURE__ */ jsx(IconStack2, {}) : /* @__PURE__ */ jsx(IconSitemap, {})
|
|
53
|
-
}));
|
|
54
|
-
};
|
|
55
|
-
const actions = useMemo(() => [
|
|
56
|
-
{
|
|
57
|
-
group: "Elements",
|
|
58
|
-
actions: getNodeActionsData()
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
group: "Views",
|
|
62
|
-
actions: getViewActionsData()
|
|
63
|
-
}
|
|
64
|
-
], [model, diagram, view]);
|
|
65
|
-
const portalProps = useMantinePortalProps();
|
|
66
|
-
return /* @__PURE__ */ jsx(
|
|
67
|
-
Spotlight,
|
|
68
|
-
{
|
|
69
|
-
...portalProps,
|
|
70
|
-
actions,
|
|
71
|
-
nothingFound: "Nothing found...",
|
|
72
|
-
shortcut: ["mod + f", "mod + k"],
|
|
73
|
-
scrollable: true,
|
|
74
|
-
highlightQuery: true,
|
|
75
|
-
maxHeight: 350,
|
|
76
|
-
classNames: {
|
|
77
|
-
actionSection
|
|
78
|
-
},
|
|
79
|
-
searchProps: {
|
|
80
|
-
leftSection: /* @__PURE__ */ jsx(IconSearch, { style: { width: rem(18), height: rem(18) }, stroke: 1.5 }),
|
|
81
|
-
placeholder: "Search elements and views..."
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
export {
|
|
87
|
-
LikeC4Search
|
|
88
|
-
};
|
package/src/LikeC4Search.css.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { rem } from '@mantine/core'
|
|
2
|
-
import { globalStyle, style } from '@vanilla-extract/css'
|
|
3
|
-
|
|
4
|
-
export const actionSection = style({
|
|
5
|
-
marginInlineEnd: 4
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
globalStyle(`:where(${actionSection}) .tabler-icon`, {
|
|
9
|
-
opacity: 0.8,
|
|
10
|
-
width: '70%',
|
|
11
|
-
height: '70%'
|
|
12
|
-
})
|