@likec4/diagram 1.31.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{chunk-BBzMXzCg.js → chunk-BvTQaUYl.js} +1675 -1207
- package/bundle/custom.js +50 -47
- package/bundle/index.js +2482 -2438
- 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 +28 -22
- 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 +8 -6
- package/dist/bundle/LikeC4View.props.d.ts +15 -4
- package/dist/bundle/ReactLikeC4.d.ts +4 -7
- package/dist/bundle/ReactLikeC4.js +3 -2
- 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 +27 -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 +104 -107
- 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 +3 -3
- 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/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Model.d.ts +22 -10
- package/dist/likec4model/useLikeC4Model.js +11 -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 +36 -25
- 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 +5 -0
- package/dist/search/Search.js +192 -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 +21 -19
- 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 +116 -0
- package/dist/search/components/SearchInput.d.ts +2 -0
- package/dist/{likec4diagram/ui/search → search/components}/SearchInput.js +53 -34
- package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.d.ts +3 -2
- package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.js +14 -13
- 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/{likec4diagram/ui/search → search/components}/utils.d.ts +1 -0
- package/dist/{likec4diagram/ui/search → search/components}/utils.js +7 -1
- package/dist/search/hooks.d.ts +16 -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 +430 -176
- package/dist/state/diagram-machine.js +119 -54
- 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 +18 -18
- package/panda.buildinfo.json +171 -148
- package/src/LikeC4CustomColors.tsx +21 -6
- package/src/LikeC4Diagram.props.ts +35 -30
- 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 +17 -19
- package/src/bundle/ReactLikeC4.tsx +14 -26
- 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 +24 -14
- package/src/custom/hooks.ts +1 -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 +115 -118
- 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/useLikeC4ElementsTree.ts +1 -1
- package/src/likec4model/useLikeC4Model.ts +18 -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 +43 -26
- 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 +237 -0
- package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.css.ts +0 -29
- package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.tsx +24 -22
- package/src/search/components/PickView.tsx +140 -0
- package/src/search/components/SearchByTags.tsx +109 -0
- package/src/{likec4diagram/ui/search → search/components}/SearchInput.tsx +63 -36
- package/src/{likec4diagram/ui/search → search/components}/ViewsColum.tsx +17 -18
- 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/{likec4diagram/ui/search → search/components}/utils.ts +7 -0
- package/src/search/hooks.ts +41 -0
- package/src/search/searchActor.ts +99 -0
- package/src/state/DiagramActorProvider.tsx +36 -25
- package/src/state/assign.ts +10 -10
- package/src/state/diagram-machine.ts +115 -52
- 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/src/likec4diagram/ui/search/LikeC4Search.tsx +0 -301
- package/src/likec4diagram/ui/search/state.ts +0 -78
- /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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { focusable } from './_shared.css.js';
|
|
2
|
+
|
|
1
3
|
function stopAndPrevent(e) {
|
|
2
4
|
e.stopPropagation();
|
|
3
5
|
e.preventDefault();
|
|
@@ -16,5 +18,9 @@ function moveFocusToSearchInput() {
|
|
|
16
18
|
input.setSelectionRange(length, length);
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
function focusToFirstFoundElement() {
|
|
22
|
+
let firstFoundElement = document.querySelector(`[data-likec4-search] .${focusable}`);
|
|
23
|
+
firstFoundElement?.focus();
|
|
24
|
+
}
|
|
19
25
|
|
|
20
|
-
export { centerY, moveFocusToSearchInput, stopAndPrevent };
|
|
26
|
+
export { centerY, focusToFirstFoundElement, moveFocusToSearchInput, stopAndPrevent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SearchActorRef } from './searchActor';
|
|
2
|
+
import { Fqn } from '@likec4/core';
|
|
3
|
+
export declare const SearchActorContext: ({ children, value }: {
|
|
4
|
+
value: {
|
|
5
|
+
searchActorRef: SearchActorRef;
|
|
6
|
+
close: (cb?: () => void) => void;
|
|
7
|
+
};
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element, useSearchActor: () => {
|
|
10
|
+
searchActorRef: SearchActorRef;
|
|
11
|
+
close: (cb?: () => void) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function useSearch(): [string, (search: string) => void];
|
|
14
|
+
export declare function useNormalizedSearch(): string;
|
|
15
|
+
export declare function useUpdateSearch(): (search: string) => void;
|
|
16
|
+
export declare function usePickViewFor(): Fqn | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createSafeContext } from '@mantine/core';
|
|
2
|
+
import { useSelector } from '@xstate/react';
|
|
3
|
+
import { useCallback, useDeferredValue } from 'react';
|
|
4
|
+
|
|
5
|
+
const [SearchActorContext, useSearchActor] = createSafeContext("SearchActorContext");
|
|
6
|
+
const selectSearchValue = (s) => s.context.searchValue;
|
|
7
|
+
function useSearch() {
|
|
8
|
+
const { searchActorRef } = useSearchActor();
|
|
9
|
+
const searchValue = useSelector(searchActorRef, selectSearchValue);
|
|
10
|
+
const updateSearch = useCallback((search) => {
|
|
11
|
+
searchActorRef.send({ type: "change.search", search });
|
|
12
|
+
}, [searchActorRef]);
|
|
13
|
+
return [searchValue, updateSearch];
|
|
14
|
+
}
|
|
15
|
+
const selectNormalizedSearchValue = (s) => {
|
|
16
|
+
const v = s.context.searchValue.trim().toLowerCase();
|
|
17
|
+
return v.length > 1 ? v : "";
|
|
18
|
+
};
|
|
19
|
+
function useNormalizedSearch() {
|
|
20
|
+
const { searchActorRef } = useSearchActor();
|
|
21
|
+
return useDeferredValue(useSelector(searchActorRef, selectNormalizedSearchValue));
|
|
22
|
+
}
|
|
23
|
+
function useUpdateSearch() {
|
|
24
|
+
const { searchActorRef } = useSearchActor();
|
|
25
|
+
return useCallback((search) => {
|
|
26
|
+
searchActorRef.send({ type: "change.search", search });
|
|
27
|
+
}, [searchActorRef]);
|
|
28
|
+
}
|
|
29
|
+
const selectPickViewFor = (s) => s.context.pickViewFor;
|
|
30
|
+
function usePickViewFor() {
|
|
31
|
+
const { searchActorRef } = useSearchActor();
|
|
32
|
+
return useSelector(searchActorRef, selectPickViewFor);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { SearchActorContext, useNormalizedSearch, usePickViewFor, useSearch, useSearchActor, useUpdateSearch };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Fqn } from '@likec4/core/types';
|
|
2
|
+
import { ActorLogicFrom, ActorRefFrom, SnapshotFrom, StateMachine, Values, NonReducibleUnknown, EventObject, MetaObject, ActionFunction } from 'xstate';
|
|
3
|
+
export type SearchActorEvent = {
|
|
4
|
+
type: 'open';
|
|
5
|
+
search?: string | undefined;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'close';
|
|
8
|
+
} | {
|
|
9
|
+
type: 'change.search';
|
|
10
|
+
search: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'pickview.open';
|
|
13
|
+
elementFqn: Fqn;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'pickview.close';
|
|
16
|
+
};
|
|
17
|
+
export interface SearchContext {
|
|
18
|
+
openedWithSearch: string | null;
|
|
19
|
+
searchValue: string;
|
|
20
|
+
pickViewFor: Fqn | null;
|
|
21
|
+
}
|
|
22
|
+
declare const _searchActorLogic: StateMachine<SearchContext, SearchActorEvent, {}, never, Values<{
|
|
23
|
+
"change searchValue": {
|
|
24
|
+
type: "change searchValue";
|
|
25
|
+
params: NonReducibleUnknown;
|
|
26
|
+
};
|
|
27
|
+
"reset pickViewFor": {
|
|
28
|
+
type: "reset pickViewFor";
|
|
29
|
+
params: NonReducibleUnknown;
|
|
30
|
+
};
|
|
31
|
+
}>, never, never, "inactive" | "opened" | "pickView", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
|
|
32
|
+
readonly id: "search";
|
|
33
|
+
readonly context: {
|
|
34
|
+
readonly openedWithSearch: null;
|
|
35
|
+
readonly searchValue: "";
|
|
36
|
+
readonly pickViewFor: null;
|
|
37
|
+
};
|
|
38
|
+
readonly initial: "inactive";
|
|
39
|
+
readonly on: {
|
|
40
|
+
readonly close: {
|
|
41
|
+
readonly target: ".inactive";
|
|
42
|
+
readonly actions: "reset pickViewFor";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly states: {
|
|
46
|
+
readonly inactive: {
|
|
47
|
+
readonly on: {
|
|
48
|
+
readonly open: {
|
|
49
|
+
readonly target: "opened";
|
|
50
|
+
readonly actions: readonly [ ActionFunction<SearchContext, {
|
|
51
|
+
type: "open";
|
|
52
|
+
search?: string | undefined;
|
|
53
|
+
}, SearchActorEvent, undefined, never, never, never, never, never>];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
readonly opened: {
|
|
58
|
+
readonly on: {
|
|
59
|
+
readonly open: {
|
|
60
|
+
readonly actions: "change searchValue";
|
|
61
|
+
};
|
|
62
|
+
readonly 'change.search': {
|
|
63
|
+
readonly actions: "change searchValue";
|
|
64
|
+
};
|
|
65
|
+
readonly 'pickview.open': {
|
|
66
|
+
readonly target: "pickView";
|
|
67
|
+
readonly actions: ActionFunction<SearchContext, {
|
|
68
|
+
type: "pickview.open";
|
|
69
|
+
elementFqn: Fqn;
|
|
70
|
+
}, SearchActorEvent, undefined, never, never, never, never, never>;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
readonly pickView: {
|
|
75
|
+
readonly on: {
|
|
76
|
+
readonly 'pickview.close': {
|
|
77
|
+
readonly target: "opened";
|
|
78
|
+
readonly actions: "reset pickViewFor";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
export interface SearchActorLogic extends ActorLogicFrom<typeof _searchActorLogic> {
|
|
85
|
+
}
|
|
86
|
+
export declare const searchActorLogic: SearchActorLogic;
|
|
87
|
+
export type SearchActorSnapshot = SnapshotFrom<SearchActorLogic>;
|
|
88
|
+
export interface SearchActorRef extends ActorRefFrom<SearchActorLogic> {
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { setup, assign, assertEvent } from 'xstate';
|
|
2
|
+
|
|
3
|
+
const _searchActorLogic = setup({
|
|
4
|
+
types: {
|
|
5
|
+
context: {},
|
|
6
|
+
events: {}
|
|
7
|
+
},
|
|
8
|
+
actions: {
|
|
9
|
+
"change searchValue": assign({
|
|
10
|
+
searchValue: ({ event, context }) => {
|
|
11
|
+
assertEvent(event, ["change.search", "open"]);
|
|
12
|
+
return event.search ?? context.searchValue;
|
|
13
|
+
}
|
|
14
|
+
}),
|
|
15
|
+
"reset pickViewFor": assign({
|
|
16
|
+
pickViewFor: () => null
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}).createMachine({
|
|
20
|
+
id: "search",
|
|
21
|
+
context: {
|
|
22
|
+
openedWithSearch: null,
|
|
23
|
+
searchValue: "",
|
|
24
|
+
pickViewFor: null
|
|
25
|
+
},
|
|
26
|
+
initial: "inactive",
|
|
27
|
+
on: {
|
|
28
|
+
"close": {
|
|
29
|
+
target: ".inactive",
|
|
30
|
+
actions: "reset pickViewFor"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
states: {
|
|
34
|
+
inactive: {
|
|
35
|
+
on: {
|
|
36
|
+
"open": {
|
|
37
|
+
target: "opened",
|
|
38
|
+
actions: [
|
|
39
|
+
assign({
|
|
40
|
+
openedWithSearch: ({ event }) => event.search ?? null,
|
|
41
|
+
searchValue: ({ event, context }) => event.search ?? context.searchValue
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
opened: {
|
|
48
|
+
on: {
|
|
49
|
+
"open": {
|
|
50
|
+
actions: "change searchValue"
|
|
51
|
+
},
|
|
52
|
+
"change.search": {
|
|
53
|
+
actions: "change searchValue"
|
|
54
|
+
},
|
|
55
|
+
"pickview.open": {
|
|
56
|
+
target: "pickView",
|
|
57
|
+
actions: assign({
|
|
58
|
+
pickViewFor: ({ event }) => event.elementFqn
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
pickView: {
|
|
64
|
+
on: {
|
|
65
|
+
"pickview.close": {
|
|
66
|
+
target: "opened",
|
|
67
|
+
actions: "reset pickViewFor"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const searchActorLogic = _searchActorLogic;
|
|
74
|
+
|
|
75
|
+
export { searchActorLogic };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { WhereOperator } from '@likec4/core';
|
|
1
|
+
import { DiagramView, WhereOperator } from '@likec4/core/types';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { PaddingWithUnit } from '../LikeC4Diagram.props';
|
|
4
|
+
export declare function DiagramActorProvider({ view, zoomable, pannable, fitViewPadding, nodesSelectable, where, children, }: PropsWithChildren<{
|
|
5
|
+
view: DiagramView;
|
|
6
|
+
zoomable: boolean;
|
|
7
|
+
pannable: boolean;
|
|
8
|
+
fitViewPadding: PaddingWithUnit;
|
|
9
|
+
nodesSelectable: boolean;
|
|
10
|
+
where: WhereOperator | null;
|
|
8
11
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useDeepCompareEffect } from '@react-hookz/web';
|
|
3
2
|
import { useActorRef, useSelector } from '@xstate/react';
|
|
4
3
|
import { useStoreApi } from '@xyflow/react';
|
|
5
4
|
import { shallowEqual } from 'fast-equals';
|
|
6
|
-
import { useEffect } from 'react';
|
|
5
|
+
import { useRef, useEffect } from 'react';
|
|
7
6
|
import { useDiagramEventHandlersRef } from '../context/DiagramEventHandlers.js';
|
|
8
7
|
import { useEnabledFeatures, DiagramFeatures } from '../context/DiagramFeatures.js';
|
|
9
8
|
import { DiagramActorContextProvider } from '../hooks/safeContext.js';
|
|
10
|
-
import { useUpdateEffect } from '../hooks/useUpdateEffect.js';
|
|
11
9
|
import { useViewToNodesEdges } from '../likec4diagram/useViewToNodesEdges.js';
|
|
12
10
|
import { diagramMachine } from './diagram-machine.js';
|
|
13
11
|
import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
|
|
14
12
|
|
|
15
13
|
const selectToggledFeatures = (state) => state.context.toggledFeatures;
|
|
16
14
|
function DiagramActorProvider({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
view,
|
|
16
|
+
zoomable,
|
|
17
|
+
pannable,
|
|
18
|
+
fitViewPadding,
|
|
19
|
+
nodesSelectable,
|
|
21
20
|
where,
|
|
22
21
|
children
|
|
23
22
|
}) {
|
|
24
23
|
const handlersRef = useDiagramEventHandlersRef();
|
|
25
24
|
const xystore = useStoreApi();
|
|
26
|
-
const
|
|
27
|
-
|
|
25
|
+
const machineRef = useRef(null);
|
|
26
|
+
if (!machineRef.current) {
|
|
27
|
+
machineRef.current = diagramMachine.provide({
|
|
28
28
|
actions: {
|
|
29
29
|
"trigger:NavigateTo": (_, { viewId }) => {
|
|
30
30
|
setTimeout(() => {
|
|
31
31
|
handlersRef.current.onNavigateTo?.(viewId);
|
|
32
|
-
},
|
|
32
|
+
}, 30);
|
|
33
33
|
},
|
|
34
34
|
"trigger:OnChange": (_, params) => {
|
|
35
35
|
handlersRef.current.onChange?.(params);
|
|
@@ -47,31 +47,37 @@ function DiagramActorProvider({
|
|
|
47
47
|
}
|
|
48
48
|
})
|
|
49
49
|
}
|
|
50
|
-
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const actorRef = useActorRef(
|
|
53
|
+
machineRef.current,
|
|
51
54
|
{
|
|
52
|
-
id: `diagram
|
|
55
|
+
id: `diagram`,
|
|
53
56
|
systemId: "diagram",
|
|
54
57
|
// ...inspector,
|
|
55
58
|
input: {
|
|
56
59
|
xystore,
|
|
57
60
|
view,
|
|
58
|
-
|
|
61
|
+
zoomable,
|
|
62
|
+
pannable,
|
|
63
|
+
fitViewPadding,
|
|
64
|
+
nodesSelectable
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
);
|
|
62
68
|
const features = useEnabledFeatures();
|
|
63
|
-
useUpdateEffect(() => {
|
|
64
|
-
actorRef.send({ type: "update.inputs", inputs });
|
|
65
|
-
}, [inputs]);
|
|
66
69
|
useEffect(() => {
|
|
67
70
|
actorRef.send({ type: "update.features", features });
|
|
68
71
|
}, [features]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
actorRef.send({ type: "update.inputs", inputs: { zoomable, pannable, fitViewPadding, nodesSelectable } });
|
|
74
|
+
}, [zoomable, pannable, fitViewPadding, nodesSelectable]);
|
|
69
75
|
const { xyedges, xynodes } = useViewToNodesEdges({
|
|
70
76
|
view,
|
|
71
77
|
where,
|
|
72
|
-
nodesSelectable
|
|
78
|
+
nodesSelectable
|
|
73
79
|
});
|
|
74
|
-
|
|
80
|
+
useEffect(() => {
|
|
75
81
|
actorRef.send({ type: "update.view", view, xyedges, xynodes });
|
|
76
82
|
}, [view, xyedges, xynodes]);
|
|
77
83
|
const toggledFeatures = useSelector(actorRef, selectToggledFeatures, shallowEqual);
|
package/dist/state/assign.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare function lastClickedNode(params: {
|
|
|
8
8
|
}): DiagramContext['lastClickedNode'];
|
|
9
9
|
export declare function mergeXYNodesEdges({ context, event }: ActionArg): Partial<DiagramContext>;
|
|
10
10
|
export declare function focusNodesEdges(params: ActionArg): Partial<DiagramContext>;
|
|
11
|
-
export declare function unfocusNodesEdges({ context }: ActionArg): Partial<DiagramContext>;
|
|
12
11
|
export declare function updateNavigationHistory({ context, event }: ActionArg): Partial<DiagramContext>;
|
|
13
12
|
export declare function navigateBack({ context }: ActionArg): Partial<DiagramContext>;
|
|
14
13
|
export declare function navigateForward({ context }: ActionArg): Partial<DiagramContext>;
|
package/dist/state/assign.js
CHANGED
|
@@ -3,8 +3,8 @@ import { getNodeDimensions } from '@xyflow/system';
|
|
|
3
3
|
import { deepEqual } from 'fast-equals';
|
|
4
4
|
import { omit, mergeDeep, isEmpty } from 'remeda';
|
|
5
5
|
import { assertEvent } from 'xstate';
|
|
6
|
-
import { Base } from '../base/types.js';
|
|
7
6
|
import { VectorImpl, vector } from '../utils/vector.js';
|
|
7
|
+
import { setDimmed, setData } from '../base/types.Base.js';
|
|
8
8
|
|
|
9
9
|
function lastClickedNode(params) {
|
|
10
10
|
const { lastClickedNode: lastClickedNode2 } = params.context;
|
|
@@ -101,31 +101,21 @@ function focusNodesEdges(params) {
|
|
|
101
101
|
if (edge.source === focusedNode || edge.target === focusedNode) {
|
|
102
102
|
focused.add(edge.source);
|
|
103
103
|
focused.add(edge.target);
|
|
104
|
-
return
|
|
104
|
+
return setData(edge, {
|
|
105
105
|
dimmed: false,
|
|
106
106
|
active: true
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return setData(edge, {
|
|
110
110
|
dimmed: true,
|
|
111
111
|
active: false
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
return {
|
|
115
|
-
xynodes: _xynodes.map((n) =>
|
|
115
|
+
xynodes: _xynodes.map((n) => setDimmed(n, !focused.has(n.id))),
|
|
116
116
|
xyedges
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
function unfocusNodesEdges({ context }) {
|
|
120
|
-
const { xynodes, xyedges } = context;
|
|
121
|
-
return {
|
|
122
|
-
xynodes: xynodes.map(Base.setDimmed(false)),
|
|
123
|
-
xyedges: xyedges.map(Base.setData({
|
|
124
|
-
dimmed: false,
|
|
125
|
-
active: false
|
|
126
|
-
}))
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
119
|
function updateNavigationHistory({ context, event }) {
|
|
130
120
|
assertEvent(event, "update.view");
|
|
131
121
|
let {
|
|
@@ -296,8 +286,8 @@ function resetEdgeControlPoints({ context }) {
|
|
|
296
286
|
const loopSize = 80;
|
|
297
287
|
const centerOfTopBoundary = new VectorImpl(0, source.height || 0).mul(-0.5).add(sourceCenter);
|
|
298
288
|
return [
|
|
299
|
-
centerOfTopBoundary.add(new VectorImpl(-
|
|
300
|
-
centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -
|
|
289
|
+
centerOfTopBoundary.add(new VectorImpl(-loopSize / 2.5, -loopSize)),
|
|
290
|
+
centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -loopSize))
|
|
301
291
|
];
|
|
302
292
|
}
|
|
303
293
|
const sourceToTargetVector = targetCenter.sub(sourceCenter);
|
|
@@ -332,16 +322,16 @@ function updateActiveWalkthrough({ context }) {
|
|
|
332
322
|
return {
|
|
333
323
|
xyedges: context.xyedges.map((edge) => {
|
|
334
324
|
const active = stepId === edge.id || !!parallelPrefix && edge.id.startsWith(parallelPrefix);
|
|
335
|
-
return
|
|
325
|
+
return setData(edge, {
|
|
336
326
|
active,
|
|
337
327
|
dimmed: !active
|
|
338
328
|
});
|
|
339
329
|
}),
|
|
340
330
|
xynodes: context.xynodes.map((node) => {
|
|
341
331
|
const dimmed = step.source !== node.id && step.target !== node.id;
|
|
342
|
-
return
|
|
332
|
+
return setDimmed(node, dimmed);
|
|
343
333
|
})
|
|
344
334
|
};
|
|
345
335
|
}
|
|
346
336
|
|
|
347
|
-
export { focusNodesEdges, lastClickedNode, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints,
|
|
337
|
+
export { focusNodesEdges, lastClickedNode, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints, updateActiveWalkthrough, updateEdgeData, updateNavigationHistory, updateNodeData };
|