@servicetitan/navigation 11.0.0-canary.237.6ce8e81.0 → 11.0.0-canary.237.8bb2b7d.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/badge-tag.d.ts +1 -1
- package/dist/components/badge-tag.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +1 -0
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +2 -2
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/titan-layout/layout-header.d.ts +2 -0
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header.js +3 -4
- package/dist/components/titan-layout/layout-header.js.map +1 -1
- package/dist/components/titan-layout/layout-header.module.less +24 -2
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.js +20 -5
- package/dist/components/titan-layout/layout-profile.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.stories.js +1 -1
- package/dist/components/titan-layout/layout-profile.stories.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +2 -2
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +4 -4
- package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.js +9 -2
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts +2 -0
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +6 -4
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.module.less +16 -3
- package/dist/components/titan-layout/notifications-context.d.ts +13 -0
- package/dist/components/titan-layout/notifications-context.d.ts.map +1 -0
- package/dist/components/titan-layout/notifications-context.js +23 -0
- package/dist/components/titan-layout/notifications-context.js.map +1 -0
- package/dist/components/titan-layout/titan-layout.d.ts +1 -0
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +35 -15
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/dist/components/titan-layout/titan-layout.module.less +22 -3
- package/dist/components/titan-layout/titan-layout.stories.d.ts +1 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.stories.js +4 -2
- package/dist/components/titan-layout/titan-layout.stories.js.map +1 -1
- package/dist/test/data.d.ts +4 -1
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +2 -3
- package/dist/test/data.js.map +1 -1
- package/package.json +2 -2
- package/src/components/badge-tag.tsx +1 -1
- package/src/components/profile-dropdown/profile-dropdown.tsx +5 -1
- package/src/components/titan-layout/layout-header.module.less +24 -2
- package/src/components/titan-layout/layout-header.tsx +7 -4
- package/src/components/titan-layout/layout-profile.stories.tsx +1 -1
- package/src/components/titan-layout/layout-profile.tsx +42 -19
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +18 -5
- package/src/components/titan-layout/layout-sidebar-links.tsx +11 -2
- package/src/components/titan-layout/layout-sidebar.module.less +16 -3
- package/src/components/titan-layout/layout-sidebar.module.less.d.ts +1 -0
- package/src/components/titan-layout/layout-sidebar.tsx +14 -5
- package/src/components/titan-layout/notifications-context.tsx +44 -0
- package/src/components/titan-layout/titan-layout.module.less +22 -3
- package/src/components/titan-layout/titan-layout.module.less.d.ts +1 -1
- package/src/components/titan-layout/titan-layout.stories.tsx +6 -1
- package/src/components/titan-layout/titan-layout.tsx +89 -55
- package/src/test/data.tsx +2 -3
|
@@ -29,6 +29,7 @@ import { TitanLayoutLogo, TitanLayoutLogoProps } from './layout-logo';
|
|
|
29
29
|
import { LayoutSidebar } from './layout-sidebar';
|
|
30
30
|
import { TitanLayoutSidebarLink, TitanLayoutSidebarTrigger } from './layout-sidebar-links';
|
|
31
31
|
import { InternalSideNavigationTrigger } from './layout-sidebar-links-internal';
|
|
32
|
+
import { useNotificationsState } from './notifications-context';
|
|
32
33
|
import * as Styles from './titan-layout.module.less';
|
|
33
34
|
|
|
34
35
|
type TitanLayoutChild = ReactElement<TitanLayoutContentProps> | ReactElement<TitanLayoutLogoProps>;
|
|
@@ -57,6 +58,7 @@ export type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'
|
|
|
57
58
|
extraLinks?: ReactElement;
|
|
58
59
|
extraLinksTop?: ReactElement;
|
|
59
60
|
extraText?: string;
|
|
61
|
+
minContentWidth?: number;
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
const defaultSidebarContext: TitanLayoutSidebarContextType = {
|
|
@@ -125,6 +127,7 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
125
127
|
extraLinks,
|
|
126
128
|
extraLinksTop,
|
|
127
129
|
extraText,
|
|
130
|
+
minContentWidth,
|
|
128
131
|
sideTop,
|
|
129
132
|
}) => {
|
|
130
133
|
const breakpoint = useTitanBreakpoint();
|
|
@@ -141,21 +144,15 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
141
144
|
const variant = useVariant(appearance);
|
|
142
145
|
const [mobileDrawerOpened, setMobileDrawerOpened] = useState(false);
|
|
143
146
|
const { content, logo } = useLayoutChildren(children);
|
|
147
|
+
const { hasNotifications, NotificationsContextProvider } = useNotificationsState();
|
|
144
148
|
|
|
145
149
|
useEffect(() => {
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
if (variant.isAnvil1) {
|
|
151
|
+
const bodyClassName = 'of-hidden-i';
|
|
152
|
+
document.body.classList.add(bodyClassName);
|
|
153
|
+
return () => document.body.classList.remove(bodyClassName);
|
|
149
154
|
}
|
|
150
|
-
|
|
151
|
-
const listener = () => {
|
|
152
|
-
setMobileDrawerOpened(false);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
document.addEventListener('click', listener);
|
|
156
|
-
|
|
157
|
-
return () => document.removeEventListener('click', listener);
|
|
158
|
-
}, [isMobile]);
|
|
155
|
+
}, [variant.isAnvil1]);
|
|
159
156
|
|
|
160
157
|
const onBurgerClick = useCallback((e: MouseEvent) => {
|
|
161
158
|
setMobileDrawerOpened(true);
|
|
@@ -181,6 +178,24 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
181
178
|
},
|
|
182
179
|
[state, onStateChange]
|
|
183
180
|
);
|
|
181
|
+
const hasMenuNotifications = useMemo(() => {
|
|
182
|
+
try {
|
|
183
|
+
return (
|
|
184
|
+
navigationMainItems?.some(item => {
|
|
185
|
+
if (item.counter || item.tag?.value) {
|
|
186
|
+
return true;
|
|
187
|
+
} else if (item.submenu) {
|
|
188
|
+
return item.submenu.groups.some(group =>
|
|
189
|
+
group.links.some(link => !!link.counter || !!link.tag?.value)
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}) ?? false
|
|
194
|
+
);
|
|
195
|
+
} catch {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}, [navigationMainItems]);
|
|
184
199
|
|
|
185
200
|
const layoutClass = variant.isLegacy
|
|
186
201
|
? Styles.layoutLegacy
|
|
@@ -215,44 +230,50 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
215
230
|
{!isMobile && extraLinks}
|
|
216
231
|
</Fragment>
|
|
217
232
|
}
|
|
233
|
+
isMobile={isMobile}
|
|
234
|
+
hasNotifications={hasNotifications || hasMenuNotifications}
|
|
218
235
|
onBurgerClick={onBurgerClick}
|
|
219
236
|
/>
|
|
220
237
|
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
238
|
+
<NotificationsContextProvider>
|
|
239
|
+
<LayoutSidebar
|
|
240
|
+
className={Styles.side}
|
|
241
|
+
mobile={breakpoint.isMobile}
|
|
242
|
+
barExpanded={!state?.navCollapsed}
|
|
243
|
+
onBarExpandChange={onBarExpandChange}
|
|
244
|
+
submenuExpanded={state?.submenuExpanded}
|
|
245
|
+
onSubmenuExpandChange={onSubmenuExpandChange}
|
|
246
|
+
drawerOpened={mobileDrawerOpened}
|
|
247
|
+
onDrawerOpenChange={setMobileDrawerOpened}
|
|
248
|
+
top={sideTop}
|
|
249
|
+
mainItems={navigationMainItems}
|
|
250
|
+
navigationComponent={context.NavigationComponent}
|
|
251
|
+
bottom={
|
|
252
|
+
isMobile ? (
|
|
253
|
+
<Fragment>
|
|
254
|
+
{profile}
|
|
255
|
+
{extraLinks}
|
|
256
|
+
{!!extraText && (
|
|
257
|
+
<InternalSideNavigationTrigger
|
|
258
|
+
id="__extra_text"
|
|
259
|
+
title={extraText}
|
|
260
|
+
submenuExpanded={undefined}
|
|
261
|
+
dataPrefix="navigation-extra-text"
|
|
262
|
+
tag={undefined}
|
|
263
|
+
icon={undefined}
|
|
264
|
+
iconActive={undefined}
|
|
265
|
+
/>
|
|
266
|
+
)}
|
|
267
|
+
</Fragment>
|
|
268
|
+
) : undefined
|
|
269
|
+
}
|
|
270
|
+
/>
|
|
271
|
+
</NotificationsContextProvider>
|
|
252
272
|
<LayoutContent
|
|
253
273
|
header={header}
|
|
254
274
|
anvil2={variant.isAnvil2}
|
|
255
275
|
anvil1={variant.isAnvil1}
|
|
276
|
+
minWidth={minContentWidth}
|
|
256
277
|
>
|
|
257
278
|
{content}
|
|
258
279
|
</LayoutContent>
|
|
@@ -291,7 +312,7 @@ const TitanLayoutHeaderObserved: FC<{
|
|
|
291
312
|
};
|
|
292
313
|
}, [heightChange]);
|
|
293
314
|
return (
|
|
294
|
-
<div ref={ref} className={Styles.header
|
|
315
|
+
<div ref={ref} className={Styles.contentHeader} data-cy="layout-content-header">
|
|
295
316
|
{children}
|
|
296
317
|
</div>
|
|
297
318
|
);
|
|
@@ -307,30 +328,43 @@ const LayoutContent: FC<{
|
|
|
307
328
|
header?: ReactNode;
|
|
308
329
|
anvil1: boolean;
|
|
309
330
|
anvil2: boolean;
|
|
310
|
-
|
|
331
|
+
minWidth: number | undefined;
|
|
332
|
+
}> = ({ anvil1, anvil2, children, header, minWidth }) => {
|
|
311
333
|
const [anvil2Styles, setAnvil2Styles] = useState<object>({});
|
|
312
334
|
const updateIndicatorsHeight = useCallback((offset: number) => {
|
|
313
335
|
setAnvil2Styles({ '--offset': `calc(var(--nav-offset-top) + ${offset}px)` });
|
|
314
336
|
}, []);
|
|
315
337
|
|
|
338
|
+
const contentStyles = useMemo(
|
|
339
|
+
() => ({
|
|
340
|
+
...(minWidth ? { minWidth: `${minWidth}px` } : {}),
|
|
341
|
+
...(anvil2 ? anvil2Styles : {}),
|
|
342
|
+
}),
|
|
343
|
+
[anvil2, minWidth, anvil2Styles]
|
|
344
|
+
);
|
|
345
|
+
|
|
316
346
|
return (
|
|
317
|
-
<
|
|
347
|
+
<Fragment>
|
|
318
348
|
{!!header &&
|
|
319
349
|
(anvil2 ? (
|
|
320
350
|
<TitanLayoutHeaderObserved heightChange={updateIndicatorsHeight}>
|
|
321
351
|
{header}
|
|
322
352
|
</TitanLayoutHeaderObserved>
|
|
323
353
|
) : (
|
|
324
|
-
header
|
|
354
|
+
<div className={Styles.contentHeader} data-cy="layout-content-header">
|
|
355
|
+
{header}
|
|
356
|
+
</div>
|
|
325
357
|
))}
|
|
326
|
-
{
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
358
|
+
<div className={Styles.content} style={contentStyles} data-cy="layout-content">
|
|
359
|
+
{anvil1 ? (
|
|
360
|
+
<div className="position-relative d-f flex-grow-1 flex-basis-0 of-hidden">
|
|
361
|
+
{children}
|
|
362
|
+
</div>
|
|
363
|
+
) : (
|
|
364
|
+
children
|
|
365
|
+
)}
|
|
366
|
+
</div>
|
|
367
|
+
</Fragment>
|
|
334
368
|
);
|
|
335
369
|
};
|
|
336
370
|
|
package/src/test/data.tsx
CHANGED
|
@@ -66,7 +66,6 @@ export const NavLinkMock = forwardRef<any, NavLinkComponentProps>(
|
|
|
66
66
|
{...rest}
|
|
67
67
|
onClick={e => {
|
|
68
68
|
e.preventDefault();
|
|
69
|
-
e.stopPropagation();
|
|
70
69
|
|
|
71
70
|
if (!to.startsWith('http')) {
|
|
72
71
|
history.replace(to);
|
|
@@ -82,10 +81,10 @@ export const NavLinkMock = forwardRef<any, NavLinkComponentProps>(
|
|
|
82
81
|
}
|
|
83
82
|
);
|
|
84
83
|
|
|
85
|
-
export const LocationInfo = () => {
|
|
84
|
+
export const LocationInfo: FC<{ className?: string }> = ({ className }) => {
|
|
86
85
|
const location = useLocation();
|
|
87
86
|
|
|
88
|
-
return <BodyText>current location - {location.pathname}</BodyText>;
|
|
87
|
+
return <BodyText className={className}>current location - {location.pathname}</BodyText>;
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
const LocationProvider: FC<{ children: any }> = ({ children }) => {
|