@likec4/diagram 1.36.0 → 1.37.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/{chunk-7MPUJFHj.js → chunk-DSORWspW.js} +1011 -983
- package/bundle/custom.js +64 -56
- package/bundle/index.js +3546 -3321
- package/dist/LikeC4Diagram.props.d.ts +5 -5
- package/dist/LikeC4Styles.js +17 -15
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/StaticLikeC4Diagram.js +3 -0
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base/BaseXYFlow.js +25 -27
- package/dist/base/const.d.ts +4 -4
- package/dist/base/const.js +5 -4
- package/dist/base/primitives/MarkdownBlock.js +4 -1
- package/dist/base/primitives/compound/CompoundActionButton.js +27 -42
- package/dist/base/primitives/compound/CompoundDetailsButton.js +23 -48
- package/dist/base/primitives/compound/CompoundNodeContainer.js +16 -48
- package/dist/base/primitives/compound/CompoundTitle.js +5 -80
- package/dist/base/primitives/compound/actionbtns.css.js +1 -13
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/customNode.d.ts +4 -4
- package/dist/base/primitives/customNode.js +7 -7
- package/dist/base/primitives/edge/EdgeLabel.d.ts +5 -4
- package/dist/base/primitives/edge/EdgeLabel.js +39 -21
- package/dist/base/primitives/edge/EdgeLabelContainer.js +11 -23
- package/dist/base/primitives/edge/edge.css.js +19 -11
- package/dist/base/primitives/element/ElementShape.js +38 -18
- package/dist/base/primitives/element/ElementTags.js +7 -4
- package/dist/base/primitives/element/ElementTitle.js +10 -2
- package/dist/base/types.d.ts +17 -21
- package/dist/bundle/LikeC4View.d.ts +2 -2
- package/dist/bundle/LikeC4View.js +4 -1
- package/dist/bundle/LikeC4View.props.d.ts +2 -2
- package/dist/bundle/ReactLikeC4.d.ts +3 -3
- package/dist/bundle/custom.js +2 -1
- package/dist/bundle/index.js +2 -1
- package/dist/components/Link.js +3 -2
- package/dist/context/ReduceGraphics.js +2 -5
- package/dist/context/RootContainer.js +1 -5
- package/dist/custom/customNodes.d.ts +32 -26
- package/dist/custom/customNodes.js +12 -8
- package/dist/custom/hooks.d.ts +2 -1
- package/dist/custom/index.js +2 -1
- package/dist/globals.css.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useDiagram.d.ts +18 -1
- package/dist/hooks/useDiagram.js +18 -2
- package/dist/hooks/useXYFlow.d.ts +40 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/likec4diagram/DiagramUI.js +7 -3
- package/dist/likec4diagram/DiagramXYFlow.js +9 -9
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +27 -44
- package/dist/likec4diagram/custom/index.js +3 -3
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +8 -6
- package/dist/likec4diagram/custom/nodes/nodes.js +13 -14
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +3 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +2 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +2 -0
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +441 -0
- package/dist/likec4diagram/relationship-popover/actor.d.ts +177 -0
- package/dist/likec4diagram/relationship-popover/actor.js +155 -0
- package/dist/likec4diagram/relationship-popover/styles.css.d.ts +2 -0
- package/dist/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.js → relationship-popover/styles.css.js} +4 -17
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +4 -4
- package/dist/likec4diagram/useLayoutConstraints.js +0 -1
- package/dist/likec4model/LikeC4ModelContext.d.ts +2 -1
- package/dist/likec4model/LikeC4ModelContext.js +10 -2
- package/dist/likec4model/useCurrentViewModel.d.ts +1 -0
- package/dist/likec4model/useCurrentViewModel.js +4 -1
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Project.js +15 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +1 -2
- package/dist/navigationpanel/actor.js +1 -2
- package/dist/navigationpanel/controls/NavigationButtons.js +1 -5
- package/dist/navigationpanel/controls/OpenSource.js +1 -1
- package/dist/navigationpanel/controls/ViewDetailsCard.js +2 -0
- package/dist/overlays/element-details/actor.d.ts +564 -8
- package/dist/overlays/overlay/Overlay.css.d.ts +1 -1
- package/dist/overlays/relationship-details/actor.d.ts +3 -1
- package/dist/overlays/relationship-details/hooks.d.ts +19 -1
- package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -1
- package/dist/overlays/relationship-details/layout.js +1 -2
- package/dist/overlays/relationships-browser/actor.d.ts +26 -2
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +16 -0
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +18 -8
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/state/DiagramActorProvider.js +5 -23
- package/dist/state/assign.js +24 -10
- package/dist/state/diagram-machine.d.ts +149 -474
- package/dist/state/diagram-machine.js +94 -54
- package/dist/state/types.d.ts +1 -1
- package/dist/styles-min.css +1 -1
- package/dist/styles-xyflow.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/roundDpr.d.ts +1 -0
- package/dist/utils/roundDpr.js +20 -0
- package/dist/utils/xyflow.d.ts +0 -1
- package/dist/utils/xyflow.js +1 -7
- package/package.json +11 -10
- package/panda.buildinfo.json +90 -155
- package/src/LikeC4Diagram.props.ts +5 -5
- package/src/LikeC4Styles.tsx +22 -14
- package/src/StaticLikeC4Diagram.tsx +3 -0
- package/src/base/BaseXYFlow.tsx +26 -29
- package/src/base/const.ts +5 -4
- package/src/base/primitives/MarkdownBlock.tsx +6 -1
- package/src/base/primitives/compound/CompoundActionButton.tsx +31 -43
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +26 -48
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +15 -43
- package/src/base/primitives/compound/CompoundTitle.tsx +4 -76
- package/src/base/primitives/compound/actionbtns.css.ts +0 -12
- package/src/base/primitives/customEdge.ts +1 -1
- package/src/base/primitives/customNode.tsx +20 -24
- package/src/base/primitives/edge/EdgeLabel.tsx +23 -8
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +9 -21
- package/src/base/primitives/edge/edge.css.ts +19 -11
- package/src/base/primitives/element/ElementShape.tsx +40 -18
- package/src/base/primitives/element/ElementTags.tsx +7 -4
- package/src/base/primitives/element/ElementTitle.tsx +23 -11
- package/src/base/types.ts +21 -25
- package/src/bundle/LikeC4View.props.ts +2 -2
- package/src/bundle/LikeC4View.tsx +8 -5
- package/src/bundle/ReactLikeC4.tsx +3 -3
- package/src/components/Link.tsx +3 -2
- package/src/context/RootContainer.tsx +1 -5
- package/src/context/TagStylesContext.tsx +2 -0
- package/src/custom/{customNodes.tsx → customNodes.ts} +58 -52
- package/src/custom/hooks.ts +7 -0
- package/src/globals.css +58 -5
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useDiagram.ts +39 -5
- package/src/hooks/useXYFlow.ts +3 -1
- package/src/index.ts +1 -0
- package/src/likec4diagram/DiagramUI.tsx +11 -2
- package/src/likec4diagram/DiagramXYFlow.tsx +9 -11
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +25 -49
- package/src/likec4diagram/custom/index.ts +5 -4
- package/src/likec4diagram/custom/nodes/nodes.tsx +13 -11
- package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +3 -2
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +535 -0
- package/src/likec4diagram/relationship-popover/actor.ts +192 -0
- package/src/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.ts → relationship-popover/styles.css.ts} +3 -19
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +4 -5
- package/src/likec4diagram/useLayoutConstraints.ts +0 -1
- package/src/likec4model/{LikeC4ModelContext.ts → LikeC4ModelContext.tsx} +9 -1
- package/src/likec4model/useCurrentViewModel.ts +4 -0
- package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
- package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -2
- package/src/navigationpanel/actor.ts +2 -2
- package/src/navigationpanel/controls/NavigationButtons.tsx +1 -5
- package/src/navigationpanel/controls/OpenSource.tsx +1 -1
- package/src/navigationpanel/controls/ViewDetailsCard.tsx +2 -0
- package/src/overlays/relationship-details/layout-to-xyflow.ts +0 -1
- package/src/overlays/relationship-details/layout.ts +4 -3
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +22 -8
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +0 -1
- package/src/state/DiagramActorProvider.tsx +8 -25
- package/src/state/assign.ts +24 -10
- package/src/state/diagram-machine.ts +101 -53
- package/src/state/types.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/roundDpr.ts +27 -0
- package/src/utils/xyflow.ts +0 -7
- package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -35
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +0 -132
- package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -7
- package/dist/base/primitives/edge/EdgeLabel.css.js +0 -57
- package/dist/base/primitives/element/ElementShape.css.d.ts +0 -6
- package/dist/base/primitives/element/ElementShape.css.js +0 -107
- package/dist/likec4diagram/custom/edges/NotePopover.css.js +0 -21
- package/dist/likec4diagram/custom/edges/NotePopover.js +0 -91
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.d.ts +0 -5
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.d.ts +0 -13
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +0 -215
- package/dist/likec4diagram/custom/index.d.ts +0 -62
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +0 -10
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -138
- package/src/base/primitives/edge/EdgeLabel.css.ts +0 -64
- package/src/base/primitives/element/ElementShape.css.ts +0 -112
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +0 -281
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { setup, assign, assertEvent } from 'xstate';
|
|
2
|
+
|
|
3
|
+
const _actorLogic = setup({
|
|
4
|
+
types: {
|
|
5
|
+
context: {},
|
|
6
|
+
events: {},
|
|
7
|
+
tags: "opened"
|
|
8
|
+
},
|
|
9
|
+
delays: {
|
|
10
|
+
"open timeout": ({ context }) => context.openTimeout,
|
|
11
|
+
"close timeout": 600,
|
|
12
|
+
"long idle": 1500
|
|
13
|
+
},
|
|
14
|
+
actions: {
|
|
15
|
+
"update edgeId": assign(({ context, event }) => {
|
|
16
|
+
assertEvent(event, ["xyedge.select", "xyedge.mouseEnter"]);
|
|
17
|
+
return {
|
|
18
|
+
edgeId: event.edgeId,
|
|
19
|
+
edgeSelected: context.edgeSelected || event.type === "xyedge.select"
|
|
20
|
+
};
|
|
21
|
+
}),
|
|
22
|
+
"increase open timeout": assign(() => ({
|
|
23
|
+
openTimeout: 800
|
|
24
|
+
})),
|
|
25
|
+
"decrease open timeout": assign(() => ({
|
|
26
|
+
openTimeout: 300
|
|
27
|
+
})),
|
|
28
|
+
"reset edgeId": assign({
|
|
29
|
+
edgeId: null,
|
|
30
|
+
edgeSelected: false
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
guards: {
|
|
34
|
+
"edge was selected": ({ context }) => context.edgeSelected,
|
|
35
|
+
"edge was hovered": ({ context }) => !context.edgeSelected
|
|
36
|
+
}
|
|
37
|
+
}).createMachine({
|
|
38
|
+
id: "breadcrumbs",
|
|
39
|
+
context: () => ({
|
|
40
|
+
edgeId: null,
|
|
41
|
+
edgeSelected: false,
|
|
42
|
+
openTimeout: 800
|
|
43
|
+
}),
|
|
44
|
+
initial: "idle",
|
|
45
|
+
on: {
|
|
46
|
+
"close": {
|
|
47
|
+
target: "#idle",
|
|
48
|
+
actions: [
|
|
49
|
+
"reset edgeId",
|
|
50
|
+
"increase open timeout"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
states: {
|
|
55
|
+
idle: {
|
|
56
|
+
id: "idle",
|
|
57
|
+
on: {
|
|
58
|
+
"xyedge.mouseEnter": {
|
|
59
|
+
target: "opening",
|
|
60
|
+
actions: "update edgeId"
|
|
61
|
+
},
|
|
62
|
+
"xyedge.select": {
|
|
63
|
+
target: "active",
|
|
64
|
+
actions: "update edgeId"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
after: {
|
|
68
|
+
"long idle": {
|
|
69
|
+
actions: "increase open timeout"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
opening: {
|
|
74
|
+
on: {
|
|
75
|
+
"xyedge.mouseLeave": {
|
|
76
|
+
target: "idle"
|
|
77
|
+
},
|
|
78
|
+
"xyedge.select": {
|
|
79
|
+
target: "active",
|
|
80
|
+
actions: "update edgeId"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
after: {
|
|
84
|
+
"open timeout": {
|
|
85
|
+
actions: "decrease open timeout",
|
|
86
|
+
target: "active"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
active: {
|
|
91
|
+
tags: ["opened"],
|
|
92
|
+
initial: "opened",
|
|
93
|
+
exit: "reset edgeId",
|
|
94
|
+
on: {
|
|
95
|
+
"xyedge.unselect": {
|
|
96
|
+
target: "idle",
|
|
97
|
+
actions: "increase open timeout"
|
|
98
|
+
},
|
|
99
|
+
"xyedge.select": {
|
|
100
|
+
actions: "update edgeId"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
states: {
|
|
104
|
+
opened: {
|
|
105
|
+
on: {
|
|
106
|
+
"dropdown.mouseEnter": {
|
|
107
|
+
target: "hovered"
|
|
108
|
+
},
|
|
109
|
+
"xyedge.mouseLeave": {
|
|
110
|
+
guard: "edge was hovered",
|
|
111
|
+
target: "closing"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
hovered: {
|
|
116
|
+
on: {
|
|
117
|
+
"dropdown.mouseLeave": [
|
|
118
|
+
{
|
|
119
|
+
guard: "edge was selected",
|
|
120
|
+
target: "opened"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
target: "closing"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
closing: {
|
|
129
|
+
on: {
|
|
130
|
+
"xyedge.mouseEnter": {
|
|
131
|
+
guard: "edge was hovered",
|
|
132
|
+
target: "opened",
|
|
133
|
+
actions: "update edgeId"
|
|
134
|
+
},
|
|
135
|
+
"xyedge.select": {
|
|
136
|
+
target: "opened",
|
|
137
|
+
actions: "update edgeId"
|
|
138
|
+
},
|
|
139
|
+
"dropdown.mouseEnter": {
|
|
140
|
+
target: "hovered"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
after: {
|
|
144
|
+
"close timeout": {
|
|
145
|
+
target: "#idle"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const RelationshipPopoverActorLogic = _actorLogic;
|
|
154
|
+
|
|
155
|
+
export { RelationshipPopoverActorLogic };
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { css } from '@likec4/styles/css';
|
|
2
2
|
|
|
3
|
-
const menuDropdown = css({
|
|
4
|
-
overflowY: "scroll",
|
|
5
|
-
minWidth: "250px",
|
|
6
|
-
maxWidth: "min(90vw, 500px)"
|
|
7
|
-
});
|
|
8
|
-
const menuItemRelationship = css({
|
|
9
|
-
gap: "1"
|
|
10
|
-
});
|
|
11
3
|
const endpoint = css({
|
|
12
4
|
display: "block",
|
|
13
5
|
fontSize: "xxs",
|
|
@@ -22,17 +14,12 @@ const endpoint = css({
|
|
|
22
14
|
_light: `[color-mix(in srgb, var(--likec4-palette-stroke), {colors.likec4.mixColor} 60%)]`,
|
|
23
15
|
_dark: "var(--likec4-palette-loContrast)"
|
|
24
16
|
}
|
|
25
|
-
// _dark: {
|
|
26
|
-
// background: `var(--likec4-palette-fill)/60`,
|
|
27
|
-
// },
|
|
28
17
|
});
|
|
29
18
|
const title = css({
|
|
30
19
|
whiteSpaceCollapse: "preserve-breaks",
|
|
31
|
-
fontSize: "
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
whiteSpaceCollapse: "preserve-breaks",
|
|
35
|
-
fontSize: "xs"
|
|
20
|
+
fontSize: "sm",
|
|
21
|
+
lineHeight: "sm",
|
|
22
|
+
userSelect: "all"
|
|
36
23
|
});
|
|
37
24
|
|
|
38
|
-
export { endpoint,
|
|
25
|
+
export { endpoint, title };
|
|
@@ -5,8 +5,8 @@ import { useLocalStorage } from '@mantine/hooks';
|
|
|
5
5
|
import { AnimatePresence, m } from 'motion/react';
|
|
6
6
|
import { Link } from '../../../components/Link.js';
|
|
7
7
|
import { useDiagramContext } from '../../../hooks/useDiagram.js';
|
|
8
|
+
import { useOptionalCurrentViewModel } from '../../../likec4model/useCurrentViewModel.js';
|
|
8
9
|
import { card, title, description } from './DiagramTitlePanel.css.js';
|
|
9
|
-
import { useCurrentViewModel } from '../../../likec4model/useCurrentViewModel.js';
|
|
10
10
|
import IconMenu from '../../../node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconMenu.js';
|
|
11
11
|
import { MarkdownBlock } from '../../../base/primitives/MarkdownBlock.js';
|
|
12
12
|
|
|
@@ -20,15 +20,15 @@ function selector(context) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
function DiagramTitlePanel() {
|
|
23
|
-
const view =
|
|
23
|
+
const view = useOptionalCurrentViewModel();
|
|
24
24
|
const { isNotActiveWalkthrough } = useDiagramContext(selector);
|
|
25
25
|
const [isCollapsed, setCollapsed] = useLocalStorage({
|
|
26
26
|
key: "diagram-title-webview-collapsed",
|
|
27
27
|
defaultValue: false
|
|
28
28
|
});
|
|
29
|
-
const title$1 = view
|
|
29
|
+
const title$1 = view?.title ?? "untitled";
|
|
30
30
|
const toggle = () => setCollapsed((v) => !v);
|
|
31
|
-
return /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: isNotActiveWalkthrough && /* @__PURE__ */ jsx(
|
|
31
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: view && isNotActiveWalkthrough && /* @__PURE__ */ jsx(
|
|
32
32
|
m.div,
|
|
33
33
|
{
|
|
34
34
|
initial: { opacity: 0.05, scale: 0.7 },
|
|
@@ -211,7 +211,6 @@ function useLayoutConstraints() {
|
|
|
211
211
|
},
|
|
212
212
|
onNodeDragStop: (_event) => {
|
|
213
213
|
moved = Math.abs(_event.clientX - initial.x) > 4 || Math.abs(_event.clientY - initial.y) > 4;
|
|
214
|
-
console.log("moved", moved);
|
|
215
214
|
if (wasPending || moved) {
|
|
216
215
|
diagram.scheduleSaveManualLayout();
|
|
217
216
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LikeC4Model, LikeC4ViewModel } from '@likec4/core/model';
|
|
2
2
|
import { aux, DiagramView } from '@likec4/core/types';
|
|
3
|
-
import { Context } from 'react';
|
|
3
|
+
import { PropsWithChildren, Context } from 'react';
|
|
4
4
|
export declare const LikeC4ModelContext: Context<LikeC4Model<any> | null>;
|
|
5
5
|
export type CurrentViewModel = LikeC4ViewModel<aux.UnknownLayouted, DiagramView<aux.UnknownLayouted>>;
|
|
6
6
|
export declare const CurrentViewModelContext: Context<CurrentViewModel | null>;
|
|
7
|
+
export declare function EnsureCurrentViewModel({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
2
3
|
|
|
3
4
|
const LikeC4ModelContext = createContext(null);
|
|
4
5
|
const CurrentViewModelContext = createContext(null);
|
|
6
|
+
function EnsureCurrentViewModel({ children }) {
|
|
7
|
+
const viewmodel = useContext(CurrentViewModelContext);
|
|
8
|
+
if (!viewmodel) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
12
|
+
}
|
|
5
13
|
|
|
6
|
-
export { CurrentViewModelContext, LikeC4ModelContext };
|
|
14
|
+
export { CurrentViewModelContext, EnsureCurrentViewModel, LikeC4ModelContext };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { CurrentViewModelContext } from './LikeC4ModelContext.js';
|
|
3
3
|
|
|
4
|
+
function useOptionalCurrentViewModel() {
|
|
5
|
+
return useContext(CurrentViewModelContext);
|
|
6
|
+
}
|
|
4
7
|
function useCurrentViewModel() {
|
|
5
8
|
const vm = useContext(CurrentViewModelContext);
|
|
6
9
|
if (!vm) {
|
|
@@ -9,4 +12,4 @@ function useCurrentViewModel() {
|
|
|
9
12
|
return vm;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export { useCurrentViewModel };
|
|
15
|
+
export { useCurrentViewModel, useOptionalCurrentViewModel };
|
|
@@ -3,6 +3,13 @@ import { LikeC4ModelContext } from './LikeC4ModelContext.js';
|
|
|
3
3
|
import { LikeC4ProjectsContext } from './LikeC4ProjectsContext.js';
|
|
4
4
|
|
|
5
5
|
const emptyProjects = [];
|
|
6
|
+
function useLikeC4Projects() {
|
|
7
|
+
const ctx = useContext(LikeC4ProjectsContext);
|
|
8
|
+
if (!ctx) {
|
|
9
|
+
return emptyProjects;
|
|
10
|
+
}
|
|
11
|
+
return ctx.projects;
|
|
12
|
+
}
|
|
6
13
|
const emptyOnProjectChange = () => {
|
|
7
14
|
};
|
|
8
15
|
const emptyContext = {
|
|
@@ -12,6 +19,13 @@ const emptyContext = {
|
|
|
12
19
|
function useLikeC4ProjectsContext() {
|
|
13
20
|
return useContext(LikeC4ProjectsContext) ?? emptyContext;
|
|
14
21
|
}
|
|
22
|
+
function useHasProjects() {
|
|
23
|
+
const ctx = useContext(LikeC4ProjectsContext);
|
|
24
|
+
if (!ctx) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return ctx.projects.length > 1;
|
|
28
|
+
}
|
|
15
29
|
function useLikeC4ProjectId() {
|
|
16
30
|
const ctx = useContext(LikeC4ModelContext);
|
|
17
31
|
if (!ctx) {
|
|
@@ -20,4 +34,4 @@ function useLikeC4ProjectId() {
|
|
|
20
34
|
return ctx.projectId;
|
|
21
35
|
}
|
|
22
36
|
|
|
23
|
-
export { useLikeC4ProjectId, useLikeC4ProjectsContext };
|
|
37
|
+
export { useHasProjects, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ifilter, ifirst, toArray, compareNaturalHierarchically, nonexhaustive } from '@likec4/core';
|
|
2
3
|
import { normalizeViewPath, VIEW_FOLDERS_SEPARATOR } from '@likec4/core/model';
|
|
3
|
-
import { ifilter, ifirst, toArray, compareNaturalHierarchically, nonexhaustive } from '@likec4/core/utils';
|
|
4
4
|
import { cx, css } from '@likec4/styles/css';
|
|
5
5
|
import { HStack, VStack, Box } from '@likec4/styles/jsx';
|
|
6
6
|
import { vstack, hstack } from '@likec4/styles/patterns';
|
|
@@ -122,7 +122,6 @@ function SearchResults({ searchQuery }) {
|
|
|
122
122
|
view: v,
|
|
123
123
|
highlight,
|
|
124
124
|
onClick: (e) => {
|
|
125
|
-
console.log("click");
|
|
126
125
|
e.stopPropagation();
|
|
127
126
|
actor.selectView(v.id);
|
|
128
127
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ViewId } from '@likec4/core/types';
|
|
2
1
|
import { isEmpty } from 'remeda';
|
|
3
2
|
import { setup, emit, assign, assertEvent, raise } from 'xstate';
|
|
4
3
|
|
|
@@ -65,7 +64,7 @@ const _actorLogic = setup({
|
|
|
65
64
|
assertEvent(event, "select.view");
|
|
66
65
|
return {
|
|
67
66
|
type: "navigateTo",
|
|
68
|
-
viewId:
|
|
67
|
+
viewId: event.viewId
|
|
69
68
|
};
|
|
70
69
|
})
|
|
71
70
|
},
|
|
@@ -19,7 +19,7 @@ const OpenSource = () => {
|
|
|
19
19
|
e.stopPropagation();
|
|
20
20
|
onOpenSource?.({ view: viewId });
|
|
21
21
|
},
|
|
22
|
-
children: /* @__PURE__ */ jsx(IconFileSymlink, {
|
|
22
|
+
children: /* @__PURE__ */ jsx(IconFileSymlink, { style: { width: "60%", height: "60%" } })
|
|
23
23
|
}
|
|
24
24
|
) });
|
|
25
25
|
};
|