@servicetitan/navigation 11.1.2 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/titan-layout/layout-header-dark.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-dark.js +32 -20
- package/dist/components/titan-layout/layout-header-dark.js.map +1 -1
- package/dist/components/titan-layout/layout-header-links-internal.d.ts +10 -0
- package/dist/components/titan-layout/layout-header-links-internal.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-header-links-internal.js +75 -0
- package/dist/components/titan-layout/layout-header-links-internal.js.map +1 -0
- package/dist/components/titan-layout/layout-header-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-links.js +10 -70
- package/dist/components/titan-layout/layout-header-links.js.map +1 -1
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header.js +1 -0
- package/dist/components/titan-layout/layout-header.js.map +1 -1
- package/dist/components/titan-layout/layout-header.module.less +76 -63
- package/dist/components/titan-layout/layout-header.module.less.d.ts +1 -0
- package/dist/components/titan-layout/layout-logo.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-logo.js +5 -2
- package/dist/components/titan-layout/layout-logo.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.js +4 -3
- package/dist/components/titan-layout/layout-profile.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +3 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +7 -3
- package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.js +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +6 -3
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +1 -2
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- 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/with-tooltip.d.ts +1 -1
- package/dist/components/titan-layout/with-tooltip.d.ts.map +1 -1
- package/dist/components/titan-layout/with-tooltip.js.map +1 -1
- package/package.json +2 -2
- package/src/components/titan-layout/layout-header-dark.tsx +42 -20
- package/src/components/titan-layout/layout-header-links-internal.tsx +151 -0
- package/src/components/titan-layout/layout-header-links.tsx +9 -125
- package/src/components/titan-layout/layout-header.module.less +76 -63
- package/src/components/titan-layout/layout-header.module.less.d.ts +1 -0
- package/src/components/titan-layout/layout-header.tsx +5 -1
- package/src/components/titan-layout/layout-logo.tsx +10 -5
- package/src/components/titan-layout/layout-profile.tsx +4 -3
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +14 -5
- package/src/components/titan-layout/layout-sidebar-links.tsx +1 -1
- package/src/components/titan-layout/layout-sidebar.tsx +8 -6
- package/src/components/titan-layout/titan-layout.stories.tsx +14 -0
- package/src/components/titan-layout/titan-layout.tsx +1 -2
- package/src/components/titan-layout/with-tooltip.tsx +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/titan-layout/titan-layout.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport {\n CSSProperties,\n ComponentPropsWithoutRef,\n FC,\n Fragment,\n ReactElement,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { NavigationItemData } from '../../utils/navigation';\nimport { DefaultNavLinkComponent, NavLinkComponentProps } from '../../utils/navigation-context';\nimport { useTitanBreakpoint } from '../../utils/use-breakpoint';\nimport { TitanLayoutState } from './interface';\nimport {\n LayoutContext,\n LayoutPlacementContext,\n TitanLayoutContextType,\n TitanLayoutSidebarContextType,\n} from './layout-context';\nimport { LayoutHeader } from './layout-header';\nimport { LayoutHeaderDark } from './layout-header-dark';\nimport { TitanLayoutLogoProps } from './layout-logo';\nimport { LayoutSidebar } from './layout-sidebar';\nimport { TitanLayoutSidebarLink, TitanLayoutSidebarTrigger } from './layout-sidebar-links';\nimport { InternalSideNavigationTrigger } from './layout-sidebar-links-internal';\nimport { useNotificationsState } from './notifications-context';\nimport * as Styles from './titan-layout.module.less';\n\nexport type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'style'> & {\n /** layout appearance */\n appearance?: 'legacy' | 'anvil1' | 'anvil2';\n\n /** layout navigation variant (left by default) */\n navVariant?: 'left' | 'top';\n\n /** layout's content */\n children?: ReactNode;\n\n /** show only content without side and top bars */\n contentOnly?: boolean;\n\n /** component used for navigation */\n navigationComponent?: FC<NavLinkComponentProps>;\n\n /** data for main navigation links */\n navigationMainItems?: NavigationItemData[];\n\n /** data for overflow navigation links (used only with top variant) */\n navigationOverflowItems?: NavigationItemData[];\n\n /** logo props */\n logo?: TitanLayoutLogoProps;\n\n state?: TitanLayoutState;\n onStateChange?: (state: TitanLayoutState) => void;\n\n header?: ReactElement;\n top?: ReactElement;\n sideTop?: ReactElement[];\n profile?: ReactElement;\n extraLinks?: ReactElement;\n extraLinksTop?: ReactElement;\n extraText?: string;\n minContentWidth?: number;\n};\n\nconst defaultSidebarContext: TitanLayoutSidebarContextType = {\n styles: {\n popoverContent: {\n '--background-color-strong': '#24323C',\n 'color': 'var(--color-white)',\n } as CSSProperties,\n },\n};\n\nconst useAppearance = (appearance: TitanLayoutProps['appearance']) =>\n useMemo(() => {\n const isLegacy = appearance === 'legacy';\n const isAnvil1 = appearance === 'anvil1';\n const isAnvil2 = appearance === 'anvil2';\n\n return {\n isLegacy,\n isAnvil1,\n isAnvil2,\n isSequent: isLegacy || isAnvil2,\n };\n }, [appearance]);\n\nconst TitanLayoutComponent: FC<TitanLayoutProps> = ({\n appearance = 'anvil2',\n navVariant = 'left',\n id,\n children,\n contentOnly,\n navigationComponent,\n header,\n top,\n profile,\n state,\n logo,\n onStateChange,\n navigationMainItems,\n navigationOverflowItems,\n extraLinks,\n extraLinksTop,\n extraText,\n minContentWidth,\n sideTop,\n}) => {\n const breakpoint = useTitanBreakpoint();\n const context: TitanLayoutContextType = useMemo(\n () => ({\n NavigationComponent: navigationComponent ?? DefaultNavLinkComponent,\n breakpoint,\n isTitanLayout: true,\n sidebar: defaultSidebarContext,\n }),\n [navigationComponent, breakpoint]\n );\n const view = useAppearance(appearance);\n const [mobileDrawerOpened, setMobileDrawerOpened] = useState(false);\n const { hasNotifications, NotificationsContextProvider } = useNotificationsState();\n const [offsetTopStyles, setOffsetTopStyles] = useState<object>({});\n const updateIndicatorsHeight = useCallback((offset: number) => {\n setOffsetTopStyles({\n '--content-offset-top': `calc(var(--nav-offset-top) + ${offset}px)`,\n });\n }, []);\n\n const isMobile = breakpoint.isMobile;\n const hasSideBar =\n !contentOnly &&\n (navVariant === 'left' || (navVariant === 'top' && isMobile)) &&\n (!!navigationMainItems?.length || !!sideTop?.length);\n const hasTopBar = !contentOnly;\n\n useEffect(() => {\n if (view.isAnvil1) {\n const bodyClassName = 'of-hidden-i';\n document.body.classList.add(bodyClassName);\n return () => document.body.classList.remove(bodyClassName);\n }\n }, [view.isAnvil1]);\n\n const onBurgerClick = useCallback((e: MouseEvent) => {\n setMobileDrawerOpened(true);\n e.stopPropagation();\n }, []);\n\n const onBarExpandChange = useCallback(\n (expanded: boolean) => {\n if (isMobile) {\n setMobileDrawerOpened(false);\n } else {\n onStateChange?.({ navCollapsed: !expanded });\n }\n },\n [onStateChange, isMobile]\n );\n const onSubmenuExpandChange = useCallback(\n (id: string, expanded: boolean) => {\n onStateChange?.({\n navCollapsed: state?.navCollapsed ?? false,\n submenuExpanded: expanded ? id : undefined,\n });\n },\n [state, onStateChange]\n );\n const sidebarNavItems = useMemo(() => {\n if (!hasSideBar) {\n return undefined;\n }\n\n if (navVariant === 'left') {\n return navigationMainItems;\n }\n\n return [...(navigationMainItems ?? []), ...(navigationOverflowItems ?? [])];\n }, [hasSideBar, navigationMainItems, navigationOverflowItems, navVariant]);\n\n const hasMenuNotifications = useMemo(() => {\n try {\n return (\n sidebarNavItems?.some(item => {\n if (item.counter || item.tag?.value) {\n return true;\n } else if (item.submenu) {\n return item.submenu.groups.some(group =>\n group.links.some(link => !!link.counter || !!link.tag?.value)\n );\n }\n return false;\n }) ?? false\n );\n } catch {\n return false;\n }\n }, [sidebarNavItems]);\n\n const limitContentWidth = useMemo(() => {\n if (view.isAnvil2 || !minContentWidth) {\n return undefined;\n }\n\n if (breakpoint.width < minContentWidth) {\n return minContentWidth;\n }\n }, [view, minContentWidth, breakpoint.width]);\n\n const contentStyles = useMemo(() => {\n if (view.isAnvil2) {\n return offsetTopStyles;\n }\n\n if (view.isLegacy) {\n return {\n ...(limitContentWidth\n ? { display: 'flex', flexDirection: 'column', minHeight: '100vh' }\n : {}),\n ...offsetTopStyles,\n };\n }\n }, [view, offsetTopStyles, limitContentWidth]);\n\n const layoutClass = view.isLegacy\n ? Styles.layoutLegacy\n : view.isAnvil1\n ? Styles.layoutAnvil1\n : Styles.layoutAnvil2;\n\n return (\n <LayoutContext.Provider value={context}>\n <LayoutPlacementContext.Provider value=\"unset\">\n <div\n id={id}\n className={classNames(\n Styles.layout,\n isMobile ? Styles.layoutMobile : Styles.layoutDesktop,\n hasTopBar &&\n (navVariant === 'left' || !top\n ? Styles.layoutTopLight\n : Styles.layoutTopNav),\n {\n [Styles.layoutNavSlim]: !isMobile && hasSideBar && state?.navCollapsed,\n [Styles.layoutNavWide]: !isMobile && hasSideBar && !state?.navCollapsed,\n },\n layoutClass\n )}\n style={contentStyles}\n >\n {view.isSequent && <div className={Styles.topPlaceholder} />}\n {hasTopBar &&\n (navVariant === 'left' ? (\n <LayoutHeader\n className={Styles.top}\n variant=\"light\"\n logo={logo}\n profile={isMobile ? undefined : profile}\n center={top}\n rightText={isMobile ? undefined : extraText}\n right={\n <Fragment>\n {extraLinksTop}\n {!isMobile && extraLinks}\n </Fragment>\n }\n isMobile={isMobile}\n hasNotifications={hasNotifications || hasMenuNotifications}\n onBurgerClick={onBurgerClick}\n />\n ) : (\n <LayoutHeaderDark\n className={Styles.top}\n logo={logo}\n profile={isMobile ? undefined : profile}\n center={top}\n rightText={isMobile ? undefined : extraText}\n right={\n <Fragment>\n {extraLinksTop}\n {!isMobile && extraLinks}\n </Fragment>\n }\n isMobile={isMobile}\n hasNotifications={hasNotifications || hasMenuNotifications}\n onBurgerClick={onBurgerClick}\n navigationMainItems={navigationMainItems}\n navigationOverflowItems={navigationOverflowItems}\n />\n ))}\n\n {hasSideBar && (\n <NotificationsContextProvider>\n <LayoutSidebar\n className={Styles.side}\n mobile={breakpoint.isMobile}\n barExpanded={!state?.navCollapsed}\n onBarExpandChange={onBarExpandChange}\n submenuExpanded={state?.submenuExpanded}\n onSubmenuExpandChange={onSubmenuExpandChange}\n drawerOpened={mobileDrawerOpened}\n onDrawerOpenChange={setMobileDrawerOpened}\n top={sideTop}\n mainItems={sidebarNavItems}\n navigationComponent={context.NavigationComponent}\n bottom={\n isMobile ? (\n <Fragment>\n {profile}\n {extraLinks}\n {!!extraText && (\n <InternalSideNavigationTrigger\n id=\"__extra_text\"\n title={extraText}\n submenuExpanded={undefined}\n dataPrefix=\"navigation-extra-text\"\n tag={undefined}\n icon={undefined}\n iconActive={undefined}\n />\n )}\n </Fragment>\n ) : undefined\n }\n />\n </NotificationsContextProvider>\n )}\n\n {view.isSequent && (\n <TitanLayoutHeaderObserved heightChange={updateIndicatorsHeight}>\n {header}\n </TitanLayoutHeaderObserved>\n )}\n {view.isAnvil1 ? (\n <LayoutContentAnvil1 header={header} minWidth={limitContentWidth}>\n {children}\n </LayoutContentAnvil1>\n ) : view.isLegacy ? (\n <LayoutContentLegacy minWidth={limitContentWidth}>\n {children}\n </LayoutContentLegacy>\n ) : (\n children\n )}\n </div>\n </LayoutPlacementContext.Provider>\n </LayoutContext.Provider>\n );\n};\n\nconst TitanLayoutHeaderObserved: FC<{\n children: ReactNode;\n heightChange?(value: number): void;\n}> = ({ children, heightChange }) => {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (ref.current) {\n const updatePosition = () => {\n if (ref.current && heightChange) {\n const pos = ref.current.getBoundingClientRect();\n heightChange(pos.height);\n }\n };\n\n const observer = new ResizeObserver(updatePosition);\n observer.observe(ref.current);\n\n updatePosition();\n return () => observer.disconnect();\n }\n }, [heightChange]);\n\n useEffect(() => {\n return () => {\n heightChange?.(0);\n };\n }, [heightChange]);\n return (\n <div ref={ref} className={Styles.contentHeader} data-cy=\"layout-content-header\">\n {children}\n </div>\n );\n};\nconst TitanLayoutHeader: FC<{ children: ReactNode }> = ({ children }) => {\n return (\n <div className={Styles.contentHeader} data-cy=\"layout-content-header\">\n {children}\n </div>\n );\n};\n\nconst LayoutContentAnvil1: FC<{\n children: ReactNode;\n header?: ReactNode;\n minWidth?: number;\n}> = ({ children, header, minWidth }) => {\n const innerContentStyles: CSSProperties = useMemo(\n () => ({\n ...(minWidth ? { minWidth: `${minWidth}px`, overflowX: 'auto' } : {}),\n }),\n [minWidth]\n );\n\n return (\n <Fragment>\n <TitanLayoutHeader>{header}</TitanLayoutHeader>\n <div\n className={classNames(Styles.content, { 'of-x-auto-i': !!minWidth })}\n data-cy=\"layout-content\"\n >\n <div\n className=\"position-relative d-f flex-grow-1 flex-basis-0 of-hidden\"\n style={innerContentStyles}\n >\n {children}\n </div>\n </div>\n </Fragment>\n );\n};\n\nconst LayoutContentLegacy: FC<{\n children: ReactNode;\n minWidth: number | undefined;\n}> = ({ children, minWidth }) => {\n const innerContentStyles: CSSProperties = useMemo(\n () => ({\n position: 'relative',\n minWidth: `${minWidth}px`,\n }),\n [minWidth]\n );\n\n return (\n <div className={minWidth ? 'of-x-auto flex-basis-0 flex-grow-1' : undefined}>\n <div style={minWidth ? innerContentStyles : undefined}>{children}</div>\n </div>\n );\n};\n\nexport const TitanLayout = Object.assign(TitanLayoutComponent, {\n Link: TitanLayoutSidebarLink,\n Trigger: TitanLayoutSidebarTrigger,\n});\n"],"names":["classNames","Fragment","useCallback","useEffect","useMemo","useRef","useState","DefaultNavLinkComponent","useTitanBreakpoint","LayoutContext","LayoutPlacementContext","LayoutHeader","LayoutHeaderDark","LayoutSidebar","TitanLayoutSidebarLink","TitanLayoutSidebarTrigger","InternalSideNavigationTrigger","useNotificationsState","Styles","defaultSidebarContext","styles","popoverContent","useAppearance","appearance","isLegacy","isAnvil1","isAnvil2","isSequent","TitanLayoutComponent","navVariant","id","children","contentOnly","navigationComponent","header","top","profile","state","logo","onStateChange","navigationMainItems","navigationOverflowItems","extraLinks","extraLinksTop","extraText","minContentWidth","sideTop","breakpoint","context","NavigationComponent","isTitanLayout","sidebar","view","mobileDrawerOpened","setMobileDrawerOpened","hasNotifications","NotificationsContextProvider","offsetTopStyles","setOffsetTopStyles","updateIndicatorsHeight","offset","isMobile","hasSideBar","length","hasTopBar","bodyClassName","document","body","classList","add","remove","onBurgerClick","e","stopPropagation","onBarExpandChange","expanded","navCollapsed","onSubmenuExpandChange","submenuExpanded","undefined","sidebarNavItems","hasMenuNotifications","some","item","counter","tag","value","submenu","groups","group","links","link","limitContentWidth","width","contentStyles","display","flexDirection","minHeight","layoutClass","layoutLegacy","layoutAnvil1","layoutAnvil2","Provider","div","className","layout","layoutMobile","layoutDesktop","layoutTopLight","layoutTopNav","layoutNavSlim","layoutNavWide","style","topPlaceholder","variant","center","rightText","right","side","mobile","barExpanded","drawerOpened","onDrawerOpenChange","mainItems","bottom","title","dataPrefix","icon","iconActive","TitanLayoutHeaderObserved","heightChange","LayoutContentAnvil1","minWidth","LayoutContentLegacy","ref","current","updatePosition","pos","getBoundingClientRect","height","observer","ResizeObserver","observe","disconnect","contentHeader","data-cy","TitanLayoutHeader","innerContentStyles","overflowX","content","position","TitanLayout","Object","assign","Link","Trigger"],"mappings":";AAAA,OAAOA,gBAAgB,aAAa;AACpC,SAIIC,QAAQ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G,sBAGD,CAAC,EAAEtG,QAAQ,EAAEqG,QAAQ,EAAE;IACxB,MAAMe,qBAAoC/I,QACtC,IAAO,CAAA;YACHkJ,UAAU;YACVlB,UAAU,GAAGA,SAAS,EAAE,CAAC;QAC7B,CAAA,GACA;QAACA;KAAS;IAGd,qBACI,KAAC7B;QAAIC,WAAW4B,WAAW,uCAAuCrD;kBAC9D,cAAA,KAACwB;YAAIS,OAAOoB,WAAWe,qBAAqBpE;sBAAYhD;;;AAGpE;AAEA,OAAO,MAAMwH,cAAcC,OAAOC,MAAM,CAAC7H,sBAAsB;IAC3D8H,MAAM5I;IACN6I,SAAS5I;AACb,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/titan-layout/titan-layout.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport {\n CSSProperties,\n ComponentPropsWithoutRef,\n FC,\n Fragment,\n ReactElement,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { NavigationItemData } from '../../utils/navigation';\nimport { DefaultNavLinkComponent, NavLinkComponentProps } from '../../utils/navigation-context';\nimport { useTitanBreakpoint } from '../../utils/use-breakpoint';\nimport { TitanLayoutState } from './interface';\nimport {\n LayoutContext,\n LayoutPlacementContext,\n TitanLayoutContextType,\n TitanLayoutSidebarContextType,\n} from './layout-context';\nimport { LayoutHeader } from './layout-header';\nimport { LayoutHeaderDark } from './layout-header-dark';\nimport { TitanLayoutLogoProps } from './layout-logo';\nimport { LayoutSidebar } from './layout-sidebar';\nimport { TitanLayoutSidebarLink, TitanLayoutSidebarTrigger } from './layout-sidebar-links';\nimport { InternalSideNavigationTrigger } from './layout-sidebar-links-internal';\nimport { useNotificationsState } from './notifications-context';\nimport * as Styles from './titan-layout.module.less';\n\nexport type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'style'> & {\n /** layout appearance */\n appearance?: 'legacy' | 'anvil1' | 'anvil2';\n\n /** layout navigation variant (left by default) */\n navVariant?: 'left' | 'top';\n\n /** layout's content */\n children?: ReactNode;\n\n /** show only content without side and top bars */\n contentOnly?: boolean;\n\n /** component used for navigation */\n navigationComponent?: FC<NavLinkComponentProps>;\n\n /** data for main navigation links */\n navigationMainItems?: NavigationItemData[];\n\n /** data for overflow navigation links (used only with top variant) */\n navigationOverflowItems?: NavigationItemData[];\n\n /** logo props */\n logo?: TitanLayoutLogoProps;\n\n state?: TitanLayoutState;\n onStateChange?: (state: TitanLayoutState) => void;\n\n header?: ReactElement;\n top?: ReactElement;\n sideTop?: ReactElement[];\n profile?: ReactElement;\n extraLinks?: ReactElement;\n extraLinksTop?: ReactElement;\n extraText?: string;\n minContentWidth?: number;\n};\n\nconst defaultSidebarContext: TitanLayoutSidebarContextType = {\n styles: {\n popoverContent: {\n '--background-color-strong': '#24323C',\n 'color': 'var(--color-white)',\n } as CSSProperties,\n },\n};\n\nconst useAppearance = (appearance: TitanLayoutProps['appearance']) =>\n useMemo(() => {\n const isLegacy = appearance === 'legacy';\n const isAnvil1 = appearance === 'anvil1';\n const isAnvil2 = appearance === 'anvil2';\n\n return {\n isLegacy,\n isAnvil1,\n isAnvil2,\n isSequent: isLegacy || isAnvil2,\n };\n }, [appearance]);\n\nconst TitanLayoutComponent: FC<TitanLayoutProps> = ({\n appearance = 'anvil2',\n navVariant = 'left',\n id,\n children,\n contentOnly,\n navigationComponent,\n header,\n top,\n profile,\n state,\n logo,\n onStateChange,\n navigationMainItems,\n navigationOverflowItems,\n extraLinks,\n extraLinksTop,\n extraText,\n minContentWidth,\n sideTop,\n}) => {\n const breakpoint = useTitanBreakpoint();\n const context: TitanLayoutContextType = useMemo(\n () => ({\n NavigationComponent: navigationComponent ?? DefaultNavLinkComponent,\n breakpoint,\n isTitanLayout: true,\n sidebar: defaultSidebarContext,\n }),\n [navigationComponent, breakpoint]\n );\n const view = useAppearance(appearance);\n const [mobileDrawerOpened, setMobileDrawerOpened] = useState(false);\n const { hasNotifications, NotificationsContextProvider } = useNotificationsState();\n const [offsetTopStyles, setOffsetTopStyles] = useState<object>({});\n const updateIndicatorsHeight = useCallback((offset: number) => {\n setOffsetTopStyles({\n '--content-offset-top': `calc(var(--nav-offset-top) + ${offset}px)`,\n });\n }, []);\n\n const isMobile = breakpoint.isMobile;\n const hasSideBar =\n !contentOnly &&\n (navVariant === 'left' || (navVariant === 'top' && isMobile)) &&\n (!!navigationMainItems?.length || !!sideTop?.length);\n const hasTopBar = !contentOnly;\n\n useEffect(() => {\n if (view.isAnvil1) {\n const bodyClassName = 'of-hidden-i';\n document.body.classList.add(bodyClassName);\n return () => document.body.classList.remove(bodyClassName);\n }\n }, [view.isAnvil1]);\n\n const onBurgerClick = useCallback((e: MouseEvent) => {\n setMobileDrawerOpened(true);\n e.stopPropagation();\n }, []);\n\n const onBarExpandChange = useCallback(\n (expanded: boolean) => {\n if (isMobile) {\n setMobileDrawerOpened(false);\n } else {\n onStateChange?.({ navCollapsed: !expanded });\n }\n },\n [onStateChange, isMobile]\n );\n const onSubmenuExpandChange = useCallback(\n (id: string, expanded: boolean) => {\n onStateChange?.({\n navCollapsed: state?.navCollapsed ?? false,\n submenuExpanded: expanded ? id : undefined,\n });\n },\n [state, onStateChange]\n );\n const sidebarNavItems = useMemo(() => {\n if (!hasSideBar) {\n return undefined;\n }\n\n if (navVariant === 'left') {\n return navigationMainItems;\n }\n\n return [...(navigationMainItems ?? []), ...(navigationOverflowItems ?? [])];\n }, [hasSideBar, navigationMainItems, navigationOverflowItems, navVariant]);\n\n const hasMenuNotifications = useMemo(() => {\n try {\n return (\n sidebarNavItems?.some(item => {\n if (item.counter || item.tag?.value) {\n return true;\n } else if (item.submenu) {\n return item.submenu.groups.some(group =>\n group.links.some(link => !!link.counter || !!link.tag?.value)\n );\n }\n return false;\n }) ?? false\n );\n } catch {\n return false;\n }\n }, [sidebarNavItems]);\n\n const limitContentWidth = useMemo(() => {\n if (view.isAnvil2 || !minContentWidth) {\n return undefined;\n }\n\n if (breakpoint.width < minContentWidth) {\n return minContentWidth;\n }\n }, [view, minContentWidth, breakpoint.width]);\n\n const contentStyles = useMemo(() => {\n if (view.isAnvil2) {\n return offsetTopStyles;\n }\n\n if (view.isLegacy) {\n return {\n ...(limitContentWidth\n ? { display: 'flex', flexDirection: 'column', minHeight: '100vh' }\n : {}),\n ...offsetTopStyles,\n };\n }\n }, [view, offsetTopStyles, limitContentWidth]);\n\n const layoutClass = view.isLegacy\n ? Styles.layoutLegacy\n : view.isAnvil1\n ? Styles.layoutAnvil1\n : Styles.layoutAnvil2;\n\n return (\n <LayoutContext.Provider value={context}>\n <LayoutPlacementContext.Provider value=\"unset\">\n <div\n id={id}\n className={classNames(\n Styles.layout,\n isMobile ? Styles.layoutMobile : Styles.layoutDesktop,\n hasTopBar &&\n (navVariant === 'left' || !top\n ? Styles.layoutTopLight\n : Styles.layoutTopNav),\n {\n [Styles.layoutNavSlim]: !isMobile && hasSideBar && state?.navCollapsed,\n [Styles.layoutNavWide]: !isMobile && hasSideBar && !state?.navCollapsed,\n },\n layoutClass\n )}\n style={contentStyles}\n >\n {view.isSequent && <div className={Styles.topPlaceholder} />}\n {hasTopBar &&\n (navVariant === 'left' ? (\n <LayoutHeader\n className={Styles.top}\n variant=\"light\"\n logo={logo}\n profile={isMobile ? undefined : profile}\n center={top}\n rightText={isMobile ? undefined : extraText}\n right={\n <Fragment>\n {extraLinksTop}\n {!isMobile && extraLinks}\n </Fragment>\n }\n isMobile={isMobile}\n hasNotifications={hasNotifications || hasMenuNotifications}\n onBurgerClick={onBurgerClick}\n />\n ) : (\n <LayoutHeaderDark\n className={Styles.top}\n logo={logo}\n profile={isMobile ? undefined : profile}\n center={top}\n rightText={isMobile ? undefined : extraText}\n right={\n <Fragment>\n {extraLinksTop}\n {!isMobile && extraLinks}\n </Fragment>\n }\n isMobile={isMobile}\n hasNotifications={hasNotifications || hasMenuNotifications}\n onBurgerClick={onBurgerClick}\n navigationMainItems={navigationMainItems}\n navigationOverflowItems={navigationOverflowItems}\n />\n ))}\n\n {hasSideBar && (\n <NotificationsContextProvider>\n <LayoutSidebar\n className={Styles.side}\n mobile={breakpoint.isMobile}\n barExpanded={!state?.navCollapsed}\n onBarExpandChange={onBarExpandChange}\n submenuExpanded={state?.submenuExpanded}\n onSubmenuExpandChange={onSubmenuExpandChange}\n drawerOpened={mobileDrawerOpened}\n onDrawerOpenChange={setMobileDrawerOpened}\n top={sideTop}\n mainItems={sidebarNavItems}\n navigationComponent={context.NavigationComponent}\n bottom={\n isMobile ? (\n <Fragment>\n {profile}\n {extraLinks}\n {!!extraText && (\n <InternalSideNavigationTrigger\n id=\"--extra-text\"\n title={extraText}\n submenuExpanded={undefined}\n tag={undefined}\n icon={undefined}\n iconActive={undefined}\n />\n )}\n </Fragment>\n ) : undefined\n }\n />\n </NotificationsContextProvider>\n )}\n\n {view.isSequent && (\n <TitanLayoutHeaderObserved heightChange={updateIndicatorsHeight}>\n {header}\n </TitanLayoutHeaderObserved>\n )}\n {view.isAnvil1 ? (\n <LayoutContentAnvil1 header={header} minWidth={limitContentWidth}>\n {children}\n </LayoutContentAnvil1>\n ) : view.isLegacy ? (\n <LayoutContentLegacy minWidth={limitContentWidth}>\n {children}\n </LayoutContentLegacy>\n ) : (\n children\n )}\n </div>\n </LayoutPlacementContext.Provider>\n </LayoutContext.Provider>\n );\n};\n\nconst TitanLayoutHeaderObserved: FC<{\n children: ReactNode;\n heightChange?(value: number): void;\n}> = ({ children, heightChange }) => {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (ref.current) {\n const updatePosition = () => {\n if (ref.current && heightChange) {\n const pos = ref.current.getBoundingClientRect();\n heightChange(pos.height);\n }\n };\n\n const observer = new ResizeObserver(updatePosition);\n observer.observe(ref.current);\n\n updatePosition();\n return () => observer.disconnect();\n }\n }, [heightChange]);\n\n useEffect(() => {\n return () => {\n heightChange?.(0);\n };\n }, [heightChange]);\n return (\n <div ref={ref} className={Styles.contentHeader} data-cy=\"layout-content-header\">\n {children}\n </div>\n );\n};\nconst TitanLayoutHeader: FC<{ children: ReactNode }> = ({ children }) => {\n return (\n <div className={Styles.contentHeader} data-cy=\"layout-content-header\">\n {children}\n </div>\n );\n};\n\nconst LayoutContentAnvil1: FC<{\n children: ReactNode;\n header?: ReactNode;\n minWidth?: number;\n}> = ({ children, header, minWidth }) => {\n const innerContentStyles: CSSProperties = useMemo(\n () => ({\n ...(minWidth ? { minWidth: `${minWidth}px`, overflowX: 'auto' } : {}),\n }),\n [minWidth]\n );\n\n return (\n <Fragment>\n <TitanLayoutHeader>{header}</TitanLayoutHeader>\n <div\n className={classNames(Styles.content, { 'of-x-auto-i': !!minWidth })}\n data-cy=\"layout-content\"\n >\n <div\n className=\"position-relative d-f flex-grow-1 flex-basis-0 of-hidden\"\n style={innerContentStyles}\n >\n {children}\n </div>\n </div>\n </Fragment>\n );\n};\n\nconst LayoutContentLegacy: FC<{\n children: ReactNode;\n minWidth: number | undefined;\n}> = ({ children, minWidth }) => {\n const innerContentStyles: CSSProperties = useMemo(\n () => ({\n position: 'relative',\n minWidth: `${minWidth}px`,\n }),\n [minWidth]\n );\n\n return (\n <div className={minWidth ? 'of-x-auto flex-basis-0 flex-grow-1' : undefined}>\n <div style={minWidth ? innerContentStyles : undefined}>{children}</div>\n </div>\n );\n};\n\nexport const TitanLayout = Object.assign(TitanLayoutComponent, {\n Link: TitanLayoutSidebarLink,\n Trigger: TitanLayoutSidebarTrigger,\n});\n"],"names":["classNames","Fragment","useCallback","useEffect","useMemo","useRef","useState","DefaultNavLinkComponent","useTitanBreakpoint","LayoutContext","LayoutPlacementContext","LayoutHeader","LayoutHeaderDark","LayoutSidebar","TitanLayoutSidebarLink","TitanLayoutSidebarTrigger","InternalSideNavigationTrigger","useNotificationsState","Styles","defaultSidebarContext","styles","popoverContent","useAppearance","appearance","isLegacy","isAnvil1","isAnvil2","isSequent","TitanLayoutComponent","navVariant","id","children","contentOnly","navigationComponent","header","top","profile","state","logo","onStateChange","navigationMainItems","navigationOverflowItems","extraLinks","extraLinksTop","extraText","minContentWidth","sideTop","breakpoint","context","NavigationComponent","isTitanLayout","sidebar","view","mobileDrawerOpened","setMobileDrawerOpened","hasNotifications","NotificationsContextProvider","offsetTopStyles","setOffsetTopStyles","updateIndicatorsHeight","offset","isMobile","hasSideBar","length","hasTopBar","bodyClassName","document","body","classList","add","remove","onBurgerClick","e","stopPropagation","onBarExpandChange","expanded","navCollapsed","onSubmenuExpandChange","submenuExpanded","undefined","sidebarNavItems","hasMenuNotifications","some","item","counter","tag","value","submenu","groups","group","links","link","limitContentWidth","width","contentStyles","display","flexDirection","minHeight","layoutClass","layoutLegacy","layoutAnvil1","layoutAnvil2","Provider","div","className","layout","layoutMobile","layoutDesktop","layoutTopLight","layoutTopNav","layoutNavSlim","layoutNavWide","style","topPlaceholder","variant","center","rightText","right","side","mobile","barExpanded","drawerOpened","onDrawerOpenChange","mainItems","bottom","title","icon","iconActive","TitanLayoutHeaderObserved","heightChange","LayoutContentAnvil1","minWidth","LayoutContentLegacy","ref","current","updatePosition","pos","getBoundingClientRect","height","observer","ResizeObserver","observe","disconnect","contentHeader","data-cy","TitanLayoutHeader","innerContentStyles","overflowX","content","position","TitanLayout","Object","assign","Link","Trigger"],"mappings":";AAAA,OAAOA,gBAAgB,aAAa;AACpC,SAIIC,QAAQ,EAGRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,QAAQ;AAEf,SAASC,uBAAuB,QAA+B,iCAAiC;AAChG,SAASC,kBAAkB,QAAQ,6BAA6B;AAEhE,SACIC,aAAa,EACbC,sBAAsB,QAGnB,mBAAmB;AAC1B,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,sBAAsB,EAAEC,yBAAyB,QAAQ,yBAAyB;AAC3F,SAASC,6BAA6B,QAAQ,kCAAkC;AAChF,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,YAA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args: LayoutContentArgs) => import("
|
|
|
22
22
|
export declare const TitanLayoutAnvil1: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
export declare const TitanLayoutAnvil1TopNav: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
export declare const TitanLayoutAnvil1Top: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const TitanLayoutAnvil1TopOverflow: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export declare const TitanLayoutAnvil2: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
26
27
|
export declare const TitanLayoutAnvil2TopNav: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
export declare const TitanLayoutAnvil2Top: (args: LayoutContentArgs) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"titan-layout.stories.d.ts","sourceRoot":"","sources":["../../../src/components/titan-layout/titan-layout.stories.tsx"],"names":[],"mappings":"AAsBA,UAAU,iBAAiB;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;;;;;;UAgBQ,iBAAiB;;AAd1B,wBAeE;AA6QF,eAAO,MAAM,iBAAiB,GAAI,MAAM,iBAAiB,4CASxD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,iBAAiB,4CAS9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,iBAAiB,4CAS3D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,iBAAiB,4CAMxD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,iBAAiB,4CAM9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"titan-layout.stories.d.ts","sourceRoot":"","sources":["../../../src/components/titan-layout/titan-layout.stories.tsx"],"names":[],"mappings":"AAsBA,UAAU,iBAAiB;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;;;;;;UAgBQ,iBAAiB;;AAd1B,wBAeE;AA6QF,eAAO,MAAM,iBAAiB,GAAI,MAAM,iBAAiB,4CASxD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,iBAAiB,4CAS9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,iBAAiB,4CAS3D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,iBAAiB,4CAMxD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,iBAAiB,4CAM9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,iBAAiB,4CAY3D,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,MAAM,iBAAiB,4CAMnE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,iBAAiB,4CAQxD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,iBAAiB,4CAQ9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,iBAAiB,4CAQ3D,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TooltipProps } from '@servicetitan/anvil2';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
|
-
export declare const withTooltip: (element: ReactElement, tooltip: string | undefined, props
|
|
3
|
+
export declare const withTooltip: (element: ReactElement, tooltip: string | undefined, props?: {
|
|
4
4
|
placement?: TooltipProps["placement"];
|
|
5
5
|
key?: string;
|
|
6
6
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/titan-layout/with-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,eAAO,MAAM,WAAW,GACpB,SAAS,YAAY,EACrB,SAAS,MAAM,GAAG,SAAS,EAC3B,
|
|
1
|
+
{"version":3,"file":"with-tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/titan-layout/with-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,eAAO,MAAM,WAAW,GACpB,SAAS,YAAY,EACrB,SAAS,MAAM,GAAG,SAAS,EAC3B,QAAQ;IACJ,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB,4CASA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/titan-layout/with-tooltip.tsx"],"sourcesContent":["import { Tooltip, TooltipProps } from '@servicetitan/anvil2';\nimport { ReactElement } from 'react';\n\nexport const withTooltip = (\n element: ReactElement,\n tooltip: string | undefined,\n props
|
|
1
|
+
{"version":3,"sources":["../../../src/components/titan-layout/with-tooltip.tsx"],"sourcesContent":["import { Tooltip, TooltipProps } from '@servicetitan/anvil2';\nimport { ReactElement } from 'react';\n\nexport const withTooltip = (\n element: ReactElement,\n tooltip: string | undefined,\n props?: {\n placement?: TooltipProps['placement'];\n key?: string;\n }\n) =>\n tooltip ? (\n <Tooltip placement=\"bottom\" {...props}>\n <Tooltip.Content>{tooltip}</Tooltip.Content>\n <Tooltip.Trigger>{element}</Tooltip.Trigger>\n </Tooltip>\n ) : (\n element\n );\n"],"names":["Tooltip","withTooltip","element","tooltip","props","placement","Content","Trigger"],"mappings":";AAAA,SAASA,OAAO,QAAsB,uBAAuB;AAG7D,OAAO,MAAMC,cAAc,CACvBC,SACAC,SACAC,QAKAD,wBACI,MAACH;QAAQK,WAAU;QAAU,GAAGD,KAAK;;0BACjC,KAACJ,QAAQM,OAAO;0BAAEH;;0BAClB,KAACH,QAAQO,OAAO;0BAAEL;;;SAGtBA,QACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/navigation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
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": "e2203627fce8344ea7b26536a80d70bca4065620"
|
|
46
46
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ButtonCompound, Icon, Menu } from '@servicetitan/anvil2';
|
|
1
|
+
import { ButtonCompound, Icon, Menu, MenuProps } from '@servicetitan/anvil2';
|
|
2
2
|
import SvgMoreVert from '@servicetitan/anvil2/assets/icons/material/round/more_vert.svg';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { FC, useCallback, useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { NavigationItemData } from '../../utils/navigation';
|
|
6
|
+
import { NavigationComponentProps } from './interface-internal';
|
|
7
|
+
import { useTitanLayoutContext } from './layout-context';
|
|
6
8
|
import { LayoutHeader, LayoutHeaderProps } from './layout-header';
|
|
7
|
-
import {
|
|
9
|
+
import { InternalLayoutHeaderNavigationLink } from './layout-header-links-internal';
|
|
8
10
|
import * as Styles from './layout-header.module.less';
|
|
9
11
|
import { withTooltip } from './with-tooltip';
|
|
10
12
|
|
|
@@ -107,6 +109,7 @@ const LayoutHeaderNav: FC<LayoutHeaderNavProps> = ({ className, mainItems, overf
|
|
|
107
109
|
const navigationRef = useRef<HTMLDivElement>(null);
|
|
108
110
|
const forceUpdate = useForceUpdate();
|
|
109
111
|
const [minimized, setMinimized] = useState(MinimizedState.Calculating);
|
|
112
|
+
const { NavigationComponent } = useTitanLayoutContext();
|
|
110
113
|
|
|
111
114
|
useEffect(() => {
|
|
112
115
|
const handleResize = () => {
|
|
@@ -120,7 +123,8 @@ const LayoutHeaderNav: FC<LayoutHeaderNavProps> = ({ className, mainItems, overf
|
|
|
120
123
|
|
|
121
124
|
const updateIsMinimized = () => {
|
|
122
125
|
if (containerRef.current && navigationRef.current) {
|
|
123
|
-
|
|
126
|
+
const widthGap = 16 + (overflowItems?.length ? 32 : 0);
|
|
127
|
+
if (navigationRef.current.clientWidth + widthGap > containerRef.current.clientWidth) {
|
|
124
128
|
setMinimized(MinimizedState.Minimized);
|
|
125
129
|
} else if (minimized === MinimizedState.Calculating) {
|
|
126
130
|
setMinimized(MinimizedState.Full);
|
|
@@ -150,37 +154,55 @@ const LayoutHeaderNav: FC<LayoutHeaderNavProps> = ({ className, mainItems, overf
|
|
|
150
154
|
<div ref={navigationRef} className={classNames(Styles.headerNavigation)}>
|
|
151
155
|
{mainItems?.map(item =>
|
|
152
156
|
withTooltip(
|
|
153
|
-
<
|
|
157
|
+
<InternalLayoutHeaderNavigationLink
|
|
154
158
|
{...item}
|
|
155
159
|
label={isMinimized ? undefined : item.title}
|
|
156
160
|
key={item.id}
|
|
161
|
+
navigationComponent={NavigationComponent}
|
|
157
162
|
/>,
|
|
158
163
|
isMinimized ? item.title : undefined,
|
|
159
164
|
{ key: item.id }
|
|
160
165
|
)
|
|
161
166
|
)}
|
|
162
167
|
</div>
|
|
163
|
-
{!!overflowItems?.length &&
|
|
168
|
+
{!!overflowItems?.length && (
|
|
169
|
+
<LayoutHeaderNavOverflow
|
|
170
|
+
items={overflowItems}
|
|
171
|
+
navigationComponent={NavigationComponent}
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
164
174
|
</div>
|
|
165
175
|
);
|
|
166
176
|
};
|
|
167
177
|
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
178
|
+
const LayoutHeaderNavOverflowTrigger: MenuProps['trigger'] = props => (
|
|
179
|
+
<ButtonCompound
|
|
180
|
+
{...props}
|
|
181
|
+
className={Styles.headerNavigationOverflowTrigger}
|
|
182
|
+
data-cy="navigation-overflow-trigger"
|
|
183
|
+
>
|
|
184
|
+
<Icon svg={SvgMoreVert} size="medium" />
|
|
185
|
+
</ButtonCompound>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const LayoutHeaderNavOverflow: FC<
|
|
189
|
+
{
|
|
190
|
+
items: NavigationItemData[];
|
|
191
|
+
} & NavigationComponentProps
|
|
192
|
+
> = ({ items, navigationComponent }) => {
|
|
171
193
|
return (
|
|
172
|
-
<Menu
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
194
|
+
<Menu trigger={LayoutHeaderNavOverflowTrigger} placement="bottom-end">
|
|
195
|
+
<div data-cy="navigation-overflow-content" className={Styles.headerNavigationOverflow}>
|
|
196
|
+
{items.map(item => (
|
|
197
|
+
<InternalLayoutHeaderNavigationLink
|
|
198
|
+
{...item}
|
|
199
|
+
label={item.title}
|
|
200
|
+
key={item.id}
|
|
201
|
+
navigationComponent={navigationComponent}
|
|
202
|
+
isOverflow
|
|
203
|
+
/>
|
|
204
|
+
))}
|
|
205
|
+
</div>
|
|
184
206
|
</Menu>
|
|
185
207
|
);
|
|
186
208
|
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Icon, IconProps } from '@servicetitan/anvil2';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { FC, Fragment } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
HeaderNavigationLinkProps,
|
|
6
|
+
HeaderNavigationTriggerProps,
|
|
7
|
+
} from '../../utils/navigation-legacy';
|
|
8
|
+
import { getCounterTag } from '../../utils/side-nav';
|
|
9
|
+
import { CounterTag, CounterTagProps } from '../counter-tag';
|
|
10
|
+
// use v1 tooltips due to bug with v2 in monolith
|
|
11
|
+
import { NavigationComponentProps } from './interface-internal';
|
|
12
|
+
import * as Styles from './layout-header.module.less';
|
|
13
|
+
|
|
14
|
+
/** Content for navigation items */
|
|
15
|
+
const InternalHeaderNavigationItemContent: FC<{
|
|
16
|
+
tag?: CounterTagProps;
|
|
17
|
+
counterClassName?: string;
|
|
18
|
+
icon: IconProps['svg'] | undefined;
|
|
19
|
+
iconActive?: IconProps['svg'];
|
|
20
|
+
label?: string;
|
|
21
|
+
labelClassName?: string;
|
|
22
|
+
}> = ({ counterClassName, icon, iconActive, label, labelClassName, tag }) => {
|
|
23
|
+
return (
|
|
24
|
+
<Fragment>
|
|
25
|
+
{!!icon && <Icon svg={icon} className={Styles.navigationIcon} />}
|
|
26
|
+
{!!iconActive && (
|
|
27
|
+
<Icon
|
|
28
|
+
svg={iconActive}
|
|
29
|
+
className={classNames(Styles.navigationIcon, Styles.navigationIconActive)}
|
|
30
|
+
/>
|
|
31
|
+
)}
|
|
32
|
+
|
|
33
|
+
{!!label && (
|
|
34
|
+
<span
|
|
35
|
+
className={classNames(Styles.navigationItemLabel, labelClassName)}
|
|
36
|
+
data-cy="nav-item-label"
|
|
37
|
+
>
|
|
38
|
+
{label}
|
|
39
|
+
</span>
|
|
40
|
+
)}
|
|
41
|
+
|
|
42
|
+
{!!tag && (
|
|
43
|
+
<CounterTag
|
|
44
|
+
data={tag}
|
|
45
|
+
className={classNames(Styles.navigationItemCounter, counterClassName)}
|
|
46
|
+
longClassName={Styles.navigationItemCounterLong}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
</Fragment>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Navigation extra item with link */
|
|
54
|
+
export const InternalLayoutHeaderNavigationLink: FC<
|
|
55
|
+
HeaderNavigationLinkProps & NavigationComponentProps & { isOverflow?: boolean }
|
|
56
|
+
> = ({
|
|
57
|
+
id,
|
|
58
|
+
to,
|
|
59
|
+
hint,
|
|
60
|
+
tooltip,
|
|
61
|
+
className,
|
|
62
|
+
counter,
|
|
63
|
+
icon,
|
|
64
|
+
iconActive,
|
|
65
|
+
iconClassName,
|
|
66
|
+
iconName,
|
|
67
|
+
iconComponent,
|
|
68
|
+
isActive,
|
|
69
|
+
isOverflow,
|
|
70
|
+
label,
|
|
71
|
+
labelClassName,
|
|
72
|
+
tag,
|
|
73
|
+
target,
|
|
74
|
+
title,
|
|
75
|
+
navigationComponent: NavigationComponent,
|
|
76
|
+
...rest
|
|
77
|
+
}) => {
|
|
78
|
+
return (
|
|
79
|
+
<NavigationComponent
|
|
80
|
+
data-cy={`navigation-item-${id}`}
|
|
81
|
+
data-pendo={`navigation-item-${id}`}
|
|
82
|
+
{...rest}
|
|
83
|
+
key={id}
|
|
84
|
+
to={to}
|
|
85
|
+
className={classNames(
|
|
86
|
+
isOverflow ? Styles.navigationLinkOverflow : Styles.navigationLink,
|
|
87
|
+
className,
|
|
88
|
+
{
|
|
89
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
90
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
91
|
+
}
|
|
92
|
+
)}
|
|
93
|
+
isActive={typeof isActive === 'function' ? isActive : undefined}
|
|
94
|
+
activeClassName={Styles.navigationItemActive}
|
|
95
|
+
target={target}
|
|
96
|
+
>
|
|
97
|
+
<InternalHeaderNavigationItemContent
|
|
98
|
+
tag={getCounterTag(counter, tag)}
|
|
99
|
+
icon={icon}
|
|
100
|
+
iconActive={iconActive}
|
|
101
|
+
label={label}
|
|
102
|
+
labelClassName={labelClassName}
|
|
103
|
+
/>
|
|
104
|
+
</NavigationComponent>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** Navigation extra item with icon button */
|
|
109
|
+
export const InternalLayoutHeaderNavigationTrigger: FC<HeaderNavigationTriggerProps> = ({
|
|
110
|
+
id,
|
|
111
|
+
className,
|
|
112
|
+
counter,
|
|
113
|
+
icon,
|
|
114
|
+
iconActive,
|
|
115
|
+
iconName,
|
|
116
|
+
isActive,
|
|
117
|
+
hint,
|
|
118
|
+
label,
|
|
119
|
+
labelClassName,
|
|
120
|
+
tag,
|
|
121
|
+
tooltip,
|
|
122
|
+
title,
|
|
123
|
+
titleClassName,
|
|
124
|
+
...rest
|
|
125
|
+
}) => {
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
data-cy={`navigation-trigger-${id}`}
|
|
129
|
+
data-pendo={`navigation-trigger-${id}`}
|
|
130
|
+
{...rest}
|
|
131
|
+
title={hint}
|
|
132
|
+
className={classNames(
|
|
133
|
+
Styles.navigationLink,
|
|
134
|
+
{
|
|
135
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
136
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
137
|
+
},
|
|
138
|
+
'cursor-pointer',
|
|
139
|
+
className
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
142
|
+
<InternalHeaderNavigationItemContent
|
|
143
|
+
tag={getCounterTag(counter, tag)}
|
|
144
|
+
icon={icon}
|
|
145
|
+
iconActive={iconActive}
|
|
146
|
+
label={label}
|
|
147
|
+
labelClassName={labelClassName}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
@@ -1,145 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { FC, Fragment } from 'react';
|
|
1
|
+
import { FC } from 'react';
|
|
4
2
|
import {
|
|
5
3
|
HeaderNavigationLinkProps,
|
|
6
4
|
HeaderNavigationTriggerProps,
|
|
7
5
|
} from '../../utils/navigation-legacy';
|
|
8
|
-
import { getCounterTag } from '../../utils/side-nav';
|
|
9
|
-
import { CounterTag, CounterTagProps } from '../counter-tag';
|
|
10
|
-
// use v1 tooltips due to bug with v2 in monolith
|
|
11
|
-
import { withTooltip } from '../header-navigation/with-tooltip';
|
|
12
6
|
import { useTitanLayoutContext } from './layout-context';
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
counterClassName?: string;
|
|
19
|
-
icon: IconProps['svg'] | undefined;
|
|
20
|
-
iconActive?: IconProps['svg'];
|
|
21
|
-
label?: string;
|
|
22
|
-
labelClassName?: string;
|
|
23
|
-
}> = ({ counterClassName, icon, iconActive, label, labelClassName, tag }) => {
|
|
24
|
-
return (
|
|
25
|
-
<Fragment>
|
|
26
|
-
{!!icon && <Icon svg={icon} className={Styles.navigationIcon} />}
|
|
27
|
-
{!!iconActive && (
|
|
28
|
-
<Icon
|
|
29
|
-
svg={iconActive}
|
|
30
|
-
className={classNames(Styles.navigationIcon, Styles.navigationIconActive)}
|
|
31
|
-
/>
|
|
32
|
-
)}
|
|
33
|
-
|
|
34
|
-
{!!label && (
|
|
35
|
-
<span className={classNames(Styles.navigationItemLabel, labelClassName)}>
|
|
36
|
-
{label}
|
|
37
|
-
</span>
|
|
38
|
-
)}
|
|
39
|
-
|
|
40
|
-
{!!tag && (
|
|
41
|
-
<CounterTag
|
|
42
|
-
data={tag}
|
|
43
|
-
className={classNames(Styles.navigationItemCounter, counterClassName)}
|
|
44
|
-
longClassName={Styles.navigationItemCounterLong}
|
|
45
|
-
/>
|
|
46
|
-
)}
|
|
47
|
-
</Fragment>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
7
|
+
import {
|
|
8
|
+
InternalLayoutHeaderNavigationLink,
|
|
9
|
+
InternalLayoutHeaderNavigationTrigger,
|
|
10
|
+
} from './layout-header-links-internal';
|
|
11
|
+
import { withTooltip } from './with-tooltip';
|
|
50
12
|
|
|
51
13
|
/** Navigation extra item with link */
|
|
52
|
-
export const LayoutHeaderNavigationLink: FC<HeaderNavigationLinkProps> = ({
|
|
53
|
-
id,
|
|
54
|
-
to,
|
|
55
|
-
hint,
|
|
56
|
-
tooltip,
|
|
57
|
-
className,
|
|
58
|
-
counter,
|
|
59
|
-
icon,
|
|
60
|
-
iconActive,
|
|
61
|
-
iconClassName,
|
|
62
|
-
iconComponent,
|
|
63
|
-
iconName,
|
|
64
|
-
isActive,
|
|
65
|
-
label,
|
|
66
|
-
labelClassName,
|
|
67
|
-
tag,
|
|
68
|
-
target,
|
|
69
|
-
title,
|
|
70
|
-
...rest
|
|
71
|
-
}) => {
|
|
14
|
+
export const LayoutHeaderNavigationLink: FC<HeaderNavigationLinkProps> = ({ tooltip, ...rest }) => {
|
|
72
15
|
const { NavigationComponent } = useTitanLayoutContext();
|
|
73
16
|
|
|
74
17
|
return withTooltip(
|
|
75
|
-
<NavigationComponent
|
|
76
|
-
data-cy={`navigation-link-${id}`}
|
|
77
|
-
data-pendo={`navigation-link-${id}`}
|
|
78
|
-
{...rest}
|
|
79
|
-
key={id}
|
|
80
|
-
to={to}
|
|
81
|
-
className={classNames(Styles.navigationLink, className, {
|
|
82
|
-
[Styles.navigationItemActive]: isActive === true,
|
|
83
|
-
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
84
|
-
})}
|
|
85
|
-
isActive={typeof isActive === 'function' ? isActive : undefined}
|
|
86
|
-
activeClassName={Styles.navigationItemActive}
|
|
87
|
-
target={target}
|
|
88
|
-
>
|
|
89
|
-
<HeaderNavigationItemContent
|
|
90
|
-
tag={getCounterTag(counter, tag)}
|
|
91
|
-
icon={icon}
|
|
92
|
-
iconActive={iconActive}
|
|
93
|
-
label={label}
|
|
94
|
-
labelClassName={labelClassName}
|
|
95
|
-
/>
|
|
96
|
-
</NavigationComponent>,
|
|
18
|
+
<InternalLayoutHeaderNavigationLink {...rest} navigationComponent={NavigationComponent} />,
|
|
97
19
|
tooltip
|
|
98
20
|
);
|
|
99
21
|
};
|
|
100
22
|
|
|
101
23
|
/** Navigation extra item with icon button */
|
|
102
24
|
export const LayoutHeaderNavigationTrigger: FC<HeaderNavigationTriggerProps> = ({
|
|
103
|
-
id,
|
|
104
|
-
className,
|
|
105
|
-
counter,
|
|
106
|
-
icon,
|
|
107
|
-
iconActive,
|
|
108
|
-
iconName,
|
|
109
|
-
isActive,
|
|
110
|
-
hint,
|
|
111
|
-
label,
|
|
112
|
-
labelClassName,
|
|
113
|
-
tag,
|
|
114
25
|
tooltip,
|
|
115
|
-
title,
|
|
116
|
-
titleClassName,
|
|
117
26
|
...rest
|
|
118
27
|
}) => {
|
|
119
|
-
return withTooltip(
|
|
120
|
-
<div
|
|
121
|
-
data-cy={`navigation-trigger-${id}`}
|
|
122
|
-
data-pendo={`navigation-trigger-${id}`}
|
|
123
|
-
{...rest}
|
|
124
|
-
title={hint}
|
|
125
|
-
className={classNames(
|
|
126
|
-
Styles.navigationLink,
|
|
127
|
-
{
|
|
128
|
-
[Styles.navigationItemActive]: isActive === true,
|
|
129
|
-
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
130
|
-
},
|
|
131
|
-
'cursor-pointer',
|
|
132
|
-
className
|
|
133
|
-
)}
|
|
134
|
-
>
|
|
135
|
-
<HeaderNavigationItemContent
|
|
136
|
-
tag={getCounterTag(counter, tag)}
|
|
137
|
-
icon={icon}
|
|
138
|
-
iconActive={iconActive}
|
|
139
|
-
label={label}
|
|
140
|
-
labelClassName={labelClassName}
|
|
141
|
-
/>
|
|
142
|
-
</div>,
|
|
143
|
-
tooltip
|
|
144
|
-
);
|
|
28
|
+
return withTooltip(<InternalLayoutHeaderNavigationTrigger {...rest} />, tooltip);
|
|
145
29
|
};
|