@likec4/diagram 1.0.0-rc.1 → 1.0.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.d.ts +1 -1
- package/dist/LikeC4Diagram.props.d.ts +6 -3
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.mjs +124 -221
- package/dist/mantine/EnsureMantine.d.ts +2 -3
- package/dist/style.css +4 -33
- package/dist/xyflow/nodes/element/ElementIcon.d.ts +1 -1
- package/dist/xyflow/types.d.ts +1 -1
- package/package.json +14 -12
- package/src/LikeC4Diagram.props.ts +12 -8
- package/src/LikeC4Diagram.tsx +3 -3
- package/src/StaticLikeC4Diagram.tsx +0 -1
- package/src/globals.css.ts +1 -1
- package/src/index.ts +1 -2
- package/src/mantine/EnsureMantine.tsx +8 -18
- package/src/mantine/theme.ts +1 -0
- package/src/ui/KeepAspectRatio.css.ts +2 -2
- package/src/ui/OptionsPanel.tsx +1 -1
- package/src/ui/options/NodeOptions.tsx +1 -2
- package/src/xyflow/FitviewOnDiagramChange.tsx +1 -1
- package/src/xyflow/SyncWithDiagram.tsx +23 -81
- package/src/xyflow/XYFlowEvents.tsx +1 -2
- package/src/xyflow/XYFlowWrapper.tsx +3 -7
- package/src/xyflow/edges/RelationshipEdge.tsx +4 -5
- package/src/xyflow/edges/edges.css.ts +7 -4
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +3 -2
- package/src/xyflow/nodes/compound/CompoundNode.tsx +2 -2
- package/src/xyflow/nodes/element/ElementIcon.tsx +1 -3
- package/src/xyflow/nodes/element/ElementLink.css.ts +2 -2
- package/src/xyflow/nodes/element/ElementLink.tsx +3 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +0 -2
- package/src/xyflow/nodes/element/element.css.ts +4 -4
- package/src/xyflow/types.ts +11 -2
- package/dist/EmbeddedLikeC4Diagram.css.d.ts +0 -5
- package/dist/EmbeddedLikeC4Diagram.d.ts +0 -17
- package/src/EmbeddedLikeC4Diagram.css.ts +0 -35
- package/src/EmbeddedLikeC4Diagram.tsx +0 -101
|
@@ -12,8 +12,6 @@ type ElementIconProps = {
|
|
|
12
12
|
|
|
13
13
|
export function ElementIcon({
|
|
14
14
|
node,
|
|
15
|
-
maxWidth,
|
|
16
|
-
paddingX = 32,
|
|
17
15
|
paddingY = 32
|
|
18
16
|
}: ElementIconProps) {
|
|
19
17
|
if (!node.icon) {
|
|
@@ -26,7 +24,7 @@ export function ElementIcon({
|
|
|
26
24
|
|
|
27
25
|
const firstLabelY = Math.floor(firstLabel.pt[1] - firstLabel.fontSize * 1.25)
|
|
28
26
|
const maxIconHeight = Math.floor(firstLabelY - paddingY - 16)
|
|
29
|
-
const maxIconWidth = maxWidth ?? node.width - paddingX * 2
|
|
27
|
+
// const maxIconWidth = maxWidth ?? node.width - paddingX * 2
|
|
30
28
|
|
|
31
29
|
// const centerY = paddingY + Math.floor(maxIconHeight / 2)
|
|
32
30
|
// const centerX = Math.floor(node.width / 2)
|
|
@@ -19,8 +19,8 @@ export const elementLink = style({
|
|
|
19
19
|
}
|
|
20
20
|
// fontSize: rem(10),
|
|
21
21
|
// height: 12,
|
|
22
|
-
// width:
|
|
23
|
-
// height:
|
|
22
|
+
// width: '100%',
|
|
23
|
+
// height: '100%',
|
|
24
24
|
// vars: {
|
|
25
25
|
// [stokeFillMix]: `color-mix(in srgb, ${vars.element.stroke} 90%, ${vars.element.fill})`
|
|
26
26
|
// }
|
|
@@ -68,9 +68,9 @@ export function ElementLink({
|
|
|
68
68
|
<span>links</span>
|
|
69
69
|
</UnstyledButton>
|
|
70
70
|
</HoverCardTarget>
|
|
71
|
-
<HoverCardDropdown p={'xs'}>
|
|
72
|
-
<Stack
|
|
73
|
-
{element.links.map((link
|
|
71
|
+
<HoverCardDropdown onClick={e => e.stopPropagation()} p={'xs'}>
|
|
72
|
+
<Stack gap={'xs'}>
|
|
73
|
+
{element.links.map((link) => (
|
|
74
74
|
<Group key={link} wrap="nowrap" gap={'sm'}>
|
|
75
75
|
<Box flex={'1'} style={{ overflow: 'clip', maxWidth: clamp(element.width, { min: 200, max: 400 }) }}>
|
|
76
76
|
<Anchor href={link} target="_blank" fz="13" truncate="end">
|
|
@@ -157,7 +157,6 @@ export function ElementNode({
|
|
|
157
157
|
))} */
|
|
158
158
|
}
|
|
159
159
|
<Handle
|
|
160
|
-
// @ts-expect-error
|
|
161
160
|
type="target"
|
|
162
161
|
position={Position.Top}
|
|
163
162
|
style={{ visibility: 'hidden' }}
|
|
@@ -204,7 +203,6 @@ export function ElementNode({
|
|
|
204
203
|
)}
|
|
205
204
|
</div>
|
|
206
205
|
<Handle
|
|
207
|
-
// @ts-expect-error
|
|
208
206
|
type="source"
|
|
209
207
|
position={Position.Bottom}
|
|
210
208
|
style={{ visibility: 'hidden' }}
|
|
@@ -9,8 +9,8 @@ const elPadding = createVar('el-padding')
|
|
|
9
9
|
|
|
10
10
|
export const container = style({
|
|
11
11
|
position: 'relative',
|
|
12
|
-
width:
|
|
13
|
-
height:
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: '100%',
|
|
14
14
|
padding: 0,
|
|
15
15
|
margin: 0,
|
|
16
16
|
vars: {
|
|
@@ -121,8 +121,8 @@ export const technology = style({
|
|
|
121
121
|
|
|
122
122
|
export const cssElement = style({
|
|
123
123
|
position: 'relative',
|
|
124
|
-
width:
|
|
125
|
-
height:
|
|
124
|
+
width: '100%',
|
|
125
|
+
height: '100%',
|
|
126
126
|
padding: elPadding,
|
|
127
127
|
display: 'flex',
|
|
128
128
|
flexDirection: 'column',
|
package/src/xyflow/types.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { BBox, DiagramEdge, DiagramNode, Fqn, Point } from '@likec4/core'
|
|
2
|
+
import type {
|
|
3
|
+
Edge,
|
|
4
|
+
EdgeMouseHandler,
|
|
5
|
+
InternalNode,
|
|
6
|
+
Node,
|
|
7
|
+
NodeMouseHandler,
|
|
8
|
+
OnMoveEnd,
|
|
9
|
+
OnMoveStart,
|
|
10
|
+
ReactFlowInstance,
|
|
11
|
+
ReactFlowState
|
|
12
|
+
} from '@xyflow/react'
|
|
2
13
|
import { isNode } from '@xyflow/react'
|
|
3
|
-
import type { Edge, InternalNode, Node, ReactFlowInstance, ReactFlowState } from '@xyflow/react'
|
|
4
|
-
import type { EdgeMouseHandler, NodeMouseHandler, OnMoveEnd, OnMoveStart, OnNodeDrag, Viewport } from '@xyflow/react'
|
|
5
14
|
import type { MouseEvent as ReactMouseEvent } from 'react'
|
|
6
15
|
import { isTruthy } from 'remeda'
|
|
7
16
|
import type { SetReadonly, SetRequired, Simplify } from 'type-fest'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LikeC4ColorScheme } from './LikeC4Diagram.props';
|
|
2
|
-
import { DiagramView } from '@likec4/core';
|
|
3
|
-
|
|
4
|
-
export type EmbeddedLikeC4DiagramProps = {
|
|
5
|
-
viewId: string;
|
|
6
|
-
views: Record<string, DiagramView>;
|
|
7
|
-
/**
|
|
8
|
-
* Controls color scheme used for styling the flow
|
|
9
|
-
* By default inherits from system or surrounding MantineProvider
|
|
10
|
-
*
|
|
11
|
-
* @example 'light' | 'dark'
|
|
12
|
-
*/
|
|
13
|
-
colorScheme?: LikeC4ColorScheme | undefined;
|
|
14
|
-
};
|
|
15
|
-
declare function EmbeddedLikeC4DiagramCmp({ viewId, views, colorScheme }: EmbeddedLikeC4DiagramProps): JSX.Element;
|
|
16
|
-
export declare const EmbeddedLikeC4Diagram: typeof EmbeddedLikeC4DiagramCmp;
|
|
17
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { style } from '@vanilla-extract/css'
|
|
2
|
-
import { mantine } from './mantine.css'
|
|
3
|
-
|
|
4
|
-
export const modalContent = style({
|
|
5
|
-
backgroundColor: 'transparent'
|
|
6
|
-
// backgroundColor: `color-mix(in srgb, ${mantine.colors.dark[7]}, transparent 50%)`,
|
|
7
|
-
// backdropFilter: 'blur(2px)',
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
export const modalBody = style({
|
|
11
|
-
padding: 0,
|
|
12
|
-
height: '100%'
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const modalHeader = style({
|
|
16
|
-
position: 'absolute',
|
|
17
|
-
top: '1rem',
|
|
18
|
-
left: '1rem'
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
export const modalCloseButtonBox = style({
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
top: '1rem',
|
|
24
|
-
right: '1rem'
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export const modalCloseButton = style({
|
|
28
|
-
'@media': {
|
|
29
|
-
[mantine.largerThan('md')]: {
|
|
30
|
-
vars: {
|
|
31
|
-
['--cb-size']: 'var(--cb-size-lg)'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
})
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { type DiagramView, invariant } from '@likec4/core'
|
|
2
|
-
import { Box, CloseButton, ModalBody, ModalContent, ModalOverlay, ModalRoot, Title } from '@mantine/core'
|
|
3
|
-
import { useToggle } from '@react-hookz/web'
|
|
4
|
-
import { shallowEqual } from 'fast-equals'
|
|
5
|
-
import { memo, useState } from 'react'
|
|
6
|
-
import {
|
|
7
|
-
modalBody,
|
|
8
|
-
modalCloseButton,
|
|
9
|
-
modalCloseButtonBox,
|
|
10
|
-
modalContent,
|
|
11
|
-
modalHeader
|
|
12
|
-
} from './EmbeddedLikeC4Diagram.css'
|
|
13
|
-
import { useUpdateEffect } from './hooks'
|
|
14
|
-
import { LikeC4Diagram } from './LikeC4Diagram'
|
|
15
|
-
import { type LikeC4ColorScheme } from './LikeC4Diagram.props'
|
|
16
|
-
import { EnsureMantine } from './mantine/EnsureMantine'
|
|
17
|
-
import { StaticLikeC4Diagram } from './StaticLikeC4Diagram'
|
|
18
|
-
import { KeepAspectRatio } from './ui/KeepAspectRatio'
|
|
19
|
-
|
|
20
|
-
export type EmbeddedLikeC4DiagramProps = {
|
|
21
|
-
viewId: string
|
|
22
|
-
views: Record<string, DiagramView>
|
|
23
|
-
/**
|
|
24
|
-
* Controls color scheme used for styling the flow
|
|
25
|
-
* By default inherits from system or surrounding MantineProvider
|
|
26
|
-
*
|
|
27
|
-
* @example 'light' | 'dark'
|
|
28
|
-
*/
|
|
29
|
-
colorScheme?: LikeC4ColorScheme | undefined
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function EmbeddedLikeC4DiagramCmp({
|
|
33
|
-
viewId,
|
|
34
|
-
views,
|
|
35
|
-
colorScheme
|
|
36
|
-
}: EmbeddedLikeC4DiagramProps) {
|
|
37
|
-
const [isOpened, toggleOpened] = useToggle(false)
|
|
38
|
-
const [browserViewId, setBrowserViewId] = useState(viewId)
|
|
39
|
-
|
|
40
|
-
const view = views[viewId]
|
|
41
|
-
invariant(view, `View with id ${viewId} not found`)
|
|
42
|
-
const browserView = views[browserViewId]
|
|
43
|
-
invariant(browserView, `View with id ${browserViewId} not found`)
|
|
44
|
-
|
|
45
|
-
const closeBrowser = () => {
|
|
46
|
-
toggleOpened(false)
|
|
47
|
-
setBrowserViewId(viewId)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
useUpdateEffect(closeBrowser, [viewId])
|
|
51
|
-
return (
|
|
52
|
-
<EnsureMantine colorScheme={colorScheme}>
|
|
53
|
-
<KeepAspectRatio
|
|
54
|
-
enabled
|
|
55
|
-
height={view.height}
|
|
56
|
-
width={view.width}
|
|
57
|
-
onClick={e => {
|
|
58
|
-
e.stopPropagation()
|
|
59
|
-
toggleOpened(true)
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<StaticLikeC4Diagram
|
|
63
|
-
colorScheme={colorScheme}
|
|
64
|
-
view={view}
|
|
65
|
-
fitView
|
|
66
|
-
fitViewPadding={0.01}
|
|
67
|
-
background={'transparent'}
|
|
68
|
-
keepAspectRatio={false}
|
|
69
|
-
/>
|
|
70
|
-
</KeepAspectRatio>
|
|
71
|
-
<ModalRoot opened={isOpened} onClose={closeBrowser} fullScreen>
|
|
72
|
-
<ModalOverlay blur={16} />
|
|
73
|
-
<ModalContent className={modalContent}>
|
|
74
|
-
<ModalBody className={modalBody}>
|
|
75
|
-
<Box className={modalHeader}>
|
|
76
|
-
<Title order={4}>{browserView.title || browserView.id}</Title>
|
|
77
|
-
</Box>
|
|
78
|
-
{isOpened && (
|
|
79
|
-
<LikeC4Diagram
|
|
80
|
-
readonly
|
|
81
|
-
view={browserView}
|
|
82
|
-
colorScheme={colorScheme}
|
|
83
|
-
background={'transparent'}
|
|
84
|
-
fitViewPadding={0.09}
|
|
85
|
-
onCanvasDblClick={closeBrowser}
|
|
86
|
-
onNavigateTo={(to) => {
|
|
87
|
-
setBrowserViewId(to)
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
90
|
-
)}
|
|
91
|
-
<Box className={modalCloseButtonBox}>
|
|
92
|
-
<CloseButton className={modalCloseButton} onClick={closeBrowser} />
|
|
93
|
-
</Box>
|
|
94
|
-
</ModalBody>
|
|
95
|
-
</ModalContent>
|
|
96
|
-
</ModalRoot>
|
|
97
|
-
</EnsureMantine>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const EmbeddedLikeC4Diagram = memo(EmbeddedLikeC4DiagramCmp, shallowEqual) as typeof EmbeddedLikeC4DiagramCmp
|