@visma-swno/vsn-navigation 1.1.0-beta.9 → 1.1.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/assets/vsn-navigation.d.ts +60 -0
- package/dist/assets/vsn-navigation.js +2888 -34
- package/dist/custom-elements.json +1 -0
- package/package.json +13 -6
|
@@ -16,6 +16,13 @@ declare type BaseTreeItem = {
|
|
|
16
16
|
id: string;
|
|
17
17
|
/** The label to show for that item, in the relevant language */
|
|
18
18
|
label: string;
|
|
19
|
+
/** Optional QA identifier rendered as a data-qa-id attribute on the nav item element */
|
|
20
|
+
'data-qa-id'?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export declare type ButtonClickedEvent = {
|
|
24
|
+
/** The clicked HTMLButtonElement. Can be used as an anchor to position popups. */
|
|
25
|
+
target: HTMLButtonElement;
|
|
19
26
|
};
|
|
20
27
|
|
|
21
28
|
export declare type FeedbackConfig = {
|
|
@@ -46,6 +53,8 @@ export declare type NavigationMenu = {
|
|
|
46
53
|
expand and select that item. When it's not found in items, breadcrumbs will show
|
|
47
54
|
nothing and the side menu will have no element selected */
|
|
48
55
|
currentItem: string;
|
|
56
|
+
/** Optionally set the current page title. This will be shown as the last item in the breadcrumbs */
|
|
57
|
+
pageTitle?: string;
|
|
49
58
|
/** Sidebar search config; default disabled when undefined */
|
|
50
59
|
search?: SearchConfig;
|
|
51
60
|
};
|
|
@@ -55,6 +64,37 @@ declare type NonEmptyArray<T> = [T, ...T[]];
|
|
|
55
64
|
export declare type SearchConfig = {
|
|
56
65
|
enabled: boolean;
|
|
57
66
|
shortcut?: string;
|
|
67
|
+
extraDataSets?: SearchDataSetConfig[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export declare type SearchDataSetConfig = {
|
|
71
|
+
/** Stable unique identifier for the dataset, used for selection and lookup */
|
|
72
|
+
id: string;
|
|
73
|
+
/** User-facing label for display purposes */
|
|
74
|
+
label: string;
|
|
75
|
+
searchFunction: (query: SearchQuery) => Promise<SearchResult>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export declare class SearchError extends Error {
|
|
79
|
+
constructor(message: string);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare type SearchQuery = {
|
|
83
|
+
abortController: AbortController;
|
|
84
|
+
query: string;
|
|
85
|
+
cursor?: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export declare type SearchResult = {
|
|
89
|
+
nextCursor?: string;
|
|
90
|
+
results: SearchResultItem[];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export declare type SearchResultItem = {
|
|
94
|
+
id: string;
|
|
95
|
+
label: string;
|
|
96
|
+
url: string;
|
|
97
|
+
lines?: [string] | [string, string];
|
|
58
98
|
};
|
|
59
99
|
|
|
60
100
|
export declare type TreeItem = TreeParent | TreeLeaf;
|
|
@@ -106,6 +146,10 @@ export declare class VSNNavigation extends LitElement {
|
|
|
106
146
|
private _resolvedModules;
|
|
107
147
|
private _modulesLoading;
|
|
108
148
|
private _modulesLoadToken;
|
|
149
|
+
/** Set at close time: whether focus was inside the side-bar. Gates the focus
|
|
150
|
+
restore so we don't steal focus when the user closed the side-bar by
|
|
151
|
+
clicking a focusable element outside (e.g. a top-bar button). */
|
|
152
|
+
private _restoreFocusToToggle;
|
|
109
153
|
private _resolveModules;
|
|
110
154
|
static styles: CSSResult[];
|
|
111
155
|
willUpdate(changed: Map<string, unknown>): void;
|
|
@@ -114,7 +158,23 @@ export declare class VSNNavigation extends LitElement {
|
|
|
114
158
|
/** Project tree into the shape the side-bar expects: top-level items lifted from the active module. */
|
|
115
159
|
private get _sideBarMenu();
|
|
116
160
|
private _onToggleSideBar;
|
|
161
|
+
/** Open the side-bar and, once rendered, focus the search field (if enabled).
|
|
162
|
+
Shared by the hamburger toggle and the CTRL/Cmd+K shortcut. */
|
|
163
|
+
private _openAndFocusSearch;
|
|
117
164
|
private _onSideBarClose;
|
|
165
|
+
/** Close the side-bar. Captures `:focus-within` BEFORE flipping the state, since
|
|
166
|
+
the side-bar becomes display:none and the check would then always be false. */
|
|
167
|
+
private _closeSideBar;
|
|
168
|
+
updated(changed: Map<string, unknown>): void;
|
|
169
|
+
connectedCallback(): void;
|
|
170
|
+
disconnectedCallback(): void;
|
|
171
|
+
/** CTRL+K (Cmd+K on Mac) opens the side-bar and focuses the search field (if enabled). */
|
|
172
|
+
private _onShortcut;
|
|
173
|
+
/** Escape closes the side-bar when nothing is focused. Skips when focus is on
|
|
174
|
+
any element — including inside the side-bar's shadow (activeElement is then
|
|
175
|
+
the host `<vsn-side-bar>`, not body), so existing in-component Escape
|
|
176
|
+
handlers (search input clear-then-close) keep their priority. */
|
|
177
|
+
private _onDocEscape;
|
|
118
178
|
private _onTopBarClick;
|
|
119
179
|
render(): TemplateResult<1>;
|
|
120
180
|
}
|