@likec4/diagram 1.30.0 → 1.31.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/README.md +324 -5
- package/bundle/chunk-BBzMXzCg.js +21383 -0
- package/bundle/custom.js +62 -0
- package/bundle/index.js +17459 -38163
- package/dist/LikeC4CustomColors.js +2 -2
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +4 -2
- package/dist/LikeC4Diagram.props.d.ts +6 -1
- package/dist/LikeC4ModelProvider.d.ts +3 -3
- package/dist/LikeC4ModelProvider.js +0 -1
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/base/BaseXYFlow.js +3 -3
- package/dist/base/primitives/compound/CompoundActionButton.d.ts +3 -2
- package/dist/base/primitives/compound/CompoundDetailsButton.d.ts +3 -2
- package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +7 -3
- package/dist/base/primitives/compound/CompoundNodeContainer.js +3 -2
- package/dist/base/primitives/customEdge.d.ts +2 -35
- package/dist/base/primitives/customEdge.js +2 -2
- package/dist/base/primitives/customNode.d.ts +2 -2
- package/dist/base/primitives/customNode.js +9 -2
- package/dist/base/primitives/edge/EdgeContainer.js +0 -1
- package/dist/base/primitives/edge/EdgeLabel.js +0 -1
- package/dist/base/primitives/edge/EdgeLabelContainer.js +0 -2
- package/dist/base/primitives/edge/EdgePath.js +2 -2
- package/dist/base/primitives/element/ElementNodeContainer.d.ts +24 -22
- package/dist/base/primitives/element/ElementNodeContainer.js +66 -68
- package/dist/base/primitives/element/ElementShape.d.ts +8 -4
- package/dist/base/primitives/element/ElementShape.js +4 -3
- package/dist/base/primitives/element/ElementTitle.css.d.ts +1 -1
- package/dist/base/primitives/element/ElementTitle.js +0 -1
- package/dist/base/types.d.ts +5 -5
- package/dist/bundle/LikeC4View.js +6 -3
- package/dist/bundle/LikeC4View.props.d.ts +5 -1
- package/dist/bundle/ReactLikeC4.js +1 -2
- package/dist/bundle/ShadowRoot.js +3 -3
- package/dist/bundle/custom.d.ts +1 -0
- package/dist/bundle/index.d.ts +3 -1
- package/dist/bundle/index.js +9 -0
- package/dist/bundle/styles.css.js +5 -5
- package/dist/components/SearchControl.js +2 -2
- package/dist/context/ControlsCustomLayout.js +0 -1
- package/dist/context/DiagramEventHandlers.js +5 -5
- package/dist/context/DiagramFeatures.d.ts +2 -4
- package/dist/context/DiagramFeatures.js +15 -16
- package/dist/context/EnsureMantine.js +9 -4
- package/dist/context/FramerMotionConfig.js +0 -1
- package/dist/context/IconRenderer.js +7 -7
- package/dist/context/ReduceGraphics.js +6 -6
- package/dist/context/RootContainer.js +5 -5
- package/dist/context/index.d.ts +1 -1
- package/dist/custom/components.d.ts +5 -0
- package/dist/custom/customNodes.d.ts +218 -0
- package/dist/custom/hooks.d.ts +10 -0
- package/dist/custom/index.d.ts +4 -0
- package/dist/hooks/safeContext.js +3 -3
- package/dist/hooks/useCurrentViewId.d.ts +5 -1
- package/dist/hooks/useCurrentViewId.js +1 -2
- package/dist/hooks/useDiagram.d.ts +14 -12544
- package/dist/hooks/useDiagram.js +3 -5
- package/dist/hooks/useMantinePortalProps.js +2 -2
- package/dist/hooks/useSetState.js +3 -3
- package/dist/hooks/useUpdateEffect.js +0 -1
- package/dist/hooks/useXYFlow.d.ts +64 -64
- package/dist/hooks/useXYFlow.js +2 -2
- package/dist/index.d.ts +2 -4
- package/dist/index.js +8 -3
- package/dist/likec4diagram/DiagramUI.js +2 -2
- package/dist/likec4diagram/DiagramXYFlow.d.ts +1 -1
- package/dist/likec4diagram/DiagramXYFlow.js +25 -7
- package/dist/likec4diagram/custom/edges/NotePopover.js +2 -2
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +9 -13
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +8 -8
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +14 -12
- package/dist/likec4diagram/custom/index.d.ts +15 -19
- package/dist/likec4diagram/custom/index.js +3 -3
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +2 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +27 -4
- package/dist/likec4diagram/custom/nodes/ElementActions.js +67 -53
- package/dist/likec4diagram/custom/nodes/index.d.ts +8 -0
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +10 -0
- package/dist/likec4diagram/custom/nodes/{nodeTypes.js → nodes.js} +39 -39
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +6 -7
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +3 -3
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +3 -2
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
- package/dist/likec4diagram/types.d.ts +15 -7
- package/dist/likec4diagram/ui/controls/ChangeAutoLayoutButton.js +4 -4
- package/dist/likec4diagram/ui/controls/Controls.js +2 -2
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +2 -2
- package/dist/likec4diagram/ui/notation/NotationPanel.js +6 -8
- package/dist/likec4diagram/ui/search/ElementsColumn.js +6 -7
- package/dist/likec4diagram/ui/search/LikeC4Search.js +3 -3
- package/dist/likec4diagram/ui/search/SearchInput.js +0 -1
- package/dist/likec4diagram/ui/search/_shared.css.d.ts +1 -1
- package/dist/likec4diagram/ui/search/state.js +3 -4
- package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +4 -4
- package/dist/likec4diagram/useLayoutConstraints.js +3 -4
- package/dist/likec4diagram/useViewToNodesEdges.js +2 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +2 -2
- package/dist/likec4model/LikeC4ModelContext.js +2 -2
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +1 -1
- package/dist/likec4model/useLikeC4ElementsTree.js +3 -3
- package/dist/likec4model/useLikeC4Model.d.ts +1 -1
- package/dist/likec4model/useLikeC4Model.js +2 -2
- package/dist/overlays/Overlays.d.ts +2 -3
- package/dist/overlays/Overlays.js +5 -6
- package/dist/overlays/element-details/ElementDetailsCard.css.js +13 -9
- package/dist/overlays/element-details/ElementDetailsCard.js +98 -105
- package/dist/overlays/element-details/TabPanelDeployments.js +4 -4
- package/dist/overlays/element-details/TabPanelRelationships.js +2 -2
- package/dist/overlays/element-details/TabPanelStructure.js +3 -3
- package/dist/overlays/element-details/actor.d.ts +6905 -19690
- package/dist/overlays/element-details/actor.js +0 -2
- package/dist/overlays/element-details/actorContext.js +3 -3
- package/dist/overlays/overlay/Overlay.d.ts +11 -1
- package/dist/overlays/overlay/Overlay.js +8 -8
- package/dist/overlays/overlaysActor.d.ts +4 -2
- package/dist/overlays/overlaysActor.js +2 -1
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +4 -8
- package/dist/overlays/relationship-details/RelationshipDetails.js +12 -12
- package/dist/overlays/relationship-details/SelectEdge.js +2 -3
- package/dist/overlays/relationship-details/_types.d.ts +6 -5
- package/dist/overlays/relationship-details/actor.d.ts +3 -3
- package/dist/overlays/relationship-details/compute.js +3 -3
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +4 -8
- package/dist/overlays/relationship-details/custom/edgeTypes.js +2 -2
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +3 -31
- package/dist/overlays/relationship-details/hooks.d.ts +27 -27
- package/dist/overlays/relationship-details/hooks.js +4 -4
- package/dist/overlays/relationship-details/layout.js +2 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +4 -8
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +8 -8
- package/dist/overlays/relationships-browser/SelectElement.js +5 -5
- package/dist/overlays/relationships-browser/_types.d.ts +6 -5
- package/dist/overlays/relationships-browser/actor.d.ts +63 -428
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +4 -8
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +2 -2
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +10 -14
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -2
- package/dist/overlays/relationships-browser/hooks.d.ts +4 -61
- package/dist/overlays/relationships-browser/hooks.js +4 -4
- package/dist/overlays/relationships-browser/layout.js +3 -4
- package/dist/state/DiagramActorProvider.js +3 -3
- package/dist/state/diagram-machine.d.ts +186 -10369
- package/dist/state/diagram-machine.js +2 -1
- package/dist/state/hotkeyActor.d.ts +4 -2
- package/dist/state/syncManualLayoutActor.d.ts +14 -3
- package/dist/state/syncManualLayoutActor.js +2 -1
- package/dist/state/types.d.ts +5 -4
- package/dist/state/utils.d.ts +1 -1
- package/dist/styles-font.css +1 -0
- package/dist/styles-min.css +1 -0
- package/dist/styles-xyflow.css +1 -0
- package/dist/styles.css +1 -0
- package/dist/styles.css2.js +3 -0
- package/package.json +46 -21
- package/panda.buildinfo.json +979 -0
- package/src/LikeC4Diagram.props.ts +7 -1
- package/src/LikeC4Diagram.tsx +2 -0
- package/src/LikeC4ModelProvider.tsx +3 -3
- package/src/StaticLikeC4Diagram.tsx +1 -0
- package/src/base/Background.tsx +0 -4
- package/src/base/primitives/compound/CompoundActionButton.tsx +7 -4
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +7 -4
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +8 -7
- package/src/base/primitives/customEdge.ts +1 -1
- package/src/base/primitives/{customNode.ts → customNode.tsx} +11 -3
- package/src/base/primitives/element/ElementNodeContainer.tsx +87 -80
- package/src/base/primitives/element/ElementShape.tsx +11 -10
- package/src/base/types.ts +28 -33
- package/src/bundle/LikeC4View.props.ts +6 -1
- package/src/bundle/LikeC4View.tsx +3 -0
- package/src/bundle/ReactLikeC4.tsx +1 -1
- package/src/bundle/custom.ts +1 -0
- package/src/bundle/index.ts +20 -1
- package/src/bundle/styles.css.ts +1 -1
- package/src/components/SearchControl.tsx +1 -1
- package/src/context/DiagramFeatures.tsx +12 -8
- package/src/context/EnsureMantine.tsx +13 -3
- package/src/context/IconRenderer.tsx +1 -1
- package/src/context/ReduceGraphics.tsx +6 -6
- package/src/context/index.ts +0 -1
- package/src/custom/components.ts +47 -0
- package/src/custom/customNodes.tsx +244 -0
- package/src/custom/hooks.ts +35 -0
- package/src/custom/index.ts +5 -0
- package/src/hooks/useCurrentViewId.ts +9 -1
- package/src/hooks/useDiagram.ts +30 -9
- package/src/index.ts +4 -8
- package/src/likec4diagram/DiagramXYFlow.tsx +28 -5
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +9 -7
- package/src/likec4diagram/custom/{index.tsx → index.ts} +2 -2
- package/src/likec4diagram/custom/nodes/CompoundActions.tsx +2 -2
- package/src/likec4diagram/custom/nodes/ElementActions.tsx +100 -57
- package/src/likec4diagram/custom/nodes/index.ts +17 -0
- package/src/likec4diagram/custom/nodes/{nodeTypes.tsx → nodes.tsx} +52 -36
- package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +3 -4
- package/src/likec4diagram/custom/nodes/toolbar/ElementToolbar.tsx +3 -3
- package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +5 -4
- package/src/likec4diagram/types.ts +19 -9
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +1 -1
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +1 -2
- package/src/likec4diagram/ui/search/ElementsColumn.tsx +2 -4
- package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.tsx +1 -1
- package/src/likec4diagram/useViewToNodesEdges.ts +2 -0
- package/src/likec4model/LikeC4ModelContext.ts +2 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +3 -1
- package/src/likec4model/useLikeC4Model.ts +1 -1
- package/src/overlays/Overlays.tsx +2 -3
- package/src/overlays/element-details/ElementDetailsCard.css.ts +14 -22
- package/src/overlays/element-details/ElementDetailsCard.tsx +18 -16
- package/src/overlays/overlay/Overlay.tsx +3 -4
- package/src/overlays/overlaysActor.ts +4 -3
- package/src/overlays/relationship-details/RelationshipDetails.tsx +1 -1
- package/src/overlays/relationship-details/SelectEdge.tsx +0 -2
- package/src/overlays/relationship-details/_types.ts +16 -13
- package/src/overlays/relationship-details/custom/edgeTypes.tsx +2 -2
- package/src/overlays/relationships-browser/_types.ts +18 -15
- package/src/overlays/relationships-browser/actor.ts +2 -2
- package/src/overlays/relationships-browser/custom/edgeTypes.tsx +2 -2
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +1 -2
- package/src/state/DiagramActorProvider.tsx +2 -2
- package/src/state/diagram-machine.ts +13 -8
- package/src/state/hotkeyActor.ts +4 -2
- package/src/state/syncManualLayoutActor.ts +9 -3
- package/src/state/types.ts +9 -3
- package/src/state/utils.ts +3 -3
- package/src/styles-min.css +2 -0
- package/src/styles-xyflow.css +1 -0
- package/dist/_virtual/_commonjsHelpers.js +0 -5
- package/dist/_virtual/default-map.js +0 -7
- package/dist/_virtual/index.js +0 -5
- package/dist/_virtual/index2.js +0 -3
- package/dist/_virtual/react.production.js +0 -3
- package/dist/_virtual/set.js +0 -5
- package/dist/_virtual/set2.js +0 -3
- package/dist/base/xyflowMachine.d.ts +0 -212
- package/dist/likec4diagram/custom/nodes/nodeTypes.d.ts +0 -8
- package/dist/node_modules/.pnpm/mnemonist@0.40.3_patch_hash_5c12abb43fcff6fd81e53021b89075d53249640d165a2556cc1e58d71201a13a/node_modules/mnemonist/default-map.js +0 -172
- package/dist/node_modules/.pnpm/mnemonist@0.40.3_patch_hash_5c12abb43fcff6fd81e53021b89075d53249640d165a2556cc1e58d71201a13a/node_modules/mnemonist/set.js +0 -369
- package/dist/node_modules/.pnpm/react@19.1.0/node_modules/react/cjs/react.production.js +0 -556
- package/dist/node_modules/.pnpm/react@19.1.0/node_modules/react/index.js +0 -15
- package/dist/packages/core/src/compute-view/relationships-view/compute.js +0 -123
- package/dist/packages/core/src/compute-view/relationships-view/utils.js +0 -68
- package/dist/packages/core/src/errors/index.js +0 -15
- package/dist/packages/core/src/model/connection/model/ConnectionModel.js +0 -121
- package/dist/packages/core/src/model/connection/model/find.js +0 -39
- package/dist/packages/core/src/model/connection/ops.js +0 -7
- package/dist/packages/core/src/utils/const.js +0 -3
- package/dist/packages/core/src/utils/fqn.js +0 -51
- package/dist/packages/core/src/utils/guards.js +0 -7
- package/dist/packages/core/src/utils/iterable/filter.js +0 -21
- package/dist/packages/core/src/utils/iterable/find.js +0 -21
- package/dist/packages/core/src/utils/iterable/map.js +0 -18
- package/dist/packages/core/src/utils/iterable/some.js +0 -21
- package/dist/packages/core/src/utils/iterable/to.js +0 -14
- package/dist/packages/core/src/utils/set.js +0 -48
- package/dist/packages/core/src/utils/string-hash.js +0 -13
- package/dist/styles.css.js +0 -3
- package/src/base/xyflowMachine.ts +0 -75
- /package/dist/{bundle/font.css.js → styles-font.css2.js} +0 -0
- /package/src/{bundle/font.css → styles-font.css} +0 -0
package/dist/hooks/useDiagram.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import '@likec4/core';
|
|
2
1
|
import { useCallbackRef } from '@mantine/hooks';
|
|
3
2
|
import { useSelector } from '@xstate/react';
|
|
4
3
|
import { shallowEqual } from 'fast-equals';
|
|
5
|
-
import {
|
|
4
|
+
import { useMemo } from 'react';
|
|
6
5
|
import { findDiagramEdge, findDiagramNode } from '../state/utils.js';
|
|
7
6
|
import { useDiagramActorRef } from './safeContext.js';
|
|
8
7
|
|
|
9
8
|
function useDiagram() {
|
|
10
9
|
const actor = useDiagramActorRef();
|
|
11
|
-
return
|
|
10
|
+
return useMemo(() => ({
|
|
12
11
|
actor,
|
|
13
|
-
send: actor.send,
|
|
12
|
+
send: (event) => actor.send(event),
|
|
14
13
|
navigateTo: (viewId, fromNode) => {
|
|
15
14
|
actor.send({
|
|
16
15
|
type: "navigate.to",
|
|
@@ -47,7 +46,6 @@ function useDiagram() {
|
|
|
47
46
|
actor.send({
|
|
48
47
|
type: "update.edgeData",
|
|
49
48
|
edgeId,
|
|
50
|
-
// @ts-expect-error TODO: fix this
|
|
51
49
|
data
|
|
52
50
|
});
|
|
53
51
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { useRootContainer } from '../context/RootContainer.js';
|
|
3
3
|
|
|
4
4
|
function useMantinePortalProps() {
|
|
5
5
|
const target = useRootContainer();
|
|
6
|
-
return
|
|
6
|
+
return useMemo(() => target ? { portalProps: { target }, withinPortal: true } : { withinPortal: false }, [target]);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { useMantinePortalProps };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { shallowEqual } from 'fast-equals';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
function useSetState(initialState) {
|
|
5
|
-
const [state, _setState] =
|
|
6
|
-
const setState =
|
|
5
|
+
const [state, _setState] = useState(initialState);
|
|
6
|
+
const setState = useCallback(
|
|
7
7
|
(statePartial) => _setState((current) => {
|
|
8
8
|
const next = {
|
|
9
9
|
...current,
|
|
@@ -2,7 +2,7 @@ import { ReactFlowState, ReactFlowInstance, InternalNode } from '@xyflow/react';
|
|
|
2
2
|
import { Types } from '../likec4diagram/types';
|
|
3
3
|
import { EdgeMarkerType, HandleType, XYPosition } from '@xyflow/system';
|
|
4
4
|
import { ReactNode, CSSProperties } from 'react';
|
|
5
|
-
import { EdgeId, NonEmptyArray, Point, Color,
|
|
5
|
+
import { EdgeId, NonEmptyArray, Point, Color, RelationshipLineType, RelationshipArrowType, BBox, ViewId } from '@likec4/core';
|
|
6
6
|
export declare const useXYFlow: () => ReactFlowInstance<Types.Node, {
|
|
7
7
|
id: string;
|
|
8
8
|
source: string;
|
|
@@ -31,23 +31,23 @@ export declare const useXYFlow: () => ReactFlowInstance<Types.Node, {
|
|
|
31
31
|
focusable?: boolean;
|
|
32
32
|
type: "relationship";
|
|
33
33
|
data: {
|
|
34
|
+
hovered?: boolean;
|
|
35
|
+
active?: boolean;
|
|
36
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
34
37
|
id: EdgeId;
|
|
35
38
|
label: string | null;
|
|
36
39
|
points: NonEmptyArray<Point>;
|
|
37
|
-
technology: string | undefined;
|
|
38
40
|
color: Color | undefined;
|
|
39
|
-
labelBBox: BBox | null | undefined;
|
|
40
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
41
41
|
line: RelationshipLineType | undefined;
|
|
42
|
-
|
|
42
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
43
43
|
tail: RelationshipArrowType | undefined;
|
|
44
|
+
head: RelationshipArrowType | undefined;
|
|
45
|
+
technology: string | undefined;
|
|
46
|
+
labelBBox: BBox | null | undefined;
|
|
44
47
|
navigateTo: ViewId<string> | undefined;
|
|
45
48
|
notes: string | undefined;
|
|
46
49
|
labelXY: XYPosition | null;
|
|
47
50
|
controlPoints: XYPosition[] | undefined | null;
|
|
48
|
-
hovered?: boolean;
|
|
49
|
-
active?: boolean;
|
|
50
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
51
51
|
};
|
|
52
52
|
}>;
|
|
53
53
|
export declare function useXYStore<StateSlice = unknown>(selector: (state: ReactFlowState<Types.Node, Types.Edge>) => StateSlice, equalityFn?: (a: NoInfer<StateSlice>, b: NoInfer<StateSlice>) => boolean): StateSlice;
|
|
@@ -80,23 +80,23 @@ export declare const useXYStoreApi: () => {
|
|
|
80
80
|
focusable?: boolean;
|
|
81
81
|
type: "relationship";
|
|
82
82
|
data: {
|
|
83
|
+
hovered?: boolean;
|
|
84
|
+
active?: boolean;
|
|
85
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
83
86
|
id: EdgeId;
|
|
84
87
|
label: string | null;
|
|
85
88
|
points: NonEmptyArray<Point>;
|
|
86
|
-
technology: string | undefined;
|
|
87
89
|
color: Color | undefined;
|
|
88
|
-
labelBBox: BBox | null | undefined;
|
|
89
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
90
90
|
line: RelationshipLineType | undefined;
|
|
91
|
-
|
|
91
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
92
92
|
tail: RelationshipArrowType | undefined;
|
|
93
|
+
head: RelationshipArrowType | undefined;
|
|
94
|
+
technology: string | undefined;
|
|
95
|
+
labelBBox: BBox | null | undefined;
|
|
93
96
|
navigateTo: ViewId<string> | undefined;
|
|
94
97
|
notes: string | undefined;
|
|
95
98
|
labelXY: XYPosition | null;
|
|
96
99
|
controlPoints: XYPosition[] | undefined | null;
|
|
97
|
-
hovered?: boolean;
|
|
98
|
-
active?: boolean;
|
|
99
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
100
100
|
};
|
|
101
101
|
}>;
|
|
102
102
|
setState: (partial: ReactFlowState<Types.Node, {
|
|
@@ -127,23 +127,23 @@ export declare const useXYStoreApi: () => {
|
|
|
127
127
|
focusable?: boolean;
|
|
128
128
|
type: "relationship";
|
|
129
129
|
data: {
|
|
130
|
+
hovered?: boolean;
|
|
131
|
+
active?: boolean;
|
|
132
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
130
133
|
id: EdgeId;
|
|
131
134
|
label: string | null;
|
|
132
135
|
points: NonEmptyArray<Point>;
|
|
133
|
-
technology: string | undefined;
|
|
134
136
|
color: Color | undefined;
|
|
135
|
-
labelBBox: BBox | null | undefined;
|
|
136
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
137
137
|
line: RelationshipLineType | undefined;
|
|
138
|
-
|
|
138
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
139
139
|
tail: RelationshipArrowType | undefined;
|
|
140
|
+
head: RelationshipArrowType | undefined;
|
|
141
|
+
technology: string | undefined;
|
|
142
|
+
labelBBox: BBox | null | undefined;
|
|
140
143
|
navigateTo: ViewId<string> | undefined;
|
|
141
144
|
notes: string | undefined;
|
|
142
145
|
labelXY: XYPosition | null;
|
|
143
146
|
controlPoints: XYPosition[] | undefined | null;
|
|
144
|
-
hovered?: boolean;
|
|
145
|
-
active?: boolean;
|
|
146
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
147
147
|
};
|
|
148
148
|
}> | Partial<ReactFlowState<Types.Node, {
|
|
149
149
|
id: string;
|
|
@@ -173,23 +173,23 @@ export declare const useXYStoreApi: () => {
|
|
|
173
173
|
focusable?: boolean;
|
|
174
174
|
type: "relationship";
|
|
175
175
|
data: {
|
|
176
|
+
hovered?: boolean;
|
|
177
|
+
active?: boolean;
|
|
178
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
176
179
|
id: EdgeId;
|
|
177
180
|
label: string | null;
|
|
178
181
|
points: NonEmptyArray<Point>;
|
|
179
|
-
technology: string | undefined;
|
|
180
182
|
color: Color | undefined;
|
|
181
|
-
labelBBox: BBox | null | undefined;
|
|
182
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
183
183
|
line: RelationshipLineType | undefined;
|
|
184
|
-
|
|
184
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
185
185
|
tail: RelationshipArrowType | undefined;
|
|
186
|
+
head: RelationshipArrowType | undefined;
|
|
187
|
+
technology: string | undefined;
|
|
188
|
+
labelBBox: BBox | null | undefined;
|
|
186
189
|
navigateTo: ViewId<string> | undefined;
|
|
187
190
|
notes: string | undefined;
|
|
188
191
|
labelXY: XYPosition | null;
|
|
189
192
|
controlPoints: XYPosition[] | undefined | null;
|
|
190
|
-
hovered?: boolean;
|
|
191
|
-
active?: boolean;
|
|
192
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
193
193
|
};
|
|
194
194
|
}>> | ((state: ReactFlowState<Types.Node, {
|
|
195
195
|
id: string;
|
|
@@ -219,23 +219,23 @@ export declare const useXYStoreApi: () => {
|
|
|
219
219
|
focusable?: boolean;
|
|
220
220
|
type: "relationship";
|
|
221
221
|
data: {
|
|
222
|
+
hovered?: boolean;
|
|
223
|
+
active?: boolean;
|
|
224
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
222
225
|
id: EdgeId;
|
|
223
226
|
label: string | null;
|
|
224
227
|
points: NonEmptyArray<Point>;
|
|
225
|
-
technology: string | undefined;
|
|
226
228
|
color: Color | undefined;
|
|
227
|
-
labelBBox: BBox | null | undefined;
|
|
228
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
229
229
|
line: RelationshipLineType | undefined;
|
|
230
|
-
|
|
230
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
231
231
|
tail: RelationshipArrowType | undefined;
|
|
232
|
+
head: RelationshipArrowType | undefined;
|
|
233
|
+
technology: string | undefined;
|
|
234
|
+
labelBBox: BBox | null | undefined;
|
|
232
235
|
navigateTo: ViewId<string> | undefined;
|
|
233
236
|
notes: string | undefined;
|
|
234
237
|
labelXY: XYPosition | null;
|
|
235
238
|
controlPoints: XYPosition[] | undefined | null;
|
|
236
|
-
hovered?: boolean;
|
|
237
|
-
active?: boolean;
|
|
238
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
239
239
|
};
|
|
240
240
|
}>) => ReactFlowState<Types.Node, {
|
|
241
241
|
id: string;
|
|
@@ -265,23 +265,23 @@ export declare const useXYStoreApi: () => {
|
|
|
265
265
|
focusable?: boolean;
|
|
266
266
|
type: "relationship";
|
|
267
267
|
data: {
|
|
268
|
+
hovered?: boolean;
|
|
269
|
+
active?: boolean;
|
|
270
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
268
271
|
id: EdgeId;
|
|
269
272
|
label: string | null;
|
|
270
273
|
points: NonEmptyArray<Point>;
|
|
271
|
-
technology: string | undefined;
|
|
272
274
|
color: Color | undefined;
|
|
273
|
-
labelBBox: BBox | null | undefined;
|
|
274
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
275
275
|
line: RelationshipLineType | undefined;
|
|
276
|
-
|
|
276
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
277
277
|
tail: RelationshipArrowType | undefined;
|
|
278
|
+
head: RelationshipArrowType | undefined;
|
|
279
|
+
technology: string | undefined;
|
|
280
|
+
labelBBox: BBox | null | undefined;
|
|
278
281
|
navigateTo: ViewId<string> | undefined;
|
|
279
282
|
notes: string | undefined;
|
|
280
283
|
labelXY: XYPosition | null;
|
|
281
284
|
controlPoints: XYPosition[] | undefined | null;
|
|
282
|
-
hovered?: boolean;
|
|
283
|
-
active?: boolean;
|
|
284
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
285
285
|
};
|
|
286
286
|
}> | Partial<ReactFlowState<Types.Node, {
|
|
287
287
|
id: string;
|
|
@@ -311,23 +311,23 @@ export declare const useXYStoreApi: () => {
|
|
|
311
311
|
focusable?: boolean;
|
|
312
312
|
type: "relationship";
|
|
313
313
|
data: {
|
|
314
|
+
hovered?: boolean;
|
|
315
|
+
active?: boolean;
|
|
316
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
314
317
|
id: EdgeId;
|
|
315
318
|
label: string | null;
|
|
316
319
|
points: NonEmptyArray<Point>;
|
|
317
|
-
technology: string | undefined;
|
|
318
320
|
color: Color | undefined;
|
|
319
|
-
labelBBox: BBox | null | undefined;
|
|
320
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
321
321
|
line: RelationshipLineType | undefined;
|
|
322
|
-
|
|
322
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
323
323
|
tail: RelationshipArrowType | undefined;
|
|
324
|
+
head: RelationshipArrowType | undefined;
|
|
325
|
+
technology: string | undefined;
|
|
326
|
+
labelBBox: BBox | null | undefined;
|
|
324
327
|
navigateTo: ViewId<string> | undefined;
|
|
325
328
|
notes: string | undefined;
|
|
326
329
|
labelXY: XYPosition | null;
|
|
327
330
|
controlPoints: XYPosition[] | undefined | null;
|
|
328
|
-
hovered?: boolean;
|
|
329
|
-
active?: boolean;
|
|
330
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
331
331
|
};
|
|
332
332
|
}>>), replace?: boolean | undefined) => void;
|
|
333
333
|
subscribe: (listener: (state: ReactFlowState<Types.Node, {
|
|
@@ -358,23 +358,23 @@ export declare const useXYStoreApi: () => {
|
|
|
358
358
|
focusable?: boolean;
|
|
359
359
|
type: "relationship";
|
|
360
360
|
data: {
|
|
361
|
+
hovered?: boolean;
|
|
362
|
+
active?: boolean;
|
|
363
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
361
364
|
id: EdgeId;
|
|
362
365
|
label: string | null;
|
|
363
366
|
points: NonEmptyArray<Point>;
|
|
364
|
-
technology: string | undefined;
|
|
365
367
|
color: Color | undefined;
|
|
366
|
-
labelBBox: BBox | null | undefined;
|
|
367
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
368
368
|
line: RelationshipLineType | undefined;
|
|
369
|
-
|
|
369
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
370
370
|
tail: RelationshipArrowType | undefined;
|
|
371
|
+
head: RelationshipArrowType | undefined;
|
|
372
|
+
technology: string | undefined;
|
|
373
|
+
labelBBox: BBox | null | undefined;
|
|
371
374
|
navigateTo: ViewId<string> | undefined;
|
|
372
375
|
notes: string | undefined;
|
|
373
376
|
labelXY: XYPosition | null;
|
|
374
377
|
controlPoints: XYPosition[] | undefined | null;
|
|
375
|
-
hovered?: boolean;
|
|
376
|
-
active?: boolean;
|
|
377
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
378
378
|
};
|
|
379
379
|
}>, prevState: ReactFlowState<Types.Node, {
|
|
380
380
|
id: string;
|
|
@@ -404,23 +404,23 @@ export declare const useXYStoreApi: () => {
|
|
|
404
404
|
focusable?: boolean;
|
|
405
405
|
type: "relationship";
|
|
406
406
|
data: {
|
|
407
|
+
hovered?: boolean;
|
|
408
|
+
active?: boolean;
|
|
409
|
+
dimmed?: import("../base").Base.Dimmed;
|
|
407
410
|
id: EdgeId;
|
|
408
411
|
label: string | null;
|
|
409
412
|
points: NonEmptyArray<Point>;
|
|
410
|
-
technology: string | undefined;
|
|
411
413
|
color: Color | undefined;
|
|
412
|
-
labelBBox: BBox | null | undefined;
|
|
413
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
414
414
|
line: RelationshipLineType | undefined;
|
|
415
|
-
|
|
415
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
416
416
|
tail: RelationshipArrowType | undefined;
|
|
417
|
+
head: RelationshipArrowType | undefined;
|
|
418
|
+
technology: string | undefined;
|
|
419
|
+
labelBBox: BBox | null | undefined;
|
|
417
420
|
navigateTo: ViewId<string> | undefined;
|
|
418
421
|
notes: string | undefined;
|
|
419
422
|
labelXY: XYPosition | null;
|
|
420
423
|
controlPoints: XYPosition[] | undefined | null;
|
|
421
|
-
hovered?: boolean;
|
|
422
|
-
active?: boolean;
|
|
423
|
-
dimmed?: import("../base").Base.Dimmed;
|
|
424
424
|
};
|
|
425
425
|
}>) => void) => () => void;
|
|
426
426
|
};
|
package/dist/hooks/useXYFlow.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useCallbackRef } from '@mantine/hooks';
|
|
2
|
-
import {
|
|
2
|
+
import { useReactFlow, useInternalNode, useStoreApi, useStore } from '@xyflow/react';
|
|
3
3
|
import { shallowEqual } from 'fast-equals';
|
|
4
4
|
|
|
5
5
|
const useXYFlow = useReactFlow;
|
|
6
6
|
function useXYStore(selector, equalityFn) {
|
|
7
7
|
return useStore(
|
|
8
8
|
useCallbackRef(selector),
|
|
9
|
-
shallowEqual
|
|
9
|
+
equalityFn ?? shallowEqual
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
12
|
const useXYStoreApi = useStoreApi;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,8 @@ export { IconRendererProvider } from './context/IconRenderer';
|
|
|
4
4
|
export { LikeC4Diagram } from './LikeC4Diagram';
|
|
5
5
|
export type { LikeC4DiagramProps } from './LikeC4Diagram';
|
|
6
6
|
export { Overlay } from './overlays/overlay/Overlay';
|
|
7
|
-
export { useLikeC4ElementsTree, useLikeC4Model, } from './likec4model';
|
|
8
7
|
export { LikeC4ModelProvider } from './LikeC4ModelProvider';
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
11
|
-
export type { ChangeEvent, DiagramNodeWithNavigate, ElementIconRenderer, LikeC4ColorScheme, LikeC4DiagramEventHandlers, LikeC4DiagramProperties, OnCanvasClick, OnChange, OnEdgeClick, OnNavigateTo, OnNodeClick, OpenSourceParams, WhereOperator, } from './LikeC4Diagram.props';
|
|
8
|
+
export * from './custom/hooks';
|
|
9
|
+
export type { ChangeEvent, CustomNodes, DiagramNodeWithNavigate, ElementIconRenderer, LikeC4ColorScheme, LikeC4DiagramEventHandlers, LikeC4DiagramProperties, OnCanvasClick, OnChange, OnEdgeClick, OnNavigateTo, OnNodeClick, OpenSourceParams, PaddingUnit, PaddingWithUnit, WhereOperator, } from './LikeC4Diagram.props';
|
|
12
10
|
export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
|
|
13
11
|
export type { StaticLikeC4DiagramProps } from './StaticLikeC4Diagram';
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,13 @@ export { IconRendererProvider } from './context/IconRenderer.js';
|
|
|
3
3
|
export { LikeC4Diagram } from './LikeC4Diagram.js';
|
|
4
4
|
export { Overlay } from './overlays/overlay/Overlay.js';
|
|
5
5
|
export { LikeC4ModelProvider } from './LikeC4ModelProvider.js';
|
|
6
|
-
export { useSetState } from './hooks/useSetState.js';
|
|
7
|
-
export { useUpdateEffect } from './hooks/useUpdateEffect.js';
|
|
8
6
|
export { StaticLikeC4Diagram } from './StaticLikeC4Diagram.js';
|
|
9
|
-
export {
|
|
7
|
+
export { useDiagramEventHandlers } from './context/DiagramEventHandlers.js';
|
|
8
|
+
export { useEnabledFeatures } from './context/DiagramFeatures.js';
|
|
9
|
+
export { useCurrentViewId } from './hooks/useCurrentViewId.js';
|
|
10
|
+
export { useDiagram, useDiagramContext } from './hooks/useDiagram.js';
|
|
11
|
+
export { useXYFlow, useXYInternalNode, useXYStore, useXYStoreApi } from './hooks/useXYFlow.js';
|
|
10
12
|
export { useLikeC4Model } from './likec4model/useLikeC4Model.js';
|
|
13
|
+
export { useMantinePortalProps } from './hooks/useMantinePortalProps.js';
|
|
14
|
+
export { useSetState } from './hooks/useSetState.js';
|
|
15
|
+
export { useUpdateEffect } from './hooks/useUpdateEffect.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { memo } from 'react';
|
|
3
3
|
import { useOverlaysActorRef } from '../hooks/useOverlaysActor.js';
|
|
4
4
|
import { Overlays } from '../overlays/Overlays.js';
|
|
5
5
|
import { useEnabledFeatures } from '../context/DiagramFeatures.js';
|
|
@@ -8,7 +8,7 @@ import { DiagramTitlePanel } from './ui/diagram-title/DiagramTitlePanel.js';
|
|
|
8
8
|
import { NotationPanel } from './ui/notation/NotationPanel.js';
|
|
9
9
|
import { DynamicViewWalkthrough } from './ui/walkthrough/DynamicViewWalkthrough.js';
|
|
10
10
|
|
|
11
|
-
const DiagramUI =
|
|
11
|
+
const DiagramUI = memo(() => {
|
|
12
12
|
const {
|
|
13
13
|
enableViewTitle,
|
|
14
14
|
enableNotations,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PropsWithChildren, NamedExoticComponent } from 'react';
|
|
2
2
|
import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
|
|
3
|
-
export type LikeC4DiagramXYFlowProps = PropsWithChildren<Pick<LikeC4DiagramProperties, 'background' | 'nodesDraggable' | 'nodesSelectable' | 'reactFlowProps'>>;
|
|
3
|
+
export type LikeC4DiagramXYFlowProps = PropsWithChildren<Pick<LikeC4DiagramProperties, 'background' | 'nodesDraggable' | 'nodesSelectable' | 'reactFlowProps' | 'renderNodes'>>;
|
|
4
4
|
export declare const LikeC4DiagramXYFlow: NamedExoticComponent<LikeC4DiagramXYFlowProps>;
|
|
@@ -2,15 +2,17 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { nonNullable } from '@likec4/core';
|
|
3
3
|
import { cx } from '@likec4/styles/css';
|
|
4
4
|
import { useTimeout, useDebouncedCallback, useCallbackRef } from '@mantine/hooks';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useCustomCompareMemo } from '@react-hookz/web';
|
|
6
|
+
import { shallowEqual, deepEqual } from 'fast-equals';
|
|
7
|
+
import { memo } from 'react';
|
|
7
8
|
import { BaseXYFlow } from '../base/BaseXYFlow.js';
|
|
8
9
|
import { useIsReducedGraphics, usePanningAtom } from '../context/ReduceGraphics.js';
|
|
9
10
|
import { useDiagram, useDiagramContext } from '../hooks/useDiagram.js';
|
|
10
|
-
import {
|
|
11
|
+
import { BuiltinNodes, edgeTypes } from './custom/index.js';
|
|
11
12
|
import { DiagramUI } from './DiagramUI.js';
|
|
12
13
|
import { useLayoutConstraints } from './useLayoutConstraints.js';
|
|
13
14
|
import { useDiagramEventHandlers } from '../context/DiagramEventHandlers.js';
|
|
15
|
+
import { useUpdateEffect } from '../hooks/useUpdateEffect.js';
|
|
14
16
|
|
|
15
17
|
const selectXYProps = (ctx) => ({
|
|
16
18
|
initialized: ctx.initialized.xydata && ctx.initialized.xyflow,
|
|
@@ -30,13 +32,14 @@ const selectXYProps = (ctx) => ({
|
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
const equalsXYProps = (a, b) => a.initialized === b.initialized && a.pannable === b.pannable && a.zoomable === b.zoomable && a.fitViewPadding === b.fitViewPadding && a.enableFitView === b.enableFitView && a.enableReadOnly === b.enableReadOnly && shallowEqual(a.nodes, b.nodes) && shallowEqual(a.edges, b.edges) && shallowEqual(a.viewport ?? null, b.viewport ?? null);
|
|
33
|
-
const compareProps = (a, b) => a.nodesDraggable
|
|
34
|
-
const LikeC4DiagramXYFlow =
|
|
35
|
+
const compareProps = (a, b) => a.nodesDraggable == b.nodesDraggable && a.nodesSelectable == b.nodesSelectable && a.children == b.children && deepEqual(a.background, b.background) && deepEqual(a.reactFlowProps ?? {}, b.reactFlowProps ?? {}) && shallowEqual(a.renderNodes ?? {}, b.renderNodes ?? {});
|
|
36
|
+
const LikeC4DiagramXYFlow = memo(({
|
|
35
37
|
background = "dots",
|
|
36
38
|
nodesDraggable = false,
|
|
37
39
|
nodesSelectable = false,
|
|
38
40
|
reactFlowProps = {},
|
|
39
|
-
children
|
|
41
|
+
children,
|
|
42
|
+
renderNodes
|
|
40
43
|
}) => {
|
|
41
44
|
const diagram = useDiagram();
|
|
42
45
|
const {
|
|
@@ -78,7 +81,22 @@ const LikeC4DiagramXYFlow = reactExports.memo(({
|
|
|
78
81
|
diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
|
|
79
82
|
}), onViewportResize = useCallbackRef(() => {
|
|
80
83
|
diagram.send({ type: "xyflow.resized" });
|
|
81
|
-
})
|
|
84
|
+
}), nodeTypes = useCustomCompareMemo(
|
|
85
|
+
() => {
|
|
86
|
+
return {
|
|
87
|
+
element: renderNodes?.element ?? BuiltinNodes.element,
|
|
88
|
+
deployment: renderNodes?.deployment ?? BuiltinNodes.deployment,
|
|
89
|
+
"compound-element": renderNodes?.compoundElement ?? BuiltinNodes["compound-element"],
|
|
90
|
+
"compound-deployment": renderNodes?.compoundDeployment ?? BuiltinNodes["compound-deployment"],
|
|
91
|
+
"view-group": renderNodes?.viewGroup ?? BuiltinNodes["view-group"]
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
[renderNodes],
|
|
95
|
+
shallowEqual
|
|
96
|
+
);
|
|
97
|
+
useUpdateEffect(() => {
|
|
98
|
+
console.warn("renderNodes changed - this might degrade performance");
|
|
99
|
+
}, [renderNodes]);
|
|
82
100
|
return /* @__PURE__ */ jsxs(
|
|
83
101
|
BaseXYFlow,
|
|
84
102
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Popover, PopoverTarget, PopoverDropdown, Stack, ScrollAreaAutosize, Text, CloseButton, Group, Button } from '@mantine/core';
|
|
3
3
|
import { useDebouncedEffect } from '@react-hookz/web';
|
|
4
|
-
import {
|
|
4
|
+
import { useState } from 'react';
|
|
5
5
|
import { isTruthy, isNonNull } from 'remeda';
|
|
6
6
|
import { useDiagramContext, useDiagram } from '../../../hooks/useDiagram.js';
|
|
7
7
|
import { edgeNoteText, edgeNoteCloseButton } from './NotePopover.css.js';
|
|
@@ -21,7 +21,7 @@ const NotePopover = ({ notes, children }) => {
|
|
|
21
21
|
hasPrevious: s.xyedges.findIndex((e) => e.id === s.activeWalkthrough?.stepId) > 0
|
|
22
22
|
}));
|
|
23
23
|
const diagram = useDiagram();
|
|
24
|
-
const [isOpened, setIsOpened] =
|
|
24
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
25
25
|
const portalProps = useMantinePortalProps();
|
|
26
26
|
useDebouncedEffect(
|
|
27
27
|
() => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { EdgeId, NonEmptyArray, Point, Color,
|
|
1
|
+
import { EdgeId, NonEmptyArray, Point, Color, RelationshipLineType, RelationshipArrowType, BBox, ViewId } from '@likec4/core';
|
|
2
2
|
import { XYPosition } from '@xyflow/react';
|
|
3
|
-
import {
|
|
3
|
+
import { FunctionComponent, CSSProperties, ReactNode } from 'react';
|
|
4
4
|
import { Position } from '@xyflow/system';
|
|
5
|
-
export declare const RelationshipEdge:
|
|
5
|
+
export declare const RelationshipEdge: FunctionComponent<{
|
|
6
6
|
id: string;
|
|
7
7
|
selected?: boolean;
|
|
8
8
|
selectable?: boolean;
|
|
9
9
|
deletable?: boolean;
|
|
10
10
|
style?: CSSProperties;
|
|
11
|
+
animated?: boolean;
|
|
11
12
|
source: string;
|
|
12
13
|
target: string;
|
|
13
|
-
animated?: boolean;
|
|
14
14
|
sourceX: number;
|
|
15
15
|
sourceY: number;
|
|
16
16
|
targetX: number;
|
|
@@ -29,27 +29,23 @@ export declare const RelationshipEdge: NamedExoticComponent<{
|
|
|
29
29
|
markerEnd?: string;
|
|
30
30
|
pathOptions?: any;
|
|
31
31
|
interactionWidth?: number;
|
|
32
|
-
data: {
|
|
32
|
+
data: import("../../../base").Base.EdgeData & {
|
|
33
33
|
hovered?: boolean;
|
|
34
34
|
active?: boolean;
|
|
35
35
|
dimmed?: import("../../../base").Base.Dimmed;
|
|
36
|
-
} & {
|
|
37
36
|
id: EdgeId;
|
|
38
37
|
label: string | null;
|
|
39
38
|
points: NonEmptyArray<Point>;
|
|
40
|
-
technology: string | undefined;
|
|
41
39
|
color: Color | undefined;
|
|
42
|
-
labelBBox: BBox | null | undefined;
|
|
43
|
-
dir: "forward" | "back" | "both" | undefined;
|
|
44
40
|
line: RelationshipLineType | undefined;
|
|
45
|
-
|
|
41
|
+
dir: "forward" | "back" | "both" | undefined;
|
|
46
42
|
tail: RelationshipArrowType | undefined;
|
|
43
|
+
head: RelationshipArrowType | undefined;
|
|
44
|
+
technology: string | undefined;
|
|
45
|
+
labelBBox: BBox | null | undefined;
|
|
47
46
|
navigateTo: ViewId<string> | undefined;
|
|
48
47
|
notes: string | undefined;
|
|
49
48
|
labelXY: XYPosition | null;
|
|
50
49
|
controlPoints: XYPosition[] | undefined | null;
|
|
51
|
-
hovered?: boolean;
|
|
52
|
-
active?: boolean;
|
|
53
|
-
dimmed?: import("../../../base").Base.Dimmed;
|
|
54
50
|
};
|
|
55
51
|
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { nonNullable } from '@likec4/core';
|
|
3
|
+
import { cx } from '@likec4/styles/css';
|
|
3
4
|
import { useDebouncedEffect } from '@react-hookz/web';
|
|
4
5
|
import { EdgeLabelRenderer } from '@xyflow/react';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
6
|
import { line, curveCatmullRomOpen } from 'd3-shape';
|
|
7
|
-
import {
|
|
7
|
+
import { useState, useRef, useEffect } from 'react';
|
|
8
8
|
import { isTruthy, first, last } from 'remeda';
|
|
9
9
|
import { ZIndexes } from '../../../base/const.js';
|
|
10
10
|
import { useEnabledFeatures } from '../../../context/DiagramFeatures.js';
|
|
@@ -28,7 +28,7 @@ const curve = line().curve(curveCatmullRomOpen).x((d) => d.x).y((d) => d.y);
|
|
|
28
28
|
const selectActiveStepId = (s) => s.context.activeWalkthrough?.stepId ?? null;
|
|
29
29
|
const RelationshipEdge = customEdge((props) => {
|
|
30
30
|
const isPanning = useIsPanning();
|
|
31
|
-
const [isControlPointDragging, setIsControlPointDragging] =
|
|
31
|
+
const [isControlPointDragging, setIsControlPointDragging] = useState(false);
|
|
32
32
|
const xyflowStore = useXYStoreApi();
|
|
33
33
|
const xyflow = useXYFlow();
|
|
34
34
|
const diagram = useDiagram();
|
|
@@ -83,12 +83,12 @@ const RelationshipEdge = customEdge((props) => {
|
|
|
83
83
|
edgePath = bezierPath(points);
|
|
84
84
|
}
|
|
85
85
|
let labelX = labelBBox?.x ?? 0, labelY = labelBBox?.y ?? 0;
|
|
86
|
-
const [labelPos, setLabelPos] =
|
|
86
|
+
const [labelPos, setLabelPos] = useState({
|
|
87
87
|
x: labelXY?.x ?? labelX,
|
|
88
88
|
y: labelXY?.y ?? labelY
|
|
89
89
|
});
|
|
90
|
-
const svgPathRef =
|
|
91
|
-
|
|
90
|
+
const svgPathRef = useRef(null);
|
|
91
|
+
useEffect(() => {
|
|
92
92
|
const path = svgPathRef.current;
|
|
93
93
|
if (!path) return;
|
|
94
94
|
const dompoint = path.getPointAtLength(path.getTotalLength() * 0.5);
|
|
@@ -264,7 +264,7 @@ const RelationshipEdge = customEdge((props) => {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
267
|
-
/* @__PURE__ */ jsxs(EdgeContainer, { ...props, className:
|
|
267
|
+
/* @__PURE__ */ jsxs(EdgeContainer, { ...props, className: cx(isControlPointDragging && controlDragging), children: [
|
|
268
268
|
/* @__PURE__ */ jsx(
|
|
269
269
|
EdgePath,
|
|
270
270
|
{
|
|
@@ -310,7 +310,7 @@ const RelationshipEdge = customEdge((props) => {
|
|
|
310
310
|
"circle",
|
|
311
311
|
{
|
|
312
312
|
onPointerDown: (e) => onControlPointerDown(i, e),
|
|
313
|
-
className:
|
|
313
|
+
className: cx("nodrag nopan", controlPoint),
|
|
314
314
|
cx: Math.round(p.x),
|
|
315
315
|
cy: Math.round(p.y),
|
|
316
316
|
r: 3
|