@visma-swno/vsn-navigation 1.1.0-beta.3 → 1.1.0-beta.30
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 +148 -26
- package/dist/assets/vsn-navigation.js +2891 -36
- package/dist/custom-elements.json +1 -0
- package/package.json +13 -6
|
@@ -1,43 +1,124 @@
|
|
|
1
|
-
import { AppModules } from '../shared/types/index.ts';
|
|
2
1
|
import { CSSResult } from 'lit';
|
|
3
|
-
import { FeedbackConfig } from '../shared/types/index.ts';
|
|
4
|
-
import { isTreeLeaf } from '../shared/types/index.ts';
|
|
5
|
-
import { isTreeParent } from '../shared/types/index.ts';
|
|
6
|
-
import { LanguageCode } from '../shared/types/index.ts';
|
|
7
2
|
import { LitElement } from 'lit';
|
|
8
|
-
import { ModuleItem } from '../shared/types/index.ts';
|
|
9
|
-
import { NavigationMenu } from '../shared/types/index.ts';
|
|
10
|
-
import { SearchConfig } from '../shared/types/index.ts';
|
|
11
3
|
import { TemplateResult } from 'lit-html';
|
|
12
|
-
import { TreeItem } from '../shared/types/index.ts';
|
|
13
|
-
import { TreeLeaf } from '../shared/types/index.ts';
|
|
14
|
-
import { TreeParent } from '../shared/types/index.ts';
|
|
15
|
-
import { VsnAuth } from '../shared/types/index.ts';
|
|
16
|
-
import { VsnNavigation } from '../shared/types/index.ts';
|
|
17
4
|
|
|
18
|
-
export
|
|
5
|
+
export declare type AppModules = {
|
|
6
|
+
/** Current module id (to be ignored from the list of modules) */
|
|
7
|
+
activeModuleId: string;
|
|
8
|
+
/** Current module label — shown before the modules list is asynchronously loaded */
|
|
9
|
+
activeModuleLabel: string;
|
|
10
|
+
/** Modules, or a loader for the modules */
|
|
11
|
+
modules: ModuleItem[] | (() => Promise<ModuleItem[]>);
|
|
12
|
+
};
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
declare type BaseTreeItem = {
|
|
15
|
+
/** id of the item, unique */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The label to show for that item, in the relevant language */
|
|
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
|
+
};
|
|
21
22
|
|
|
22
|
-
export
|
|
23
|
+
export declare type ButtonClickedEvent = {
|
|
24
|
+
/** The clicked HTMLButtonElement. Can be used as an anchor to position popups. */
|
|
25
|
+
target: HTMLButtonElement;
|
|
26
|
+
};
|
|
23
27
|
|
|
24
|
-
export
|
|
28
|
+
export declare type FeedbackConfig = {
|
|
29
|
+
workspaceId: string;
|
|
30
|
+
surveyId: string;
|
|
31
|
+
};
|
|
25
32
|
|
|
26
|
-
export
|
|
33
|
+
export declare function isTreeLeaf(item: TreeItem): item is TreeLeaf;
|
|
27
34
|
|
|
28
|
-
export
|
|
35
|
+
export declare function isTreeParent(item: TreeItem): item is TreeParent;
|
|
29
36
|
|
|
30
|
-
|
|
37
|
+
/** Supported languages. Note: 'nb' and 'nn' are automatically mapped to 'no'. Non-supported languages will default to 'en' */
|
|
38
|
+
export declare type LanguageCode = 'en' | 'no' | 'nb' | 'nn' | 'sv' | 'nl' | 'fi' | 'da';
|
|
31
39
|
|
|
32
|
-
export
|
|
40
|
+
export declare type ModuleItem = {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
url: string;
|
|
44
|
+
};
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
/** Configuration for the navigation menu (pages in current module) */
|
|
47
|
+
export declare type NavigationMenu = {
|
|
48
|
+
/** The list of items to show in the side menu and the breadcrumbs. Applications can
|
|
49
|
+
update it at any time, e.g. when the context changes, when the language changes */
|
|
50
|
+
items: TreeItem[];
|
|
51
|
+
/** the item id corresponding to the current page. When it's found in items,
|
|
52
|
+
the breadcrumbs will update to reflect the path to the item and side menu will
|
|
53
|
+
expand and select that item. When it's not found in items, breadcrumbs will show
|
|
54
|
+
nothing and the side menu will have no element selected */
|
|
55
|
+
currentItem: string;
|
|
56
|
+
/** Optionally set the current page title. This will be shown as the last item in the breadcrumbs */
|
|
57
|
+
pageTitle?: string;
|
|
58
|
+
/** Sidebar search config; default disabled when undefined */
|
|
59
|
+
search?: SearchConfig;
|
|
60
|
+
};
|
|
35
61
|
|
|
36
|
-
|
|
62
|
+
declare type NonEmptyArray<T> = [T, ...T[]];
|
|
37
63
|
|
|
38
|
-
export
|
|
64
|
+
export declare type SearchConfig = {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
shortcut?: string;
|
|
67
|
+
extraDataSets?: SearchDataSetConfig[];
|
|
68
|
+
};
|
|
39
69
|
|
|
40
|
-
export
|
|
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];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export declare type TreeItem = TreeParent | TreeLeaf;
|
|
101
|
+
|
|
102
|
+
export declare type TreeLeaf = BaseTreeItem & {
|
|
103
|
+
url: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export declare type TreeParent = BaseTreeItem & {
|
|
107
|
+
items: NonEmptyArray<TreeItem>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
declare type User = {
|
|
111
|
+
userId: string;
|
|
112
|
+
clientId?: string;
|
|
113
|
+
userName: string;
|
|
114
|
+
userEmail: string;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export declare type VsnAuth = {
|
|
118
|
+
user: User;
|
|
119
|
+
profilePictureBaseUrl: string;
|
|
120
|
+
myProfileUrl: string;
|
|
121
|
+
};
|
|
41
122
|
|
|
42
123
|
export declare class VSNNavigation extends LitElement {
|
|
43
124
|
/** Language to use for the component's labels (Search, Log out, etc) */
|
|
@@ -65,6 +146,10 @@ export declare class VSNNavigation extends LitElement {
|
|
|
65
146
|
private _resolvedModules;
|
|
66
147
|
private _modulesLoading;
|
|
67
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;
|
|
68
153
|
private _resolveModules;
|
|
69
154
|
static styles: CSSResult[];
|
|
70
155
|
willUpdate(changed: Map<string, unknown>): void;
|
|
@@ -73,11 +158,48 @@ export declare class VSNNavigation extends LitElement {
|
|
|
73
158
|
/** Project tree into the shape the side-bar expects: top-level items lifted from the active module. */
|
|
74
159
|
private get _sideBarMenu();
|
|
75
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;
|
|
76
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;
|
|
77
178
|
private _onTopBarClick;
|
|
78
179
|
render(): TemplateResult<1>;
|
|
79
180
|
}
|
|
80
181
|
|
|
81
|
-
export
|
|
182
|
+
export declare type VsnNavigation = {
|
|
183
|
+
/** Language to use for the component's labels (Search, Log out, etc) */
|
|
184
|
+
lang?: LanguageCode;
|
|
185
|
+
/** Link to landing page */
|
|
186
|
+
landingPageUrl?: string;
|
|
187
|
+
/** Configuration for the navigation menu (pages in current module) */
|
|
188
|
+
tree?: NavigationMenu;
|
|
189
|
+
/** Configuration for the module switcher */
|
|
190
|
+
modules?: AppModules;
|
|
191
|
+
/** Show help icon */
|
|
192
|
+
showHelp?: boolean;
|
|
193
|
+
/** Use a fixed url for link to help */
|
|
194
|
+
helpUrl?: string;
|
|
195
|
+
/** Show notification icon */
|
|
196
|
+
showNotification?: boolean;
|
|
197
|
+
/** Notification icon shows active state */
|
|
198
|
+
notificationActive?: boolean;
|
|
199
|
+
/** Configuration related to authenticated user */
|
|
200
|
+
auth?: VsnAuth;
|
|
201
|
+
/** Configuration for the feedback component */
|
|
202
|
+
feedback?: FeedbackConfig | null;
|
|
203
|
+
};
|
|
82
204
|
|
|
83
205
|
export { }
|