@equinor/amplify-component-lib 8.7.0 → 8.7.1
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.
|
@@ -3,8 +3,20 @@ import { SideBarMenuItem } from '../../atoms/types/SideBar';
|
|
|
3
3
|
export type MenuItemProps = {
|
|
4
4
|
currentUrl?: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* This is useful for routes that drills into a path,
|
|
8
|
+
* by still highlighting the original path and not disable "back to start" by click on the same link again
|
|
9
|
+
* eg. navigating to /collections and clicking on an item to go into /collections/:id and so on
|
|
10
|
+
*/
|
|
11
|
+
hasPathDrilling?: boolean;
|
|
6
12
|
} & SideBarMenuItem & HTMLAttributes<HTMLAnchorElement>;
|
|
7
13
|
export declare const MenuItem: import("react").ForwardRefExoticComponent<{
|
|
8
14
|
currentUrl?: string;
|
|
9
15
|
disabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* This is useful for routes that drills into a path,
|
|
18
|
+
* by still highlighting the original path and not disable "back to start" by click on the same link again
|
|
19
|
+
* eg. navigating to /collections and clicking on an item to go into /collections/:id and so on
|
|
20
|
+
*/
|
|
21
|
+
hasPathDrilling?: boolean;
|
|
10
22
|
} & SideBarMenuItem & HTMLAttributes<HTMLAnchorElement> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as i}from"react/jsx-runtime";import{forwardRef as t,useMemo as r}from"react";import{Icon as a}from"@equinor/eds-core-react";import{Link as n,IconContainer as o,ItemText as
|
|
1
|
+
import{jsxs as e,jsx as i}from"react/jsx-runtime";import{forwardRef as t,useMemo as r}from"react";import{Icon as a}from"@equinor/eds-core-react";import{Link as n,IconContainer as o,ItemText as l}from"./MenuItem.styles.js";import{isCurrentUrl as d}from"./MenuItem.utils.js";import{OptionalTooltip as s}from"../../molecules/OptionalTooltip/OptionalTooltip.js";import{useSideBar as c}from"../../providers/SideBarProvider.js";const m=t((({currentUrl:t,icon:m,name:p,link:u,onClick:b,disabled:h=!1,replace:f=!1,hasPathDrilling:v=!1},$)=>{const g=d({currentUrl:t,link:u,replace:f,hasPathDrilling:v}),{isOpen:j}=c(),k=r((()=>!h&&!g),[h,g]),I=e=>{k?b&&b():e.preventDefault()};return j?e(n,{to:u,$active:g,"aria-disabled":h,$disabled:h,onClick:I,tabIndex:0,$open:!0,ref:$,"data-testid":"sidebar-menu-item",replace:f,children:[m&&i(o,{"data-testid":"icon-container",children:i(a,{data:m,size:24})}),i(l,{$active:g,$disabled:h,variant:"button",group:"navigation",children:p})]}):i(n,{to:u,$active:g,"aria-disabled":h,$disabled:h,onClick:I,$open:j,tabIndex:0,ref:$,"data-testid":"sidebar-menu-item",children:i(s,{title:p,placement:"right",children:m&&i(o,{"data-testid":"icon-container",children:i(a,{data:m,size:24})})})})}));m.displayName="MenuItem";export{m as MenuItem};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
currentUrl?: string;
|
|
3
|
+
link: string;
|
|
4
|
+
replace: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* This is useful for routes that drills into a path,
|
|
7
|
+
* by still highlighting the original path and not disable "back to start" by click on the same link again
|
|
8
|
+
* eg. navigating to /collections and clicking on an item to go into /collections/:id and so on
|
|
9
|
+
*/
|
|
10
|
+
hasPathDrilling: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const isCurrentUrl: ({ currentUrl, link, replace, hasPathDrilling, }: Props) => boolean;
|
|
13
|
+
export { isCurrentUrl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=({currentUrl:e,link:l,replace:n,hasPathDrilling:r})=>n?r?e?.includes(l)??!1:"string"==typeof e&&e===l:e?.includes(l)??!1;export{e as isCurrentUrl};
|