import { type ComponentProps, type ComponentType, type HTMLAttributes, type ReactNode, type RefCallback, type RefObject } from "react"; import { type EmptyObject } from "@gooddata/util"; import { type IDropdownButtonRenderProps } from "../../Dropdown/Dropdown.js"; import { type IAccessibilityConfigBase } from "../../typings/accessibility.js"; import { type SizeLarge, type SizeMedium, type SizeSmall } from "../@types/size.js"; import { type IUiMenuSeparatorItem } from "../UiMenu/types.js"; /** * @internal */ export type IUiTabAction = EmptyObject, TTabActionProps extends Record = EmptyObject> = { id: string; label: string; isDisabled?: boolean; isDestructive?: boolean; tooltip?: ReactNode; tooltipWidth?: number; onSelect?: (context: { tab: IUiTab; }) => void; /** * Whether to close the dropdown when the action is selected. * - "actions" - close actions menu when action is selected * - "all" - close actions menu and possibly all tabs list when action is selected * - false - do not close anything when action is selected * * @defaultValue "actions" */ closeOnSelect?: "actions" | "all" | false; iconRight?: ReactNode; iconLeft?: ReactNode; dataTestId?: string; } & TTabActionProps; /** * @internal */ export type IUiTab = EmptyObject, TTabActionProps extends Record = EmptyObject> = { id: string; label: string; /** * @defaultValue "default" */ variant?: "default" | "placeholder"; /** * Optional DOM id for the tab button. */ tabId?: string; /** * Optional id of the tabpanel controlled by this tab. */ panelId?: string; /** * When true, focusing the tab will select it. */ autoSelectOnFocus?: boolean; /** * Optional aria-label override for the tab button. * When provided, used instead of `label` for the `aria-label` attribute. */ ariaLabel?: string; actions?: Array | IUiMenuSeparatorItem>; } & TTabProps; /** * @internal */ export type IUiTabComponents = EmptyObject, TTabActionProps extends Record = EmptyObject> = { Container: ComponentType; Tab: ComponentType<{ tab: IUiTab; isSelected: boolean; onSelect: () => void; onDoubleClick?: () => void; /** * Whether this tab is the currently focused tab in keyboard navigation. * When true, the tab button and its actions button become tabbable (tabIndex=0). */ isFocused?: boolean; }>; TabValue: ComponentType<{ tab: IUiTab; isSelected: boolean; location: "tabs" | "allList"; }>; TabActions: ComponentType<{ tab: IUiTab; location: "tabs" | "allList"; isOpen: boolean; onToggleOpen: (desiredState?: boolean) => void; tabIndex?: number; id?: string; }>; TabActionsButton: ComponentType<{ tab: IUiTab; isOpen: boolean; onClick: () => void; location: "tabs" | "allList"; ariaAttributes?: IDropdownButtonRenderProps["ariaAttributes"]; tabIndex?: number; id?: string; }>; AllTabs: ComponentType; AllTabsButton: ComponentType<{ isOpen: boolean; onClick: () => void; ref?: RefObject; ariaAttributes?: IDropdownButtonRenderProps["ariaAttributes"]; }>; }; /** * @internal */ export type IUiTabComponentProps, TTabProps extends Record = EmptyObject, TTabActionProps extends Record = EmptyObject> = ComponentProps[TComponent]>; /** * @internal */ export type IUiTabActionEventContext = EmptyObject, TTabActionProps extends Record = EmptyObject> = { action: IUiTabAction; tab: IUiTab; location: "tabs" | "allList"; }; /** * @internal */ export type IUiTabContext = EmptyObject, TTabActionProps extends Record = EmptyObject> = Pick, "tabs" | "selectedTabId" | "onTabSelect" | "onTabDoubleClick" | "size" | "accessibilityConfig" | "maxLabelLength" | "disableBottomBorder"> & { isOverflowing: boolean; containerRef: RefCallback; onActionTriggered: (context: IUiTabActionEventContext) => void; useActionListener: (callback: (context: IUiTabActionEventContext) => void) => void; } & IUiTabComponents; /** * @internal */ export type IUiTabsProps = EmptyObject, TTabActionProps extends Record = EmptyObject> = { tabs: IUiTab[]; selectedTabId: string; onTabSelect: (tab: IUiTab) => void; onTabDoubleClick?: (tab: IUiTab) => void; size?: SizeSmall | SizeMedium | SizeLarge; maxLabelLength?: number; accessibilityConfig?: IUiTabsAccessibilityConfig; /** * When true, disables the gray bottom border line. * * @defaultValue false */ disableBottomBorder?: boolean; } & Partial>; /** * @internal */ export interface IUiTabsAccessibilityConfig extends IAccessibilityConfigBase { tabRole?: HTMLAttributes["role"]; } //# sourceMappingURL=types.d.ts.map