@likec4/diagram 1.1.0 → 1.2.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/dist/KeepAspectRatioContainer.d.ts +1 -1
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.props.d.ts +22 -12
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2209 -706
- package/dist/mantine/EnsureMantine.d.ts +1 -1
- package/dist/state/DiagramContext.d.ts +2143 -19
- package/dist/state/WhenInitialized.d.ts +1 -1
- package/dist/state/diagramStore.d.ts +2152 -19
- package/dist/state/useDiagramStore.d.ts +2142 -18
- package/dist/style.css +256 -118
- package/dist/theme.css.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +3 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/OptionsPanel.d.ts +1 -3
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/options/NodeOptions.d.ts +1 -2
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -2
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SyncWithDiagram.d.ts +1 -2
- package/dist/xyflow/XYFlow.d.ts +4 -7
- package/dist/xyflow/XYFlowBackground.d.ts +5 -4
- package/dist/xyflow/XYFlowEvents.d.ts +84 -84
- package/dist/xyflow/XYFlowInner.d.ts +11 -0
- package/dist/xyflow/diagram-to-xyflow.d.ts +1 -1
- package/dist/xyflow/edges/RelationshipEdge.d.ts +14 -14
- package/dist/xyflow/edges/edges.css.d.ts +5 -2
- package/dist/xyflow/edges/utils.d.ts +2 -0
- package/dist/xyflow/hooks/useXYFlow.d.ts +126 -126
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementIcon.d.ts +1 -1
- package/dist/xyflow/nodes/element/ElementLink.d.ts +1 -1
- package/dist/xyflow/nodes/element/ElementNode.d.ts +1 -1
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +2 -2
- package/dist/xyflow/nodes/element/element.css.d.ts +2 -1
- package/dist/xyflow/nodes/shared/NavigateToBtn.d.ts +1 -2
- package/dist/xyflow/types.d.ts +18 -18
- package/package.json +21 -16
- package/src/KeepAspectRatioContainer.tsx +1 -1
- package/src/LikeC4Diagram.css.ts +4 -1
- package/src/LikeC4Diagram.props.ts +24 -14
- package/src/LikeC4Diagram.tsx +18 -9
- package/src/StaticLikeC4Diagram.tsx +2 -0
- package/src/globals.css.ts +7 -1
- package/src/index.ts +0 -3
- package/src/state/DiagramContext.tsx +21 -12
- package/src/state/diagramStore.ts +275 -98
- package/src/theme.css.ts +1 -0
- package/src/ui/DiagramTitlePanel.css.ts +33 -0
- package/src/ui/DiagramTitlePanel.tsx +138 -0
- package/src/ui/DynamicViewWalkthrough.css.ts +46 -0
- package/src/ui/DynamicViewWalkthrough.tsx +86 -0
- package/src/ui/OptionsPanel.tsx +7 -24
- package/src/ui/index.ts +1 -0
- package/src/ui/options/NodeOptions.tsx +103 -27
- package/src/xyflow/FitviewOnDiagramChange.tsx +89 -69
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +75 -0
- package/src/xyflow/SyncWithDiagram.tsx +55 -101
- package/src/xyflow/XYFlow.tsx +52 -32
- package/src/xyflow/XYFlowBackground.tsx +7 -5
- package/src/xyflow/XYFlowEvents.tsx +150 -104
- package/src/xyflow/XYFlowInner.tsx +50 -0
- package/src/xyflow/diagram-to-xyflow.ts +16 -21
- package/src/xyflow/edges/RelationshipEdge.tsx +102 -70
- package/src/xyflow/edges/edges.css.ts +128 -53
- package/src/xyflow/edges/utils.ts +31 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +20 -12
- package/src/xyflow/nodes/compound/CompoundNode.tsx +6 -3
- package/src/xyflow/nodes/element/ElementLink.tsx +13 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +24 -19
- package/src/xyflow/nodes/element/element.css.ts +10 -2
- package/src/xyflow/nodes/shared/NavigateToBtn.tsx +1 -0
- package/src/xyflow/types.ts +7 -8
|
@@ -68,7 +68,10 @@ export function ElementLink({
|
|
|
68
68
|
<span>links</span>
|
|
69
69
|
</UnstyledButton>
|
|
70
70
|
</HoverCardTarget>
|
|
71
|
-
<HoverCardDropdown
|
|
71
|
+
<HoverCardDropdown
|
|
72
|
+
onPointerDownCapture={e => e.stopPropagation()}
|
|
73
|
+
onClick={e => e.stopPropagation()}
|
|
74
|
+
p={'xs'}>
|
|
72
75
|
<Stack gap={'xs'}>
|
|
73
76
|
{element.links.map((link) => (
|
|
74
77
|
<Group key={link} wrap="nowrap" gap={'sm'}>
|
|
@@ -79,8 +82,15 @@ export function ElementLink({
|
|
|
79
82
|
</Box>
|
|
80
83
|
<CopyButton value={link}>
|
|
81
84
|
{({ copied, copy }) => (
|
|
82
|
-
<Button
|
|
83
|
-
|
|
85
|
+
<Button
|
|
86
|
+
size="compact-xs"
|
|
87
|
+
fz={'10'}
|
|
88
|
+
variant="light"
|
|
89
|
+
onClick={copy}
|
|
90
|
+
color={copied
|
|
91
|
+
? 'teal'
|
|
92
|
+
: 'gray'}>
|
|
93
|
+
{copied ? 'copied' : 'copy'}
|
|
84
94
|
</Button>
|
|
85
95
|
)}
|
|
86
96
|
</CopyButton>
|
|
@@ -7,16 +7,7 @@ import { useDiagramState } from '../../../state'
|
|
|
7
7
|
import type { ElementXYFlowNode } from '../../types'
|
|
8
8
|
import { toDomPrecision } from '../../utils'
|
|
9
9
|
import { NavigateToBtn } from '../shared/NavigateToBtn'
|
|
10
|
-
import
|
|
11
|
-
container,
|
|
12
|
-
cssElement,
|
|
13
|
-
cssNavigateBtn,
|
|
14
|
-
cssShapeSvg,
|
|
15
|
-
description as cssdescription,
|
|
16
|
-
indicator,
|
|
17
|
-
technology as csstechnology,
|
|
18
|
-
title as cssTitle
|
|
19
|
-
} from './element.css'
|
|
10
|
+
import * as css from './element.css'
|
|
20
11
|
import { ElementIcon } from './ElementIcon'
|
|
21
12
|
import { ElementLink } from './ElementLink'
|
|
22
13
|
import { ElementShapeSvg, SelectedIndicator } from './ElementShapeSvg'
|
|
@@ -38,6 +29,13 @@ const variants = {
|
|
|
38
29
|
delay: isNumber(scale) && scale > selectedScale ? 0.075 : 0
|
|
39
30
|
}
|
|
40
31
|
}),
|
|
32
|
+
// dimmed: {
|
|
33
|
+
// filter: 'brightness(0.5)',
|
|
34
|
+
// transition: {
|
|
35
|
+
// duration: 0.8,
|
|
36
|
+
// ease: 'easeInOut',
|
|
37
|
+
// }
|
|
38
|
+
// },
|
|
41
39
|
// dragging: {
|
|
42
40
|
// scale: selectedScale
|
|
43
41
|
// },
|
|
@@ -76,8 +74,9 @@ export function ElementNode({
|
|
|
76
74
|
width,
|
|
77
75
|
height
|
|
78
76
|
}: ElementNodeProps) {
|
|
79
|
-
const { isHovered, hasOnNavigateTo, isHovercards, isInteractive } = useDiagramState(s => ({
|
|
77
|
+
const { isHovered, isDimmed, hasOnNavigateTo, isHovercards, isInteractive } = useDiagramState(s => ({
|
|
80
78
|
isHovered: s.hoveredNodeId === id,
|
|
79
|
+
isDimmed: s.dimmed.has(id),
|
|
81
80
|
isInteractive: s.nodesDraggable || s.nodesSelectable || !!s.onNavigateTo,
|
|
82
81
|
isHovercards: s.showElementLinks,
|
|
83
82
|
hasOnNavigateTo: !!s.onNavigateTo
|
|
@@ -112,7 +111,11 @@ export function ElementNode({
|
|
|
112
111
|
return (
|
|
113
112
|
<motion.div
|
|
114
113
|
id={id}
|
|
115
|
-
className={clsx(
|
|
114
|
+
className={clsx([
|
|
115
|
+
css.container,
|
|
116
|
+
isDimmed && css.dimmed,
|
|
117
|
+
'likec4-element-node'
|
|
118
|
+
])}
|
|
116
119
|
data-likec4-color={element.color}
|
|
117
120
|
data-likec4-shape={element.shape}
|
|
118
121
|
variants={variants}
|
|
@@ -162,12 +165,14 @@ export function ElementNode({
|
|
|
162
165
|
style={{ visibility: 'hidden' }}
|
|
163
166
|
/>
|
|
164
167
|
<svg
|
|
165
|
-
className={
|
|
168
|
+
className={clsx(
|
|
169
|
+
css.cssShapeSvg
|
|
170
|
+
)}
|
|
166
171
|
viewBox={`0 0 ${w} ${h}`}
|
|
167
172
|
width={w}
|
|
168
173
|
height={h}
|
|
169
174
|
>
|
|
170
|
-
<g className={indicator}>
|
|
175
|
+
<g className={css.indicator}>
|
|
171
176
|
<SelectedIndicator
|
|
172
177
|
shape={element.shape}
|
|
173
178
|
w={w}
|
|
@@ -180,24 +185,24 @@ export function ElementNode({
|
|
|
180
185
|
h={h}
|
|
181
186
|
/>
|
|
182
187
|
</svg>
|
|
183
|
-
<div className={clsx(
|
|
188
|
+
<div className={clsx(css.element, 'likec4-element')}>
|
|
184
189
|
{element.icon && <ElementIcon node={element} />}
|
|
185
190
|
<Text
|
|
186
191
|
component="div"
|
|
187
|
-
className={clsx(
|
|
192
|
+
className={clsx(css.title, 'likec4-element-title')}>
|
|
188
193
|
{element.title}
|
|
189
194
|
</Text>
|
|
190
195
|
{element.technology && (
|
|
191
196
|
<Text
|
|
192
197
|
component="div"
|
|
193
|
-
className={clsx(
|
|
198
|
+
className={clsx(css.technology, 'likec4-element-technology')}>
|
|
194
199
|
{element.technology}
|
|
195
200
|
</Text>
|
|
196
201
|
)}
|
|
197
202
|
{element.description && (
|
|
198
203
|
<Text
|
|
199
204
|
component="div"
|
|
200
|
-
className={clsx(
|
|
205
|
+
className={clsx(css.description, 'likec4-element-description')}>
|
|
201
206
|
{element.description}
|
|
202
207
|
</Text>
|
|
203
208
|
)}
|
|
@@ -219,7 +224,7 @@ export function ElementNode({
|
|
|
219
224
|
))} */
|
|
220
225
|
}
|
|
221
226
|
{isHovercards && element.links && <ElementLink element={element} />}
|
|
222
|
-
{isNavigable && <NavigateToBtn xynodeId={id} className={cssNavigateBtn} />}
|
|
227
|
+
{isNavigable && <NavigateToBtn xynodeId={id} className={css.cssNavigateBtn} />}
|
|
223
228
|
</motion.div>
|
|
224
229
|
)
|
|
225
230
|
}
|
|
@@ -13,11 +13,19 @@ export const container = style({
|
|
|
13
13
|
height: '100%',
|
|
14
14
|
padding: 0,
|
|
15
15
|
margin: 0,
|
|
16
|
+
backfaceVisibility: 'hidden',
|
|
16
17
|
vars: {
|
|
17
18
|
[stokeFillMix]: `color-mix(in srgb, ${vars.element.stroke} 90%, ${vars.element.fill})`
|
|
18
19
|
}
|
|
19
20
|
})
|
|
20
21
|
|
|
22
|
+
export const dimmed = style({})
|
|
23
|
+
|
|
24
|
+
globalStyle(`.react-flow__node:has(${dimmed})`, {
|
|
25
|
+
filter: vars.filterDimmed,
|
|
26
|
+
transition: 'filter 800ms ease-out'
|
|
27
|
+
})
|
|
28
|
+
|
|
21
29
|
const indicatorKeyframes = generateIdentifier('indicator')
|
|
22
30
|
globalKeyframes(indicatorKeyframes, {
|
|
23
31
|
'from': {
|
|
@@ -91,7 +99,7 @@ export const description = style({
|
|
|
91
99
|
fontStyle: 'normal',
|
|
92
100
|
fontWeight: 400,
|
|
93
101
|
fontSize: rem(14),
|
|
94
|
-
lineHeight: 1.
|
|
102
|
+
lineHeight: 1.25,
|
|
95
103
|
textAlign: 'center',
|
|
96
104
|
textWrap: 'pretty',
|
|
97
105
|
color: vars.element.loContrast,
|
|
@@ -119,7 +127,7 @@ export const technology = style({
|
|
|
119
127
|
}
|
|
120
128
|
})
|
|
121
129
|
|
|
122
|
-
export const
|
|
130
|
+
export const element = style({
|
|
123
131
|
position: 'relative',
|
|
124
132
|
width: '100%',
|
|
125
133
|
height: '100%',
|
|
@@ -14,6 +14,7 @@ export function NavigateToBtn({ xynodeId, className }: NavigateToBtnProps) {
|
|
|
14
14
|
<ActionIcon
|
|
15
15
|
className={clsx('nodrag nopan', className)}
|
|
16
16
|
radius="xl"
|
|
17
|
+
onPointerDownCapture={e => e.stopPropagation()}
|
|
17
18
|
onClick={event => {
|
|
18
19
|
event.stopPropagation()
|
|
19
20
|
diagramApi.getState().triggerOnNavigateTo(xynodeId, event)
|
package/src/xyflow/types.ts
CHANGED
|
@@ -24,6 +24,10 @@ type TypedXYFlowNode<D extends Record<string, unknown>, T extends string> = SetR
|
|
|
24
24
|
SetRequired<Node<D, T>, 'type'>,
|
|
25
25
|
'id' | 'type'
|
|
26
26
|
>
|
|
27
|
+
type TypedXYFlowEdge<D extends Record<string, unknown>, T extends string> = SetReadonly<
|
|
28
|
+
SetRequired<Edge<D, T>, 'type' | 'data'>,
|
|
29
|
+
'id' | 'type'
|
|
30
|
+
>
|
|
27
31
|
|
|
28
32
|
export type ElementXYFlowNode = TypedXYFlowNode<ElementNodeData, 'element'>
|
|
29
33
|
|
|
@@ -57,20 +61,15 @@ export type RelationshipData = {
|
|
|
57
61
|
headPoint: Point | null
|
|
58
62
|
tailPoint: Point | null
|
|
59
63
|
type: 'bezier' | 'poly'
|
|
64
|
+
// if dynamic view
|
|
65
|
+
stepNum: number | null
|
|
60
66
|
label: null | {
|
|
61
67
|
bbox: BBox
|
|
62
68
|
text: string
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
export type RelationshipEdge =
|
|
67
|
-
SetRequired<
|
|
68
|
-
Omit<Edge<RelationshipData>, 'type'>,
|
|
69
|
-
'data'
|
|
70
|
-
> & {
|
|
71
|
-
type: 'relationship'
|
|
72
|
-
}
|
|
73
|
-
>
|
|
72
|
+
export type RelationshipEdge = TypedXYFlowEdge<RelationshipData, 'relationship'>
|
|
74
73
|
|
|
75
74
|
export type XYFlowEdge = RelationshipEdge
|
|
76
75
|
|