@likec4/diagram 1.56.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LikeC4Diagram.js +3 -1
- package/dist/LikeC4View.js +47 -55
- package/dist/adhoc-editor/EditorPanel.d.ts +1 -1
- package/dist/adhoc-editor/ElementsTree.d.ts +1 -1
- package/dist/adhoc-editor/ElementsTree.js +2 -6
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +1 -1
- package/dist/adhoc-editor/components/Tree.d.ts +5 -5
- package/dist/adhoc-editor/state/ActorProvider.d.ts +1 -1
- package/dist/adhoc-editor/state/panel.d.ts +1 -1
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +1 -1
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base-primitives/Markdown.d.ts +1 -1
- package/dist/base-primitives/NodeHandles.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundNodeContainer.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundTitle.d.ts +1 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeMarkers.d.ts +8 -8
- package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -1
- package/dist/base-primitives/element/ElementData.d.ts +2 -2
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +1 -1
- package/dist/base-primitives/element/ElementShape.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.js +1 -3
- package/dist/components/ErrorFallback.d.ts +2 -2
- package/dist/components/NavigationPanel.d.ts +2 -2
- package/dist/components/PortalToContainer.d.ts +1 -1
- package/dist/components/RootContainer.d.ts +1 -1
- package/dist/components/RootContainer.js +19 -18
- package/dist/components/SearchControl.d.ts +2 -2
- package/dist/components/ViewNotFound.d.ts +2 -2
- package/dist/context/CurrentViewModelProvider.d.ts +1 -1
- package/dist/context/DefaultMantineProvider.d.ts +1 -1
- package/dist/context/DiagramEventHandlers.d.ts +1 -1
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +5 -0
- package/dist/context/EnsureMantine.d.ts +1 -1
- package/dist/context/FramerMotionConfig.d.ts +3 -3
- package/dist/context/FramerMotionConfig.js +2 -2
- package/dist/context/IconRenderer.d.ts +2 -2
- package/dist/context/IconRenderer.js +32 -12
- package/dist/context/LikeC4ModelContext.d.ts +1 -1
- package/dist/context/RootContainerContext.d.ts +10 -17
- package/dist/context/RootContainerContext.js +1 -13
- package/dist/context/ShadowRootContext.d.ts +3 -0
- package/dist/context/ShadowRootContext.js +5 -0
- package/dist/context/TagStylesContext.d.ts +2 -1
- package/dist/context/TagStylesContext.js +5 -7
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +1 -2
- package/dist/editor/LikeC4EditorCallbacks.d.ts +5 -0
- package/dist/editor/LikeC4EditorProvider.d.ts +2 -2
- package/dist/editor/actor/actions.d.ts +174 -0
- package/dist/editor/actor/actions.js +188 -0
- package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +2 -2
- package/dist/editor/{hotkeyActor.js → actor/hotkey.js} +11 -4
- package/dist/editor/{editorActor.states.d.ts → actor/machine.d.ts} +5 -3
- package/dist/editor/actor/machine.js +23 -0
- package/dist/editor/actor/setup.d.ts +55 -0
- package/dist/editor/{editorActor.setup.js → actor/setup.js} +14 -10
- package/dist/editor/actor/state.editor.d.ts +147 -0
- package/dist/editor/actor/state.editor.js +56 -0
- package/dist/editor/actor/state.sync-queue.d.ts +612 -0
- package/dist/editor/actor/state.sync-queue.js +272 -0
- package/dist/editor/actor/types.d.ts +64 -0
- package/dist/editor/actor/types.js +5 -0
- package/dist/editor/applyChangesToManualLayout.js +1 -1
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/useEditorActorLogic.d.ts +8 -2
- package/dist/editor/useEditorActorLogic.js +39 -7
- package/dist/hooks/useDiagram.js +6 -1
- package/dist/hooks/useDiagramCompareLayout.js +1 -1
- package/dist/hooks/useEditorActor.d.ts +9 -0
- package/dist/hooks/useEditorActor.js +27 -0
- package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
- package/dist/hooks/useLikeC4ElementsTree.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/likec4diagram/DiagramUI.d.ts +1 -1
- package/dist/likec4diagram/DiagramUI.js +8 -4
- package/dist/likec4diagram/DiagramXYFlow.js +26 -14
- package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +127 -14
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +1 -0
- package/dist/likec4diagram/custom/edges/edges.css.js +5 -1
- package/dist/likec4diagram/custom/nodes/CompoundActions.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/NodeNotes.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +7 -7
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +3 -3
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -3
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +1 -1
- package/dist/likec4diagram/relationship-popover/components.d.ts +2 -2
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +1 -1
- package/dist/likec4diagram/state/aligners.js +3 -0
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +1 -0
- package/dist/likec4diagram/state/diagram-api.d.ts +16 -0
- package/dist/likec4diagram/state/diagram-api.js +13 -7
- package/dist/likec4diagram/state/machine.actions.js +10 -10
- package/dist/likec4diagram/state/machine.d.ts +1 -1
- package/dist/likec4diagram/state/machine.setup.js +1 -1
- package/dist/likec4diagram/state/types.d.ts +1 -1
- package/dist/likec4diagram/state/utils.d.ts +1 -1
- package/dist/likec4diagram/types.d.ts +2 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +1 -1
- package/dist/likec4diagram/ui/notation/NotationPanel.d.ts +1 -1
- package/dist/likec4diagram/useLayoutConstraints.js +2 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +4 -2
- package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +1 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelControls.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +2 -2
- package/dist/navigationpanel/_common.d.ts +2 -2
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/DriftsSummary.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +1 -1
- package/dist/navigationpanel/controls/DetailsControls.d.ts +1 -1
- package/dist/navigationpanel/controls/LayoutWarning.d.ts +1 -1
- package/dist/navigationpanel/controls/LogoButton.d.ts +1 -1
- package/dist/navigationpanel/controls/NavigationButtons.d.ts +1 -1
- package/dist/navigationpanel/controls/OpenSource.d.ts +1 -1
- package/dist/navigationpanel/controls/SearchControl.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.js +4 -2
- package/dist/navigationpanel/editorpanel/ApplySemanticLayout.d.ts +4 -0
- package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +36 -0
- package/dist/navigationpanel/editorpanel/CenterCamera.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.js +45 -33
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +62 -62
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -1
- package/dist/overlays/Overlays.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetails.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
- package/dist/overlays/element-details/MetadataValue.d.ts +2 -2
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelStructure.d.ts +2 -2
- package/dist/overlays/overlay/Overlay.d.ts +16 -0
- package/dist/overlays/overlay/Overlay.js +50 -52
- package/dist/overlays/overlaysActor.js +28 -27
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
- package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -5
- package/dist/overlays/relationship-details/custom/nodeTypes.js +25 -24
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/EmptyNode.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +4 -4
- package/dist/projects-overview/ProjectsOverview.d.ts +1 -1
- package/dist/projects-overview/custom/nodeTypes.d.ts +1 -1
- package/dist/projects-overview/panel/ProjectsOverviewPanel.d.ts +1 -1
- package/dist/search/Search.d.ts +6 -3
- package/dist/search/Search.js +60 -71
- package/dist/search/XStateSearchAdapter.d.ts +1 -1
- package/dist/search/components/ElementsColumn.d.ts +1 -1
- package/dist/search/components/ElementsColumn.js +12 -8
- package/dist/search/components/PickView.d.ts +1 -1
- package/dist/search/components/SearchByTags.d.ts +1 -1
- package/dist/search/components/SearchInput.d.ts +1 -1
- package/dist/search/components/ViewsColum.d.ts +3 -3
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/searchActor.js +30 -26
- package/dist/shadowroot/ShadowRoot.d.ts +6 -6
- package/dist/shadowroot/ShadowRoot.js +68 -23
- package/dist/shadowroot/index.d.ts +1 -0
- package/dist/shadowroot/styles.d.ts +13 -0
- package/dist/shadowroot/styles.js +60 -0
- package/dist/styles2.js +1 -1
- package/package.json +33 -40
- package/panda.buildinfo.json +19 -22
- package/src/styles-font.css +114 -0
- package/src/styles-min.css +2 -0
- package/src/styles-xyflow.css +1 -0
- package/src/styles.css +3 -0
- package/styles-min.css +1 -1
- package/styles-xyflow.css +1 -1
- package/styles.css +1 -1
- package/dist/bundle/index.d.ts +0 -1
- package/dist/editor/editorActor.actions.d.ts +0 -153
- package/dist/editor/editorActor.actions.js +0 -133
- package/dist/editor/editorActor.setup.d.ts +0 -84
- package/dist/editor/editorActor.states.js +0 -219
- package/dist/hooks/useOverlaysActor.js +0 -11
- package/dist/hooks/useSearchActor.js +0 -11
- package/dist/shadowroot/styles.css.d.ts +0 -4
- package/dist/shadowroot/styles.css.js +0 -62
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RelationshipsBrowserTypes as Types } from '../_types';
|
|
2
|
-
export declare const ElementActions: (props: Types.NodeProps<"element">) => import("react
|
|
2
|
+
export declare const ElementActions: (props: Types.NodeProps<"element">) => import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RelationshipsBrowserTypes } from '../_types';
|
|
2
|
-
export declare function EmptyNode({ data: { column, }, }: RelationshipsBrowserTypes.NodeProps<'empty'>): import("react
|
|
2
|
+
export declare function EmptyNode({ data: { column, }, }: RelationshipsBrowserTypes.NodeProps<'empty'>): import("react").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseNodePropsWithData } from '../../../base';
|
|
2
2
|
import { RelationshipsBrowserTypes } from '../_types';
|
|
3
|
-
export declare function ElementNode(props: RelationshipsBrowserTypes.NodeProps<'element'>): import("react
|
|
4
|
-
export declare function CompoundNode(props: RelationshipsBrowserTypes.NodeProps<'compound'>): import("react
|
|
3
|
+
export declare function ElementNode(props: RelationshipsBrowserTypes.NodeProps<'element'>): import("react").JSX.Element;
|
|
4
|
+
export declare function CompoundNode(props: RelationshipsBrowserTypes.NodeProps<'compound'>): import("react").JSX.Element;
|
|
5
5
|
type ElementPortsProps = BaseNodePropsWithData<Pick<RelationshipsBrowserTypes.ElementNodeData, 'ports' | 'height'>>;
|
|
6
|
-
export declare const ElementPorts: ({ data: { ports, height: h } }: ElementPortsProps) => import("react
|
|
6
|
+
export declare const ElementPorts: ({ data: { ports, height: h } }: ElementPortsProps) => import("react").JSX.Element;
|
|
7
7
|
type CompoundPortsProps = BaseNodePropsWithData<Pick<RelationshipsBrowserTypes.CompoundNodeData, 'ports'>>;
|
|
8
|
-
export declare const CompoundPorts: ({ data }: CompoundPortsProps) => import("react
|
|
8
|
+
export declare const CompoundPorts: ({ data }: CompoundPortsProps) => import("react").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -10,4 +10,4 @@ export type ProjectsOverviewProps = {
|
|
|
10
10
|
onNavigateToProject?: undefined | ((projectId: ProjectId) => void);
|
|
11
11
|
fitViewPadding?: ViewPadding | undefined;
|
|
12
12
|
} & ProjectsOverviewXYProps;
|
|
13
|
-
export declare function ProjectsOverview({ view, onNavigateToProject, fitViewPadding, ...props }: ProjectsOverviewProps): import("react
|
|
13
|
+
export declare function ProjectsOverview({ view, onNavigateToProject, fitViewPadding, ...props }: ProjectsOverviewProps): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ProjectsOverviewTypes } from '../_types';
|
|
2
|
-
export declare function ProjectNode(props: ProjectsOverviewTypes.NodeProps<'project'>): import("react
|
|
2
|
+
export declare function ProjectNode(props: ProjectsOverviewTypes.NodeProps<'project'>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ProjectsOverviewPanel: () => import("react
|
|
1
|
+
export declare const ProjectsOverviewPanel: () => import("react").JSX.Element;
|
package/dist/search/Search.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchActorRef } from './searchActor';
|
|
2
|
+
import { MemoExoticComponent, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
3
|
export declare const dialogCss: string;
|
|
3
4
|
export declare const bodyCss: string;
|
|
4
5
|
export declare const scrollAreaCss: string;
|
|
5
|
-
export declare const Search: MemoExoticComponent<(
|
|
6
|
+
export declare const Search: MemoExoticComponent<({ searchActorRef }: {
|
|
7
|
+
searchActorRef: SearchActorRef;
|
|
8
|
+
}) => import("react").JSX.Element>;
|
|
6
9
|
/**
|
|
7
10
|
* The shared search panel content used by both diagram and overview search.
|
|
8
11
|
* Must be rendered inside a SearchContext.Provider.
|
|
9
12
|
*/
|
|
10
|
-
export declare const SearchPanelContent:
|
|
13
|
+
export declare const SearchPanelContent: ForwardRefExoticComponent<RefAttributes<HTMLDivElement>>;
|
package/dist/search/Search.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useDiagram } from "../hooks/safeContext.js";
|
|
3
3
|
import { Overlay } from "../overlays/overlay/Overlay.js";
|
|
4
|
-
import { useSearchActorRef } from "../hooks/useSearchActor.js";
|
|
5
4
|
import { useSearchContext } from "./SearchContext.js";
|
|
6
5
|
import { focusToFirstFoundElement, moveFocusToSearchInput } from "./components/utils.js";
|
|
7
6
|
import { ViewsColumn } from "./components/ViewsColum.js";
|
|
@@ -11,16 +10,15 @@ import { SearchByTags } from "./components/SearchByTags.js";
|
|
|
11
10
|
import { LikeC4SearchInput } from "./components/SearchInput.js";
|
|
12
11
|
import { XStateSearchAdapter } from "./XStateSearchAdapter.js";
|
|
13
12
|
import { css } from "@likec4/styles/css";
|
|
14
|
-
import {
|
|
13
|
+
import { forwardRef, memo, useRef } from "react";
|
|
15
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
import { useTimeoutEffect } from "@react-hookz/web";
|
|
17
16
|
import { isTruthy } from "remeda";
|
|
18
17
|
import { Grid, GridCol, Group, ScrollArea, Title } from "@mantine/core";
|
|
19
|
-
import { AnimatePresence, LayoutGroup
|
|
18
|
+
import { AnimatePresence, LayoutGroup } from "motion/react";
|
|
20
19
|
import { useSelector } from "@xstate/react";
|
|
21
|
-
import { useHotkeys } from "@mantine/hooks";
|
|
20
|
+
import { useHotkeys, useMergedRef } from "@mantine/hooks";
|
|
22
21
|
import { Box as Box$1, VStack } from "@likec4/styles/jsx";
|
|
23
|
-
import { createEmptyActor } from "xstate";
|
|
24
22
|
//#region src/search/Search.tsx
|
|
25
23
|
var dialogCss = css({
|
|
26
24
|
backgroundColor: `[rgb(34 34 34 / var(--_opacity, 95%))]`,
|
|
@@ -61,52 +59,64 @@ var selectIsOpened = (s) => {
|
|
|
61
59
|
return false;
|
|
62
60
|
}
|
|
63
61
|
};
|
|
64
|
-
var Search = memo(() => {
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
backdrop: { opacity: .9 },
|
|
87
|
-
classes: {
|
|
88
|
-
dialog: dialogCss,
|
|
89
|
-
body: bodyCss
|
|
62
|
+
var Search = memo(({ searchActorRef }) => {
|
|
63
|
+
const diagram = useDiagram();
|
|
64
|
+
const isOpened = useSelector(searchActorRef, selectIsOpened);
|
|
65
|
+
const close = () => {
|
|
66
|
+
diagram.searchActor().send({ type: "close" });
|
|
67
|
+
};
|
|
68
|
+
const open = (event) => {
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
diagram.searchActor().send({ type: "open" });
|
|
71
|
+
};
|
|
72
|
+
useHotkeys(isOpened ? [] : [[
|
|
73
|
+
"mod+k",
|
|
74
|
+
open,
|
|
75
|
+
{ preventDefault: true }
|
|
76
|
+
], [
|
|
77
|
+
"mod+f",
|
|
78
|
+
open,
|
|
79
|
+
{ preventDefault: true }
|
|
80
|
+
]]);
|
|
81
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
82
|
+
onExitComplete: () => {
|
|
83
|
+
diagram.searchActor().send({ type: "animation.presence.end" });
|
|
90
84
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
children: isOpened && /* @__PURE__ */ jsx(Overlay, {
|
|
86
|
+
fullscreen: true,
|
|
87
|
+
withBackdrop: false,
|
|
88
|
+
backdrop: { opacity: .9 },
|
|
89
|
+
classes: {
|
|
90
|
+
dialog: dialogCss,
|
|
91
|
+
body: bodyCss
|
|
92
|
+
},
|
|
93
|
+
openDelay: 0,
|
|
94
|
+
onClose: close,
|
|
95
|
+
"data-likec4-search": "true",
|
|
96
|
+
children: /* @__PURE__ */ jsx(XStateSearchAdapter, {
|
|
97
|
+
searchActorRef,
|
|
98
|
+
children: /* @__PURE__ */ jsx(SearchOverlayBody, { searchActorRef })
|
|
99
|
+
})
|
|
97
100
|
})
|
|
98
|
-
})
|
|
101
|
+
});
|
|
99
102
|
});
|
|
100
103
|
Search.displayName = "Search";
|
|
104
|
+
function SearchOverlayBody({ searchActorRef }) {
|
|
105
|
+
const ref = useRef(null);
|
|
106
|
+
useTimeoutEffect(() => {
|
|
107
|
+
if (isTruthy(searchActorRef.getSnapshot().context.openedWithSearch)) focusToFirstFoundElement(ref.current);
|
|
108
|
+
}, 150);
|
|
109
|
+
return /* @__PURE__ */ jsx(SearchPanelContent, { ref });
|
|
110
|
+
}
|
|
101
111
|
/**
|
|
102
112
|
* The shared search panel content used by both diagram and overview search.
|
|
103
113
|
* Must be rendered inside a SearchContext.Provider.
|
|
104
114
|
*/
|
|
105
|
-
var SearchPanelContent =
|
|
106
|
-
const
|
|
115
|
+
var SearchPanelContent = forwardRef((_, ref) => {
|
|
116
|
+
const contentRef = useRef(null);
|
|
107
117
|
const { pickViewFor } = useSearchContext();
|
|
108
118
|
return /* @__PURE__ */ jsxs(Box$1, {
|
|
109
|
-
ref,
|
|
119
|
+
ref: useMergedRef(ref, contentRef),
|
|
110
120
|
display: "contents",
|
|
111
121
|
children: [
|
|
112
122
|
/* @__PURE__ */ jsx(Group, {
|
|
@@ -114,7 +124,7 @@ var SearchPanelContent = memo(() => {
|
|
|
114
124
|
wrap: "nowrap",
|
|
115
125
|
onClick: (e) => {
|
|
116
126
|
e.stopPropagation();
|
|
117
|
-
moveFocusToSearchInput(
|
|
127
|
+
moveFocusToSearchInput(contentRef.current);
|
|
118
128
|
},
|
|
119
129
|
children: /* @__PURE__ */ jsxs(VStack, {
|
|
120
130
|
flex: 1,
|
|
@@ -157,7 +167,11 @@ var SearchPanelContent = memo(() => {
|
|
|
157
167
|
scrollbars: "y",
|
|
158
168
|
children: /* @__PURE__ */ jsx(LayoutGroup, {
|
|
159
169
|
id: "likec4-search-elements",
|
|
160
|
-
children: /* @__PURE__ */ jsx(
|
|
170
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
171
|
+
mode: "popLayout",
|
|
172
|
+
anchorY: "top",
|
|
173
|
+
children: /* @__PURE__ */ jsx(ElementsColumn, {})
|
|
174
|
+
})
|
|
161
175
|
})
|
|
162
176
|
})
|
|
163
177
|
}), /* @__PURE__ */ jsx(GridCol, {
|
|
@@ -167,10 +181,10 @@ var SearchPanelContent = memo(() => {
|
|
|
167
181
|
className: scrollAreaCss,
|
|
168
182
|
pr: "xs",
|
|
169
183
|
scrollbars: "y",
|
|
170
|
-
children: /* @__PURE__ */ jsx(
|
|
184
|
+
children: /* @__PURE__ */ jsx(LayoutGroup, {
|
|
171
185
|
id: "likec4-search-views",
|
|
172
186
|
children: /* @__PURE__ */ jsx(ViewsColumn, {})
|
|
173
|
-
})
|
|
187
|
+
})
|
|
174
188
|
})
|
|
175
189
|
})]
|
|
176
190
|
}),
|
|
@@ -179,30 +193,5 @@ var SearchPanelContent = memo(() => {
|
|
|
179
193
|
});
|
|
180
194
|
});
|
|
181
195
|
SearchPanelContent.displayName = "SearchPanelContent";
|
|
182
|
-
var SearchOverlayBody = memo(function SearchOverlayBody({ searchActorRef }) {
|
|
183
|
-
const ref = useRef(null);
|
|
184
|
-
useTimeoutEffect(() => {
|
|
185
|
-
if (isTruthy(searchActorRef.getSnapshot().context.openedWithSearch)) focusToFirstFoundElement(ref.current);
|
|
186
|
-
}, 150);
|
|
187
|
-
const [isPresent, safeToRemove] = usePresence();
|
|
188
|
-
useEffect(() => {
|
|
189
|
-
if (isPresent) return;
|
|
190
|
-
safeToRemove();
|
|
191
|
-
try {
|
|
192
|
-
searchActorRef.send({ type: "animation.presence.end" });
|
|
193
|
-
} catch (e) {
|
|
194
|
-
console.debug("SearchOverlayBody: animation.presence.end failed", e);
|
|
195
|
-
}
|
|
196
|
-
}, [
|
|
197
|
-
isPresent,
|
|
198
|
-
searchActorRef,
|
|
199
|
-
safeToRemove
|
|
200
|
-
]);
|
|
201
|
-
return /* @__PURE__ */ jsx(Box$1, {
|
|
202
|
-
ref,
|
|
203
|
-
display: "contents",
|
|
204
|
-
children: /* @__PURE__ */ jsx(SearchPanelContent, {})
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
196
|
//#endregion
|
|
208
197
|
export { Search, SearchPanelContent, bodyCss, dialogCss };
|
|
@@ -2,4 +2,4 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { SearchActorRef } from './searchActor';
|
|
3
3
|
export declare function XStateSearchAdapter({ searchActorRef, children, }: PropsWithChildren<{
|
|
4
4
|
searchActorRef: SearchActorRef;
|
|
5
|
-
}>): import("react
|
|
5
|
+
}>): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MemoExoticComponent } from 'react';
|
|
2
|
-
export declare const ElementsColumn: MemoExoticComponent<() => import("react
|
|
2
|
+
export declare const ElementsColumn: MemoExoticComponent<() => import("react").JSX.Element>;
|
|
@@ -25,7 +25,8 @@ function useElementsColumnData() {
|
|
|
25
25
|
value: element.id,
|
|
26
26
|
element,
|
|
27
27
|
viewsCount: [...element.views()].length,
|
|
28
|
-
children: []
|
|
28
|
+
children: [],
|
|
29
|
+
hasChildren: false
|
|
29
30
|
})), toArray()), [model]);
|
|
30
31
|
const search = useNormalizedSearch();
|
|
31
32
|
return useMemo(() => {
|
|
@@ -61,10 +62,13 @@ function useElementsColumnData() {
|
|
|
61
62
|
const byid = {};
|
|
62
63
|
const { hash, all, roots } = pipe(elements, reduce((acc, treeItem) => {
|
|
63
64
|
treeItem.children = [];
|
|
65
|
+
treeItem.hasChildren = false;
|
|
64
66
|
byid[treeItem.value] = treeItem;
|
|
65
67
|
const parent = acc.all.findLast((root) => isAncestor(root.value, treeItem.value));
|
|
66
|
-
if (parent)
|
|
67
|
-
|
|
68
|
+
if (parent) {
|
|
69
|
+
parent.children.push(treeItem);
|
|
70
|
+
parent.hasChildren = true;
|
|
71
|
+
} else acc.roots.push(treeItem);
|
|
68
72
|
acc.all.push(treeItem);
|
|
69
73
|
acc.hash = stringHash(acc.hash + treeItem.value);
|
|
70
74
|
return acc;
|
|
@@ -111,7 +115,7 @@ function ElementsTree({ data: { searchTerms, all, byid, hash, roots }, handleCli
|
|
|
111
115
|
return;
|
|
112
116
|
}
|
|
113
117
|
if (e.key === "ArrowRight") {
|
|
114
|
-
if (node.children.length > 0 && tree.expandedState[id]
|
|
118
|
+
if (node.children.length > 0 && tree.expandedState[id] !== true) return;
|
|
115
119
|
const maxY = (e.target.querySelector(".mantine-Tree-label") ?? target).getBoundingClientRect().y;
|
|
116
120
|
const viewButtons = queryAllFocusable(target, "views");
|
|
117
121
|
let view = viewButtons.length > 1 ? viewButtons.find((el, i, all) => centerY(el) > maxY || i === all.length - 1) : null;
|
|
@@ -135,7 +139,7 @@ function ElementsTree({ data: { searchTerms, all, byid, hash, roots }, handleCli
|
|
|
135
139
|
selectOnClick: false,
|
|
136
140
|
tree,
|
|
137
141
|
data: roots,
|
|
138
|
-
levelOffset: "
|
|
142
|
+
levelOffset: "md",
|
|
139
143
|
classNames: {
|
|
140
144
|
root: treeRoot,
|
|
141
145
|
node: cx(focusable, treeNode),
|
|
@@ -150,7 +154,7 @@ function ElementsTree({ data: { searchTerms, all, byid, hash, roots }, handleCli
|
|
|
150
154
|
})
|
|
151
155
|
});
|
|
152
156
|
}
|
|
153
|
-
function ElementTreeNode({ node, elementProps,
|
|
157
|
+
function ElementTreeNode({ node, elementProps, expanded, handleClick, searchTerms }) {
|
|
154
158
|
const { label, element, viewsCount } = node;
|
|
155
159
|
const elementIcon$1 = IconOrShapeRenderer({
|
|
156
160
|
element: {
|
|
@@ -170,7 +174,7 @@ function ElementTreeNode({ node, elementProps, hasChildren, expanded, handleClic
|
|
|
170
174
|
size: 16,
|
|
171
175
|
tabIndex: -1,
|
|
172
176
|
className: cx(elementExpandIcon),
|
|
173
|
-
style: { visibility: hasChildren ? "visible" : "hidden" },
|
|
177
|
+
style: { visibility: node.hasChildren ? "visible" : "hidden" },
|
|
174
178
|
children: /* @__PURE__ */ jsx(IconChevronRight, {
|
|
175
179
|
stroke: 3.5,
|
|
176
180
|
style: {
|
|
@@ -186,7 +190,7 @@ function ElementTreeNode({ node, elementProps, hasChildren, expanded, handleClic
|
|
|
186
190
|
"data-value": element.id,
|
|
187
191
|
className: cx(btn.root, "group", "likec4-element-button"),
|
|
188
192
|
...viewsCount > 0 && { onClick: (e) => {
|
|
189
|
-
if (!hasChildren || expanded) {
|
|
193
|
+
if (!node.hasChildren || expanded) {
|
|
190
194
|
e.stopPropagation();
|
|
191
195
|
handleClick(element);
|
|
192
196
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function SearchByTags(): import("react
|
|
1
|
+
export declare function SearchByTags(): import("react").JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MemoExoticComponent } from 'react';
|
|
2
|
-
export declare const LikeC4SearchInput: MemoExoticComponent<() => import("react
|
|
2
|
+
export declare const LikeC4SearchInput: MemoExoticComponent<() => import("react").JSX.Element>;
|
|
@@ -2,12 +2,12 @@ import { LikeC4Model } from '@likec4/core/model';
|
|
|
2
2
|
import { Fqn } from '@likec4/core/types';
|
|
3
3
|
import { ElementProps, UnstyledButtonProps } from '@mantine/core';
|
|
4
4
|
import { MemoExoticComponent } from 'react';
|
|
5
|
-
export declare const NothingFound: () => import("react
|
|
6
|
-
export declare const ViewsColumn: MemoExoticComponent<() => import("react
|
|
5
|
+
export declare const NothingFound: () => import("react").JSX.Element;
|
|
6
|
+
export declare const ViewsColumn: MemoExoticComponent<() => import("react").JSX.Element>;
|
|
7
7
|
export declare function ViewButton({ className, view, loop, search, focusOnElement, currentViewId, ...props }: {
|
|
8
8
|
view: LikeC4Model.View;
|
|
9
9
|
currentViewId: string;
|
|
10
10
|
search: string;
|
|
11
11
|
loop?: boolean;
|
|
12
12
|
focusOnElement?: Fqn;
|
|
13
|
-
} & UnstyledButtonProps & ElementProps<'button'>): import("react
|
|
13
|
+
} & UnstyledButtonProps & ElementProps<'button'>): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlotRecipeRuntimeFn, SlotRecipeVariantRecord } from '
|
|
1
|
+
import { SlotRecipeRuntimeFn, SlotRecipeVariantRecord } from '../../../styled-system';
|
|
2
2
|
export declare const focusable = "likec4-focusable";
|
|
3
3
|
export declare const emptyBoX: string;
|
|
4
4
|
export declare const buttonsva: SlotRecipeRuntimeFn<"title" | "description" | "icon" | "root" | "descriptionColor", SlotRecipeVariantRecord<"title" | "description" | "icon" | "root" | "descriptionColor">>;
|
|
@@ -6,8 +6,9 @@ var searchActorLogic = setup({
|
|
|
6
6
|
context: {},
|
|
7
7
|
events: {}
|
|
8
8
|
},
|
|
9
|
+
delays: { "MAX_WAIT_ANIMATION_END": 1e3 },
|
|
9
10
|
actions: {
|
|
10
|
-
"reset navigateTo": assign({ navigateTo:
|
|
11
|
+
"reset navigateTo": assign(() => ({ navigateTo: null })),
|
|
11
12
|
"assign navigateTo": assign(({ event }) => {
|
|
12
13
|
assertEvent(event, ["navigate.to"]);
|
|
13
14
|
return { navigateTo: {
|
|
@@ -19,7 +20,7 @@ var searchActorLogic = setup({
|
|
|
19
20
|
assertEvent(event, ["change.search", "open"]);
|
|
20
21
|
return event.search ?? context.searchValue;
|
|
21
22
|
} }),
|
|
22
|
-
"reset pickViewFor": assign({ pickViewFor:
|
|
23
|
+
"reset pickViewFor": assign(() => ({ pickViewFor: null }))
|
|
23
24
|
}
|
|
24
25
|
}).createMachine({
|
|
25
26
|
id: "search",
|
|
@@ -30,7 +31,6 @@ var searchActorLogic = setup({
|
|
|
30
31
|
navigateTo: null
|
|
31
32
|
},
|
|
32
33
|
initial: "inactive",
|
|
33
|
-
on: { "close": { target: ".inactive" } },
|
|
34
34
|
states: {
|
|
35
35
|
inactive: {
|
|
36
36
|
entry: ["reset navigateTo", "reset pickViewFor"],
|
|
@@ -52,7 +52,8 @@ var searchActorLogic = setup({
|
|
|
52
52
|
"navigate.to": {
|
|
53
53
|
target: "waitAnimationEnd",
|
|
54
54
|
actions: "assign navigateTo"
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"close": { target: "inactive" }
|
|
56
57
|
} },
|
|
57
58
|
pickView: { on: {
|
|
58
59
|
"pickview.close": {
|
|
@@ -62,34 +63,37 @@ var searchActorLogic = setup({
|
|
|
62
63
|
"navigate.to": {
|
|
63
64
|
target: "waitAnimationEnd",
|
|
64
65
|
actions: "assign navigateTo"
|
|
65
|
-
}
|
|
66
|
+
},
|
|
67
|
+
"close": { target: "inactive" }
|
|
66
68
|
} },
|
|
67
69
|
/**
|
|
68
70
|
* Wait for animation end before triggering navigation
|
|
69
71
|
* Otherwise, there could be weird artifacts when navigating to large diagrams.
|
|
70
72
|
*/
|
|
71
|
-
waitAnimationEnd: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
waitAnimationEnd: {
|
|
74
|
+
on: { "animation.presence.end": {
|
|
75
|
+
target: "inactive",
|
|
76
|
+
actions: enqueueActions(({ context, system, enqueue }) => {
|
|
77
|
+
const navigateTo = context.navigateTo;
|
|
78
|
+
if (!navigateTo) return;
|
|
79
|
+
const diagramActor = typedSystem(system).diagramActorRef;
|
|
80
|
+
if (navigateTo.focusOnElement) {
|
|
81
|
+
if (diagramActor.getSnapshot().context.view.id === navigateTo.viewId) {
|
|
82
|
+
enqueue.sendTo(diagramActor, {
|
|
83
|
+
type: "focus.node",
|
|
84
|
+
nodeId: navigateTo.focusOnElement
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
89
|
+
enqueue.sendTo(diagramActor, {
|
|
90
|
+
type: "navigate.to",
|
|
91
|
+
...navigateTo
|
|
92
|
+
});
|
|
93
|
+
})
|
|
94
|
+
} },
|
|
95
|
+
after: { MAX_WAIT_ANIMATION_END: { target: "inactive" } }
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
});
|
|
95
99
|
//#endregion
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { HTMLAttributes
|
|
2
|
-
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
type ShadowRootProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
injectFontCss?: boolean | undefined;
|
|
4
4
|
styleNonce?: string | (() => string) | undefined;
|
|
5
|
-
|
|
6
|
-
delegatesFocus?: boolean;
|
|
7
|
-
colorScheme?: "light" | "dark" | undefined;
|
|
5
|
+
colorScheme?: 'light' | 'dark' | undefined;
|
|
8
6
|
keepAspectRatio?: false | undefined | {
|
|
9
7
|
width: number;
|
|
10
8
|
height: number;
|
|
@@ -14,4 +12,6 @@ export declare const ShadowRoot: ForwardRefExoticComponent<HTMLAttributes<HTMLDi
|
|
|
14
12
|
* @see https://mantine.dev/theming/mantine-provider/#theme-prop
|
|
15
13
|
*/
|
|
16
14
|
theme?: any;
|
|
17
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export declare function ShadowRoot({ children, theme, injectFontCss, styleNonce, colorScheme: explicitColorScheme, keepAspectRatio, ...props }: ShadowRootProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { useCallbackRef
|
|
2
|
+
import { useCallbackRef } from "../hooks/useCallbackRef.js";
|
|
3
3
|
import { DefaultMantineProvider } from "../context/DefaultMantineProvider.js";
|
|
4
4
|
import { FramerMotionConfig } from "../context/FramerMotionConfig.js";
|
|
5
|
-
import { useId
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { useId } from "../hooks/useId.js";
|
|
6
|
+
import { ShadowRootContext } from "../context/ShadowRootContext.js";
|
|
7
|
+
import { appendFontToDocument, createShadowRootStylesheets, shadowRootCSS, useColorScheme } from "./styles.js";
|
|
8
|
+
import { memo, useEffectEvent, useLayoutEffect, useRef, useState } from "react";
|
|
8
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { shallowEqual } from "fast-equals";
|
|
9
11
|
import { isDefined } from "remeda";
|
|
10
|
-
import {
|
|
11
|
-
import root from "react-shadow";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
12
13
|
//#region src/shadowroot/ShadowRoot.tsx
|
|
13
|
-
var Root = root["div"];
|
|
14
14
|
function useShadowRootStyle(instanceId, keepAspectRatio = false) {
|
|
15
15
|
if (keepAspectRatio === false) return `
|
|
16
16
|
:where([data-likec4-instance="${instanceId}"]) {
|
|
@@ -50,31 +50,28 @@ function useShadowRootStyle(instanceId, keepAspectRatio = false) {
|
|
|
50
50
|
}
|
|
51
51
|
`.trim();
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
const colorScheme = useColorScheme
|
|
55
|
-
const id = useId
|
|
53
|
+
function ShadowRoot({ children, theme, injectFontCss = true, styleNonce, colorScheme: explicitColorScheme, keepAspectRatio = false, ...props }) {
|
|
54
|
+
const colorScheme = useColorScheme(explicitColorScheme);
|
|
55
|
+
const id = useId();
|
|
56
56
|
const cssstyle = useShadowRootStyle(id, keepAspectRatio);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const getRootElement = useCallbackRef
|
|
60
|
-
const getStyleNonce = useCallbackRef
|
|
57
|
+
const mantineRootRef = useRef(null);
|
|
58
|
+
useLayoutEffect(() => appendFontToDocument(injectFontCss, styleNonce), []);
|
|
59
|
+
const getRootElement = useCallbackRef(() => mantineRootRef.current ?? void 0);
|
|
60
|
+
const getStyleNonce = useCallbackRef(() => {
|
|
61
61
|
if (isDefined(styleNonce)) {
|
|
62
62
|
if (typeof styleNonce === "string") return styleNonce;
|
|
63
63
|
else if (typeof styleNonce === "function") return styleNonce();
|
|
64
64
|
}
|
|
65
65
|
return "";
|
|
66
66
|
});
|
|
67
|
-
const [nonce] = useState(getStyleNonce);
|
|
68
67
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MemoizedStyle, {
|
|
69
|
-
nonce,
|
|
68
|
+
nonce: getStyleNonce(),
|
|
70
69
|
cssstyle
|
|
71
|
-
}), /* @__PURE__ */ jsx(
|
|
72
|
-
ssr: false,
|
|
70
|
+
}), /* @__PURE__ */ jsx(ShadowRootHost, {
|
|
73
71
|
...props,
|
|
74
|
-
styleSheets,
|
|
75
72
|
"data-likec4-instance": id,
|
|
76
73
|
children: /* @__PURE__ */ jsx("div", {
|
|
77
|
-
ref:
|
|
74
|
+
ref: mantineRootRef,
|
|
78
75
|
"data-mantine-color-scheme": colorScheme,
|
|
79
76
|
className: "likec4-shadow-root",
|
|
80
77
|
children: /* @__PURE__ */ jsx(DefaultMantineProvider, {
|
|
@@ -89,15 +86,63 @@ var ShadowRoot = forwardRef(({ children, theme, injectFontCss = true, styleNonce
|
|
|
89
86
|
})
|
|
90
87
|
})
|
|
91
88
|
})] });
|
|
92
|
-
}
|
|
89
|
+
}
|
|
93
90
|
/**
|
|
94
91
|
* @internal Memoized styles gives a performance boost during development
|
|
95
92
|
*/
|
|
96
93
|
var MemoizedStyle = memo(({ nonce, cssstyle }) => /* @__PURE__ */ jsx("style", {
|
|
97
94
|
type: "text/css",
|
|
98
|
-
nonce
|
|
95
|
+
nonce,
|
|
99
96
|
dangerouslySetInnerHTML: { __html: cssstyle }
|
|
100
|
-
}));
|
|
97
|
+
}), shallowEqual);
|
|
101
98
|
MemoizedStyle.displayName = "MemoizedStyle";
|
|
99
|
+
var ShadowRootHostPortal = ({ children, root }) => {
|
|
100
|
+
return createPortal(children, root, "likec4-shadow-root");
|
|
101
|
+
};
|
|
102
|
+
var ShadowRootHost = ({ children, ...props }) => {
|
|
103
|
+
const hostRef = useRef(null);
|
|
104
|
+
const [root, setRoot] = useState(null);
|
|
105
|
+
const styles = shadowRootCSS();
|
|
106
|
+
const updateShadowRoot = useEffectEvent((styles) => {
|
|
107
|
+
setRoot((current) => {
|
|
108
|
+
const host = hostRef.current;
|
|
109
|
+
if (!host) return null;
|
|
110
|
+
if (host.shadowRoot) {
|
|
111
|
+
try {
|
|
112
|
+
if (host.shadowRoot.adoptedStyleSheets?.length !== 1) {
|
|
113
|
+
console.error("Shadow root has unexpected number of style sheets (expected 1, got %d)", host.shadowRoot.adoptedStyleSheets?.length ?? 0);
|
|
114
|
+
return host.shadowRoot;
|
|
115
|
+
}
|
|
116
|
+
host.shadowRoot.adoptedStyleSheets[0].replaceSync(styles);
|
|
117
|
+
} catch (error) {}
|
|
118
|
+
return host.shadowRoot;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const shadowRoot = host.attachShadow({
|
|
122
|
+
mode: "open",
|
|
123
|
+
delegatesFocus: false
|
|
124
|
+
});
|
|
125
|
+
shadowRoot.adoptedStyleSheets = createShadowRootStylesheets(styles);
|
|
126
|
+
return shadowRoot;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return current;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
useLayoutEffect(() => {
|
|
133
|
+
updateShadowRoot(styles);
|
|
134
|
+
}, [styles]);
|
|
135
|
+
return /* @__PURE__ */ jsx("div", {
|
|
136
|
+
...props,
|
|
137
|
+
ref: hostRef,
|
|
138
|
+
children: root && /* @__PURE__ */ jsx(ShadowRootHostPortal, {
|
|
139
|
+
root,
|
|
140
|
+
children: /* @__PURE__ */ jsx(ShadowRootContext, {
|
|
141
|
+
value: root,
|
|
142
|
+
children
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
};
|
|
102
147
|
//#endregion
|
|
103
148
|
export { ShadowRoot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ShadowRoot } from './ShadowRoot';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function scopeStylesToShadowRoot(styles: string): string;
|
|
2
|
+
export declare function appendFontToDocument(injectFontCss: boolean, styleNonce?: string | (() => string) | undefined): void;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a CSS string with styles scoped to the shadow root
|
|
5
|
+
* @returns CSS string for the shadow root
|
|
6
|
+
*/
|
|
7
|
+
export declare const shadowRootCSS: () => string;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a CSSStyleSheet with styles scoped to the shadow root
|
|
10
|
+
*/
|
|
11
|
+
export declare function createShadowRootStylesheets(csstext: string): [CSSStyleSheet];
|
|
12
|
+
export type ColorScheme = 'light' | 'dark';
|
|
13
|
+
export declare function useColorScheme(explicit?: ColorScheme): ColorScheme;
|