@likec4/diagram 1.58.0 → 1.59.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 +1 -1
- package/dist/LikeC4Diagram.props.d.ts +1 -1
- package/dist/LikeC4Styles.js +1 -1
- package/dist/LikeC4View.js +2 -2
- package/dist/ReactLikeC4.d.ts +1 -1
- package/dist/base/Base.d.ts +3 -2
- package/dist/base/Base.js +14 -26
- package/dist/base/BaseXYFlow.d.ts +2 -1
- package/dist/base/BaseXYFlow.js +63 -4
- package/dist/base/keyboardZoom.d.ts +3 -0
- package/dist/base/keyboardZoom.js +20 -0
- package/dist/base/updateEdges.js +7 -16
- package/dist/base/updateNodes.js +3 -9
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundActionButton.js +5 -2
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +5 -2
- package/dist/base-primitives/compound/CompoundTitle.d.ts +7 -1
- package/dist/base-primitives/compound/CompoundTitle.js +2 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +2 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +2 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +4 -2
- package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -0
- package/dist/base-primitives/edge/EdgeLabel.js +2 -5
- package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -0
- package/dist/base-primitives/element/ElementActionButtons.js +4 -1
- package/dist/base-primitives/element/ElementData.d.ts +3 -1
- package/dist/base-primitives/element/ElementData.js +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +5 -2
- package/dist/base-primitives/element/ElementNodeContainer.js +1 -1
- package/dist/base-primitives/element/ElementShape.js +3 -0
- package/dist/components/ErrorFallback.js +3 -5
- package/dist/components/Link.js +6 -6
- package/dist/components/NavigationPanel.js +1 -1
- package/dist/components/SearchControl.css.js +11 -11
- package/dist/context/TagStylesContext.d.ts +3 -3
- package/dist/context/TagStylesContext.js +16 -16
- package/dist/custom/index.d.ts +1 -0
- package/dist/custom/index.js +3 -2
- package/dist/editor/actor/actions.js +1 -1
- package/dist/editor/actor/machine.d.ts +4 -6
- package/dist/editor/actor/setup.d.ts +16 -2
- package/dist/editor/actor/setup.js +5 -4
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/safeContext.d.ts +156 -3
- package/dist/hooks/safeContext.js +60 -12
- package/dist/hooks/useCurrentViewModel.js +1 -1
- package/dist/hooks/useDiagram.d.ts +8 -0
- package/dist/hooks/useDiagram.js +9 -2
- package/dist/hooks/useEditorActor.js +1 -1
- package/dist/hooks/useLikeC4ElementsTree.js +1 -1
- package/dist/hooks/useLikeC4Model.js +1 -1
- package/dist/hooks/useXYFlow.d.ts +1 -0
- package/dist/hooks/useXYFlow.js +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/likec4diagram/DiagramUI.js +19 -6
- package/dist/likec4diagram/DiagramXYFlow.js +39 -14
- package/dist/likec4diagram/convert-to-xyflow.d.ts +3 -5
- package/dist/likec4diagram/convert-to-xyflow.js +29 -10
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +13 -4
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +11 -4
- package/dist/likec4diagram/custom/edges/edges.css.js +1 -1
- package/dist/likec4diagram/custom/index.d.ts +2 -1
- package/dist/likec4diagram/custom/index.js +5 -3
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +1 -0
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.js +13 -3
- package/dist/likec4diagram/custom/nodes/NodeNotes.js +0 -4
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +32 -19
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.d.ts +2 -0
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.js +234 -0
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.js +20 -5
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +15 -14
- package/dist/likec4diagram/relationship-popover/components.d.ts +1 -1
- package/dist/likec4diagram/state/DiagramActorProvider.js +11 -20
- package/dist/likec4diagram/state/aligners.js +1 -1
- package/dist/likec4diagram/state/assign.d.ts +1 -1
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +1 -1
- package/dist/likec4diagram/state/diagram-api.d.ts +18 -10
- package/dist/likec4diagram/state/diagram-api.js +333 -229
- package/dist/likec4diagram/state/machine.actions.d.ts +1026 -332
- package/dist/likec4diagram/state/machine.actions.js +115 -44
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +123 -51
- package/dist/likec4diagram/state/machine.actions.layout.js +40 -33
- package/dist/likec4diagram/state/machine.d.ts +154 -16
- package/dist/likec4diagram/state/machine.js +5 -41
- package/dist/likec4diagram/state/machine.setup.d.ts +84 -19
- package/dist/likec4diagram/state/machine.setup.js +65 -12
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +59 -33
- package/dist/likec4diagram/state/machine.state.navigating.js +7 -3
- package/dist/likec4diagram/state/machine.state.ready.d.ts +1540 -476
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +294 -53
- package/dist/likec4diagram/state/machine.state.ready.focused.js +3 -3
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +264 -73
- package/dist/likec4diagram/state/machine.state.ready.idle.js +31 -6
- package/dist/likec4diagram/state/machine.state.ready.js +22 -16
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +23 -9
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +288 -84
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +135 -66
- package/dist/likec4diagram/state/types.d.ts +4 -2
- package/dist/likec4diagram/state/utils.d.ts +7 -0
- package/dist/likec4diagram/state/utils.js +36 -34
- package/dist/likec4diagram/types.d.ts +47 -3
- package/dist/likec4diagram/ui/FloatingSequenceActors.d.ts +6 -0
- package/dist/likec4diagram/ui/FloatingSequenceActors.js +155 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.js +2 -2
- package/dist/likec4diagram/ui/index.d.ts +2 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -5
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.d.ts +2 -0
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.js +519 -0
- package/dist/likec4diagram/ui/sequence-outline/state.d.ts +36 -0
- package/dist/likec4diagram/ui/sequence-outline/state.js +55 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +1 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +112 -60
- package/dist/likec4diagram/xyflow-sequence/_types.d.ts +55 -5
- package/dist/likec4diagram/xyflow-sequence/const.d.ts +5 -5
- package/dist/likec4diagram/xyflow-sequence/const.js +4 -4
- package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +30 -6
- package/dist/likec4diagram/xyflow-sequence/layouter.js +561 -0
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.d.ts → sequence-view-to-xy.d.ts} +8 -2
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.js → sequence-view-to-xy.js} +111 -14
- package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +2 -7
- package/dist/likec4diagram/xyflow-sequence/sequence-view.js +144 -0
- package/dist/likec4diagram/xyflow-sequence/utils.d.ts +9 -1
- package/dist/likec4diagram/xyflow-sequence/utils.js +96 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +5 -2
- package/dist/navigationpanel/NavigationPanel.js +58 -59
- package/dist/navigationpanel/NavigationPanelDropdown.js +45 -38
- package/dist/navigationpanel/_common.js +2 -2
- package/dist/navigationpanel/actor.actions.d.ts +19 -0
- package/dist/navigationpanel/actor.actions.js +45 -0
- package/dist/navigationpanel/actor.d.ts +34 -96
- package/dist/navigationpanel/actor.js +21 -84
- package/dist/navigationpanel/actor.setup.d.ts +98 -0
- package/dist/navigationpanel/actor.setup.js +31 -0
- package/dist/navigationpanel/comparepanel/DriftsSummary.js +4 -5
- package/dist/navigationpanel/controls/DetailsControls.js +7 -8
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
- package/dist/navigationpanel/editorpanel/styles.js +8 -8
- package/dist/navigationpanel/hooks.d.ts +20 -5
- package/dist/navigationpanel/hooks.js +4 -18
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +2 -2
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +4 -4
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +23 -25
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +5 -5
- package/dist/overlays/Overlays.d.ts +4 -2
- package/dist/overlays/Overlays.js +10 -10
- package/dist/overlays/element-details/ElementDetailsCard.css.js +17 -17
- package/dist/overlays/element-details/MetadataValue.js +15 -15
- package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -5
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -11
- package/dist/overlays/element-details/TabPanelRelationships.js +1 -1
- package/dist/overlays/element-details/TabPanelStructure.css.js +2 -2
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/element-details/actor.d.ts +2 -3
- package/dist/overlays/hooks.d.ts +28 -0
- package/dist/overlays/hooks.js +5 -0
- package/dist/overlays/overlay/Overlay.js +34 -25
- package/dist/overlays/overlaysActor.js +0 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationship-details/layout.js +1 -1
- package/dist/overlays/relationships-browser/SelectElement.css.js +2 -2
- package/dist/overlays/relationships-browser/actor.js +79 -78
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.js +1 -1
- package/dist/overlays/relationships-browser/layout.js +2 -2
- package/dist/projects-overview/actor.js +4 -4
- package/dist/search/Search.js +1 -1
- package/dist/search/components/ElementsColumn.css.js +2 -2
- package/dist/search/components/ViewsColum.js +1 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/components/_shared.css.js +23 -23
- package/dist/search/components/styles.css.js +4 -4
- package/dist/shadowroot/ShadowRoot.d.ts +1 -1
- package/dist/shadowroot/ShadowRoot.js +76 -28
- package/dist/styles2.js +1 -1
- package/dist/utils/defineActors.d.ts +21 -0
- package/dist/utils/defineActors.js +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -4
- package/dist/utils/readableText.d.ts +11 -0
- package/dist/utils/readableText.js +18 -0
- package/package.json +18 -30
- package/panda.buildinfo.json +267 -288
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/adhoc-editor/package.json +0 -4
- package/dist/adhoc-editor/EditorPanel.d.ts +0 -1
- package/dist/adhoc-editor/EditorPanel.js +0 -106
- package/dist/adhoc-editor/ElementsTree.d.ts +0 -2
- package/dist/adhoc-editor/ElementsTree.js +0 -112
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +0 -4
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.js +0 -83
- package/dist/adhoc-editor/components/Tree.d.ts +0 -48
- package/dist/adhoc-editor/components/Tree.js +0 -213
- package/dist/adhoc-editor/hooks.d.ts +0 -14
- package/dist/adhoc-editor/hooks.js +0 -34
- package/dist/adhoc-editor/index.d.ts +0 -2
- package/dist/adhoc-editor/index.js +0 -2
- package/dist/adhoc-editor/state/ActorProvider.d.ts +0 -5
- package/dist/adhoc-editor/state/ActorProvider.js +0 -37
- package/dist/adhoc-editor/state/actor.d.ts +0 -13
- package/dist/adhoc-editor/state/actor.editor.d.ts +0 -56
- package/dist/adhoc-editor/state/actor.editor.js +0 -167
- package/dist/adhoc-editor/state/actor.js +0 -14
- package/dist/adhoc-editor/state/actor.layouter.d.ts +0 -51
- package/dist/adhoc-editor/state/actor.layouter.js +0 -54
- package/dist/adhoc-editor/state/actor.types.d.ts +0 -63
- package/dist/adhoc-editor/state/actor.types.js +0 -25
- package/dist/adhoc-editor/state/panel.d.ts +0 -95
- package/dist/adhoc-editor/state/panel.js +0 -124
- package/dist/adhoc-editor/state/utils.d.ts +0 -17
- package/dist/adhoc-editor/state/utils.js +0 -25
- package/dist/adhoc-editor/useElementsTree.d.ts +0 -18
- package/dist/adhoc-editor/useElementsTree.js +0 -98
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +0 -6
- package/dist/context/ShadowRootContext.d.ts +0 -3
- package/dist/context/ShadowRootContext.js +0 -5
- package/dist/shadowroot/styles.d.ts +0 -13
- package/dist/shadowroot/styles.js +0 -60
|
@@ -2,14 +2,14 @@ import { css, sva } from "@likec4/styles/css";
|
|
|
2
2
|
//#region src/search/components/_shared.css.ts
|
|
3
3
|
var buttonFocused = css.raw({
|
|
4
4
|
outline: "none",
|
|
5
|
-
background: "mantine.
|
|
6
|
-
borderColor: "mantine.
|
|
5
|
+
background: "mantine.primary[8]",
|
|
6
|
+
borderColor: "mantine.primary[9]"
|
|
7
7
|
});
|
|
8
8
|
var _treenodefocus = ".mantine-Tree-node:focus > .mantine-Tree-label &";
|
|
9
9
|
var button = css.raw({
|
|
10
10
|
display: "flex",
|
|
11
11
|
width: "100%",
|
|
12
|
-
background: "
|
|
12
|
+
background: "surface.default",
|
|
13
13
|
rounded: "sm",
|
|
14
14
|
padding: `[12px 8px 12px 14px]`,
|
|
15
15
|
minHeight: "60px",
|
|
@@ -18,20 +18,20 @@ var button = css.raw({
|
|
|
18
18
|
borderColor: "default.border",
|
|
19
19
|
_hover: {
|
|
20
20
|
...buttonFocused,
|
|
21
|
-
borderColor: "mantine.
|
|
22
|
-
background: `mantine.
|
|
21
|
+
borderColor: "mantine.primary[9]",
|
|
22
|
+
background: `mantine.primary[8]/60`
|
|
23
23
|
},
|
|
24
24
|
_focus: buttonFocused,
|
|
25
25
|
[_treenodefocus]: buttonFocused,
|
|
26
26
|
_dark: {
|
|
27
27
|
borderColor: "transparent",
|
|
28
|
-
background: `mantine.
|
|
28
|
+
background: `mantine.dark[6]/80`
|
|
29
29
|
},
|
|
30
30
|
_light: {
|
|
31
|
-
background: `mantine.
|
|
31
|
+
background: `mantine.white/80`,
|
|
32
32
|
_hover: {
|
|
33
|
-
borderColor: "mantine.
|
|
34
|
-
backgroundColor: "mantine.
|
|
33
|
+
borderColor: "mantine.primary[6]",
|
|
34
|
+
backgroundColor: "mantine.primary[5]"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -40,11 +40,11 @@ var iconSize = { ref: "var(--likec4-icon-size, 24px)" };
|
|
|
40
40
|
var icon = css.raw({
|
|
41
41
|
color: {
|
|
42
42
|
base: "text.dimmed",
|
|
43
|
-
_light: "mantine.
|
|
44
|
-
_groupHover: "mantine.
|
|
45
|
-
_groupFocus: "mantine.
|
|
43
|
+
_light: "mantine.gray[5]",
|
|
44
|
+
_groupHover: "mantine.primary[0]",
|
|
45
|
+
_groupFocus: "mantine.primary[0]"
|
|
46
46
|
},
|
|
47
|
-
[_treenodefocus]: { color: "mantine.
|
|
47
|
+
[_treenodefocus]: { color: "mantine.primary[0]" },
|
|
48
48
|
flex: `0 0 ${iconSize.ref}`,
|
|
49
49
|
height: iconSize.ref,
|
|
50
50
|
width: iconSize.ref,
|
|
@@ -60,7 +60,7 @@ var icon = css.raw({
|
|
|
60
60
|
pointerEvents: "none"
|
|
61
61
|
},
|
|
62
62
|
[`& img`]: { objectFit: "contain" },
|
|
63
|
-
"&.likec4-shape-icon svg": { strokeWidth: 1.5 }
|
|
63
|
+
"&.likec4-shape-icon svg": { strokeWidth: "[1.5]" }
|
|
64
64
|
});
|
|
65
65
|
var title = css.raw({
|
|
66
66
|
fontSize: "16px",
|
|
@@ -68,19 +68,19 @@ var title = css.raw({
|
|
|
68
68
|
lineHeight: "1.1",
|
|
69
69
|
[`:where([data-disabled]) &`]: { opacity: .4 },
|
|
70
70
|
color: {
|
|
71
|
-
base: "mantine.
|
|
72
|
-
_light: "mantine.
|
|
71
|
+
base: "mantine.dark[1]",
|
|
72
|
+
_light: "mantine.gray[7]",
|
|
73
73
|
_groupHover: {
|
|
74
|
-
base: "mantine.
|
|
74
|
+
base: "mantine.primary[1]",
|
|
75
75
|
_light: "white"
|
|
76
76
|
},
|
|
77
77
|
_groupFocus: {
|
|
78
|
-
base: "mantine.
|
|
78
|
+
base: "mantine.primary[1]",
|
|
79
79
|
_light: "white"
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
[_treenodefocus]: { color: {
|
|
83
|
-
base: "mantine.
|
|
83
|
+
base: "mantine.primary[1]",
|
|
84
84
|
_light: "white"
|
|
85
85
|
} }
|
|
86
86
|
});
|
|
@@ -88,12 +88,12 @@ var descriptionColor = css.raw({
|
|
|
88
88
|
color: {
|
|
89
89
|
base: "text.dimmed",
|
|
90
90
|
_groupHover: {
|
|
91
|
-
base: "mantine.
|
|
92
|
-
_light: "mantine.
|
|
91
|
+
base: "mantine.primary[1]",
|
|
92
|
+
_light: "mantine.primary[0]"
|
|
93
93
|
},
|
|
94
|
-
_groupFocus: "mantine.
|
|
94
|
+
_groupFocus: "mantine.primary[0]"
|
|
95
95
|
},
|
|
96
|
-
[_treenodefocus]: { color: "mantine.
|
|
96
|
+
[_treenodefocus]: { color: "mantine.primary[0]" }
|
|
97
97
|
});
|
|
98
98
|
var description = css.raw(descriptionColor, {
|
|
99
99
|
marginTop: "1",
|
|
@@ -6,12 +6,12 @@ var input = css({
|
|
|
6
6
|
background: {
|
|
7
7
|
base: "transparent",
|
|
8
8
|
_focusWithin: {
|
|
9
|
-
base: `mantine.
|
|
10
|
-
_dark: `mantine.
|
|
9
|
+
base: `mantine.gray[4]/55 !important`,
|
|
10
|
+
_dark: `mantine.dark[5]/55 !important`
|
|
11
11
|
},
|
|
12
12
|
_groupHover: {
|
|
13
|
-
base: "mantine.
|
|
14
|
-
_dark: "mantine.
|
|
13
|
+
base: "mantine.gray[3]/35",
|
|
14
|
+
_dark: "mantine.dark[5]/35"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
2
|
type ShadowRootProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
injectFontCss?: boolean | undefined;
|
|
4
|
-
styleNonce?: string | (() => string) | undefined;
|
|
4
|
+
styleNonce?: string | (() => string | undefined) | undefined;
|
|
5
5
|
colorScheme?: 'light' | 'dark' | undefined;
|
|
6
6
|
keepAspectRatio?: false | undefined | {
|
|
7
7
|
width: number;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { useCallbackRef } from "../hooks/useCallbackRef.js";
|
|
1
|
+
import { __name } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { useCallbackRef as useCallbackRef$1 } from "../hooks/useCallbackRef.js";
|
|
3
3
|
import { DefaultMantineProvider } from "../context/DefaultMantineProvider.js";
|
|
4
4
|
import { FramerMotionConfig } from "../context/FramerMotionConfig.js";
|
|
5
|
-
import { useId } from "../hooks/useId.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { memo, useEffectEvent, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { useId as useId$1 } from "../hooks/useId.js";
|
|
6
|
+
import styles_font_default from "../styles-font2.js";
|
|
7
|
+
import styles_default from "../styles2.js";
|
|
8
|
+
import { memo, useEffectEvent, useInsertionEffect, useLayoutEffect, useRef, useState } from "react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import
|
|
11
|
-
import { isDefined } from "remeda";
|
|
10
|
+
import "fast-equals";
|
|
11
|
+
import { first, isDefined, isFunction, isString, once } from "remeda";
|
|
12
|
+
import { useColorScheme, useMutationObserverTarget } from "@mantine/hooks";
|
|
12
13
|
import { createPortal } from "react-dom";
|
|
13
14
|
//#region src/shadowroot/ShadowRoot.tsx
|
|
14
15
|
function useShadowRootStyle(instanceId, keepAspectRatio = false) {
|
|
@@ -25,8 +26,7 @@ function useShadowRootStyle(instanceId, keepAspectRatio = false) {
|
|
|
25
26
|
height: 100%;
|
|
26
27
|
min-width: 80px;
|
|
27
28
|
min-height: 80px;
|
|
28
|
-
}
|
|
29
|
-
`.trim();
|
|
29
|
+
}`;
|
|
30
30
|
const width = Math.ceil(keepAspectRatio.width);
|
|
31
31
|
const height = Math.ceil(keepAspectRatio.height);
|
|
32
32
|
const isLandscape = width > height;
|
|
@@ -40,27 +40,41 @@ function useShadowRootStyle(instanceId, keepAspectRatio = false) {
|
|
|
40
40
|
overflow: hidden;
|
|
41
41
|
aspect-ratio: ${width} / ${height};
|
|
42
42
|
${isLandscape ? "" : `
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
max-width: min(100%, var(--likec4-view-max-width, ${width}px));
|
|
44
|
+
margin-left: auto;
|
|
45
|
+
margin-right: auto;`}
|
|
46
46
|
width: ${isLandscape ? "100%" : "auto"};
|
|
47
47
|
height: ${isLandscape ? "auto" : "100%"};
|
|
48
48
|
${isLandscape ? `min-width: 80px;` : `min-height: 80px;`}
|
|
49
49
|
max-height: min(100%, var(--likec4-view-max-height, ${height}px));
|
|
50
|
+
}`;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
function useInjectLikeC4Font(injectFontCss, styleNonce) {
|
|
53
|
+
useInsertionEffect(() => {
|
|
54
|
+
if (injectFontCss && !document.querySelector(`style[data-likec4-font]`)) {
|
|
55
|
+
const style = document.createElement("style");
|
|
56
|
+
style.setAttribute("type", "text/css");
|
|
57
|
+
style.setAttribute("data-likec4-font", "");
|
|
58
|
+
let nonce;
|
|
59
|
+
if (isString(styleNonce)) nonce = styleNonce;
|
|
60
|
+
if (isFunction(styleNonce)) nonce = styleNonce();
|
|
61
|
+
if (nonce) style.setAttribute("nonce", nonce);
|
|
62
|
+
style.appendChild(document.createTextNode(styles_font_default));
|
|
63
|
+
document.head.appendChild(style);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
52
66
|
}
|
|
53
67
|
function ShadowRoot({ children, theme, injectFontCss = true, styleNonce, colorScheme: explicitColorScheme, keepAspectRatio = false, ...props }) {
|
|
54
|
-
const colorScheme = useColorScheme(explicitColorScheme);
|
|
55
|
-
const id = useId();
|
|
68
|
+
const colorScheme = useColorScheme$1(explicitColorScheme);
|
|
69
|
+
const id = useId$1();
|
|
56
70
|
const cssstyle = useShadowRootStyle(id, keepAspectRatio);
|
|
57
71
|
const mantineRootRef = useRef(null);
|
|
58
|
-
|
|
59
|
-
const getRootElement = useCallbackRef(() => mantineRootRef.current ?? void 0);
|
|
60
|
-
const getStyleNonce = useCallbackRef(() => {
|
|
72
|
+
useInjectLikeC4Font(injectFontCss, styleNonce);
|
|
73
|
+
const getRootElement = useCallbackRef$1(() => mantineRootRef.current ?? void 0);
|
|
74
|
+
const getStyleNonce = useCallbackRef$1(() => {
|
|
61
75
|
if (isDefined(styleNonce)) {
|
|
62
|
-
if (typeof styleNonce === "string") return styleNonce;
|
|
63
|
-
else if (typeof styleNonce === "function") return styleNonce();
|
|
76
|
+
if (typeof styleNonce === "string") return styleNonce ?? "";
|
|
77
|
+
else if (typeof styleNonce === "function") return styleNonce() ?? "";
|
|
64
78
|
}
|
|
65
79
|
return "";
|
|
66
80
|
});
|
|
@@ -92,9 +106,9 @@ function ShadowRoot({ children, theme, injectFontCss = true, styleNonce, colorSc
|
|
|
92
106
|
*/
|
|
93
107
|
var MemoizedStyle = memo(({ nonce, cssstyle }) => /* @__PURE__ */ jsx("style", {
|
|
94
108
|
type: "text/css",
|
|
95
|
-
nonce,
|
|
109
|
+
...nonce && { nonce },
|
|
96
110
|
dangerouslySetInnerHTML: { __html: cssstyle }
|
|
97
|
-
}),
|
|
111
|
+
}), (a, b) => a.cssstyle === b.cssstyle);
|
|
98
112
|
MemoizedStyle.displayName = "MemoizedStyle";
|
|
99
113
|
var ShadowRootHostPortal = ({ children, root }) => {
|
|
100
114
|
return createPortal(children, root, "likec4-shadow-root");
|
|
@@ -102,7 +116,7 @@ var ShadowRootHostPortal = ({ children, root }) => {
|
|
|
102
116
|
var ShadowRootHost = ({ children, ...props }) => {
|
|
103
117
|
const hostRef = useRef(null);
|
|
104
118
|
const [root, setRoot] = useState(null);
|
|
105
|
-
const styles =
|
|
119
|
+
const styles = shadowScopedCSS();
|
|
106
120
|
const updateShadowRoot = useEffectEvent((styles) => {
|
|
107
121
|
setRoot((current) => {
|
|
108
122
|
const host = hostRef.current;
|
|
@@ -137,12 +151,46 @@ var ShadowRootHost = ({ children, ...props }) => {
|
|
|
137
151
|
ref: hostRef,
|
|
138
152
|
children: root && /* @__PURE__ */ jsx(ShadowRootHostPortal, {
|
|
139
153
|
root,
|
|
140
|
-
children
|
|
141
|
-
value: root,
|
|
142
|
-
children
|
|
143
|
-
})
|
|
154
|
+
children
|
|
144
155
|
})
|
|
145
156
|
});
|
|
146
157
|
};
|
|
158
|
+
function scopeStylesToShadowRoot(styles) {
|
|
159
|
+
return styles.replaceAll(/:where\(\s*:root\s*,\s*:host\s*\)/g, `:where(.likec4-shadow-root)`).replaceAll(":root", `.likec4-shadow-root`).replaceAll(/(^|[{},;]|\*\/)(\s*)body(?=\s*[{,])/g, "$1$2.likec4-shadow-root");
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Creates a CSS string with styles scoped to the shadow root
|
|
163
|
+
* @returns CSS string for the shadow root
|
|
164
|
+
*/
|
|
165
|
+
var shadowScopedCSS = once(() => {
|
|
166
|
+
return scopeStylesToShadowRoot(styles_default);
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Creates a CSSStyleSheet with styles scoped to the shadow root
|
|
170
|
+
*/
|
|
171
|
+
function createShadowRootStylesheets(csstext) {
|
|
172
|
+
const css = new CSSStyleSheet();
|
|
173
|
+
css.replaceSync(csstext);
|
|
174
|
+
return [css];
|
|
175
|
+
}
|
|
176
|
+
var getComputedColorScheme = () => {
|
|
177
|
+
try {
|
|
178
|
+
const colorScheme = first((window.getComputedStyle(document.documentElement).colorScheme ?? "").split(" "));
|
|
179
|
+
if (colorScheme === "light" || colorScheme === "dark") return colorScheme;
|
|
180
|
+
} catch {}
|
|
181
|
+
return null;
|
|
182
|
+
};
|
|
183
|
+
var getDocumentElement = () => document.documentElement;
|
|
184
|
+
function useColorScheme$1(explicit) {
|
|
185
|
+
const preferred = useColorScheme();
|
|
186
|
+
const [computed, setComputed] = useState(getComputedColorScheme);
|
|
187
|
+
useMutationObserverTarget(useCallbackRef$1(() => setComputed(getComputedColorScheme)), {
|
|
188
|
+
attributes: true,
|
|
189
|
+
childList: false,
|
|
190
|
+
subtree: false
|
|
191
|
+
}, getDocumentElement);
|
|
192
|
+
return explicit ?? computed ?? preferred;
|
|
193
|
+
}
|
|
194
|
+
__name(useColorScheme$1, "useColorScheme");
|
|
147
195
|
//#endregion
|
|
148
196
|
export { ShadowRoot };
|