@servicetitan/navigation 12.0.3 → 13.0.0-canary.256.b43c6d7.0
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/dist/components/profile-dropdown/{profile-dropdown-tiny.stories.d.ts → profile-dropdown-legacy.stories.d.ts} +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-legacy.stories.d.ts.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +5 -8
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/interface.d.ts +14 -12
- package/dist/components/titan-layout/interface.d.ts.map +1 -1
- package/dist/components/titan-layout/interface.js.map +1 -1
- package/dist/components/titan-layout/layout-header-links.d.ts +3 -3
- package/dist/components/titan-layout/layout-header-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-links.js.map +1 -1
- package/dist/components/titan-layout/layout-header.d.ts +2 -2
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.js +1 -7
- package/dist/components/titan-layout/layout-profile.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +10 -17
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +34 -41
- package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.d.ts +3 -3
- package/dist/components/titan-layout/layout-sidebar-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.js +13 -13
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +5 -3
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/titan-layout-links.d.ts +5 -0
- package/dist/components/titan-layout/titan-layout-links.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout-links.js +34 -0
- package/dist/components/titan-layout/titan-layout-links.js.map +1 -0
- package/dist/components/titan-layout/titan-layout.d.ts +2 -3
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +3 -3
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/test/data.d.ts +27 -2
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +181 -27
- package/dist/test/data.js.map +1 -1
- package/dist/utils/navigation-context.d.ts +3 -22
- package/dist/utils/navigation-context.d.ts.map +1 -1
- package/dist/utils/navigation-context.js +2 -10
- package/dist/utils/navigation-context.js.map +1 -1
- package/dist/utils/navigation.d.ts +2 -5
- package/dist/utils/navigation.d.ts.map +1 -1
- package/dist/utils/navigation.js.map +1 -1
- package/package.json +2 -2
- package/src/components/profile-dropdown/{profile-dropdown-tiny.stories.tsx → profile-dropdown-legacy.stories.tsx} +6 -6
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +12 -4
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +16 -9
- package/src/components/profile-dropdown/profile-dropdown.tsx +2 -11
- package/src/components/titan-layout/interface.ts +19 -15
- package/src/components/titan-layout/layout-header-links.tsx +3 -6
- package/src/components/titan-layout/layout-header.tsx +2 -2
- package/src/components/titan-layout/layout-profile.tsx +2 -6
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +69 -81
- package/src/components/titan-layout/layout-sidebar-links.tsx +38 -24
- package/src/components/titan-layout/layout-sidebar.tsx +1 -1
- package/src/components/titan-layout/titan-layout-links.tsx +34 -0
- package/src/components/titan-layout/titan-layout.stories.tsx +34 -33
- package/src/components/titan-layout/titan-layout.tsx +5 -4
- package/src/index.ts +1 -11
- package/src/test/data.tsx +152 -39
- package/src/utils/navigation-context.tsx +9 -35
- package/src/utils/navigation.ts +3 -7
- package/dist/components/header-navigation/header-navigation-content.d.ts +0 -30
- package/dist/components/header-navigation/header-navigation-content.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-content.js +0 -58
- package/dist/components/header-navigation/header-navigation-content.js.map +0 -1
- package/dist/components/header-navigation/header-navigation-extra-stacked.stories.d.ts +0 -9
- package/dist/components/header-navigation/header-navigation-extra-stacked.stories.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts +0 -12
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-links.d.ts +0 -11
- package/dist/components/header-navigation/header-navigation-links.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-links.js +0 -62
- package/dist/components/header-navigation/header-navigation-links.js.map +0 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts +0 -12
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-stories.module.less +0 -6
- package/dist/components/header-navigation/header-navigation-stories.module.less.d.ts +0 -3
- package/dist/components/header-navigation/header-navigation.d.ts +0 -59
- package/dist/components/header-navigation/header-navigation.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation.js +0 -228
- package/dist/components/header-navigation/header-navigation.js.map +0 -1
- package/dist/components/header-navigation/header-navigation.module.less +0 -260
- package/dist/components/header-navigation/header-navigation.module.less.d.ts +0 -22
- package/dist/components/header-navigation/header-navigation.stories.d.ts +0 -12
- package/dist/components/header-navigation/header-navigation.stories.d.ts.map +0 -1
- package/dist/components/header-navigation/index.d.ts +0 -2
- package/dist/components/header-navigation/index.d.ts.map +0 -1
- package/dist/components/header-navigation/index.js +0 -3
- package/dist/components/header-navigation/index.js.map +0 -1
- package/dist/components/header-navigation/with-tooltip.d.ts +0 -4
- package/dist/components/header-navigation/with-tooltip.d.ts.map +0 -1
- package/dist/components/header-navigation/with-tooltip.js +0 -10
- package/dist/components/header-navigation/with-tooltip.js.map +0 -1
- package/dist/components/layout.stories.d.ts +0 -13
- package/dist/components/layout.stories.d.ts.map +0 -1
- package/dist/components/left-navigation/header-navigation-extra-tiny.stories.d.ts +0 -9
- package/dist/components/left-navigation/header-navigation-extra-tiny.stories.d.ts.map +0 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts +0 -18
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts.map +0 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.js +0 -79
- package/dist/components/left-navigation/header-navigation-tiny-links.js.map +0 -1
- package/dist/components/left-navigation/header-navigation-tiny.d.ts +0 -23
- package/dist/components/left-navigation/header-navigation-tiny.d.ts.map +0 -1
- package/dist/components/left-navigation/header-navigation-tiny.js +0 -32
- package/dist/components/left-navigation/header-navigation-tiny.js.map +0 -1
- package/dist/components/left-navigation/header-navigation-tiny.module.less +0 -117
- package/dist/components/left-navigation/header-navigation-tiny.module.less.d.ts +0 -15
- package/dist/components/left-navigation/header-navigation-tiny.stories.d.ts +0 -12
- package/dist/components/left-navigation/header-navigation-tiny.stories.d.ts.map +0 -1
- package/dist/components/left-navigation/index.d.ts +0 -5
- package/dist/components/left-navigation/index.d.ts.map +0 -1
- package/dist/components/left-navigation/index.js +0 -5
- package/dist/components/left-navigation/index.js.map +0 -1
- package/dist/components/left-navigation/interface-internal.d.ts +0 -10
- package/dist/components/left-navigation/interface-internal.d.ts.map +0 -1
- package/dist/components/left-navigation/interface-internal.js +0 -3
- package/dist/components/left-navigation/interface-internal.js.map +0 -1
- package/dist/components/left-navigation/interface.d.ts +0 -20
- package/dist/components/left-navigation/interface.d.ts.map +0 -1
- package/dist/components/left-navigation/interface.js +0 -3
- package/dist/components/left-navigation/interface.js.map +0 -1
- package/dist/components/left-navigation/side-navigation-context.d.ts +0 -8
- package/dist/components/left-navigation/side-navigation-context.d.ts.map +0 -1
- package/dist/components/left-navigation/side-navigation-context.js +0 -8
- package/dist/components/left-navigation/side-navigation-context.js.map +0 -1
- package/dist/components/left-navigation/side-navigation-links-internal.d.ts +0 -28
- package/dist/components/left-navigation/side-navigation-links-internal.d.ts.map +0 -1
- package/dist/components/left-navigation/side-navigation-links-internal.js +0 -89
- package/dist/components/left-navigation/side-navigation-links-internal.js.map +0 -1
- package/dist/components/left-navigation/side-navigation-links.d.ts +0 -6
- package/dist/components/left-navigation/side-navigation-links.d.ts.map +0 -1
- package/dist/components/left-navigation/side-navigation-links.js +0 -48
- package/dist/components/left-navigation/side-navigation-links.js.map +0 -1
- package/dist/components/left-navigation/side-navigation.d.ts +0 -29
- package/dist/components/left-navigation/side-navigation.d.ts.map +0 -1
- package/dist/components/left-navigation/side-navigation.js +0 -411
- package/dist/components/left-navigation/side-navigation.js.map +0 -1
- package/dist/components/left-navigation/side-navigation.module.less +0 -530
- package/dist/components/left-navigation/side-navigation.module.less.d.ts +0 -48
- package/dist/components/left-navigation/side-navigation.stories.d.ts +0 -17
- package/dist/components/left-navigation/side-navigation.stories.d.ts.map +0 -1
- package/dist/components/left-navigation/with-tooltip.d.ts +0 -4
- package/dist/components/left-navigation/with-tooltip.d.ts.map +0 -1
- package/dist/components/left-navigation/with-tooltip.js +0 -15
- package/dist/components/left-navigation/with-tooltip.js.map +0 -1
- package/dist/components/links.d.ts +0 -5
- package/dist/components/links.d.ts.map +0 -1
- package/dist/components/links.js +0 -35
- package/dist/components/links.js.map +0 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts.map +0 -1
- package/dist/components/titan-layout/layout-profile.stories.d.ts +0 -13
- package/dist/components/titan-layout/layout-profile.stories.d.ts.map +0 -1
- package/src/components/header-navigation/header-navigation-content.tsx +0 -120
- package/src/components/header-navigation/header-navigation-extra-stacked.stories.tsx +0 -19
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +0 -142
- package/src/components/header-navigation/header-navigation-links.tsx +0 -141
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +0 -146
- package/src/components/header-navigation/header-navigation-stories.module.less +0 -6
- package/src/components/header-navigation/header-navigation-stories.module.less.d.ts +0 -3
- package/src/components/header-navigation/header-navigation.module.less +0 -260
- package/src/components/header-navigation/header-navigation.module.less.d.ts +0 -22
- package/src/components/header-navigation/header-navigation.stories.tsx +0 -165
- package/src/components/header-navigation/header-navigation.tsx +0 -327
- package/src/components/header-navigation/index.ts +0 -1
- package/src/components/header-navigation/with-tooltip.tsx +0 -15
- package/src/components/layout.stories.tsx +0 -103
- package/src/components/left-navigation/header-navigation-extra-tiny.stories.tsx +0 -21
- package/src/components/left-navigation/header-navigation-tiny-links.tsx +0 -145
- package/src/components/left-navigation/header-navigation-tiny.module.less +0 -117
- package/src/components/left-navigation/header-navigation-tiny.module.less.d.ts +0 -15
- package/src/components/left-navigation/header-navigation-tiny.stories.tsx +0 -178
- package/src/components/left-navigation/header-navigation-tiny.tsx +0 -65
- package/src/components/left-navigation/index.ts +0 -4
- package/src/components/left-navigation/interface-internal.ts +0 -11
- package/src/components/left-navigation/interface.ts +0 -26
- package/src/components/left-navigation/side-navigation-context.tsx +0 -13
- package/src/components/left-navigation/side-navigation-links-internal.tsx +0 -151
- package/src/components/left-navigation/side-navigation-links.tsx +0 -57
- package/src/components/left-navigation/side-navigation.module.less +0 -530
- package/src/components/left-navigation/side-navigation.module.less.d.ts +0 -48
- package/src/components/left-navigation/side-navigation.stories.tsx +0 -226
- package/src/components/left-navigation/side-navigation.tsx +0 -543
- package/src/components/left-navigation/with-tooltip.tsx +0 -16
- package/src/components/links.tsx +0 -54
- package/src/components/titan-layout/layout-profile.stories.tsx +0 -46
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface NavLinkComponentPropsStrict {
|
|
1
|
+
import { ComponentPropsWithoutRef, FC } from 'react';
|
|
2
|
+
export type NavLinkComponentProps = ComponentPropsWithoutRef<'a'> & {
|
|
4
3
|
to: string;
|
|
5
|
-
title?: string;
|
|
6
|
-
className?: string;
|
|
7
4
|
activeClassName?: string;
|
|
8
|
-
children: ReactNode;
|
|
9
5
|
isActive?: (pathname: string) => boolean;
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export interface NavLinkComponentProps extends NavLinkComponentPropsStrict {
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
}
|
|
6
|
+
};
|
|
15
7
|
export declare const DefaultNavLinkComponent: FC<NavLinkComponentProps>;
|
|
16
|
-
export interface NavigationLocationInfo {
|
|
17
|
-
pathname: string;
|
|
18
|
-
}
|
|
19
|
-
export type NavigationActiveLinkMatcher = (location: NavigationLocationInfo, link: NavigationLinkData) => boolean;
|
|
20
|
-
export interface NavigationLocationContextType {
|
|
21
|
-
location: NavigationLocationInfo;
|
|
22
|
-
isLinkActive: NavigationActiveLinkMatcher;
|
|
23
|
-
}
|
|
24
|
-
export declare const NavigationComponentContext: import("react").Context<FC<NavLinkComponentProps>>;
|
|
25
|
-
export declare const NavigationLegacyContext: import("react").Context<boolean>;
|
|
26
|
-
export declare const NavigationLocationContext: import("react").Context<NavigationLocationContextType>;
|
|
27
8
|
//# sourceMappingURL=navigation-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-context.d.ts","sourceRoot":"","sources":["../../src/utils/navigation-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"navigation-context.d.ts","sourceRoot":"","sources":["../../src/utils/navigation-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAErD,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,GAAG,CAAC,GAAG;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,qBAAqB,CAU7D,CAAC"}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export const DefaultNavLinkComponent = ({ children, to, activeClassName, isActive, ...props })=>/*#__PURE__*/ _jsx("a", {
|
|
3
|
+
href: to,
|
|
4
4
|
...props,
|
|
5
5
|
children: children
|
|
6
6
|
});
|
|
7
|
-
export const NavigationComponentContext = /*#__PURE__*/ createContext(DefaultNavLinkComponent);
|
|
8
|
-
export const NavigationLegacyContext = /*#__PURE__*/ createContext(false);
|
|
9
|
-
export const NavigationLocationContext = /*#__PURE__*/ createContext({
|
|
10
|
-
location: {
|
|
11
|
-
pathname: ''
|
|
12
|
-
},
|
|
13
|
-
isLinkActive: ()=>false
|
|
14
|
-
});
|
|
15
7
|
|
|
16
8
|
//# sourceMappingURL=navigation-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/navigation-context.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/navigation-context.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, FC } from 'react';\n\nexport type NavLinkComponentProps = ComponentPropsWithoutRef<'a'> & {\n to: string;\n activeClassName?: string;\n isActive?: (pathname: string) => boolean;\n};\n\nexport const DefaultNavLinkComponent: FC<NavLinkComponentProps> = ({\n children,\n to,\n activeClassName,\n isActive,\n ...props\n}) => (\n <a href={to} {...props}>\n {children}\n </a>\n);\n"],"names":["DefaultNavLinkComponent","children","to","activeClassName","isActive","props","a","href"],"mappings":";AAQA,OAAO,MAAMA,0BAAqD,CAAC,EAC/DC,QAAQ,EACRC,EAAE,EACFC,eAAe,EACfC,QAAQ,EACR,GAAGC,OACN,iBACG,KAACC;QAAEC,MAAML;QAAK,GAAGG,KAAK;kBACjBJ;OAEP"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { IconProps } from '@servicetitan/anvil2';
|
|
2
|
-
import { FC } from 'react';
|
|
3
2
|
import { CounterTagData, CounterTagValue } from './counter-tag';
|
|
4
3
|
export interface NavigationItemData extends NavigationLinkData {
|
|
5
4
|
/** flag if the link is not shown (based on FG and/or user permissions) */
|
|
6
5
|
isHidden?: boolean;
|
|
7
|
-
/** custom className (can be used for mdi icons) */
|
|
8
|
-
iconClassName?: string;
|
|
9
6
|
/** svg icon (anvil2) of inactive item */
|
|
10
7
|
icon: IconProps['svg'] | undefined;
|
|
11
8
|
/** svg icon (anvil2) of active item */
|
|
12
9
|
iconActive: IconProps['svg'] | undefined;
|
|
13
|
-
/** icon component of item (<svg />) */
|
|
14
|
-
iconComponent?: FC;
|
|
15
10
|
/** item tag (optional). shown if it is set and true or greater than 0 */
|
|
16
11
|
counter?: CounterTagValue;
|
|
17
12
|
tag?: CounterTagData;
|
|
@@ -19,6 +14,8 @@ export interface NavigationItemData extends NavigationLinkData {
|
|
|
19
14
|
className?: string;
|
|
20
15
|
/** optional submenu of link item */
|
|
21
16
|
submenu?: NavigationSubmenuData;
|
|
17
|
+
iconClassName?: never;
|
|
18
|
+
iconComponent?: never;
|
|
22
19
|
}
|
|
23
20
|
export interface NavigationLinkData {
|
|
24
21
|
/** link id */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/utils/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/utils/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC1D,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yCAAyC;IACzC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAEnC,uCAAuC;IACvC,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAEzC,yEAAyE;IACzE,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,GAAG,CAAC,EAAE,cAAc,CAAC;IAErB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oCAAoC;IACpC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAEhC,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,aAAa,CAAC,EAAE,KAAK,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IAC/B,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IAEX,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;IAEX,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IAEd,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,qBAAqB;IAClC,qBAAqB;IACrB,MAAM,EAAE,0BAA0B,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACjE,+EAA+E;IAC/E,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,GAAG,CAAC,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACvC,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IAEd,0BAA0B;IAC1B,KAAK,EAAE,yBAAyB,EAAE,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/navigation.ts"],"sourcesContent":["import { IconProps } from '@servicetitan/anvil2';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/navigation.ts"],"sourcesContent":["import { IconProps } from '@servicetitan/anvil2';\nimport { CounterTagData, CounterTagValue } from './counter-tag';\n\nexport interface NavigationItemData extends NavigationLinkData {\n /** flag if the link is not shown (based on FG and/or user permissions) */\n isHidden?: boolean;\n\n /** svg icon (anvil2) of inactive item */\n icon: IconProps['svg'] | undefined;\n\n /** svg icon (anvil2) of active item */\n iconActive: IconProps['svg'] | undefined;\n\n /** item tag (optional). shown if it is set and true or greater than 0 */\n counter?: CounterTagValue;\n tag?: CounterTagData;\n\n /** class name of link item */\n className?: string;\n\n /** optional submenu of link item */\n submenu?: NavigationSubmenuData;\n\n iconClassName?: never;\n iconComponent?: never;\n}\n\nexport interface NavigationLinkData {\n /** link id */\n id: string;\n\n /** link href */\n to: string;\n\n /** link title */\n title: string;\n\n /** callback to return active state. By default, it compares link href with current pathname */\n isActive?: boolean | ((pathname: string) => boolean);\n}\n\nexport interface NavigationSubmenuData {\n /** submenu groups */\n groups: NavigationSubmenuGroupData[];\n}\n\nexport interface NavigationSubmenuItemData extends NavigationLinkData {\n /** item tag (optional) value. shown if it is set and true or greater than 0 */\n counter?: CounterTagValue;\n tag?: CounterTagData;\n}\n\nexport interface NavigationSubmenuGroupData {\n /** submenu group title */\n title: string;\n\n /** submenu group links */\n links: NavigationSubmenuItemData[];\n}\n"],"names":[],"mappings":"AAoDA,WAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/navigation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-canary.256.b43c6d7.0",
|
|
4
4
|
"description": "Navigation components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"less": true,
|
|
43
43
|
"webpack": false
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "b43c6d785de8f5055e173ac84493359f502dc296"
|
|
46
46
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { withAnvil, withMemoryRouter } from '../../test/data';
|
|
2
|
-
import {
|
|
1
|
+
import { NavLinkMock, withAnvil, withMemoryRouter } from '../../test/data';
|
|
2
|
+
import { TitanLayout } from '../titan-layout';
|
|
3
3
|
import { ProfileDropdown } from './profile-dropdown';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
<
|
|
5
|
+
const withLayout = (Story: any) => (
|
|
6
|
+
<TitanLayout navVariant="top" profile={<Story />} navigationComponent={NavLinkMock} />
|
|
7
7
|
);
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
|
-
title: 'Navigation/ProfileDropdown/
|
|
10
|
+
title: 'Navigation/ProfileDropdown/Legacy',
|
|
11
11
|
component: ProfileDropdown,
|
|
12
12
|
parameters: {},
|
|
13
|
-
decorators: [withMemoryRouter, withAnvil,
|
|
13
|
+
decorators: [withMemoryRouter, withAnvil, withLayout],
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export {
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { withAnvil, withMemoryRouter } from '../../test/data';
|
|
2
|
-
import {
|
|
1
|
+
import { NavLinkMock, navItems, withAnvil, withMemoryRouter } from '../../test/data';
|
|
2
|
+
import { TitanLayout } from '../titan-layout';
|
|
3
3
|
import { ProfileDropdown } from './profile-dropdown';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const withStackedLayout = (Story: any) => (
|
|
6
|
+
<TitanLayout
|
|
7
|
+
navVariant="top"
|
|
8
|
+
top={<div />}
|
|
9
|
+
profile={<Story />}
|
|
10
|
+
navigationMainItems={[navItems.accounting]}
|
|
11
|
+
navigationComponent={NavLinkMock}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
export default {
|
|
8
16
|
title: 'Navigation/ProfileDropdown/Stacked',
|
|
9
17
|
component: ProfileDropdown,
|
|
10
18
|
parameters: {},
|
|
11
|
-
decorators: [withMemoryRouter, withAnvil
|
|
19
|
+
decorators: [withStackedLayout, withMemoryRouter, withAnvil],
|
|
12
20
|
};
|
|
13
21
|
|
|
14
22
|
export {
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { Button } from '@servicetitan/design-system';
|
|
2
|
-
import { withAnvil, withMemoryRouter } from '../../test/data';
|
|
3
|
-
import {
|
|
2
|
+
import { NavLinkMock, withAnvil, withMemoryRouter } from '../../test/data';
|
|
3
|
+
import { TitanLayout } from '../titan-layout';
|
|
4
4
|
import { ProfileDropdown } from './profile-dropdown';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
<
|
|
8
|
-
<Story />
|
|
9
|
-
</HeaderNavigation>
|
|
6
|
+
const withLegacyLayout = (Story: any) => (
|
|
7
|
+
<TitanLayout navigationComponent={NavLinkMock} profile={<Story />} />
|
|
10
8
|
);
|
|
11
9
|
|
|
12
10
|
export default {
|
|
13
|
-
title: 'Navigation/ProfileDropdown/
|
|
11
|
+
title: 'Navigation/ProfileDropdown/Default',
|
|
14
12
|
component: ProfileDropdown,
|
|
15
13
|
parameters: {},
|
|
16
|
-
decorators: [withMemoryRouter, withAnvil
|
|
14
|
+
decorators: [withLegacyLayout, withMemoryRouter, withAnvil],
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
export const ProfileDropdownDefault = () => (
|
|
20
18
|
<ProfileDropdown>
|
|
21
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
19
|
+
<ProfileDropdown.Link id="first" to="https://google.com" external>
|
|
22
20
|
first link
|
|
23
21
|
</ProfileDropdown.Link>
|
|
24
22
|
<ProfileDropdown.Section id="second" onClick={() => alert('second click')}>
|
|
@@ -33,6 +31,15 @@ export const ProfileDropdownDefault = () => (
|
|
|
33
31
|
third link
|
|
34
32
|
</ProfileDropdown.Link>
|
|
35
33
|
<ProfileDropdown.Divider />
|
|
34
|
+
<ProfileDropdown.Section
|
|
35
|
+
id="forth"
|
|
36
|
+
onClick={() => alert('forth click')}
|
|
37
|
+
text="Sign Out user"
|
|
38
|
+
>
|
|
39
|
+
Sign Out
|
|
40
|
+
<span className="c-neutral-60 m-l-1">user</span>
|
|
41
|
+
</ProfileDropdown.Section>
|
|
42
|
+
<ProfileDropdown.Divider />
|
|
36
43
|
</ProfileDropdown>
|
|
37
44
|
);
|
|
38
45
|
|
|
@@ -13,22 +13,17 @@ import {
|
|
|
13
13
|
MouseEventHandler,
|
|
14
14
|
ReactNode,
|
|
15
15
|
useCallback,
|
|
16
|
-
useContext,
|
|
17
16
|
useEffect,
|
|
18
17
|
useMemo,
|
|
19
18
|
useState,
|
|
20
19
|
} from 'react';
|
|
21
20
|
|
|
22
21
|
import { CounterTagData, CounterTagValue } from '../../utils/counter-tag';
|
|
23
|
-
import {
|
|
24
|
-
NavigationComponentContext,
|
|
25
|
-
NavigationLegacyContext,
|
|
26
|
-
} from '../../utils/navigation-context';
|
|
27
22
|
import { getCounterTag } from '../../utils/side-nav';
|
|
28
23
|
import { CounterTag } from '../counter-tag';
|
|
24
|
+
import { useTitanLayoutContext } from '../titan-layout';
|
|
29
25
|
import { withTooltip } from '../titan-layout/with-tooltip';
|
|
30
26
|
import * as Styles from './profile-dropdown.module.less';
|
|
31
|
-
import { ProfileLogo } from './profile-icon';
|
|
32
27
|
|
|
33
28
|
export interface ProfileDropdownTriggerProps {
|
|
34
29
|
className?: string;
|
|
@@ -53,7 +48,6 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
53
48
|
}) => {
|
|
54
49
|
const [avatarSource, setAvatarSource] = useState(imageSrc ?? '');
|
|
55
50
|
const [avatarSourceError, setAvatarSourceError] = useState(false);
|
|
56
|
-
const isLegacy = useContext(NavigationLegacyContext);
|
|
57
51
|
|
|
58
52
|
useEffect(() => {
|
|
59
53
|
const src = imageSrc ?? '';
|
|
@@ -78,7 +72,6 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
78
72
|
Styles.triggerContainer,
|
|
79
73
|
{
|
|
80
74
|
[Styles.triggerContainerHintArrow]: hintArrow,
|
|
81
|
-
[Styles.triggerContainerLegacy]: isLegacy,
|
|
82
75
|
},
|
|
83
76
|
className
|
|
84
77
|
)}
|
|
@@ -93,8 +86,6 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
93
86
|
onError={onAvatarError}
|
|
94
87
|
alt="user dropdown menu"
|
|
95
88
|
/>
|
|
96
|
-
) : isLegacy ? (
|
|
97
|
-
<ProfileLogo />
|
|
98
89
|
) : (
|
|
99
90
|
<Icon
|
|
100
91
|
className="c-inherit-i"
|
|
@@ -255,7 +246,7 @@ export const ProfileDropdownLink: FC<ProfileDropdownLinkProps> = ({
|
|
|
255
246
|
onClick,
|
|
256
247
|
...rest
|
|
257
248
|
}: ProfileDropdownLinkProps) => {
|
|
258
|
-
const NavigationComponent =
|
|
249
|
+
const { NavigationComponent } = useTitanLayoutContext();
|
|
259
250
|
|
|
260
251
|
const isExternalLink = external ?? to?.startsWith('http');
|
|
261
252
|
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { FC,
|
|
1
|
+
import { ComponentPropsWithoutRef, FC, ReactNode } from 'react';
|
|
2
2
|
import { NavigationItemData } from '../../utils/navigation';
|
|
3
3
|
import { TitanLayoutSidebarContextType } from './layout-context';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
6
|
-
children:
|
|
7
|
-
| ReactElement<TitanLayoutSidebarLinkProps>
|
|
8
|
-
| ReactElement<TitanLayoutSidebarTriggerProps>;
|
|
5
|
+
export interface TitanLayoutLinkWrapperProps {
|
|
6
|
+
children: ReactNode;
|
|
9
7
|
context: TitanLayoutSidebarContextType;
|
|
8
|
+
isMobile: boolean;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export
|
|
13
|
-
wrapper?: FC<TitanLayoutSidebarLinkWrapperProps>;
|
|
14
|
-
}
|
|
15
|
-
export interface TitanLayoutSidebarTriggerProps
|
|
16
|
-
extends Omit<TitanLayoutSidebarLinkProps, 'to' | 'isActive'> {
|
|
17
|
-
isActive?: boolean;
|
|
18
|
-
wrapper?: FC<TitanLayoutSidebarLinkWrapperProps>;
|
|
19
|
-
onClick?: () => void;
|
|
20
|
-
onMobileClick?: () => void;
|
|
21
|
-
}
|
|
11
|
+
export type TitanLayoutLinkWrapper = FC<TitanLayoutLinkWrapperProps>;
|
|
22
12
|
|
|
23
13
|
export interface TitanLayoutState {
|
|
24
14
|
navCollapsed: boolean;
|
|
25
15
|
submenuExpanded?: string;
|
|
26
16
|
}
|
|
17
|
+
|
|
18
|
+
export type TitanLayoutLinkProps = Omit<NavigationItemData, 'submenu' | 'isHidden'> & {
|
|
19
|
+
tooltip?: string;
|
|
20
|
+
wrapper?: TitanLayoutLinkWrapper;
|
|
21
|
+
} & Omit<ComponentPropsWithoutRef<'a'>, 'children' | 'title'>;
|
|
22
|
+
|
|
23
|
+
export type TitanLayoutTriggerProps = Omit<
|
|
24
|
+
NavigationItemData,
|
|
25
|
+
'to' | 'isActive' | 'isHidden' | 'submenu'
|
|
26
|
+
> & {
|
|
27
|
+
isActive?: boolean;
|
|
28
|
+
tooltip?: string;
|
|
29
|
+
wrapper?: TitanLayoutLinkWrapper;
|
|
30
|
+
} & Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'title'>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
HeaderNavigationLinkProps,
|
|
4
|
-
HeaderNavigationTriggerProps,
|
|
5
|
-
} from '../../utils/navigation-legacy';
|
|
2
|
+
import { TitanLayoutLinkProps, TitanLayoutTriggerProps } from './interface';
|
|
6
3
|
import { useTitanLayoutContext } from './layout-context';
|
|
7
4
|
import {
|
|
8
5
|
InternalLayoutHeaderNavigationLink,
|
|
@@ -11,7 +8,7 @@ import {
|
|
|
11
8
|
import { withTooltip } from './with-tooltip';
|
|
12
9
|
|
|
13
10
|
/** Navigation extra item with link */
|
|
14
|
-
export const LayoutHeaderNavigationLink: FC<
|
|
11
|
+
export const LayoutHeaderNavigationLink: FC<TitanLayoutLinkProps> = ({ tooltip, ...rest }) => {
|
|
15
12
|
const { NavigationComponent } = useTitanLayoutContext();
|
|
16
13
|
|
|
17
14
|
return withTooltip(
|
|
@@ -21,7 +18,7 @@ export const LayoutHeaderNavigationLink: FC<HeaderNavigationLinkProps> = ({ tool
|
|
|
21
18
|
};
|
|
22
19
|
|
|
23
20
|
/** Navigation extra item with icon button */
|
|
24
|
-
export const LayoutHeaderNavigationTrigger: FC<
|
|
21
|
+
export const LayoutHeaderNavigationTrigger: FC<TitanLayoutTriggerProps> = ({
|
|
25
22
|
tooltip,
|
|
26
23
|
...rest
|
|
27
24
|
}) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SvgBurgerMenu from '@servicetitan/anvil2/assets/icons/material/round/menu.svg';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { ComponentPropsWithoutRef, FC, ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { ComponentPropsWithoutRef, FC, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
4
4
|
import { LayoutPlacementContext } from './layout-context';
|
|
5
5
|
import { LayoutHeaderNavigationTrigger } from './layout-header-links';
|
|
6
6
|
import * as Styles from './layout-header.module.less';
|
|
@@ -22,7 +22,7 @@ export type LayoutHeaderProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'
|
|
|
22
22
|
isMobile: boolean;
|
|
23
23
|
variant: 'light' | 'dark';
|
|
24
24
|
hasNotifications: boolean;
|
|
25
|
-
onBurgerClick?: (e: MouseEvent) => void;
|
|
25
|
+
onBurgerClick?: (e: MouseEvent<never>) => void;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export const LayoutHeader: FC<LayoutHeaderProps> = ({
|
|
@@ -2,7 +2,7 @@ import SvgAccountActive from '@servicetitan/anvil2/assets/icons/st/gnav_account_
|
|
|
2
2
|
import SvgAccountInactive from '@servicetitan/anvil2/assets/icons/st/gnav_account_inactive.svg';
|
|
3
3
|
|
|
4
4
|
import { FC, MouseEvent, useEffect, useState } from 'react';
|
|
5
|
-
import { NavLinkComponentProps
|
|
5
|
+
import { NavLinkComponentProps } from '../../utils/navigation-context';
|
|
6
6
|
import {
|
|
7
7
|
ProfileDropdown as DesktopProfileDropdown,
|
|
8
8
|
ProfileDropdownLinkProps,
|
|
@@ -38,13 +38,9 @@ const ExternalNavComponent: FC<NavLinkComponentProps> = ({
|
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
const ProfileDropdownContent: FC<ProfileDropdownProps> = props => {
|
|
41
|
-
const {
|
|
41
|
+
const { breakpoint, NavigationComponent } = useTitanLayoutContext();
|
|
42
42
|
return breakpoint.isMobile ? (
|
|
43
43
|
<MobileProfileDropdown {...props} navigationComponent={NavigationComponent} />
|
|
44
|
-
) : isTitanLayout ? (
|
|
45
|
-
<NavigationComponentContext.Provider value={NavigationComponent}>
|
|
46
|
-
<DesktopProfileDropdown {...props} />
|
|
47
|
-
</NavigationComponentContext.Provider>
|
|
48
44
|
) : (
|
|
49
45
|
<DesktopProfileDropdown {...props} />
|
|
50
46
|
);
|
|
@@ -7,22 +7,22 @@ import { FC, Fragment, MouseEvent, ReactNode } from 'react';
|
|
|
7
7
|
import { NavigationItemData, NavigationSubmenuItemData } from '../../utils/navigation';
|
|
8
8
|
import { getCounterTag } from '../../utils/side-nav';
|
|
9
9
|
import { BadgeTag, BadgeTagProps } from '../badge-tag';
|
|
10
|
-
import {
|
|
10
|
+
import { TitanLayoutLinkProps, TitanLayoutTriggerProps } from './interface';
|
|
11
11
|
import { NavigationComponentProps } from './interface-internal';
|
|
12
12
|
import * as Styles from './layout-sidebar.module.less';
|
|
13
13
|
|
|
14
|
-
export interface InternalSideNavigationItemContentProps
|
|
15
|
-
|
|
14
|
+
export interface InternalSideNavigationItemContentProps {
|
|
15
|
+
icon: TitanLayoutLinkProps['icon'];
|
|
16
|
+
iconActive: TitanLayoutLinkProps['iconActive'];
|
|
17
|
+
title: TitanLayoutLinkProps['title'];
|
|
16
18
|
submenuExpanded: boolean | undefined;
|
|
17
19
|
tag: BadgeTagProps | undefined;
|
|
18
20
|
onExpandToggle?: (e: MouseEvent<never>) => void;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
const InternalSideNavigationItemContent: FC<InternalSideNavigationItemContentProps> = ({
|
|
22
24
|
icon,
|
|
23
25
|
iconActive,
|
|
24
|
-
iconClassName,
|
|
25
|
-
iconComponent: IconComponent,
|
|
26
26
|
tag,
|
|
27
27
|
title,
|
|
28
28
|
submenuExpanded,
|
|
@@ -30,33 +30,14 @@ export const InternalSideNavigationItemContent: FC<InternalSideNavigationItemCon
|
|
|
30
30
|
}) => (
|
|
31
31
|
<Fragment>
|
|
32
32
|
<div className={Styles.navItemIconWrapper}>
|
|
33
|
-
{
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
svg={icon}
|
|
42
|
-
className={classNames(
|
|
43
|
-
Styles.navIcon,
|
|
44
|
-
Styles.navIconInactive,
|
|
45
|
-
iconClassName
|
|
46
|
-
)}
|
|
47
|
-
/>
|
|
48
|
-
)}
|
|
49
|
-
{iconActive && (
|
|
50
|
-
<Icon
|
|
51
|
-
svg={iconActive}
|
|
52
|
-
className={classNames(
|
|
53
|
-
Styles.navIcon,
|
|
54
|
-
Styles.navIconActive,
|
|
55
|
-
iconClassName
|
|
56
|
-
)}
|
|
57
|
-
/>
|
|
58
|
-
)}
|
|
59
|
-
</Fragment>
|
|
33
|
+
{icon && (
|
|
34
|
+
<Icon svg={icon} className={classNames(Styles.navIcon, Styles.navIconInactive)} />
|
|
35
|
+
)}
|
|
36
|
+
{iconActive && (
|
|
37
|
+
<Icon
|
|
38
|
+
svg={iconActive}
|
|
39
|
+
className={classNames(Styles.navIcon, Styles.navIconActive)}
|
|
40
|
+
/>
|
|
60
41
|
)}
|
|
61
42
|
|
|
62
43
|
<div className={Styles.navItemTextExpanded} data-cy="nav-item-label">
|
|
@@ -95,93 +76,98 @@ export const InternalSideNavigationItemContent: FC<InternalSideNavigationItemCon
|
|
|
95
76
|
</div>
|
|
96
77
|
</Fragment>
|
|
97
78
|
);
|
|
98
|
-
|
|
99
|
-
export interface InternalSideNavigationLinkProps
|
|
100
|
-
extends Omit<NavigationItemData, 'iconName' | 'counter' | 'tag'>,
|
|
101
|
-
NavigationComponentProps {
|
|
79
|
+
interface InternalLinkProps {
|
|
102
80
|
submenuExpanded: boolean | undefined;
|
|
103
|
-
dataPrefix?: string;
|
|
104
81
|
tag: BadgeTagProps | undefined;
|
|
105
82
|
onExpandToggle?: (e: MouseEvent<never>) => void;
|
|
106
83
|
}
|
|
107
84
|
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
isActive,
|
|
115
|
-
prefix,
|
|
116
|
-
isLink,
|
|
117
|
-
}: Omit<TitanLayoutSidebarTriggerProps, 'isActive' | 'tag'> & {
|
|
118
|
-
prefix: string;
|
|
119
|
-
isActive?: any;
|
|
120
|
-
isLink: boolean;
|
|
121
|
-
}) => ({
|
|
122
|
-
'data-cy': `${prefix}-${id}`,
|
|
123
|
-
'data-pendo': `${prefix}-${id}`,
|
|
124
|
-
'className': classNames(Styles.navItem, className, {
|
|
125
|
-
[Styles.navLink]: isLink,
|
|
126
|
-
[Styles.navItemActive]: isActive === true,
|
|
127
|
-
[Styles.navItemIconSwitch]: !!icon && !!iconActive && !iconComponent,
|
|
128
|
-
}),
|
|
129
|
-
});
|
|
85
|
+
export type InternalSideNavigationLinkProps = Omit<
|
|
86
|
+
TitanLayoutLinkProps,
|
|
87
|
+
'wrapper' | 'counter' | 'tag'
|
|
88
|
+
> &
|
|
89
|
+
NavigationComponentProps &
|
|
90
|
+
InternalLinkProps;
|
|
130
91
|
|
|
131
92
|
/** Side Navigation menu item (for internal usage) */
|
|
132
93
|
export const InternalSideNavigationLink: FC<InternalSideNavigationLinkProps> = ({
|
|
94
|
+
id,
|
|
133
95
|
to,
|
|
134
96
|
className,
|
|
135
|
-
|
|
97
|
+
icon,
|
|
98
|
+
iconActive,
|
|
136
99
|
isActive,
|
|
137
100
|
navigationComponent: NavigationComponent,
|
|
101
|
+
tag,
|
|
102
|
+
title,
|
|
138
103
|
submenuExpanded,
|
|
139
104
|
onExpandToggle,
|
|
140
105
|
...props
|
|
141
106
|
}) => {
|
|
142
107
|
return (
|
|
143
108
|
<NavigationComponent
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
isActive,
|
|
149
|
-
|
|
109
|
+
data-cy={`navigation-item-${id}`}
|
|
110
|
+
data-pendo={`navigation-item-${id}`}
|
|
111
|
+
{...props}
|
|
112
|
+
className={classNames(Styles.navItem, Styles.navLink, className, {
|
|
113
|
+
[Styles.navItemActive]: isActive === true,
|
|
114
|
+
[Styles.navItemIconSwitch]: !!icon && !!iconActive,
|
|
150
115
|
})}
|
|
151
116
|
to={to}
|
|
152
117
|
isActive={typeof isActive === 'function' ? isActive : undefined}
|
|
153
118
|
activeClassName={Styles.navItemActive}
|
|
154
119
|
>
|
|
155
120
|
<InternalSideNavigationItemContent
|
|
121
|
+
icon={icon}
|
|
122
|
+
iconActive={iconActive}
|
|
156
123
|
submenuExpanded={submenuExpanded}
|
|
157
124
|
onExpandToggle={onExpandToggle}
|
|
158
|
-
{
|
|
125
|
+
title={title}
|
|
126
|
+
tag={tag}
|
|
159
127
|
/>
|
|
160
128
|
</NavigationComponent>
|
|
161
129
|
);
|
|
162
130
|
};
|
|
163
131
|
|
|
132
|
+
export type InternalSideNavigationTriggerProps = Omit<
|
|
133
|
+
TitanLayoutTriggerProps,
|
|
134
|
+
'wrapper' | 'counter' | 'tag'
|
|
135
|
+
> &
|
|
136
|
+
InternalLinkProps;
|
|
137
|
+
|
|
164
138
|
/** Side Navigation menu trigger (for internal usage) */
|
|
165
|
-
export const InternalSideNavigationTrigger: FC<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
139
|
+
export const InternalSideNavigationTrigger: FC<InternalSideNavigationTriggerProps> = ({
|
|
140
|
+
className,
|
|
141
|
+
icon,
|
|
142
|
+
iconActive,
|
|
143
|
+
id,
|
|
144
|
+
isActive,
|
|
145
|
+
submenuExpanded,
|
|
146
|
+
onExpandToggle,
|
|
147
|
+
onClick,
|
|
148
|
+
title,
|
|
149
|
+
tag,
|
|
150
|
+
...props
|
|
151
|
+
}) => {
|
|
170
152
|
return (
|
|
171
153
|
<div
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
154
|
+
data-cy={`navigation-item-${id}`}
|
|
155
|
+
data-pendo={`navigation-item-${id}`}
|
|
156
|
+
{...props}
|
|
157
|
+
className={classNames(Styles.navItem, className, {
|
|
158
|
+
[Styles.navLink]: !!onClick,
|
|
159
|
+
[Styles.navItemActive]: isActive === true,
|
|
160
|
+
[Styles.navItemIconSwitch]: !!icon && !!iconActive,
|
|
178
161
|
})}
|
|
179
162
|
onClick={onClick}
|
|
180
163
|
>
|
|
181
164
|
<InternalSideNavigationItemContent
|
|
182
165
|
submenuExpanded={submenuExpanded}
|
|
183
166
|
onExpandToggle={onExpandToggle}
|
|
184
|
-
{
|
|
167
|
+
icon={icon}
|
|
168
|
+
iconActive={iconActive}
|
|
169
|
+
title={title}
|
|
170
|
+
tag={tag}
|
|
185
171
|
/>
|
|
186
172
|
</div>
|
|
187
173
|
);
|
|
@@ -254,13 +240,14 @@ export const InternalSideNavigationGroup: FC<
|
|
|
254
240
|
to: NavigationItemData['to'] | undefined;
|
|
255
241
|
onClick?: (e: MouseEvent<never>) => void;
|
|
256
242
|
}
|
|
257
|
-
> = ({ children, submenuExpanded, to, onExpandToggle, onClick, ...props }) => {
|
|
243
|
+
> = ({ children, submenuExpanded, to, onExpandToggle, onClick, isActive, ...props }) => {
|
|
258
244
|
return (
|
|
259
245
|
<div className={classNames(Styles.navGroupWrapper)}>
|
|
260
246
|
<div className={Styles.navGroupItem}>
|
|
261
247
|
{to ? (
|
|
262
248
|
<InternalSideNavigationLink
|
|
263
249
|
{...props}
|
|
250
|
+
isActive={isActive}
|
|
264
251
|
to={to}
|
|
265
252
|
submenuExpanded={submenuExpanded}
|
|
266
253
|
onExpandToggle={onExpandToggle}
|
|
@@ -268,6 +255,7 @@ export const InternalSideNavigationGroup: FC<
|
|
|
268
255
|
) : (
|
|
269
256
|
<InternalSideNavigationTrigger
|
|
270
257
|
{...props}
|
|
258
|
+
isActive={isActive === true || undefined}
|
|
271
259
|
submenuExpanded={submenuExpanded}
|
|
272
260
|
onExpandToggle={onExpandToggle}
|
|
273
261
|
onClick={onClick}
|