likec4 0.41.0 → 0.42.1

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.
Files changed (144) hide show
  1. package/README.md +108 -0
  2. package/dist/__app__/src/App.jsx +1 -1
  3. package/dist/__app__/src/components/view-page/ExportDiagram.jsx +72 -0
  4. package/dist/__app__/src/components/view-page/ViewActionsToolbar.jsx +38 -12
  5. package/dist/cli/index.js +53 -53
  6. package/package.json +6 -6
  7. package/dist/@likec4/diagrams/cjs/components/EmbeddedDiagram.js +0 -83
  8. package/dist/@likec4/diagrams/cjs/components/FullscreenDiagramBrowser.js +0 -50
  9. package/dist/@likec4/diagrams/cjs/components/index.js +0 -49
  10. package/dist/@likec4/diagrams/cjs/components/primitives/fullscreen/CloseButton.js +0 -44
  11. package/dist/@likec4/diagrams/cjs/components/primitives/fullscreen/FullscreenDiagram.js +0 -110
  12. package/dist/@likec4/diagrams/cjs/components/primitives/fullscreen/FullscreenDiagramTitle.js +0 -39
  13. package/dist/@likec4/diagrams/cjs/components/primitives/index.js +0 -38
  14. package/dist/@likec4/diagrams/cjs/components/primitives/responsive/ResponsiveDiagram.js +0 -56
  15. package/dist/@likec4/diagrams/cjs/components/types.js +0 -1
  16. package/dist/@likec4/diagrams/cjs/diagram/Diagram.js +0 -326
  17. package/dist/@likec4/diagrams/cjs/diagram/Edges.js +0 -121
  18. package/dist/@likec4/diagrams/cjs/diagram/Nodes.js +0 -204
  19. package/dist/@likec4/diagrams/cjs/diagram/icons/BrainIcon.js +0 -25
  20. package/dist/@likec4/diagrams/cjs/diagram/icons/ExternalLink.js +0 -82
  21. package/dist/@likec4/diagrams/cjs/diagram/icons/index.js +0 -27
  22. package/dist/@likec4/diagrams/cjs/diagram/index.js +0 -27
  23. package/dist/@likec4/diagrams/cjs/diagram/shapes/Browser.js +0 -67
  24. package/dist/@likec4/diagrams/cjs/diagram/shapes/Compound.js +0 -55
  25. package/dist/@likec4/diagrams/cjs/diagram/shapes/Cylinder.js +0 -71
  26. package/dist/@likec4/diagrams/cjs/diagram/shapes/Edge.js +0 -62
  27. package/dist/@likec4/diagrams/cjs/diagram/shapes/Mobile.js +0 -45
  28. package/dist/@likec4/diagrams/cjs/diagram/shapes/NodeIcon.js +0 -38
  29. package/dist/@likec4/diagrams/cjs/diagram/shapes/NodeLabel.js +0 -62
  30. package/dist/@likec4/diagrams/cjs/diagram/shapes/Person.js +0 -48
  31. package/dist/@likec4/diagrams/cjs/diagram/shapes/Queue.js +0 -72
  32. package/dist/@likec4/diagrams/cjs/diagram/shapes/Rectangle.js +0 -30
  33. package/dist/@likec4/diagrams/cjs/diagram/shapes/index.js +0 -54
  34. package/dist/@likec4/diagrams/cjs/diagram/shapes/types.js +0 -1
  35. package/dist/@likec4/diagrams/cjs/diagram/shapes/utils.js +0 -19
  36. package/dist/@likec4/diagrams/cjs/diagram/springs.js +0 -61
  37. package/dist/@likec4/diagrams/cjs/diagram/state/atoms.js +0 -63
  38. package/dist/@likec4/diagrams/cjs/diagram/state/gestures.js +0 -26
  39. package/dist/@likec4/diagrams/cjs/diagram/state/hooks.js +0 -36
  40. package/dist/@likec4/diagrams/cjs/diagram/state/index.js +0 -38
  41. package/dist/@likec4/diagrams/cjs/diagram/state/provider.js +0 -18
  42. package/dist/@likec4/diagrams/cjs/diagram/types.js +0 -1
  43. package/dist/@likec4/diagrams/cjs/hooks/index.js +0 -49
  44. package/dist/@likec4/diagrams/cjs/hooks/useDarkMode.js +0 -11
  45. package/dist/@likec4/diagrams/cjs/hooks/useDiagramApi.js +0 -27
  46. package/dist/@likec4/diagrams/cjs/hooks/useImageLoader.js +0 -68
  47. package/dist/@likec4/diagrams/cjs/hooks/useViewIdFromHash.js +0 -93
  48. package/dist/@likec4/diagrams/cjs/index.js +0 -51
  49. package/dist/@likec4/diagrams/cjs/konva-html.js +0 -93
  50. package/dist/@likec4/diagrams/cjs/konva-portal.js +0 -50
  51. package/dist/@likec4/diagrams/cjs/konva.js +0 -102
  52. package/dist/@likec4/diagrams/cjs/likec4.js +0 -91
  53. package/dist/@likec4/diagrams/components/EmbeddedDiagram.mjs +0 -77
  54. package/dist/@likec4/diagrams/components/FullscreenDiagramBrowser.mjs +0 -52
  55. package/dist/@likec4/diagrams/components/index.mjs +0 -4
  56. package/dist/@likec4/diagrams/components/primitives/fullscreen/CloseButton.mjs +0 -43
  57. package/dist/@likec4/diagrams/components/primitives/fullscreen/FullscreenDiagram.mjs +0 -116
  58. package/dist/@likec4/diagrams/components/primitives/fullscreen/FullscreenDiagramTitle.mjs +0 -32
  59. package/dist/@likec4/diagrams/components/primitives/index.mjs +0 -3
  60. package/dist/@likec4/diagrams/components/primitives/responsive/ResponsiveDiagram.mjs +0 -42
  61. package/dist/@likec4/diagrams/components/types.mjs +0 -0
  62. package/dist/@likec4/diagrams/diagram/Diagram.mjs +0 -307
  63. package/dist/@likec4/diagrams/diagram/Edges.mjs +0 -117
  64. package/dist/@likec4/diagrams/diagram/Nodes.mjs +0 -178
  65. package/dist/@likec4/diagrams/diagram/icons/BrainIcon.mjs +0 -20
  66. package/dist/@likec4/diagrams/diagram/icons/ExternalLink.mjs +0 -90
  67. package/dist/@likec4/diagrams/diagram/icons/index.mjs +0 -2
  68. package/dist/@likec4/diagrams/diagram/index.mjs +0 -2
  69. package/dist/@likec4/diagrams/diagram/shapes/Browser.mjs +0 -49
  70. package/dist/@likec4/diagrams/diagram/shapes/Compound.mjs +0 -48
  71. package/dist/@likec4/diagrams/diagram/shapes/Cylinder.mjs +0 -57
  72. package/dist/@likec4/diagrams/diagram/shapes/Edge.mjs +0 -63
  73. package/dist/@likec4/diagrams/diagram/shapes/Mobile.mjs +0 -33
  74. package/dist/@likec4/diagrams/diagram/shapes/NodeIcon.mjs +0 -28
  75. package/dist/@likec4/diagrams/diagram/shapes/NodeLabel.mjs +0 -59
  76. package/dist/@likec4/diagrams/diagram/shapes/Person.mjs +0 -42
  77. package/dist/@likec4/diagrams/diagram/shapes/Queue.mjs +0 -58
  78. package/dist/@likec4/diagrams/diagram/shapes/Rectangle.mjs +0 -20
  79. package/dist/@likec4/diagrams/diagram/shapes/index.mjs +0 -7
  80. package/dist/@likec4/diagrams/diagram/shapes/types.mjs +0 -0
  81. package/dist/@likec4/diagrams/diagram/shapes/utils.mjs +0 -12
  82. package/dist/@likec4/diagrams/diagram/springs.mjs +0 -57
  83. package/dist/@likec4/diagrams/diagram/state/atoms.mjs +0 -71
  84. package/dist/@likec4/diagrams/diagram/state/gestures.mjs +0 -19
  85. package/dist/@likec4/diagrams/diagram/state/hooks.mjs +0 -28
  86. package/dist/@likec4/diagrams/diagram/state/index.mjs +0 -3
  87. package/dist/@likec4/diagrams/diagram/state/provider.mjs +0 -7
  88. package/dist/@likec4/diagrams/diagram/types.mjs +0 -0
  89. package/dist/@likec4/diagrams/esm/components/EmbeddedDiagram.js +0 -77
  90. package/dist/@likec4/diagrams/esm/components/FullscreenDiagramBrowser.js +0 -52
  91. package/dist/@likec4/diagrams/esm/components/index.js +0 -4
  92. package/dist/@likec4/diagrams/esm/components/primitives/fullscreen/CloseButton.js +0 -43
  93. package/dist/@likec4/diagrams/esm/components/primitives/fullscreen/FullscreenDiagram.js +0 -116
  94. package/dist/@likec4/diagrams/esm/components/primitives/fullscreen/FullscreenDiagramTitle.js +0 -32
  95. package/dist/@likec4/diagrams/esm/components/primitives/index.js +0 -3
  96. package/dist/@likec4/diagrams/esm/components/primitives/responsive/ResponsiveDiagram.js +0 -42
  97. package/dist/@likec4/diagrams/esm/components/types.js +0 -0
  98. package/dist/@likec4/diagrams/esm/diagram/Diagram.js +0 -307
  99. package/dist/@likec4/diagrams/esm/diagram/Edges.js +0 -117
  100. package/dist/@likec4/diagrams/esm/diagram/Nodes.js +0 -178
  101. package/dist/@likec4/diagrams/esm/diagram/icons/BrainIcon.js +0 -20
  102. package/dist/@likec4/diagrams/esm/diagram/icons/ExternalLink.js +0 -90
  103. package/dist/@likec4/diagrams/esm/diagram/icons/index.js +0 -2
  104. package/dist/@likec4/diagrams/esm/diagram/index.js +0 -2
  105. package/dist/@likec4/diagrams/esm/diagram/shapes/Browser.js +0 -49
  106. package/dist/@likec4/diagrams/esm/diagram/shapes/Compound.js +0 -48
  107. package/dist/@likec4/diagrams/esm/diagram/shapes/Cylinder.js +0 -57
  108. package/dist/@likec4/diagrams/esm/diagram/shapes/Edge.js +0 -63
  109. package/dist/@likec4/diagrams/esm/diagram/shapes/Mobile.js +0 -33
  110. package/dist/@likec4/diagrams/esm/diagram/shapes/NodeIcon.js +0 -28
  111. package/dist/@likec4/diagrams/esm/diagram/shapes/NodeLabel.js +0 -59
  112. package/dist/@likec4/diagrams/esm/diagram/shapes/Person.js +0 -42
  113. package/dist/@likec4/diagrams/esm/diagram/shapes/Queue.js +0 -58
  114. package/dist/@likec4/diagrams/esm/diagram/shapes/Rectangle.js +0 -20
  115. package/dist/@likec4/diagrams/esm/diagram/shapes/index.js +0 -7
  116. package/dist/@likec4/diagrams/esm/diagram/shapes/types.js +0 -0
  117. package/dist/@likec4/diagrams/esm/diagram/shapes/utils.js +0 -12
  118. package/dist/@likec4/diagrams/esm/diagram/springs.js +0 -57
  119. package/dist/@likec4/diagrams/esm/diagram/state/atoms.js +0 -71
  120. package/dist/@likec4/diagrams/esm/diagram/state/gestures.js +0 -19
  121. package/dist/@likec4/diagrams/esm/diagram/state/hooks.js +0 -28
  122. package/dist/@likec4/diagrams/esm/diagram/state/index.js +0 -3
  123. package/dist/@likec4/diagrams/esm/diagram/state/provider.js +0 -7
  124. package/dist/@likec4/diagrams/esm/diagram/types.js +0 -0
  125. package/dist/@likec4/diagrams/esm/hooks/index.js +0 -4
  126. package/dist/@likec4/diagrams/esm/hooks/useDarkMode.js +0 -5
  127. package/dist/@likec4/diagrams/esm/hooks/useDiagramApi.js +0 -27
  128. package/dist/@likec4/diagrams/esm/hooks/useImageLoader.js +0 -64
  129. package/dist/@likec4/diagrams/esm/hooks/useViewIdFromHash.js +0 -87
  130. package/dist/@likec4/diagrams/esm/index.js +0 -4
  131. package/dist/@likec4/diagrams/esm/konva-html.js +0 -74
  132. package/dist/@likec4/diagrams/esm/konva-portal.js +0 -34
  133. package/dist/@likec4/diagrams/esm/konva.js +0 -22
  134. package/dist/@likec4/diagrams/esm/likec4.js +0 -54
  135. package/dist/@likec4/diagrams/hooks/index.mjs +0 -4
  136. package/dist/@likec4/diagrams/hooks/useDarkMode.mjs +0 -5
  137. package/dist/@likec4/diagrams/hooks/useDiagramApi.mjs +0 -27
  138. package/dist/@likec4/diagrams/hooks/useImageLoader.mjs +0 -64
  139. package/dist/@likec4/diagrams/hooks/useViewIdFromHash.mjs +0 -87
  140. package/dist/@likec4/diagrams/index.mjs +0 -4
  141. package/dist/@likec4/diagrams/konva-html.mjs +0 -74
  142. package/dist/@likec4/diagrams/konva-portal.mjs +0 -34
  143. package/dist/@likec4/diagrams/konva.mjs +0 -33
  144. package/dist/@likec4/diagrams/likec4.mjs +0 -54
@@ -1,71 +0,0 @@
1
- import { atom } from "jotai";
2
- import { equals } from "rambdax";
3
- import { selectAtom } from "jotai/utils";
4
- const currentHoveredNodeAtom = atom(null);
5
- const nodeTimeoutAtom = atom(void 0);
6
- export const hoveredNodeAtom = atom(
7
- (get) => get(currentHoveredNodeAtom),
8
- (get, set, update) => {
9
- clearTimeout(get(nodeTimeoutAtom));
10
- const _prev = get(currentHoveredNodeAtom);
11
- const _next = typeof update === "function" ? update(_prev) : update;
12
- if (equals(_prev, _next)) {
13
- return false;
14
- }
15
- if (_next != null && _prev == null) {
16
- set(
17
- nodeTimeoutAtom,
18
- setTimeout(() => {
19
- set(currentHoveredNodeAtom, _next);
20
- }, 100)
21
- );
22
- return true;
23
- }
24
- if (_next == null && _prev != null) {
25
- set(
26
- nodeTimeoutAtom,
27
- setTimeout(() => {
28
- set(currentHoveredNodeAtom, null);
29
- }, 150)
30
- );
31
- return true;
32
- }
33
- set(currentHoveredNodeAtom, _next);
34
- return true;
35
- }
36
- );
37
- export const hoveredNodeIdAtom = selectAtom(hoveredNodeAtom, (node) => node?.id ?? null);
38
- const currentHoveredEdgeAtom = atom(null);
39
- const edgeTimeoutAtom = atom(void 0);
40
- export const hoveredEdgeAtom = atom(
41
- (get) => get(currentHoveredEdgeAtom),
42
- (get, set, update) => {
43
- clearTimeout(get(edgeTimeoutAtom));
44
- const _prev = get(currentHoveredEdgeAtom);
45
- const _next = typeof update === "function" ? update(_prev) : update;
46
- if (equals(_prev, _next)) {
47
- return false;
48
- }
49
- if (_next != null && _prev == null) {
50
- set(
51
- edgeTimeoutAtom,
52
- setTimeout(() => {
53
- set(currentHoveredEdgeAtom, _next);
54
- }, 100)
55
- );
56
- return true;
57
- }
58
- if (_next == null && _prev != null) {
59
- set(
60
- edgeTimeoutAtom,
61
- setTimeout(() => {
62
- set(currentHoveredEdgeAtom, null);
63
- }, 150)
64
- );
65
- return true;
66
- }
67
- set(currentHoveredEdgeAtom, _next);
68
- return true;
69
- }
70
- );
71
- export const hoveredEdgeIdAtom = selectAtom(hoveredEdgeAtom, (edge) => edge?.id ?? null);
@@ -1,19 +0,0 @@
1
- let _isDragging = false;
2
- let tm;
3
- export const DiagramGesture = {
4
- get isDragging() {
5
- return _isDragging;
6
- },
7
- set isDragging(value) {
8
- clearTimeout(tm);
9
- if (value) {
10
- _isDragging = value;
11
- return;
12
- }
13
- if (_isDragging) {
14
- tm = setTimeout(() => {
15
- _isDragging = false;
16
- }, 100);
17
- }
18
- }
19
- };
@@ -1,28 +0,0 @@
1
- import { useAtom, useAtomValue, useSetAtom } from "jotai";
2
- import { selectAtom } from "jotai/utils";
3
- import { hoveredEdgeAtom, hoveredEdgeIdAtom, hoveredNodeAtom, hoveredNodeIdAtom } from "./atoms.mjs";
4
- import { useCallback } from "react";
5
- export function useHoveredNode() {
6
- return useAtom(hoveredNodeAtom);
7
- }
8
- export function useHoveredNodeId() {
9
- return useAtomValue(hoveredNodeIdAtom);
10
- }
11
- export function useSetHoveredNode() {
12
- return useSetAtom(hoveredNodeAtom);
13
- }
14
- export function useGetNodeState(nodeId) {
15
- const isHovered = useAtomValue(
16
- selectAtom(
17
- hoveredNodeAtom,
18
- useCallback((node) => node?.id === nodeId, [nodeId])
19
- )
20
- );
21
- return { isHovered };
22
- }
23
- export function useHoveredEdgeId() {
24
- return useAtomValue(hoveredEdgeIdAtom);
25
- }
26
- export function useSetHoveredEdge() {
27
- return useSetAtom(hoveredEdgeAtom);
28
- }
@@ -1,3 +0,0 @@
1
- export * from "./hooks.mjs";
2
- export * from "./gestures.mjs";
3
- export * from "./provider.mjs";
@@ -1,7 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Provider, createStore } from "jotai";
3
- import { useState } from "react";
4
- export function DiagramStateProvider({ children }) {
5
- const [store] = useState(() => createStore());
6
- return /* @__PURE__ */ jsx(Provider, { store, children });
7
- }
File without changes
@@ -1,77 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { invariant } from "@likec4/core";
3
- import { forwardRef, useCallback, useState } from "react";
4
- import { ResponsiveDiagram } from "./primitives/index.js";
5
- import { FullscreenDiagramBrowser } from "./FullscreenDiagramBrowser.js";
6
- const EmbeddedPadding = [20, 20, 20, 20];
7
- const defaultRenderDisclose = ({
8
- views,
9
- viewId,
10
- initialPosition,
11
- onClose
12
- }) => /* @__PURE__ */ jsx(
13
- FullscreenDiagramBrowser,
14
- {
15
- views,
16
- initialViewId: viewId,
17
- initialPosition,
18
- onClose
19
- }
20
- );
21
- export const EmbeddedDiagram = /* @__PURE__ */ forwardRef(
22
- ({
23
- animate = false,
24
- views,
25
- viewId,
26
- padding,
27
- noBrowser = false,
28
- renderDisclose = defaultRenderDisclose,
29
- ...props
30
- }, ref) => {
31
- const diagram = views[viewId];
32
- invariant(diagram, `View "${viewId}" not found in views`);
33
- const [initialPosition, setBrowserInitialPosition] = useState(
34
- null
35
- );
36
- const isOpened = initialPosition !== null;
37
- const openBrowser = (s) => {
38
- const rect = s.container().getBoundingClientRect(), scale = s.scaleX(), embeddedX = s.x() - s.offsetX(), embeddedY = s.y() - s.offsetY(), offset = {
39
- x: window.innerWidth / 2,
40
- y: window.innerHeight / 2
41
- };
42
- setBrowserInitialPosition({
43
- x: Math.ceil(embeddedX + rect.x * scale + offset.x),
44
- y: Math.ceil(embeddedY + rect.y * scale + offset.y),
45
- scale
46
- });
47
- };
48
- const onNodeEdgeClick = (_node, e) => {
49
- const stage = e.target.getStage();
50
- if (stage) {
51
- e.cancelBubble = true;
52
- openBrowser(stage);
53
- }
54
- };
55
- const onClose = useCallback(() => setBrowserInitialPosition(null), []);
56
- const enableBrowseClicks = !noBrowser && !isOpened;
57
- return /* @__PURE__ */ jsxs("div", { ...props, children: [
58
- /* @__PURE__ */ jsx(
59
- ResponsiveDiagram,
60
- {
61
- ref,
62
- animate,
63
- zoomable: false,
64
- pannable: false,
65
- diagram,
66
- padding: padding ?? EmbeddedPadding,
67
- ...enableBrowseClicks && {
68
- onStageClick: openBrowser,
69
- onEdgeClick: onNodeEdgeClick,
70
- onNodeClick: onNodeEdgeClick
71
- }
72
- }
73
- ),
74
- isOpened && renderDisclose({ views, viewId, initialPosition, onClose })
75
- ] });
76
- }
77
- );
@@ -1,52 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { invariant } from "@likec4/core";
3
- import { useSyncedRef } from "@react-hookz/web/esm";
4
- import { useCallback } from "react";
5
- import { createPortal } from "react-dom";
6
- import { useViewIdFromHash } from "../hooks/useViewIdFromHash.js";
7
- import { FullscreenDiagram, FullscreenDiagramTitle } from "./primitives/index.js";
8
- export function FullscreenDiagramBrowser({
9
- initialViewId,
10
- views,
11
- initialPosition,
12
- onClose,
13
- closeOnEsc,
14
- closeOnOutsideClick,
15
- ...props
16
- }) {
17
- const viewsRef = useSyncedRef(views);
18
- const [viewId, setViewId] = useViewIdFromHash({
19
- initialViewId,
20
- onReturnToInitial: () => {
21
- onClose?.();
22
- }
23
- });
24
- const diagram = views[viewId];
25
- invariant(diagram, `View "${viewId}" not found in views`);
26
- const onNodeClick = useCallback(
27
- (node) => {
28
- if (node.navigateTo && node.navigateTo in viewsRef.current) {
29
- setViewId(node.navigateTo);
30
- }
31
- },
32
- [viewsRef, setViewId]
33
- );
34
- return createPortal(
35
- /* @__PURE__ */ jsx(
36
- FullscreenDiagram,
37
- {
38
- diagram,
39
- initialPosition,
40
- closeOnEsc: true,
41
- closeOnOutsideClick: true,
42
- onNodeClick,
43
- onClose,
44
- ...props,
45
- children: /* @__PURE__ */ jsx(FullscreenDiagramTitle, { children: diagram.title })
46
- }
47
- ),
48
- document.body,
49
- "FullscreenDiagramBrowser"
50
- );
51
- }
52
- FullscreenDiagramBrowser.displayName = "FullscreenDiagramBrowser";
@@ -1,4 +0,0 @@
1
- export * from "./FullscreenDiagramBrowser.js";
2
- export * from "./EmbeddedDiagram.js";
3
- export * from "./primitives/index.js";
4
- export * from "./types.js";
@@ -1,43 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- const CrossIcon = forwardRef((props, ref) => /* @__PURE__ */ jsx(
4
- "svg",
5
- {
6
- ref,
7
- width: "15",
8
- height: "15",
9
- viewBox: "0 0 15 15",
10
- fill: "none",
11
- xmlns: "http://www.w3.org/2000/svg",
12
- ...props,
13
- children: /* @__PURE__ */ jsx(
14
- "path",
15
- {
16
- d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
17
- fill: "currentColor",
18
- fillRule: "evenodd",
19
- clipRule: "evenodd"
20
- }
21
- )
22
- }
23
- ));
24
- export const CloseButton = ({
25
- style,
26
- ...props
27
- }) => /* @__PURE__ */ jsx(
28
- "div",
29
- {
30
- ...props,
31
- style: {
32
- position: "absolute",
33
- top: "1rem",
34
- right: "1rem",
35
- width: 24,
36
- height: 24,
37
- cursor: "pointer",
38
- color: "var(--likec4-browser-close-btn-color, rgba(200,200,200,0.8))",
39
- ...style
40
- },
41
- children: /* @__PURE__ */ jsx(CrossIcon, { width: 24, height: 24 })
42
- }
43
- );
@@ -1,116 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { invariant } from "@likec4/core";
3
- import { useKeyboardEvent, useMeasure } from "@react-hookz/web/esm";
4
- import { disableBodyScroll, enableBodyScroll } from "body-scroll-lock-upgrade";
5
- import { useEffect, useRef } from "react";
6
- import { Diagram } from "../../../diagram/Diagram.js";
7
- import { CloseButton } from "./CloseButton.js";
8
- const DefaultPadding = [30, 30, 30, 30];
9
- const StyleOverlay = {
10
- position: "fixed",
11
- top: 0,
12
- left: 0,
13
- right: 0,
14
- bottom: 0,
15
- backgroundColor: "var(--likec4-browser-overlay-bg, rgba(18,18,18,0.8))",
16
- backdropFilter: "var(--likec4-browser-backdrop, blur(4px))",
17
- zIndex: "var(--likec4-overlay-z-index, 100)",
18
- display: "flex",
19
- placeContent: "strech",
20
- placeItems: "strech",
21
- touchAction: "pan-x pan-y pinch-zoom",
22
- boxSizing: "border-box",
23
- margin: 0,
24
- padding: 0,
25
- border: "0 solid transparent"
26
- };
27
- const StyleContainer = {
28
- margin: 0,
29
- padding: 0,
30
- flex: "1 1 100%",
31
- overflow: "hidden"
32
- };
33
- export function FullscreenDiagram({
34
- diagram,
35
- initialPosition,
36
- padding,
37
- style,
38
- styleDiagram,
39
- closeOnEsc = true,
40
- closeOnOutsideClick,
41
- onNodeClick,
42
- onEdgeClick,
43
- onStageClick,
44
- onClose,
45
- children,
46
- ...props
47
- }) {
48
- if (onStageClick && closeOnOutsideClick === true) {
49
- throw new Error("onStageClick cannot be used with closeOnOutsideClick");
50
- }
51
- if (closeOnEsc || closeOnOutsideClick) {
52
- invariant(onClose, "onClose is required when closeOnEsc or closeOnOutsideClick");
53
- }
54
- const overlayRef = useRef(null);
55
- const [measures, containerRef] = useMeasure();
56
- useEffect(() => {
57
- const target = overlayRef.current;
58
- if (!target) {
59
- return;
60
- }
61
- disableBodyScroll(target);
62
- return () => {
63
- enableBodyScroll(target);
64
- };
65
- }, []);
66
- useKeyboardEvent(
67
- closeOnEsc && "Escape",
68
- () => {
69
- onClose?.();
70
- },
71
- [],
72
- { eventOptions: { passive: true } }
73
- );
74
- return /* @__PURE__ */ jsxs(
75
- "div",
76
- {
77
- ref: overlayRef,
78
- style: {
79
- ...StyleOverlay,
80
- ...style
81
- },
82
- ...props,
83
- children: [
84
- /* @__PURE__ */ jsx(
85
- "div",
86
- {
87
- ref: containerRef,
88
- style: {
89
- ...StyleContainer
90
- },
91
- children: measures && /* @__PURE__ */ jsx(
92
- Diagram,
93
- {
94
- animate: true,
95
- pannable: true,
96
- zoomable: true,
97
- diagram,
98
- width: measures.width,
99
- height: measures.height,
100
- initialPosition,
101
- padding: padding ?? DefaultPadding,
102
- style: styleDiagram,
103
- onNodeClick,
104
- onEdgeClick,
105
- onStageClick: onStageClick ?? (closeOnOutsideClick ? onClose : void 0)
106
- }
107
- )
108
- }
109
- ),
110
- children,
111
- onClose && /* @__PURE__ */ jsx(CloseButton, { onClick: () => onClose() })
112
- ]
113
- }
114
- );
115
- }
116
- FullscreenDiagram.displayName = "FullscreenDiagram";
@@ -1,32 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- const ContainerStyles = {
3
- position: "absolute",
4
- pointerEvents: "none",
5
- userSelect: "none",
6
- top: 0,
7
- left: 0,
8
- width: "100%",
9
- margin: 0,
10
- padding: "10px 20px 0 20px",
11
- boxSizing: "border-box",
12
- color: "rgb(241 245 249 / 95%)",
13
- fontFamily: 'ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif',
14
- fontSize: "16px",
15
- lineHeight: "1.1",
16
- fontWeight: "500",
17
- textShadow: "4px 4px 5px rgb(17 17 17)"
18
- };
19
- export function FullscreenDiagramTitle({ children, style, ...props }) {
20
- return /* @__PURE__ */ jsx(
21
- "div",
22
- {
23
- style: {
24
- ...ContainerStyles,
25
- ...style
26
- },
27
- ...props,
28
- children
29
- }
30
- );
31
- }
32
- FullscreenDiagramTitle.displayName = "FullscreenDiagramTitle";
@@ -1,3 +0,0 @@
1
- export * from "./responsive/ResponsiveDiagram.js";
2
- export * from "./fullscreen/FullscreenDiagram.js";
3
- export * from "./fullscreen/FullscreenDiagramTitle.js";
@@ -1,42 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMeasure } from "@react-hookz/web/esm";
3
- import { forwardRef } from "react";
4
- import { Diagram } from "../../../diagram/index.js";
5
- export const ResponsiveDiagram = /* @__PURE__ */ forwardRef(
6
- ({ diagram, animate = false, className, diagramClassName, style, ...props }, ref) => {
7
- const [measures, containerRef] = useMeasure();
8
- const w = diagram.width, h = diagram.height;
9
- return /* @__PURE__ */ jsx(
10
- "div",
11
- {
12
- style: {
13
- position: "relative",
14
- display: "flex",
15
- aspectRatio: `${w} / ${h}`,
16
- width: "100%",
17
- height: "auto",
18
- marginLeft: "auto",
19
- marginRight: "auto",
20
- padding: 0,
21
- maxWidth: w,
22
- boxSizing: "border-box",
23
- ...style
24
- },
25
- className,
26
- children: /* @__PURE__ */ jsx("div", { ref: containerRef, style: { flex: "1 1 100%", overflow: "hidden" }, children: measures && /* @__PURE__ */ jsx(
27
- Diagram,
28
- {
29
- ref,
30
- width: Math.floor(measures.width),
31
- height: Math.floor(measures.height),
32
- diagram,
33
- className: diagramClassName,
34
- animate,
35
- ...props
36
- }
37
- ) })
38
- }
39
- );
40
- }
41
- );
42
- ResponsiveDiagram.displayName = "ResponsiveDiagram";
File without changes