@likec4/diagram 1.31.0 → 1.32.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.
- package/bundle/{chunk-BBzMXzCg.js → chunk-DlHyKoeo.js} +1700 -1206
- package/bundle/custom.js +51 -47
- package/bundle/index.js +5495 -5428
- package/dist/LikeC4CustomColors.d.ts +2 -7
- package/dist/LikeC4CustomColors.js +17 -6
- package/dist/LikeC4Diagram.d.ts +3 -2
- package/dist/LikeC4Diagram.js +10 -14
- package/dist/LikeC4Diagram.props.d.ts +41 -24
- package/dist/LikeC4ModelProvider.d.ts +5 -4
- package/dist/StaticLikeC4Diagram.d.ts +3 -2
- package/dist/StaticLikeC4Diagram.js +2 -2
- package/dist/base/BaseXYFlow.js +5 -5
- package/dist/base/const.d.ts +1 -1
- package/dist/base/const.js +1 -1
- package/dist/base/index.d.ts +2 -1
- package/dist/base/primitives/compound/CompoundActionButton.js +2 -1
- package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -1
- package/dist/base/primitives/compound/CompoundTitle.d.ts +1 -1
- package/dist/base/primitives/compound/CompoundTitle.js +2 -1
- package/dist/base/primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeLabel.css.js +1 -0
- package/dist/base/primitives/edge/EdgeLabel.d.ts +3 -3
- package/dist/base/primitives/edge/EdgeLabel.js +6 -4
- package/dist/base/primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeMarkers.d.ts +1 -1
- package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
- package/dist/base/primitives/element/ElementActionButtons.js +10 -9
- package/dist/base/primitives/element/ElementDetailsButton.js +2 -1
- package/dist/base/primitives/element/ElementShape.d.ts +1 -1
- package/dist/base/primitives/element/ElementTags.d.ts +14 -0
- package/dist/base/primitives/element/ElementTags.js +176 -0
- package/dist/base/primitives/element/ElementTitle.d.ts +5 -4
- package/dist/base/primitives/element/ElementTitle.js +6 -6
- package/dist/base/primitives/index.d.ts +1 -0
- package/dist/base/types.Base.d.ts +54 -0
- package/dist/base/types.Base.js +48 -0
- package/dist/base/types.d.ts +2 -52
- package/dist/bundle/LikeC4View.d.ts +2 -1
- package/dist/bundle/LikeC4View.js +22 -19
- package/dist/bundle/LikeC4View.props.d.ts +15 -4
- package/dist/bundle/ReactLikeC4.d.ts +4 -7
- package/dist/bundle/ReactLikeC4.js +10 -8
- package/dist/bundle/index.js +1 -1
- package/dist/components/ErrorFallback.d.ts +2 -0
- package/dist/components/ErrorFallback.js +29 -0
- package/dist/context/DiagramEventHandlers.d.ts +6 -5
- package/dist/context/DiagramFeatures.d.ts +2 -2
- package/dist/context/DiagramFeatures.js +3 -31
- package/dist/context/EnsureMantine.js +1 -1
- package/dist/context/IconRenderer.js +1 -4
- package/dist/context/RootContainer.js +5 -1
- package/dist/context/TagStylesContext.d.ts +7 -0
- package/dist/context/TagStylesContext.js +85 -0
- package/dist/custom/components.d.ts +1 -1
- package/dist/custom/customNodes.d.ts +32 -17
- package/dist/custom/hooks.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useDiagram.d.ts +73 -38
- package/dist/hooks/useDiagram.js +7 -3
- package/dist/hooks/useMantinePortalProps.d.ts +2 -2
- package/dist/hooks/useSearchActor.d.ts +2 -0
- package/dist/hooks/useSearchActor.js +10 -0
- package/dist/hooks/useUpdateEffect.js +3 -0
- package/dist/hooks/useXYFlow.d.ts +39 -37
- package/dist/hooks/useXYFlow.js +5 -1
- package/dist/index.js +1 -1
- package/dist/likec4diagram/DiagramUI.js +7 -2
- package/dist/likec4diagram/DiagramXYFlow.d.ts +4 -3
- package/dist/likec4diagram/DiagramXYFlow.js +107 -110
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +7 -6
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +8 -0
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +7 -5
- package/dist/likec4diagram/custom/index.d.ts +7 -6
- package/dist/likec4diagram/custom/nodes/nodes.js +39 -26
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +7 -7
- package/dist/likec4diagram/types.d.ts +5 -5
- package/dist/likec4diagram/ui/controls/Controls.js +12 -4
- package/dist/likec4diagram/ui/notation/NotationPanel.js +1 -1
- package/dist/likec4diagram/useViewToNodesEdges.d.ts +5 -3
- package/dist/likec4diagram/useViewToNodesEdges.js +20 -30
- package/dist/likec4model/LikeC4ModelContext.d.ts +2 -2
- package/dist/likec4model/index.d.ts +1 -1
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Model.d.ts +23 -10
- package/dist/likec4model/useLikeC4Model.js +22 -7
- package/dist/overlays/Overlays.js +4 -27
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetailsCard.js +19 -12
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelStructure.d.ts +1 -1
- package/dist/overlays/element-details/actor.d.ts +288 -286
- package/dist/overlays/overlay/Overlay.css.d.ts +57 -2
- package/dist/overlays/overlay/Overlay.css.js +76 -39
- package/dist/overlays/overlay/Overlay.d.ts +12 -0
- package/dist/overlays/overlay/Overlay.js +58 -27
- package/dist/overlays/overlaysActor.d.ts +1 -1
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +3 -2
- package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
- package/dist/overlays/relationship-details/_types.d.ts +2 -2
- package/dist/overlays/relationship-details/actor.js +7 -7
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +3 -2
- package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -0
- package/dist/overlays/relationship-details/hooks.d.ts +10 -9
- package/dist/overlays/relationship-details/layout-to-xyflow.js +1 -0
- package/dist/overlays/relationship-details/layout.js +3 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -2
- package/dist/overlays/relationships-browser/SelectElement.js +1 -1
- package/dist/overlays/relationships-browser/_types.d.ts +2 -2
- package/dist/overlays/relationships-browser/actor.d.ts +1 -1
- package/dist/overlays/relationships-browser/actor.js +7 -7
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -2
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +8 -5
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -0
- package/dist/overlays/relationships-browser/layout.d.ts +2 -2
- package/dist/overlays/relationships-browser/layout.js +10 -6
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +4 -3
- package/dist/search/Search.d.ts +4 -0
- package/dist/search/Search.js +173 -0
- package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.js +0 -1
- package/dist/search/components/ElementsColumn.d.ts +2 -0
- package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.js +26 -25
- package/dist/search/components/PickView.d.ts +4 -0
- package/dist/search/components/PickView.js +135 -0
- package/dist/search/components/SearchByTags.d.ts +1 -0
- package/dist/search/components/SearchByTags.js +119 -0
- package/dist/search/components/SearchInput.d.ts +2 -0
- package/dist/{likec4diagram/ui/search → search/components}/SearchInput.js +61 -40
- package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.d.ts +3 -2
- package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.js +25 -17
- package/dist/{likec4diagram/ui/search → search/components}/_shared.css.js +26 -35
- package/dist/{likec4diagram/ui/search/LikeC4Search.css.d.ts → search/components/styles.css.d.ts} +0 -2
- package/dist/search/components/styles.css.js +60 -0
- package/dist/search/components/utils.d.ts +5 -0
- package/dist/search/components/utils.js +58 -0
- package/dist/search/hooks.d.ts +10 -0
- package/dist/search/hooks.js +35 -0
- package/dist/search/searchActor.d.ts +90 -0
- package/dist/search/searchActor.js +75 -0
- package/dist/state/DiagramActorProvider.d.ts +9 -7
- package/dist/state/DiagramActorProvider.js +24 -18
- package/dist/state/assign.d.ts +0 -1
- package/dist/state/assign.js +9 -19
- package/dist/state/diagram-machine.d.ts +645 -183
- package/dist/state/diagram-machine.js +127 -60
- package/dist/state/syncManualLayoutActor.d.ts +2 -2
- package/dist/state/types.d.ts +2 -0
- package/dist/state/utils.d.ts +2 -0
- package/dist/state/utils.js +3 -0
- 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/package.json +20 -19
- package/panda.buildinfo.json +171 -148
- package/src/LikeC4CustomColors.tsx +21 -6
- package/src/LikeC4Diagram.props.ts +48 -32
- package/src/LikeC4Diagram.tsx +19 -20
- package/src/LikeC4ModelProvider.tsx +6 -5
- package/src/StaticLikeC4Diagram.tsx +8 -6
- package/src/base/const.ts +1 -1
- package/src/base/index.ts +2 -1
- package/src/base/primitives/compound/CompoundActionButton.tsx +2 -1
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -1
- package/src/base/primitives/compound/CompoundTitle.tsx +3 -2
- package/src/base/primitives/edge/EdgeContainer.tsx +2 -1
- package/src/base/primitives/edge/EdgeLabel.css.ts +1 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +20 -15
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
- package/src/base/primitives/edge/EdgeMarkers.tsx +2 -1
- package/src/base/primitives/edge/EdgePath.tsx +1 -1
- package/src/base/primitives/element/ElementActionButtons.tsx +11 -10
- package/src/base/primitives/element/ElementDetailsButton.tsx +2 -1
- package/src/base/primitives/element/ElementShape.tsx +2 -1
- package/src/base/primitives/element/ElementTags.tsx +182 -0
- package/src/base/primitives/element/ElementTitle.tsx +21 -15
- package/src/base/primitives/index.ts +1 -0
- package/src/base/types.Base.ts +104 -0
- package/src/base/types.ts +2 -99
- package/src/bundle/LikeC4View.props.ts +17 -4
- package/src/bundle/LikeC4View.tsx +27 -36
- package/src/bundle/ReactLikeC4.tsx +16 -36
- package/src/components/ErrorFallback.tsx +30 -0
- package/src/context/DiagramEventHandlers.tsx +5 -4
- package/src/context/DiagramFeatures.tsx +3 -22
- package/src/context/EnsureMantine.tsx +1 -1
- package/src/context/IconRenderer.tsx +1 -4
- package/src/context/RootContainer.tsx +9 -3
- package/src/context/TagStylesContext.tsx +96 -0
- package/src/custom/components.ts +2 -0
- package/src/custom/customNodes.tsx +29 -14
- package/src/custom/hooks.ts +2 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useCurrentViewId.ts +1 -4
- package/src/hooks/useDiagram.ts +104 -12
- package/src/hooks/useMantinePortalProps.ts +10 -1
- package/src/hooks/useSearchActor.ts +11 -0
- package/src/hooks/useUpdateEffect.ts +7 -4
- package/src/hooks/useXYFlow.ts +5 -0
- package/src/likec4diagram/DiagramUI.tsx +5 -0
- package/src/likec4diagram/DiagramXYFlow.tsx +118 -121
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +9 -0
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +10 -9
- package/src/likec4diagram/custom/nodes/nodes.tsx +45 -43
- package/src/likec4diagram/custom/nodes/toolbar/_shared.tsx +11 -3
- package/src/likec4diagram/types.ts +5 -3
- package/src/likec4diagram/ui/controls/Controls.tsx +11 -4
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -2
- package/src/likec4diagram/useViewToNodesEdges.ts +34 -36
- package/src/likec4model/LikeC4ModelContext.ts +2 -2
- package/src/likec4model/index.ts +2 -0
- package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
- package/src/likec4model/useLikeC4Model.ts +32 -16
- package/src/overlays/Overlays.tsx +5 -32
- package/src/overlays/element-details/ElementDetailsCard.tsx +25 -18
- package/src/overlays/element-details/TabPanelDeployments.tsx +3 -2
- package/src/overlays/element-details/TabPanelRelationships.tsx +2 -1
- package/src/overlays/element-details/TabPanelStructure.tsx +1 -1
- package/src/overlays/element-details/actor.ts +2 -2
- package/src/overlays/overlay/Overlay.css.ts +75 -38
- package/src/overlays/overlay/Overlay.tsx +61 -29
- package/src/overlays/overlaysActor.ts +1 -1
- package/src/overlays/relationship-details/RelationshipDetails.tsx +4 -4
- package/src/overlays/relationship-details/_types.ts +2 -1
- package/src/overlays/relationship-details/custom/nodeTypes.tsx +4 -0
- package/src/overlays/relationship-details/layout-to-xyflow.ts +1 -0
- package/src/overlays/relationship-details/layout.ts +3 -1
- package/src/overlays/relationships-browser/SelectElement.tsx +1 -1
- package/src/overlays/relationships-browser/_types.ts +2 -1
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +4 -0
- package/src/overlays/relationships-browser/layout.ts +12 -7
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +4 -4
- package/src/search/Search.tsx +220 -0
- package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.css.ts +0 -29
- package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.tsx +28 -29
- package/src/search/components/PickView.tsx +134 -0
- package/src/search/components/SearchByTags.tsx +112 -0
- package/src/{likec4diagram/ui/search → search/components}/SearchInput.tsx +72 -42
- package/src/{likec4diagram/ui/search → search/components}/ViewsColum.tsx +29 -22
- package/src/{likec4diagram/ui/search → search/components}/_shared.css.ts +26 -37
- package/src/{likec4diagram/ui/search/LikeC4Search.css.ts → search/components/styles.css.ts} +9 -36
- package/src/search/components/utils.ts +64 -0
- package/src/search/hooks.ts +38 -0
- package/src/search/searchActor.ts +99 -0
- package/src/state/DiagramActorProvider.tsx +37 -25
- package/src/state/assign.ts +10 -10
- package/src/state/diagram-machine.ts +123 -58
- package/src/state/syncManualLayoutActor.ts +1 -1
- package/src/state/types.ts +2 -0
- package/src/state/utils.ts +4 -0
- package/dist/base/types.js +0 -54
- package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +0 -1
- package/dist/likec4diagram/ui/search/LikeC4Search.css.js +0 -87
- package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +0 -2
- package/dist/likec4diagram/ui/search/LikeC4Search.js +0 -267
- package/dist/likec4diagram/ui/search/SearchInput.d.ts +0 -1
- package/dist/likec4diagram/ui/search/state.d.ts +0 -19
- package/dist/likec4diagram/ui/search/state.js +0 -63
- package/dist/likec4diagram/ui/search/utils.d.ts +0 -3
- package/dist/likec4diagram/ui/search/utils.js +0 -20
- package/src/likec4diagram/ui/search/LikeC4Search.tsx +0 -301
- package/src/likec4diagram/ui/search/state.ts +0 -78
- package/src/likec4diagram/ui/search/utils.ts +0 -20
- /package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.d.ts +0 -0
- /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.d.ts +0 -0
- /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.js +0 -0
- /package/dist/{likec4diagram/ui/search → search/components}/_shared.css.d.ts +0 -0
- /package/src/{likec4diagram/ui/search → search/components}/ViewsColumn.css.ts +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { isTagColorSpecified } from '@likec4/core';
|
|
3
|
+
import { cx, css } from '@likec4/styles/css';
|
|
4
|
+
import { Box, HStack } from '@likec4/styles/jsx';
|
|
5
|
+
import { hstack } from '@likec4/styles/patterns';
|
|
6
|
+
import { likec4tag } from '@likec4/styles/recipes';
|
|
7
|
+
import { HoverCard } from '@mantine/core';
|
|
8
|
+
import { deepEqual } from 'fast-equals';
|
|
9
|
+
import { memo, useCallback, forwardRef } from 'react';
|
|
10
|
+
import { useTagSpecification } from '../../../context/TagStylesContext.js';
|
|
11
|
+
import { useDiagram } from '../../../hooks/useDiagram.js';
|
|
12
|
+
import { useMantinePortalProps } from '../../../hooks/useMantinePortalProps.js';
|
|
13
|
+
import { useCurrentZoom } from '../../../hooks/useXYFlow.js';
|
|
14
|
+
import { stopPropagation } from '../../../utils/xyflow.js';
|
|
15
|
+
|
|
16
|
+
const ElementTag = forwardRef(
|
|
17
|
+
({ tag, className, ...props }, ref) => {
|
|
18
|
+
const spec = useTagSpecification(tag);
|
|
19
|
+
return /* @__PURE__ */ jsxs(
|
|
20
|
+
Box,
|
|
21
|
+
{
|
|
22
|
+
ref,
|
|
23
|
+
"data-likec4-tag": tag,
|
|
24
|
+
className: cx(
|
|
25
|
+
likec4tag({
|
|
26
|
+
autoTextColor: isTagColorSpecified(spec)
|
|
27
|
+
}),
|
|
28
|
+
className
|
|
29
|
+
),
|
|
30
|
+
...props,
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx("span", { style: { opacity: 0.7, fontSize: "1.05em" }, children: "#" }),
|
|
33
|
+
/* @__PURE__ */ jsx("span", { children: tag })
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
const propsAreEqual = (prev, next) => {
|
|
40
|
+
return prev.data.width === next.data.width && deepEqual(prev.data.tags, next.data.tags);
|
|
41
|
+
};
|
|
42
|
+
const ElementTags = memo(({ id, data: { tags, width } }) => {
|
|
43
|
+
const zoom = useCurrentZoom();
|
|
44
|
+
const zoomIsLargeEnough = zoom > 1.2;
|
|
45
|
+
const portalProps = useMantinePortalProps();
|
|
46
|
+
if (!tags || tags.length === 0) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const maxWidth = Math.max(Math.round(width * zoom) - 10, 200);
|
|
50
|
+
return /* @__PURE__ */ jsxs(
|
|
51
|
+
HoverCard,
|
|
52
|
+
{
|
|
53
|
+
...portalProps,
|
|
54
|
+
floatingStrategy: "fixed",
|
|
55
|
+
position: "bottom-start",
|
|
56
|
+
offset: {
|
|
57
|
+
alignmentAxis: Math.round(4 * zoom),
|
|
58
|
+
mainAxis: 8
|
|
59
|
+
},
|
|
60
|
+
keepMounted: false,
|
|
61
|
+
openDelay: 300,
|
|
62
|
+
closeDelay: 500,
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx(HoverCard.Target, { children: /* @__PURE__ */ jsx(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
className: cx(
|
|
68
|
+
"likec4-element-tags",
|
|
69
|
+
hstack({
|
|
70
|
+
pointerEvents: "all",
|
|
71
|
+
gap: 4,
|
|
72
|
+
alignItems: "flex-end",
|
|
73
|
+
justifyItems: "stretch",
|
|
74
|
+
position: "absolute",
|
|
75
|
+
width: "100%",
|
|
76
|
+
bottom: 0,
|
|
77
|
+
left: 0,
|
|
78
|
+
padding: 4,
|
|
79
|
+
_shapeCylinder: {
|
|
80
|
+
bottom: 5
|
|
81
|
+
},
|
|
82
|
+
_shapeStorage: {
|
|
83
|
+
bottom: 5
|
|
84
|
+
},
|
|
85
|
+
_shapeQueue: {
|
|
86
|
+
bottom: 0,
|
|
87
|
+
paddingLeft: 14
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
),
|
|
91
|
+
onClick: stopPropagation,
|
|
92
|
+
children: tags.map((tag) => /* @__PURE__ */ jsx(
|
|
93
|
+
Box,
|
|
94
|
+
{
|
|
95
|
+
"data-likec4-tag": tag,
|
|
96
|
+
className: css({
|
|
97
|
+
layerStyle: "likec4.tag",
|
|
98
|
+
flex: 1,
|
|
99
|
+
display: "flex",
|
|
100
|
+
alignItems: "center",
|
|
101
|
+
justifyContent: "center",
|
|
102
|
+
maxWidth: 50,
|
|
103
|
+
height: 5,
|
|
104
|
+
_whenHovered: {
|
|
105
|
+
height: 12,
|
|
106
|
+
borderRadius: 4,
|
|
107
|
+
transitionDelay: ".08s"
|
|
108
|
+
},
|
|
109
|
+
transition: "fast"
|
|
110
|
+
})
|
|
111
|
+
},
|
|
112
|
+
id + "#" + tag
|
|
113
|
+
))
|
|
114
|
+
}
|
|
115
|
+
) }),
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
HoverCard.Dropdown,
|
|
118
|
+
{
|
|
119
|
+
p: 0,
|
|
120
|
+
w: "auto",
|
|
121
|
+
maw: maxWidth,
|
|
122
|
+
className: css({
|
|
123
|
+
background: "transparent",
|
|
124
|
+
border: "none"
|
|
125
|
+
}),
|
|
126
|
+
children: /* @__PURE__ */ jsx(ElementTagsDropdown, { tags, zoomIsLargeEnough })
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}, propsAreEqual);
|
|
133
|
+
ElementTags.displayName = "ElementTags";
|
|
134
|
+
function ElementTagsDropdown({ tags, zoomIsLargeEnough }) {
|
|
135
|
+
const diagram = useDiagram();
|
|
136
|
+
const onHover = (tag) => {
|
|
137
|
+
diagram.send({ type: "tag.highlight", tag });
|
|
138
|
+
};
|
|
139
|
+
const onLeave = useCallback(() => {
|
|
140
|
+
diagram.send({ type: "tag.unhighlight" });
|
|
141
|
+
}, []);
|
|
142
|
+
return /* @__PURE__ */ jsx(
|
|
143
|
+
HStack,
|
|
144
|
+
{
|
|
145
|
+
css: {
|
|
146
|
+
gap: 4,
|
|
147
|
+
flexWrap: "wrap",
|
|
148
|
+
pb: "sm"
|
|
149
|
+
},
|
|
150
|
+
children: tags.map((tag) => /* @__PURE__ */ jsx(
|
|
151
|
+
ElementTag,
|
|
152
|
+
{
|
|
153
|
+
tag,
|
|
154
|
+
className: css({
|
|
155
|
+
userSelect: "none",
|
|
156
|
+
cursor: "pointer",
|
|
157
|
+
...zoomIsLargeEnough && {
|
|
158
|
+
fontSize: "lg",
|
|
159
|
+
borderRadius: 4,
|
|
160
|
+
px: 6
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
onClick: (e) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
diagram.openSearch(`#${tag}`);
|
|
166
|
+
},
|
|
167
|
+
onMouseEnter: () => onHover(tag),
|
|
168
|
+
onMouseLeave: onLeave
|
|
169
|
+
},
|
|
170
|
+
tag
|
|
171
|
+
))
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { ElementTag, ElementTags };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DiagramNode } from '@likec4/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { DiagramNode } from '@likec4/core/types';
|
|
2
|
+
import { Simplify } from 'type-fest';
|
|
3
|
+
import { NodeProps, NonOptional } from '../../types';
|
|
4
|
+
type Data = Simplify<NonOptional<Pick<DiagramNode, 'title' | 'technology' | 'description' | 'color' | 'style'>> & {
|
|
4
5
|
icon?: string | null;
|
|
5
|
-
}
|
|
6
|
+
}>;
|
|
6
7
|
type ElementTitleProps = NodeProps<Data> & {
|
|
7
8
|
iconSize?: number;
|
|
8
9
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cx } from '@likec4/styles/css';
|
|
3
|
-
import { Box
|
|
3
|
+
import { Box } from '@likec4/styles/jsx';
|
|
4
|
+
import { Text } from '@mantine/core';
|
|
4
5
|
import { isTruthy, isEmpty, isNumber } from 'remeda';
|
|
5
6
|
import { IconRenderer } from '../../../context/IconRenderer.js';
|
|
6
7
|
import { nodeSizes } from './ElementNodeContainer.js';
|
|
@@ -30,11 +31,10 @@ function ElementTitle({ id, data, iconSize: iconSize$1 }) {
|
|
|
30
31
|
classes.root,
|
|
31
32
|
"likec4-element"
|
|
32
33
|
),
|
|
33
|
-
style: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
34
|
+
style: isNumber(iconSize$1) ? {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
[iconSize]: `${iconSize$1}px`
|
|
37
|
+
} : void 0,
|
|
38
38
|
children: [
|
|
39
39
|
elementIcon$1,
|
|
40
40
|
/* @__PURE__ */ jsxs(Box, { className: cx(classes.textContainer, "likec4-element-main-props"), children: [
|
|
@@ -14,5 +14,6 @@ export { ElementActionButtons } from './element/ElementActionButtons';
|
|
|
14
14
|
export { ElementDetailsButton } from './element/ElementDetailsButton';
|
|
15
15
|
export { ElementNodeContainer } from './element/ElementNodeContainer';
|
|
16
16
|
export { ElementShape } from './element/ElementShape';
|
|
17
|
+
export { ElementTag, ElementTags } from './element/ElementTags';
|
|
17
18
|
export { ElementTitle } from './element/ElementTitle';
|
|
18
19
|
export { DefaultHandles } from './NodeHandles';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Edge as RFEdge, Node as RFNode, NodeProps as ReactFlowNodeProps } from '@xyflow/react';
|
|
2
|
+
import { Simplify } from 'type-fest';
|
|
3
|
+
export type Dimmed = 'immediate' | boolean;
|
|
4
|
+
export type NodeData = {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the cursor is hovering over the node
|
|
7
|
+
*/
|
|
8
|
+
hovered?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the node is dimmed
|
|
11
|
+
* 'immediate' means that the node is dimmed without delay
|
|
12
|
+
*/
|
|
13
|
+
dimmed?: Dimmed;
|
|
14
|
+
};
|
|
15
|
+
export type Node = RFNode<NodeData>;
|
|
16
|
+
export type NodeProps = ReactFlowNodeProps<RFNode<NodeData, any>>;
|
|
17
|
+
export type EdgeData = {
|
|
18
|
+
/**
|
|
19
|
+
* Whether the cursor is hovering over the edge
|
|
20
|
+
*/
|
|
21
|
+
hovered?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the edge is active (animated and highlighted)
|
|
24
|
+
*/
|
|
25
|
+
active?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the edge is dimmed
|
|
28
|
+
* 'immediate' means that the edge is dimmed without delay
|
|
29
|
+
*/
|
|
30
|
+
dimmed?: Dimmed;
|
|
31
|
+
};
|
|
32
|
+
export type Edge = Simplify<Omit<RFEdge, 'data'> & {
|
|
33
|
+
data: EdgeData;
|
|
34
|
+
}>;
|
|
35
|
+
type WithDimmed = {
|
|
36
|
+
data: {
|
|
37
|
+
dimmed?: Dimmed;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
type WithHovered = {
|
|
41
|
+
data: {
|
|
42
|
+
hovered?: boolean;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare function setDimmed<T extends WithDimmed>(value: T, dimmed: 'immediate' | boolean): T;
|
|
46
|
+
export declare function setDimmed(dimmed: 'immediate' | boolean): <T extends WithDimmed>(value: T) => T;
|
|
47
|
+
export declare function setHovered<T extends WithHovered>(value: T, hovered: boolean): T;
|
|
48
|
+
export declare function setHovered(hovered: boolean): <T extends WithHovered>(value: T) => T;
|
|
49
|
+
type WithData<D> = {
|
|
50
|
+
data: D;
|
|
51
|
+
};
|
|
52
|
+
export declare function setData<E extends WithData<any>>(value: E, state: Partial<E['data']>): E;
|
|
53
|
+
export declare function setData<E extends WithData<any>>(state: Partial<E['data']>): (value: E) => E;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { hasSubObject } from 'remeda';
|
|
2
|
+
|
|
3
|
+
const _setDimmed = (v, dimmed) => (v.data.dimmed ?? false) === dimmed ? v : {
|
|
4
|
+
...v,
|
|
5
|
+
data: {
|
|
6
|
+
...v.data,
|
|
7
|
+
dimmed
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function setDimmed(arg1, arg2) {
|
|
11
|
+
if (arg2 !== void 0) {
|
|
12
|
+
return _setDimmed(arg1, arg2);
|
|
13
|
+
}
|
|
14
|
+
return (v) => _setDimmed(v, arg1);
|
|
15
|
+
}
|
|
16
|
+
const _setHovered = (v, hovered) => (v.data.hovered ?? false) === hovered ? v : {
|
|
17
|
+
...v,
|
|
18
|
+
data: {
|
|
19
|
+
...v.data,
|
|
20
|
+
hovered
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function setHovered(arg1, arg2) {
|
|
24
|
+
if (arg2 !== void 0) {
|
|
25
|
+
return _setHovered(arg1, arg2);
|
|
26
|
+
}
|
|
27
|
+
return (v) => _setHovered(v, arg1);
|
|
28
|
+
}
|
|
29
|
+
function _setData(value, state) {
|
|
30
|
+
if (hasSubObject(value.data, state)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
...value,
|
|
35
|
+
data: {
|
|
36
|
+
...value.data,
|
|
37
|
+
...state
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function setData(arg1, arg2) {
|
|
42
|
+
if (arg2 !== void 0) {
|
|
43
|
+
return _setData(arg1, arg2);
|
|
44
|
+
}
|
|
45
|
+
return (edge) => _setData(edge, arg1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { setData, setDimmed, setHovered };
|
package/dist/base/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Edge as RFEdge, EdgeProps as ReactFlowEdgeProps, Node as RFNode, NodeProps as ReactFlowNodeProps } from '@xyflow/react';
|
|
2
2
|
import { OptionalKeysOf, SetRequired, Simplify } from 'type-fest';
|
|
3
|
+
import * as Base from './types.Base';
|
|
3
4
|
/**
|
|
4
5
|
|
|
5
6
|
To cooperate with `exactOptionalPropertyTypes` in `tsconfig.json`
|
|
@@ -36,55 +37,4 @@ export type NodeProps<T extends Record<string, unknown> = {}, NodeType extends s
|
|
|
36
37
|
export type EdgeProps<T extends Record<string, unknown> = {}> = SetRequired<ReactFlowEdgeProps<RFEdge<Base.EdgeData & T, any>>, 'data'>;
|
|
37
38
|
export type ReactFlowNode<Data extends Record<string, unknown>, NodeType extends string> = SetRequired<RFNode<Data, NodeType>, 'type' | 'initialWidth' | 'initialHeight'>;
|
|
38
39
|
export type ReactFlowEdge<Data extends Record<string, unknown>, EdgeType extends string> = SetRequired<RFEdge<Data, EdgeType>, 'type' | 'data'>;
|
|
39
|
-
export
|
|
40
|
-
export type Dimmed = 'immediate' | boolean;
|
|
41
|
-
export type NodeData = {
|
|
42
|
-
/**
|
|
43
|
-
* Whether the cursor is hovering over the node
|
|
44
|
-
*/
|
|
45
|
-
hovered?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Whether the node is dimmed
|
|
48
|
-
* 'immediate' means that the node is dimmed without delay
|
|
49
|
-
*/
|
|
50
|
-
dimmed?: Dimmed;
|
|
51
|
-
};
|
|
52
|
-
export type Node = RFNode<NodeData>;
|
|
53
|
-
export type NodeProps = ReactFlowNodeProps<RFNode<Base.NodeData, any>>;
|
|
54
|
-
export type EdgeData = {
|
|
55
|
-
/**
|
|
56
|
-
* Whether the cursor is hovering over the edge
|
|
57
|
-
*/
|
|
58
|
-
hovered?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Whether the edge is active (animated and highlighted)
|
|
61
|
-
*/
|
|
62
|
-
active?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Whether the edge is dimmed
|
|
65
|
-
* 'immediate' means that the edge is dimmed without delay
|
|
66
|
-
*/
|
|
67
|
-
dimmed?: Dimmed;
|
|
68
|
-
};
|
|
69
|
-
export type Edge = SetRequired<RFEdge<EdgeData>, 'data'>;
|
|
70
|
-
type WithDimmed = {
|
|
71
|
-
data: {
|
|
72
|
-
dimmed?: Dimmed;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
type WithHovered = {
|
|
76
|
-
data: {
|
|
77
|
-
hovered?: boolean;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
export function setDimmed<T extends WithDimmed>(value: T, dimmed: 'immediate' | boolean): T;
|
|
81
|
-
export function setDimmed(dimmed: 'immediate' | boolean): <T extends WithDimmed>(value: T) => T;
|
|
82
|
-
export function setHovered<T extends WithHovered>(value: T, hovered: boolean): T;
|
|
83
|
-
export function setHovered(hovered: boolean): <T extends WithHovered>(value: T) => T;
|
|
84
|
-
type WithData<D> = {
|
|
85
|
-
data: D;
|
|
86
|
-
};
|
|
87
|
-
export function setData<E extends WithData<any>>(value: E, state: Partial<E['data']>): E;
|
|
88
|
-
export function setData<E extends WithData<any>>(state: Partial<E['data']>): (value: E) => E;
|
|
89
|
-
export {};
|
|
90
|
-
}
|
|
40
|
+
export * as Base from './types.Base';
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { LikeC4ViewProps } from './LikeC4View.props';
|
|
2
|
-
|
|
2
|
+
import type * as aux from '@likec4/core/types/aux';
|
|
3
|
+
export declare function LikeC4View<A extends aux.Any = aux.UnknownLayouted>({ viewId, ...props }: LikeC4ViewProps<A>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { memo, useState } from 'react';
|
|
3
|
-
import { ShadowRoot } from './ShadowRoot.js';
|
|
4
2
|
import { cx } from '@likec4/styles/css';
|
|
5
3
|
import { Box, ActionIcon } from '@mantine/core';
|
|
6
4
|
import { shallowEqual } from '@mantine/hooks';
|
|
7
5
|
import { IconX } from '@tabler/icons-react';
|
|
6
|
+
import { memo, useState } from 'react';
|
|
8
7
|
import { isBoolean } from 'remeda';
|
|
9
8
|
import { FramerMotionConfig } from '../context/FramerMotionConfig.js';
|
|
10
9
|
import { LikeC4Diagram } from '../LikeC4Diagram.js';
|
|
11
10
|
import { useLikeC4Model } from '../likec4model/useLikeC4Model.js';
|
|
12
11
|
import { Overlay } from '../overlays/overlay/Overlay.js';
|
|
12
|
+
import { ShadowRoot } from './ShadowRoot.js';
|
|
13
13
|
import { useColorScheme, useShadowRootStyle, cssInteractive } from './styles.css.js';
|
|
14
|
-
import {
|
|
14
|
+
import { ViewNotFound, ErrorMessage } from './ViewNotFound.js';
|
|
15
15
|
|
|
16
16
|
function LikeC4View({
|
|
17
17
|
viewId,
|
|
18
18
|
...props
|
|
19
19
|
}) {
|
|
20
20
|
const likec4model = useLikeC4Model();
|
|
21
|
-
const view = likec4model
|
|
22
|
-
if (!
|
|
23
|
-
return /* @__PURE__ */ jsx(ErrorMessage, { children: "LikeC4Model not found. Make sure you have LikeC4ModelProvider." });
|
|
24
|
-
}
|
|
25
|
-
if (likec4model.type !== "layouted") {
|
|
26
|
-
return /* @__PURE__ */ jsx(ErrorMessage, { children: "LikeC4Model is not layouted. Make sure you have LikeC4ModelProvider with layouted model." });
|
|
27
|
-
}
|
|
28
|
-
if (!view || !view.isDiagram()) {
|
|
21
|
+
const view = likec4model.findView(viewId);
|
|
22
|
+
if (!view) {
|
|
29
23
|
return /* @__PURE__ */ jsx(ViewNotFound, { viewId });
|
|
30
24
|
}
|
|
25
|
+
if (!view.isDiagram()) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(ErrorMessage, { children: [
|
|
27
|
+
'LikeC4 View "$',
|
|
28
|
+
viewId,
|
|
29
|
+
'" is not layouted. Make sure you have LikeC4ModelProvider with layouted model.'
|
|
30
|
+
] });
|
|
31
|
+
}
|
|
31
32
|
return /* @__PURE__ */ jsx(LikeC4ViewInner, { view: view.$view, ...props });
|
|
32
33
|
}
|
|
33
34
|
const LikeC4ViewInner = memo(({
|
|
@@ -40,7 +41,7 @@ const LikeC4ViewInner = memo(({
|
|
|
40
41
|
injectFontCss = true,
|
|
41
42
|
controls = false,
|
|
42
43
|
fitView = true,
|
|
43
|
-
fitViewPadding = "
|
|
44
|
+
fitViewPadding = "16px",
|
|
44
45
|
background = "transparent",
|
|
45
46
|
browser = true,
|
|
46
47
|
showDiagramTitle = false,
|
|
@@ -59,12 +60,12 @@ const LikeC4ViewInner = memo(({
|
|
|
59
60
|
renderNodes,
|
|
60
61
|
...props
|
|
61
62
|
}) => {
|
|
62
|
-
const likec4model = useLikeC4Model(
|
|
63
|
+
const likec4model = useLikeC4Model("layouted");
|
|
63
64
|
const colorScheme = useColorScheme(explicitColorScheme);
|
|
64
65
|
const [shadowRootProps, cssstyle] = useShadowRootStyle(keepAspectRatio, view);
|
|
65
66
|
const [browserViewId, onNavigateTo] = useState(null);
|
|
66
67
|
const browserView = browserViewId ? likec4model.findView(browserViewId)?.$view : null;
|
|
67
|
-
const notations = view.notation?.
|
|
68
|
+
const notations = view.notation?.nodes ?? [];
|
|
68
69
|
const hasNotations = notations.length > 0;
|
|
69
70
|
let nonce;
|
|
70
71
|
if (typeof styleNonce === "string") {
|
|
@@ -118,6 +119,7 @@ const LikeC4ViewInner = memo(({
|
|
|
118
119
|
enableRelationshipDetails,
|
|
119
120
|
enableElementDetails,
|
|
120
121
|
enableRelationshipBrowser,
|
|
122
|
+
enableElementTags: false,
|
|
121
123
|
controls,
|
|
122
124
|
nodesDraggable: false,
|
|
123
125
|
reduceGraphics,
|
|
@@ -133,27 +135,28 @@ const LikeC4ViewInner = memo(({
|
|
|
133
135
|
...props
|
|
134
136
|
}
|
|
135
137
|
),
|
|
136
|
-
browserView && /* @__PURE__ */ jsxs(Overlay, { onClose: () => onNavigateTo(null), children: [
|
|
138
|
+
browserView && /* @__PURE__ */ jsxs(Overlay, { openDelay: 0, onClose: () => onNavigateTo(null), children: [
|
|
137
139
|
/* @__PURE__ */ jsx(
|
|
138
140
|
LikeC4Diagram,
|
|
139
141
|
{
|
|
140
142
|
view: browserView,
|
|
141
143
|
background: "dots",
|
|
142
|
-
onNavigateTo
|
|
144
|
+
onNavigateTo,
|
|
143
145
|
enableDynamicViewWalkthrough: true,
|
|
144
146
|
enableFocusMode: true,
|
|
145
147
|
enableRelationshipBrowser: true,
|
|
146
148
|
enableElementDetails: true,
|
|
147
149
|
enableRelationshipDetails: true,
|
|
148
150
|
enableSearch: true,
|
|
151
|
+
enableElementTags: true,
|
|
149
152
|
controls: true,
|
|
150
153
|
readonly: true,
|
|
151
154
|
fitView: true,
|
|
152
|
-
fitViewPadding: "
|
|
153
|
-
renderNodes,
|
|
155
|
+
fitViewPadding: "32px",
|
|
154
156
|
...props,
|
|
155
157
|
...browserProps,
|
|
156
|
-
showNotations: (browserProps.showNotations ?? true) && (browserView.notation?.
|
|
158
|
+
showNotations: (browserProps.showNotations ?? true) && (browserView.notation?.nodes.length ?? 0) > 0,
|
|
159
|
+
renderNodes
|
|
157
160
|
}
|
|
158
161
|
),
|
|
159
162
|
/* @__PURE__ */ jsx(Box, { pos: "absolute", top: "1rem", right: "1rem", children: /* @__PURE__ */ jsx(
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { WhereOperator } from '@likec4/core';
|
|
1
|
+
import { WhereOperator } from '@likec4/core/types';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
3
|
import { CustomNodes, ElementIconRenderer, OverrideReactFlowProps, PaddingWithUnit } from '../LikeC4Diagram.props';
|
|
4
|
-
|
|
4
|
+
import type * as aux from '@likec4/core/types/aux';
|
|
5
|
+
export interface LikeC4ViewProps<A extends aux.Any> {
|
|
5
6
|
/**
|
|
6
7
|
* View to display.
|
|
7
8
|
*/
|
|
8
|
-
viewId: ViewId
|
|
9
|
+
viewId: aux.ViewId<A>;
|
|
9
10
|
/**
|
|
10
11
|
* Enable/disable panning
|
|
11
12
|
* @default false
|
|
@@ -92,6 +93,11 @@ export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
|
|
|
92
93
|
* @default false
|
|
93
94
|
*/
|
|
94
95
|
enableElementDetails?: boolean | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Display element tags in the bottom left corner
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
enableElementTags?: boolean | undefined;
|
|
95
101
|
/**
|
|
96
102
|
* Experimental feature to browse relationships
|
|
97
103
|
*
|
|
@@ -109,7 +115,7 @@ export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
|
|
|
109
115
|
* @default 'auto' - will be set to true if view is pannable and has more than 3000 * 2000 pixels
|
|
110
116
|
*/
|
|
111
117
|
reduceGraphics?: 'auto' | boolean | undefined;
|
|
112
|
-
where?: WhereOperator<
|
|
118
|
+
where?: WhereOperator<A> | undefined;
|
|
113
119
|
/**
|
|
114
120
|
* Override some react flow props
|
|
115
121
|
*/
|
|
@@ -191,6 +197,11 @@ export interface LikeC4BrowserProps {
|
|
|
191
197
|
* @default enableRelationshipBrowser
|
|
192
198
|
*/
|
|
193
199
|
enableRelationshipDetails?: boolean | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Display element tags in the bottom left corner
|
|
202
|
+
* @default true
|
|
203
|
+
*/
|
|
204
|
+
enableElementTags?: boolean | undefined;
|
|
194
205
|
/**
|
|
195
206
|
* Display notations of the view
|
|
196
207
|
* @default true
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { WhereOperator } from '@likec4/core';
|
|
2
1
|
import { CSSProperties } from 'react';
|
|
3
2
|
import { LikeC4DiagramProps } from '../LikeC4Diagram';
|
|
4
|
-
import
|
|
5
|
-
export type ReactLikeC4Props<
|
|
6
|
-
viewId: ViewId
|
|
3
|
+
import type * as aux from '@likec4/core/types/aux';
|
|
4
|
+
export type ReactLikeC4Props<A extends aux.Any> = Omit<LikeC4DiagramProps<A>, 'view'> & {
|
|
5
|
+
viewId: aux.ViewId<A>;
|
|
7
6
|
/**
|
|
8
7
|
* Keep aspect ratio of the diagram
|
|
9
8
|
* Disable if you need to manage the viewport (use className)
|
|
@@ -24,13 +23,11 @@ export type ReactLikeC4Props<ViewId = string, Tag = string, Kind = string> = Omi
|
|
|
24
23
|
*/
|
|
25
24
|
injectFontCss?: boolean | undefined;
|
|
26
25
|
style?: CSSProperties | undefined;
|
|
27
|
-
where?: WhereOperator<Tag, Kind> | undefined;
|
|
28
|
-
onNavigateTo?: OnNavigateTo<ViewId> | undefined;
|
|
29
26
|
mantineTheme?: any;
|
|
30
27
|
/** Function to generate nonce attribute added to all generated `<style />` tags */
|
|
31
28
|
styleNonce?: string | (() => string) | undefined;
|
|
32
29
|
};
|
|
33
|
-
export declare function ReactLikeC4<
|
|
30
|
+
export declare function ReactLikeC4<A extends aux.Any = aux.UnknownLayouted>({ viewId, ...props }: ReactLikeC4Props<A>): import("react/jsx-runtime").JSX.Element;
|
|
34
31
|
export declare namespace ReactLikeC4 {
|
|
35
32
|
var displayName: string;
|
|
36
33
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { ShadowRoot } from './ShadowRoot.js';
|
|
3
2
|
import { cx } from '@likec4/styles/css';
|
|
4
3
|
import { isString, isFunction } from 'remeda';
|
|
5
4
|
import { LikeC4Diagram } from '../LikeC4Diagram.js';
|
|
6
5
|
import { useLikeC4Model } from '../likec4model/useLikeC4Model.js';
|
|
6
|
+
import { ShadowRoot } from './ShadowRoot.js';
|
|
7
7
|
import { useColorScheme, useShadowRootStyle } from './styles.css.js';
|
|
8
|
-
import {
|
|
8
|
+
import { ViewNotFound, ErrorMessage } from './ViewNotFound.js';
|
|
9
9
|
|
|
10
10
|
function ReactLikeC4({
|
|
11
11
|
viewId,
|
|
12
12
|
...props
|
|
13
13
|
}) {
|
|
14
14
|
const likec4model = useLikeC4Model();
|
|
15
|
-
const view = likec4model
|
|
16
|
-
if (!likec4model) {
|
|
17
|
-
return /* @__PURE__ */ jsx(ErrorMessage, { children: "LikeC4Model not found. Make sure you have LikeC4ModelProvider." });
|
|
18
|
-
}
|
|
15
|
+
const view = likec4model.findView(viewId);
|
|
19
16
|
if (!view) {
|
|
20
17
|
return /* @__PURE__ */ jsx(ViewNotFound, { viewId });
|
|
21
18
|
}
|
|
22
19
|
if (!view.isDiagram()) {
|
|
23
|
-
return /* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ jsxs(ErrorMessage, { children: [
|
|
21
|
+
'LikeC4 View "$',
|
|
22
|
+
viewId,
|
|
23
|
+
'" is not layouted. Make sure you have LikeC4ModelProvider with layouted model.'
|
|
24
|
+
] });
|
|
24
25
|
}
|
|
25
26
|
return /* @__PURE__ */ jsx(ReactLikeC4Inner, { view: view.$view, ...props });
|
|
26
27
|
}
|
|
@@ -40,7 +41,7 @@ function ReactLikeC4Inner({
|
|
|
40
41
|
}) {
|
|
41
42
|
const colorScheme = useColorScheme(explicitColorScheme);
|
|
42
43
|
const [shadowRootProps, cssstyle] = useShadowRootStyle(keepAspectRatio, view);
|
|
43
|
-
const notations = view.notation?.
|
|
44
|
+
const notations = view.notation?.nodes ?? [];
|
|
44
45
|
const hasNotations = notations.length > 0;
|
|
45
46
|
let nonce;
|
|
46
47
|
if (isString(styleNonce)) {
|
|
@@ -77,6 +78,7 @@ function ReactLikeC4Inner({
|
|
|
77
78
|
showNotations: showNotations && hasNotations,
|
|
78
79
|
onNavigateTo,
|
|
79
80
|
background,
|
|
81
|
+
enableElementTags: false,
|
|
80
82
|
...props
|
|
81
83
|
}
|
|
82
84
|
)
|
package/dist/bundle/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { useEnabledFeatures } from '../context/DiagramFeatures.js';
|
|
|
7
7
|
export { useCurrentViewId } from '../hooks/useCurrentViewId.js';
|
|
8
8
|
export { useDiagram, useDiagramContext } from '../hooks/useDiagram.js';
|
|
9
9
|
export { useXYFlow, useXYInternalNode, useXYStore, useXYStoreApi } from '../hooks/useXYFlow.js';
|
|
10
|
-
export { useLikeC4Model } from '../likec4model/useLikeC4Model.js';
|
|
10
|
+
export { useLikeC4Model, useLikeC4Specification, useLikeC4ViewModel } from '../likec4model/useLikeC4Model.js';
|
|
11
11
|
export { useMantinePortalProps } from '../hooks/useMantinePortalProps.js';
|
|
12
12
|
export { useSetState } from '../hooks/useSetState.js';
|
|
13
13
|
export { useUpdateEffect } from '../hooks/useUpdateEffect.js';
|