@vaadin/side-nav 24.2.0-alpha2 → 24.2.0-alpha3

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.2.0-alpha2",
3
+ "version": "24.2.0-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,10 +35,10 @@
35
35
  "web-component"
36
36
  ],
37
37
  "dependencies": {
38
- "@vaadin/component-base": "24.2.0-alpha2",
39
- "@vaadin/vaadin-lumo-styles": "24.2.0-alpha2",
40
- "@vaadin/vaadin-material-styles": "24.2.0-alpha2",
41
- "@vaadin/vaadin-themable-mixin": "24.2.0-alpha2",
38
+ "@vaadin/component-base": "24.2.0-alpha3",
39
+ "@vaadin/vaadin-lumo-styles": "24.2.0-alpha3",
40
+ "@vaadin/vaadin-material-styles": "24.2.0-alpha3",
41
+ "@vaadin/vaadin-themable-mixin": "24.2.0-alpha3",
42
42
  "lit": "^2.0.0"
43
43
  },
44
44
  "devDependencies": {
@@ -51,5 +51,5 @@
51
51
  "web-types.json",
52
52
  "web-types.lit.json"
53
53
  ],
54
- "gitHead": "b8378bd2267728e172012bcb2ea45c3e5a6e590a"
54
+ "gitHead": "e5d1e1ed2d01b56d5922e18a3fcb7cd306351954"
55
55
  }
@@ -15,6 +15,10 @@ export const sideNavItemBaseStyles = css`
15
15
  display: none !important;
16
16
  }
17
17
 
18
+ :host([disabled]) {
19
+ pointer-events: none;
20
+ }
21
+
18
22
  [part='content'] {
19
23
  display: flex;
20
24
  align-items: center;
@@ -51,15 +55,6 @@ export const sideNavItemBaseStyles = css`
51
55
  display: none !important;
52
56
  }
53
57
 
54
- :host(:not([path])) button::after {
55
- content: '';
56
- position: absolute;
57
- top: 0;
58
- right: 0;
59
- bottom: 0;
60
- left: 0;
61
- }
62
-
63
58
  slot[name='prefix'],
64
59
  slot[name='suffix'] {
65
60
  flex: none;
@@ -38,4 +38,9 @@ export declare class SideNavChildrenMixinClass {
38
38
  * Name of the slot to be used for children.
39
39
  */
40
40
  protected readonly _itemsSlotName: string;
41
+
42
+ /**
43
+ * Count of child items.
44
+ */
45
+ protected _itemsCount: number;
41
46
  }
@@ -64,7 +64,7 @@ export const SideNavChildrenMixin = (superClass) =>
64
64
 
65
65
  /**
66
66
  * Count of child items.
67
- * @private
67
+ * @protected
68
68
  */
69
69
  _itemsCount: {
70
70
  type: Number,
@@ -4,6 +4,7 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { LitElement } from 'lit';
7
+ import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
7
8
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -70,6 +71,7 @@ export type SideNavItemEventMap = HTMLElementEventMap & SideNavItemCustomEventMa
70
71
  *
71
72
  * Attribute | Description
72
73
  * ---------------|-------------
74
+ * `disabled` | Set when the element is disabled.
73
75
  * `expanded` | Set when the element is expanded.
74
76
  * `has-children` | Set when the element has child items.
75
77
  *
@@ -77,7 +79,9 @@ export type SideNavItemEventMap = HTMLElementEventMap & SideNavItemCustomEventMa
77
79
  *
78
80
  * @fires {CustomEvent} expanded-changed - Fired when the `expanded` property changes.
79
81
  */
80
- declare class SideNavItem extends SideNavChildrenMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
82
+ declare class SideNavItem extends SideNavChildrenMixin(
83
+ DisabledMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))),
84
+ ) {
81
85
  /**
82
86
  * The path to navigate to
83
87
  */
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { html, LitElement } from 'lit';
7
7
  import { ifDefined } from 'lit/directives/if-defined.js';
8
+ import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
8
9
  import { screenReaderOnly } from '@vaadin/a11y-base/src/styles/sr-only-styles.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';
@@ -67,6 +68,7 @@ function isEnabled() {
67
68
  *
68
69
  * Attribute | Description
69
70
  * ---------------|-------------
71
+ * `disabled` | Set when the element is disabled.
70
72
  * `expanded` | Set when the element is expanded.
71
73
  * `has-children` | Set when the element has child items.
72
74
  *
@@ -77,10 +79,11 @@ function isEnabled() {
77
79
  * @extends LitElement
78
80
  * @mixes PolylitMixin
79
81
  * @mixes ThemableMixin
82
+ * @mixes DisabledMixin
80
83
  * @mixes ElementMixin
81
84
  * @mixes SideNavChildrenMixin
82
85
  */
83
- class SideNavItem extends SideNavChildrenMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
86
+ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement))))) {
84
87
  static get is() {
85
88
  return 'vaadin-side-nav-item';
86
89
  }
@@ -169,6 +172,13 @@ class SideNavItem extends SideNavChildrenMixin(ElementMixin(ThemableMixin(Polyli
169
172
  if (props.has('path') || props.has('pathAliases')) {
170
173
  this.__updateCurrent();
171
174
  }
175
+
176
+ // Ensure all the child items are disabled
177
+ if (props.has('disabled') || props.has('_itemsCount')) {
178
+ this._items.forEach((item) => {
179
+ item.disabled = this.disabled;
180
+ });
181
+ }
172
182
  }
173
183
 
174
184
  /** @protected */
@@ -189,20 +199,28 @@ class SideNavItem extends SideNavChildrenMixin(ElementMixin(ThemableMixin(Polyli
189
199
  render() {
190
200
  return html`
191
201
  <div part="content" @click="${this._onContentClick}">
192
- <a id="link" href="${ifDefined(this.path)}" part="link" aria-current="${this.current ? 'page' : 'false'}">
202
+ <a
203
+ id="link"
204
+ ?disabled="${this.disabled}"
205
+ tabindex="${this.disabled ? '-1' : '0'}"
206
+ href="${ifDefined(this.disabled ? null : this.path)}"
207
+ part="link"
208
+ aria-current="${this.current ? 'page' : 'false'}"
209
+ >
193
210
  <slot name="prefix"></slot>
194
211
  <slot></slot>
195
212
  <slot name="suffix"></slot>
196
213
  </a>
197
214
  <button
198
215
  part="toggle-button"
216
+ ?disabled="${this.disabled}"
199
217
  @click="${this._onButtonClick}"
200
218
  aria-controls="children"
201
219
  aria-expanded="${this.expanded}"
202
220
  aria-labelledby="link i18n"
203
221
  ></button>
204
222
  </div>
205
- <ul part="children" ?hidden="${!this.expanded}">
223
+ <ul part="children" ?hidden="${!this.expanded}" aria-hidden="${this.expanded ? 'false' : 'true'}">
206
224
  <slot name="children"></slot>
207
225
  </ul>
208
226
  <div class="sr-only" id="i18n">${this.i18n.toggle}</div>
@@ -23,6 +23,10 @@ export const sideNavItemStyles = css`
23
23
  cursor: pointer;
24
24
  }
25
25
 
26
+ :host([disabled]) [part='link'] {
27
+ color: var(--lumo-disabled-text-color);
28
+ }
29
+
26
30
  [part='toggle-button'] {
27
31
  margin-inline-end: calc(var(--lumo-space-xs) * -1);
28
32
  width: var(--lumo-size-s);
@@ -53,6 +57,10 @@ export const sideNavItemStyles = css`
53
57
  transition: transform 140ms;
54
58
  }
55
59
 
60
+ :host([dir='rtl']) [part='toggle-button']::before {
61
+ transform: rotate(90deg);
62
+ }
63
+
56
64
  :host([expanded]) [part='toggle-button']::before {
57
65
  transform: none;
58
66
  }
@@ -84,6 +92,10 @@ export const sideNavItemStyles = css`
84
92
  color: var(--lumo-contrast-60pct);
85
93
  }
86
94
 
95
+ :host([disabled]) slot[name='prefix']::slotted(:is(vaadin-icon, [class*='icon'])) {
96
+ color: var(--lumo-disabled-text-color);
97
+ }
98
+
87
99
  :host([current]) slot[name='prefix']::slotted(:is(vaadin-icon, [class*='icon'])) {
88
100
  color: inherit;
89
101
  }
@@ -55,16 +55,21 @@ export const sideNavStyles = css`
55
55
 
56
56
  [part='toggle-button']::before {
57
57
  content: var(--lumo-icons-angle-right);
58
+ transition: transform 140ms;
58
59
  }
59
60
 
60
61
  :host(:not([collapsible])) [part='toggle-button'] {
61
62
  display: none !important;
62
63
  }
63
64
 
64
- :host(:not([collapsed])) [part='toggle-button'] {
65
+ :host(:not([collapsed])) [part='toggle-button']::before {
65
66
  transform: rotate(90deg);
66
67
  }
67
68
 
69
+ :host([collapsed][dir='rtl']) [part='toggle-button']::before {
70
+ transform: rotate(180deg);
71
+ }
72
+
68
73
  @media (any-hover: hover) {
69
74
  [part='label']:hover [part='toggle-button'] {
70
75
  color: var(--lumo-body-text-color);
@@ -31,6 +31,10 @@ export const sideNavItemStyles = css`
31
31
  color: var(--material-primary-text-color);
32
32
  }
33
33
 
34
+ :host([disabled]) [part='link'] {
35
+ color: var(--material-disabled-text-color);
36
+ }
37
+
34
38
  :host([current]) [part='link']::before {
35
39
  position: absolute;
36
40
  content: '';
@@ -118,6 +122,10 @@ export const sideNavItemStyles = css`
118
122
  color: var(--material-secondary-text-color);
119
123
  }
120
124
 
125
+ :host([disabled]) slot[name='prefix']::slotted(:is(vaadin-icon, [class*='icon'])) {
126
+ color: var(--material-disabled-text-color);
127
+ }
128
+
121
129
  :host([current]) slot[name='prefix']::slotted(:is(vaadin-icon, [class*='icon'])) {
122
130
  color: inherit;
123
131
  }
package/web-types.json CHANGED
@@ -1,15 +1,26 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/side-nav",
4
- "version": "24.2.0-alpha2",
4
+ "version": "24.2.0-alpha3",
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`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\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
12
  "attributes": [
13
+ {
14
+ "name": "disabled",
15
+ "description": "If true, the user cannot interact with this element.",
16
+ "value": {
17
+ "type": [
18
+ "boolean",
19
+ "null",
20
+ "undefined"
21
+ ]
22
+ }
23
+ },
13
24
  {
14
25
  "name": "path",
15
26
  "description": "The path to navigate to",
@@ -44,6 +55,17 @@
44
55
  ],
45
56
  "js": {
46
57
  "properties": [
58
+ {
59
+ "name": "disabled",
60
+ "description": "If true, the user cannot interact with this element.",
61
+ "value": {
62
+ "type": [
63
+ "boolean",
64
+ "null",
65
+ "undefined"
66
+ ]
67
+ }
68
+ },
47
69
  {
48
70
  "name": "i18n",
49
71
  "description": "The object used to localize this component.\n\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nThe object has the following structure and default values:\n```\n{\n toggle: 'Toggle child items'\n}\n```",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/side-nav",
4
- "version": "24.2.0-alpha2",
4
+ "version": "24.2.0-alpha3",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,9 +16,16 @@
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`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\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
+ {
23
+ "name": "?disabled",
24
+ "description": "If true, the user cannot interact with this element.",
25
+ "value": {
26
+ "kind": "expression"
27
+ }
28
+ },
22
29
  {
23
30
  "name": "?expanded",
24
31
  "description": "Whether to show the child items or not",