@vaadin/side-nav 25.0.0-alpha15 → 25.0.0-alpha17

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-alpha15",
3
+ "version": "25.0.0-alpha17",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,22 +34,22 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@open-wc/dedupe-mixin": "^1.3.0",
37
- "@vaadin/a11y-base": "25.0.0-alpha15",
38
- "@vaadin/component-base": "25.0.0-alpha15",
39
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha15",
37
+ "@vaadin/a11y-base": "25.0.0-alpha17",
38
+ "@vaadin/component-base": "25.0.0-alpha17",
39
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha17",
40
40
  "lit": "^3.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@vaadin/chai-plugins": "25.0.0-alpha15",
44
- "@vaadin/test-runner-commands": "25.0.0-alpha15",
43
+ "@vaadin/chai-plugins": "25.0.0-alpha17",
44
+ "@vaadin/test-runner-commands": "25.0.0-alpha17",
45
45
  "@vaadin/testing-helpers": "^2.0.0",
46
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha15",
46
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha17",
47
47
  "lit": "^3.0.0",
48
- "sinon": "^18.0.0"
48
+ "sinon": "^21.0.0"
49
49
  },
50
50
  "web-types": [
51
51
  "web-types.json",
52
52
  "web-types.lit.json"
53
53
  ],
54
- "gitHead": "1ad98437e7600769bf66f870929feefbeef16edf"
54
+ "gitHead": "8264c71309907be99368b09414f0f8d7f591e0b9"
55
55
  }
@@ -26,17 +26,35 @@ const sideNav = css`
26
26
  line-height: var(--vaadin-side-nav-label-line-height, inherit);
27
27
  border-radius: var(--vaadin-side-nav-item-border-radius, var(--vaadin-radius-m));
28
28
  touch-action: manipulation;
29
+ min-width: 0;
30
+ max-width: 100%;
31
+ }
32
+
33
+ ::slotted([slot='label']) {
34
+ min-width: 0;
35
+ overflow: hidden;
36
+ text-overflow: ellipsis;
37
+ margin: 0;
29
38
  }
30
39
  `;
31
40
 
32
41
  export const sideNavStyles = [sharedStyles, sideNav];
33
42
 
34
43
  export const sideNavSlotStyles = css`
35
- :where(vaadin-side-nav:has(vaadin-icon[slot='prefix'])) {
36
- --_has-prefix-icon: '';
44
+ :where(vaadin-side-nav:has(> vaadin-side-nav-item > vaadin-icon[slot='prefix']))::part(children),
45
+ :where(vaadin-side-nav-item:has(> vaadin-side-nav-item[slot='children'] > vaadin-icon[slot='prefix']))::part(
46
+ children
47
+ ) {
48
+ --_icon-indent: calc(var(--_icon-indent-2, 0) + 1);
49
+ }
50
+
51
+ :where(vaadin-side-nav-item:has(> vaadin-icon[slot='prefix']))::part(content) {
52
+ --_icon-indent: calc(var(--_icon-indent-2) - 1);
37
53
  }
38
54
 
39
- :where(vaadin-side-nav-item:has(> vaadin-icon[slot='prefix']))::part(link) {
40
- --_has-prefix-icon:;
55
+ :where(
56
+ vaadin-side-nav-item:has(> vaadin-icon[slot='prefix']):has(> vaadin-side-nav-item > vaadin-icon[slot='prefix'])
57
+ )::part(children) {
58
+ --_level: var(--_level-2, 0);
41
59
  }
42
60
  `;
@@ -5,14 +5,18 @@
5
5
  */
6
6
  import '@vaadin/component-base/src/styles/style-props.js';
7
7
  import { css } from 'lit';
8
+ import { screenReaderOnly } from '@vaadin/a11y-base/src/styles/sr-only-styles.js';
8
9
  import { sharedStyles } from './vaadin-side-nav-shared-base-styles.js';
9
10
 
10
11
  const sideNavItem = css`
11
12
  [part='content'] {
12
13
  display: flex;
13
14
  align-items: center;
15
+ min-width: 0;
16
+ max-width: 100%;
14
17
  padding: var(--vaadin-side-nav-item-padding, var(--vaadin-padding-container));
15
- gap: var(--vaadin-side-nav-item-gap, var(--vaadin-gap-s));
18
+ --_gap: var(--vaadin-side-nav-item-gap, var(--vaadin-gap-s));
19
+ gap: var(--_gap);
16
20
  font-size: var(--vaadin-side-nav-item-font-size, 1em);
17
21
  font-weight: var(--vaadin-side-nav-item-font-weight, 500);
18
22
  line-height: var(--vaadin-side-nav-item-line-height, inherit);
@@ -68,14 +72,6 @@ const sideNavItem = css`
68
72
  flex: none;
69
73
  }
70
74
 
71
- /* Reserved space for icon */
72
- slot[name='prefix']::before {
73
- content: var(--_has-prefix-icon);
74
- display: block;
75
- width: var(--vaadin-icon-size, 1lh);
76
- flex: none;
77
- }
78
-
79
75
  [part='content']:not(:has([href])):has([part='toggle-button']:focus-visible),
80
76
  [part='content']:has(:not([part='toggle-button']):focus-visible),
81
77
  [part='content']:has([href]) [part='toggle-button']:focus-visible {
@@ -89,18 +85,19 @@ const sideNavItem = css`
89
85
  /* Hierarchy indentation */
90
86
  [part='content']::before {
91
87
  content: '';
92
- --_hierarchy-indent: calc(var(--_level, 0) * var(--vaadin-side-nav-child-indent, var(--vaadin-icon-size, 1lh)));
93
- --_icon-indent: calc(var(--_level, 0) * var(--vaadin-side-nav-item-gap, var(--vaadin-gap-s)));
94
- width: calc(var(--_hierarchy-indent) + var(--_icon-indent));
88
+ width: calc(
89
+ var(--vaadin-side-nav-child-indent, 1em) * var(--_level, 0) + var(--_icon-indent, 0) *
90
+ (var(--vaadin-icon-size, 1lh) + var(--_gap))
91
+ );
95
92
  flex: none;
96
- margin-inline-start: calc(var(--vaadin-side-nav-item-gap, var(--vaadin-gap-s)) * -1);
93
+ margin-inline-start: calc(var(--_gap) * -1);
97
94
  }
98
95
 
99
- slot[name='children'] {
96
+ [part='children'] {
100
97
  --_level: calc(var(--_level-2, 0) + 1);
101
98
  }
102
99
 
103
- slot[name='children']::slotted(*) {
100
+ [part='children'] ::slotted(*) {
104
101
  --_level-2: var(--_level);
105
102
  }
106
103
 
@@ -119,4 +116,4 @@ const sideNavItem = css`
119
116
  }
120
117
  `;
121
118
 
122
- export const sideNavItemStyles = [sharedStyles, sideNavItem];
119
+ export const sideNavItemStyles = [sharedStyles, screenReaderOnly, sideNavItem];
@@ -10,6 +10,8 @@ export const sharedStyles = css`
10
10
  :host {
11
11
  display: flex;
12
12
  flex-direction: column;
13
+ min-width: 0;
14
+ max-width: 100%;
13
15
  gap: var(--vaadin-side-nav-items-gap, var(--vaadin-gap-s));
14
16
  cursor: default;
15
17
  -webkit-tap-highlight-color: transparent;
@@ -79,6 +81,10 @@ export const sharedStyles = css`
79
81
  gap: var(--vaadin-side-nav-items-gap, var(--vaadin-gap-s));
80
82
  }
81
83
 
84
+ [part='children'] slot {
85
+ --_icon-indent-2: var(--_icon-indent);
86
+ }
87
+
82
88
  :focus-visible {
83
89
  outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
84
90
  }
@@ -72,6 +72,7 @@ export type SideNavItemEventMap = HTMLElementEventMap & SideNavItemCustomEventMa
72
72
  * `disabled` | Set when the element is disabled.
73
73
  * `expanded` | Set when the element is expanded.
74
74
  * `has-children` | Set when the element has child items.
75
+ * `has-tooltip` | Set when the element has a slotted tooltip.
75
76
  *
76
77
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
77
78
  *
@@ -9,6 +9,7 @@ import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
9
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
10
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
11
11
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
12
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
12
13
  import { matchPaths } from '@vaadin/component-base/src/url-utils.js';
13
14
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
14
15
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -69,6 +70,7 @@ import { SideNavChildrenMixin } from './vaadin-side-nav-children-mixin.js';
69
70
  * `disabled` | Set when the element is disabled.
70
71
  * `expanded` | Set when the element is expanded.
71
72
  * `has-children` | Set when the element has child items.
73
+ * `has-tooltip` | Set when the element has a slotted tooltip.
72
74
  *
73
75
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
74
76
  *
@@ -174,6 +176,11 @@ class SideNavItem extends SideNavChildrenMixin(
174
176
  type: Boolean,
175
177
  value: false,
176
178
  },
179
+
180
+ /** @private */
181
+ __tooltipText: {
182
+ type: String,
183
+ },
177
184
  };
178
185
  }
179
186
 
@@ -246,7 +253,7 @@ class SideNavItem extends SideNavChildrenMixin(
246
253
  /** @protected */
247
254
  render() {
248
255
  return html`
249
- <div part="content" @click="${this._onContentClick}">
256
+ <div id="content" part="content" @click="${this._onContentClick}">
250
257
  <a
251
258
  id="link"
252
259
  ?disabled="${this.disabled}"
@@ -259,6 +266,7 @@ class SideNavItem extends SideNavChildrenMixin(
259
266
  >
260
267
  <slot name="prefix"></slot>
261
268
  <slot></slot>
269
+ <div class="sr-only">${this.__tooltipText}</div>
262
270
  <slot name="suffix"></slot>
263
271
  </a>
264
272
  <button
@@ -274,9 +282,29 @@ class SideNavItem extends SideNavChildrenMixin(
274
282
  <slot name="children"></slot>
275
283
  </ul>
276
284
  <div hidden id="i18n">${this.__effectiveI18n.toggle}</div>
285
+ <slot name="tooltip"></slot>
277
286
  `;
278
287
  }
279
288
 
289
+ /** @protected */
290
+ ready() {
291
+ super.ready();
292
+
293
+ this._tooltipController = new TooltipController(this);
294
+ this._tooltipController.setTarget(this.$.content);
295
+ this._tooltipController.setAriaTarget(null);
296
+ this._tooltipController.addEventListener('tooltip-changed', (event) => {
297
+ const { node } = event.detail;
298
+ if (node) {
299
+ this.__tooltipText = node.textContent.trim();
300
+ node.setAttribute('aria-hidden', 'true');
301
+ } else {
302
+ this.__tooltipText = '';
303
+ }
304
+ });
305
+ this.addController(this._tooltipController);
306
+ }
307
+
280
308
  /** @private */
281
309
  _onButtonClick(event) {
282
310
  // Prevent the event from being handled
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/side-nav",
4
- "version": "25.0.0-alpha15",
4
+ "version": "25.0.0-alpha17",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-side-nav-item",
11
- "description": "A navigation item to be used within `<vaadin-side-nav>`. Represents a navigation target.\nNot intended to be used separately.\n\n```html\n<vaadin-side-nav-item>\n Item 1\n <vaadin-side-nav-item path=\"/path1\" slot=\"children\">\n Child item 1\n </vaadin-side-nav-item>\n <vaadin-side-nav-item path=\"/path2\" slot=\"children\">\n Child item 2\n </vaadin-side-nav-item>\n</vaadin-side-nav-item>\n```\n\n### Customization\n\nYou can configure the item by using `slot` names.\n\nSlot name | Description\n----------|-------------\n`prefix` | A slot for content before the label (e.g. an icon).\n`suffix` | A slot for content after the label (e.g. an icon).\n\n#### Example\n\n```html\n<vaadin-side-nav-item>\n <vaadin-icon icon=\"vaadin:chart\" slot=\"prefix\"></vaadin-icon>\n Item\n <span theme=\"badge primary\" slot=\"suffix\">Suffix</span>\n</vaadin-side-nav-item>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`content` | The element that wraps link and toggle button\n`children` | The element that wraps child items\n`link` | The clickable anchor used for navigation\n`toggle-button` | The toggle button\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`disabled` | Set when the element is disabled.\n`expanded` | Set when the element is expanded.\n`has-children` | Set when the element has child items.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
11
+ "description": "A navigation item to be used within `<vaadin-side-nav>`. Represents a navigation target.\nNot intended to be used separately.\n\n```html\n<vaadin-side-nav-item>\n Item 1\n <vaadin-side-nav-item path=\"/path1\" slot=\"children\">\n Child item 1\n </vaadin-side-nav-item>\n <vaadin-side-nav-item path=\"/path2\" slot=\"children\">\n Child item 2\n </vaadin-side-nav-item>\n</vaadin-side-nav-item>\n```\n\n### Customization\n\nYou can configure the item by using `slot` names.\n\nSlot name | Description\n----------|-------------\n`prefix` | A slot for content before the label (e.g. an icon).\n`suffix` | A slot for content after the label (e.g. an icon).\n\n#### Example\n\n```html\n<vaadin-side-nav-item>\n <vaadin-icon icon=\"vaadin:chart\" slot=\"prefix\"></vaadin-icon>\n Item\n <span theme=\"badge primary\" slot=\"suffix\">Suffix</span>\n</vaadin-side-nav-item>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`content` | The element that wraps link and toggle button\n`children` | The element that wraps child items\n`link` | The clickable anchor used for navigation\n`toggle-button` | The toggle button\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`disabled` | Set when the element is disabled.\n`expanded` | Set when the element is expanded.\n`has-children` | Set when the element has child items.\n`has-tooltip` | Set when the element has a slotted tooltip.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "disabled",
@@ -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-alpha15",
4
+ "version": "25.0.0-alpha17",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-side-nav-item",
19
- "description": "A navigation item to be used within `<vaadin-side-nav>`. Represents a navigation target.\nNot intended to be used separately.\n\n```html\n<vaadin-side-nav-item>\n Item 1\n <vaadin-side-nav-item path=\"/path1\" slot=\"children\">\n Child item 1\n </vaadin-side-nav-item>\n <vaadin-side-nav-item path=\"/path2\" slot=\"children\">\n Child item 2\n </vaadin-side-nav-item>\n</vaadin-side-nav-item>\n```\n\n### Customization\n\nYou can configure the item by using `slot` names.\n\nSlot name | Description\n----------|-------------\n`prefix` | A slot for content before the label (e.g. an icon).\n`suffix` | A slot for content after the label (e.g. an icon).\n\n#### Example\n\n```html\n<vaadin-side-nav-item>\n <vaadin-icon icon=\"vaadin:chart\" slot=\"prefix\"></vaadin-icon>\n Item\n <span theme=\"badge primary\" slot=\"suffix\">Suffix</span>\n</vaadin-side-nav-item>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`content` | The element that wraps link and toggle button\n`children` | The element that wraps child items\n`link` | The clickable anchor used for navigation\n`toggle-button` | The toggle button\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`disabled` | Set when the element is disabled.\n`expanded` | Set when the element is expanded.\n`has-children` | Set when the element has child items.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
19
+ "description": "A navigation item to be used within `<vaadin-side-nav>`. Represents a navigation target.\nNot intended to be used separately.\n\n```html\n<vaadin-side-nav-item>\n Item 1\n <vaadin-side-nav-item path=\"/path1\" slot=\"children\">\n Child item 1\n </vaadin-side-nav-item>\n <vaadin-side-nav-item path=\"/path2\" slot=\"children\">\n Child item 2\n </vaadin-side-nav-item>\n</vaadin-side-nav-item>\n```\n\n### Customization\n\nYou can configure the item by using `slot` names.\n\nSlot name | Description\n----------|-------------\n`prefix` | A slot for content before the label (e.g. an icon).\n`suffix` | A slot for content after the label (e.g. an icon).\n\n#### Example\n\n```html\n<vaadin-side-nav-item>\n <vaadin-icon icon=\"vaadin:chart\" slot=\"prefix\"></vaadin-icon>\n Item\n <span theme=\"badge primary\" slot=\"suffix\">Suffix</span>\n</vaadin-side-nav-item>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`content` | The element that wraps link and toggle button\n`children` | The element that wraps child items\n`link` | The clickable anchor used for navigation\n`toggle-button` | The toggle button\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`disabled` | Set when the element is disabled.\n`expanded` | Set when the element is expanded.\n`has-children` | Set when the element has child items.\n`has-tooltip` | Set when the element has a slotted tooltip.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {