@likec4/diagram 1.1.1 → 1.2.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/KeepAspectRatioContainer.d.ts +1 -1
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.props.d.ts +10 -5
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/hooks/useUpdateEffect.d.ts +1 -1
- package/dist/icons/Clipboard.d.ts +1 -1
- package/dist/icons/Link.d.ts +1 -1
- package/dist/icons/ZoomIn.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2604 -1502
- package/dist/mantine/EnsureMantine.d.ts +1 -1
- package/dist/state/DiagramContext.d.ts +2307 -192
- package/dist/state/WhenInitialized.d.ts +1 -1
- package/dist/state/diagramStore.d.ts +2220 -97
- package/dist/state/useDiagramStore.d.ts +2124 -9
- package/dist/style.css +210 -136
- package/dist/theme.css.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -2
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +3 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/OptionsPanel.d.ts +1 -2
- 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/SyncWithDiagram.d.ts +1 -2
- package/dist/xyflow/XYFlow.d.ts +5 -8
- package/dist/xyflow/XYFlowBackground.d.ts +6 -5
- package/dist/xyflow/XYFlowEvents.d.ts +60 -66
- package/dist/xyflow/XYFlowInner.d.ts +11 -0
- package/dist/xyflow/diagram-to-xyflow.d.ts +2 -2
- package/dist/xyflow/edges/RelationshipEdge.d.ts +17 -17
- package/dist/xyflow/edges/edges.css.d.ts +4 -2
- package/dist/xyflow/edges/utils.d.ts +3 -1
- package/dist/xyflow/hooks/useLayoutConstraints.d.ts +1 -1
- package/dist/xyflow/hooks/useXYFlow.d.ts +162 -162
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +1 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +1 -1
- 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 +2 -2
- 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 +23 -23
- package/package.json +23 -21
- package/src/KeepAspectRatioContainer.tsx +1 -1
- package/src/LikeC4Diagram.css.ts +2 -0
- package/src/LikeC4Diagram.props.ts +9 -4
- package/src/LikeC4Diagram.tsx +17 -11
- package/src/StaticLikeC4Diagram.tsx +1 -0
- package/src/globals.css.ts +1 -0
- package/src/index.ts +0 -3
- package/src/state/DiagramContext.tsx +21 -12
- package/src/state/diagramStore.ts +177 -38
- package/src/theme.css.ts +1 -0
- package/src/ui/DiagramTitlePanel.css.ts +2 -1
- package/src/ui/DiagramTitlePanel.tsx +3 -4
- package/src/ui/DynamicViewWalkthrough.css.ts +46 -0
- package/src/ui/DynamicViewWalkthrough.tsx +86 -0
- package/src/ui/OptionsPanel.tsx +5 -3
- package/src/ui/index.ts +1 -0
- package/src/ui/options/NodeOptions.tsx +23 -24
- package/src/xyflow/FitviewOnDiagramChange.tsx +89 -69
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +57 -39
- package/src/xyflow/SyncWithDiagram.tsx +55 -107
- package/src/xyflow/XYFlow.tsx +51 -35
- package/src/xyflow/XYFlowBackground.tsx +7 -5
- package/src/xyflow/XYFlowEvents.tsx +100 -95
- package/src/xyflow/XYFlowInner.tsx +50 -0
- package/src/xyflow/diagram-to-xyflow.ts +16 -21
- package/src/xyflow/edges/RelationshipEdge.tsx +70 -34
- package/src/xyflow/edges/edges.css.ts +68 -34
- package/src/xyflow/edges/utils.ts +31 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +6 -2
- 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 +9 -2
- package/src/xyflow/nodes/shared/NavigateToBtn.tsx +1 -0
- package/src/xyflow/types.ts +7 -8
|
@@ -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
|
}
|
|
@@ -19,6 +19,13 @@ export const container = style({
|
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
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
|
+
|
|
22
29
|
const indicatorKeyframes = generateIdentifier('indicator')
|
|
23
30
|
globalKeyframes(indicatorKeyframes, {
|
|
24
31
|
'from': {
|
|
@@ -92,7 +99,7 @@ export const description = style({
|
|
|
92
99
|
fontStyle: 'normal',
|
|
93
100
|
fontWeight: 400,
|
|
94
101
|
fontSize: rem(14),
|
|
95
|
-
lineHeight: 1.
|
|
102
|
+
lineHeight: 1.25,
|
|
96
103
|
textAlign: 'center',
|
|
97
104
|
textWrap: 'pretty',
|
|
98
105
|
color: vars.element.loContrast,
|
|
@@ -120,7 +127,7 @@ export const technology = style({
|
|
|
120
127
|
}
|
|
121
128
|
})
|
|
122
129
|
|
|
123
|
-
export const
|
|
130
|
+
export const element = style({
|
|
124
131
|
position: 'relative',
|
|
125
132
|
width: '100%',
|
|
126
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
|
|