@likec4/diagram 1.21.1 → 1.22.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/dist/LikeC4Diagram.js +9 -13
- package/dist/base/index.d.ts +0 -1
- package/dist/base/primitives/element/styles.css.js +1 -1
- package/dist/{base → components}/Link.css.js +3 -3
- package/dist/components/SearchControl.css.d.ts +2 -0
- package/dist/components/SearchControl.css.js +7 -0
- package/dist/components/SearchControl.d.ts +5 -0
- package/dist/components/SearchControl.js +17 -0
- package/dist/context/IconRenderer.d.ts +10 -0
- package/dist/context/IconRenderer.js +34 -0
- package/dist/hooks/useCurrentViewId.js +8 -0
- package/dist/hooks/useDiagram.d.ts +4 -4
- package/dist/likec4diagram/DiagramUI.js +0 -2
- package/dist/likec4diagram/XYFlow.d.ts +6 -1
- package/dist/likec4diagram/XYFlow.js +28 -29
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +2 -1
- package/dist/likec4diagram/state/actorContext.d.ts +16 -16
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/machine.d.ts +7 -7
- package/dist/likec4diagram/state/machine.js +10 -7
- package/dist/likec4diagram/ui/controls/Controls.js +63 -48
- package/dist/likec4diagram/ui/controls/NavigationButtons.js +44 -69
- package/dist/likec4diagram/ui/controls/_shared.js +1 -1
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +1 -1
- package/dist/likec4diagram/ui/search/ElementsColumn.css.d.ts +15 -0
- package/dist/likec4diagram/ui/search/ElementsColumn.css.js +30 -0
- package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +1 -0
- package/dist/likec4diagram/ui/search/ElementsColumn.js +243 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.css.d.ts +8 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.css.js +20 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +1 -0
- package/dist/likec4diagram/ui/search/LikeC4Search.js +265 -0
- package/dist/likec4diagram/ui/search/SearchInput.d.ts +1 -0
- package/dist/likec4diagram/ui/search/SearchInput.js +196 -0
- package/dist/likec4diagram/ui/search/ViewsColum.d.ts +9 -0
- package/dist/likec4diagram/ui/search/ViewsColum.js +130 -0
- package/dist/likec4diagram/ui/search/ViewsColumn.css.d.ts +5 -0
- package/dist/likec4diagram/ui/search/ViewsColumn.css.js +12 -0
- package/dist/likec4diagram/ui/search/_shared.css.d.ts +16 -0
- package/dist/likec4diagram/ui/search/_shared.css.js +5 -0
- package/dist/likec4diagram/ui/search/state.d.ts +19 -0
- package/dist/likec4diagram/ui/search/state.js +72 -0
- package/dist/likec4diagram/ui/search/utils.d.ts +3 -0
- package/dist/likec4diagram/ui/search/utils.js +23 -0
- package/dist/likec4diagram/useLayoutConstraints.js +4 -5
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +1 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -0
- package/dist/overlays/Overlays.js +9 -9
- package/dist/overlays/element-details/ElementDetailsCard.js +20 -13
- package/dist/overlays/overlay/Overlay.d.ts +6 -2
- package/dist/overlays/overlay/Overlay.js +18 -29
- package/dist/overlays/relationship-details/SelectEdge.js +1 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -5
- package/dist/overlays/relationships-browser/SelectElement.js +10 -6
- package/dist/overlays/relationships-browser/actor.d.ts +2 -2
- package/dist/overlays/relationships-browser/actor.js +8 -8
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +13 -12
- package/src/LikeC4Diagram.tsx +0 -1
- package/src/base/index.ts +0 -2
- package/src/base/primitives/element/styles.css.ts +2 -2
- package/src/{base → components}/Link.css.ts +3 -3
- package/src/components/SearchControl.css.ts +69 -0
- package/src/components/SearchControl.tsx +33 -0
- package/src/context/IconRenderer.tsx +54 -1
- package/src/globals.css.ts +0 -2
- package/src/likec4diagram/DiagramUI.tsx +0 -4
- package/src/likec4diagram/XYFlow.tsx +30 -30
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +2 -1
- package/src/likec4diagram/state/assign.ts +1 -1
- package/src/likec4diagram/state/machine.ts +12 -10
- package/src/likec4diagram/ui/controls/Controls.tsx +35 -25
- package/src/likec4diagram/ui/controls/NavigationButtons.tsx +36 -58
- package/src/likec4diagram/ui/controls/styles.css.ts +3 -1
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +1 -1
- package/src/likec4diagram/ui/search/ElementsColumn.css.ts +119 -0
- package/src/likec4diagram/ui/search/ElementsColumn.tsx +291 -0
- package/src/likec4diagram/ui/search/LikeC4Search.css.ts +117 -0
- package/src/likec4diagram/ui/search/LikeC4Search.tsx +312 -0
- package/src/likec4diagram/ui/search/SearchInput.tsx +235 -0
- package/src/likec4diagram/ui/search/ViewsColum.tsx +158 -0
- package/src/likec4diagram/ui/search/ViewsColumn.css.ts +37 -0
- package/src/likec4diagram/ui/search/_shared.css.ts +104 -0
- package/src/likec4diagram/ui/search/state.ts +76 -0
- package/src/likec4diagram/ui/search/utils.ts +20 -0
- package/src/likec4diagram/useLayoutConstraints.ts +4 -5
- package/src/likec4model/useLikeC4ElementsTree.ts +4 -4
- package/src/overlays/Overlays.tsx +31 -25
- package/src/overlays/element-details/ElementDetailsCard.css.ts +4 -4
- package/src/overlays/element-details/ElementDetailsCard.tsx +245 -240
- package/src/overlays/overlay/Overlay.css.ts +10 -9
- package/src/overlays/overlay/Overlay.tsx +38 -26
- package/src/overlays/relationship-details/SelectEdge.css.ts +1 -0
- package/src/overlays/relationship-details/SelectEdge.tsx +2 -4
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +10 -5
- package/src/overlays/relationships-browser/SelectElement.tsx +88 -82
- package/src/overlays/relationships-browser/actor.ts +10 -10
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +2 -2
- package/dist/LikeC4Search.css.d.ts +0 -1
- package/dist/LikeC4Search.css.js +0 -5
- package/dist/LikeC4Search.d.ts +0 -2
- package/dist/LikeC4Search.js +0 -88
- package/src/LikeC4Search.css.ts +0 -12
- package/src/LikeC4Search.tsx +0 -91
- /package/dist/{base → components}/Link.css.d.ts +0 -0
- /package/dist/{base → components}/Link.d.ts +0 -0
- /package/dist/{base → components}/Link.js +0 -0
- /package/src/{base → components}/Link.tsx +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { jsx, Fragment
|
|
2
|
-
import { Stack, ActionIconGroup, Badge, Loader } from "@mantine/core";
|
|
3
|
-
import {
|
|
4
|
-
import { IconSearch, IconFileSymlink, IconFocusCentered } from "@tabler/icons-react";
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Group, Stack, ActionIconGroup, Badge, Loader } from "@mantine/core";
|
|
3
|
+
import { IconMenu2, IconFileSymlink, IconFocusCentered } from "@tabler/icons-react";
|
|
5
4
|
import { clsx } from "clsx";
|
|
5
|
+
import { LayoutGroup } from "framer-motion";
|
|
6
6
|
import { memo } from "react";
|
|
7
7
|
import { useDiagram } from "../../../hooks/useDiagram.js";
|
|
8
8
|
import { useDiagramSyncLayoutState } from "../../../hooks/useDiagramActor.js";
|
|
9
9
|
import { useDiagramContext } from "../../../hooks/useDiagramContext.js";
|
|
10
|
-
import {
|
|
10
|
+
import { LikeC4Search } from "../search/LikeC4Search.js";
|
|
11
|
+
import { ActionIcon, Tooltip } from "./_shared.js";
|
|
11
12
|
import { ChangeAutoLayoutButton } from "./ChangeAutoLayoutButton.js";
|
|
12
13
|
import { LayoutDriftNotification } from "./LayoutDriftNotification.js";
|
|
13
14
|
import { ManualLayoutToolsButton } from "./ManualLayoutToolsButton.js";
|
|
14
15
|
import { NavigationButtons } from "./NavigationButtons.js";
|
|
15
|
-
import { actionIconGroup, panel } from "./styles.css.js";
|
|
16
|
+
import { navigationButtons, actionIconGroup, panel } from "./styles.css.js";
|
|
16
17
|
import { useDiagramEventHandlers } from "../../../context/DiagramEventHandlers.js";
|
|
17
18
|
import { useEnabledFeatures } from "../../../context/DiagramFeatures.js";
|
|
18
19
|
import { useMantinePortalProps } from "../../../hooks/useMantinePortalProps.js";
|
|
@@ -25,72 +26,86 @@ const Controls = memo(() => {
|
|
|
25
26
|
}));
|
|
26
27
|
const diagram = useDiagram();
|
|
27
28
|
const {
|
|
28
|
-
onOpenSource
|
|
29
|
+
onOpenSource,
|
|
30
|
+
onBurgerMenuClick
|
|
29
31
|
} = useDiagramEventHandlers();
|
|
30
32
|
const {
|
|
31
33
|
enableControls,
|
|
32
34
|
enableSearch,
|
|
33
35
|
enableNavigationButtons,
|
|
34
36
|
enableReadOnly,
|
|
35
|
-
enableEdgeEditing,
|
|
36
37
|
enableVscode
|
|
37
38
|
} = useEnabledFeatures();
|
|
38
39
|
const notReadOnly = !enableReadOnly;
|
|
39
40
|
const portalProps = useMantinePortalProps();
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
|
|
41
|
+
return /* @__PURE__ */ jsxs(
|
|
42
|
+
Group,
|
|
42
43
|
{
|
|
44
|
+
align: "flex-start",
|
|
43
45
|
className: clsx(
|
|
44
46
|
"react-flow__panel",
|
|
45
47
|
panel,
|
|
46
48
|
"likec4-top-left-panel"
|
|
47
49
|
),
|
|
48
|
-
align: "flex-start",
|
|
49
|
-
onClick: stopPropagation,
|
|
50
50
|
gap: "xs",
|
|
51
|
+
onClick: stopPropagation,
|
|
51
52
|
children: [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
ActionIcon,
|
|
53
|
+
/* @__PURE__ */ jsxs(Stack, { align: "flex-start", gap: "xs", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsxs(
|
|
55
|
+
Group,
|
|
56
56
|
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
className: clsx(navigationButtons, "likec4-navigation-webview"),
|
|
58
|
+
gap: "xs",
|
|
59
|
+
children: [
|
|
60
|
+
onBurgerMenuClick && /* @__PURE__ */ jsx(
|
|
61
|
+
ActionIcon,
|
|
62
|
+
{
|
|
63
|
+
onClick: (e) => {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
onBurgerMenuClick();
|
|
66
|
+
},
|
|
67
|
+
children: /* @__PURE__ */ jsx(IconMenu2, {})
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
enableNavigationButtons && /* @__PURE__ */ jsx(NavigationButtons, {})
|
|
71
|
+
]
|
|
62
72
|
}
|
|
63
73
|
) }),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
e
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
e
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
/* @__PURE__ */ jsxs(ActionIconGroup, { className: actionIconGroup, orientation: "vertical", children: [
|
|
75
|
+
enableVscode && /* @__PURE__ */ jsx(Tooltip, { label: "Open source", ...portalProps, children: /* @__PURE__ */ jsx(
|
|
76
|
+
ActionIcon,
|
|
77
|
+
{
|
|
78
|
+
onClick: (e) => {
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
onOpenSource == null ? void 0 : onOpenSource({ view: viewId });
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ jsx(IconFileSymlink, { stroke: 1.5 })
|
|
83
|
+
}
|
|
84
|
+
) }),
|
|
85
|
+
enableControls && hasLayoutDrift && /* @__PURE__ */ jsx(LayoutDriftNotification, { ...portalProps }),
|
|
86
|
+
enableControls && notReadOnly && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
87
|
+
/* @__PURE__ */ jsx(ChangeAutoLayoutButton, { ...portalProps }),
|
|
88
|
+
/* @__PURE__ */ jsx(ManualLayoutToolsButton, { ...portalProps })
|
|
89
|
+
] }),
|
|
90
|
+
enableControls && /* @__PURE__ */ jsx(Tooltip, { label: viewportChanged ? "Center camera" : "Camera is centered", ...portalProps, children: /* @__PURE__ */ jsx(
|
|
91
|
+
ActionIcon,
|
|
92
|
+
{
|
|
93
|
+
onClick: (e) => {
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
diagram.fitDiagram();
|
|
96
|
+
},
|
|
97
|
+
children: /* @__PURE__ */ jsx(IconFocusCentered, {})
|
|
98
|
+
}
|
|
99
|
+
) })
|
|
100
|
+
] })
|
|
89
101
|
] }),
|
|
90
|
-
|
|
102
|
+
/* @__PURE__ */ jsxs(Group, { children: [
|
|
103
|
+
enableSearch && /* @__PURE__ */ jsx(LikeC4Search, {}),
|
|
104
|
+
notReadOnly && /* @__PURE__ */ jsx(SyncLayoutBadge, {})
|
|
105
|
+
] })
|
|
91
106
|
]
|
|
92
107
|
}
|
|
93
|
-
)
|
|
108
|
+
);
|
|
94
109
|
});
|
|
95
110
|
const SyncLayoutBadge = () => {
|
|
96
111
|
const isPending = useDiagramSyncLayoutState((s) => s.hasTag("pending"));
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Group } from "@mantine/core";
|
|
5
|
-
import clsx from "clsx";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
|
|
3
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
6
4
|
import { useDiagram } from "../../../hooks/useDiagram.js";
|
|
7
5
|
import { useDiagramContext } from "../../../hooks/useDiagramContext.js";
|
|
8
6
|
import { ActionIcon } from "./_shared.js";
|
|
9
|
-
import { navigationButtons } from "./styles.css.js";
|
|
10
|
-
import { useDiagramEventHandlers } from "../../../context/DiagramEventHandlers.js";
|
|
11
7
|
const NavigationButtons = () => {
|
|
12
8
|
const diagram = useDiagram();
|
|
13
|
-
const { onBurgerMenuClick } = useDiagramEventHandlers();
|
|
14
9
|
const {
|
|
15
10
|
hasStepBack,
|
|
16
11
|
hasStepForward
|
|
@@ -18,74 +13,54 @@ const NavigationButtons = () => {
|
|
|
18
13
|
hasStepBack: s.navigationHistory.currentIndex > 0,
|
|
19
14
|
hasStepForward: s.navigationHistory.currentIndex < s.navigationHistory.history.length - 1
|
|
20
15
|
}));
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
return /* @__PURE__ */ jsxs(AnimatePresence, { children: [
|
|
17
|
+
hasStepBack && /* @__PURE__ */ jsx(
|
|
18
|
+
m.div,
|
|
19
|
+
{
|
|
20
|
+
layout: true,
|
|
21
|
+
initial: { opacity: 0.05, transform: "translateX(-10px)" },
|
|
22
|
+
animate: { opacity: 1, transform: "translateX(0)" },
|
|
23
|
+
exit: {
|
|
24
|
+
opacity: 0.05,
|
|
25
|
+
transform: "translateX(-10px)"
|
|
26
|
+
},
|
|
27
|
+
children: /* @__PURE__ */ jsx(
|
|
29
28
|
ActionIcon,
|
|
30
29
|
{
|
|
31
30
|
onClick: (e) => {
|
|
32
31
|
e.stopPropagation();
|
|
33
|
-
|
|
32
|
+
diagram.navigate("back");
|
|
34
33
|
},
|
|
35
|
-
children: /* @__PURE__ */ jsx(
|
|
34
|
+
children: /* @__PURE__ */ jsx(IconChevronLeft, {})
|
|
36
35
|
}
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
},
|
|
60
|
-
"back"
|
|
61
|
-
),
|
|
62
|
-
hasStepForward && /* @__PURE__ */ jsx(
|
|
63
|
-
m.div,
|
|
64
|
-
{
|
|
65
|
-
layout: true,
|
|
66
|
-
initial: { opacity: 0.05, transform: "translateX(10px)" },
|
|
67
|
-
animate: { opacity: 1, transform: "translateX(0)" },
|
|
68
|
-
exit: {
|
|
69
|
-
opacity: 0,
|
|
70
|
-
transform: "translateX(10px)"
|
|
71
|
-
},
|
|
72
|
-
children: /* @__PURE__ */ jsx(
|
|
73
|
-
ActionIcon,
|
|
74
|
-
{
|
|
75
|
-
onClick: (e) => {
|
|
76
|
-
e.stopPropagation();
|
|
77
|
-
diagram.navigate("forward");
|
|
78
|
-
},
|
|
79
|
-
children: /* @__PURE__ */ jsx(IconChevronRight, {})
|
|
80
|
-
}
|
|
81
|
-
)
|
|
36
|
+
)
|
|
37
|
+
},
|
|
38
|
+
"back"
|
|
39
|
+
),
|
|
40
|
+
hasStepForward && /* @__PURE__ */ jsx(
|
|
41
|
+
m.div,
|
|
42
|
+
{
|
|
43
|
+
layout: true,
|
|
44
|
+
initial: { opacity: 0.05, transform: "translateX(10px)" },
|
|
45
|
+
animate: { opacity: 1, transform: "translateX(0)" },
|
|
46
|
+
exit: {
|
|
47
|
+
opacity: 0,
|
|
48
|
+
transform: "translateX(10px)"
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ jsx(
|
|
51
|
+
ActionIcon,
|
|
52
|
+
{
|
|
53
|
+
onClick: (e) => {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
diagram.navigate("forward");
|
|
82
56
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
57
|
+
children: /* @__PURE__ */ jsx(IconChevronRight, {})
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
},
|
|
61
|
+
"forward"
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
89
64
|
};
|
|
90
65
|
export {
|
|
91
66
|
NavigationButtons
|
|
@@ -4,9 +4,9 @@ import { useLocalStorage } from "@mantine/hooks";
|
|
|
4
4
|
import { IconMenu } from "@tabler/icons-react";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { AnimatePresence, m } from "framer-motion";
|
|
7
|
+
import { Link } from "../../../components/Link.js";
|
|
7
8
|
import { useDiagramContext } from "../../../hooks/useDiagramContext.js";
|
|
8
9
|
import { card, title, description, container } from "./DiagramTitlePanel.css.js";
|
|
9
|
-
import { Link } from "../../../base/Link.js";
|
|
10
10
|
const selector = (s) => ({
|
|
11
11
|
id: s.view.id,
|
|
12
12
|
title: s.view.title ?? "untitled",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { focusable } from './_shared.css';
|
|
2
|
+
export declare const treeContainer: string;
|
|
3
|
+
export declare const treeNode: string;
|
|
4
|
+
export declare const treeRoot: string;
|
|
5
|
+
export declare const treeLabel: string;
|
|
6
|
+
export declare const treeSubtree: string;
|
|
7
|
+
export declare const iconSize: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
8
|
+
export declare const elementExpandIcon: string;
|
|
9
|
+
export declare const elementButton: string;
|
|
10
|
+
export declare const elementTitleAndId: string;
|
|
11
|
+
export declare const elementTitle: string;
|
|
12
|
+
export declare const elementId: string;
|
|
13
|
+
export declare const elementDescription: string;
|
|
14
|
+
export declare const elementIcon: string;
|
|
15
|
+
export declare const elementViewsCount: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
var focusable = "_1cfw8gr4";
|
|
4
|
+
var treeNode = "basone1";
|
|
5
|
+
var treeRoot = "basone2";
|
|
6
|
+
var treeLabel = "basone3";
|
|
7
|
+
var treeSubtree = "basone4";
|
|
8
|
+
var elementExpandIcon = "basone5";
|
|
9
|
+
var elementButton = "basone6 _1cfw8gr3";
|
|
10
|
+
var elementTitleAndId = "basone7";
|
|
11
|
+
var elementTitle = "basone8 _1cfw8gr5";
|
|
12
|
+
var elementId = "basone9";
|
|
13
|
+
var elementDescription = "basonea _1cfw8gr6";
|
|
14
|
+
var elementIcon = "basoneb";
|
|
15
|
+
var elementViewsCount = "basonec";
|
|
16
|
+
export {
|
|
17
|
+
elementButton,
|
|
18
|
+
elementDescription,
|
|
19
|
+
elementExpandIcon,
|
|
20
|
+
elementIcon,
|
|
21
|
+
elementId,
|
|
22
|
+
elementTitle,
|
|
23
|
+
elementTitleAndId,
|
|
24
|
+
elementViewsCount,
|
|
25
|
+
focusable,
|
|
26
|
+
treeLabel,
|
|
27
|
+
treeNode,
|
|
28
|
+
treeRoot,
|
|
29
|
+
treeSubtree
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ElementsColumn(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ifilter, toArray, sortParentsFirst, isAncestor, nameFromFqn } from "@likec4/core";
|
|
3
|
+
import { useTree, Tree, ActionIcon, UnstyledButton, Box, Group, Highlight, Tooltip, Text } from "@mantine/core";
|
|
4
|
+
import { useCallbackRef } from "@mantine/hooks";
|
|
5
|
+
import { IconChevronRight } from "@tabler/icons-react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { m } from "framer-motion";
|
|
8
|
+
import { useMemo, useEffect } from "react";
|
|
9
|
+
import { isEmpty, pipe, reduce, indexBy, prop, first, only, partition } from "remeda";
|
|
10
|
+
import { IconOrShapeRenderer } from "../../../context/IconRenderer.js";
|
|
11
|
+
import { sortByLabel } from "../../../likec4model/useLikeC4ElementsTree.js";
|
|
12
|
+
import { useLikeC4Model } from "../../../likec4model/useLikeC4Model.js";
|
|
13
|
+
import { treeSubtree, treeLabel, treeRoot, focusable, treeNode, elementExpandIcon, elementTitleAndId, elementTitle, elementId, elementDescription, elementViewsCount, elementButton, elementIcon } from "./ElementsColumn.css.js";
|
|
14
|
+
import { useNormalizedSearch, useCloseSearchAndNavigateTo, setPickView } from "./state.js";
|
|
15
|
+
import { stopAndPrevent, moveFocusToSearchInput, centerY } from "./utils.js";
|
|
16
|
+
import { NothingFound } from "./ViewsColum.js";
|
|
17
|
+
function ElementsColumn() {
|
|
18
|
+
const search = useNormalizedSearch();
|
|
19
|
+
const model = useLikeC4Model(true);
|
|
20
|
+
const {
|
|
21
|
+
all,
|
|
22
|
+
byid,
|
|
23
|
+
roots: data
|
|
24
|
+
} = useMemo(() => {
|
|
25
|
+
const searchTerms = search.split(".");
|
|
26
|
+
let elements;
|
|
27
|
+
if (isEmpty(search) || search === "kind:") {
|
|
28
|
+
elements = model.elements();
|
|
29
|
+
} else {
|
|
30
|
+
elements = ifilter(model.elements(), (element) => {
|
|
31
|
+
if (search.startsWith("kind:")) {
|
|
32
|
+
return element.kind.toLocaleLowerCase().startsWith(search.slice(5));
|
|
33
|
+
}
|
|
34
|
+
if (search.startsWith("#")) {
|
|
35
|
+
return element.tags.some((tag) => tag.toLocaleLowerCase().includes(search.slice(1)));
|
|
36
|
+
}
|
|
37
|
+
return (element.title + " " + element.id + " " + (element.description ?? "")).toLocaleLowerCase().includes(search);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const { all: all2, roots } = pipe(
|
|
41
|
+
elements,
|
|
42
|
+
toArray(),
|
|
43
|
+
sortParentsFirst,
|
|
44
|
+
reduce((acc, element) => {
|
|
45
|
+
const treeItem = {
|
|
46
|
+
label: element.title,
|
|
47
|
+
value: element.id,
|
|
48
|
+
element,
|
|
49
|
+
searchTerms,
|
|
50
|
+
children: []
|
|
51
|
+
};
|
|
52
|
+
const parent = acc.all.findLast((root) => isAncestor(root.value, treeItem.value));
|
|
53
|
+
if (parent) {
|
|
54
|
+
parent.children.push(treeItem);
|
|
55
|
+
if (parent.children.length > 1) {
|
|
56
|
+
parent.children.sort(sortByLabel);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
acc.roots.push(treeItem);
|
|
60
|
+
}
|
|
61
|
+
acc.all.push(treeItem);
|
|
62
|
+
return acc;
|
|
63
|
+
}, {
|
|
64
|
+
all: [],
|
|
65
|
+
roots: []
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
return {
|
|
69
|
+
all: all2,
|
|
70
|
+
byid: indexBy(all2, prop("value")),
|
|
71
|
+
roots: roots.sort(sortByLabel)
|
|
72
|
+
};
|
|
73
|
+
}, [model, search]);
|
|
74
|
+
const tree = useTree({
|
|
75
|
+
multiple: false
|
|
76
|
+
});
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
tree.collapseAllNodes();
|
|
79
|
+
for (const nd of all) {
|
|
80
|
+
if (nd.children.length > 0) {
|
|
81
|
+
tree.expand(nd.value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [all]);
|
|
85
|
+
const handleClick = useHandleElementSelection();
|
|
86
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
87
|
+
data.length === 0 && /* @__PURE__ */ jsx(NothingFound, {}),
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
Tree,
|
|
90
|
+
{
|
|
91
|
+
"data-likec4-search-elements": true,
|
|
92
|
+
allowRangeSelection: false,
|
|
93
|
+
clearSelectionOnOutsideClick: true,
|
|
94
|
+
selectOnClick: false,
|
|
95
|
+
tree,
|
|
96
|
+
data,
|
|
97
|
+
levelOffset: "lg",
|
|
98
|
+
classNames: {
|
|
99
|
+
root: treeRoot,
|
|
100
|
+
node: clsx(focusable, treeNode),
|
|
101
|
+
label: treeLabel,
|
|
102
|
+
subtree: treeSubtree
|
|
103
|
+
},
|
|
104
|
+
onKeyDownCapture: (e) => {
|
|
105
|
+
var _a;
|
|
106
|
+
const target = e.target;
|
|
107
|
+
const id = target.getAttribute("data-value");
|
|
108
|
+
const node = !!id && byid[id];
|
|
109
|
+
if (!node) return;
|
|
110
|
+
if (e.key === "ArrowUp") {
|
|
111
|
+
if (id === ((_a = data[0]) == null ? void 0 : _a.value)) {
|
|
112
|
+
stopAndPrevent(e);
|
|
113
|
+
moveFocusToSearchInput();
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (e.key === "ArrowRight") {
|
|
118
|
+
const hasChildren = node.children.length > 0;
|
|
119
|
+
if (hasChildren && tree.expandedState[id] === false) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const label = e.target.querySelector(".mantine-Tree-label") ?? target;
|
|
123
|
+
const maxY = label.getBoundingClientRect().y;
|
|
124
|
+
const viewButtons = [...document.querySelectorAll(
|
|
125
|
+
`[data-likec4-search-views] .${focusable}`
|
|
126
|
+
)];
|
|
127
|
+
let view = viewButtons.length > 1 ? viewButtons.find((el, i, all2) => centerY(el) > maxY || i === all2.length - 1) : null;
|
|
128
|
+
view ?? (view = first(viewButtons));
|
|
129
|
+
if (view) {
|
|
130
|
+
stopAndPrevent(e);
|
|
131
|
+
view.focus();
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (e.key === " " || e.key === "Enter") {
|
|
136
|
+
stopAndPrevent(e);
|
|
137
|
+
handleClick(node.element);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
renderNode: ElementTreeNode
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
function ElementTreeNode({ node, elementProps, hasChildren, expanded }) {
|
|
147
|
+
const { element, searchTerms } = node;
|
|
148
|
+
const elementIcon$1 = IconOrShapeRenderer({
|
|
149
|
+
element: {
|
|
150
|
+
id: element.id,
|
|
151
|
+
title: element.title,
|
|
152
|
+
shape: element.shape,
|
|
153
|
+
icon: element.icon
|
|
154
|
+
},
|
|
155
|
+
className: elementIcon
|
|
156
|
+
});
|
|
157
|
+
const views = [...element.views()];
|
|
158
|
+
const handleClick = useHandleElementSelection();
|
|
159
|
+
const key = `@tree.${node.value}`;
|
|
160
|
+
return /* @__PURE__ */ jsxs(m.div, { layoutId: key, ...elementProps, children: [
|
|
161
|
+
/* @__PURE__ */ jsx(
|
|
162
|
+
ActionIcon,
|
|
163
|
+
{
|
|
164
|
+
variant: "transparent",
|
|
165
|
+
size: 16,
|
|
166
|
+
tabIndex: -1,
|
|
167
|
+
className: clsx(elementExpandIcon),
|
|
168
|
+
style: {
|
|
169
|
+
visibility: hasChildren ? "visible" : "hidden"
|
|
170
|
+
},
|
|
171
|
+
children: /* @__PURE__ */ jsx(
|
|
172
|
+
IconChevronRight,
|
|
173
|
+
{
|
|
174
|
+
stroke: 3.5,
|
|
175
|
+
style: {
|
|
176
|
+
transition: "transform 150ms ease",
|
|
177
|
+
transform: `rotate(${expanded ? "90deg" : "0"})`,
|
|
178
|
+
width: "100%"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsxs(
|
|
185
|
+
UnstyledButton,
|
|
186
|
+
{
|
|
187
|
+
component: m.button,
|
|
188
|
+
layout: true,
|
|
189
|
+
tabIndex: -1,
|
|
190
|
+
className: clsx(elementButton, "likec4-element-button"),
|
|
191
|
+
...views.length > 0 && {
|
|
192
|
+
onClick: (e) => {
|
|
193
|
+
if (!hasChildren || expanded) {
|
|
194
|
+
e.stopPropagation();
|
|
195
|
+
handleClick(element);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
children: [
|
|
200
|
+
elementIcon$1,
|
|
201
|
+
/* @__PURE__ */ jsxs(Box, { style: { flexGrow: 1 }, children: [
|
|
202
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", align: "center", className: elementTitleAndId, children: [
|
|
203
|
+
/* @__PURE__ */ jsx(Highlight, { component: "div", highlight: searchTerms, className: elementTitle, children: node.label }),
|
|
204
|
+
/* @__PURE__ */ jsx(Tooltip, { label: element.id, withinPortal: false, fz: "xs", disabled: !element.id.includes("."), children: /* @__PURE__ */ jsx(Highlight, { component: "div", highlight: searchTerms, className: elementId, children: nameFromFqn(element.id) }) })
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ jsx(Highlight, { component: "div", highlight: searchTerms, className: elementDescription, lineClamp: 1, children: element.description || "No description" })
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ jsx(Text, { component: "div", className: elementViewsCount, children: views.length === 0 ? "No views" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
209
|
+
views.length,
|
|
210
|
+
" view",
|
|
211
|
+
views.length > 1 ? "s" : ""
|
|
212
|
+
] }) })
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
] }, key);
|
|
217
|
+
}
|
|
218
|
+
function useHandleElementSelection() {
|
|
219
|
+
const navigateTo = useCloseSearchAndNavigateTo();
|
|
220
|
+
return useCallbackRef((element) => {
|
|
221
|
+
const views = [...element.views()];
|
|
222
|
+
if (views.length === 0) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const singleView = only(views);
|
|
226
|
+
if (singleView) {
|
|
227
|
+
navigateTo(singleView.id, element.id);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const [scoped, others] = partition(views, (v) => {
|
|
231
|
+
var _a;
|
|
232
|
+
return ((_a = v.viewOf) == null ? void 0 : _a.id) === element.id;
|
|
233
|
+
});
|
|
234
|
+
setPickView({
|
|
235
|
+
elementFqn: element.id,
|
|
236
|
+
scoped,
|
|
237
|
+
others
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
ElementsColumn
|
|
243
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { focusable } from './_shared.css';
|
|
2
|
+
export declare const backdrop: string;
|
|
3
|
+
export declare const root: string;
|
|
4
|
+
export declare const input: string;
|
|
5
|
+
export declare const pickviewBackdrop: string;
|
|
6
|
+
export declare const pickview: string;
|
|
7
|
+
export declare const pickviewGroup: string;
|
|
8
|
+
export declare const scrollArea: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
var focusable = "_1cfw8gr4";
|
|
4
|
+
var backdrop = "eien2d0";
|
|
5
|
+
var root = "eien2d1";
|
|
6
|
+
var input = "eien2d2";
|
|
7
|
+
var pickviewBackdrop = "eien2d3";
|
|
8
|
+
var pickview = "eien2d4";
|
|
9
|
+
var pickviewGroup = "eien2d5";
|
|
10
|
+
var scrollArea = "eien2d6";
|
|
11
|
+
export {
|
|
12
|
+
backdrop,
|
|
13
|
+
focusable,
|
|
14
|
+
input,
|
|
15
|
+
pickview,
|
|
16
|
+
pickviewBackdrop,
|
|
17
|
+
pickviewGroup,
|
|
18
|
+
root,
|
|
19
|
+
scrollArea
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function LikeC4Search(): import("react/jsx-runtime").JSX.Element;
|