import { type CompanyAvatarProps, type GenericAvatarProps } from "../Avatar"; import type { ButtonProps, CustomButtonProps } from "../ButtonV1"; import { type MenuItemProps } from "../MenuV1"; import { type Select } from "../Select"; import { type NavigationTabProps } from './subcomponents/NavigationTabs'; /** * @param TitleBlockProps ### Accessing internal types of TitleBlockProps * If you want access to types like `PrimaryActionProps` (for example, in the scenario * where you want to create an object containing menu items to be passed in for the primary * menu button), you can use the shorthand: * ``` * const myMenu: TitleBlockProps["primaryAction"] = ... * ``` * This will ensure that `myMenu` has a type of `PrimaryActionProps`. */ export type TitleBlockProps = { children?: React.ReactNode; title: string; variant?: TitleBlockVariant; breadcrumb?: TitleBlockBreadcrumbType; avatar?: JSX.Element | TitleBlockAvatarProps; subtitle?: React.ReactNode; sectionTitle?: string; sectionTitleDescription?: string; renderSectionTitle?: (renderProps: SectionTitleRenderProps) => React.ReactNode; pageSwitcherSelect?: TitleBlockSelectProps; handleHamburgerClick?: (event: React.MouseEvent) => void; primaryAction?: PrimaryActionProps; defaultAction?: DefaultActionProps; secondaryActions?: SecondaryActionsProps; secondaryOverflowMenuItems?: TitleBlockMenuItemProps[]; navigationTabs?: NavigationTabs; collapseNavigationAreaWhenPossible?: boolean; textDirection?: TextDirection; surveyStatus?: SurveyStatus; id?: string; titleAutomationId?: string; breadcrumbAutomationId?: string; breadcrumbTextAutomationId?: string; avatarAutomationId?: string; subtitleAutomationId?: string; sectionTitleAutomationId?: string; sectionTitleDescriptionAutomationId?: string; autoHideMobileActionsMenu?: boolean; }; /** * ### PrimaryActionProps * * The primary action (the "main" button in the top right) can either be a Button, * or a Button that reveals a Menu (a menu button). * * For a button, pass in an object containing the same props you would normally use * for a Button component. * * For a menu button, pass in a `MenuGroup`: * ```typescript * { * label: string * menuItems: MenuItemProps[] * } * ``` * Using the `label`, the Title Block will render a Button with a chevron icon and your `menuItems` will appear * in the dropdown menu when you click it. (`MenuItemProps` is a type imported from the `Menu` component.) */ export type PrimaryActionProps = (TitleBlockMenuGroup & { badge?: TitleBlockBadgeProps; }) | ((TitleBlockButtonProps | TitleBlockCustomButtonProps) & { badge?: TitleBlockBadgeProps; }); /** * ### SecondaryActionsProps * * Secondary actions can only be buttons or button menus * (a button that reveals a dropdown menu). * * **IMPORTANT:** The visual order of these from left to right should always be: * ```text * buttons -> menu buttons * ``` * * For a button, pass in an object containing the same props you would normally use * for a Button component. * * For a menu button, pass in a `MenuGroup`: * * ```typescript * { * label: string * menuItems: MenuItemProps[] * } * ``` * (`MenuItemProps` is imported from the Menu component.) * */ export type SecondaryActionsProps = SecondaryActionItemProps[]; export type SecondaryActionItemProps = TitleBlockMenuGroup | (ButtonWithHrefNotOnClick | ButtonWithOnClickNotHref | TitleBlockCustomButtonProps); export type TitleBlockBadgeProps = { text: string; animateChange?: boolean; }; export type TitleBlockButtonProps = TitleBlockDistributiveOmit & { onClick?: (e: any) => void; }; export type TitleBlockCustomButtonProps = TitleBlockDistributiveOmit & { className?: string; component: (props: CustomButtonProps) => JSX.Element; }; export type TitleBlockMenuItemProps = MenuItemProps | TitleBlockCustomButtonProps; export type ButtonWithHrefNotOnClick = TitleBlockDistributiveOmit; export type ButtonWithOnClickNotHref = TitleBlockDistributiveOmit; export type TitleBlockMenuGroup = { label: string; menuItems: TitleBlockMenuItemProps[]; }; export type TitleBlockSelectProps = React.ComponentProps; export type TitleBlockDistributiveOmit = T extends any ? Omit : never; export type TitleBlockAvatarProps = Omit | Omit; export type DefaultActionProps = TitleBlockButtonProps | TitleBlockCustomButtonProps; export type SectionTitleRenderProps = Pick; export type TitleBlockVariant = 'light' | 'admin' | 'education'; export type NavigationTabs = React.ReactElement[]; export type TextDirection = 'ltr' | 'rtl'; export type SurveyStatus = { text: string; status: 'draft' | 'live' | 'scheduled' | 'closed' | 'sentimentPositive' | 'default'; }; export type TitleBlockBreadcrumbType = { text: string; path?: string; handleClick?: (event: React.MouseEvent) => void; /** * Custom render for the breadcrumb. Commonly used to replace the parent link with a router link component. * Props given to the breadcrumb component will be passed back, along with a decorated className and children. * It is up to you to reapply them to your custom component. */ render?: (props: CustomBreadcrumbProps) => JSX.Element; }; export type TitleBlockBreadcrumbProps = { breadcrumb: TitleBlockBreadcrumbType; automationId: string; textAutomationId: string; textDirection?: TextDirection; }; export type CustomBreadcrumbProps = TitleBlockBreadcrumbProps & { className: string; children: React.ReactNode; };