@likec4/diagram 1.18.0 → 1.19.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/LICENSE +1 -1
- package/dist/LikeC4CustomColors.d.ts +7 -0
- package/dist/LikeC4CustomColors.js +30 -0
- package/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +13 -0
- package/dist/LikeC4Diagram.d.ts +6 -0
- package/dist/LikeC4Diagram.js +194 -0
- package/dist/LikeC4Diagram.props.d.ts +166 -0
- package/dist/LikeC4ModelProvider.d.ts +9 -0
- package/dist/LikeC4ModelProvider.js +12 -0
- package/dist/LikeC4Search.css.d.ts +1 -0
- package/dist/LikeC4Search.css.js +5 -0
- package/dist/LikeC4Search.d.ts +2 -0
- package/dist/LikeC4Search.js +96 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -0
- package/dist/StaticLikeC4Diagram.js +41 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/controls/Text.d.ts +2 -0
- package/dist/controls/Text.js +7 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
- package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
- package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
- package/dist/controls/action-buttons/ActionButton.css.js +5 -0
- package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
- package/dist/controls/action-buttons/ActionButton.js +66 -0
- package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
- package/dist/controls/action-buttons/ActionButtons.js +99 -0
- package/dist/globals.css.d.ts +1 -0
- package/dist/globals.css.js +92 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDiagramState.d.ts +6 -0
- package/dist/hooks/useDiagramState.js +27 -0
- package/dist/hooks/useMantinePortalProps.d.ts +9 -0
- package/dist/hooks/useMantinePortalProps.js +9 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSetState.js +19 -0
- package/dist/hooks/useUpdateEffect.d.ts +4 -0
- package/dist/hooks/useUpdateEffect.js +32 -0
- package/dist/hooks/useXYFlow.d.ts +270 -0
- package/dist/hooks/useXYFlow.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
- package/dist/likec4model/LikeC4ModelContext.js +5 -0
- package/dist/likec4model/index.d.ts +2 -0
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
- package/dist/likec4model/useLikeC4Model.d.ts +20 -0
- package/dist/likec4model/useLikeC4Model.js +55 -0
- package/dist/overlays/OverlayContext.d.ts +10 -0
- package/dist/overlays/OverlayContext.js +9 -0
- package/dist/overlays/Overlays.css.d.ts +3 -0
- package/dist/overlays/Overlays.css.js +7 -0
- package/dist/overlays/Overlays.d.ts +2 -0
- package/dist/overlays/Overlays.js +137 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
- package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
- package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
- package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
- package/dist/overlays/edge-details/SelectEdge.js +129 -0
- package/dist/overlays/edge-details/_types.d.ts +14 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
- package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
- package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
- package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
- package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
- package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
- package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
- package/dist/overlays/element-details/TabPanelStructure.js +91 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
- package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
- package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
- package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
- package/dist/overlays/relationships-of/SelectElement.js +126 -0
- package/dist/overlays/relationships-of/_types.d.ts +28 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
- package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
- package/dist/state/DiagramContext.d.ts +1609 -0
- package/dist/state/DiagramContext.js +101 -0
- package/dist/state/aligners.d.ts +42 -0
- package/dist/state/aligners.js +349 -0
- package/dist/state/diagram-to-xyflow.d.ts +11 -0
- package/dist/state/diagram-to-xyflow.js +113 -0
- package/dist/state/diagramStore.d.ts +1705 -0
- package/dist/state/diagramStore.js +808 -0
- package/dist/state/diagramStore.layout.d.ts +4 -0
- package/dist/state/diagramStore.layout.js +56 -0
- package/dist/style.css +1 -0
- package/dist/theme-vars.css.d.ts +72 -0
- package/dist/theme-vars.css.js +6 -0
- package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
- package/dist/theme-vars.d.ts +3 -0
- package/dist/theme-vars.js +5 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.css.js +11 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.js +159 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
- package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.js +156 -0
- package/dist/ui/EnsureMantine.d.ts +7 -0
- package/dist/ui/EnsureMantine.js +14 -0
- package/dist/ui/FramerMotionConfig.d.ts +2 -0
- package/dist/ui/FramerMotionConfig.js +14 -0
- package/dist/ui/Link.d.ts +4 -0
- package/dist/ui/Link.js +36 -0
- package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
- package/dist/ui/notation/NotationPanel.css.js +16 -0
- package/dist/ui/notation/NotationPanel.d.ts +1 -0
- package/dist/ui/notation/NotationPanel.js +250 -0
- package/dist/ui/notation/index.d.ts +1 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
- package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
- package/dist/ui/top-left/TopLeftPanel.js +211 -0
- package/dist/ui/top-left/_shared.d.ts +7 -0
- package/dist/ui/top-left/_shared.js +22 -0
- package/dist/ui/top-left/styles.css.d.ts +8 -0
- package/dist/ui/top-left/styles.css.js +17 -0
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/vector.d.ts +24 -0
- package/dist/utils/vector.js +55 -0
- package/dist/xyflow/EdgeMarkers.d.ts +12 -0
- package/dist/xyflow/EdgeMarkers.js +192 -0
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
- package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
- package/dist/xyflow/XYFlow.d.ts +8 -0
- package/dist/xyflow/XYFlow.js +145 -0
- package/dist/xyflow/XYFlowBackground.d.ts +10 -0
- package/dist/xyflow/XYFlowBackground.js +25 -0
- package/dist/xyflow/XYFlowInner.d.ts +8 -0
- package/dist/xyflow/XYFlowInner.js +41 -0
- package/dist/xyflow/const.d.ts +7 -0
- package/dist/xyflow/const.js +12 -0
- package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
- package/dist/xyflow/edges/EdgeLabel.js +160 -0
- package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
- package/dist/xyflow/edges/RelationshipEdge.js +443 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
- package/dist/xyflow/edges/edges.css.d.ts +17 -0
- package/dist/xyflow/edges/edges.css.js +37 -0
- package/dist/xyflow/edges/utils.d.ts +16 -0
- package/dist/xyflow/edges/utils.js +24 -0
- package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
- package/dist/xyflow/nodes/AnimateVariants.js +123 -0
- package/dist/xyflow/nodes/Node.css.d.ts +3 -0
- package/dist/xyflow/nodes/Node.css.js +9 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
- package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
- package/dist/xyflow/nodes/compound/index.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
- package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.js +190 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
- package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
- package/dist/xyflow/nodes/element/element.css.js +31 -0
- package/dist/xyflow/nodes/element/index.d.ts +1 -0
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
- package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
- package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
- package/dist/xyflow/types.d.ts +36 -0
- package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
- package/dist/xyflow/useLayoutConstraints.js +226 -0
- package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
- package/dist/xyflow/useXYFlowEvents.js +275 -0
- package/dist/xyflow/utils.d.ts +22 -0
- package/dist/xyflow/utils.js +72 -0
- package/package.json +34 -27
- package/src/LikeC4Diagram.tsx +4 -4
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +39 -90
- package/src/controls/Text.ts +5 -0
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
- package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
- package/src/controls/action-buttons/ActionButton.css.ts +29 -0
- package/src/controls/action-buttons/ActionButton.tsx +66 -0
- package/src/controls/action-buttons/ActionButtons.tsx +138 -0
- package/src/hooks/useXYFlow.ts +8 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
- package/src/overlays/edge-details/_types.ts +13 -37
- package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
- package/src/overlays/shared/xyflow/_types.ts +87 -0
- package/src/state/diagram-to-xyflow.ts +6 -7
- package/src/state/diagramStore.layout.ts +3 -4
- package/src/state/diagramStore.ts +35 -37
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +6 -6
- package/src/utils/types.ts +6 -0
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
- package/src/xyflow/XYFlow.tsx +2 -2
- package/src/xyflow/edges/EdgeLabel.tsx +25 -18
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
- package/src/xyflow/edges/edges.css.ts +68 -74
- package/src/xyflow/edges/utils.ts +6 -6
- package/src/xyflow/nodes/AnimateVariants.ts +143 -0
- package/src/xyflow/nodes/Node.css.ts +44 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
- package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
- package/src/xyflow/nodes/element/element.css.ts +0 -57
- package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +9 -9
- package/src/xyflow/useXYFlowEvents.ts +13 -30
- package/src/xyflow/utils.ts +2 -2
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@mantine/core";
|
|
3
|
+
import { useId } from "@mantine/hooks";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import "framer-motion";
|
|
6
|
+
import { container } from "./ActionButtonBar.css.js";
|
|
7
|
+
import { ActionButtonBarContext } from "./useActionButtonBarCtx.js";
|
|
8
|
+
const TRANSLATE_DIFF = 5;
|
|
9
|
+
const elementVariants = (prefix, index, count, shiftX, shiftY) => {
|
|
10
|
+
const name = `${prefix}${index + 1}`;
|
|
11
|
+
const translation = count > 1 ? {
|
|
12
|
+
x: shiftX === "spread" ? 1 - count + index * 2 : shiftX,
|
|
13
|
+
y: shiftY === "spread" ? 1 - count + index * 2 : shiftY
|
|
14
|
+
} : {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 1
|
|
17
|
+
};
|
|
18
|
+
const variants = {
|
|
19
|
+
idle: {
|
|
20
|
+
"--icon-scale": "scale(1)",
|
|
21
|
+
"--ai-bg": "var(--ai-bg-idle)",
|
|
22
|
+
scale: 1,
|
|
23
|
+
opacity: 0.8,
|
|
24
|
+
translateX: 0,
|
|
25
|
+
translateY: 0,
|
|
26
|
+
originX: 0.5,
|
|
27
|
+
originY: 0.5
|
|
28
|
+
// translateY: 0,
|
|
29
|
+
// ...align === 'left' && {
|
|
30
|
+
// originX: 0.75,
|
|
31
|
+
// translateX: -1
|
|
32
|
+
// },
|
|
33
|
+
// ...align === 'right' && {
|
|
34
|
+
// originX: 0.25,
|
|
35
|
+
// translateX: 1
|
|
36
|
+
// }
|
|
37
|
+
},
|
|
38
|
+
hovered: {
|
|
39
|
+
"--ai-bg": "var(--ai-bg-hover)",
|
|
40
|
+
"--icon-scale": "scale(1)",
|
|
41
|
+
// translateY: 3,
|
|
42
|
+
scale: 1.28,
|
|
43
|
+
opacity: 1,
|
|
44
|
+
translateX: translation.x * TRANSLATE_DIFF,
|
|
45
|
+
translateY: translation.y * TRANSLATE_DIFF
|
|
46
|
+
// ...align === 'left' && {
|
|
47
|
+
// translateX: -4
|
|
48
|
+
// },
|
|
49
|
+
// ...align === 'right' && {
|
|
50
|
+
// translateX: 4
|
|
51
|
+
// }
|
|
52
|
+
},
|
|
53
|
+
[`hovered:${name}`]: {
|
|
54
|
+
"--ai-bg": "var(--ai-hover)",
|
|
55
|
+
"--icon-scale": "scale(1.08)",
|
|
56
|
+
scale: 1.45
|
|
57
|
+
},
|
|
58
|
+
[`tap:${name}`]: {
|
|
59
|
+
"--icon-scale": "scale(1)",
|
|
60
|
+
scale: 1.15
|
|
61
|
+
},
|
|
62
|
+
selected: {}
|
|
63
|
+
};
|
|
64
|
+
variants["selected"] = variants["hovered"];
|
|
65
|
+
variants["hovered:details"] = variants["idle"];
|
|
66
|
+
return {
|
|
67
|
+
variants,
|
|
68
|
+
["data-animate-target"]: name
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const ActionButtonBar = ({
|
|
72
|
+
shiftX = "spread",
|
|
73
|
+
shiftY = "spread",
|
|
74
|
+
children
|
|
75
|
+
}) => {
|
|
76
|
+
const id = useId();
|
|
77
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
78
|
+
let shiftDiffX = "spread";
|
|
79
|
+
if (shiftX == "left") {
|
|
80
|
+
shiftDiffX = -1;
|
|
81
|
+
} else if (shiftX == "right") {
|
|
82
|
+
shiftDiffX = 1;
|
|
83
|
+
}
|
|
84
|
+
let shiftDiffY = "spread";
|
|
85
|
+
if (shiftY == "top") {
|
|
86
|
+
shiftDiffY = -1;
|
|
87
|
+
} else if (shiftY == "bottom") {
|
|
88
|
+
shiftDiffY = 1;
|
|
89
|
+
}
|
|
90
|
+
return /* @__PURE__ */ jsx(Box, { className: clsx(container), children: childrenArray.map((child, i, all) => /* @__PURE__ */ jsx(
|
|
91
|
+
ActionButtonBarContext.Provider,
|
|
92
|
+
{
|
|
93
|
+
value: elementVariants(id, i, all.length, shiftDiffX, shiftDiffY),
|
|
94
|
+
children: child
|
|
95
|
+
}
|
|
96
|
+
)) });
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
ActionButtonBar
|
|
100
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Variants } from 'framer-motion';
|
|
2
|
+
import { Context } from 'react';
|
|
3
|
+
export declare const ActionButtonBarContext: Context<{
|
|
4
|
+
variants: Variants;
|
|
5
|
+
"data-animate-target"?: string;
|
|
6
|
+
} | null>;
|
|
7
|
+
export declare function useActionButtonBarCtx(): {
|
|
8
|
+
variants: Variants;
|
|
9
|
+
"data-animate-target"?: string;
|
|
10
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const btn: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionIconProps } from '@mantine/core';
|
|
2
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
3
|
+
import { PropsWithoutRef } from 'react';
|
|
4
|
+
export type ActionButtonProps = PropsWithoutRef<Omit<ActionIconProps & HTMLMotionProps<'div'>, 'onClick' | 'children'> & {
|
|
5
|
+
onClick: (e: React.MouseEvent) => void;
|
|
6
|
+
IconComponent: React.ComponentType<any>;
|
|
7
|
+
tooltipLabel?: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const ActionButton: ({ onClick: action, IconComponent, tooltipLabel, ...props }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip, ActionIcon } from "@mantine/core";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { m } from "framer-motion";
|
|
5
|
+
import { stopPropagation } from "../../xyflow/utils.js";
|
|
6
|
+
import { useActionButtonBarCtx } from "../action-button-bar/useActionButtonBarCtx.js";
|
|
7
|
+
import { btn } from "./ActionButton.css.js";
|
|
8
|
+
const variants = {
|
|
9
|
+
idle: {
|
|
10
|
+
"--icon-scale": "scale(1)",
|
|
11
|
+
"--ai-bg": "var(--ai-bg-idle)"
|
|
12
|
+
},
|
|
13
|
+
hovered: {
|
|
14
|
+
"--icon-scale": "scale(1)",
|
|
15
|
+
"--ai-bg": "var(--ai-bg-hover)"
|
|
16
|
+
},
|
|
17
|
+
selected: {}
|
|
18
|
+
};
|
|
19
|
+
variants["selected"] = variants["hovered"];
|
|
20
|
+
const ActionButton = ({
|
|
21
|
+
onClick: action,
|
|
22
|
+
IconComponent,
|
|
23
|
+
tooltipLabel,
|
|
24
|
+
...props
|
|
25
|
+
}) => {
|
|
26
|
+
const ctx = useActionButtonBarCtx() ?? {
|
|
27
|
+
variants
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
Tooltip,
|
|
31
|
+
{
|
|
32
|
+
fz: "xs",
|
|
33
|
+
color: "dark",
|
|
34
|
+
label: tooltipLabel ?? "",
|
|
35
|
+
disabled: !tooltipLabel,
|
|
36
|
+
withinPortal: false,
|
|
37
|
+
offset: 2,
|
|
38
|
+
openDelay: 600,
|
|
39
|
+
children: /* @__PURE__ */ jsx(
|
|
40
|
+
ActionIcon,
|
|
41
|
+
{
|
|
42
|
+
component: m.div,
|
|
43
|
+
className: clsx("nodrag nopan", btn),
|
|
44
|
+
radius: "md",
|
|
45
|
+
role: "button",
|
|
46
|
+
onClick: action,
|
|
47
|
+
onDoubleClick: stopPropagation,
|
|
48
|
+
...ctx,
|
|
49
|
+
...props,
|
|
50
|
+
children: /* @__PURE__ */ jsx(
|
|
51
|
+
IconComponent,
|
|
52
|
+
{
|
|
53
|
+
style: {
|
|
54
|
+
width: "70%",
|
|
55
|
+
transform: "var(--icon-scale)"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
ActionButton
|
|
66
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fqn } from '@likec4/core';
|
|
2
|
+
import { ActionButtonProps } from './ActionButton';
|
|
3
|
+
export type NodeActionButtonProps = Omit<ActionButtonProps, 'onClick' | 'IconComponent' | 'tooltipLabel'> & {
|
|
4
|
+
fqn: Fqn;
|
|
5
|
+
};
|
|
6
|
+
export declare const BrowseRelationshipsButton: ({ fqn, ...props }: NodeActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export type NavigateToButtonProps = Omit<ActionButtonProps, 'onClick' | 'IconComponent' | 'tooltipLabel'> & {
|
|
8
|
+
xynodeId: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const NavigateToButton: ({ xynodeId, ...props }: NavigateToButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const OpenDetailsButton: ({ fqn, ...props }: NodeActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const OpenSourceButton: ({ fqn, ...props }: NodeActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconTransform, IconZoomScan, IconId } from "@tabler/icons-react";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { ActionButton } from "./ActionButton.js";
|
|
5
|
+
import { useDiagramState, useDiagramStoreApi } from "../../hooks/useDiagramState.js";
|
|
6
|
+
const BrowseRelationshipsButton = ({
|
|
7
|
+
fqn,
|
|
8
|
+
...props
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
openOverlay
|
|
12
|
+
} = useDiagramState((s) => ({
|
|
13
|
+
openOverlay: s.openOverlay
|
|
14
|
+
}));
|
|
15
|
+
const onBrowseRelationships = useCallback((e) => {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
openOverlay({ relationshipsOf: fqn });
|
|
18
|
+
}, [openOverlay, fqn]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
ActionButton,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
onClick: onBrowseRelationships,
|
|
24
|
+
IconComponent: IconTransform,
|
|
25
|
+
tooltipLabel: "Browse relationships"
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
const NavigateToButton = ({
|
|
30
|
+
xynodeId,
|
|
31
|
+
...props
|
|
32
|
+
}) => {
|
|
33
|
+
const store = useDiagramStoreApi();
|
|
34
|
+
const onNavigateTo = useCallback((e) => {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
store.getState().triggerOnNavigateTo(xynodeId, e);
|
|
37
|
+
}, [store, xynodeId]);
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
ActionButton,
|
|
40
|
+
{
|
|
41
|
+
...props,
|
|
42
|
+
onClick: onNavigateTo,
|
|
43
|
+
IconComponent: IconZoomScan,
|
|
44
|
+
tooltipLabel: "Open scoped view"
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
const VariantsDetailsBtn = {
|
|
49
|
+
idle: {
|
|
50
|
+
"--ai-bg": "var(--ai-bg-idle)",
|
|
51
|
+
scale: 1,
|
|
52
|
+
opacity: 0.5,
|
|
53
|
+
originX: 0.45,
|
|
54
|
+
originY: 0.55
|
|
55
|
+
},
|
|
56
|
+
selected: {},
|
|
57
|
+
hovered: {
|
|
58
|
+
scale: 1.2,
|
|
59
|
+
opacity: 0.7
|
|
60
|
+
},
|
|
61
|
+
"hovered:details": {
|
|
62
|
+
scale: 1.44,
|
|
63
|
+
opacity: 1
|
|
64
|
+
},
|
|
65
|
+
"tap:details": {
|
|
66
|
+
scale: 1.15
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
VariantsDetailsBtn["selected"] = VariantsDetailsBtn["hovered"];
|
|
70
|
+
const OpenDetailsButton = ({
|
|
71
|
+
fqn,
|
|
72
|
+
...props
|
|
73
|
+
}) => {
|
|
74
|
+
const {
|
|
75
|
+
openOverlay
|
|
76
|
+
} = useDiagramState((s) => ({
|
|
77
|
+
openOverlay: s.openOverlay
|
|
78
|
+
}));
|
|
79
|
+
const onOpenDetails = useCallback((e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
openOverlay({ elementDetails: fqn });
|
|
82
|
+
}, [openOverlay, fqn]);
|
|
83
|
+
return /* @__PURE__ */ jsx(
|
|
84
|
+
ActionButton,
|
|
85
|
+
{
|
|
86
|
+
variants: VariantsDetailsBtn,
|
|
87
|
+
onClick: onOpenDetails,
|
|
88
|
+
IconComponent: IconId,
|
|
89
|
+
tooltipLabel: "Open details",
|
|
90
|
+
"data-animate-target": "details",
|
|
91
|
+
...props
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
BrowseRelationshipsButton,
|
|
97
|
+
NavigateToButton,
|
|
98
|
+
OpenDetailsButton
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const rootClassName = "likec4-diagram-root";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import "./node_modules/@mantine/core/esm/components/ScrollArea/ScrollArea.module.css.mjs.vanilla.css.js";
|
|
2
|
+
import "./node_modules/@mantine/core/esm/components/UnstyledButton/UnstyledButton.module.css.mjs.vanilla.css.js";
|
|
3
|
+
import "./node_modules/@mantine/core/esm/components/VisuallyHidden/VisuallyHidden.module.css.mjs.vanilla.css.js";
|
|
4
|
+
import "./node_modules/@mantine/core/esm/components/Paper/Paper.module.css.mjs.vanilla.css.js";
|
|
5
|
+
import "./node_modules/@mantine/core/esm/components/Popover/Popover.module.css.mjs.vanilla.css.js";
|
|
6
|
+
import "./node_modules/@mantine/core/esm/components/Loader/Loader.module.css.mjs.vanilla.css.js";
|
|
7
|
+
import "./node_modules/@mantine/core/esm/components/ActionIcon/ActionIcon.module.css.mjs.vanilla.css.js";
|
|
8
|
+
import "./node_modules/@mantine/core/esm/components/CloseButton/CloseButton.module.css.mjs.vanilla.css.js";
|
|
9
|
+
import "./node_modules/@mantine/core/esm/components/Group/Group.module.css.mjs.vanilla.css.js";
|
|
10
|
+
import "./node_modules/@mantine/core/esm/components/Overlay/Overlay.module.css.mjs.vanilla.css.js";
|
|
11
|
+
import "./node_modules/@mantine/core/esm/components/ModalBase/ModalBase.module.css.mjs.vanilla.css.js";
|
|
12
|
+
import "./node_modules/@mantine/core/esm/components/Input/Input.module.css.mjs.vanilla.css.js";
|
|
13
|
+
import "./node_modules/@mantine/core/esm/components/Flex/Flex.module.css.mjs.vanilla.css.js";
|
|
14
|
+
import "./node_modules/@mantine/core/esm/components/FloatingIndicator/FloatingIndicator.module.css.mjs.vanilla.css.js";
|
|
15
|
+
import "./node_modules/@mantine/core/esm/components/Accordion/Accordion.module.css.mjs.vanilla.css.js";
|
|
16
|
+
import "./node_modules/@mantine/core/esm/components/Affix/Affix.module.css.mjs.vanilla.css.js";
|
|
17
|
+
import "./node_modules/@mantine/core/esm/components/Alert/Alert.module.css.mjs.vanilla.css.js";
|
|
18
|
+
import "./node_modules/@mantine/core/esm/components/Text/Text.module.css.mjs.vanilla.css.js";
|
|
19
|
+
import "./node_modules/@mantine/core/esm/components/Anchor/Anchor.module.css.mjs.vanilla.css.js";
|
|
20
|
+
import "./node_modules/@mantine/core/esm/components/AngleSlider/AngleSlider.module.css.mjs.vanilla.css.js";
|
|
21
|
+
import "./node_modules/@mantine/core/esm/components/AppShell/AppShell.module.css.mjs.vanilla.css.js";
|
|
22
|
+
import "./node_modules/@mantine/core/esm/components/AspectRatio/AspectRatio.module.css.mjs.vanilla.css.js";
|
|
23
|
+
import "./node_modules/@mantine/core/esm/components/Combobox/Combobox.module.css.mjs.vanilla.css.js";
|
|
24
|
+
import "./node_modules/@mantine/core/esm/components/InlineInput/InlineInput.module.css.mjs.vanilla.css.js";
|
|
25
|
+
import "./node_modules/@mantine/core/esm/components/Checkbox/CheckboxCard/CheckboxCard.module.css.mjs.vanilla.css.js";
|
|
26
|
+
import "./node_modules/@mantine/core/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.module.css.mjs.vanilla.css.js";
|
|
27
|
+
import "./node_modules/@mantine/core/esm/components/Checkbox/Checkbox.module.css.mjs.vanilla.css.js";
|
|
28
|
+
import "./node_modules/@mantine/core/esm/components/Avatar/Avatar.module.css.mjs.vanilla.css.js";
|
|
29
|
+
import "./node_modules/@mantine/core/esm/components/BackgroundImage/BackgroundImage.module.css.mjs.vanilla.css.js";
|
|
30
|
+
import "./node_modules/@mantine/core/esm/components/Badge/Badge.module.css.mjs.vanilla.css.js";
|
|
31
|
+
import "./node_modules/@mantine/core/esm/components/Blockquote/Blockquote.module.css.mjs.vanilla.css.js";
|
|
32
|
+
import "./node_modules/@mantine/core/esm/components/Breadcrumbs/Breadcrumbs.module.css.mjs.vanilla.css.js";
|
|
33
|
+
import "./node_modules/@mantine/core/esm/components/Burger/Burger.module.css.mjs.vanilla.css.js";
|
|
34
|
+
import "./node_modules/@mantine/core/esm/components/Button/Button.module.css.mjs.vanilla.css.js";
|
|
35
|
+
import "./node_modules/@mantine/core/esm/components/Card/Card.module.css.mjs.vanilla.css.js";
|
|
36
|
+
import "./node_modules/@mantine/core/esm/components/Center/Center.module.css.mjs.vanilla.css.js";
|
|
37
|
+
import "./node_modules/@mantine/core/esm/components/Chip/Chip.module.css.mjs.vanilla.css.js";
|
|
38
|
+
import "./node_modules/@mantine/core/esm/components/Code/Code.module.css.mjs.vanilla.css.js";
|
|
39
|
+
import "./node_modules/@mantine/core/esm/components/ColorSwatch/ColorSwatch.module.css.mjs.vanilla.css.js";
|
|
40
|
+
import "./node_modules/@mantine/core/esm/components/ColorPicker/ColorPicker.module.css.mjs.vanilla.css.js";
|
|
41
|
+
import "./node_modules/@mantine/core/esm/components/ColorInput/ColorInput.module.css.mjs.vanilla.css.js";
|
|
42
|
+
import "./node_modules/@mantine/core/esm/components/Container/Container.module.css.mjs.vanilla.css.js";
|
|
43
|
+
import "./node_modules/@mantine/core/esm/components/Dialog/Dialog.module.css.mjs.vanilla.css.js";
|
|
44
|
+
import "./node_modules/@mantine/core/esm/components/Divider/Divider.module.css.mjs.vanilla.css.js";
|
|
45
|
+
import "./node_modules/@mantine/core/esm/components/Drawer/Drawer.module.css.mjs.vanilla.css.js";
|
|
46
|
+
import "./node_modules/@mantine/core/esm/components/Fieldset/Fieldset.module.css.mjs.vanilla.css.js";
|
|
47
|
+
import "./node_modules/@mantine/core/esm/components/Grid/Grid.module.css.mjs.vanilla.css.js";
|
|
48
|
+
import "./node_modules/@mantine/core/esm/components/Mark/Mark.module.css.mjs.vanilla.css.js";
|
|
49
|
+
import "./node_modules/@mantine/core/esm/components/Image/Image.module.css.mjs.vanilla.css.js";
|
|
50
|
+
import "./node_modules/@mantine/core/esm/components/Indicator/Indicator.module.css.mjs.vanilla.css.js";
|
|
51
|
+
import "./node_modules/@mantine/core/esm/components/Kbd/Kbd.module.css.mjs.vanilla.css.js";
|
|
52
|
+
import "./node_modules/@mantine/core/esm/components/List/List.module.css.mjs.vanilla.css.js";
|
|
53
|
+
import "./node_modules/@mantine/core/esm/components/LoadingOverlay/LoadingOverlay.module.css.mjs.vanilla.css.js";
|
|
54
|
+
import "./node_modules/@mantine/core/esm/components/Menu/Menu.module.css.mjs.vanilla.css.js";
|
|
55
|
+
import "./node_modules/@mantine/core/esm/components/Modal/Modal.module.css.mjs.vanilla.css.js";
|
|
56
|
+
import "./node_modules/@mantine/core/esm/components/Pill/Pill.module.css.mjs.vanilla.css.js";
|
|
57
|
+
import "./node_modules/@mantine/core/esm/components/PillsInput/PillsInput.module.css.mjs.vanilla.css.js";
|
|
58
|
+
import "./node_modules/@mantine/core/esm/components/NavLink/NavLink.module.css.mjs.vanilla.css.js";
|
|
59
|
+
import "./node_modules/@mantine/core/esm/components/Notification/Notification.module.css.mjs.vanilla.css.js";
|
|
60
|
+
import "./node_modules/@mantine/core/esm/components/NumberInput/NumberInput.module.css.mjs.vanilla.css.js";
|
|
61
|
+
import "./node_modules/@mantine/core/esm/components/Pagination/Pagination.module.css.mjs.vanilla.css.js";
|
|
62
|
+
import "./node_modules/@mantine/core/esm/components/PasswordInput/PasswordInput.module.css.mjs.vanilla.css.js";
|
|
63
|
+
import "./node_modules/@mantine/core/esm/components/PinInput/PinInput.module.css.mjs.vanilla.css.js";
|
|
64
|
+
import "./node_modules/@mantine/core/esm/components/Progress/Progress.module.css.mjs.vanilla.css.js";
|
|
65
|
+
import "./node_modules/@mantine/core/esm/components/Radio/RadioCard/RadioCard.module.css.mjs.vanilla.css.js";
|
|
66
|
+
import "./node_modules/@mantine/core/esm/components/Radio/RadioIndicator/RadioIndicator.module.css.mjs.vanilla.css.js";
|
|
67
|
+
import "./node_modules/@mantine/core/esm/components/Radio/Radio.module.css.mjs.vanilla.css.js";
|
|
68
|
+
import "./node_modules/@mantine/core/esm/components/Rating/Rating.module.css.mjs.vanilla.css.js";
|
|
69
|
+
import "./node_modules/@mantine/core/esm/components/Tooltip/Tooltip.module.css.mjs.vanilla.css.js";
|
|
70
|
+
import "./node_modules/@mantine/core/esm/components/RingProgress/RingProgress.module.css.mjs.vanilla.css.js";
|
|
71
|
+
import "./node_modules/@mantine/core/esm/components/SegmentedControl/SegmentedControl.module.css.mjs.vanilla.css.js";
|
|
72
|
+
import "./node_modules/@mantine/core/esm/components/SemiCircleProgress/SemiCircleProgress.module.css.mjs.vanilla.css.js";
|
|
73
|
+
import "./node_modules/@mantine/core/esm/components/SimpleGrid/SimpleGrid.module.css.mjs.vanilla.css.js";
|
|
74
|
+
import "./node_modules/@mantine/core/esm/components/Skeleton/Skeleton.module.css.mjs.vanilla.css.js";
|
|
75
|
+
import "./node_modules/@mantine/core/esm/components/Slider/Slider.module.css.mjs.vanilla.css.js";
|
|
76
|
+
import "./node_modules/@mantine/core/esm/components/Spoiler/Spoiler.module.css.mjs.vanilla.css.js";
|
|
77
|
+
import "./node_modules/@mantine/core/esm/components/Stack/Stack.module.css.mjs.vanilla.css.js";
|
|
78
|
+
import "./node_modules/@mantine/core/esm/components/Stepper/Stepper.module.css.mjs.vanilla.css.js";
|
|
79
|
+
import "./node_modules/@mantine/core/esm/components/Switch/Switch.module.css.mjs.vanilla.css.js";
|
|
80
|
+
import "./node_modules/@mantine/core/esm/components/Table/Table.module.css.mjs.vanilla.css.js";
|
|
81
|
+
import "./node_modules/@mantine/core/esm/components/Tabs/Tabs.module.css.mjs.vanilla.css.js";
|
|
82
|
+
import "./node_modules/@mantine/core/esm/components/ThemeIcon/ThemeIcon.module.css.mjs.vanilla.css.js";
|
|
83
|
+
import "./node_modules/@mantine/core/esm/components/Timeline/Timeline.module.css.mjs.vanilla.css.js";
|
|
84
|
+
import "./node_modules/@mantine/core/esm/components/Title/Title.module.css.mjs.vanilla.css.js";
|
|
85
|
+
import "./node_modules/@mantine/core/esm/components/Tree/Tree.module.css.mjs.vanilla.css.js";
|
|
86
|
+
import "./node_modules/@mantine/core/esm/components/TypographyStylesProvider/TypographyStylesProvider.module.css.mjs.vanilla.css.js";
|
|
87
|
+
import "./theme-vars.css.ts.vanilla.css.js";
|
|
88
|
+
/* empty css */
|
|
89
|
+
var rootClassName = "likec4-diagram-root";
|
|
90
|
+
export {
|
|
91
|
+
rootClassName
|
|
92
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ViewId } from '@likec4/core';
|
|
2
|
+
import { DiagramState, DiagramStoreApi } from '../state/diagramStore';
|
|
3
|
+
export declare function useCurrentViewId(): ViewId;
|
|
4
|
+
export declare function useDiagramState<StateSlice = unknown>(selector: (state: DiagramState) => StateSlice, equalityFn?: (a: StateSlice, b: StateSlice) => boolean): StateSlice;
|
|
5
|
+
export declare function useDiagramStoreApi(): DiagramStoreApi;
|
|
6
|
+
export type { DiagramState, DiagramStoreApi };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { shallowEqual } from "fast-equals";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { useStoreWithEqualityFn } from "zustand/traditional";
|
|
4
|
+
import { DiagramContext } from "../state/DiagramContext.js";
|
|
5
|
+
const selectViewId = (state) => state.view.id;
|
|
6
|
+
function useCurrentViewId() {
|
|
7
|
+
return useDiagramState(selectViewId);
|
|
8
|
+
}
|
|
9
|
+
function useDiagramState(selector, equalityFn) {
|
|
10
|
+
const store = useContext(DiagramContext);
|
|
11
|
+
if (store === null) {
|
|
12
|
+
throw new Error("useDiagramStore could be used only inside DiagramContext");
|
|
13
|
+
}
|
|
14
|
+
return useStoreWithEqualityFn(store, selector, equalityFn ?? shallowEqual);
|
|
15
|
+
}
|
|
16
|
+
function useDiagramStoreApi() {
|
|
17
|
+
const store = useContext(DiagramContext);
|
|
18
|
+
if (store === null) {
|
|
19
|
+
throw new Error("useDiagramStoreApi could be used only inside DiagramContext");
|
|
20
|
+
}
|
|
21
|
+
return store;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
useCurrentViewId,
|
|
25
|
+
useDiagramState,
|
|
26
|
+
useDiagramStoreApi
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useDiagramState } from "./useDiagramState.js";
|
|
3
|
+
function useMantinePortalProps() {
|
|
4
|
+
const target = useDiagramState((s) => s.getContainer());
|
|
5
|
+
return useMemo(() => target ? { portalProps: { target }, withinPortal: true } : { withinPortal: false }, [target]);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
useMantinePortalProps
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { shallowEqual } from "fast-equals";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
function useSetState(initialState) {
|
|
4
|
+
const [state, _setState] = useState(initialState);
|
|
5
|
+
const setState = useCallback(
|
|
6
|
+
(statePartial) => _setState((current) => {
|
|
7
|
+
const next = {
|
|
8
|
+
...current,
|
|
9
|
+
...typeof statePartial === "function" ? statePartial(current) : statePartial
|
|
10
|
+
};
|
|
11
|
+
return shallowEqual(current, next) ? current : next;
|
|
12
|
+
}),
|
|
13
|
+
[]
|
|
14
|
+
);
|
|
15
|
+
return [state, setState];
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useSetState
|
|
19
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DependenciesComparator, EffectHook } from '@react-hookz/web';
|
|
2
|
+
import { DependencyList, EffectCallback } from 'react';
|
|
3
|
+
export declare const depsShallowEqual: DependenciesComparator;
|
|
4
|
+
export declare function useUpdateEffect<Callback extends EffectCallback = EffectCallback, Deps extends DependencyList = DependencyList>(callback: Callback, deps: Deps, equalityFn?: DependenciesComparator<Deps>, effectHook?: EffectHook<Callback, Deps>): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useFirstMountState, useCustomCompareEffect } from "@react-hookz/web";
|
|
2
|
+
import { shallowEqual } from "fast-equals";
|
|
3
|
+
import "react";
|
|
4
|
+
const noop = () => {
|
|
5
|
+
};
|
|
6
|
+
const depsShallowEqual = (d1, d2) => {
|
|
7
|
+
if (d1 === d2) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (d1.length !== d2.length) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
for (const [i, element] of d1.entries()) {
|
|
14
|
+
if (!shallowEqual(element, d2[i])) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
function useUpdateEffect(callback, deps, equalityFn, effectHook) {
|
|
21
|
+
const isFirstMount = useFirstMountState();
|
|
22
|
+
useCustomCompareEffect(
|
|
23
|
+
isFirstMount ? noop : callback,
|
|
24
|
+
deps,
|
|
25
|
+
equalityFn ?? depsShallowEqual,
|
|
26
|
+
effectHook
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
depsShallowEqual,
|
|
31
|
+
useUpdateEffect
|
|
32
|
+
};
|