@likec4/diagram 1.20.3 → 1.21.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.
Files changed (105) hide show
  1. package/README.md +2 -2
  2. package/dist/base/BaseXYFlow.js +1 -2
  3. package/dist/base/example/_types.d.ts +3 -3
  4. package/dist/base/example/custom.d.ts +3 -2
  5. package/dist/base/primitives/compound/CompoundActionButton.js +1 -1
  6. package/dist/base/primitives/compound/CompoundDetailsButton.js +1 -1
  7. package/dist/base/primitives/compound/CompoundNodeContainer.js +2 -2
  8. package/dist/base/primitives/compound/CompoundTitle.css.d.ts +1 -0
  9. package/dist/base/primitives/compound/CompoundTitle.css.js +2 -0
  10. package/dist/base/primitives/compound/CompoundTitle.d.ts +2 -2
  11. package/dist/base/primitives/compound/CompoundTitle.js +17 -6
  12. package/dist/base/primitives/edge/EdgeLabel.js +2 -2
  13. package/dist/base/primitives/element/ElementActionButtons.js +1 -1
  14. package/dist/base/primitives/element/ElementDetailsButton.js +1 -1
  15. package/dist/base/primitives/element/ElementNodeContainer.d.ts +7 -2
  16. package/dist/base/primitives/element/ElementNodeContainer.js +34 -1
  17. package/dist/base/primitives/element/ElementShape.js +1 -1
  18. package/dist/base/primitives/element/ElementTitle.css.d.ts +0 -1
  19. package/dist/base/primitives/element/ElementTitle.css.js +8 -8
  20. package/dist/base/primitives/element/ElementTitle.d.ts +1 -1
  21. package/dist/base/primitives/element/ElementTitle.js +11 -5
  22. package/dist/base/primitives/element/styles.css.d.ts +3 -0
  23. package/dist/base/primitives/element/styles.css.js +6 -0
  24. package/dist/context/DiagramEventHandlers.js +1 -1
  25. package/dist/context/DiagramFeatures.js +1 -1
  26. package/dist/context/RootContainer.js +1 -1
  27. package/dist/hooks/index.d.ts +0 -1
  28. package/dist/hooks/useDiagram.d.ts +1 -2
  29. package/dist/hooks/useXYFlow.js +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/likec4diagram/DiagramUI.d.ts +1 -2
  32. package/dist/likec4diagram/DiagramUI.js +3 -4
  33. package/dist/likec4diagram/XYFlow.js +1 -1
  34. package/dist/likec4diagram/custom/edges/NotePopover.js +1 -1
  35. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  36. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +5 -4
  37. package/dist/likec4diagram/custom/nodes/nodeTypes.js +8 -8
  38. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
  39. package/dist/likec4diagram/state/assign.js +1 -1
  40. package/dist/likec4diagram/state/machine.js +5 -5
  41. package/dist/likec4diagram/types.d.ts +2 -2
  42. package/dist/likec4diagram/ui/controls/Controls.js +1 -1
  43. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +5 -4
  44. package/dist/likec4diagram/ui/index.d.ts +2 -0
  45. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +2 -2
  46. package/dist/likec4diagram/useViewToNodesEdges.js +1 -1
  47. package/dist/overlays/Overlays.js +43 -22
  48. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -3
  49. package/dist/overlays/element-details/ElementDetailsCard.js +38 -39
  50. package/dist/overlays/element-details/TabPanelDeployments.js +5 -3
  51. package/dist/overlays/element-details/TabPanelRelationships.js +14 -30
  52. package/dist/overlays/overlay/Overlay.css.js +2 -1
  53. package/dist/overlays/overlay/Overlay.js +2 -2
  54. package/dist/overlays/relationship-details/SelectEdge.js +1 -1
  55. package/dist/overlays/relationship-details/_types.d.ts +3 -3
  56. package/dist/overlays/relationship-details/actor.js +1 -1
  57. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +3 -3
  58. package/dist/overlays/relationship-details/custom/nodeTypes.js +2 -2
  59. package/dist/overlays/relationship-details/useLayoutedDetails.js +1 -4
  60. package/dist/overlays/relationships-browser/-useRelationshipsView.js +0 -3
  61. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
  62. package/dist/overlays/relationships-browser/_types.d.ts +3 -3
  63. package/dist/overlays/relationships-browser/actor.js +16 -16
  64. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +3 -2
  65. package/dist/overlays/relationships-browser/custom/nodeTypes.js +3 -3
  66. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -2
  67. package/dist/style.css +1 -1
  68. package/package.json +14 -14
  69. package/src/base/BaseXYFlow.tsx +0 -1
  70. package/src/base/example/_types.ts +3 -2
  71. package/src/base/example/useViewToNodesEdges.ts +2 -1
  72. package/src/base/primitives/compound/CompoundTitle.css.ts +27 -1
  73. package/src/base/primitives/compound/CompoundTitle.tsx +12 -2
  74. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -7
  75. package/src/base/primitives/element/ElementNodeContainer.tsx +41 -1
  76. package/src/base/primitives/element/ElementShape.css.ts +5 -0
  77. package/src/base/primitives/element/ElementTitle.css.ts +25 -29
  78. package/src/base/primitives/element/ElementTitle.tsx +10 -4
  79. package/src/base/primitives/element/styles.css.ts +52 -0
  80. package/src/globals.css.ts +2 -0
  81. package/src/hooks/index.ts +0 -1
  82. package/src/hooks/useDiagram.ts +1 -1
  83. package/src/index.ts +15 -1
  84. package/src/likec4diagram/DiagramUI.tsx +3 -6
  85. package/src/likec4diagram/XYFlow.tsx +2 -2
  86. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
  87. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +1 -0
  88. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +4 -2
  89. package/src/likec4diagram/types.ts +2 -2
  90. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +110 -107
  91. package/src/likec4diagram/ui/index.ts +2 -0
  92. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
  93. package/src/likec4diagram/useViewToNodesEdges.ts +1 -1
  94. package/src/overlays/Overlays.tsx +62 -282
  95. package/src/overlays/element-details/ElementDetailsCard.tsx +214 -261
  96. package/src/overlays/element-details/TabPanelDeployments.tsx +4 -4
  97. package/src/overlays/element-details/TabPanelRelationships.tsx +13 -75
  98. package/src/overlays/overlay/Overlay.tsx +1 -1
  99. package/src/overlays/relationship-details/_types.ts +3 -3
  100. package/src/overlays/relationship-details/useLayoutedDetails.ts +1 -1
  101. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +44 -55
  102. package/src/overlays/relationships-browser/_types.ts +12 -2
  103. package/src/overlays/relationships-browser/actor.ts +11 -10
  104. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +2 -1
  105. package/dist/hooks/useCurrentViewId.js +0 -8
@@ -1,12 +1,9 @@
1
1
  import { type DiagramView, type Fqn, type LikeC4Model, nameFromFqn } from '@likec4/core'
2
2
  import { Box, Group, Paper, Stack, Text, ThemeIcon } from '@mantine/core'
3
- import { useId } from '@mantine/hooks'
4
3
  import { IconArrowRight, IconInfoCircle } from '@tabler/icons-react'
5
4
  import { useActorRef } from '@xstate/react'
6
- import { LayoutGroup } from 'framer-motion'
7
- import { memo, useState } from 'react'
5
+ import { useState } from 'react'
8
6
  import { unique } from 'remeda'
9
- import { DiagramFeatures, useEnabledFeature } from '../../context'
10
7
  import { relationshipsBrowserActor } from '../relationships-browser/actor'
11
8
  import { RelationshipsBrowser } from '../relationships-browser/RelationshipsBrowser'
12
9
  import * as css from './TabPanelRelationships.css'
@@ -22,7 +19,6 @@ export function TabPanelRelationships({
22
19
  node,
23
20
  element,
24
21
  }: RelationshipsTabPanelProps) {
25
- const layoutId = useId()
26
22
  const [scope, setScope] = useState<'global' | 'view'>('view')
27
23
 
28
24
  const incoming = [...element.incoming()].map(r => r.id)
@@ -76,53 +72,7 @@ export function TabPanelRelationships({
76
72
  )}
77
73
 
78
74
  <Box className={css.xyflow}>
79
- <LayoutGroup id={layoutId}>
80
- <EmbeddedRelationshipsBrowser subjectId={element.id} currentView={currentView} />
81
- {
82
- /* <RelationshipsXYFlow
83
- subjectId={element.id}
84
- bounds={bounds}
85
- nodes={nodes}
86
- edges={edges}
87
- view={currentView}
88
- elementsSelectable={false}
89
- >
90
- <Panel position="top-left" className={css.panelScope}>
91
- <SegmentedControl
92
- size="xs"
93
- withItemsBorders={false}
94
- value={scope}
95
- onChange={setScope as any}
96
- data={[
97
- { label: 'Global', value: 'global' },
98
- { label: 'View', value: 'view' },
99
- ]}
100
- />
101
- </Panel>
102
- {enableRelationshipBrowser && (
103
- <Panel position="top-right">
104
- <Button
105
- size="compact-sm"
106
- variant="default"
107
- fz={'xs'}
108
- fw={500}
109
- rightSection={<IconExternalLink stroke={1.6} style={{ width: 16 }} />}
110
- onClick={(e) => {
111
- e.stopPropagation()
112
- overlay.close(() => {
113
- overlay.openOverlay({
114
- relationshipsOf: element.id,
115
- })
116
- })
117
- }}
118
- >
119
- Open
120
- </Button>
121
- </Panel>
122
- )}
123
- </RelationshipsXYFlow> */
124
- }
125
- </LayoutGroup>
75
+ <EmbeddedRelationshipsBrowser subjectId={element.id} currentView={currentView} />
126
76
  </Box>
127
77
  </Stack>
128
78
  )
@@ -192,26 +142,14 @@ function RelationshipsStat({
192
142
  )
193
143
  }
194
144
 
195
- const EmbeddedRelationshipsBrowser = memo<{ subjectId: Fqn; currentView: DiagramView }>(
196
- ({ subjectId, currentView }) => {
197
- const actor = useActorRef(relationshipsBrowserActor, {
198
- input: {
199
- subject: subjectId,
200
- scope: currentView,
201
- closeable: false,
202
- enableNavigationMenu: false,
203
- },
204
- })
205
-
206
- return (
207
- <DiagramFeatures
208
- overrides={{
209
- enableRelationshipBrowser: false,
210
- enableNavigateTo: false,
211
- }}>
212
- <RelationshipsBrowser actorRef={actor} />
213
- </DiagramFeatures>
214
- )
215
- },
216
- (prev, next) => prev.subjectId === next.subjectId,
217
- )
145
+ const EmbeddedRelationshipsBrowser = ({ subjectId, currentView }: { subjectId: Fqn; currentView: DiagramView }) => {
146
+ const actor = useActorRef(relationshipsBrowserActor, {
147
+ input: {
148
+ subject: subjectId,
149
+ scope: currentView,
150
+ closeable: false,
151
+ enableNavigationMenu: false,
152
+ },
153
+ })
154
+ return <RelationshipsBrowser actorRef={actor} />
155
+ }
@@ -35,7 +35,7 @@ export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(({ children,
35
35
  useLayoutEffect(() => {
36
36
  const cancel = (e: Event) => {
37
37
  e.preventDefault()
38
- close()
38
+ onCloseRef.current()
39
39
  }
40
40
  dialogRef.current?.addEventListener('cancel', cancel, { capture: true })
41
41
  return () => {
@@ -1,4 +1,4 @@
1
- import type { Color, DiagramNode, Fqn, RelationId, RelationshipLineType, ViewId } from '@likec4/core'
1
+ import type { Color, DiagramNode, Fqn, IconUrl, RelationId, RelationshipLineType, ViewId } from '@likec4/core'
2
2
  import type { Base, NonOptional, ReactFlowEdge, ReactFlowNode } from '../../base/types'
3
3
 
4
4
  export namespace RelationshipDetailsTypes {
@@ -27,7 +27,7 @@ export namespace RelationshipDetailsTypes {
27
27
  >
28
28
  & {
29
29
  fqn: Fqn
30
- icon: string | null
30
+ icon: IconUrl
31
31
  ports: Ports
32
32
  }
33
33
  >
@@ -45,7 +45,7 @@ export namespace RelationshipDetailsTypes {
45
45
  & {
46
46
  fqn: Fqn
47
47
  depth: number
48
- icon: string | null
48
+ icon?: IconUrl
49
49
  ports: Ports
50
50
  }
51
51
  >
@@ -115,7 +115,7 @@ function nodeData(
115
115
  description: diagramNode?.description ?? element.description,
116
116
  color: diagramNode?.color ?? ancestor?.color ?? element.color,
117
117
  shape: diagramNode?.shape ?? element.shape,
118
- icon: diagramNode?.icon ?? element.icon,
118
+ icon: diagramNode?.icon ?? element.icon ?? 'none',
119
119
  style: diagramNode?.style ?? element.$element.style ?? {},
120
120
  navigateTo: diagramNode?.navigateTo ?? first(element.scopedViews().take(1).toArray())?.id ?? null,
121
121
  width: 0,
@@ -5,7 +5,7 @@ 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, LayoutGroup, m } from 'framer-motion'
8
+ import { AnimatePresence, m } from 'framer-motion'
9
9
  import { memo, useEffect, useRef } from 'react'
10
10
  import type { SnapshotFrom } from 'xstate'
11
11
  import { BaseXYFlow } from '../../base/BaseXYFlow'
@@ -83,51 +83,49 @@ const RelationshipsBrowserXYFlow = memo(() => {
83
83
  // useLifecycleLogger('RelationshipsBrowserXYFlow.edges', [edges])
84
84
 
85
85
  return (
86
- <LayoutGroup>
87
- <BaseXYFlow<Types.Node, Types.Edge>
88
- id="relationships-browser"
89
- nodes={nodes}
90
- edges={edges}
91
- className={clsx(initialized && isActive ? 'initialized' : 'not-initialized')}
92
- nodeTypes={nodeTypes}
93
- edgeTypes={edgeTypes}
94
- fitViewPadding={ViewPadding}
95
- onInit={useCallbackRef((instance) => {
96
- browser.send({ type: 'xyflow.init', instance, store: xystore })
97
- })}
98
- onNodeClick={useCallbackRef((e, node) => {
99
- e.stopPropagation()
100
- browser.send({ type: 'xyflow.nodeClick', node })
101
- })}
102
- onEdgeClick={useCallbackRef((e, edge) => {
103
- e.stopPropagation()
104
- browser.send({ type: 'xyflow.edgeClick', edge })
105
- })}
106
- onPaneClick={useCallbackRef((e) => {
107
- e.stopPropagation()
108
- browser.send({ type: 'xyflow.paneClick' })
109
- })}
110
- onDoubleClick={useCallbackRef(e => {
111
- e.stopPropagation()
112
- browser.send({ type: 'xyflow.paneDblClick' })
113
- })}
114
- onViewportResize={useCallbackRef(() => {
115
- browser.send({ type: 'xyflow.resized' })
116
- })}
117
- onNodesChange={useCallbackRef((changes) => {
118
- browser.send({ type: 'xyflow.applyNodeChages', changes })
119
- })}
120
- onEdgesChange={useCallbackRef((changes) => {
121
- browser.send({ type: 'xyflow.applyEdgeChages', changes })
122
- })}
123
- nodesDraggable={false}
124
- fitView={false}
125
- pannable
126
- zoomable
127
- >
128
- {initialized && <RelationshipsBrowserInner />}
129
- </BaseXYFlow>
130
- </LayoutGroup>
86
+ <BaseXYFlow<Types.Node, Types.Edge>
87
+ id="relationships-browser"
88
+ nodes={nodes}
89
+ edges={edges}
90
+ className={clsx(initialized && isActive ? 'initialized' : 'not-initialized')}
91
+ nodeTypes={nodeTypes}
92
+ edgeTypes={edgeTypes}
93
+ fitViewPadding={ViewPadding}
94
+ onInit={useCallbackRef((instance) => {
95
+ browser.send({ type: 'xyflow.init', instance, store: xystore })
96
+ })}
97
+ onNodeClick={useCallbackRef((e, node) => {
98
+ e.stopPropagation()
99
+ browser.send({ type: 'xyflow.nodeClick', node })
100
+ })}
101
+ onEdgeClick={useCallbackRef((e, edge) => {
102
+ e.stopPropagation()
103
+ browser.send({ type: 'xyflow.edgeClick', edge })
104
+ })}
105
+ onPaneClick={useCallbackRef((e) => {
106
+ e.stopPropagation()
107
+ browser.send({ type: 'xyflow.paneClick' })
108
+ })}
109
+ onDoubleClick={useCallbackRef(e => {
110
+ e.stopPropagation()
111
+ browser.send({ type: 'xyflow.paneDblClick' })
112
+ })}
113
+ onViewportResize={useCallbackRef(() => {
114
+ browser.send({ type: 'xyflow.resized' })
115
+ })}
116
+ onNodesChange={useCallbackRef((changes) => {
117
+ browser.send({ type: 'xyflow.applyNodeChages', changes })
118
+ })}
119
+ onEdgesChange={useCallbackRef((changes) => {
120
+ browser.send({ type: 'xyflow.applyEdgeChages', changes })
121
+ })}
122
+ nodesDraggable={false}
123
+ fitView={false}
124
+ pannable
125
+ zoomable
126
+ >
127
+ {initialized && <RelationshipsBrowserInner />}
128
+ </BaseXYFlow>
131
129
  )
132
130
  })
133
131
 
@@ -167,15 +165,6 @@ const RelationshipsBrowserInner = memo(() => {
167
165
  const hasStepBack = current > 0
168
166
  const hasStepForward = current + 1 < history.length
169
167
 
170
- // useLifecycleLogger('RelationshipsBrowserInner.browser', [browser])
171
- // useLifecycleLogger('RelationshipsBrowserInner.layouted', [layouted])
172
- // useLifecycleLogger('RelationshipsBrowserInner', [
173
- // historySubjectId,
174
- // subjectId,
175
- // closeable,
176
- // enableNavigationMenu,
177
- // ])
178
-
179
168
  return (
180
169
  <>
181
170
  <TopLeftPanel
@@ -1,4 +1,13 @@
1
- import type { Color, DiagramNode, Fqn, NonEmptyArray, RelationId, RelationshipLineType, ViewId } from '@likec4/core'
1
+ import type {
2
+ Color,
3
+ DiagramNode,
4
+ Fqn,
5
+ IconUrl,
6
+ NonEmptyArray,
7
+ RelationId,
8
+ RelationshipLineType,
9
+ ViewId,
10
+ } from '@likec4/core'
2
11
  import type { Base, NonOptional, ReactFlowEdge, ReactFlowNode } from '../../base/types'
3
12
 
4
13
  export namespace RelationshipsBrowserTypes {
@@ -21,6 +30,7 @@ export namespace RelationshipsBrowserTypes {
21
30
  | 'description'
22
31
  | 'color'
23
32
  | 'shape'
33
+ | 'style'
24
34
  | 'width'
25
35
  | 'height'
26
36
  | 'navigateTo'
@@ -48,7 +58,7 @@ export namespace RelationshipsBrowserTypes {
48
58
  column: Column
49
59
  fqn: Fqn
50
60
  depth: number
51
- icon: string | null
61
+ icon: IconUrl
52
62
  ports: Ports
53
63
  }
54
64
  >
@@ -21,6 +21,7 @@ import {
21
21
  fromPromise,
22
22
  raise,
23
23
  setup,
24
+ stopChild,
24
25
  } from 'xstate'
25
26
  import { Base } from '../../base'
26
27
  import { MinZoom, ZIndexes } from '../../base/const'
@@ -145,7 +146,6 @@ export const relationshipsBrowserActor = setup({
145
146
  },
146
147
  guards: {
147
148
  'enable: navigate.to': () => true,
148
- 'closeable': ({ context }) => context.closeable,
149
149
  },
150
150
  actors: {
151
151
  layouter: fromPromise<{
@@ -167,8 +167,6 @@ export const relationshipsBrowserActor = setup({
167
167
  } = input
168
168
  let {
169
169
  nodes: currentNodes,
170
- setNodes,
171
- setEdges,
172
170
  width,
173
171
  height,
174
172
  } = xystore.getState()
@@ -275,7 +273,7 @@ export const relationshipsBrowserActor = setup({
275
273
  nextviewport.zoom,
276
274
  )
277
275
  // allow framer to render
278
- await delay(180)
276
+ await delay(175)
279
277
  next.xynodes = next.xynodes.map(Base.setDimmed(false))
280
278
 
281
279
  if (signal.aborted) {
@@ -431,18 +429,21 @@ export const relationshipsBrowserActor = setup({
431
429
  ],
432
430
  },
433
431
  'close': {
434
- guard: 'closeable',
435
432
  target: 'closed',
436
433
  },
437
434
  },
438
- exit: assign({
439
- initialized: false,
440
- xyflow: null,
441
- xystore: null,
442
- }),
443
435
  },
444
436
  'closed': {
437
+ id: 'closed',
445
438
  type: 'final',
439
+ entry: [
440
+ stopChild('layouter'),
441
+ assign({
442
+ initialized: false,
443
+ xyflow: null,
444
+ xystore: null,
445
+ }),
446
+ ],
446
447
  },
447
448
  },
448
449
  on: {
@@ -119,7 +119,7 @@ export function viewToNodesEdge(
119
119
  shape: node.shape,
120
120
  style: node.style,
121
121
  depth: node.depth ?? 0,
122
- icon: node.icon ?? null,
122
+ icon: node.icon ?? 'none',
123
123
  ports: node.ports,
124
124
  fqn,
125
125
  ...navigateTo,
@@ -146,6 +146,7 @@ export function viewToNodesEdge(
146
146
  shape: node.shape,
147
147
  icon: node.icon ?? 'none',
148
148
  ports: node.ports,
149
+ style: node.style,
149
150
  ...navigateTo,
150
151
  },
151
152
  },
@@ -1,8 +0,0 @@
1
- import { useDiagramContext } from "./useDiagramContext.js";
2
- const selectViewId = (state) => state.view.id;
3
- function useCurrentViewId() {
4
- return useDiagramContext(selectViewId);
5
- }
6
- export {
7
- useCurrentViewId
8
- };