@likec4/diagram 1.27.3 → 1.28.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/bundle/index.js +564 -443
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeActionButton.d.ts +1 -2
- package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
- package/dist/base/primitives/element/ElementActionButtons.d.ts +1 -1
- package/dist/base/primitives/element/ElementActionButtons.js +5 -3
- package/dist/base/primitives/element/ElementDetailsButton.js +5 -1
- package/dist/bundle/styles.css.js +2 -2
- package/dist/hooks/useDiagram.d.ts +3 -7
- package/dist/hooks/useXYFlow.d.ts +2 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +11 -1
- package/dist/likec4diagram/custom/index.d.ts +2 -1
- package/dist/likec4diagram/ui/notation/NotationPanel.js +0 -1
- package/dist/overlays/Overlays.js +2 -2
- package/dist/overlays/element-details/actor.d.ts +303 -303
- package/dist/overlays/overlay/Overlay.css.d.ts +2 -25
- package/dist/overlays/overlay/Overlay.css.js +0 -40
- package/dist/overlays/overlay/Overlay.d.ts +1 -1
- package/dist/overlays/overlay/Overlay.js +97 -88
- package/dist/overlays/overlaysActor.js +4 -1
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
- package/dist/overlays/relationship-details/actor.d.ts +1 -2
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationship-details/hooks.d.ts +2 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
- package/dist/overlays/relationships-browser/actor.d.ts +2 -3
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.d.ts +2 -3
- package/dist/state/diagram-machine.d.ts +2 -2
- package/dist/state/hotkeyActor.js +12 -3
- package/dist/styles.css.js +1 -1
- package/package.json +10 -10
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -3
- package/src/base/primitives/edge/EdgeActionButton.tsx +1 -2
- package/src/base/primitives/element/ElementActionButtons.tsx +5 -3
- package/src/base/primitives/element/ElementDetailsButton.tsx +4 -0
- package/src/base/primitives/element/ElementNodeContainer.css.ts +0 -18
- package/src/bundle/styles.css.ts +7 -2
- package/src/components/SearchControl.css.ts +4 -8
- package/src/hooks/useDiagram.ts +1 -1
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +7 -1
- package/src/likec4diagram/custom/edges/edges.css.ts +0 -2
- package/src/likec4diagram/ui/notation/NotationPanel.css.ts +0 -4
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +0 -1
- package/src/likec4diagram/ui/search/ViewsColumn.css.ts +0 -4
- package/src/overlays/Overlays.tsx +2 -2
- package/src/overlays/overlay/Overlay.css.ts +0 -40
- package/src/overlays/overlay/Overlay.tsx +107 -98
- package/src/overlays/overlaysActor.ts +5 -1
- package/src/overlays/relationship-details/custom/nodeTypes.tsx +1 -1
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +1 -1
- package/src/state/hotkeyActor.ts +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/diagram",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
6
6
|
"homepage": "https://likec4.dev",
|
|
@@ -48,23 +48,23 @@
|
|
|
48
48
|
"@react-hookz/web": "^25.1.0",
|
|
49
49
|
"@tabler/icons-react": "3.31.0",
|
|
50
50
|
"@xstate/react": "^5.0.3",
|
|
51
|
-
"@xyflow/react": "^12.5.
|
|
51
|
+
"@xyflow/react": "^12.5.3",
|
|
52
52
|
"@xyflow/system": "^0.0.53",
|
|
53
53
|
"bezier-js": "^6.1.4",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
55
55
|
"d3-shape": "^3.2.0",
|
|
56
56
|
"fast-equals": "^5.2.2",
|
|
57
|
-
"framer-motion": "^12.6.
|
|
57
|
+
"framer-motion": "^12.6.3",
|
|
58
58
|
"nanostores": "0.11.4",
|
|
59
59
|
"react": "^19.0.0",
|
|
60
60
|
"react-dom": "^19.0.0",
|
|
61
61
|
"react-error-boundary": "^5.0.0",
|
|
62
62
|
"react-shadow": "^20.6.0",
|
|
63
63
|
"remeda": "^2.21.2",
|
|
64
|
-
"type-fest": "^4.
|
|
64
|
+
"type-fest": "^4.39.1",
|
|
65
65
|
"xstate": "^5.19.2",
|
|
66
|
-
"@likec4/core": "1.
|
|
67
|
-
"@likec4/styles": "1.
|
|
66
|
+
"@likec4/core": "1.28.0",
|
|
67
|
+
"@likec4/styles": "1.28.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@pandacss/dev": "^0.53.3",
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"@types/node": "^20.17.28",
|
|
77
77
|
"@vitejs/plugin-react": "^4.3.4",
|
|
78
78
|
"postcss": "^8.5.3",
|
|
79
|
-
"typescript": "^5.8.
|
|
80
|
-
"vite": "^6.2.
|
|
79
|
+
"typescript": "^5.8.3",
|
|
80
|
+
"vite": "^6.2.5",
|
|
81
81
|
"vite-plugin-dts": "^4.5.3",
|
|
82
|
-
"vitest": "^3.
|
|
82
|
+
"vitest": "^3.1.1",
|
|
83
83
|
"wireit": "^0.14.11",
|
|
84
|
-
"@likec4/tsconfig": "1.
|
|
84
|
+
"@likec4/tsconfig": "1.28.0"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"generate": "panda codegen",
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { css, sva } from '@likec4/styles/css'
|
|
2
|
-
// import { createVar, fallbackVar, globalStyle, keyframes, style } from '@vanilla-extract/css'
|
|
3
|
-
// import { calc } from '@vanilla-extract/css-utils'
|
|
4
|
-
// import { easings, vars, whereLight, whereNotReducedGraphics } from '../../../theme-vars'
|
|
5
2
|
|
|
6
3
|
// export const _compoundOpacity = '--_compound-opacity'
|
|
7
4
|
// const compoundOpacity = `var(${_compoundOpacity})`
|
|
@@ -2,10 +2,9 @@ import { cx } from '@likec4/styles/css'
|
|
|
2
2
|
import { ActionIcon } from '@mantine/core'
|
|
3
3
|
import { IconZoomScan } from '@tabler/icons-react'
|
|
4
4
|
import { stopPropagation } from '../../../utils/xyflow'
|
|
5
|
-
import type { EdgeProps } from '../../types'
|
|
6
5
|
import { actionBtn } from './edge.css'
|
|
7
6
|
|
|
8
|
-
type EdgeActionBtnProps =
|
|
7
|
+
type EdgeActionBtnProps = {
|
|
9
8
|
icon?: React.ReactNode
|
|
10
9
|
onClick: (e: React.MouseEvent) => void
|
|
11
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css, cx } from '@likec4/styles/css'
|
|
2
2
|
import { actionBtn } from '@likec4/styles/recipes'
|
|
3
3
|
import { ActionIcon, Box } from '@mantine/core'
|
|
4
|
+
import { useId } from '@mantine/hooks'
|
|
4
5
|
import { m } from 'framer-motion'
|
|
5
6
|
import { useIsZoomTooSmall } from '../../../hooks/useXYFlow'
|
|
6
7
|
import { stopPropagation } from '../../../utils/xyflow'
|
|
@@ -33,13 +34,13 @@ const actionButtons = css({
|
|
|
33
34
|
})
|
|
34
35
|
|
|
35
36
|
export function ElementActionButtons({
|
|
36
|
-
id,
|
|
37
37
|
selected = false,
|
|
38
38
|
data: {
|
|
39
39
|
hovered: isHovered = false,
|
|
40
40
|
},
|
|
41
41
|
buttons,
|
|
42
42
|
}: ElementActionButtonsProps) {
|
|
43
|
+
const id = useId()
|
|
43
44
|
const zoomTooSmall = useIsZoomTooSmall()
|
|
44
45
|
if (!buttons.length || zoomTooSmall) {
|
|
45
46
|
return null
|
|
@@ -49,6 +50,7 @@ export function ElementActionButtons({
|
|
|
49
50
|
<Box
|
|
50
51
|
component={m.div}
|
|
51
52
|
layoutRoot
|
|
53
|
+
key={`${id}-action-buttons`}
|
|
52
54
|
initial={false}
|
|
53
55
|
style={{
|
|
54
56
|
originY: 0,
|
|
@@ -67,14 +69,14 @@ export function ElementActionButtons({
|
|
|
67
69
|
component={m.button}
|
|
68
70
|
layout
|
|
69
71
|
className={actionBtn({})}
|
|
70
|
-
key={
|
|
72
|
+
key={`${id}-${button.key ?? index}`}
|
|
71
73
|
initial={false}
|
|
72
74
|
whileTap={{ scale: 1 }}
|
|
73
75
|
whileHover={{
|
|
74
76
|
scale: 1.3,
|
|
75
77
|
}}
|
|
76
|
-
// Otherwise node receives click event and is selected
|
|
77
78
|
onClick={button.onClick}
|
|
79
|
+
// Otherwise node receives click event and is selected
|
|
78
80
|
onDoubleClick={stopPropagation}
|
|
79
81
|
>
|
|
80
82
|
{button.icon}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css, cx } from '@likec4/styles/css'
|
|
2
2
|
import { actionBtn } from '@likec4/styles/recipes'
|
|
3
3
|
import { ActionIcon, Box } from '@mantine/core'
|
|
4
|
+
import { useId } from '@mantine/hooks'
|
|
4
5
|
import { IconId } from '@tabler/icons-react'
|
|
5
6
|
import { m } from 'framer-motion'
|
|
6
7
|
import { stopPropagation } from '../../../utils/xyflow'
|
|
@@ -41,11 +42,14 @@ export function ElementDetailsButton({
|
|
|
41
42
|
icon,
|
|
42
43
|
onClick,
|
|
43
44
|
}: ElementDetailsButtonProps) {
|
|
45
|
+
const id = useId()
|
|
44
46
|
return (
|
|
45
47
|
<Box className={cx(container, 'details-button')}>
|
|
46
48
|
<ActionIcon
|
|
49
|
+
key={id}
|
|
47
50
|
className={cx('nodrag nopan', actionBtn({ variant: 'transparent' }))}
|
|
48
51
|
component={m.button}
|
|
52
|
+
layout
|
|
49
53
|
initial={false}
|
|
50
54
|
style={{
|
|
51
55
|
originX: 0.45,
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { css as style } from '@likec4/styles/css'
|
|
2
|
-
// import { createVar, fallbackVar, globalStyle, style } from '@vanilla-extract/css'
|
|
3
|
-
// import { easings, vars, whereReducedGraphics } from '../../../theme-vars'
|
|
4
|
-
// import { iconSize, paddingSize, textSize } from './vars.css'
|
|
5
2
|
|
|
6
3
|
export const container = style({
|
|
7
4
|
position: 'relative',
|
|
@@ -52,18 +49,3 @@ export const container = style({
|
|
|
52
49
|
cursor: 'pointer',
|
|
53
50
|
},
|
|
54
51
|
})
|
|
55
|
-
|
|
56
|
-
// const sizes = ['xs', 'sm', 'lg', 'xl'] as const
|
|
57
|
-
// sizes.forEach((size) => {
|
|
58
|
-
// globalStyle(`${container}[data-likec4-text-size="${size}"]`, {
|
|
59
|
-
// vars: {
|
|
60
|
-
// [textSize]: rem(defaultTheme.textSizes[size]),
|
|
61
|
-
// },
|
|
62
|
-
// })
|
|
63
|
-
|
|
64
|
-
// globalStyle(`${container}[data-likec4-padding="${size}"]`, {
|
|
65
|
-
// vars: {
|
|
66
|
-
// [paddingSize]: rem(defaultTheme.spacing[size]),
|
|
67
|
-
// },
|
|
68
|
-
// })
|
|
69
|
-
// })
|
package/src/bundle/styles.css.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { DiagramView } from '@likec4/core'
|
|
2
2
|
import { css } from '@likec4/styles/css'
|
|
3
3
|
import { type MantineThemeOverride, createTheme, Portal } from '@mantine/core'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useColorScheme as usePreferredColorScheme,
|
|
6
|
+
useDebouncedCallback,
|
|
7
|
+
useId,
|
|
8
|
+
useMutationObserver,
|
|
9
|
+
} from '@mantine/hooks'
|
|
5
10
|
import { useIsomorphicLayoutEffect } from '@react-hookz/web'
|
|
6
|
-
import {
|
|
11
|
+
import { useState } from 'react'
|
|
7
12
|
import { first, isFunction, isString } from 'remeda'
|
|
8
13
|
import inlinedStyles from '../styles.css?inline'
|
|
9
14
|
import fontsCss from './font.css?inline'
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { css
|
|
2
|
-
// import { createVar, fallbackVar, globalStyle, style } from '@vanilla-extract/css'
|
|
3
|
-
// import { mantine, transitions, vars, whereDark, whereLight, whereNotReducedGraphics } from '../theme-vars'
|
|
1
|
+
import { css } from '@likec4/styles/css'
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
// const bgColor = createVar('bgcolor')
|
|
7
|
-
export const root = style({
|
|
3
|
+
export const root = css({
|
|
8
4
|
height: '30px',
|
|
9
5
|
paddingLeft: 'sm',
|
|
10
6
|
paddingRight: '4px',
|
|
@@ -42,7 +38,7 @@ export const root = style({
|
|
|
42
38
|
},
|
|
43
39
|
})
|
|
44
40
|
|
|
45
|
-
export const placeholder =
|
|
41
|
+
export const placeholder = css({
|
|
46
42
|
fontSize: 'sm', // mantine.fontSizes.sm,
|
|
47
43
|
fontWeight: 500,
|
|
48
44
|
paddingRight: '50px',
|
|
@@ -50,7 +46,7 @@ export const placeholder = style({
|
|
|
50
46
|
flex: '1',
|
|
51
47
|
})
|
|
52
48
|
|
|
53
|
-
export const shortcut =
|
|
49
|
+
export const shortcut = css({
|
|
54
50
|
fontSize: '11px',
|
|
55
51
|
fontWeight: 600,
|
|
56
52
|
lineHeight: 1,
|
package/src/hooks/useDiagram.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type DiagramView, type EdgeId, type ElementNotation, type Fqn, type Nod
|
|
|
2
2
|
import { useCallbackRef } from '@mantine/hooks'
|
|
3
3
|
import { useSelector as useXstateSelector } from '@xstate/react'
|
|
4
4
|
import { shallowEqual } from 'fast-equals'
|
|
5
|
-
import { useMemo
|
|
5
|
+
import { useMemo } from 'react'
|
|
6
6
|
import type { PartialDeep } from 'type-fest'
|
|
7
7
|
import type { FeatureName } from '../context/DiagramFeatures'
|
|
8
8
|
import type { OpenSourceParams } from '../LikeC4Diagram.props'
|
|
@@ -335,7 +335,13 @@ export const RelationshipEdge = customEdge<Types.RelationshipEdgeData>((props) =
|
|
|
335
335
|
return (
|
|
336
336
|
<>
|
|
337
337
|
<EdgeContainer {...props} className={clsx(isControlPointDragging && edgesCss.controlDragging)}>
|
|
338
|
-
<EdgePath
|
|
338
|
+
<EdgePath
|
|
339
|
+
{...props}
|
|
340
|
+
svgPath={edgePath}
|
|
341
|
+
ref={svgPathRef}
|
|
342
|
+
{...enableEdgeEditing && {
|
|
343
|
+
onEdgePointerDown,
|
|
344
|
+
}} />
|
|
339
345
|
<EdgeLabelContainer
|
|
340
346
|
edgeProps={props}
|
|
341
347
|
labelPosition={{
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { css } from '@likec4/styles/css'
|
|
2
|
-
// import { fallbackVar, style } from '@vanilla-extract/css'
|
|
3
|
-
// import { calc } from '@vanilla-extract/css-utils'
|
|
4
|
-
// import { mantine, vars, whereDark, whereNotReducedGraphics } from '../../../theme-vars'
|
|
5
|
-
// import { stokeFillMix } from '../../xyflow/nodes/element/element.css'
|
|
6
2
|
|
|
7
3
|
export const container = css({
|
|
8
4
|
bottom: 0,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { css, cx } from '@likec4/styles/css'
|
|
2
2
|
|
|
3
|
-
// import { fallbackVar, globalStyle, style } from '@vanilla-extract/css'
|
|
4
|
-
// import { mantine } from '../../../theme-vars'
|
|
5
|
-
// import { button, description, descriptionColor, iconColor, title } from './_shared.css'
|
|
6
|
-
|
|
7
3
|
export { emptyBoX, focusable } from './_shared.css'
|
|
8
4
|
|
|
9
5
|
const _viewBtn = 'likec4-view-btn'
|
|
@@ -108,7 +108,7 @@ export const Overlays = memo(({ overlaysActorRef }: { overlaysActorRef: Overlays
|
|
|
108
108
|
return (
|
|
109
109
|
<Overlay
|
|
110
110
|
key={overlay.actorRef.sessionId}
|
|
111
|
-
overlayLevel={
|
|
111
|
+
overlayLevel={index}
|
|
112
112
|
onClose={() => close(overlay.actorRef)}>
|
|
113
113
|
<RelationshipsBrowser actorRef={overlay.actorRef} />
|
|
114
114
|
</Overlay>
|
|
@@ -116,7 +116,7 @@ export const Overlays = memo(({ overlaysActorRef }: { overlaysActorRef: Overlays
|
|
|
116
116
|
case 'relationshipDetails':
|
|
117
117
|
return (
|
|
118
118
|
<Overlay
|
|
119
|
-
overlayLevel={
|
|
119
|
+
overlayLevel={index}
|
|
120
120
|
key={overlay.actorRef.sessionId}
|
|
121
121
|
onClose={() => close(overlay.actorRef)}>
|
|
122
122
|
<RelationshipDetails actorRef={overlay.actorRef} />
|
|
@@ -61,22 +61,6 @@ const dialog = css.raw({
|
|
|
61
61
|
xl: {
|
|
62
62
|
[offset]: '4rem',
|
|
63
63
|
},
|
|
64
|
-
// inset: '[calc(2rem + var(--_level, 0) * 1rem), 2rem, 2rem, 2rem]',
|
|
65
|
-
// width: 'calc(100vw - 4rem)',
|
|
66
|
-
// height: 'calc(100vh - 4rem - var(--_level, 0) * 1rem)',
|
|
67
|
-
// },
|
|
68
|
-
// lg: {
|
|
69
|
-
// inset: '[calc(4rem + var(--_level, 0) * 1rem), 4rem, 4rem, 4rem]',
|
|
70
|
-
// width: 'calc(100vw - 8rem)',
|
|
71
|
-
// height: 'calc(100vh - 8rem)',
|
|
72
|
-
// },
|
|
73
|
-
// xl: {
|
|
74
|
-
// [borderRadius]: '8px',
|
|
75
|
-
// padding: '8px',
|
|
76
|
-
// inset: '[calc(5rem + var(--_level, 0) * 1rem), 5rem, 5rem, 5rem]',
|
|
77
|
-
// width: 'calc(100vw - 10rem)',
|
|
78
|
-
// height: 'calc(100vh - 10rem - var(--_level, 0) * 1rem)',
|
|
79
|
-
// },
|
|
80
64
|
})
|
|
81
65
|
|
|
82
66
|
const body = css.raw({
|
|
@@ -99,28 +83,4 @@ export const overlay = sva({
|
|
|
99
83
|
dialog: dialog,
|
|
100
84
|
body: body,
|
|
101
85
|
},
|
|
102
|
-
variants: {
|
|
103
|
-
level: {
|
|
104
|
-
0: {
|
|
105
|
-
dialog: {
|
|
106
|
-
[level]: '0',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
1: {
|
|
110
|
-
dialog: {
|
|
111
|
-
[level]: '1',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
2: {
|
|
115
|
-
dialog: {
|
|
116
|
-
[level]: '2',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
3: {
|
|
120
|
-
dialog: {
|
|
121
|
-
[level]: '3',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
86
|
})
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
import { useMergedRef } from '@mantine/hooks'
|
|
7
7
|
import { useDebouncedCallback, useSyncedRef, useTimeoutEffect } from '@react-hookz/web'
|
|
8
8
|
import { m, useReducedMotionConfig } from 'framer-motion'
|
|
9
|
-
import { type PropsWithChildren, forwardRef,
|
|
9
|
+
import { type PropsWithChildren, forwardRef, useEffect, useRef, useState } from 'react'
|
|
10
10
|
import { stopPropagation } from '../../utils'
|
|
11
|
-
import { backdropBlur, backdropOpacity, overlay as overlayCVA } from './Overlay.css'
|
|
11
|
+
import { backdropBlur, backdropOpacity, level as cssVarLevel, overlay as overlayCVA } from './Overlay.css'
|
|
12
12
|
|
|
13
13
|
type OverlayProps = PropsWithChildren<{
|
|
14
|
-
overlayLevel?:
|
|
14
|
+
overlayLevel?: number
|
|
15
15
|
className?: string
|
|
16
16
|
classes?: {
|
|
17
17
|
dialog?: string
|
|
@@ -21,108 +21,117 @@ type OverlayProps = PropsWithChildren<{
|
|
|
21
21
|
onClick?: never
|
|
22
22
|
}>
|
|
23
23
|
|
|
24
|
-
export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export const Overlay = forwardRef<HTMLDialogElement, OverlayProps>(({
|
|
25
|
+
onClose,
|
|
26
|
+
className,
|
|
27
|
+
classes,
|
|
28
|
+
overlayLevel = 0,
|
|
29
|
+
children,
|
|
30
|
+
...rest
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const [opened, setOpened] = useState(false)
|
|
33
|
+
const dialogRef = useRef<HTMLDialogElement>(null)
|
|
34
|
+
const isClosingRef = useRef(false)
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
const motionNotReduced = useReducedMotionConfig() !== true
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const onCloseRef = useSyncedRef(onClose)
|
|
39
|
+
const close = useDebouncedCallback(
|
|
40
|
+
() => {
|
|
41
|
+
if (isClosingRef.current) return
|
|
42
|
+
isClosingRef.current = true
|
|
43
|
+
onCloseRef.current()
|
|
44
|
+
},
|
|
45
|
+
[],
|
|
46
|
+
50,
|
|
47
|
+
)
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const cancel = (e: Event) => {
|
|
51
|
+
e.preventDefault()
|
|
52
|
+
close()
|
|
53
|
+
}
|
|
54
|
+
dialogRef.current?.addEventListener('cancel', cancel, { capture: true })
|
|
55
|
+
return () => {
|
|
56
|
+
dialogRef.current?.removeEventListener('cancel', cancel, { capture: true })
|
|
57
|
+
}
|
|
58
|
+
}, [])
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
useTimeoutEffect(() => {
|
|
61
|
+
if (!dialogRef.current?.open) {
|
|
62
|
+
// Move dialog to the top of the DOM
|
|
63
|
+
dialogRef.current?.showModal()
|
|
64
|
+
}
|
|
65
|
+
}, 30)
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
useTimeoutEffect(() => {
|
|
68
|
+
setOpened(true)
|
|
69
|
+
}, 120)
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
const styles = overlayCVA({
|
|
72
|
+
level: overlayLevel as 0 | 1 | 2 | 3,
|
|
73
|
+
})
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
opacity: 0,
|
|
94
|
-
[backdropBlur]: '0px',
|
|
95
|
-
[backdropOpacity]: '0%',
|
|
75
|
+
return (
|
|
76
|
+
<m.dialog
|
|
77
|
+
ref={useMergedRef(dialogRef, ref)}
|
|
78
|
+
className={cx(RemoveScroll.classNames.fullWidth, styles.dialog, classes?.dialog, className)}
|
|
79
|
+
layout
|
|
80
|
+
style={{
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
[cssVarLevel]: overlayLevel,
|
|
83
|
+
}}
|
|
84
|
+
{...motionNotReduced
|
|
85
|
+
? ({
|
|
86
|
+
initial: {
|
|
87
|
+
[backdropBlur]: '0px',
|
|
88
|
+
[backdropOpacity]: '0%',
|
|
89
|
+
scale: overlayLevel > 0 ? 0.9 : 1.075,
|
|
90
|
+
opacity: 0,
|
|
91
|
+
},
|
|
92
|
+
animate: {
|
|
93
|
+
[backdropBlur]: overlayLevel > 0 ? '4px' : '8px',
|
|
94
|
+
[backdropOpacity]: overlayLevel > 0 ? '50%' : '60%',
|
|
95
|
+
scale: 1,
|
|
96
|
+
opacity: 1,
|
|
97
|
+
transition: {
|
|
98
|
+
delay: 0.075,
|
|
96
99
|
},
|
|
97
|
-
}
|
|
98
|
-
: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}}
|
|
111
|
-
onDoubleClick={stopPropagation}
|
|
112
|
-
onPointerDown={stopPropagation}
|
|
113
|
-
onClose={e => {
|
|
114
|
-
e.stopPropagation()
|
|
115
|
-
close()
|
|
100
|
+
},
|
|
101
|
+
exit: {
|
|
102
|
+
scale: 1.2,
|
|
103
|
+
opacity: 0,
|
|
104
|
+
[backdropBlur]: '0px',
|
|
105
|
+
[backdropOpacity]: '0%',
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
: {
|
|
109
|
+
initial: {
|
|
110
|
+
[backdropBlur]: '8px',
|
|
111
|
+
[backdropOpacity]: '60%',
|
|
112
|
+
},
|
|
116
113
|
}}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
114
|
+
onClick={e => {
|
|
115
|
+
e.stopPropagation()
|
|
116
|
+
if ((e.target as any)?.nodeName?.toUpperCase() === 'DIALOG') {
|
|
117
|
+
dialogRef.current?.close()
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
onDoubleClick={stopPropagation}
|
|
122
|
+
onPointerDown={stopPropagation}
|
|
123
|
+
onClose={e => {
|
|
124
|
+
e.stopPropagation()
|
|
125
|
+
close()
|
|
126
|
+
}}
|
|
127
|
+
{...rest}
|
|
128
|
+
>
|
|
129
|
+
<RemoveScroll forwardProps removeScrollBar={false}>
|
|
130
|
+
<Box className={cx(styles.body, 'overlay-body', classes?.body)}>
|
|
131
|
+
{opened && <>{children}</>}
|
|
132
|
+
</Box>
|
|
133
|
+
</RemoveScroll>
|
|
134
|
+
</m.dialog>
|
|
135
|
+
)
|
|
136
|
+
})
|
|
128
137
|
Overlay.displayName = 'Overlay'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Fqn } from '@likec4/core'
|
|
2
2
|
import { getHotkeyHandler } from '@mantine/hooks'
|
|
3
|
+
import type { KeyboardEvent } from 'react'
|
|
3
4
|
import { isString, last, reverse } from 'remeda'
|
|
4
5
|
import {
|
|
5
6
|
type ActorLogicFrom,
|
|
@@ -45,7 +46,10 @@ const hotkeyLogic = fromCallback(({ sendBack }: {
|
|
|
45
46
|
sendBack: (event: HotKeyEvent) => void
|
|
46
47
|
}) => {
|
|
47
48
|
const handler = getHotkeyHandler([
|
|
48
|
-
['Escape', () =>
|
|
49
|
+
['Escape', (event: KeyboardEvent) => {
|
|
50
|
+
event.stopPropagation()
|
|
51
|
+
sendBack({ type: 'close' })
|
|
52
|
+
}, {
|
|
49
53
|
preventDefault: true,
|
|
50
54
|
}],
|
|
51
55
|
])
|
|
@@ -33,7 +33,7 @@ export const ElementNode = customNode<RelationshipDetailsTypes.ElementNodeData>(
|
|
|
33
33
|
return (
|
|
34
34
|
<ElementNodeContainer nodeProps={props}>
|
|
35
35
|
<ElementShape {...props} />
|
|
36
|
-
<ElementTitle {...props}
|
|
36
|
+
<ElementTitle {...props} />
|
|
37
37
|
<ElementDetailsButtonWithHandler {...props} />
|
|
38
38
|
<ElementActions {...props} />
|
|
39
39
|
<ElementPorts {...props} />
|
|
@@ -36,7 +36,7 @@ export const ElementNode = customNode<RelationshipsBrowserTypes.ElementNodeData>
|
|
|
36
36
|
return (
|
|
37
37
|
<ElementNodeContainer key={props.id} component={m.div} layoutId={props.id} nodeProps={props}>
|
|
38
38
|
<ElementShape {...props} />
|
|
39
|
-
<ElementTitle {...props}
|
|
39
|
+
<ElementTitle {...props} />
|
|
40
40
|
<ElementDetailsButtonWithHandler {...props} />
|
|
41
41
|
<ElementActions {...props} />
|
|
42
42
|
<ElementPorts {...props} />
|
package/src/state/hotkeyActor.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getHotkeyHandler } from '@mantine/hooks'
|
|
2
|
+
import type { KeyboardEvent } from 'react'
|
|
2
3
|
import { type AnyEventObject, type NonReducibleUnknown, fromCallback } from 'xstate'
|
|
3
4
|
|
|
4
5
|
export type HotKeyEvent = { type: 'key.esc' | `key.arrow.${'left' | 'right'}` }
|
|
@@ -7,16 +8,25 @@ export const hotkeyActorLogic = fromCallback<AnyEventObject, NonReducibleUnknown
|
|
|
7
8
|
sendBack: (event: HotKeyEvent) => void
|
|
8
9
|
}) => {
|
|
9
10
|
const escHandler = getHotkeyHandler([
|
|
10
|
-
['Escape', () =>
|
|
11
|
+
['Escape', (event: KeyboardEvent) => {
|
|
12
|
+
event.stopPropagation()
|
|
13
|
+
sendBack({ type: 'key.esc' })
|
|
14
|
+
}, {
|
|
11
15
|
preventDefault: true,
|
|
12
16
|
}],
|
|
13
17
|
])
|
|
14
18
|
|
|
15
19
|
const arrowshandler = getHotkeyHandler([
|
|
16
|
-
['ArrowLeft', () =>
|
|
20
|
+
['ArrowLeft', (event: KeyboardEvent) => {
|
|
21
|
+
event.stopPropagation()
|
|
22
|
+
sendBack({ type: 'key.arrow.left' })
|
|
23
|
+
}, {
|
|
17
24
|
preventDefault: true,
|
|
18
25
|
}],
|
|
19
|
-
['ArrowRight', () =>
|
|
26
|
+
['ArrowRight', (event: KeyboardEvent) => {
|
|
27
|
+
event.stopPropagation()
|
|
28
|
+
sendBack({ type: 'key.arrow.right' })
|
|
29
|
+
}, {
|
|
20
30
|
preventDefault: true,
|
|
21
31
|
}],
|
|
22
32
|
])
|