@servicetitan/navigation 12.0.2 → 13.0.0-canary.256.5761ed1.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/counter-tag.d.ts +1 -1
- package/dist/components/counter-tag.d.ts.map +1 -1
- package/dist/components/counter-tag.js.map +1 -1
- package/dist/components/profile-dropdown/interface.d.ts +55 -0
- package/dist/components/profile-dropdown/interface.d.ts.map +1 -0
- package/dist/components/profile-dropdown/interface.js.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown-legacy.stories.d.ts +13 -0
- 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 +5 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +9 -79
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +22 -22
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts +5 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/interface-internal.d.ts +12 -0
- package/dist/components/titan-layout/interface-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/interface-internal.js.map +1 -1
- package/dist/components/titan-layout/interface.d.ts +66 -13
- 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-dark.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-dark.js +22 -12
- package/dist/components/titan-layout/layout-header-dark.js.map +1 -1
- package/dist/components/titan-layout/layout-header-links-internal.d.ts +22 -3
- package/dist/components/titan-layout/layout-header-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-links-internal.js +15 -18
- package/dist/components/titan-layout/layout-header-links-internal.js.map +1 -1
- package/dist/components/titan-layout/layout-header-links.d.ts +3 -4
- package/dist/components/titan-layout/layout-header-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-links.js +25 -5
- 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-header.module.less +36 -0
- package/dist/components/titan-layout/layout-header.module.less.d.ts +2 -0
- package/dist/components/titan-layout/layout-profile.d.ts +8 -5
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.js +30 -28
- package/dist/components/titan-layout/layout-profile.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +48 -25
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +56 -52
- 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 +33 -18
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +49 -24
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/titan-layout-default.stories.d.ts +16 -0
- package/dist/components/titan-layout/titan-layout-default.stories.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout-legacy.stories.d.ts +10 -0
- package/dist/components/titan-layout/titan-layout-legacy.stories.d.ts.map +1 -0
- 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-stacked.stories.d.ts +10 -0
- package/dist/components/titan-layout/titan-layout-stacked.stories.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout.d.ts +5 -4
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +10 -8
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/dist/index.d.ts +1 -6
- 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 +26 -23
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +26 -69
- package/dist/test/data.js.map +1 -1
- package/dist/test/titan-layout.d.ts +16 -0
- package/dist/test/titan-layout.d.ts.map +1 -0
- package/dist/test/titan-layout.js +21 -0
- package/dist/test/titan-layout.js.map +1 -0
- 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 -7
- 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/counter-tag.tsx +1 -1
- package/src/components/profile-dropdown/interface.ts +47 -0
- package/src/components/profile-dropdown/profile-dropdown-legacy.stories.tsx +25 -0
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +15 -7
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +50 -43
- package/src/components/profile-dropdown/profile-dropdown.tsx +39 -115
- package/src/components/titan-layout/interface-internal.ts +13 -0
- package/src/components/titan-layout/interface.ts +72 -16
- package/src/components/titan-layout/layout-header-dark.tsx +18 -5
- package/src/components/titan-layout/layout-header-links-internal.tsx +41 -54
- package/src/components/titan-layout/layout-header-links.tsx +65 -12
- package/src/components/titan-layout/layout-header.module.less +36 -0
- package/src/components/titan-layout/layout-header.module.less.d.ts +2 -0
- package/src/components/titan-layout/layout-header.tsx +2 -2
- package/src/components/titan-layout/layout-profile.tsx +53 -34
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +169 -116
- package/src/components/titan-layout/layout-sidebar-links.tsx +73 -24
- package/src/components/titan-layout/layout-sidebar.tsx +52 -28
- package/src/components/titan-layout/{titan-layout.stories.tsx → titan-layout-default.stories.tsx} +125 -113
- package/src/components/titan-layout/titan-layout-legacy.stories.tsx +24 -0
- package/src/components/titan-layout/titan-layout-links.tsx +34 -0
- package/src/components/titan-layout/titan-layout-stacked.stories.tsx +30 -0
- package/src/components/titan-layout/titan-layout.tsx +12 -9
- package/src/index.ts +1 -12
- package/src/test/data.tsx +31 -83
- package/src/test/titan-layout.tsx +34 -0
- package/src/utils/navigation-context.tsx +9 -35
- package/src/utils/navigation.ts +3 -10
- 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.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 +0 -9
- 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/dist/components/titan-layout/titan-layout.stories.d.ts +0 -29
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +0 -1
- package/dist/utils/navigation-legacy.d.ts +0 -88
- package/dist/utils/navigation-legacy.d.ts.map +0 -1
- package/dist/utils/navigation-legacy.js +0 -3
- package/dist/utils/navigation-legacy.js.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/profile-dropdown/profile-dropdown-tiny.stories.tsx +0 -25
- package/src/components/titan-layout/layout-profile.stories.tsx +0 -46
- package/src/utils/navigation-legacy.ts +0 -106
- /package/dist/components/{left-navigation → profile-dropdown}/interface.js +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import { TitanLayoutLinkProps, TitanLayoutTriggerProps } from './interface';
|
|
4
|
+
import { useTitanLayoutPlacementContext } from './layout-context';
|
|
5
|
+
import { LayoutHeaderNavigationLink, LayoutHeaderNavigationTrigger } from './layout-header-links';
|
|
6
|
+
import { LayoutSidebarLink, LayoutSidebarTrigger } from './layout-sidebar-links';
|
|
7
|
+
|
|
8
|
+
export const TitanLayoutLink: FC<TitanLayoutLinkProps> = props => {
|
|
9
|
+
const placement = useTitanLayoutPlacementContext();
|
|
10
|
+
|
|
11
|
+
if (placement === 'top') {
|
|
12
|
+
return <LayoutHeaderNavigationLink {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (placement === 'side') {
|
|
16
|
+
return <LayoutSidebarLink {...props} />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const TitanLayoutTrigger: FC<TitanLayoutTriggerProps> = props => {
|
|
23
|
+
const placement = useTitanLayoutPlacementContext();
|
|
24
|
+
|
|
25
|
+
if (placement === 'top') {
|
|
26
|
+
return <LayoutHeaderNavigationTrigger {...props} />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (placement === 'side') {
|
|
30
|
+
return <LayoutSidebarTrigger {...props} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TextField } from '@servicetitan/anvil2';
|
|
2
|
+
|
|
3
|
+
import { withAnvil, withDefaultRedirects, withMemoryRouter } from '../../test/data';
|
|
4
|
+
import { getDefaultArgs, withDefaultLayoutProps } from '../../test/titan-layout';
|
|
5
|
+
|
|
6
|
+
const SearchBar = () => (
|
|
7
|
+
<TextField size="small" placeholder="Search" className="w-100-i m-x-half-i" />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Navigation/TitanLayout/Stacked',
|
|
12
|
+
decorators: [
|
|
13
|
+
withDefaultLayoutProps({ navVariant: 'top', top: <SearchBar /> }),
|
|
14
|
+
withDefaultRedirects,
|
|
15
|
+
withMemoryRouter,
|
|
16
|
+
withAnvil,
|
|
17
|
+
],
|
|
18
|
+
parameters: {},
|
|
19
|
+
argTypes: {},
|
|
20
|
+
args: getDefaultArgs(),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
ContentLegacy,
|
|
25
|
+
ContentAnvil1,
|
|
26
|
+
ContentAnvil2,
|
|
27
|
+
ExtraWithTitle,
|
|
28
|
+
ExtraWithFlashing,
|
|
29
|
+
ExtraWithTitleFlashing,
|
|
30
|
+
} from './titan-layout-default.stories';
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ComponentPropsWithoutRef,
|
|
5
5
|
FC,
|
|
6
6
|
Fragment,
|
|
7
|
+
MouseEvent,
|
|
7
8
|
ReactElement,
|
|
8
9
|
ReactNode,
|
|
9
10
|
useCallback,
|
|
@@ -26,9 +27,9 @@ import { LayoutHeader } from './layout-header';
|
|
|
26
27
|
import { LayoutHeaderDark } from './layout-header-dark';
|
|
27
28
|
import { TitanLayoutLogoProps } from './layout-logo';
|
|
28
29
|
import { LayoutSidebar } from './layout-sidebar';
|
|
29
|
-
import { TitanLayoutSidebarLink, TitanLayoutSidebarTrigger } from './layout-sidebar-links';
|
|
30
30
|
import { InternalSideNavigationTrigger } from './layout-sidebar-links-internal';
|
|
31
31
|
import { useNotificationsState } from './notifications-context';
|
|
32
|
+
import { TitanLayoutLink, TitanLayoutTrigger } from './titan-layout-links';
|
|
32
33
|
import * as Styles from './titan-layout.module.less';
|
|
33
34
|
|
|
34
35
|
export type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'style'> & {
|
|
@@ -92,7 +93,7 @@ const useAppearance = (appearance: TitanLayoutProps['appearance']) =>
|
|
|
92
93
|
};
|
|
93
94
|
}, [appearance]);
|
|
94
95
|
|
|
95
|
-
|
|
96
|
+
function TitanLayoutComponent({
|
|
96
97
|
appearance = 'anvil2',
|
|
97
98
|
navVariant = 'left',
|
|
98
99
|
id,
|
|
@@ -112,7 +113,7 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
112
113
|
extraText,
|
|
113
114
|
minContentWidth,
|
|
114
115
|
sideTop,
|
|
115
|
-
})
|
|
116
|
+
}: TitanLayoutProps) {
|
|
116
117
|
const breakpoint = useTitanBreakpoint();
|
|
117
118
|
const context: TitanLayoutContextType = useMemo(
|
|
118
119
|
() => ({
|
|
@@ -148,7 +149,7 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
148
149
|
}
|
|
149
150
|
}, [view.isAnvil1]);
|
|
150
151
|
|
|
151
|
-
const onBurgerClick = useCallback((e: MouseEvent) => {
|
|
152
|
+
const onBurgerClick = useCallback((e: MouseEvent<never>) => {
|
|
152
153
|
setMobileDrawerOpened(true);
|
|
153
154
|
e.stopPropagation();
|
|
154
155
|
}, []);
|
|
@@ -318,10 +319,12 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
318
319
|
<InternalSideNavigationTrigger
|
|
319
320
|
id="--extra-text"
|
|
320
321
|
title={extraText}
|
|
321
|
-
|
|
322
|
-
tag={undefined}
|
|
322
|
+
isActive={undefined}
|
|
323
323
|
icon={undefined}
|
|
324
324
|
iconActive={undefined}
|
|
325
|
+
tag={undefined}
|
|
326
|
+
className={undefined}
|
|
327
|
+
submenuExpanded={undefined}
|
|
325
328
|
/>
|
|
326
329
|
)}
|
|
327
330
|
</Fragment>
|
|
@@ -351,7 +354,7 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
351
354
|
</LayoutPlacementContext.Provider>
|
|
352
355
|
</LayoutContext.Provider>
|
|
353
356
|
);
|
|
354
|
-
}
|
|
357
|
+
}
|
|
355
358
|
|
|
356
359
|
const TitanLayoutHeaderObserved: FC<{
|
|
357
360
|
children: ReactNode;
|
|
@@ -445,6 +448,6 @@ const LayoutContentLegacy: FC<{
|
|
|
445
448
|
};
|
|
446
449
|
|
|
447
450
|
export const TitanLayout = Object.assign(TitanLayoutComponent, {
|
|
448
|
-
Link:
|
|
449
|
-
Trigger:
|
|
451
|
+
Link: TitanLayoutLink,
|
|
452
|
+
Trigger: TitanLayoutTrigger,
|
|
450
453
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
export * from './components/header-navigation';
|
|
2
1
|
export * from './components/logo/logo-company-title';
|
|
3
2
|
export * from './components/logo/logo-titan';
|
|
4
3
|
export * from './components/logo/logo-titan-text';
|
|
5
4
|
export * from './components/counter-tag';
|
|
6
|
-
export * from './components/left-navigation';
|
|
7
5
|
export * from './components/titan-layout';
|
|
8
|
-
export * from './components/links';
|
|
9
6
|
export type * from './utils/navigation';
|
|
10
|
-
export type {
|
|
11
|
-
NavLinkComponentPropsStrict,
|
|
12
|
-
NavLinkComponentProps,
|
|
13
|
-
NavigationLocationContextType,
|
|
14
|
-
NavigationLocationInfo,
|
|
15
|
-
NavigationActiveLinkMatcher,
|
|
16
|
-
} from './utils/navigation-context';
|
|
17
|
-
export { NavigationComponentContext, NavigationLocationContext } from './utils/navigation-context';
|
|
18
|
-
export type * from './utils/navigation-legacy';
|
|
7
|
+
export type { NavLinkComponentProps } from './utils/navigation-context';
|
|
19
8
|
export * from './utils/use-breakpoint';
|
package/src/test/data.tsx
CHANGED
|
@@ -33,26 +33,17 @@ import SvgTasks from '@servicetitan/anvil2/assets/icons/st/gnav_tasks_inactive.s
|
|
|
33
33
|
import { BodyText, Popover } from '@servicetitan/design-system';
|
|
34
34
|
|
|
35
35
|
import classNames from 'classnames';
|
|
36
|
-
import { FC, Fragment, forwardRef,
|
|
36
|
+
import { FC, Fragment, forwardRef, useState } from 'react';
|
|
37
37
|
// needed only for storybook and added in root dependencies
|
|
38
38
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
39
|
+
import { MemoryRouter, Redirect, Switch, useHistory, useLocation } from 'react-router-dom';
|
|
40
|
+
import { TitanLayout } from '../components/titan-layout';
|
|
39
41
|
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
useLocation,
|
|
46
|
-
} from 'react-router-dom';
|
|
47
|
-
import { HeaderNavigationTrigger } from '../components/links';
|
|
48
|
-
import { NavigationSubmenuGroupData, NavigationSubmenuItemData } from '../utils/navigation';
|
|
49
|
-
import {
|
|
50
|
-
NavLinkComponentProps,
|
|
51
|
-
NavigationComponentContext,
|
|
52
|
-
NavigationLocationContext,
|
|
53
|
-
NavigationLocationContextType,
|
|
54
|
-
} from '../utils/navigation-context';
|
|
55
|
-
import { HeaderNavigationItemData } from '../utils/navigation-legacy';
|
|
42
|
+
NavigationItemData,
|
|
43
|
+
NavigationSubmenuGroupData,
|
|
44
|
+
NavigationSubmenuItemData,
|
|
45
|
+
} from '../utils/navigation';
|
|
46
|
+
import { NavLinkComponentProps } from '../utils/navigation-context';
|
|
56
47
|
import * as Styles from './data-stories.module.less';
|
|
57
48
|
|
|
58
49
|
export const NavLinkMock = forwardRef<any, NavLinkComponentProps>(
|
|
@@ -87,29 +78,9 @@ export const LocationInfo: FC<{ className?: string }> = ({ className }) => {
|
|
|
87
78
|
return <BodyText className={className}>current location - {location.pathname}</BodyText>;
|
|
88
79
|
};
|
|
89
80
|
|
|
90
|
-
const LocationProvider: FC<{ children: any }> = ({ children }) => {
|
|
91
|
-
const location = useLocation();
|
|
92
|
-
const context: NavigationLocationContextType = useMemo(
|
|
93
|
-
() => ({
|
|
94
|
-
location: { pathname: location.pathname },
|
|
95
|
-
isLinkActive: (location, item) => !!matchPath(location.pathname, item.to),
|
|
96
|
-
}),
|
|
97
|
-
[location.pathname]
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<NavigationLocationContext.Provider value={context}>
|
|
102
|
-
{children}
|
|
103
|
-
</NavigationLocationContext.Provider>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
81
|
export const withMemoryRouter = (Story: any) => (
|
|
107
82
|
<MemoryRouter>
|
|
108
|
-
<
|
|
109
|
-
<LocationProvider>
|
|
110
|
-
<Story />
|
|
111
|
-
</LocationProvider>
|
|
112
|
-
</NavigationComponentContext.Provider>
|
|
83
|
+
<Story />
|
|
113
84
|
</MemoryRouter>
|
|
114
85
|
);
|
|
115
86
|
|
|
@@ -143,14 +114,10 @@ export const SearchIcon = () => (
|
|
|
143
114
|
</svg>
|
|
144
115
|
);
|
|
145
116
|
|
|
146
|
-
const
|
|
147
|
-
id: string,
|
|
148
|
-
data: Partial<HeaderNavigationItemData>
|
|
149
|
-
): HeaderNavigationItemData => ({
|
|
117
|
+
const getNavItem = (id: string, data: Partial<NavigationItemData>): NavigationItemData => ({
|
|
150
118
|
id,
|
|
151
119
|
to: '/' + id,
|
|
152
120
|
title: id[0].toUpperCase() + id.substring(1),
|
|
153
|
-
hint: id,
|
|
154
121
|
icon: undefined,
|
|
155
122
|
iconActive: undefined,
|
|
156
123
|
...data,
|
|
@@ -186,48 +153,40 @@ const getGroup = (
|
|
|
186
153
|
links,
|
|
187
154
|
});
|
|
188
155
|
|
|
189
|
-
export const
|
|
190
|
-
calendar:
|
|
191
|
-
iconName: 'event',
|
|
156
|
+
export const navItems = {
|
|
157
|
+
calendar: getNavItem('calendar', {
|
|
192
158
|
icon: SvgSchedule,
|
|
193
159
|
iconActive: SvgScheduleActive,
|
|
194
160
|
}),
|
|
195
|
-
schedule:
|
|
196
|
-
iconName: 'event',
|
|
161
|
+
schedule: getNavItem('schedule', {
|
|
197
162
|
icon: SvgSchedule,
|
|
198
163
|
iconActive: SvgScheduleActive,
|
|
199
164
|
}),
|
|
200
|
-
calls:
|
|
201
|
-
iconName: 'local_phone',
|
|
165
|
+
calls: getNavItem('calls', {
|
|
202
166
|
icon: SvgCalls,
|
|
203
167
|
iconActive: SvgCallsActive,
|
|
204
168
|
counter: 1234,
|
|
205
169
|
}),
|
|
206
|
-
dashboard:
|
|
207
|
-
iconName: 'odometer',
|
|
170
|
+
dashboard: getNavItem('dashboard', {
|
|
208
171
|
icon: SvgDashboard,
|
|
209
172
|
iconActive: SvgDashboardActive,
|
|
210
173
|
}),
|
|
211
|
-
dispatch:
|
|
212
|
-
iconName: 'location_disabled',
|
|
174
|
+
dispatch: getNavItem('dispatch', {
|
|
213
175
|
icon: SvgDispatch,
|
|
214
176
|
iconActive: SvgDispatchActive,
|
|
215
177
|
tag: { value: 3 },
|
|
216
178
|
}),
|
|
217
|
-
fleet:
|
|
218
|
-
iconName: 'fleet-pro',
|
|
179
|
+
fleet: getNavItem('fleet', {
|
|
219
180
|
icon: SvgFleetPro,
|
|
220
181
|
iconActive: SvgFleetProActive,
|
|
221
182
|
title: 'Fleet Pro',
|
|
222
183
|
}),
|
|
223
|
-
followUps:
|
|
224
|
-
iconName: 'flag',
|
|
184
|
+
followUps: getNavItem('followUps', {
|
|
225
185
|
icon: SvgFollowUp,
|
|
226
186
|
iconActive: SvgFollowUpActive,
|
|
227
187
|
title: 'Follow Up',
|
|
228
188
|
}),
|
|
229
|
-
followUpsWithSubmenu:
|
|
230
|
-
iconName: 'flag',
|
|
189
|
+
followUpsWithSubmenu: getNavItem('followUps', {
|
|
231
190
|
icon: SvgFollowUp,
|
|
232
191
|
iconActive: SvgFollowUpActive,
|
|
233
192
|
title: 'Follow Up',
|
|
@@ -241,14 +200,12 @@ export const items = {
|
|
|
241
200
|
],
|
|
242
201
|
},
|
|
243
202
|
}),
|
|
244
|
-
inventory:
|
|
245
|
-
iconName: 'toys',
|
|
203
|
+
inventory: getNavItem('inventory', {
|
|
246
204
|
icon: SvgInventory,
|
|
247
205
|
iconActive: SvgInventoryActive,
|
|
248
206
|
}),
|
|
249
|
-
purchasing:
|
|
250
|
-
purchasingWithSubmenu:
|
|
251
|
-
iconName: 'toys',
|
|
207
|
+
purchasing: getNavItem('purchasing', {}),
|
|
208
|
+
purchasingWithSubmenu: getNavItem('purchasing', {
|
|
252
209
|
icon: SvgInventory,
|
|
253
210
|
iconActive: SvgInventoryActive,
|
|
254
211
|
counter: true,
|
|
@@ -263,14 +220,12 @@ export const items = {
|
|
|
263
220
|
],
|
|
264
221
|
},
|
|
265
222
|
}),
|
|
266
|
-
accounting:
|
|
267
|
-
iconName: 'assignment',
|
|
223
|
+
accounting: getNavItem('accounting', {
|
|
268
224
|
icon: SvgAccounting,
|
|
269
225
|
iconActive: SvgAccountingActive,
|
|
270
226
|
counter: true,
|
|
271
227
|
}),
|
|
272
|
-
accountingWithSubmenu:
|
|
273
|
-
iconName: 'assignment',
|
|
228
|
+
accountingWithSubmenu: getNavItem('accounting', {
|
|
274
229
|
icon: SvgAccounting,
|
|
275
230
|
iconActive: SvgAccountingActive,
|
|
276
231
|
counter: 1,
|
|
@@ -292,34 +247,28 @@ export const items = {
|
|
|
292
247
|
],
|
|
293
248
|
},
|
|
294
249
|
}),
|
|
295
|
-
marketing:
|
|
296
|
-
iconName: 'bullhorn',
|
|
250
|
+
marketing: getNavItem('marketing', {
|
|
297
251
|
icon: SvgMarketing,
|
|
298
252
|
iconActive: SvgMarketingActive,
|
|
299
253
|
}),
|
|
300
|
-
priceBook:
|
|
301
|
-
iconName: 'book',
|
|
254
|
+
priceBook: getNavItem('pricebook', {
|
|
302
255
|
icon: SvgPriceBook,
|
|
303
256
|
iconActive: SvgPriceBookActive,
|
|
304
257
|
}),
|
|
305
|
-
pointOfSale:
|
|
306
|
-
iconName: 'cash-register',
|
|
258
|
+
pointOfSale: getNavItem('pointOfSale', {
|
|
307
259
|
icon: SvgPos,
|
|
308
260
|
iconActive: SvgPosActive,
|
|
309
261
|
title: 'Point Of Sale',
|
|
310
262
|
}),
|
|
311
|
-
projects:
|
|
312
|
-
iconName: 'folder_special',
|
|
263
|
+
projects: getNavItem('projects', {
|
|
313
264
|
icon: SvgProjects,
|
|
314
265
|
iconActive: SvgProjectsActive,
|
|
315
266
|
}),
|
|
316
|
-
reports:
|
|
317
|
-
iconName: 'folder_special',
|
|
267
|
+
reports: getNavItem('reports', {
|
|
318
268
|
icon: SvgReports,
|
|
319
269
|
iconActive: SvgReportsActive,
|
|
320
270
|
}),
|
|
321
|
-
tasks:
|
|
322
|
-
iconName: 'format_list_bulleted',
|
|
271
|
+
tasks: getNavItem('tasks', {
|
|
323
272
|
icon: SvgTasks,
|
|
324
273
|
iconActive: SvgTasksActive,
|
|
325
274
|
}),
|
|
@@ -334,9 +283,8 @@ export const CallsNavigationTrigger = () => {
|
|
|
334
283
|
onClickOutside={() => setOpen(false)}
|
|
335
284
|
direction="bl"
|
|
336
285
|
trigger={
|
|
337
|
-
<
|
|
286
|
+
<TitanLayout.Trigger
|
|
338
287
|
id="dialpad"
|
|
339
|
-
iconName="phone"
|
|
340
288
|
counter={2}
|
|
341
289
|
title="Calls"
|
|
342
290
|
icon={SvgPhone}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import { TitanLayoutProps } from '../components/titan-layout';
|
|
3
|
+
|
|
4
|
+
export interface LayoutContentArgs {
|
|
5
|
+
header: boolean;
|
|
6
|
+
sideTop: boolean;
|
|
7
|
+
extraText: boolean;
|
|
8
|
+
search: boolean;
|
|
9
|
+
longContent: boolean;
|
|
10
|
+
wideContent: boolean;
|
|
11
|
+
minWidth: boolean;
|
|
12
|
+
emptyNav: boolean;
|
|
13
|
+
overflowItems: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const getDefaultArgs = (): LayoutContentArgs => ({
|
|
17
|
+
header: true,
|
|
18
|
+
sideTop: true,
|
|
19
|
+
extraText: true,
|
|
20
|
+
search: true,
|
|
21
|
+
longContent: true,
|
|
22
|
+
wideContent: false,
|
|
23
|
+
minWidth: false,
|
|
24
|
+
emptyNav: false,
|
|
25
|
+
overflowItems: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const DefaultPropsContext = createContext<Partial<TitanLayoutProps>>({});
|
|
29
|
+
export const withDefaultLayoutProps = (props: Partial<TitanLayoutProps>) => (Story: any) => (
|
|
30
|
+
<DefaultPropsContext.Provider value={props}>
|
|
31
|
+
<Story />
|
|
32
|
+
</DefaultPropsContext.Provider>
|
|
33
|
+
);
|
|
34
|
+
export const useDefaultLayoutProps = () => useContext(DefaultPropsContext);
|
|
@@ -1,45 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NavigationLinkData } from './navigation';
|
|
1
|
+
import { ComponentPropsWithoutRef, FC } from 'react';
|
|
3
2
|
|
|
4
|
-
export
|
|
3
|
+
export type NavLinkComponentProps = ComponentPropsWithoutRef<'a'> & {
|
|
5
4
|
to: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
className?: string;
|
|
8
5
|
activeClassName?: string;
|
|
9
|
-
children: ReactNode;
|
|
10
6
|
isActive?: (pathname: string) => boolean;
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NavLinkComponentProps extends NavLinkComponentPropsStrict {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
7
|
+
};
|
|
17
8
|
|
|
18
9
|
export const DefaultNavLinkComponent: FC<NavLinkComponentProps> = ({
|
|
19
10
|
children,
|
|
11
|
+
to,
|
|
20
12
|
activeClassName,
|
|
21
13
|
isActive,
|
|
22
14
|
...props
|
|
23
|
-
}) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export type NavigationActiveLinkMatcher = (
|
|
30
|
-
location: NavigationLocationInfo,
|
|
31
|
-
link: NavigationLinkData
|
|
32
|
-
) => boolean;
|
|
33
|
-
|
|
34
|
-
export interface NavigationLocationContextType {
|
|
35
|
-
location: NavigationLocationInfo;
|
|
36
|
-
isLinkActive: NavigationActiveLinkMatcher;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const NavigationComponentContext =
|
|
40
|
-
createContext<FC<NavLinkComponentProps>>(DefaultNavLinkComponent);
|
|
41
|
-
export const NavigationLegacyContext = createContext(false);
|
|
42
|
-
export const NavigationLocationContext = createContext<NavigationLocationContextType>({
|
|
43
|
-
location: { pathname: '' },
|
|
44
|
-
isLinkActive: () => false,
|
|
45
|
-
});
|
|
15
|
+
}) => (
|
|
16
|
+
<a href={to} {...props}>
|
|
17
|
+
{children}
|
|
18
|
+
</a>
|
|
19
|
+
);
|
package/src/utils/navigation.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { IconProps } from '@servicetitan/anvil2';
|
|
2
|
-
import { FC } from 'react';
|
|
3
2
|
import { CounterTagData, CounterTagValue } from './counter-tag';
|
|
4
3
|
|
|
5
4
|
export interface NavigationItemData extends NavigationLinkData {
|
|
6
|
-
/** flag if the link is not shown (based on FG and/or user permissions) */
|
|
7
|
-
isHidden?: boolean;
|
|
8
|
-
|
|
9
|
-
/** custom className (can be used for mdi icons) */
|
|
10
|
-
iconClassName?: string;
|
|
11
|
-
|
|
12
5
|
/** svg icon (anvil2) of inactive item */
|
|
13
6
|
icon: IconProps['svg'] | undefined;
|
|
14
7
|
|
|
15
8
|
/** svg icon (anvil2) of active item */
|
|
16
9
|
iconActive: IconProps['svg'] | undefined;
|
|
17
10
|
|
|
18
|
-
/** icon component of item (<svg />) */
|
|
19
|
-
iconComponent?: FC;
|
|
20
|
-
|
|
21
11
|
/** item tag (optional). shown if it is set and true or greater than 0 */
|
|
22
12
|
counter?: CounterTagValue;
|
|
23
13
|
tag?: CounterTagData;
|
|
@@ -27,6 +17,9 @@ export interface NavigationItemData extends NavigationLinkData {
|
|
|
27
17
|
|
|
28
18
|
/** optional submenu of link item */
|
|
29
19
|
submenu?: NavigationSubmenuData;
|
|
20
|
+
|
|
21
|
+
iconClassName?: never;
|
|
22
|
+
iconComponent?: never;
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
export interface NavigationLinkData {
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { IconPropsStrict } from '@servicetitan/design-system';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
import { HeaderNavigationItemData } from '../../utils/navigation-legacy';
|
|
4
|
-
import { CounterTagProps } from '../counter-tag';
|
|
5
|
-
export interface HeaderNavigationItemContentPropsStrict {
|
|
6
|
-
/** item text */
|
|
7
|
-
title?: string;
|
|
8
|
-
/** text component class name */
|
|
9
|
-
titleClassName?: string;
|
|
10
|
-
/** counter tag shown for item */
|
|
11
|
-
tag: CounterTagProps | undefined;
|
|
12
|
-
/** counter component class name */
|
|
13
|
-
counterClassName?: string;
|
|
14
|
-
/** icon component class name */
|
|
15
|
-
iconClassName?: string;
|
|
16
|
-
/** IconComponent custom icon component */
|
|
17
|
-
iconComponent?: FC;
|
|
18
|
-
/** iconName name of anvil icon */
|
|
19
|
-
iconName?: IconPropsStrict['name'];
|
|
20
|
-
}
|
|
21
|
-
/** Content for navigation items */
|
|
22
|
-
export declare const HeaderNavigationItemContent: FC<HeaderNavigationItemContentPropsStrict>;
|
|
23
|
-
interface HeaderNavigationItemPropsStrict extends HeaderNavigationItemData {
|
|
24
|
-
minimized: boolean;
|
|
25
|
-
main: boolean;
|
|
26
|
-
}
|
|
27
|
-
/** Navigation main menu item */
|
|
28
|
-
export declare const HeaderNavigationItem: FC<HeaderNavigationItemPropsStrict>;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=header-navigation-content.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"header-navigation-content.d.ts","sourceRoot":"","sources":["../../../src/components/header-navigation/header-navigation-content.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,EAAE,EAAwB,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAc,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAI7D,MAAM,WAAW,sCAAsC;IACnD,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,GAAG,EAAE,eAAe,GAAG,SAAS,CAAC;IACjC,mCAAmC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gCAAgC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,EAAE,CAAC;IACnB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,mCAAmC;AACnC,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,sCAAsC,CAqClF,CAAC;AAEF,UAAU,+BAAgC,SAAQ,wBAAwB;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,gCAAgC;AAChC,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,+BAA+B,CA8CpE,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Icon } from '@servicetitan/design-system';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { Fragment, useContext } from 'react';
|
|
5
|
-
import { NavigationComponentContext } from '../../utils/navigation-context';
|
|
6
|
-
import { getCounterTag } from '../../utils/side-nav';
|
|
7
|
-
import { CounterTag } from '../counter-tag';
|
|
8
|
-
import * as Styles from './header-navigation.module.less';
|
|
9
|
-
import { withTooltip } from './with-tooltip';
|
|
10
|
-
/** Content for navigation items */ export const HeaderNavigationItemContent = ({ title, titleClassName, counterClassName, iconClassName, iconComponent: IconComponent, iconName, tag })=>{
|
|
11
|
-
const iconClass = classNames(Styles.navigationIcon, iconClassName);
|
|
12
|
-
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
13
|
-
children: [
|
|
14
|
-
IconComponent ? /*#__PURE__*/ _jsx("i", {
|
|
15
|
-
className: iconClass,
|
|
16
|
-
children: /*#__PURE__*/ _jsx(IconComponent, {})
|
|
17
|
-
}) : iconName ? /*#__PURE__*/ _jsx(Icon, {
|
|
18
|
-
name: iconName,
|
|
19
|
-
className: iconClass
|
|
20
|
-
}) : /*#__PURE__*/ _jsx("i", {
|
|
21
|
-
className: iconClass
|
|
22
|
-
}),
|
|
23
|
-
!!title && /*#__PURE__*/ _jsx("span", {
|
|
24
|
-
className: classNames(Styles.navigationItemTitle, titleClassName),
|
|
25
|
-
children: title
|
|
26
|
-
}),
|
|
27
|
-
!!tag && /*#__PURE__*/ _jsx(CounterTag, {
|
|
28
|
-
data: tag,
|
|
29
|
-
className: classNames(Styles.navigationItemCounter, counterClassName),
|
|
30
|
-
longClassName: Styles.navigationItemCounterLong
|
|
31
|
-
})
|
|
32
|
-
]
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
/** Navigation main menu item */ export const HeaderNavigationItem = ({ id, to, counter, title, hint, className, iconClassName, iconComponent, iconName, isActive, main, minimized, tag })=>{
|
|
36
|
-
const NavigationComponent = useContext(NavigationComponentContext);
|
|
37
|
-
return withTooltip(/*#__PURE__*/ _jsx(NavigationComponent, {
|
|
38
|
-
"data-cy": `navigation-item-${id}`,
|
|
39
|
-
"data-pendo": `navigation-item-${id}`,
|
|
40
|
-
to: to,
|
|
41
|
-
title: hint,
|
|
42
|
-
className: classNames(Styles.navigationItem, main ? Styles.navigationItemMain : Styles.navigationItemOverflow, className, {
|
|
43
|
-
[Styles.navigationItemActive]: isActive === true
|
|
44
|
-
}),
|
|
45
|
-
isActive: typeof isActive === 'function' ? isActive : undefined,
|
|
46
|
-
activeClassName: Styles.navigationItemActive,
|
|
47
|
-
children: /*#__PURE__*/ _jsx(HeaderNavigationItemContent, {
|
|
48
|
-
title: minimized ? undefined : title,
|
|
49
|
-
titleClassName: main ? '' : 'm-l-half',
|
|
50
|
-
tag: getCounterTag(counter, tag),
|
|
51
|
-
iconComponent: iconComponent,
|
|
52
|
-
iconClassName: iconClassName,
|
|
53
|
-
iconName: iconName
|
|
54
|
-
})
|
|
55
|
-
}, id), minimized ? title : undefined);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=header-navigation-content.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/header-navigation/header-navigation-content.tsx"],"sourcesContent":["import { Icon, IconPropsStrict } from '@servicetitan/design-system';\nimport classNames from 'classnames';\nimport { FC, Fragment, useContext } from 'react';\nimport { NavigationComponentContext } from '../../utils/navigation-context';\nimport { HeaderNavigationItemData } from '../../utils/navigation-legacy';\nimport { getCounterTag } from '../../utils/side-nav';\nimport { CounterTag, CounterTagProps } from '../counter-tag';\nimport * as Styles from './header-navigation.module.less';\nimport { withTooltip } from './with-tooltip';\n\nexport interface HeaderNavigationItemContentPropsStrict {\n /** item text */\n title?: string;\n /** text component class name */\n titleClassName?: string;\n /** counter tag shown for item */\n tag: CounterTagProps | undefined;\n /** counter component class name */\n counterClassName?: string;\n /** icon component class name */\n iconClassName?: string;\n /** IconComponent custom icon component */\n iconComponent?: FC;\n /** iconName name of anvil icon */\n iconName?: IconPropsStrict['name'];\n}\n\n/** Content for navigation items */\nexport const HeaderNavigationItemContent: FC<HeaderNavigationItemContentPropsStrict> = ({\n title,\n titleClassName,\n counterClassName,\n iconClassName,\n iconComponent: IconComponent,\n iconName,\n tag,\n}) => {\n const iconClass = classNames(Styles.navigationIcon, iconClassName);\n return (\n <Fragment>\n {IconComponent ? (\n <i className={iconClass}>\n <IconComponent />\n </i>\n ) : iconName ? (\n <Icon name={iconName} className={iconClass} />\n ) : (\n <i className={iconClass} />\n )}\n\n {!!title && (\n <span className={classNames(Styles.navigationItemTitle, titleClassName)}>\n {title}\n </span>\n )}\n\n {!!tag && (\n <CounterTag\n data={tag}\n className={classNames(Styles.navigationItemCounter, counterClassName)}\n longClassName={Styles.navigationItemCounterLong}\n />\n )}\n </Fragment>\n );\n};\n\ninterface HeaderNavigationItemPropsStrict extends HeaderNavigationItemData {\n minimized: boolean;\n main: boolean;\n}\n\n/** Navigation main menu item */\nexport const HeaderNavigationItem: FC<HeaderNavigationItemPropsStrict> = ({\n id,\n to,\n counter,\n title,\n hint,\n className,\n iconClassName,\n iconComponent,\n iconName,\n isActive,\n main,\n minimized,\n tag,\n}) => {\n const NavigationComponent = useContext(NavigationComponentContext);\n\n return withTooltip(\n <NavigationComponent\n data-cy={`navigation-item-${id}`}\n data-pendo={`navigation-item-${id}`}\n key={id}\n to={to}\n title={hint}\n className={classNames(\n Styles.navigationItem,\n main ? Styles.navigationItemMain : Styles.navigationItemOverflow,\n className,\n {\n [Styles.navigationItemActive]: isActive === true,\n }\n )}\n isActive={typeof isActive === 'function' ? isActive : undefined}\n activeClassName={Styles.navigationItemActive}\n >\n <HeaderNavigationItemContent\n title={minimized ? undefined : title}\n titleClassName={main ? '' : 'm-l-half'}\n tag={getCounterTag(counter, tag)}\n iconComponent={iconComponent}\n iconClassName={iconClassName}\n iconName={iconName}\n />\n </NavigationComponent>,\n minimized ? title : undefined\n );\n};\n"],"names":["Icon","classNames","Fragment","useContext","NavigationComponentContext","getCounterTag","CounterTag","Styles","withTooltip","HeaderNavigationItemContent","title","titleClassName","counterClassName","iconClassName","iconComponent","IconComponent","iconName","tag","iconClass","navigationIcon","i","className","name","span","navigationItemTitle","data","navigationItemCounter","longClassName","navigationItemCounterLong","HeaderNavigationItem","id","to","counter","hint","isActive","main","minimized","NavigationComponent","data-cy","data-pendo","navigationItem","navigationItemMain","navigationItemOverflow","navigationItemActive","undefined","activeClassName"],"mappings":";AAAA,SAASA,IAAI,QAAyB,8BAA8B;AACpE,OAAOC,gBAAgB,aAAa;AACpC,SAAaC,QAAQ,EAAEC,UAAU,QAAQ,QAAQ;AACjD,SAASC,0BAA0B,QAAQ,iCAAiC;AAE5E,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,UAAU,QAAyB,iBAAiB;AAC7D,YAAYC,YAAY,kCAAkC;AAC1D,SAASC,WAAW,QAAQ,iBAAiB;AAmB7C,iCAAiC,GACjC,OAAO,MAAMC,8BAA0E,CAAC,EACpFC,KAAK,EACLC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,eAAeC,aAAa,EAC5BC,QAAQ,EACRC,GAAG,EACN;IACG,MAAMC,YAAYjB,WAAWM,OAAOY,cAAc,EAAEN;IACpD,qBACI,MAACX;;YACIa,8BACG,KAACK;gBAAEC,WAAWH;0BACV,cAAA,KAACH;iBAELC,yBACA,KAAChB;gBAAKsB,MAAMN;gBAAUK,WAAWH;+BAEjC,KAACE;gBAAEC,WAAWH;;YAGjB,CAAC,CAACR,uBACC,KAACa;gBAAKF,WAAWpB,WAAWM,OAAOiB,mBAAmB,EAAEb;0BACnDD;;YAIR,CAAC,CAACO,qBACC,KAACX;gBACGmB,MAAMR;gBACNI,WAAWpB,WAAWM,OAAOmB,qBAAqB,EAAEd;gBACpDe,eAAepB,OAAOqB,yBAAyB;;;;AAKnE,EAAE;AAOF,8BAA8B,GAC9B,OAAO,MAAMC,uBAA4D,CAAC,EACtEC,EAAE,EACFC,EAAE,EACFC,OAAO,EACPtB,KAAK,EACLuB,IAAI,EACJZ,SAAS,EACTR,aAAa,EACbC,aAAa,EACbE,QAAQ,EACRkB,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTnB,GAAG,EACN;IACG,MAAMoB,sBAAsBlC,WAAWC;IAEvC,OAAOI,0BACH,KAAC6B;QACGC,WAAS,CAAC,gBAAgB,EAAER,IAAI;QAChCS,cAAY,CAAC,gBAAgB,EAAET,IAAI;QAEnCC,IAAIA;QACJrB,OAAOuB;QACPZ,WAAWpB,WACPM,OAAOiC,cAAc,EACrBL,OAAO5B,OAAOkC,kBAAkB,GAAGlC,OAAOmC,sBAAsB,EAChErB,WACA;YACI,CAACd,OAAOoC,oBAAoB,CAAC,EAAET,aAAa;QAChD;QAEJA,UAAU,OAAOA,aAAa,aAAaA,WAAWU;QACtDC,iBAAiBtC,OAAOoC,oBAAoB;kBAE5C,cAAA,KAAClC;YACGC,OAAO0B,YAAYQ,YAAYlC;YAC/BC,gBAAgBwB,OAAO,KAAK;YAC5BlB,KAAKZ,cAAc2B,SAASf;YAC5BH,eAAeA;YACfD,eAAeA;YACfG,UAAUA;;OApBTc,KAuBTM,YAAY1B,QAAQkC;AAE5B,EAAE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("../..").HeaderNavigationLinkProps>;
|
|
4
|
-
decorators: ((Story: any) => import("react/jsx-runtime").JSX.Element)[];
|
|
5
|
-
parameters: {};
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
export { ExtraWithTooltip, ExtraLink, ExtraTrigger, ExtraWithLabel, } from './header-navigation-extra.stories';
|
|
9
|
-
//# sourceMappingURL=header-navigation-extra-stacked.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"header-navigation-extra-stacked.stories.d.ts","sourceRoot":"","sources":["../../../src/components/header-navigation/header-navigation-extra-stacked.stories.tsx"],"names":[],"mappings":";;;;;;AAMA,wBAKE;AAEF,OAAO,EACH,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,cAAc,GACjB,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
title: string;
|
|
3
|
-
component: import("react").FC<import("../..").HeaderNavigationLinkProps>;
|
|
4
|
-
decorators: ((Story: any) => import("react/jsx-runtime").JSX.Element)[];
|
|
5
|
-
parameters: {};
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
export declare const ExtraLink: () => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare const ExtraTrigger: () => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export declare const ExtraWithTooltip: () => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare const ExtraWithLabel: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
//# sourceMappingURL=header-navigation-extra.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"header-navigation-extra.stories.d.ts","sourceRoot":"","sources":["../../../src/components/header-navigation/header-navigation-extra.stories.tsx"],"names":[],"mappings":";;;;;;AAeA,wBAKE;AAEF,eAAO,MAAM,SAAS,+CAWrB,CAAC;AAEF,eAAO,MAAM,YAAY,+CAUxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+CA0B5B,CAAC;AA2CF,eAAO,MAAM,cAAc,+CAyB1B,CAAC"}
|