@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
@@ -27,12 +27,13 @@ import { IconArrowRight, IconFileSymlink, IconInfoCircle, IconZoomScan } from '@
27
27
  import clsx from 'clsx'
28
28
  import { type MouseEventHandler, type PropsWithChildren, forwardRef, Fragment, useCallback } from 'react'
29
29
  import { filter, isTruthy, map, partition, pipe } from 'remeda'
30
- import { Link } from '../../../base'
30
+ import { Link } from '../../../base/Link'
31
31
  import { IfEnabled, useDiagramEventHandlers, useEnabledFeature } from '../../../context'
32
32
  import { useMantinePortalProps } from '../../../hooks'
33
33
  import { useDiagram } from '../../../hooks/useDiagram'
34
- import { DiagramContext, useDiagramContext } from '../../../hooks/useDiagramContext'
34
+ import { useDiagramContext } from '../../../hooks/useDiagramContext'
35
35
  import { useLikeC4Model } from '../../../likec4model'
36
+ import { DiagramContext } from '../../state/machine'
36
37
  import * as css from './RelationshipsDropdownMenu.css'
37
38
 
38
39
  const stopPropagation: MouseEventHandler = (e) => e.stopPropagation()
@@ -129,6 +130,7 @@ export function RelationshipsDropdownMenu({
129
130
  closeOnItemClick={false}
130
131
  disabled={disabled}
131
132
  position="bottom-start"
133
+ middlewares={{ size: { padding: 8 } }}
132
134
  {...portalProps}
133
135
  >
134
136
  <MenuTarget>
@@ -1,4 +1,4 @@
1
- import type { DiagramEdge, DiagramNode, Fqn, ViewId } from '@likec4/core'
1
+ import type { DiagramEdge, DiagramNode, Fqn, IconUrl, ViewId } from '@likec4/core'
2
2
  import type { XYPosition } from '@xyflow/system'
3
3
  import type { OptionalKeysOf, Simplify } from 'type-fest'
4
4
  import type { Base } from '../base'
@@ -75,7 +75,7 @@ export namespace Types {
75
75
  >
76
76
  & {
77
77
  depth: number
78
- icon: string | null
78
+ icon?: IconUrl
79
79
  }
80
80
  >
81
81
 
@@ -13,10 +13,11 @@ const selector = (s: DiagramContext) => ({
13
13
  title: s.view.title ?? 'untitled',
14
14
  description: s.view.description,
15
15
  links: s.view.links,
16
+ isNotActiveWalkthrough: s.activeWalkthrough === null,
16
17
  })
17
18
 
18
19
  export function DiagramTitlePanel() {
19
- const { id, title, description, links } = useDiagramContext(selector)
20
+ const { id, title, description, links, isNotActiveWalkthrough } = useDiagramContext(selector)
20
21
  const [isCollapsed, setCollapsed] = useLocalStorage({
21
22
  key: 'diagram-title-webview-collapsed',
22
23
  defaultValue: false,
@@ -41,126 +42,128 @@ export function DiagramTitlePanel() {
41
42
  </div>
42
43
  </ViewportPortal> */
43
44
  }
44
- <m.div
45
- key={id}
46
- initial={{ opacity: 0.05, scale: 0.7 }}
47
- animate={{ opacity: 1, scale: 1 }}
48
- exit={{
49
- opacity: 0.05,
50
- scale: 0.6,
51
- }}
52
- className={clsx('react-flow__panel', css.container)}
53
- style={{
54
- transformOrigin: 'left center',
55
- }}
56
- >
57
- <Card
58
- radius="sm"
59
- className={css.card}
60
- withBorder={!isCollapsed}
61
- p={isCollapsed ? 'sm' : 'md'}
62
- onDoubleClick={e => e.stopPropagation()}>
63
- {isCollapsed && (
64
- <CardSection>
65
- <Button
66
- fullWidth
67
- justify="stretch"
68
- size="md"
69
- radius={'0'}
70
- variant={'subtle'}
71
- color="gray"
72
- onClick={toggle}
73
- fw={500}
74
- fz={'sm'}
75
- tabIndex={-1}
76
- >
77
- {title}
78
- </Button>
79
- </CardSection>
80
- )}
81
- {!isCollapsed && (
82
- <>
83
- <CardSection mb={'xs'}>
45
+ {isNotActiveWalkthrough && (
46
+ <m.div
47
+ key={id}
48
+ initial={{ opacity: 0.05, scale: 0.7 }}
49
+ animate={{ opacity: 1, scale: 1 }}
50
+ exit={{
51
+ opacity: 0.05,
52
+ scale: 0.6,
53
+ }}
54
+ className={clsx('react-flow__panel', css.container)}
55
+ style={{
56
+ transformOrigin: 'left center',
57
+ }}
58
+ >
59
+ <Card
60
+ radius="sm"
61
+ className={css.card}
62
+ withBorder={!isCollapsed}
63
+ p={isCollapsed ? 'sm' : 'md'}
64
+ onDoubleClick={e => e.stopPropagation()}>
65
+ {isCollapsed && (
66
+ <CardSection>
84
67
  <Button
85
68
  fullWidth
86
- size="xs"
87
- h={'sm'}
88
- py={2}
69
+ justify="stretch"
70
+ size="md"
89
71
  radius={'0'}
90
72
  variant={'subtle'}
91
73
  color="gray"
92
74
  onClick={toggle}
75
+ fw={500}
76
+ fz={'sm'}
93
77
  tabIndex={-1}
94
78
  >
95
- <IconMenu size={11} opacity={0.7} />
79
+ {title}
96
80
  </Button>
97
81
  </CardSection>
82
+ )}
83
+ {!isCollapsed && (
84
+ <>
85
+ <CardSection mb={'xs'}>
86
+ <Button
87
+ fullWidth
88
+ size="xs"
89
+ h={'sm'}
90
+ py={2}
91
+ radius={'0'}
92
+ variant={'subtle'}
93
+ color="gray"
94
+ onClick={toggle}
95
+ tabIndex={-1}
96
+ >
97
+ <IconMenu size={11} opacity={0.7} />
98
+ </Button>
99
+ </CardSection>
98
100
 
99
- <Group justify="stretch" wrap="nowrap" mb={'sm'}>
100
- <Text
101
- component={'div'}
102
- flex={'1'}
103
- size={'md'}
104
- fw={500}
105
- lh={1.1}
106
- className={css.title}
107
- >
108
- {title}
109
- </Text>
110
- <Text
111
- hidden={isCollapsed}
112
- component={'div'}
113
- flex={'0 0 auto'}
114
- inline
115
- size="xs"
116
- fz={9}
117
- fw={500}
118
- c={'dimmed'}
119
- style={{
120
- userSelect: 'all',
121
- }}>
122
- <span style={{ userSelect: 'none' }}>id:{' '}</span>
123
- {id}
124
- </Text>
125
- </Group>
126
- {description && (
127
- <Spoiler
128
- maxHeight={42}
129
- showLabel={
130
- <Button color="gray" variant="light" fz={'10'} size="compact-xs" tabIndex={-1}>show more</Button>
131
- }
132
- hideLabel={
133
- <Button color="gray" variant="light" fz={'10'} size="compact-xs" tabIndex={-1}>hide</Button>
134
- }>
101
+ <Group justify="stretch" wrap="nowrap" mb={'sm'}>
135
102
  <Text
136
103
  component={'div'}
137
- size="sm"
138
- className={css.description}>
139
- {description || 'no description'}
104
+ flex={'1'}
105
+ size={'md'}
106
+ fw={500}
107
+ lh={1.1}
108
+ className={css.title}
109
+ >
110
+ {title}
140
111
  </Text>
141
- </Spoiler>
142
- )}
143
- {!description && (
144
- <Text
145
- component={'div'}
146
- size="xs"
147
- c={'dimmed'}>
148
- no description
149
- </Text>
150
- )}
151
- {links && (
152
- <Stack
153
- mt={'xs'}
154
- gap={4}
155
- justify="stretch"
156
- align="stretch">
157
- {links.map((link) => <Link value={link} key={link.url} />)}
158
- </Stack>
159
- )}
160
- </>
161
- )}
162
- </Card>
163
- </m.div>
112
+ <Text
113
+ hidden={isCollapsed}
114
+ component={'div'}
115
+ flex={'0 0 auto'}
116
+ inline
117
+ size="xs"
118
+ fz={9}
119
+ fw={500}
120
+ c={'dimmed'}
121
+ style={{
122
+ userSelect: 'all',
123
+ }}>
124
+ <span style={{ userSelect: 'none' }}>id:{' '}</span>
125
+ {id}
126
+ </Text>
127
+ </Group>
128
+ {description && (
129
+ <Spoiler
130
+ maxHeight={42}
131
+ showLabel={
132
+ <Button color="gray" variant="light" fz={'10'} size="compact-xs" tabIndex={-1}>show more</Button>
133
+ }
134
+ hideLabel={
135
+ <Button color="gray" variant="light" fz={'10'} size="compact-xs" tabIndex={-1}>hide</Button>
136
+ }>
137
+ <Text
138
+ component={'div'}
139
+ size="sm"
140
+ className={css.description}>
141
+ {description || 'no description'}
142
+ </Text>
143
+ </Spoiler>
144
+ )}
145
+ {!description && (
146
+ <Text
147
+ component={'div'}
148
+ size="xs"
149
+ c={'dimmed'}>
150
+ no description
151
+ </Text>
152
+ )}
153
+ {links && (
154
+ <Stack
155
+ mt={'xs'}
156
+ gap={4}
157
+ justify="stretch"
158
+ align="stretch">
159
+ {links.map((link) => <Link value={link} key={link.url} />)}
160
+ </Stack>
161
+ )}
162
+ </>
163
+ )}
164
+ </Card>
165
+ </m.div>
166
+ )}
164
167
  </AnimatePresence>
165
168
  )
166
169
  }
@@ -1,2 +1,4 @@
1
1
  export { Controls } from './controls/Controls'
2
2
  export { DiagramTitlePanel } from './diagram-title/DiagramTitlePanel'
3
+ export { NotationPanel } from './notation/NotationPanel'
4
+ export { DynamicViewWalkthrough } from './walkthrough/DynamicViewWalkthrough'
@@ -1,4 +1,3 @@
1
- // @ts-ignore
2
1
  import { type ComputedNode, type ElementNotation as ElementNotationData } from '@likec4/core'
3
2
  import {
4
3
  ActionIcon,
@@ -23,12 +22,12 @@ import clsx from 'clsx'
23
22
  import { AnimatePresence, m } from 'framer-motion'
24
23
  import { memo, useState } from 'react'
25
24
  import { ceil, isNonNullish } from 'remeda'
26
- // import { ElementShapeSvg } from '../../xyflow/nodes/element/ElementShapeSvg'
27
25
  import { ElementShape } from '../../../base/primitives'
28
- import { type DiagramContext, useMantinePortalProps } from '../../../hooks'
26
+ import { useMantinePortalProps } from '../../../hooks'
29
27
  import { useDiagram } from '../../../hooks/useDiagram'
30
28
  import { useDiagramContext } from '../../../hooks/useDiagramContext'
31
29
  import { useXYStore } from '../../../hooks/useXYFlow'
30
+ import { DiagramContext } from '../../../likec4diagram/state/machine'
32
31
  import { vars } from '../../../theme-vars'
33
32
  import * as css from './NotationPanel.css'
34
33
 
@@ -120,7 +120,7 @@ function viewToNodesEdge(opts: {
120
120
  shape: node.shape,
121
121
  style: node.style,
122
122
  depth: node.depth ?? 0,
123
- icon: node.icon ?? null,
123
+ icon: node.icon ?? 'none',
124
124
  position: node.position,
125
125
  } satisfies Types.CompoundNodeData
126
126