@streamscloud/kit 0.29.0 → 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.
@@ -1,12 +1,13 @@
1
1
  <script lang="ts">import { IconSlot } from '../icon';
2
- const { label, icon, href, active = false, disabled = false, badge, target, rel, on } = $props();
2
+ const { label, icon, href, active = false, activeStyle = 'plain', disabled = false, badge, target, rel, on } = $props();
3
+ const activeFilled = $derived(active && activeStyle === 'filled');
3
4
  const badgeText = $derived(typeof badge === 'number' && badge > 99 ? '99+' : badge);
4
5
  const hasBadge = $derived(badge !== undefined && badge !== null && badge !== '');
5
- const handleClick = () => {
6
+ const handleClick = (event) => {
6
7
  if (disabled) {
7
8
  return;
8
9
  }
9
- on?.click?.();
10
+ on?.click?.(event);
10
11
  };
11
12
  </script>
12
13
 
@@ -20,17 +21,16 @@ const handleClick = () => {
20
21
  <span class="nav-menu-item__label">{label}</span>
21
22
  {/snippet}
22
23
 
23
- {#if href}
24
+ {#if href && !disabled}
24
25
  <a
25
26
  class="nav-menu-item"
26
27
  class:nav-menu-item--active={active}
27
- class:nav-menu-item--disabled={disabled}
28
+ class:nav-menu-item--active-filled={activeFilled}
28
29
  href={href}
29
30
  target={target}
30
31
  rel={rel}
31
32
  aria-current={active ? 'page' : undefined}
32
- aria-disabled={disabled || undefined}
33
- tabindex={disabled ? -1 : undefined}>
33
+ onclick={handleClick}>
34
34
  {@render content()}
35
35
  </a>
36
36
  {:else}
@@ -38,6 +38,7 @@ const handleClick = () => {
38
38
  type="button"
39
39
  class="nav-menu-item"
40
40
  class:nav-menu-item--active={active}
41
+ class:nav-menu-item--active-filled={activeFilled}
41
42
  class:nav-menu-item--disabled={disabled}
42
43
  disabled={disabled}
43
44
  aria-current={active ? 'page' : undefined}
@@ -50,8 +51,11 @@ const handleClick = () => {
50
51
  @component
51
52
  NavMenuItem — single row inside a `NavMenuGroup`. Icon + label, optional badge in the top-right of
52
53
  the icon (numbers > 99 truncate to `99+`). The icon accepts an SVG source string or a snippet.
53
- Renders as `<a>` when `href` is set, `<button>` otherwise. Active state is consumer-controlled
54
- (`active` prop) wire it to your router's pathname matching upstream.
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
56
+ (`active` prop) — wire it to your router's pathname matching upstream. `activeStyle` picks how the
57
+ active row reads: `'plain'` (default) leaves color as the only signal and keeps the hover background
58
+ working on the active row, `'filled'` plates it and suppresses hover there.
55
59
 
56
60
  ### CSS Custom Properties
57
61
  | Property | Description | Default |
@@ -63,7 +67,7 @@ Renders as `<a>` when `href` is set, `<button>` otherwise. Active state is consu
63
67
  | `--sc-kit--nav-menu-item--color--active` | Active / hover text color | `--sc-kit--color--text--primary` |
64
68
  | `--sc-kit--nav-menu-item--color--disabled` | Disabled text color | `--sc-kit--color--text--muted` |
65
69
  | `--sc-kit--nav-menu-item--background--hover` | Hover background | `--sc-kit--color--bg--hover` |
66
- | `--sc-kit--nav-menu-item--background--active` | Active background | `--sc-kit--color--bg--menu-active` |
70
+ | `--sc-kit--nav-menu-item--background--active` | Active background — `activeStyle="filled"` only | `--sc-kit--color--bg--menu-active` |
67
71
  | `--sc-kit--nav-menu-item--badge--background` | Badge background | `--sc-kit--color--accent` |
68
72
  | `--sc-kit--nav-menu-item--badge--color` | Badge text color | `--sc-kit--color--text--on-accent` |
69
73
  -->
@@ -93,13 +97,13 @@ Renders as `<a>` when `href` is set, `<button>` otherwise. Active state is consu
93
97
  text-align: left;
94
98
  transition: color var(--sc-kit--duration--base) var(--sc-kit--ease--default), background-color var(--sc-kit--duration--base) var(--sc-kit--ease--default);
95
99
  }
96
- .nav-menu-item:hover:not(.nav-menu-item--active):not(.nav-menu-item--disabled):not(:disabled) {
100
+ .nav-menu-item:hover:not(.nav-menu-item--active-filled):not(.nav-menu-item--disabled):not(:disabled) {
97
101
  background: var(--_nav-menu-item--background-hover);
98
102
  }
99
103
  .nav-menu-item:hover:not(.nav-menu-item--disabled):not(:disabled), .nav-menu-item--active {
100
104
  color: var(--_nav-menu-item--color-active);
101
105
  }
102
- .nav-menu-item--active {
106
+ .nav-menu-item--active-filled {
103
107
  background: var(--_nav-menu-item--background-active);
104
108
  }
105
109
  .nav-menu-item--disabled, .nav-menu-item:disabled {
@@ -3,10 +3,12 @@ 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;
10
+ /** Active row visuals — `'plain'` uses color only and keeps hover, `'filled'` paints the active background (no hover on it). @default 'plain' */
11
+ activeStyle?: 'filled' | 'plain';
10
12
  disabled?: boolean;
11
13
  /** Notification badge on the icon (top-right corner). Numbers > 99 render as `99+`; strings render as-is. */
12
14
  badge?: number | string;
@@ -15,14 +17,17 @@ type Props = {
15
17
  /** Anchor rel — only relevant when `href` is set. */
16
18
  rel?: string;
17
19
  on?: {
18
- click?: () => void;
20
+ click?: (event: MouseEvent) => void;
19
21
  };
20
22
  };
21
23
  /**
22
24
  * NavMenuItem — single row inside a `NavMenuGroup`. Icon + label, optional badge in the top-right of
23
25
  * the icon (numbers > 99 truncate to `99+`). The icon accepts an SVG source string or a snippet.
24
- * Renders as `<a>` when `href` is set, `<button>` otherwise. Active state is consumer-controlled
25
- * (`active` prop) wire it to your router's pathname matching upstream.
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
28
+ * (`active` prop) — wire it to your router's pathname matching upstream. `activeStyle` picks how the
29
+ * active row reads: `'plain'` (default) leaves color as the only signal and keeps the hover background
30
+ * working on the active row, `'filled'` plates it and suppresses hover there.
26
31
  *
27
32
  * ### CSS Custom Properties
28
33
  * | Property | Description | Default |
@@ -34,7 +39,7 @@ type Props = {
34
39
  * | `--sc-kit--nav-menu-item--color--active` | Active / hover text color | `--sc-kit--color--text--primary` |
35
40
  * | `--sc-kit--nav-menu-item--color--disabled` | Disabled text color | `--sc-kit--color--text--muted` |
36
41
  * | `--sc-kit--nav-menu-item--background--hover` | Hover background | `--sc-kit--color--bg--hover` |
37
- * | `--sc-kit--nav-menu-item--background--active` | Active background | `--sc-kit--color--bg--menu-active` |
42
+ * | `--sc-kit--nav-menu-item--background--active` | Active background — `activeStyle="filled"` only | `--sc-kit--color--bg--menu-active` |
38
43
  * | `--sc-kit--nav-menu-item--badge--background` | Badge background | `--sc-kit--color--accent` |
39
44
  * | `--sc-kit--nav-menu-item--badge--color` | Badge text color | `--sc-kit--color--text--on-accent` |
40
45
  */
@@ -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.0",
3
+ "version": "0.30.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",