@wentools/overlay 0.1.0 → 0.1.1

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": "@wentools/overlay",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Svelte 5 popover, dropdown menu, and tooltip components with CSS custom property theming",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -91,7 +91,7 @@ Perfect for: context menus, action menus, navigation dropdowns.
91
91
 
92
92
  const getMenuItems = (): HTMLElement[] => {
93
93
  if (!menuElement) return []
94
- return Array.from(menuElement.querySelectorAll('[role="menuitem"]:not([disabled])'))
94
+ return Array.from(menuElement.querySelectorAll('[role="menuitem"]:not([disabled]):not([aria-disabled="true"])'))
95
95
  }
96
96
 
97
97
  const focusItem = (index: number) => {
@@ -5,7 +5,9 @@ MenuItem - Individual menu item for DropdownMenu
5
5
  A styled menu item that works with DropdownMenu's keyboard navigation.
6
6
  Follows ARIA menuitem patterns and integrates with focus management.
7
7
 
8
- Perfect for: actions in dropdown menus, selectable options.
8
+ Renders as a `<button>` by default, or as an `<a>` when `href` is provided.
9
+
10
+ Perfect for: actions in dropdown menus, selectable options, navigation links.
9
11
 
10
12
  @example
11
13
  ```svelte
@@ -13,6 +15,10 @@ Perfect for: actions in dropdown menus, selectable options.
13
15
  Delete Item
14
16
  </MenuItem>
15
17
 
18
+ <MenuItem href="/settings">
19
+ Settings
20
+ </MenuItem>
21
+
16
22
  <MenuItem disabled>
17
23
  Unavailable Action
18
24
  </MenuItem>
@@ -28,6 +34,8 @@ Perfect for: actions in dropdown menus, selectable options.
28
34
  highlighted?: boolean
29
35
  /** Color theme for special items (e.g., 'var(--blue-ch)' for create, 'var(--red-ch)' for destructive) */
30
36
  color?: string
37
+ /** Navigate to URL — renders as <a> instead of <button> */
38
+ href?: string
31
39
  /** Click handler */
32
40
  onclick?: () => void
33
41
  /** CSS class for styling */
@@ -40,28 +48,50 @@ Perfect for: actions in dropdown menus, selectable options.
40
48
  disabled = false,
41
49
  highlighted = false,
42
50
  color,
51
+ href,
43
52
  onclick,
44
53
  class: className = '',
45
54
  children,
46
55
  }: Props = $props()
47
56
  </script>
48
57
 
49
- <button
50
- class="menu-item {className}"
51
- class:highlighted
52
- class:disabled
53
- {disabled}
54
- role="menuitem"
55
- tabindex="-1"
56
- style:--item-color={color}
57
- onclick={() => {
58
- if (!disabled) {
58
+ {#if href}
59
+ <a
60
+ href={disabled ? undefined : href}
61
+ class="menu-item {className}"
62
+ class:highlighted
63
+ class:disabled
64
+ role="menuitem"
65
+ tabindex="-1"
66
+ aria-disabled={disabled}
67
+ style:--item-color={color}
68
+ onclick={(e) => {
69
+ if (disabled) {
70
+ e.preventDefault()
71
+ }
59
72
  onclick?.()
60
- }
61
- }}
62
- >
63
- {@render children()}
64
- </button>
73
+ }}
74
+ >
75
+ {@render children()}
76
+ </a>
77
+ {:else}
78
+ <button
79
+ class="menu-item {className}"
80
+ class:highlighted
81
+ class:disabled
82
+ {disabled}
83
+ role="menuitem"
84
+ tabindex="-1"
85
+ style:--item-color={color}
86
+ onclick={() => {
87
+ if (!disabled) {
88
+ onclick?.()
89
+ }
90
+ }}
91
+ >
92
+ {@render children()}
93
+ </button>
94
+ {/if}
65
95
 
66
96
  <style>
67
97
  .menu-item {
@@ -77,6 +107,8 @@ Perfect for: actions in dropdown menus, selectable options.
77
107
  text-align: left;
78
108
  cursor: pointer;
79
109
  color: inherit;
110
+ text-decoration: none;
111
+ font: inherit;
80
112
  transition: background-color 0.2s ease;
81
113
  }
82
114