@servicetitan/navigation 1.4.2 → 1.4.3
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.d.ts +12 -5
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +12 -5
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +8 -0
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts +0 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.js +5 -4
- package/dist/components/profile-dropdown/profile-dropdown.stories.js.map +1 -1
- package/package.json +2 -2
- package/src/components/profile-dropdown/profile-dropdown.module.less +8 -0
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +14 -3
- package/src/components/profile-dropdown/profile-dropdown.tsx +27 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PopoverPropsStrict } from '@servicetitan/design-system';
|
|
2
2
|
import { FC, HTMLAttributeAnchorTarget, MouseEvent, ReactNode } from 'react';
|
|
3
|
-
interface ProfileDropdownTriggerProps {
|
|
3
|
+
export interface ProfileDropdownTriggerProps {
|
|
4
4
|
className?: string;
|
|
5
5
|
info?: {
|
|
6
6
|
title: string;
|
|
@@ -15,12 +15,16 @@ interface ProfileDropdownTriggerProps {
|
|
|
15
15
|
hintArrow?: boolean;
|
|
16
16
|
onClick?(e: MouseEvent): void;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
export interface ProfileDropdownSectionPropsStrict {
|
|
19
19
|
children: ReactNode;
|
|
20
20
|
className?: string;
|
|
21
21
|
onClick?(e: MouseEvent): void;
|
|
22
22
|
}
|
|
23
|
+
interface ProfileDropdownSectionProps extends ProfileDropdownSectionPropsStrict {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
23
26
|
export declare const ProfileDropdownSection: FC<ProfileDropdownSectionProps>;
|
|
27
|
+
export declare const ProfileDropdownDivider: FC;
|
|
24
28
|
export interface ProfileDropdownLinkPropsStrict {
|
|
25
29
|
children: ReactNode;
|
|
26
30
|
className?: string;
|
|
@@ -38,15 +42,18 @@ export interface ProfileDropdownProps {
|
|
|
38
42
|
trigger?: Omit<ProfileDropdownTriggerProps, 'onClick'>;
|
|
39
43
|
hintPopup?: {
|
|
40
44
|
className?: string;
|
|
41
|
-
content:
|
|
45
|
+
content: FC<{
|
|
46
|
+
openProfile(): void;
|
|
47
|
+
}>;
|
|
42
48
|
width?: PopoverPropsStrict['width'];
|
|
43
49
|
onClose?: () => void;
|
|
44
50
|
};
|
|
51
|
+
width?: PopoverPropsStrict['width'];
|
|
45
52
|
onClose?(): void;
|
|
46
53
|
onOpen?(): void;
|
|
47
54
|
}
|
|
48
55
|
export interface ProfileDropdownType extends FC<ProfileDropdownProps> {
|
|
49
|
-
Divider: typeof
|
|
56
|
+
Divider: typeof ProfileDropdownDivider;
|
|
50
57
|
Link: typeof ProfileDropdownLink;
|
|
51
58
|
Section: typeof ProfileDropdownSection;
|
|
52
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"profile-dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EACH,EAAE,EACF,yBAAyB,EACzB,UAAU,EAEV,SAAS,EAKZ,MAAM,OAAO,CAAC;AAMf,MAAM,WAAW,2BAA2B;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE;QAAE,KAA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AAO,CAAC,EAAE,IAAI,CAAC,2BAA2B,EAAE,SAAS,CAAC,CAAC;IACvD,SAAS,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,EAAE,CAAC;YAAE,WAAW,IAAI,IAAI,CAAA;SAAE,CAAC,CAAC;QACrC,KAAK,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;KACxB,CAAC;IACF,KAAK,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,MAAM,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,mBAAoB,SAAQ,EAAE,CAAC,oBAAoB,CAAC;IACjE,OAAO,EAAE,OAAO,sBAAsB,CAAC;IACvC,IAAI,EAAE,OAAO,mBAAmB,CAAC;IACjC,OAAO,EAAE,OAAO,sBAAsB,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,mBA4EL,CAAC"}
|
|
@@ -32,7 +32,8 @@ const ProfileDropdownTrigger = ({ avatarBadge, badge, className, hintArrow, imag
|
|
|
32
32
|
}, []);
|
|
33
33
|
return (_jsxs("div", Object.assign({ className: classNames('d-f align-items-center cursor-pointer position-relative p-y-1 p-x-1', Styles.triggerContainer, { [Styles.triggerContainerHintArrow]: hintArrow }, className), onClick: onClick }, { children: [avatarSource && !avatarSourceError ? (_jsx("img", { src: avatarSource, className: Styles.profileImage, onError: onAvatarError, alt: "user dropdown menu" })) : (_jsx(ProfileLogo, { size: 28 })), !!info && (_jsxs("div", Object.assign({ className: Styles.info }, { children: [_jsx(BodyText, Object.assign({ bold: true, title: info.title, className: "t-truncate c-white", size: "xsmall" }, { children: info.title })), _jsx(BodyText, Object.assign({ title: info.text, className: "t-truncate c-neutral-70 tt-uppercase", size: "xsmall" }, { children: info.text }))] }))), _jsx(Icon, { className: "m-l-half", name: "expand_more", size: 12 }), !!avatarBadge && (_jsx("div", { className: classNames(Styles.avatarBadge, avatarBadge === true ? 'bg-blue-500' : `bg-${avatarBadge}`) })), !!badge && (_jsx("span", Object.assign({ className: classNames(Styles.badge, badge.content ? Styles.badgeWithContent : Styles.badgeNoContent, badge.className) }, { children: badge.content })))] })));
|
|
34
34
|
};
|
|
35
|
-
export const ProfileDropdownSection = (
|
|
35
|
+
export const ProfileDropdownSection = (_a) => {
|
|
36
|
+
var { children, className, onClick } = _a, rest = __rest(_a, ["children", "className", "onClick"]);
|
|
36
37
|
const clickHandler = e => {
|
|
37
38
|
if (onClick) {
|
|
38
39
|
onClick(e);
|
|
@@ -41,8 +42,9 @@ export const ProfileDropdownSection = ({ children, className, onClick, }) => {
|
|
|
41
42
|
e.stopPropagation();
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
return (_jsx("div", Object.assign({ className: classNames(Styles.dropdownSection, className), onClick: clickHandler }, { children: children })));
|
|
45
|
+
return (_jsx("div", Object.assign({ className: classNames(Styles.dropdownSection, className), onClick: clickHandler }, rest, { children: children })));
|
|
45
46
|
};
|
|
47
|
+
export const ProfileDropdownDivider = Popover.Divider;
|
|
46
48
|
export const ProfileDropdownLink = (_a) => {
|
|
47
49
|
var { children, className, external, target, to, onClick } = _a, rest = __rest(_a, ["children", "className", "external", "target", "to", "onClick"]);
|
|
48
50
|
const NavigationComponent = useContext(NavigationContext);
|
|
@@ -53,13 +55,17 @@ export const ProfileDropdownLink = (_a) => {
|
|
|
53
55
|
const isExternalLink = external !== null && external !== void 0 ? external : to === null || to === void 0 ? void 0 : to.startsWith('http');
|
|
54
56
|
return isExternalLink ? (_jsx("a", Object.assign({ className: classNames(Styles.dropdownSection, Styles.dropdownLink, className), href: to, target: target }, rest, { children: children }))) : to ? (_jsx(NavigationComponent, Object.assign({ className: classNames(Styles.dropdownSection, Styles.dropdownLink, className), target: target, to: to }, rest, { children: children }))) : (_jsx("a", Object.assign({ className: classNames(Styles.dropdownSection, Styles.dropdownLink, className), onClick: clickHandler }, rest, { children: children })));
|
|
55
57
|
};
|
|
56
|
-
export const ProfileDropdown = (({ children, hintPopup, onClose, onOpen, trigger, }) => {
|
|
58
|
+
export const ProfileDropdown = (({ children, hintPopup, onClose, onOpen, trigger, width, }) => {
|
|
57
59
|
var _a;
|
|
58
60
|
const [open, setOpen] = useState(false);
|
|
59
61
|
const handleClose = useCallback(() => {
|
|
60
62
|
setOpen(false);
|
|
61
63
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
62
64
|
}, [onClose]);
|
|
65
|
+
const handleOpen = useCallback(() => {
|
|
66
|
+
setOpen(true);
|
|
67
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
68
|
+
}, [onOpen]);
|
|
63
69
|
const onTriggerClick = useCallback((e) => {
|
|
64
70
|
e.stopPropagation();
|
|
65
71
|
setOpen(!open);
|
|
@@ -71,10 +77,11 @@ export const ProfileDropdown = (({ children, hintPopup, onClose, onOpen, trigger
|
|
|
71
77
|
}
|
|
72
78
|
}, [open, onOpen, onClose]);
|
|
73
79
|
const hintShown = !!hintPopup && !open;
|
|
80
|
+
const HintComponent = hintPopup === null || hintPopup === void 0 ? void 0 : hintPopup.content;
|
|
74
81
|
const triggerElement = (_jsx(ProfileDropdownTrigger, Object.assign({}, trigger, { onClick: children ? onTriggerClick : undefined, hintArrow: hintShown })));
|
|
75
|
-
return (_jsx("div", Object.assign({ className: "position-relative" }, { children: !!hintPopup && hintShown ? (_jsx(Popover, Object.assign({ direction: "bl", width: (_a = hintPopup.width) !== null && _a !== void 0 ? _a : 'xs', trigger: triggerElement, popoverContentClassName: Styles.hint, onClickOutside: hintPopup === null || hintPopup === void 0 ? void 0 : hintPopup.onClose, open: true }, { children: _jsx("div", Object.assign({ className: classNames(Styles.hintContent, hintPopup.className) }, { children:
|
|
82
|
+
return (_jsx("div", Object.assign({ className: "position-relative" }, { children: !!hintPopup && hintShown && HintComponent ? (_jsx(Popover, Object.assign({ direction: "bl", width: (_a = hintPopup.width) !== null && _a !== void 0 ? _a : 'xs', trigger: triggerElement, popoverContentClassName: Styles.hint, onClickOutside: hintPopup === null || hintPopup === void 0 ? void 0 : hintPopup.onClose, open: true }, { children: _jsx("div", Object.assign({ className: classNames(Styles.hintContent, hintPopup.className) }, { children: _jsx(HintComponent, { openProfile: handleOpen }) })) }))) : (_jsx(Popover, Object.assign({ direction: "bl", width: width !== null && width !== void 0 ? width : 'xs', trigger: triggerElement, open: open, onClickOutside: handleClose, className: Styles.dropdown, popoverContentClassName: classNames(Styles.dropdownContent, Styles.dropdownContentBottomLeft) }, { children: _jsx("div", Object.assign({ className: Styles.dropdownContentWrapper, onClick: handleClose }, { children: children })) }))) })));
|
|
76
83
|
});
|
|
77
|
-
ProfileDropdown.Divider =
|
|
84
|
+
ProfileDropdown.Divider = ProfileDropdownDivider;
|
|
78
85
|
ProfileDropdown.Link = ProfileDropdownLink;
|
|
79
86
|
ProfileDropdown.Section = ProfileDropdownSection;
|
|
80
87
|
//# sourceMappingURL=profile-dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-dropdown.js","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAsB,MAAM,6BAA6B,CAAC;AAC1F,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAMH,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAY7C,MAAM,sBAAsB,GAAoC,CAAC,EAC7D,WAAW,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI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AAE,SAAS,EAAC,oBAAoB,EAAC,IAAI,EAAC,QAAQ,gBACzE,IAAI,CAAC,KAAK,IACJ,EACX,KAAC,QAAQ,kBACL,KAAK,EAAE,IAAI,CAAC,IAAI,EAChB,SAAS,EAAC,sCAAsC,EAChD,IAAI,EAAC,QAAQ,gBAEZ,IAAI,CAAC,IAAI,IACH,KACT,CACT,EAED,KAAC,IAAI,IAAC,SAAS,EAAC,UAAU,EAAC,IAAI,EAAC,aAAa,EAAC,IAAI,EAAE,EAAE,GAAI,EAEzD,CAAC,CAAC,WAAW,IAAI,CACd,cACI,SAAS,EAAE,UAAU,CACjB,MAAM,CAAC,WAAW,EAClB,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,WAAW,EAAE,CAC7D,GACH,CACL,EACA,CAAC,CAAC,KAAK,IAAI,CACR,6BACI,SAAS,EAAE,UAAU,CACjB,MAAM,CAAC,KAAK,EACZ,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAC/D,KAAK,CAAC,SAAS,CAClB,gBAEA,KAAK,CAAC,OAAO,IACX,CACV,KACC,CACT,CAAC;AACN,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"profile-dropdown.js","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAsB,MAAM,6BAA6B,CAAC;AAC1F,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAMH,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBA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,CAAC"}
|
|
@@ -78,6 +78,14 @@
|
|
|
78
78
|
width: 100%;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
:global(.Popover__divider) + :global(.Popover__divider) {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:global(.Popover__divider):last-child {
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
:global(.Popover__content).dropdown-content {
|
|
82
90
|
padding: @spacing-1 @spacing-0;
|
|
83
91
|
font-size: @typescale-2;
|
|
@@ -10,7 +10,6 @@ export declare const profileDropdownWithErrorLogo: () => import("react/jsx-runti
|
|
|
10
10
|
export declare const profileDropdownWithInfo: () => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export declare const profileDropdownWithCounter: () => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export declare const profileDropdownWithBothBadges: () => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare const log: (text: string) => void;
|
|
14
13
|
export declare const profileDropdownWithHintPopup: () => import("react/jsx-runtime").JSX.Element;
|
|
15
14
|
export declare const profileDropdownWithHintAndInfoPopup: () => import("react/jsx-runtime").JSX.Element;
|
|
16
15
|
//# sourceMappingURL=profile-dropdown.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-dropdown.stories.d.ts","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.stories.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"profile-dropdown.stories.d.ts","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.stories.tsx"],"names":[],"mappings":";;;;;AAMA,wBAIE;AAeF,eAAO,MAAM,sBAAsB,+CAgBlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,+CAanC,CAAC;AAEF,eAAO,MAAM,4BAA4B,+CAQxC,CAAC;AAEF,eAAO,MAAM,uBAAuB,+CASnC,CAAC;AAEF,eAAO,MAAM,0BAA0B,+CAUtC,CAAC;AAEF,eAAO,MAAM,6BAA6B,+CASzC,CAAC;AAKF,eAAO,MAAM,4BAA4B,+CA4BxC,CAAC;AAEF,eAAO,MAAM,mCAAmC,+CAa/C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@servicetitan/design-system';
|
|
2
3
|
import { HeaderNavigation } from '../header-navigation/header-navigation';
|
|
3
4
|
import { ProfileDropdown } from './profile-dropdown';
|
|
4
5
|
export default {
|
|
@@ -9,7 +10,7 @@ export default {
|
|
|
9
10
|
const NavLinkMock = props => (_jsx("a", Object.assign({ href: props.to, target: props.target, onClick: e => {
|
|
10
11
|
e.preventDefault();
|
|
11
12
|
}, className: props.className }, { children: props.children })));
|
|
12
|
-
export const profileDropdownDefault = () => (_jsx(HeaderNavigation, Object.assign({ navigationComponent: NavLinkMock }, { children: _jsxs(ProfileDropdown, { children: [_jsx(ProfileDropdown.Link, Object.assign({ to: "https://google.com" }, { children: "first link" })), _jsx(ProfileDropdown.Link, Object.assign({ onClick: () => alert('second click') }, { children: "second link" })), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Section, { children: "some content" }), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Link, Object.assign({ to: "https://google.com" }, { children: "third link" }))] }) })));
|
|
13
|
+
export const profileDropdownDefault = () => (_jsx(HeaderNavigation, Object.assign({ navigationComponent: NavLinkMock }, { children: _jsxs(ProfileDropdown, { children: [_jsx(ProfileDropdown.Link, Object.assign({ to: "https://google.com" }, { children: "first link" })), _jsx(ProfileDropdown.Link, Object.assign({ onClick: () => alert('second click') }, { children: "second link" })), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Section, { children: "some content" }), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Link, Object.assign({ to: "https://google.com" }, { children: "third link" })), _jsx(ProfileDropdown.Divider, {})] }) })));
|
|
13
14
|
export const profileDropdownWithLogo = () => (_jsx(HeaderNavigation, Object.assign({ navigationComponent: NavLinkMock }, { children: _jsxs(ProfileDropdown, Object.assign({ trigger: {
|
|
14
15
|
imageSrc: 'https://upload.wikimedia.org/wikipedia/en/1/11/Milhouse_Van_Houten.png',
|
|
15
16
|
} }, { children: [_jsx(ProfileDropdown.Link, Object.assign({ to: "https://google.com" }, { children: "first link" })), _jsx(ProfileDropdown.Link, Object.assign({ onClick: () => alert('second click') }, { children: "second link" }))] })) })));
|
|
@@ -30,13 +31,13 @@ export const profileDropdownWithBothBadges = () => (_jsx(HeaderNavigation, { chi
|
|
|
30
31
|
badge: { className: 'bg-red-400' },
|
|
31
32
|
} }) }));
|
|
32
33
|
// eslint-disable-next-line no-console
|
|
33
|
-
|
|
34
|
+
const log = (text) => console.log(text);
|
|
34
35
|
export const profileDropdownWithHintPopup = () => (_jsx(HeaderNavigation, Object.assign({ navigationComponent: NavLinkMock }, { children: _jsxs(ProfileDropdown, Object.assign({ trigger: {
|
|
35
36
|
avatarBadge: 'yellow-500',
|
|
36
37
|
badge: { className: 'bg-red-400' },
|
|
37
38
|
}, hintPopup: {
|
|
38
39
|
className: 'bg-blue-500-i c-white',
|
|
39
|
-
content:
|
|
40
|
+
content: ({ openProfile }) => (_jsxs("div", { children: ["hello", ' ', _jsx(Button, Object.assign({ onClick: openProfile, size: "xsmall" }, { children: "show me" }))] })),
|
|
40
41
|
width: 's',
|
|
41
42
|
onClose: () => log('close profile dropdown hint'),
|
|
42
43
|
}, onOpen: () => log('open profile dropdown'), onClose: () => log('close profile dropdown') }, { children: [_jsx(ProfileDropdown.Link, Object.assign({ to: "https://google.com" }, { children: "first item" })), _jsx(ProfileDropdown.Divider, {}), _jsx(ProfileDropdown.Section, { children: "second item" })] })) })));
|
|
@@ -45,6 +46,6 @@ export const profileDropdownWithHintAndInfoPopup = () => (_jsx(HeaderNavigation,
|
|
|
45
46
|
badge: { className: 'bg-red-400' },
|
|
46
47
|
info: { title: 'some text', text: 'qq' },
|
|
47
48
|
}, hintPopup: {
|
|
48
|
-
content: _jsx("div", { children: "hello" }),
|
|
49
|
+
content: () => _jsx("div", { children: "hello" }),
|
|
49
50
|
} }) })));
|
|
50
51
|
//# sourceMappingURL=profile-dropdown.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-dropdown.stories.js","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.stories.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"profile-dropdown.stories.js","sourceRoot":"","sources":["../../../src/components/profile-dropdown/profile-dropdown.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAe;IACX,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,eAAe;IAC1B,UAAU,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,WAAW,GAAuC,KAAK,CAAC,EAAE,CAAC,CAC7D,0BACI,IAAI,EAAE,KAAK,CAAC,EAAE,EACd,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,OAAO,EAAE,CAAC,CAAC,EAAE;QACT,CAAC,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC,EACD,SAAS,EAAE,KAAK,CAAC,SAAS,gBAEzB,KAAK,CAAC,QAAQ,IACf,CACP,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,CACxC,KAAC,gBAAgB,kBAAC,mBAAmB,EAAE,WAAW,gBAC9C,MAAC,eAAe,eACZ,KAAC,eAAe,CAAC,IAAI,kBAAC,EAAE,EAAC,oBAAoB,gCAAkC,EAC/E,KAAC,eAAe,C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C,IAAI,kBAAC,EAAE,EAAC,oBAAoB,gCAAkC,EAC/E,KAAC,eAAe,CAAC,OAAO,KAAG,EAC3B,KAAC,eAAe,CAAC,OAAO,8BAAsC,KAChD,IACH,CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,EAAE,CAAC,CACrD,KAAC,gBAAgB,kBAAC,mBAAmB,EAAE,WAAW,gBAC9C,KAAC,eAAe,IACZ,OAAO,EAAE;YACL,WAAW,EAAE,YAAY;YACzB,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE;YAClC,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE;SAC3C,EACD,SAAS,EAAE;YACP,OAAO,EAAE,GAAG,EAAE,CAAC,kCAAgB;SAClC,GACH,IACa,CACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/navigation",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Navigation components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"less": true,
|
|
44
44
|
"webpack": false
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "724504fc869d5ae68a39b70bc27f45bf8abae328"
|
|
47
47
|
}
|
|
@@ -78,6 +78,14 @@
|
|
|
78
78
|
width: 100%;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
:global(.Popover__divider) + :global(.Popover__divider) {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:global(.Popover__divider):last-child {
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
:global(.Popover__content).dropdown-content {
|
|
82
90
|
padding: @spacing-1 @spacing-0;
|
|
83
91
|
font-size: @typescale-2;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Button } from '@servicetitan/design-system';
|
|
1
2
|
import { FC } from 'react';
|
|
2
3
|
import { HeaderNavigationComponentProps } from '../../utils/navigation';
|
|
3
4
|
import { HeaderNavigation } from '../header-navigation/header-navigation';
|
|
@@ -32,7 +33,10 @@ export const profileDropdownDefault = () => (
|
|
|
32
33
|
<ProfileDropdown.Divider />
|
|
33
34
|
<ProfileDropdown.Section>some content</ProfileDropdown.Section>
|
|
34
35
|
<ProfileDropdown.Divider />
|
|
36
|
+
<ProfileDropdown.Divider />
|
|
37
|
+
<ProfileDropdown.Divider />
|
|
35
38
|
<ProfileDropdown.Link to="https://google.com">third link</ProfileDropdown.Link>
|
|
39
|
+
<ProfileDropdown.Divider />
|
|
36
40
|
</ProfileDropdown>
|
|
37
41
|
</HeaderNavigation>
|
|
38
42
|
);
|
|
@@ -97,7 +101,7 @@ export const profileDropdownWithBothBadges = () => (
|
|
|
97
101
|
);
|
|
98
102
|
|
|
99
103
|
// eslint-disable-next-line no-console
|
|
100
|
-
|
|
104
|
+
const log = (text: string) => console.log(text);
|
|
101
105
|
|
|
102
106
|
export const profileDropdownWithHintPopup = () => (
|
|
103
107
|
<HeaderNavigation navigationComponent={NavLinkMock}>
|
|
@@ -108,7 +112,14 @@ export const profileDropdownWithHintPopup = () => (
|
|
|
108
112
|
}}
|
|
109
113
|
hintPopup={{
|
|
110
114
|
className: 'bg-blue-500-i c-white',
|
|
111
|
-
content:
|
|
115
|
+
content: ({ openProfile }) => (
|
|
116
|
+
<div>
|
|
117
|
+
hello{' '}
|
|
118
|
+
<Button onClick={openProfile} size="xsmall">
|
|
119
|
+
show me
|
|
120
|
+
</Button>
|
|
121
|
+
</div>
|
|
122
|
+
),
|
|
112
123
|
width: 's',
|
|
113
124
|
onClose: () => log('close profile dropdown hint'),
|
|
114
125
|
}}
|
|
@@ -131,7 +142,7 @@ export const profileDropdownWithHintAndInfoPopup = () => (
|
|
|
131
142
|
info: { title: 'some text', text: 'qq' },
|
|
132
143
|
}}
|
|
133
144
|
hintPopup={{
|
|
134
|
-
content: <div>hello</div>,
|
|
145
|
+
content: () => <div>hello</div>,
|
|
135
146
|
}}
|
|
136
147
|
/>
|
|
137
148
|
</HeaderNavigation>
|
|
@@ -16,7 +16,7 @@ import { NavigationContext } from '../../utils/navigation-context';
|
|
|
16
16
|
import * as Styles from './profile-dropdown.module.less';
|
|
17
17
|
import { ProfileLogo } from './profile-icon';
|
|
18
18
|
|
|
19
|
-
interface ProfileDropdownTriggerProps {
|
|
19
|
+
export interface ProfileDropdownTriggerProps {
|
|
20
20
|
className?: string;
|
|
21
21
|
info?: { title: string; text: string };
|
|
22
22
|
imageSrc?: string | null;
|
|
@@ -114,16 +114,21 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
114
114
|
);
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
interface
|
|
117
|
+
export interface ProfileDropdownSectionPropsStrict {
|
|
118
118
|
children: ReactNode;
|
|
119
119
|
className?: string;
|
|
120
120
|
onClick?(e: MouseEvent): void;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
interface ProfileDropdownSectionProps extends ProfileDropdownSectionPropsStrict {
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
export const ProfileDropdownSection: FC<ProfileDropdownSectionProps> = ({
|
|
124
128
|
children,
|
|
125
129
|
className,
|
|
126
130
|
onClick,
|
|
131
|
+
...rest
|
|
127
132
|
}) => {
|
|
128
133
|
const clickHandler: MouseEventHandler<never> = e => {
|
|
129
134
|
if (onClick) {
|
|
@@ -134,12 +139,18 @@ export const ProfileDropdownSection: FC<ProfileDropdownSectionProps> = ({
|
|
|
134
139
|
};
|
|
135
140
|
|
|
136
141
|
return (
|
|
137
|
-
<div
|
|
142
|
+
<div
|
|
143
|
+
className={classNames(Styles.dropdownSection, className)}
|
|
144
|
+
onClick={clickHandler}
|
|
145
|
+
{...rest}
|
|
146
|
+
>
|
|
138
147
|
{children}
|
|
139
148
|
</div>
|
|
140
149
|
);
|
|
141
150
|
};
|
|
142
151
|
|
|
152
|
+
export const ProfileDropdownDivider: FC = Popover.Divider;
|
|
153
|
+
|
|
143
154
|
export interface ProfileDropdownLinkPropsStrict {
|
|
144
155
|
children: ReactNode;
|
|
145
156
|
className?: string;
|
|
@@ -205,16 +216,17 @@ export interface ProfileDropdownProps {
|
|
|
205
216
|
trigger?: Omit<ProfileDropdownTriggerProps, 'onClick'>;
|
|
206
217
|
hintPopup?: {
|
|
207
218
|
className?: string;
|
|
208
|
-
content:
|
|
219
|
+
content: FC<{ openProfile(): void }>;
|
|
209
220
|
width?: PopoverPropsStrict['width'];
|
|
210
221
|
onClose?: () => void;
|
|
211
222
|
};
|
|
223
|
+
width?: PopoverPropsStrict['width'];
|
|
212
224
|
onClose?(): void;
|
|
213
225
|
onOpen?(): void;
|
|
214
226
|
}
|
|
215
227
|
|
|
216
228
|
export interface ProfileDropdownType extends FC<ProfileDropdownProps> {
|
|
217
|
-
Divider: typeof
|
|
229
|
+
Divider: typeof ProfileDropdownDivider;
|
|
218
230
|
Link: typeof ProfileDropdownLink;
|
|
219
231
|
Section: typeof ProfileDropdownSection;
|
|
220
232
|
}
|
|
@@ -225,12 +237,17 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
225
237
|
onClose,
|
|
226
238
|
onOpen,
|
|
227
239
|
trigger,
|
|
240
|
+
width,
|
|
228
241
|
}) => {
|
|
229
242
|
const [open, setOpen] = useState(false);
|
|
230
243
|
const handleClose = useCallback(() => {
|
|
231
244
|
setOpen(false);
|
|
232
245
|
onClose?.();
|
|
233
246
|
}, [onClose]);
|
|
247
|
+
const handleOpen = useCallback(() => {
|
|
248
|
+
setOpen(true);
|
|
249
|
+
onOpen?.();
|
|
250
|
+
}, [onOpen]);
|
|
234
251
|
const onTriggerClick = useCallback(
|
|
235
252
|
(e: MouseEvent) => {
|
|
236
253
|
e.stopPropagation();
|
|
@@ -245,6 +262,7 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
245
262
|
[open, onOpen, onClose]
|
|
246
263
|
);
|
|
247
264
|
const hintShown = !!hintPopup && !open;
|
|
265
|
+
const HintComponent = hintPopup?.content;
|
|
248
266
|
|
|
249
267
|
const triggerElement = (
|
|
250
268
|
<ProfileDropdownTrigger
|
|
@@ -256,7 +274,7 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
256
274
|
|
|
257
275
|
return (
|
|
258
276
|
<div className="position-relative">
|
|
259
|
-
{!!hintPopup && hintShown ? (
|
|
277
|
+
{!!hintPopup && hintShown && HintComponent ? (
|
|
260
278
|
<Popover
|
|
261
279
|
direction="bl"
|
|
262
280
|
width={hintPopup.width ?? 'xs'}
|
|
@@ -266,13 +284,13 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
266
284
|
open
|
|
267
285
|
>
|
|
268
286
|
<div className={classNames(Styles.hintContent, hintPopup.className)}>
|
|
269
|
-
{
|
|
287
|
+
<HintComponent openProfile={handleOpen} />
|
|
270
288
|
</div>
|
|
271
289
|
</Popover>
|
|
272
290
|
) : (
|
|
273
291
|
<Popover
|
|
274
292
|
direction="bl"
|
|
275
|
-
width=
|
|
293
|
+
width={width ?? 'xs'}
|
|
276
294
|
trigger={triggerElement}
|
|
277
295
|
open={open}
|
|
278
296
|
onClickOutside={handleClose}
|
|
@@ -291,6 +309,6 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
291
309
|
);
|
|
292
310
|
}) as ProfileDropdownType;
|
|
293
311
|
|
|
294
|
-
ProfileDropdown.Divider =
|
|
312
|
+
ProfileDropdown.Divider = ProfileDropdownDivider;
|
|
295
313
|
ProfileDropdown.Link = ProfileDropdownLink;
|
|
296
314
|
ProfileDropdown.Section = ProfileDropdownSection;
|