@vaadin/side-nav 24.9.0-alpha1 → 24.9.0-beta1

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": "24.9.0-alpha1",
3
+ "version": "24.9.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,16 +35,16 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
- "@vaadin/a11y-base": "24.9.0-alpha1",
39
- "@vaadin/component-base": "24.9.0-alpha1",
40
- "@vaadin/vaadin-lumo-styles": "24.9.0-alpha1",
41
- "@vaadin/vaadin-material-styles": "24.9.0-alpha1",
42
- "@vaadin/vaadin-themable-mixin": "24.9.0-alpha1",
38
+ "@vaadin/a11y-base": "24.9.0-beta1",
39
+ "@vaadin/component-base": "24.9.0-beta1",
40
+ "@vaadin/vaadin-lumo-styles": "24.9.0-beta1",
41
+ "@vaadin/vaadin-material-styles": "24.9.0-beta1",
42
+ "@vaadin/vaadin-themable-mixin": "24.9.0-beta1",
43
43
  "lit": "^3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@vaadin/chai-plugins": "24.9.0-alpha1",
47
- "@vaadin/test-runner-commands": "24.9.0-alpha1",
46
+ "@vaadin/chai-plugins": "24.9.0-beta1",
47
+ "@vaadin/test-runner-commands": "24.9.0-beta1",
48
48
  "@vaadin/testing-helpers": "^1.1.0",
49
49
  "lit": "^3.0.0",
50
50
  "sinon": "^18.0.0"
@@ -53,5 +53,5 @@
53
53
  "web-types.json",
54
54
  "web-types.lit.json"
55
55
  ],
56
- "gitHead": "cc13d59f0e3cd1a3b0c19c1a900a5308446fe7ac"
56
+ "gitHead": "5f6e6e33217fef06e5d5cc52baa4d760969ef1e4"
57
57
  }
@@ -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
  *
@@ -6,9 +6,11 @@
6
6
  import { html, LitElement } from 'lit';
7
7
  import { ifDefined } from 'lit/directives/if-defined.js';
8
8
  import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
+ import { screenReaderOnly } from '@vaadin/a11y-base/src/styles/sr-only-styles.js';
9
10
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
10
11
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
11
12
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
13
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
12
14
  import { matchPaths } from '@vaadin/component-base/src/url-utils.js';
13
15
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
16
  import { location } from './location.js';
@@ -68,6 +70,7 @@ import { SideNavChildrenMixin } from './vaadin-side-nav-children-mixin.js';
68
70
  * `disabled` | Set when the element is disabled.
69
71
  * `expanded` | Set when the element is expanded.
70
72
  * `has-children` | Set when the element has child items.
73
+ * `has-tooltip` | Set when the element has a slotted tooltip.
71
74
  *
72
75
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
73
76
  *
@@ -171,11 +174,16 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
171
174
  type: Boolean,
172
175
  value: false,
173
176
  },
177
+
178
+ /** @private */
179
+ __tooltipText: {
180
+ type: String,
181
+ },
174
182
  };
175
183
  }
176
184
 
177
185
  static get styles() {
178
- return [sideNavItemBaseStyles];
186
+ return [sideNavItemBaseStyles, screenReaderOnly];
179
187
  }
180
188
 
181
189
  constructor() {
@@ -243,7 +251,7 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
243
251
  /** @protected */
244
252
  render() {
245
253
  return html`
246
- <div part="content" @click="${this._onContentClick}">
254
+ <div id="content" part="content" @click="${this._onContentClick}">
247
255
  <a
248
256
  id="link"
249
257
  ?disabled="${this.disabled}"
@@ -256,6 +264,7 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
256
264
  >
257
265
  <slot name="prefix"></slot>
258
266
  <slot></slot>
267
+ <div class="sr-only">${this.__tooltipText}</div>
259
268
  <slot name="suffix"></slot>
260
269
  </a>
261
270
  <button
@@ -271,9 +280,30 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
271
280
  <slot name="children"></slot>
272
281
  </ul>
273
282
  <div hidden id="i18n">${this.__effectiveI18n.toggle}</div>
283
+ <slot name="tooltip"></slot>
274
284
  `;
275
285
  }
276
286
 
287
+ /** @protected */
288
+ ready() {
289
+ super.ready();
290
+
291
+ this._tooltipController = new TooltipController(this);
292
+ this._tooltipController.setTarget(this.$.content);
293
+ this._tooltipController.setAriaTarget(null);
294
+ this._tooltipController.addEventListener('tooltip-changed', (event) => {
295
+ const { node } = event.detail;
296
+ if (node) {
297
+ const overlay = node._overlayElement;
298
+ this.__tooltipText = overlay ? overlay.textContent.trim() : '';
299
+ node.setAttribute('aria-hidden', 'true');
300
+ } else {
301
+ this.__tooltipText = '';
302
+ }
303
+ });
304
+ this.addController(this._tooltipController);
305
+ }
306
+
277
307
  /** @private */
278
308
  _onButtonClick(event) {
279
309
  // 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": "24.9.0-alpha1",
4
+ "version": "24.9.0-beta1",
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": "24.9.0-alpha1",
4
+ "version": "24.9.0-beta1",
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
  {