@gsa-tts/graymatter-ui 0.4.10 → 0.4.12
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/graymatter-ui.js +1763 -1751
- package/dist/graymatter-ui.umd.cjs +6 -6
- package/package.json +1 -1
- package/src/components/DesktopHeader.svelte +1 -3
- package/src/components/DesktopSideNav.svelte +42 -25
- package/src/components/MobileBottomNav.svelte +1 -1
- package/src/components/MobileTopNav.svelte +44 -33
- package/src/layouts/GlobalAppLayout.astro +2 -1
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
selectedSubNavItemTitle,
|
|
6
6
|
} from '../stores/navigationStore.js';
|
|
7
7
|
import { onMount } from 'svelte';
|
|
8
|
-
import { subNavReady } from '../stores/subNavReadyStore';
|
|
9
8
|
|
|
10
9
|
const { customHeaderText = '' } = $props();
|
|
11
10
|
|
|
@@ -16,8 +15,7 @@
|
|
|
16
15
|
$selectedItem &&
|
|
17
16
|
$selectedItem !== 'discover' &&
|
|
18
17
|
!$isExpanded &&
|
|
19
|
-
!isLayoutTransitioning
|
|
20
|
-
$subNavReady
|
|
18
|
+
!isLayoutTransitioning
|
|
21
19
|
);
|
|
22
20
|
const headerText = $derived(
|
|
23
21
|
() => customHeaderText || $selectedSubNavItemTitle
|
|
@@ -11,10 +11,8 @@
|
|
|
11
11
|
selectedItem,
|
|
12
12
|
isMenuButtonDisabled,
|
|
13
13
|
navigationStore,
|
|
14
|
-
selectedSubNavItemId,
|
|
15
14
|
type NavigationItem,
|
|
16
15
|
} from '../stores/navigationStore.js';
|
|
17
|
-
import { get } from 'svelte/store';
|
|
18
16
|
import DiscoverIcon from './icons/DiscoverIcon.svelte';
|
|
19
17
|
import ChatIcon from './icons/ChatIcon.svelte';
|
|
20
18
|
import ConsoleIcon from './icons/ConsoleIcon.svelte';
|
|
@@ -38,7 +36,31 @@
|
|
|
38
36
|
} = $props();
|
|
39
37
|
|
|
40
38
|
const helpUrl = supplementalMenuData?.help?.url?.trim();
|
|
41
|
-
|
|
39
|
+
|
|
40
|
+
// Check if we're on the help page by comparing URLs (help is not a nav/subnav item)
|
|
41
|
+
function getPathname(url: string, baseOrigin: string) {
|
|
42
|
+
try {
|
|
43
|
+
return new URL(url, baseOrigin).pathname;
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function checkIsHelpPage(): boolean {
|
|
50
|
+
if (!helpUrl || helpUrl === '#' || helpUrl.startsWith('#')) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const location = (
|
|
54
|
+
globalThis as { location?: { pathname?: string; origin?: string } }
|
|
55
|
+
).location;
|
|
56
|
+
if (location?.origin && location?.pathname) {
|
|
57
|
+
const helpPath = getPathname(helpUrl, location.origin);
|
|
58
|
+
return helpPath !== null && location.pathname === helpPath;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const isHelpSelected = $derived(checkIsHelpPage());
|
|
42
64
|
|
|
43
65
|
let hydrated = false;
|
|
44
66
|
let navContainer: HTMLDivElement;
|
|
@@ -170,38 +192,33 @@
|
|
|
170
192
|
);
|
|
171
193
|
};
|
|
172
194
|
|
|
195
|
+
// Listen for navigation changes to update help button state
|
|
196
|
+
const handleNavigationChange = () => {
|
|
197
|
+
// Force reactivity update by accessing the derived value
|
|
198
|
+
// Accessing isHelpSelected triggers reactivity
|
|
199
|
+
void isHelpSelected;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
window.addEventListener('popstate', handleNavigationChange);
|
|
203
|
+
|
|
173
204
|
return () => {
|
|
174
205
|
window.removeEventListener('layoutTransition', handleLayoutTransition);
|
|
175
206
|
window.removeEventListener('keydown', handleEscape);
|
|
207
|
+
window.removeEventListener('popstate', handleNavigationChange);
|
|
176
208
|
if (eventListenerCleanup) {
|
|
177
209
|
eventListenerCleanup();
|
|
178
210
|
}
|
|
179
211
|
};
|
|
180
212
|
}
|
|
181
|
-
|
|
182
|
-
const location = (
|
|
183
|
-
globalThis as { location?: { pathname?: string; origin?: string } }
|
|
184
|
-
).location;
|
|
185
|
-
if (helpUrl && location?.origin && location?.pathname) {
|
|
186
|
-
const helpPath = getPathname(helpUrl, location.origin);
|
|
187
|
-
if (helpPath && location.pathname === helpPath) {
|
|
188
|
-
selectedSubNavItemId.set('help');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
213
|
});
|
|
192
214
|
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return null;
|
|
215
|
+
function handleHelpClick(event: MouseEvent) {
|
|
216
|
+
// If it's a hash link, prevent default to stay on same page
|
|
217
|
+
if (helpUrl === '#' || helpUrl?.startsWith('#')) {
|
|
218
|
+
event.preventDefault();
|
|
198
219
|
}
|
|
199
220
|
}
|
|
200
221
|
|
|
201
|
-
function handleHelpClick() {
|
|
202
|
-
selectedSubNavItemId.set('help');
|
|
203
|
-
}
|
|
204
|
-
|
|
205
222
|
function toggleNav() {
|
|
206
223
|
if ($isMenuButtonDisabled) return;
|
|
207
224
|
navigationStore.toggleExpanded();
|
|
@@ -460,8 +477,8 @@
|
|
|
460
477
|
>
|
|
461
478
|
<a
|
|
462
479
|
class="help-link"
|
|
463
|
-
class:selected={isHelpSelected
|
|
464
|
-
aria-current={isHelpSelected
|
|
480
|
+
class:selected={isHelpSelected}
|
|
481
|
+
aria-current={isHelpSelected ? 'page' : undefined}
|
|
465
482
|
href={helpUrl}
|
|
466
483
|
part="help-link"
|
|
467
484
|
title="Help"
|
|
@@ -470,7 +487,7 @@
|
|
|
470
487
|
>
|
|
471
488
|
<div class="icon-container" part="help-icon-container">
|
|
472
489
|
<div class="icon-wrapper">
|
|
473
|
-
<HelpIcon isSelected={isHelpSelected
|
|
490
|
+
<HelpIcon isSelected={isHelpSelected} />
|
|
474
491
|
</div>
|
|
475
492
|
</div>
|
|
476
493
|
</a>
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
isMenuButtonDisabled,
|
|
4
4
|
navigationStore,
|
|
5
5
|
selectedSubNavItemTitle,
|
|
6
|
-
selectedSubNavItemId,
|
|
7
6
|
} from '../stores/navigationStore.js';
|
|
8
7
|
import Logo from './Logo.svelte';
|
|
9
8
|
import MenuIcon from './icons/MenuIcon.svelte';
|
|
10
9
|
import HelpIcon from './icons/HelpIcon.svelte';
|
|
11
10
|
import { onMount } from 'svelte';
|
|
12
|
-
import { get } from 'svelte/store';
|
|
13
11
|
|
|
14
12
|
let { profileMenuData, logoLinkUrl, logoLinkLabel, supplementalMenuData } =
|
|
15
13
|
$props();
|
|
@@ -17,14 +15,37 @@
|
|
|
17
15
|
import ProfileMenu from './ProfileMenu.svelte';
|
|
18
16
|
|
|
19
17
|
const helpUrl = supplementalMenuData?.help?.url?.trim();
|
|
20
|
-
|
|
18
|
+
|
|
19
|
+
// Check if we're on the help page by comparing URLs (help is not a nav/subnav item)
|
|
20
|
+
function getPathname(url: string, baseOrigin: string) {
|
|
21
|
+
try {
|
|
22
|
+
return new URL(url, baseOrigin).pathname;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function checkIsHelpPage(): boolean {
|
|
29
|
+
if (!helpUrl || helpUrl === '#' || helpUrl.startsWith('#')) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const location = (
|
|
33
|
+
globalThis as {
|
|
34
|
+
location?: { pathname?: string; origin?: string };
|
|
35
|
+
}
|
|
36
|
+
).location;
|
|
37
|
+
if (location?.origin && location?.pathname) {
|
|
38
|
+
const helpPath = getPathname(helpUrl, location.origin);
|
|
39
|
+
return helpPath !== null && location.pathname === helpPath;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const isHelpSelected = $derived(checkIsHelpPage());
|
|
21
45
|
|
|
22
46
|
onMount(() => {
|
|
23
47
|
// Listen for section visibility changes to update header
|
|
24
48
|
const handleSectionVisible = (event: Event) => {
|
|
25
|
-
if (window.innerWidth <= 640) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
49
|
const customEvent = event as CustomEvent;
|
|
29
50
|
if (customEvent.detail && customEvent.detail.title) {
|
|
30
51
|
selectedSubNavItemTitle.set(customEvent.detail.title);
|
|
@@ -74,39 +95,29 @@
|
|
|
74
95
|
}, 100);
|
|
75
96
|
}
|
|
76
97
|
|
|
98
|
+
// Listen for navigation changes to update help button state
|
|
99
|
+
const handleNavigationChange = () => {
|
|
100
|
+
// Force reactivity update by accessing the derived value
|
|
101
|
+
void isHelpSelected;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
window.addEventListener('popstate', handleNavigationChange);
|
|
105
|
+
|
|
77
106
|
return () => {
|
|
78
107
|
window.removeEventListener('sectionVisible', handleSectionVisible);
|
|
108
|
+
window.removeEventListener('popstate', handleNavigationChange);
|
|
79
109
|
};
|
|
80
110
|
});
|
|
81
111
|
|
|
82
|
-
onMount(() => {
|
|
83
|
-
const location = (
|
|
84
|
-
globalThis as {
|
|
85
|
-
location?: { pathname?: string; origin?: string };
|
|
86
|
-
}
|
|
87
|
-
).location;
|
|
88
|
-
if (helpUrl && location?.origin && location?.pathname) {
|
|
89
|
-
const helpPath = getPathname(helpUrl, location.origin);
|
|
90
|
-
if (helpPath && location.pathname === helpPath) {
|
|
91
|
-
selectedSubNavItemId.set('help');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
function getPathname(url: string, baseOrigin: string) {
|
|
97
|
-
try {
|
|
98
|
-
return new URL(url, baseOrigin).pathname;
|
|
99
|
-
} catch {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
112
|
function toggleMobileNav() {
|
|
105
113
|
navigationStore.toggleExpanded();
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
function handleHelpClick() {
|
|
109
|
-
|
|
116
|
+
function handleHelpClick(event: MouseEvent) {
|
|
117
|
+
// If it's a hash link, prevent default to stay on same page
|
|
118
|
+
if (helpUrl === '#' || helpUrl?.startsWith('#')) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
}
|
|
110
121
|
}
|
|
111
122
|
</script>
|
|
112
123
|
|
|
@@ -137,15 +148,15 @@
|
|
|
137
148
|
{#if helpUrl}
|
|
138
149
|
<a
|
|
139
150
|
class="help-button"
|
|
140
|
-
class:selected={isHelpSelected
|
|
141
|
-
aria-current={isHelpSelected
|
|
151
|
+
class:selected={isHelpSelected}
|
|
152
|
+
aria-current={isHelpSelected ? 'page' : undefined}
|
|
142
153
|
href={helpUrl}
|
|
143
154
|
title="Help"
|
|
144
155
|
aria-label="Help"
|
|
145
156
|
onclick={handleHelpClick}
|
|
146
157
|
>
|
|
147
158
|
<span class="icon-container">
|
|
148
|
-
<HelpIcon isSelected={isHelpSelected
|
|
159
|
+
<HelpIcon isSelected={isHelpSelected} />
|
|
149
160
|
</span>
|
|
150
161
|
</a>
|
|
151
162
|
{/if}
|
|
@@ -77,6 +77,7 @@ const discover = discoverUrl || '#';
|
|
|
77
77
|
profileMenuData={profileMenuData}
|
|
78
78
|
logoLinkUrl={logoLinkUrl}
|
|
79
79
|
logoLinkLabel={logoLinkLabel}
|
|
80
|
+
{supplementalMenuData}
|
|
80
81
|
/>
|
|
81
82
|
<MobileSideMenu client:load {logoLinkUrl} {logoLinkLabel}>
|
|
82
83
|
<slot name="sub-nav" />
|
|
@@ -87,7 +88,7 @@ const discover = discoverUrl || '#';
|
|
|
87
88
|
hideDiscover={hideDiscover}
|
|
88
89
|
apiUrl={api}
|
|
89
90
|
chatUrl={chat}
|
|
90
|
-
consoleUrl={
|
|
91
|
+
consoleUrl={consoleApp}
|
|
91
92
|
discoverUrl={discover}
|
|
92
93
|
/>
|
|
93
94
|
</nav>
|