@vaadin/side-nav 25.0.0-alpha2 → 25.0.0-alpha4

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": "@vaadin/side-nav",
3
- "version": "25.0.0-alpha2",
3
+ "version": "25.0.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,6 +21,8 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
+ "!src/styles/*-base-styles.d.ts",
25
+ "!src/styles/*-base-styles.js",
24
26
  "theme",
25
27
  "vaadin-*.d.ts",
26
28
  "vaadin-*.js",
@@ -35,15 +37,15 @@
35
37
  ],
36
38
  "dependencies": {
37
39
  "@open-wc/dedupe-mixin": "^1.3.0",
38
- "@vaadin/a11y-base": "25.0.0-alpha2",
39
- "@vaadin/component-base": "25.0.0-alpha2",
40
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha2",
41
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha2",
40
+ "@vaadin/a11y-base": "25.0.0-alpha4",
41
+ "@vaadin/component-base": "25.0.0-alpha4",
42
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha4",
43
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha4",
42
44
  "lit": "^3.0.0"
43
45
  },
44
46
  "devDependencies": {
45
- "@vaadin/chai-plugins": "25.0.0-alpha2",
46
- "@vaadin/test-runner-commands": "25.0.0-alpha2",
47
+ "@vaadin/chai-plugins": "25.0.0-alpha4",
48
+ "@vaadin/test-runner-commands": "25.0.0-alpha4",
47
49
  "@vaadin/testing-helpers": "^2.0.0",
48
50
  "lit": "^3.0.0",
49
51
  "sinon": "^18.0.0"
@@ -52,5 +54,5 @@
52
54
  "web-types.json",
53
55
  "web-types.lit.json"
54
56
  ],
55
- "gitHead": "67ffcd5355cf21ce1b5039c598525109fc4c164b"
57
+ "gitHead": "ce4421f0daf26027b863b91787a474e4cc264344"
56
58
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const sideNavStyles: CSSResult;
9
+
10
+ export const sideNavSlotStyles: CSSResult;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/component-base/src/style-props.js';
7
+ import { css } from 'lit';
8
+ import { sharedStyles } from './vaadin-side-nav-shared-base-styles.js';
9
+
10
+ const sideNav = css`
11
+ @layer base {
12
+ :host {
13
+ white-space: nowrap;
14
+ touch-action: manipulation;
15
+ }
16
+
17
+ [part='label'] {
18
+ align-self: start;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: start;
22
+ gap: var(--vaadin-side-nav-item-gap, var(--_vaadin-gap-container-inline));
23
+ padding: var(--vaadin-side-nav-item-padding, var(--_vaadin-padding-container));
24
+ font-size: var(--vaadin-side-nav-label-font-size, 0.875em);
25
+ font-weight: var(--vaadin-side-nav-label-font-weight, 500);
26
+ color: var(--vaadin-side-nav-label-color, inherit);
27
+ line-height: var(--vaadin-side-nav-label-line-height, inherit);
28
+ border-radius: var(--vaadin-side-nav-item-border-radius, var(--_vaadin-radius-m));
29
+ touch-action: manipulation;
30
+ }
31
+ }
32
+ `;
33
+
34
+ export const sideNavStyles = [sharedStyles, sideNav];
35
+
36
+ export const sideNavSlotStyles = css`
37
+ @layer vaadin.base {
38
+ vaadin-side-nav:has(vaadin-icon[slot='prefix']) {
39
+ --_has-prefix-icon: '';
40
+ }
41
+
42
+ vaadin-side-nav-item:has(> vaadin-icon[slot='prefix'])::part(link) {
43
+ --_has-prefix-icon:;
44
+ }
45
+ }
46
+ `;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const sideNavStyles: CSSResult;
9
+
10
+ export const sideNavSlotStyles: CSSResult;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from 'lit';
7
+
8
+ export const sideNavStyles = css`
9
+ :host {
10
+ display: block;
11
+ }
12
+
13
+ :host([hidden]) {
14
+ display: none !important;
15
+ }
16
+
17
+ button {
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: inherit;
21
+ width: 100%;
22
+ margin: 0;
23
+ padding: 0;
24
+ background-color: initial;
25
+ color: inherit;
26
+ border: initial;
27
+ outline: none;
28
+ font: inherit;
29
+ text-align: inherit;
30
+ }
31
+
32
+ [part='children'] {
33
+ padding: 0;
34
+ margin: 0;
35
+ list-style-type: none;
36
+ }
37
+ `;
38
+
39
+ export const sideNavSlotStyles = css``;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const sideNavItemStyles: CSSResult;
@@ -0,0 +1,124 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/component-base/src/style-props.js';
7
+ import { css } from 'lit';
8
+ import { sharedStyles } from './vaadin-side-nav-shared-base-styles.js';
9
+
10
+ const sideNavItem = css`
11
+ @layer base {
12
+ [part='content'] {
13
+ display: flex;
14
+ align-items: center;
15
+ padding: var(--vaadin-side-nav-item-padding, var(--_vaadin-padding));
16
+ gap: var(--vaadin-side-nav-item-gap, var(--_vaadin-gap-container-inline));
17
+ font-size: var(--vaadin-side-nav-item-font-size, 1em);
18
+ font-weight: var(--vaadin-side-nav-item-font-weight, 500);
19
+ line-height: var(--vaadin-side-nav-item-line-height, inherit);
20
+ color: var(--vaadin-side-nav-item-color, inherit);
21
+ background: var(--vaadin-side-nav-item-background, transparent);
22
+ background-origin: border-box;
23
+ border: var(--vaadin-side-nav-item-border-width, 0) solid var(--vaadin-side-nav-item-border-color, transparent);
24
+ border-radius: var(--vaadin-side-nav-item-border-radius, var(--_vaadin-radius-m));
25
+ cursor: var(--vaadin-clickable-cursor);
26
+ touch-action: manipulation;
27
+ }
28
+
29
+ :host([current]) [part='content'] {
30
+ --vaadin-side-nav-item-background: var(--_vaadin-background-container-strong);
31
+ --vaadin-side-nav-item-color: var(--_vaadin-color-strong);
32
+ }
33
+
34
+ :host([disabled]) {
35
+ --vaadin-clickable-cursor: var(--vaadin-disabled-cursor);
36
+ }
37
+
38
+ :host([disabled]) [part='content'] {
39
+ --vaadin-side-nav-item-color: var(--_vaadin-color-subtle);
40
+ }
41
+
42
+ [part='link'] {
43
+ flex: auto;
44
+ min-width: 0;
45
+ display: flex;
46
+ align-items: center;
47
+ gap: inherit;
48
+ text-decoration: none;
49
+ color: inherit;
50
+ outline: 0;
51
+ }
52
+
53
+ :host(:not([has-children])) [part='toggle-button'] {
54
+ display: none !important;
55
+ }
56
+
57
+ slot:not([name]) {
58
+ display: block;
59
+ flex: auto;
60
+ min-width: 0;
61
+ overflow: hidden;
62
+ text-overflow: ellipsis;
63
+ /* Don't clip ascenders or descenders */
64
+ padding-block: 0.25em;
65
+ margin-block: -0.25em;
66
+ }
67
+
68
+ slot:is([name='prefix'], [name='suffix'])::slotted(*) {
69
+ flex: none;
70
+ }
71
+
72
+ /* Reserved space for icon */
73
+ slot[name='prefix']::before {
74
+ content: var(--_has-prefix-icon);
75
+ display: block;
76
+ width: var(--vaadin-icon-size, 1lh);
77
+ flex: none;
78
+ }
79
+
80
+ [part='content']:not(:has([href])):has([part='toggle-button']:focus-visible),
81
+ [part='content']:has(:not([part='toggle-button']):focus-visible),
82
+ [part='content']:has([href]) [part='toggle-button']:focus-visible {
83
+ outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
84
+ }
85
+
86
+ [part='content']:not(:has([href])) [part='toggle-button']:focus-visible {
87
+ outline: 0;
88
+ }
89
+
90
+ /* Hierarchy indentation */
91
+ [part='content']::before {
92
+ content: '';
93
+ --_hierarchy-indent: calc(var(--_level, 0) * var(--vaadin-side-nav-child-indent, var(--vaadin-icon-size, 1lh)));
94
+ --_icon-indent: calc(var(--_level, 0) * var(--vaadin-side-nav-item-gap, var(--_vaadin-gap-container-inline)));
95
+ width: calc(var(--_hierarchy-indent) + var(--_icon-indent));
96
+ flex: none;
97
+ margin-inline-start: calc(var(--vaadin-side-nav-item-gap, var(--_vaadin-gap-container-inline)) * -1);
98
+ }
99
+
100
+ slot[name='children'] {
101
+ --_level: calc(var(--_level-2, 0) + 1);
102
+ }
103
+
104
+ slot[name='children']::slotted(*) {
105
+ --_level-2: var(--_level);
106
+ }
107
+
108
+ @media (forced-colors: active) {
109
+ :host([current]) [part='content'] {
110
+ color: Highlight;
111
+ }
112
+
113
+ :host([disabled]) [part='content'] {
114
+ --vaadin-side-nav-item-color: GrayText;
115
+ }
116
+
117
+ :host([disabled]) [part='toggle-button']::before {
118
+ background: GrayText;
119
+ }
120
+ }
121
+ }
122
+ `;
123
+
124
+ export const sideNavItemStyles = [sharedStyles, sideNavItem];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const sideNavItemStyles: CSSResult;
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { css } from 'lit';
7
7
 
8
- export const sideNavItemBaseStyles = css`
8
+ export const sideNavItemStyles = css`
9
9
  :host {
10
10
  display: block;
11
11
  }
@@ -69,34 +69,3 @@ export const sideNavItemBaseStyles = css`
69
69
  white-space: nowrap;
70
70
  }
71
71
  `;
72
-
73
- export const sideNavBaseStyles = css`
74
- :host {
75
- display: block;
76
- }
77
-
78
- :host([hidden]) {
79
- display: none !important;
80
- }
81
-
82
- button {
83
- display: flex;
84
- align-items: center;
85
- justify-content: inherit;
86
- width: 100%;
87
- margin: 0;
88
- padding: 0;
89
- background-color: initial;
90
- color: inherit;
91
- border: initial;
92
- outline: none;
93
- font: inherit;
94
- text-align: inherit;
95
- }
96
-
97
- [part='children'] {
98
- padding: 0;
99
- margin: 0;
100
- list-style-type: none;
101
- }
102
- `;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const sharedStyles: CSSResult;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/component-base/src/style-props.js';
7
+ import { css } from 'lit';
8
+
9
+ export const sharedStyles = css`
10
+ @layer base {
11
+ :host {
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: var(--vaadin-side-nav-items-gap, var(--_vaadin-gap-container-block));
15
+ cursor: default;
16
+ -webkit-tap-highlight-color: transparent;
17
+ }
18
+
19
+ :host([hidden]),
20
+ [hidden] {
21
+ display: none !important;
22
+ }
23
+
24
+ button {
25
+ appearance: none;
26
+ margin: 0;
27
+ padding: 0;
28
+ border: 0;
29
+ background: transparent;
30
+ color: inherit;
31
+ font: inherit;
32
+ text-align: inherit;
33
+ cursor: var(--vaadin-clickable-cursor);
34
+ flex: none;
35
+ }
36
+
37
+ [part='toggle-button'] {
38
+ border-radius: var(--vaadin-side-nav-item-border-radius, var(--_vaadin-radius-s));
39
+ color: var(--_vaadin-color);
40
+ }
41
+
42
+ [part='toggle-button']::before {
43
+ content: '';
44
+ display: block;
45
+ background: currentColor;
46
+ mask-image: var(--_vaadin-icon-chevron-down);
47
+ width: var(--vaadin-icon-size, 1lh);
48
+ height: var(--vaadin-icon-size, 1lh);
49
+ rotate: -90deg;
50
+ }
51
+
52
+ :host([dir='rtl']) [part='toggle-button']::before {
53
+ scale: -1;
54
+ }
55
+
56
+ :host(:is(vaadin-side-nav-item[expanded], vaadin-side-nav:not([collapsed]))) [part='toggle-button'] {
57
+ rotate: 90deg;
58
+ }
59
+
60
+ :host([dir='rtl']:is(vaadin-side-nav-item[expanded], vaadin-side-nav:not([collapsed]))) [part='toggle-button'] {
61
+ rotate: -90deg;
62
+ }
63
+
64
+ @media (prefers-reduced-motion: no-preference) {
65
+ [part='toggle-button'] {
66
+ transition: rotate 150ms;
67
+ }
68
+ }
69
+
70
+ :host([disabled]) [part='toggle-button'] {
71
+ opacity: 0.5;
72
+ }
73
+
74
+ [part='children'] {
75
+ padding: 0;
76
+ margin: 0;
77
+ list-style-type: none;
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: var(--vaadin-side-nav-items-gap, var(--_vaadin-gap-container-block));
81
+ }
82
+
83
+ :focus-visible {
84
+ outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
85
+ }
86
+
87
+ @media (forced-colors: active) {
88
+ [part='toggle-button']::before {
89
+ background: CanvasText;
90
+ }
91
+ }
92
+ }
93
+ `;
@@ -12,7 +12,7 @@ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
12
12
  import { matchPaths } from '@vaadin/component-base/src/url-utils.js';
13
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
14
  import { location } from './location.js';
15
- import { sideNavItemBaseStyles } from './vaadin-side-nav-base-styles.js';
15
+ import { sideNavItemStyles } from './styles/vaadin-side-nav-item-core-styles.js';
16
16
  import { SideNavChildrenMixin } from './vaadin-side-nav-children-mixin.js';
17
17
 
18
18
  /**
@@ -175,7 +175,7 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
175
175
  }
176
176
 
177
177
  static get styles() {
178
- return [sideNavItemBaseStyles];
178
+ return sideNavItemStyles;
179
179
  }
180
180
 
181
181
  constructor() {
@@ -283,9 +283,13 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
283
283
  }
284
284
 
285
285
  /** @private */
286
- _onContentClick() {
286
+ _onContentClick(e) {
287
+ // Navigate if path is defined and not clicking on the link directly
288
+ if (this.path && !e.composedPath().find((el) => el === this.$.link)) {
289
+ this.$.link.click();
290
+ }
287
291
  // Toggle item expanded state unless the link has a non-empty path
288
- if (this.path == null && this.hasAttribute('has-children')) {
292
+ else if (this.path == null && this.hasAttribute('has-children') && !this.disabled) {
289
293
  this.__toggleExpanded();
290
294
  }
291
295
  }
@@ -3,14 +3,16 @@
3
3
  * Copyright (c) 2023 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import './vaadin-side-nav-item.js';
6
7
  import { html, LitElement } from 'lit';
7
8
  import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
8
9
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
11
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
12
+ import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
11
13
  import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
12
14
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
- import { sideNavBaseStyles } from './vaadin-side-nav-base-styles.js';
15
+ import { sideNavSlotStyles, sideNavStyles } from './styles/vaadin-side-nav-core-styles.js';
14
16
  import { SideNavChildrenMixin } from './vaadin-side-nav-children-mixin.js';
15
17
 
16
18
  /**
@@ -70,7 +72,9 @@ import { SideNavChildrenMixin } from './vaadin-side-nav-children-mixin.js';
70
72
  * @mixes ElementMixin
71
73
  * @mixes SideNavChildrenMixin
72
74
  */
73
- class SideNav extends SideNavChildrenMixin(FocusMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement))))) {
75
+ class SideNav extends SideNavChildrenMixin(
76
+ SlotStylesMixin(FocusMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement))))),
77
+ ) {
74
78
  static get is() {
75
79
  return 'vaadin-side-nav';
76
80
  }
@@ -149,7 +153,12 @@ class SideNav extends SideNavChildrenMixin(FocusMixin(ElementMixin(ThemableMixin
149
153
  }
150
154
 
151
155
  static get styles() {
152
- return sideNavBaseStyles;
156
+ return sideNavStyles;
157
+ }
158
+
159
+ /** @protected */
160
+ get slotStyles() {
161
+ return [sideNavSlotStyles];
153
162
  }
154
163
 
155
164
  constructor() {
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/side-nav",
4
- "version": "25.0.0-alpha2",
4
+ "version": "25.0.0-alpha4",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/side-nav",
4
- "version": "25.0.0-alpha2",
4
+ "version": "25.0.0-alpha4",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {