@likec4/diagram 1.21.0 → 1.22.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.
Files changed (129) hide show
  1. package/dist/LikeC4Diagram.js +9 -13
  2. package/dist/base/BaseXYFlow.js +0 -1
  3. package/dist/base/index.d.ts +0 -1
  4. package/dist/base/primitives/compound/CompoundNodeContainer.js +2 -2
  5. package/dist/base/primitives/edge/EdgeLabel.js +2 -2
  6. package/dist/base/primitives/element/ElementNodeContainer.d.ts +6 -1
  7. package/dist/base/primitives/element/ElementNodeContainer.js +31 -13
  8. package/dist/base/primitives/element/ElementTitle.js +7 -3
  9. package/dist/base/primitives/element/styles.css.js +1 -1
  10. package/dist/{base → components}/Link.css.js +3 -3
  11. package/dist/components/SearchControl.css.d.ts +2 -0
  12. package/dist/components/SearchControl.css.js +7 -0
  13. package/dist/components/SearchControl.d.ts +5 -0
  14. package/dist/components/SearchControl.js +17 -0
  15. package/dist/context/IconRenderer.d.ts +10 -0
  16. package/dist/context/IconRenderer.js +34 -0
  17. package/dist/hooks/index.d.ts +0 -1
  18. package/dist/hooks/useDiagram.d.ts +4 -4
  19. package/dist/index.d.ts +1 -1
  20. package/dist/likec4diagram/DiagramUI.js +1 -4
  21. package/dist/likec4diagram/XYFlow.d.ts +6 -1
  22. package/dist/likec4diagram/XYFlow.js +28 -29
  23. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +3 -1
  24. package/dist/likec4diagram/state/actorContext.d.ts +16 -16
  25. package/dist/likec4diagram/state/assign.js +1 -1
  26. package/dist/likec4diagram/state/machine.d.ts +7 -7
  27. package/dist/likec4diagram/state/machine.js +10 -7
  28. package/dist/likec4diagram/ui/controls/Controls.js +63 -48
  29. package/dist/likec4diagram/ui/controls/NavigationButtons.js +44 -69
  30. package/dist/likec4diagram/ui/controls/_shared.js +1 -1
  31. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +5 -4
  32. package/dist/likec4diagram/ui/index.d.ts +2 -0
  33. package/dist/likec4diagram/ui/search/ElementsColumn.css.d.ts +15 -0
  34. package/dist/likec4diagram/ui/search/ElementsColumn.css.js +30 -0
  35. package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +1 -0
  36. package/dist/likec4diagram/ui/search/ElementsColumn.js +243 -0
  37. package/dist/likec4diagram/ui/search/LikeC4Search.css.d.ts +8 -0
  38. package/dist/likec4diagram/ui/search/LikeC4Search.css.js +20 -0
  39. package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +1 -0
  40. package/dist/likec4diagram/ui/search/LikeC4Search.js +265 -0
  41. package/dist/likec4diagram/ui/search/SearchInput.d.ts +1 -0
  42. package/dist/likec4diagram/ui/search/SearchInput.js +196 -0
  43. package/dist/likec4diagram/ui/search/ViewsColum.d.ts +9 -0
  44. package/dist/likec4diagram/ui/search/ViewsColum.js +130 -0
  45. package/dist/likec4diagram/ui/search/ViewsColumn.css.d.ts +5 -0
  46. package/dist/likec4diagram/ui/search/ViewsColumn.css.js +12 -0
  47. package/dist/likec4diagram/ui/search/_shared.css.d.ts +16 -0
  48. package/dist/likec4diagram/ui/search/_shared.css.js +5 -0
  49. package/dist/likec4diagram/ui/search/state.d.ts +19 -0
  50. package/dist/likec4diagram/ui/search/state.js +72 -0
  51. package/dist/likec4diagram/ui/search/utils.d.ts +3 -0
  52. package/dist/likec4diagram/ui/search/utils.js +23 -0
  53. package/dist/likec4diagram/useLayoutConstraints.js +4 -5
  54. package/dist/likec4model/useLikeC4ElementsTree.d.ts +1 -0
  55. package/dist/likec4model/useLikeC4ElementsTree.js +1 -0
  56. package/dist/overlays/Overlays.js +10 -10
  57. package/dist/overlays/element-details/ElementDetailsCard.js +20 -13
  58. package/dist/overlays/element-details/TabPanelDeployments.js +4 -2
  59. package/dist/overlays/overlay/Overlay.d.ts +6 -2
  60. package/dist/overlays/overlay/Overlay.js +18 -29
  61. package/dist/overlays/relationship-details/SelectEdge.js +1 -3
  62. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -5
  63. package/dist/overlays/relationships-browser/SelectElement.js +10 -6
  64. package/dist/overlays/relationships-browser/actor.d.ts +2 -2
  65. package/dist/overlays/relationships-browser/actor.js +8 -8
  66. package/dist/overlays/relationships-browser/custom/nodeTypes.js +2 -2
  67. package/dist/style.css +1 -1
  68. package/package.json +15 -14
  69. package/src/LikeC4Diagram.tsx +0 -1
  70. package/src/base/BaseXYFlow.tsx +0 -1
  71. package/src/base/index.ts +0 -2
  72. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -7
  73. package/src/base/primitives/element/ElementNodeContainer.tsx +36 -16
  74. package/src/base/primitives/element/ElementTitle.css.ts +12 -9
  75. package/src/base/primitives/element/ElementTitle.tsx +6 -2
  76. package/src/base/primitives/element/styles.css.ts +18 -40
  77. package/src/{base → components}/Link.css.ts +3 -3
  78. package/src/components/SearchControl.css.ts +69 -0
  79. package/src/components/SearchControl.tsx +33 -0
  80. package/src/context/IconRenderer.tsx +54 -1
  81. package/src/hooks/index.ts +0 -1
  82. package/src/index.ts +15 -1
  83. package/src/likec4diagram/DiagramUI.tsx +1 -8
  84. package/src/likec4diagram/XYFlow.tsx +30 -30
  85. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
  86. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +1 -0
  87. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -1
  88. package/src/likec4diagram/state/assign.ts +1 -1
  89. package/src/likec4diagram/state/machine.ts +12 -10
  90. package/src/likec4diagram/ui/controls/Controls.tsx +35 -25
  91. package/src/likec4diagram/ui/controls/NavigationButtons.tsx +36 -58
  92. package/src/likec4diagram/ui/controls/styles.css.ts +3 -1
  93. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +111 -108
  94. package/src/likec4diagram/ui/index.ts +2 -0
  95. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
  96. package/src/likec4diagram/ui/search/ElementsColumn.css.ts +119 -0
  97. package/src/likec4diagram/ui/search/ElementsColumn.tsx +291 -0
  98. package/src/likec4diagram/ui/search/LikeC4Search.css.ts +117 -0
  99. package/src/likec4diagram/ui/search/LikeC4Search.tsx +312 -0
  100. package/src/likec4diagram/ui/search/SearchInput.tsx +235 -0
  101. package/src/likec4diagram/ui/search/ViewsColum.tsx +158 -0
  102. package/src/likec4diagram/ui/search/ViewsColumn.css.ts +37 -0
  103. package/src/likec4diagram/ui/search/_shared.css.ts +104 -0
  104. package/src/likec4diagram/ui/search/state.ts +76 -0
  105. package/src/likec4diagram/ui/search/utils.ts +20 -0
  106. package/src/likec4diagram/useLayoutConstraints.ts +4 -5
  107. package/src/likec4model/useLikeC4ElementsTree.ts +4 -4
  108. package/src/overlays/Overlays.tsx +32 -26
  109. package/src/overlays/element-details/ElementDetailsCard.css.ts +4 -4
  110. package/src/overlays/element-details/ElementDetailsCard.tsx +246 -244
  111. package/src/overlays/element-details/TabPanelDeployments.tsx +4 -4
  112. package/src/overlays/overlay/Overlay.css.ts +10 -9
  113. package/src/overlays/overlay/Overlay.tsx +38 -26
  114. package/src/overlays/relationship-details/SelectEdge.css.ts +1 -0
  115. package/src/overlays/relationship-details/SelectEdge.tsx +2 -4
  116. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +10 -5
  117. package/src/overlays/relationships-browser/SelectElement.tsx +88 -82
  118. package/src/overlays/relationships-browser/actor.ts +10 -10
  119. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +2 -2
  120. package/dist/LikeC4Search.css.d.ts +0 -1
  121. package/dist/LikeC4Search.css.js +0 -5
  122. package/dist/LikeC4Search.d.ts +0 -2
  123. package/dist/LikeC4Search.js +0 -88
  124. package/src/LikeC4Search.css.ts +0 -12
  125. package/src/LikeC4Search.tsx +0 -91
  126. /package/dist/{base → components}/Link.css.d.ts +0 -0
  127. /package/dist/{base → components}/Link.d.ts +0 -0
  128. /package/dist/{base → components}/Link.js +0 -0
  129. /package/src/{base → components}/Link.tsx +0 -0
@@ -0,0 +1,243 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { ifilter, toArray, sortParentsFirst, isAncestor, nameFromFqn } from "@likec4/core";
3
+ import { useTree, Tree, ActionIcon, UnstyledButton, Box, Group, Highlight, Tooltip, Text } from "@mantine/core";
4
+ import { useCallbackRef } from "@mantine/hooks";
5
+ import { IconChevronRight } from "@tabler/icons-react";
6
+ import clsx from "clsx";
7
+ import { m } from "framer-motion";
8
+ import { useMemo, useEffect } from "react";
9
+ import { isEmpty, pipe, reduce, indexBy, prop, first, only, partition } from "remeda";
10
+ import { IconOrShapeRenderer } from "../../../context/IconRenderer.js";
11
+ import { sortByLabel } from "../../../likec4model/useLikeC4ElementsTree.js";
12
+ import { useLikeC4Model } from "../../../likec4model/useLikeC4Model.js";
13
+ import { treeSubtree, treeLabel, treeRoot, focusable, treeNode, elementExpandIcon, elementTitleAndId, elementTitle, elementId, elementDescription, elementViewsCount, elementButton, elementIcon } from "./ElementsColumn.css.js";
14
+ import { useNormalizedSearch, useCloseSearchAndNavigateTo, setPickView } from "./state.js";
15
+ import { stopAndPrevent, moveFocusToSearchInput, centerY } from "./utils.js";
16
+ import { NothingFound } from "./ViewsColum.js";
17
+ function ElementsColumn() {
18
+ const search = useNormalizedSearch();
19
+ const model = useLikeC4Model(true);
20
+ const {
21
+ all,
22
+ byid,
23
+ roots: data
24
+ } = useMemo(() => {
25
+ const searchTerms = search.split(".");
26
+ let elements;
27
+ if (isEmpty(search) || search === "kind:") {
28
+ elements = model.elements();
29
+ } else {
30
+ elements = ifilter(model.elements(), (element) => {
31
+ if (search.startsWith("kind:")) {
32
+ return element.kind.toLocaleLowerCase().startsWith(search.slice(5));
33
+ }
34
+ if (search.startsWith("#")) {
35
+ return element.tags.some((tag) => tag.toLocaleLowerCase().includes(search.slice(1)));
36
+ }
37
+ return (element.title + " " + element.id + " " + (element.description ?? "")).toLocaleLowerCase().includes(search);
38
+ });
39
+ }
40
+ const { all: all2, roots } = pipe(
41
+ elements,
42
+ toArray(),
43
+ sortParentsFirst,
44
+ reduce((acc, element) => {
45
+ const treeItem = {
46
+ label: element.title,
47
+ value: element.id,
48
+ element,
49
+ searchTerms,
50
+ children: []
51
+ };
52
+ const parent = acc.all.findLast((root) => isAncestor(root.value, treeItem.value));
53
+ if (parent) {
54
+ parent.children.push(treeItem);
55
+ if (parent.children.length > 1) {
56
+ parent.children.sort(sortByLabel);
57
+ }
58
+ } else {
59
+ acc.roots.push(treeItem);
60
+ }
61
+ acc.all.push(treeItem);
62
+ return acc;
63
+ }, {
64
+ all: [],
65
+ roots: []
66
+ })
67
+ );
68
+ return {
69
+ all: all2,
70
+ byid: indexBy(all2, prop("value")),
71
+ roots: roots.sort(sortByLabel)
72
+ };
73
+ }, [model, search]);
74
+ const tree = useTree({
75
+ multiple: false
76
+ });
77
+ useEffect(() => {
78
+ tree.collapseAllNodes();
79
+ for (const nd of all) {
80
+ if (nd.children.length > 0) {
81
+ tree.expand(nd.value);
82
+ }
83
+ }
84
+ }, [all]);
85
+ const handleClick = useHandleElementSelection();
86
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
87
+ data.length === 0 && /* @__PURE__ */ jsx(NothingFound, {}),
88
+ /* @__PURE__ */ jsx(
89
+ Tree,
90
+ {
91
+ "data-likec4-search-elements": true,
92
+ allowRangeSelection: false,
93
+ clearSelectionOnOutsideClick: true,
94
+ selectOnClick: false,
95
+ tree,
96
+ data,
97
+ levelOffset: "lg",
98
+ classNames: {
99
+ root: treeRoot,
100
+ node: clsx(focusable, treeNode),
101
+ label: treeLabel,
102
+ subtree: treeSubtree
103
+ },
104
+ onKeyDownCapture: (e) => {
105
+ var _a;
106
+ const target = e.target;
107
+ const id = target.getAttribute("data-value");
108
+ const node = !!id && byid[id];
109
+ if (!node) return;
110
+ if (e.key === "ArrowUp") {
111
+ if (id === ((_a = data[0]) == null ? void 0 : _a.value)) {
112
+ stopAndPrevent(e);
113
+ moveFocusToSearchInput();
114
+ }
115
+ return;
116
+ }
117
+ if (e.key === "ArrowRight") {
118
+ const hasChildren = node.children.length > 0;
119
+ if (hasChildren && tree.expandedState[id] === false) {
120
+ return;
121
+ }
122
+ const label = e.target.querySelector(".mantine-Tree-label") ?? target;
123
+ const maxY = label.getBoundingClientRect().y;
124
+ const viewButtons = [...document.querySelectorAll(
125
+ `[data-likec4-search-views] .${focusable}`
126
+ )];
127
+ let view = viewButtons.length > 1 ? viewButtons.find((el, i, all2) => centerY(el) > maxY || i === all2.length - 1) : null;
128
+ view ?? (view = first(viewButtons));
129
+ if (view) {
130
+ stopAndPrevent(e);
131
+ view.focus();
132
+ }
133
+ return;
134
+ }
135
+ if (e.key === " " || e.key === "Enter") {
136
+ stopAndPrevent(e);
137
+ handleClick(node.element);
138
+ return;
139
+ }
140
+ },
141
+ renderNode: ElementTreeNode
142
+ }
143
+ )
144
+ ] });
145
+ }
146
+ function ElementTreeNode({ node, elementProps, hasChildren, expanded }) {
147
+ const { element, searchTerms } = node;
148
+ const elementIcon$1 = IconOrShapeRenderer({
149
+ element: {
150
+ id: element.id,
151
+ title: element.title,
152
+ shape: element.shape,
153
+ icon: element.icon
154
+ },
155
+ className: elementIcon
156
+ });
157
+ const views = [...element.views()];
158
+ const handleClick = useHandleElementSelection();
159
+ const key = `@tree.${node.value}`;
160
+ return /* @__PURE__ */ jsxs(m.div, { layoutId: key, ...elementProps, children: [
161
+ /* @__PURE__ */ jsx(
162
+ ActionIcon,
163
+ {
164
+ variant: "transparent",
165
+ size: 16,
166
+ tabIndex: -1,
167
+ className: clsx(elementExpandIcon),
168
+ style: {
169
+ visibility: hasChildren ? "visible" : "hidden"
170
+ },
171
+ children: /* @__PURE__ */ jsx(
172
+ IconChevronRight,
173
+ {
174
+ stroke: 3.5,
175
+ style: {
176
+ transition: "transform 150ms ease",
177
+ transform: `rotate(${expanded ? "90deg" : "0"})`,
178
+ width: "100%"
179
+ }
180
+ }
181
+ )
182
+ }
183
+ ),
184
+ /* @__PURE__ */ jsxs(
185
+ UnstyledButton,
186
+ {
187
+ component: m.button,
188
+ layout: true,
189
+ tabIndex: -1,
190
+ className: clsx(elementButton, "likec4-element-button"),
191
+ ...views.length > 0 && {
192
+ onClick: (e) => {
193
+ if (!hasChildren || expanded) {
194
+ e.stopPropagation();
195
+ handleClick(element);
196
+ }
197
+ }
198
+ },
199
+ children: [
200
+ elementIcon$1,
201
+ /* @__PURE__ */ jsxs(Box, { style: { flexGrow: 1 }, children: [
202
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", align: "center", className: elementTitleAndId, children: [
203
+ /* @__PURE__ */ jsx(Highlight, { component: "div", highlight: searchTerms, className: elementTitle, children: node.label }),
204
+ /* @__PURE__ */ jsx(Tooltip, { label: element.id, withinPortal: false, fz: "xs", disabled: !element.id.includes("."), children: /* @__PURE__ */ jsx(Highlight, { component: "div", highlight: searchTerms, className: elementId, children: nameFromFqn(element.id) }) })
205
+ ] }),
206
+ /* @__PURE__ */ jsx(Highlight, { component: "div", highlight: searchTerms, className: elementDescription, lineClamp: 1, children: element.description || "No description" })
207
+ ] }),
208
+ /* @__PURE__ */ jsx(Text, { component: "div", className: elementViewsCount, children: views.length === 0 ? "No views" : /* @__PURE__ */ jsxs(Fragment, { children: [
209
+ views.length,
210
+ " view",
211
+ views.length > 1 ? "s" : ""
212
+ ] }) })
213
+ ]
214
+ }
215
+ )
216
+ ] }, key);
217
+ }
218
+ function useHandleElementSelection() {
219
+ const navigateTo = useCloseSearchAndNavigateTo();
220
+ return useCallbackRef((element) => {
221
+ const views = [...element.views()];
222
+ if (views.length === 0) {
223
+ return;
224
+ }
225
+ const singleView = only(views);
226
+ if (singleView) {
227
+ navigateTo(singleView.id, element.id);
228
+ return;
229
+ }
230
+ const [scoped, others] = partition(views, (v) => {
231
+ var _a;
232
+ return ((_a = v.viewOf) == null ? void 0 : _a.id) === element.id;
233
+ });
234
+ setPickView({
235
+ elementFqn: element.id,
236
+ scoped,
237
+ others
238
+ });
239
+ });
240
+ }
241
+ export {
242
+ ElementsColumn
243
+ };
@@ -0,0 +1,8 @@
1
+ export { focusable } from './_shared.css';
2
+ export declare const backdrop: string;
3
+ export declare const root: string;
4
+ export declare const input: string;
5
+ export declare const pickviewBackdrop: string;
6
+ export declare const pickview: string;
7
+ export declare const pickviewGroup: string;
8
+ export declare const scrollArea: string;
@@ -0,0 +1,20 @@
1
+ /* empty css */
2
+ /* empty css */
3
+ var focusable = "_1cfw8gr4";
4
+ var backdrop = "eien2d0";
5
+ var root = "eien2d1";
6
+ var input = "eien2d2";
7
+ var pickviewBackdrop = "eien2d3";
8
+ var pickview = "eien2d4";
9
+ var pickviewGroup = "eien2d5";
10
+ var scrollArea = "eien2d6";
11
+ export {
12
+ backdrop,
13
+ focusable,
14
+ input,
15
+ pickview,
16
+ pickviewBackdrop,
17
+ pickviewGroup,
18
+ root,
19
+ scrollArea
20
+ };
@@ -0,0 +1 @@
1
+ export declare function LikeC4Search(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,265 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { Portal, RemoveScroll, Group, Box, ActionIcon, Grid, GridCol, Title, ScrollArea, ScrollAreaAutosize, Stack } from "@mantine/core";
3
+ import { useDisclosure, useHotkeys, useCallbackRef, useFocusTrap, useFocusWithin, useMergedRef, useWindowEvent, useFocusReturn } from "@mantine/hooks";
4
+ import { IconX } from "@tabler/icons-react";
5
+ import { AnimatePresence, m, LayoutGroup } from "framer-motion";
6
+ import { useRef } from "react";
7
+ import { SearchControl } from "../../../components/SearchControl.js";
8
+ import { ElementsColumn } from "./ElementsColumn.js";
9
+ import { backdrop, root, scrollArea, pickviewBackdrop, pickview, pickviewGroup } from "./LikeC4Search.css.js";
10
+ import { LikeC4SearchInput } from "./SearchInput.js";
11
+ import { LikeC4SearchContext, useCloseSearch, wasResetPickView, usePickView, setPickView } from "./state.js";
12
+ import { stopAndPrevent } from "./utils.js";
13
+ import { ViewsColumn, ViewButton } from "./ViewsColum.js";
14
+ import { useMantinePortalProps } from "../../../hooks/useMantinePortalProps.js";
15
+ function LikeC4Search() {
16
+ const [searchOpened, searchOps] = useDisclosure(false);
17
+ useHotkeys([
18
+ ["mod+k", () => searchOps.toggle(), {
19
+ preventDefault: true
20
+ }],
21
+ ["mod+f", () => searchOps.toggle(), {
22
+ preventDefault: true
23
+ }]
24
+ ]);
25
+ const afterCloseCbRef = useRef(null);
26
+ const close = useCallbackRef((cb) => {
27
+ afterCloseCbRef.current = cb ?? null;
28
+ searchOps.close();
29
+ });
30
+ const onExitComplete = useCallbackRef(() => {
31
+ if (afterCloseCbRef.current) {
32
+ afterCloseCbRef.current();
33
+ afterCloseCbRef.current = null;
34
+ }
35
+ });
36
+ const { portalProps } = useMantinePortalProps();
37
+ return /* @__PURE__ */ jsxs(LikeC4SearchContext, { value: close, children: [
38
+ /* @__PURE__ */ jsx(
39
+ SearchControl,
40
+ {
41
+ onClick: (e) => {
42
+ e.stopPropagation();
43
+ searchOps.toggle();
44
+ }
45
+ }
46
+ ),
47
+ /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsx(RemoveScroll, { enabled: searchOpened, children: /* @__PURE__ */ jsx(AnimatePresence, { onExitComplete, children: searchOpened && /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ /* @__PURE__ */ jsx(
49
+ m.div,
50
+ {
51
+ className: backdrop,
52
+ initial: { opacity: 0.7 },
53
+ animate: {
54
+ opacity: 1,
55
+ transition: {
56
+ duration: 0.1
57
+ }
58
+ },
59
+ exit: {
60
+ opacity: 0,
61
+ transition: {
62
+ duration: 0.075
63
+ }
64
+ }
65
+ },
66
+ "backdrop"
67
+ ),
68
+ /* @__PURE__ */ jsx(LikeC4SearchOverlay, {}, "overlay")
69
+ ] }) }) }) })
70
+ ] });
71
+ }
72
+ function LikeC4SearchOverlay() {
73
+ const close = useCloseSearch();
74
+ const focusTrapRef = useFocusTrap();
75
+ const { ref: forcusRef, focused } = useFocusWithin();
76
+ const ref = useMergedRef(forcusRef, focusTrapRef);
77
+ useWindowEvent(
78
+ "keydown",
79
+ (event) => {
80
+ if (event.key === "Escape") {
81
+ stopAndPrevent(event);
82
+ if (!wasResetPickView()) {
83
+ close();
84
+ }
85
+ return;
86
+ }
87
+ }
88
+ );
89
+ return /* @__PURE__ */ jsxs(
90
+ m.div,
91
+ {
92
+ ref,
93
+ className: root,
94
+ animate: {
95
+ opacity: 1,
96
+ scale: 1,
97
+ translateY: 0
98
+ },
99
+ exit: {
100
+ opacity: 0,
101
+ scale: 0.9,
102
+ transition: {
103
+ duration: 0.1
104
+ }
105
+ },
106
+ children: [
107
+ /* @__PURE__ */ jsxs(Group, { wrap: "nowrap", children: [
108
+ /* @__PURE__ */ jsx(Box, { flex: 1, px: "sm", children: /* @__PURE__ */ jsx(LikeC4SearchInput, {}) }),
109
+ /* @__PURE__ */ jsx(Box, { flex: "0 0 auto", children: /* @__PURE__ */ jsx(
110
+ ActionIcon,
111
+ {
112
+ size: "lg",
113
+ variant: "default",
114
+ onClick: (e) => {
115
+ e.stopPropagation();
116
+ close();
117
+ },
118
+ children: /* @__PURE__ */ jsx(IconX, {})
119
+ }
120
+ ) })
121
+ ] }),
122
+ /* @__PURE__ */ jsxs(Grid, { children: [
123
+ /* @__PURE__ */ jsx(GridCol, { span: 6, children: /* @__PURE__ */ jsx(Title, { component: "div", order: 6, c: "dimmed", pl: "sm", children: "Elements" }) }),
124
+ /* @__PURE__ */ jsx(GridCol, { span: 6, children: /* @__PURE__ */ jsx(Title, { component: "div", order: 6, c: "dimmed", pl: "sm", children: "Views" }) })
125
+ ] }),
126
+ /* @__PURE__ */ jsxs(
127
+ Grid,
128
+ {
129
+ style: {
130
+ containerName: "likec4-search-elements",
131
+ containerType: "size",
132
+ overflow: "hidden",
133
+ flexGrow: 1
134
+ },
135
+ children: [
136
+ /* @__PURE__ */ jsx(GridCol, { span: 6, children: /* @__PURE__ */ jsx(
137
+ ScrollArea,
138
+ {
139
+ type: "hover",
140
+ className: scrollArea,
141
+ pr: "xs",
142
+ scrollbars: "y",
143
+ children: /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(LayoutGroup, { id: "likec4-search-elements", children: /* @__PURE__ */ jsx(ElementsColumn, {}) }) })
144
+ }
145
+ ) }),
146
+ /* @__PURE__ */ jsx(GridCol, { span: 6, children: /* @__PURE__ */ jsx(
147
+ ScrollArea,
148
+ {
149
+ type: "hover",
150
+ className: scrollArea,
151
+ pr: "xs",
152
+ scrollbars: "y",
153
+ children: /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(LayoutGroup, { id: "likec4-search-views", children: /* @__PURE__ */ jsx(ViewsColumn, {}) }) })
154
+ }
155
+ ) })
156
+ ]
157
+ }
158
+ ),
159
+ /* @__PURE__ */ jsx(Box, {}),
160
+ /* @__PURE__ */ jsx(PickView, {})
161
+ ]
162
+ }
163
+ );
164
+ }
165
+ function PickView() {
166
+ const pickview$1 = usePickView();
167
+ const focusTrapRef = useFocusTrap(!!pickview$1);
168
+ useFocusReturn({
169
+ opened: !!pickview$1
170
+ });
171
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(LayoutGroup, { id: "likec4-search-pickview", children: pickview$1 && /* @__PURE__ */ jsxs(Fragment, { children: [
172
+ /* @__PURE__ */ jsx(
173
+ m.div,
174
+ {
175
+ className: pickviewBackdrop,
176
+ onClick: (e) => {
177
+ e.stopPropagation();
178
+ setPickView(null);
179
+ }
180
+ },
181
+ "backdrop"
182
+ ),
183
+ /* @__PURE__ */ jsxs(
184
+ m.div,
185
+ {
186
+ initial: {
187
+ opacity: 0,
188
+ scale: 0.95,
189
+ originY: 0,
190
+ translateX: "-50%",
191
+ translateY: -20
192
+ },
193
+ animate: {
194
+ opacity: 1,
195
+ scale: 1,
196
+ translateY: 0
197
+ },
198
+ exit: {
199
+ opacity: 0,
200
+ scale: 0.98,
201
+ translateY: -20,
202
+ transition: {
203
+ duration: 0.1
204
+ }
205
+ },
206
+ className: pickview,
207
+ "data-likec4-search-views": true,
208
+ ref: focusTrapRef,
209
+ children: [
210
+ /* @__PURE__ */ jsxs(Group, { px: "sm", py: "md", justify: "space-between", children: [
211
+ /* @__PURE__ */ jsx(Title, { order: 2, lh: 1, children: "Select view" }),
212
+ /* @__PURE__ */ jsx(
213
+ ActionIcon,
214
+ {
215
+ size: "md",
216
+ variant: "default",
217
+ onClick: (e) => {
218
+ e.stopPropagation();
219
+ setPickView(null);
220
+ },
221
+ children: /* @__PURE__ */ jsx(IconX, {})
222
+ }
223
+ )
224
+ ] }),
225
+ /* @__PURE__ */ jsxs(ScrollAreaAutosize, { mah: "calc(100vh - 8rem - 50px)", type: "never", children: [
226
+ pickview$1.scoped.length > 0 && /* @__PURE__ */ jsxs(Stack, { gap: "sm", px: "sm", className: pickviewGroup, children: [
227
+ /* @__PURE__ */ jsx(Title, { order: 6, c: "dimmed", children: "scoped views of the element" }),
228
+ pickview$1.scoped.map((view, i) => /* @__PURE__ */ jsx(
229
+ ViewButton,
230
+ {
231
+ view,
232
+ search: "",
233
+ loop: true,
234
+ mod: {
235
+ autofocus: i === 0
236
+ }
237
+ },
238
+ view.id
239
+ ))
240
+ ] }),
241
+ pickview$1.others.length > 0 && /* @__PURE__ */ jsxs(Stack, { gap: "sm", px: "sm", className: pickviewGroup, children: [
242
+ /* @__PURE__ */ jsx(Title, { order: 6, c: "dimmed", children: "views including this element" }),
243
+ pickview$1.others.map((view, i) => /* @__PURE__ */ jsx(
244
+ ViewButton,
245
+ {
246
+ view,
247
+ search: "",
248
+ loop: true,
249
+ mod: {
250
+ autofocus: i === 0 && pickview$1.scoped.length === 0
251
+ }
252
+ },
253
+ view.id
254
+ ))
255
+ ] })
256
+ ] })
257
+ ]
258
+ },
259
+ "pickview"
260
+ )
261
+ ] }) }) });
262
+ }
263
+ export {
264
+ LikeC4Search
265
+ };
@@ -0,0 +1 @@
1
+ export declare function LikeC4SearchInput(): import("react/jsx-runtime").JSX.Element;