@likec4/diagram 1.50.0 → 1.52.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/components/NavigationPanel.js +4 -2
- package/dist/components/SearchControl.css.js +79 -0
- package/dist/components/SearchControl.js +17 -0
- package/dist/custom/index.d.ts +1 -0
- package/dist/custom/index.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/navigationpanel/comparepanel/DriftsSummary.js +13 -11
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +5 -5
- package/dist/search/Search.d.ts +8 -0
- package/dist/search/Search.js +40 -47
- package/dist/search/SearchContext.d.ts +21 -0
- package/dist/search/SearchContext.js +20 -0
- package/dist/search/XStateSearchAdapter.d.ts +5 -0
- package/dist/search/XStateSearchAdapter.js +64 -0
- package/dist/search/components/ElementsColumn.js +5 -8
- package/dist/search/components/PickView.d.ts +1 -3
- package/dist/search/components/PickView.js +4 -4
- package/dist/search/components/SearchInput.js +5 -6
- package/dist/search/components/ViewsColum.js +6 -10
- package/dist/search/hooks.d.ts +0 -2
- package/dist/search/hooks.js +7 -33
- package/dist/styles.css2.js +1 -1
- package/package.json +9 -17
- package/styles-min.css +1 -1
- package/styles.css +1 -1
|
@@ -6,9 +6,9 @@ import { Stack, VisuallyHidden, UnstyledButton, ThemeIcon, Group, Highlight, Bad
|
|
|
6
6
|
import * as m from 'motion/react-m';
|
|
7
7
|
import { memo, useRef, useMemo } from 'react';
|
|
8
8
|
import { first } from 'remeda';
|
|
9
|
-
import { useCurrentViewId } from '../../hooks/useCurrentView.js';
|
|
10
9
|
import { useLikeC4Model } from '../../hooks/useLikeC4Model.js';
|
|
11
|
-
import { useNormalizedSearch
|
|
10
|
+
import { useNormalizedSearch } from '../hooks.js';
|
|
11
|
+
import { useSearchContext } from '../SearchContext.js';
|
|
12
12
|
import { emptyBoX, focusable, buttonsva } from './_shared.css.js';
|
|
13
13
|
import { moveFocusToSearchInput, queryAllFocusable, centerY } from './utils.js';
|
|
14
14
|
import { viewButton } from './ViewsColumn.css.js';
|
|
@@ -17,7 +17,7 @@ import IconZoomScan from '../../node_modules/.pnpm/@tabler_icons-react@3.36.1_re
|
|
|
17
17
|
|
|
18
18
|
const NothingFound = () => /* @__PURE__ */ jsx(Box, { className: emptyBoX, children: "Nothing found" });
|
|
19
19
|
const useFoundViews = () => {
|
|
20
|
-
const currentViewId =
|
|
20
|
+
const { currentViewId } = useSearchContext();
|
|
21
21
|
const likec4model = useLikeC4Model();
|
|
22
22
|
const search = useNormalizedSearch();
|
|
23
23
|
return useMemo(() => {
|
|
@@ -79,7 +79,7 @@ const ViewsColumn = memo(() => {
|
|
|
79
79
|
ViewButton,
|
|
80
80
|
{
|
|
81
81
|
view,
|
|
82
|
-
currentViewId,
|
|
82
|
+
currentViewId: currentViewId ?? "",
|
|
83
83
|
search,
|
|
84
84
|
tabIndex: i === 0 ? 0 : -1
|
|
85
85
|
}
|
|
@@ -90,15 +90,11 @@ const ViewsColumn = memo(() => {
|
|
|
90
90
|
});
|
|
91
91
|
const btn = buttonsva();
|
|
92
92
|
function ViewButton({ className, view, loop = false, search, focusOnElement, currentViewId, ...props }) {
|
|
93
|
-
const
|
|
93
|
+
const ctx = useSearchContext();
|
|
94
94
|
const nextViewId = view.id;
|
|
95
95
|
const isCurrentView = nextViewId === currentViewId;
|
|
96
96
|
const navigate = () => {
|
|
97
|
-
|
|
98
|
-
type: "navigate.to",
|
|
99
|
-
viewId: nextViewId,
|
|
100
|
-
focusOnElement
|
|
101
|
-
});
|
|
97
|
+
ctx.navigateTo(nextViewId, focusOnElement);
|
|
102
98
|
};
|
|
103
99
|
return /* @__PURE__ */ jsxs(
|
|
104
100
|
UnstyledButton,
|
package/dist/search/hooks.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SearchActorRef } from './searchActor';
|
|
2
|
-
export declare function useSearchActor(): SearchActorRef;
|
|
3
1
|
export declare function useSearch(): [string, (search: string) => void];
|
|
4
2
|
export declare function useNormalizedSearch(): string;
|
|
5
3
|
export declare function useUpdateSearch(): (search: string) => void;
|
package/dist/search/hooks.js
CHANGED
|
@@ -1,41 +1,15 @@
|
|
|
1
|
-
import { useSelector } from '@xstate/react';
|
|
2
1
|
import { useCallback, useDeferredValue } from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import { useSearchContext } from './SearchContext.js';
|
|
4
3
|
|
|
5
|
-
function useSearchActor() {
|
|
6
|
-
const searchActorRef = useSearchActorRef();
|
|
7
|
-
if (!searchActorRef) {
|
|
8
|
-
throw new Error("Search actor not found");
|
|
9
|
-
}
|
|
10
|
-
return searchActorRef;
|
|
11
|
-
}
|
|
12
|
-
const selectSearchValue = (s) => s.context.searchValue;
|
|
13
|
-
function useSearch() {
|
|
14
|
-
const searchActorRef = useSearchActor();
|
|
15
|
-
const searchValue = useSelector(searchActorRef, selectSearchValue);
|
|
16
|
-
const updateSearch = useCallback((search) => {
|
|
17
|
-
searchActorRef.send({ type: "change.search", search });
|
|
18
|
-
}, [searchActorRef]);
|
|
19
|
-
return [searchValue, updateSearch];
|
|
20
|
-
}
|
|
21
|
-
const selectNormalizedSearchValue = (s) => {
|
|
22
|
-
let v = selectSearchValue(s);
|
|
23
|
-
if (v === "") return v;
|
|
24
|
-
v = v.trim().toLowerCase();
|
|
25
|
-
if (v.startsWith("#") && v.length <= 2) {
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
return v.length > 1 ? v : "";
|
|
29
|
-
};
|
|
30
4
|
function useNormalizedSearch() {
|
|
31
|
-
const
|
|
32
|
-
return useDeferredValue(
|
|
5
|
+
const ctx = useSearchContext();
|
|
6
|
+
return useDeferredValue(ctx.normalizedSearch);
|
|
33
7
|
}
|
|
34
8
|
function useUpdateSearch() {
|
|
35
|
-
const
|
|
9
|
+
const { setSearchValue } = useSearchContext();
|
|
36
10
|
return useCallback((search) => {
|
|
37
|
-
|
|
38
|
-
}, [
|
|
11
|
+
setSearchValue(search);
|
|
12
|
+
}, [setSearchValue]);
|
|
39
13
|
}
|
|
40
14
|
|
|
41
|
-
export { useNormalizedSearch,
|
|
15
|
+
export { useNormalizedSearch, useUpdateSearch };
|