Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vaadin/side-nav

Package Overview
Dependencies
Maintainers
12
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vaadin/side-nav - npm Package Compare versions

Comparing version 24.4.0-alpha13 to 24.4.0-alpha14

14

package.json
{
"name": "@vaadin/side-nav",
"version": "24.4.0-alpha13",
"version": "24.4.0-alpha14",
"publishConfig": {

@@ -38,7 +38,7 @@ "access": "public"

"@open-wc/dedupe-mixin": "^1.3.0",
"@vaadin/a11y-base": "24.4.0-alpha13",
"@vaadin/component-base": "24.4.0-alpha13",
"@vaadin/vaadin-lumo-styles": "24.4.0-alpha13",
"@vaadin/vaadin-material-styles": "24.4.0-alpha13",
"@vaadin/vaadin-themable-mixin": "24.4.0-alpha13",
"@vaadin/a11y-base": "24.4.0-alpha14",
"@vaadin/component-base": "24.4.0-alpha14",
"@vaadin/vaadin-lumo-styles": "24.4.0-alpha14",
"@vaadin/vaadin-material-styles": "24.4.0-alpha14",
"@vaadin/vaadin-themable-mixin": "24.4.0-alpha14",
"lit": "^3.0.0"

@@ -56,3 +56,3 @@ },

],
"gitHead": "97246b0703cd04a4b0ea5dcd49e2581d45cf6367"
"gitHead": "303c07338b748bc6036a92a92cf1733c3bc351eb"
}

@@ -97,5 +97,10 @@ /**

/**
* Whether the path of the item matches the current path.
* Set when the item is appended to DOM or when navigated back
* to the page that contains this item using the browser.
* Whether the item's path matches the current browser URL.
*
* A match occurs when both share the same base origin (like https://example.com),
* the same path (like /path/to/page), and the browser URL contains all
* the query parameters with the same values from the item's path.
*
* The state is updated when the item is added to the DOM or when the browser
* navigates to a new page.
*/

@@ -102,0 +107,0 @@ readonly current: boolean;

@@ -118,6 +118,11 @@ /**

/**
* Whether the path of the item matches the current path.
* Set when the item is appended to DOM or when navigated back
* to the page that contains this item using the browser.
* Whether the item's path matches the current browser URL.
*
* A match occurs when both share the same base origin (like https://example.com),
* the same path (like /path/to/page), and the browser URL contains at least
* all the query parameters with the same values from the item's path.
*
* The state is updated when the item is added to the DOM or when the browser
* navigates to a new page.
*
* @type {boolean}

@@ -193,2 +198,3 @@ */

window.addEventListener('popstate', this.__boundUpdateCurrent);
window.addEventListener('side-nav-location-changed', this.__boundUpdateCurrent);
}

@@ -200,2 +206,3 @@

window.removeEventListener('popstate', this.__boundUpdateCurrent);
window.removeEventListener('side-nav-location-changed', this.__boundUpdateCurrent);
}

@@ -270,6 +277,5 @@

}
return (
matchPaths(document.location.pathname, this.path) ||
this.pathAliases.some((alias) => matchPaths(document.location.pathname, alias))
);
const browserPath = `${document.location.pathname}${document.location.search}`;
return matchPaths(browserPath, this.path) || this.pathAliases.some((alias) => matchPaths(browserPath, alias));
}

@@ -276,0 +282,0 @@ }

@@ -10,2 +10,3 @@ /**

import { SideNavChildrenMixin, type SideNavI18n } from './vaadin-side-nav-children-mixin.js';
import type { SideNavItem } from './vaadin-side-nav-item.js';

@@ -25,2 +26,11 @@ export type { SideNavI18n };

export type NavigateEvent = {
path: SideNavItem['path'];
target: SideNavItem['target'];
current: SideNavItem['current'];
expanded: SideNavItem['expanded'];
pathAliases: SideNavItem['pathAliases'];
originalEvent: MouseEvent;
};
/**

@@ -88,2 +98,36 @@ * `<vaadin-side-nav>` is a Web Component for navigation menus.

/**
* Callback function for router integration.
*
* When a side nav item link is clicked, this function is called and the default click action is cancelled.
* This delegates the responsibility of navigation to the function's logic.
*
* The click event action is not cancelled in the following cases:
* - The click event has a modifier (e.g. `metaKey`, `shiftKey`)
* - The click event is on an external link
* - The click event is on a link with `target="_blank"`
* - The function explicitly returns `false`
*
* The function receives an object with the properties of the clicked side-nav item:
* - `path`: The path of the navigation item.
* - `target`: The target of the navigation item.
* - `current`: A boolean indicating whether the navigation item is currently selected.
* - `expanded`: A boolean indicating whether the navigation item is expanded.
* - `pathAliases`: An array of path aliases for the navigation item.
* - `originalEvent`: The original DOM event that triggered the navigation.
*
* Also see the `location` property for updating the highlighted navigation item on route change.
*/
onNavigate?: ((event: NavigateEvent) => boolean) | ((event: NavigateEvent) => void);
/**
* A change to this property triggers an update of the highlighted item in the side navigation. While it typically
* corresponds to the browser's URL, the specific value assigned to the property is irrelevant. The component has
* its own internal logic for determining which item is highlighted.
*
* The main use case for this property is when the side navigation is used with a client-side router. In this case,
* the component needs to be informed about route changes so it can update the highlighted item.
*/
location: any;
addEventListener<K extends keyof SideNavEventMap>(

@@ -90,0 +134,0 @@ type: K,

@@ -106,2 +106,44 @@ /**

},
/**
* Callback function for router integration.
*
* When a side nav item link is clicked, this function is called and the default click action is cancelled.
* This delegates the responsibility of navigation to the function's logic.
*
* The click event action is not cancelled in the following cases:
* - The click event has a modifier (e.g. `metaKey`, `shiftKey`)
* - The click event is on an external link
* - The click event is on a link with `target="_blank"`
* - The function explicitly returns `false`
*
* The function receives an object with the properties of the clicked side-nav item:
* - `path`: The path of the navigation item.
* - `target`: The target of the navigation item.
* - `current`: A boolean indicating whether the navigation item is currently selected.
* - `expanded`: A boolean indicating whether the navigation item is expanded.
* - `pathAliases`: An array of path aliases for the navigation item.
* - `originalEvent`: The original DOM event that triggered the navigation.
*
* Also see the `location` property for updating the highlighted navigation item on route change.
*
* @type {function(Object): boolean | undefined}
*/
onNavigate: {
attribute: false,
},
/**
* A change to this property triggers an update of the highlighted item in the side navigation. While it typically
* corresponds to the browser's URL, the specific value assigned to the property is irrelevant. The component has
* its own internal logic for determining which item is highlighted.
*
* The main use case for this property is when the side navigation is used with a client-side router. In this case,
* the component needs to be informed about route changes so it can update the highlighted item.
*
* @type {any}
*/
location: {
observer: '__locationChanged',
},
};

@@ -118,2 +160,3 @@ }

this._labelId = `side-nav-label-${generateUniqueId()}`;
this.addEventListener('click', this.__onClick);
}

@@ -209,5 +252,57 @@

/** @private */
__locationChanged() {
window.dispatchEvent(new CustomEvent('side-nav-location-changed'));
}
/** @private */
__toggleCollapsed() {
this.collapsed = !this.collapsed;
}
/** @private */
__onClick(e) {
if (!this.onNavigate) {
return;
}
const hasModifier = e.metaKey || e.shiftKey;
if (hasModifier) {
// Allow default action for clicks with modifiers
return;
}
const composedPath = e.composedPath();
const item = composedPath.find((el) => el.localName && el.localName.includes('side-nav-item'));
const anchor = composedPath.find((el) => el instanceof HTMLAnchorElement);
if (!item || !item.shadowRoot.contains(anchor)) {
// Not a click on a side-nav-item anchor
return;
}
const isRelative = anchor.href && anchor.href.startsWith(location.origin);
if (!isRelative) {
// Allow default action for external links
return;
}
if (item.target === '_blank') {
// Allow default action for links with target="_blank"
return;
}
// Call the onNavigate callback
const result = this.onNavigate({
path: item.path,
target: item.target,
current: item.current,
expanded: item.expanded,
pathAliases: item.pathAliases,
originalEvent: e,
});
if (result !== false) {
// Cancel the default action if the callback didn't return false
e.preventDefault();
}
}
}

@@ -214,0 +309,0 @@

{
"$schema": "https://json.schemastore.org/web-types",
"name": "@vaadin/side-nav",
"version": "24.4.0-alpha13",
"version": "24.4.0-alpha14",
"description-markup": "markdown",

@@ -161,2 +161,21 @@ "contributions": {

{
"name": "on-navigate",
"description": "Callback function for router integration.\n\nWhen a side nav item link is clicked, this function is called and the default click action is cancelled.\nThis delegates the responsibility of navigation to the function's logic.\n\nThe click event action is not cancelled in the following cases:\n- The click event has a modifier (e.g. `metaKey`, `shiftKey`)\n- The click event is on an external link\n- The click event is on a link with `target=\"_blank\"`\n- The function explicitly returns `false`\n\nThe function receives an object with the properties of the clicked side-nav item:\n- `path`: The path of the navigation item.\n- `target`: The target of the navigation item.\n- `current`: A boolean indicating whether the navigation item is currently selected.\n- `expanded`: A boolean indicating whether the navigation item is expanded.\n- `pathAliases`: An array of path aliases for the navigation item.\n- `originalEvent`: The original DOM event that triggered the navigation.\n\nAlso see the `location` property for updating the highlighted navigation item on route change.",
"value": {
"type": [
"function Object: boolean",
"undefined"
]
}
},
{
"name": "location",
"description": "A change to this property triggers an update of the highlighted item in the side navigation. While it typically\ncorresponds to the browser's URL, the specific value assigned to the property is irrelevant. The component has\nits own internal logic for determining which item is highlighted.\n\nThe main use case for this property is when the side navigation is used with a client-side router. In this case,\nthe component needs to be informed about route changes so it can update the highlighted item.",
"value": {
"type": [
"any"
]
}
},
{
"name": "theme",

@@ -201,2 +220,21 @@ "description": "The theme variants to apply to the component.",

}
},
{
"name": "onNavigate",
"description": "Callback function for router integration.\n\nWhen a side nav item link is clicked, this function is called and the default click action is cancelled.\nThis delegates the responsibility of navigation to the function's logic.\n\nThe click event action is not cancelled in the following cases:\n- The click event has a modifier (e.g. `metaKey`, `shiftKey`)\n- The click event is on an external link\n- The click event is on a link with `target=\"_blank\"`\n- The function explicitly returns `false`\n\nThe function receives an object with the properties of the clicked side-nav item:\n- `path`: The path of the navigation item.\n- `target`: The target of the navigation item.\n- `current`: A boolean indicating whether the navigation item is currently selected.\n- `expanded`: A boolean indicating whether the navigation item is expanded.\n- `pathAliases`: An array of path aliases for the navigation item.\n- `originalEvent`: The original DOM event that triggered the navigation.\n\nAlso see the `location` property for updating the highlighted navigation item on route change.",
"value": {
"type": [
"function Object: boolean",
"undefined"
]
}
},
{
"name": "location",
"description": "A change to this property triggers an update of the highlighted item in the side navigation. While it typically\ncorresponds to the browser's URL, the specific value assigned to the property is irrelevant. The component has\nits own internal logic for determining which item is highlighted.\n\nThe main use case for this property is when the side navigation is used with a client-side router. In this case,\nthe component needs to be informed about route changes so it can update the highlighted item.",
"value": {
"type": [
"any"
]
}
}

@@ -203,0 +241,0 @@ ],

{
"$schema": "https://json.schemastore.org/web-types",
"name": "@vaadin/side-nav",
"version": "24.4.0-alpha13",
"version": "24.4.0-alpha14",
"description-markup": "markdown",

@@ -93,2 +93,9 @@ "framework": "lit",

{
"name": "?onNavigate",
"description": "Callback function for router integration.\n\nWhen a side nav item link is clicked, this function is called and the default click action is cancelled.\nThis delegates the responsibility of navigation to the function's logic.\n\nThe click event action is not cancelled in the following cases:\n- The click event has a modifier (e.g. `metaKey`, `shiftKey`)\n- The click event is on an external link\n- The click event is on a link with `target=\"_blank\"`\n- The function explicitly returns `false`\n\nThe function receives an object with the properties of the clicked side-nav item:\n- `path`: The path of the navigation item.\n- `target`: The target of the navigation item.\n- `current`: A boolean indicating whether the navigation item is currently selected.\n- `expanded`: A boolean indicating whether the navigation item is expanded.\n- `pathAliases`: An array of path aliases for the navigation item.\n- `originalEvent`: The original DOM event that triggered the navigation.\n\nAlso see the `location` property for updating the highlighted navigation item on route change.",
"value": {
"kind": "expression"
}
},
{
"name": ".i18n",

@@ -101,2 +108,9 @@ "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```",

{
"name": ".location",
"description": "A change to this property triggers an update of the highlighted item in the side navigation. While it typically\ncorresponds to the browser's URL, the specific value assigned to the property is irrelevant. The component has\nits own internal logic for determining which item is highlighted.\n\nThe main use case for this property is when the side navigation is used with a client-side router. In this case,\nthe component needs to be informed about route changes so it can update the highlighted item.",
"value": {
"kind": "expression"
}
},
{
"name": "@collapsed-changed",

@@ -103,0 +117,0 @@ "description": "Fired when the `collapsed` property changes.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc