@streamscloud/kit 0.29.1 → 0.30.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.
@@ -3,11 +3,11 @@ const { label, icon, href, active = false, activeStyle = 'plain', disabled = fal
3
3
  const activeFilled = $derived(active && activeStyle === 'filled');
4
4
  const badgeText = $derived(typeof badge === 'number' && badge > 99 ? '99+' : badge);
5
5
  const hasBadge = $derived(badge !== undefined && badge !== null && badge !== '');
6
- const handleClick = () => {
6
+ const handleClick = (event) => {
7
7
  if (disabled) {
8
8
  return;
9
9
  }
10
- on?.click?.();
10
+ on?.click?.(event);
11
11
  };
12
12
  </script>
13
13
 
@@ -21,18 +21,16 @@ const handleClick = () => {
21
21
  <span class="nav-menu-item__label">{label}</span>
22
22
  {/snippet}
23
23
 
24
- {#if href}
24
+ {#if href && !disabled}
25
25
  <a
26
26
  class="nav-menu-item"
27
27
  class:nav-menu-item--active={active}
28
28
  class:nav-menu-item--active-filled={activeFilled}
29
- class:nav-menu-item--disabled={disabled}
30
29
  href={href}
31
30
  target={target}
32
31
  rel={rel}
33
32
  aria-current={active ? 'page' : undefined}
34
- aria-disabled={disabled || undefined}
35
- tabindex={disabled ? -1 : undefined}>
33
+ onclick={handleClick}>
36
34
  {@render content()}
37
35
  </a>
38
36
  {:else}
@@ -53,7 +51,8 @@ const handleClick = () => {
53
51
  @component
54
52
  NavMenuItem — single row inside a `NavMenuGroup`. Icon + label, optional badge in the top-right of
55
53
  the icon (numbers > 99 truncate to `99+`). The icon accepts an SVG source string or a snippet.
56
- Renders as `<a>` when `href` is set, `<button>` otherwise. Active state is consumer-controlled
54
+ Renders as `<a>` when `href` is set and enabled, `<button>` otherwise; `on.click` fires in both forms
55
+ with the `MouseEvent` and the link default is left intact. Active state is consumer-controlled
57
56
  (`active` prop) — wire it to your router's pathname matching upstream. `activeStyle` picks how the
58
57
  active row reads: `'plain'` (default) leaves color as the only signal and keeps the hover background
59
58
  working on the active row, `'filled'` plates it and suppresses hover there.
@@ -3,7 +3,7 @@ type Props = {
3
3
  label: string;
4
4
  /** Icon — string SVG source, `{ src, color?, size? }` object, or custom snippet. */
5
5
  icon: IconProp;
6
- /** Render as `<a href>`. Mutually exclusive with `on.click`. */
6
+ /** Render as `<a href>` unless `disabled`, which falls back to the button form. `on.click` still fires; `event.preventDefault()` keeps the click from navigating. */
7
7
  href?: string;
8
8
  /** Highlight as the current item. Consumer-controlled. @default false */
9
9
  active?: boolean;
@@ -17,13 +17,14 @@ type Props = {
17
17
  /** Anchor rel — only relevant when `href` is set. */
18
18
  rel?: string;
19
19
  on?: {
20
- click?: () => void;
20
+ click?: (event: MouseEvent) => void;
21
21
  };
22
22
  };
23
23
  /**
24
24
  * NavMenuItem — single row inside a `NavMenuGroup`. Icon + label, optional badge in the top-right of
25
25
  * the icon (numbers > 99 truncate to `99+`). The icon accepts an SVG source string or a snippet.
26
- * Renders as `<a>` when `href` is set, `<button>` otherwise. Active state is consumer-controlled
26
+ * Renders as `<a>` when `href` is set and enabled, `<button>` otherwise; `on.click` fires in both forms
27
+ * with the `MouseEvent` and the link default is left intact. Active state is consumer-controlled
27
28
  * (`active` prop) — wire it to your router's pathname matching upstream. `activeStyle` picks how the
28
29
  * active row reads: `'plain'` (default) leaves color as the only signal and keeps the hover background
29
30
  * working on the active row, `'filled'` plates it and suppresses hover there.
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">import { IconSlot } from '../icon';
2
2
  const { label, icon, href, active = false, error = false, disabled = false, target, rel, on } = $props();
3
- const handleClick = () => {
3
+ const handleClick = (event) => {
4
4
  if (disabled) {
5
5
  return;
6
6
  }
7
- on?.click?.();
7
+ on?.click?.(event);
8
8
  };
9
9
  </script>
10
10
 
@@ -13,18 +13,16 @@ const handleClick = () => {
13
13
  <span class="nav-rail-item__label">{label}</span>
14
14
  {/snippet}
15
15
 
16
- {#if href}
16
+ {#if href && !disabled}
17
17
  <a
18
18
  class="nav-rail-item"
19
19
  class:nav-rail-item--active={active}
20
20
  class:nav-rail-item--error={error}
21
- class:nav-rail-item--disabled={disabled}
22
21
  href={href}
23
22
  target={target}
24
23
  rel={rel}
25
24
  aria-current={active ? 'page' : undefined}
26
- aria-disabled={disabled || undefined}
27
- tabindex={disabled ? -1 : undefined}>
25
+ onclick={handleClick}>
28
26
  {@render tile()}
29
27
  </a>
30
28
  {:else}
@@ -43,8 +41,9 @@ const handleClick = () => {
43
41
 
44
42
  <!--
45
43
  @component
46
- NavRailItem — one icon-and-label tile inside a `NavRail`. Renders as `<a>` when `href` is set,
47
- `<button>` otherwise. Active state is consumer-controlled (`active` prop). The icon accepts an SVG
44
+ NavRailItem — one icon-and-label tile inside a `NavRail`. Renders as `<a>` when `href` is set and
45
+ enabled, `<button>` otherwise; `on.click` fires in both forms with the `MouseEvent` and the link
46
+ default is left intact. Active state is consumer-controlled (`active` prop). The icon accepts an SVG
48
47
  source string or a snippet. Tile dimensions are controlled via the `--sc-kit--nav-rail--item-*`
49
48
  CSS variables (settable on the parent rail or any ancestor).
50
49
 
@@ -3,7 +3,7 @@ type Props = {
3
3
  label: string;
4
4
  /** Icon — string SVG source, `{ src, color?, size? }` object, or custom snippet. */
5
5
  icon: IconProp;
6
- /** Render as `<a href>`. Mutually exclusive with `on.click`. */
6
+ /** Render as `<a href>` unless `disabled`, which falls back to the button form. `on.click` still fires; `event.preventDefault()` keeps the click from navigating. */
7
7
  href?: string;
8
8
  /** Highlight as the current section. Consumer-controlled. @default false */
9
9
  active?: boolean;
@@ -15,12 +15,13 @@ type Props = {
15
15
  /** Anchor rel — only relevant when `href` is set. */
16
16
  rel?: string;
17
17
  on?: {
18
- click?: () => void;
18
+ click?: (event: MouseEvent) => void;
19
19
  };
20
20
  };
21
21
  /**
22
- * NavRailItem — one icon-and-label tile inside a `NavRail`. Renders as `<a>` when `href` is set,
23
- * `<button>` otherwise. Active state is consumer-controlled (`active` prop). The icon accepts an SVG
22
+ * NavRailItem — one icon-and-label tile inside a `NavRail`. Renders as `<a>` when `href` is set and
23
+ * enabled, `<button>` otherwise; `on.click` fires in both forms with the `MouseEvent` and the link
24
+ * default is left intact. Active state is consumer-controlled (`active` prop). The icon accepts an SVG
24
25
  * source string or a snippet. Tile dimensions are controlled via the `--sc-kit--nav-rail--item-*`
25
26
  * CSS variables (settable on the parent rail or any ancestor).
26
27
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.29.1",
3
+ "version": "0.30.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",