@gsa-tts/graymatter-ui 0.2.4 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gsa-tts/graymatter-ui",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -56,8 +56,8 @@
56
56
  "vitest": "^3.0.7",
57
57
  "vite": "^6.3.5",
58
58
  "@gsa-tts/graymatter-eslint": "0.0.1",
59
- "@gsa-tts/graymatter-vitest-config": "0.0.1",
60
- "@gsa-tts/graymatter-typescript-config": "0.0.1"
59
+ "@gsa-tts/graymatter-typescript-config": "0.0.1",
60
+ "@gsa-tts/graymatter-vitest-config": "0.0.1"
61
61
  },
62
62
  "dependencies": {
63
63
  "@fontsource-variable/archivo": "^5.2.6",
@@ -2,9 +2,9 @@
2
2
  import { onMount } from 'svelte';
3
3
  /**
4
4
  * Array of menu items to render in the profile menu.
5
- * Each item: { label: string, icon: string, onClick: () => void }
5
+ * Each item: { label: string, icon: string, onClick: string | (() => void) }
6
6
  */
7
- export let menuItems: Array<{ label: string; icon: string; onClick: () => void }> = [];
7
+ export let menuItems: Array<{ label: string; icon: string; onClick: string | (() => void) }> = [];
8
8
  export let userMeta: { initials: string};
9
9
  export let ariaLabel: string = 'Open profile menu';
10
10
  export let menuAlign: 'desktop' | 'mobile' = 'desktop';
@@ -14,6 +14,24 @@
14
14
  function toggleMenu() { menuOpen = !menuOpen; }
15
15
  function closeMenu() { menuOpen = false; }
16
16
 
17
+ // Execute the onClick function - handles both string and function types
18
+ function executeOnClick(onClick: string | (() => void)) {
19
+ try {
20
+ if (typeof onClick === 'string') {
21
+ // Handle string-based function (for Astro apps)
22
+ const onClickFunction = new Function('return ' + onClick)();
23
+ onClickFunction();
24
+ } else if (typeof onClick === 'function') {
25
+ // Handle actual function (for Svelte apps)
26
+ onClick();
27
+ } else {
28
+ console.error('Invalid onClick type:', typeof onClick);
29
+ }
30
+ } catch (error) {
31
+ console.error('Error executing onClick function:', error);
32
+ }
33
+ }
34
+
17
35
  // Optional: close menu on outside click
18
36
  function handleBlur(event: FocusEvent) {
19
37
  const related = event.relatedTarget as HTMLElement | null;
@@ -91,7 +109,7 @@
91
109
  <button
92
110
  type="button"
93
111
  class="menu-item"
94
- on:click={() => { item.onClick(); closeMenu(); }}
112
+ on:click={() => { executeOnClick(item.onClick); closeMenu(); }}
95
113
  bind:this={btns[idx]}
96
114
  on:keydown={(e) => handleMenuKeydown(e, idx)}
97
115
  role="menuitem"
@@ -18,12 +18,11 @@ const {
18
18
  profileMenuData = undefined,
19
19
  logoLinkUrl,
20
20
  logoLinkLabel,
21
+ title: pageTitle,
21
22
  } = Astro.props;
22
-
23
- const title = getPageTitle(Astro);
24
23
  ---
25
24
 
26
- <BaseLayout title={title} gtmID={gtmID}>
25
+ <BaseLayout title={pageTitle} gtmID={gtmID}>
27
26
  <div class="app">
28
27
  <!-- Desktop Navigation -->
29
28
  <div class="layout-container">
@@ -1 +1 @@
1
- export * from './getAppUrls';
1
+ export * from './getAppUrls.js';