@vaadin/side-nav 24.5.0-alpha9 → 24.5.0-rc1
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 +8 -8
- package/src/location.js +19 -0
- package/src/vaadin-side-nav-item.d.ts +18 -2
- package/src/vaadin-side-nav-item.js +28 -3
- package/web-types.json +19 -1
- package/web-types.lit.json +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/side-nav",
|
|
3
|
-
"version": "24.5.0-
|
|
3
|
+
"version": "24.5.0-rc1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/a11y-base": "24.5.0-
|
|
39
|
-
"@vaadin/component-base": "24.5.0-
|
|
40
|
-
"@vaadin/vaadin-lumo-styles": "24.5.0-
|
|
41
|
-
"@vaadin/vaadin-material-styles": "24.5.0-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "24.5.0-
|
|
38
|
+
"@vaadin/a11y-base": "24.5.0-rc1",
|
|
39
|
+
"@vaadin/component-base": "24.5.0-rc1",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "24.5.0-rc1",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "24.5.0-rc1",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "24.5.0-rc1",
|
|
43
43
|
"lit": "^3.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vaadin/chai-plugins": "24.5.0-
|
|
46
|
+
"@vaadin/chai-plugins": "24.5.0-rc1",
|
|
47
47
|
"@vaadin/testing-helpers": "^1.0.0",
|
|
48
48
|
"lit": "^3.0.0",
|
|
49
49
|
"sinon": "^18.0.0"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"web-types.json",
|
|
53
53
|
"web-types.lit.json"
|
|
54
54
|
],
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a8ae853ab69d7938cf507843784f1551a2eeb972"
|
|
56
56
|
}
|
package/src/location.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2023 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Facade for `document.location`, can be stubbed for testing.
|
|
9
|
+
*
|
|
10
|
+
* For internal use only.
|
|
11
|
+
*/
|
|
12
|
+
export const location = {
|
|
13
|
+
get pathname() {
|
|
14
|
+
return document.location.pathname;
|
|
15
|
+
},
|
|
16
|
+
get search() {
|
|
17
|
+
return document.location.search;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -93,12 +93,28 @@ declare class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixi
|
|
|
93
93
|
*/
|
|
94
94
|
expanded: boolean;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Whether to also match nested paths / routes. `false` by default.
|
|
98
|
+
*
|
|
99
|
+
* When enabled, an item with the path `/path` is considered current when
|
|
100
|
+
* the browser URL is `/path`, `/path/child`, `/path/child/grandchild`,
|
|
101
|
+
* etc.
|
|
102
|
+
*
|
|
103
|
+
* Note that this only affects matching of the URLs path, not the base
|
|
104
|
+
* origin or query parameters.
|
|
105
|
+
*
|
|
106
|
+
* @attr {boolean} match-nested
|
|
107
|
+
*/
|
|
108
|
+
matchNested: boolean;
|
|
109
|
+
|
|
96
110
|
/**
|
|
97
111
|
* Whether the item's path matches the current browser URL.
|
|
98
112
|
*
|
|
99
113
|
* A match occurs when both share the same base origin (like https://example.com),
|
|
100
|
-
* the same path (like /path/to/page), and the browser URL contains
|
|
101
|
-
* the query parameters with the same values from the item's path.
|
|
114
|
+
* the same path (like /path/to/page), and the browser URL contains at least
|
|
115
|
+
* all the query parameters with the same values from the item's path.
|
|
116
|
+
*
|
|
117
|
+
* See [`matchNested`](#/elements/vaadin-side-nav-item#property-matchNested) for how to change the path matching behavior.
|
|
102
118
|
*
|
|
103
119
|
* The state is updated when the item is added to the DOM or when the browser
|
|
104
120
|
* navigates to a new page.
|
|
@@ -12,6 +12,7 @@ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
|
12
12
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
13
|
import { matchPaths } from '@vaadin/component-base/src/url-utils.js';
|
|
14
14
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
+
import { location } from './location.js';
|
|
15
16
|
import { sideNavItemBaseStyles } from './vaadin-side-nav-base-styles.js';
|
|
16
17
|
import { SideNavChildrenMixin } from './vaadin-side-nav-children-mixin.js';
|
|
17
18
|
|
|
@@ -114,6 +115,24 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
|
|
|
114
115
|
reflectToAttribute: true,
|
|
115
116
|
},
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Whether to also match nested paths / routes. `false` by default.
|
|
120
|
+
*
|
|
121
|
+
* When enabled, an item with the path `/path` is considered current when
|
|
122
|
+
* the browser URL is `/path`, `/path/child`, `/path/child/grandchild`,
|
|
123
|
+
* etc.
|
|
124
|
+
*
|
|
125
|
+
* Note that this only affects matching of the URLs path, not the base
|
|
126
|
+
* origin or query parameters.
|
|
127
|
+
*
|
|
128
|
+
* @type {boolean}
|
|
129
|
+
* @attr {boolean} match-nested
|
|
130
|
+
*/
|
|
131
|
+
matchNested: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
value: false,
|
|
134
|
+
},
|
|
135
|
+
|
|
117
136
|
/**
|
|
118
137
|
* Whether the item's path matches the current browser URL.
|
|
119
138
|
*
|
|
@@ -121,6 +140,8 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
|
|
|
121
140
|
* the same path (like /path/to/page), and the browser URL contains at least
|
|
122
141
|
* all the query parameters with the same values from the item's path.
|
|
123
142
|
*
|
|
143
|
+
* See [`matchNested`](#/elements/vaadin-side-nav-item#property-matchNested) for how to change the path matching behavior.
|
|
144
|
+
*
|
|
124
145
|
* The state is updated when the item is added to the DOM or when the browser
|
|
125
146
|
* navigates to a new page.
|
|
126
147
|
*
|
|
@@ -190,7 +211,7 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
|
|
|
190
211
|
updated(props) {
|
|
191
212
|
super.updated(props);
|
|
192
213
|
|
|
193
|
-
if (props.has('path') || props.has('pathAliases')) {
|
|
214
|
+
if (props.has('path') || props.has('pathAliases') || props.has('matchNested')) {
|
|
194
215
|
this.__updateCurrent();
|
|
195
216
|
}
|
|
196
217
|
|
|
@@ -304,8 +325,12 @@ class SideNavItem extends SideNavChildrenMixin(DisabledMixin(ElementMixin(Themab
|
|
|
304
325
|
return false;
|
|
305
326
|
}
|
|
306
327
|
|
|
307
|
-
const browserPath = `${
|
|
308
|
-
|
|
328
|
+
const browserPath = `${location.pathname}${location.search}`;
|
|
329
|
+
const matchOptions = { matchNested: this.matchNested };
|
|
330
|
+
return (
|
|
331
|
+
matchPaths(browserPath, this.path, matchOptions) ||
|
|
332
|
+
this.pathAliases.some((alias) => matchPaths(browserPath, alias, matchOptions))
|
|
333
|
+
);
|
|
309
334
|
}
|
|
310
335
|
}
|
|
311
336
|
|
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": "24.5.0-
|
|
4
|
+
"version": "24.5.0-rc1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -41,6 +41,15 @@
|
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"name": "match-nested",
|
|
46
|
+
"description": "Whether to also match nested paths / routes. `false` by default.\n\nWhen enabled, an item with the path `/path` is considered current when\nthe browser URL is `/path`, `/path/child`, `/path/child/grandchild`,\netc.\n\nNote that this only affects matching of the URLs path, not the base\norigin or query parameters.",
|
|
47
|
+
"value": {
|
|
48
|
+
"type": [
|
|
49
|
+
"boolean"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
44
53
|
{
|
|
45
54
|
"name": "target",
|
|
46
55
|
"description": "The target of the link. Works only when `path` is set.",
|
|
@@ -124,6 +133,15 @@
|
|
|
124
133
|
]
|
|
125
134
|
}
|
|
126
135
|
},
|
|
136
|
+
{
|
|
137
|
+
"name": "matchNested",
|
|
138
|
+
"description": "Whether to also match nested paths / routes. `false` by default.\n\nWhen enabled, an item with the path `/path` is considered current when\nthe browser URL is `/path`, `/path/child`, `/path/child/grandchild`,\netc.\n\nNote that this only affects matching of the URLs path, not the base\norigin or query parameters.",
|
|
139
|
+
"value": {
|
|
140
|
+
"type": [
|
|
141
|
+
"boolean"
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
127
145
|
{
|
|
128
146
|
"name": "target",
|
|
129
147
|
"description": "The target of the link. Works only when `path` is set.",
|
package/web-types.lit.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": "24.5.0-
|
|
4
|
+
"version": "24.5.0-rc1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -33,6 +33,13 @@
|
|
|
33
33
|
"kind": "expression"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
"name": "?matchNested",
|
|
38
|
+
"description": "Whether to also match nested paths / routes. `false` by default.\n\nWhen enabled, an item with the path `/path` is considered current when\nthe browser URL is `/path`, `/path/child`, `/path/child/grandchild`,\netc.\n\nNote that this only affects matching of the URLs path, not the base\norigin or query parameters.",
|
|
39
|
+
"value": {
|
|
40
|
+
"kind": "expression"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
36
43
|
{
|
|
37
44
|
"name": "?routerIgnore",
|
|
38
45
|
"description": "Whether to exclude the item from client-side routing. When enabled,\nthis causes the item to behave like a regular anchor, causing a full\npage reload. This only works with supported routers, such as the one\nprovided in Vaadin apps, or when using the side nav `onNavigate` hook.",
|