import { type CSSProperties, type MouseEvent, type ReactElement, type ReactNode, type RefObject } from "react"; import { type IDashboardLayout, type IDashboardLayoutSizeByScreenSize, type IDashboardWidget, type ScreenSize } from "@gooddata/sdk-model"; import { type IDashboardLayoutItemFacade, type IDashboardLayoutSectionFacade } from "../../../_staging/dashboard/flexibleLayout/facade/interfaces.js"; import { type IDashboardFocusObject } from "../../../model/types/commonTypes.js"; import { type ILayoutItemPath, type RenderMode } from "../../../types.js"; import { type CommonExportDataAttributes, type HeaderExportData } from "../../export/types.js"; /** * Default props provided to {@link IDashboardLayoutSectionKeyGetter}. * * @alpha */ export type IDashboardLayoutSectionKeyGetterProps = { /** * Dashboard layout section. */ section: IDashboardLayoutSectionFacade; /** * Current screen type with respect to the set breakpoints. */ screen: ScreenSize; }; /** * Dashboard layout section key getter. * This callback is used to determine a unique key of the section. * By this callback, you can avoid unnecessary re-renders of the section components, * the returned unique key is passed to the React "key" property, when rendering rows. * By default, dashboard layout will use sectionIndex as a unique key. * * @alpha */ export type IDashboardLayoutSectionKeyGetter = (props: IDashboardLayoutSectionKeyGetterProps) => string; /** * Default props provided to {@link IDashboardLayoutSectionRenderer}. * * @alpha */ export interface IDashboardLayoutSectionRenderProps { /** * Dashboard layout section. */ section: IDashboardLayoutSectionFacade; /** * The size of layout item in which the section is nested. Undefined, when section is in the root layout. */ parentLayoutItemSize?: IDashboardLayoutSizeByScreenSize; /** * The path to the layout item in which the section is nested. Undefined if the layout is a root layout. */ parentLayoutPath: ILayoutItemPath | undefined; /** * Default renderer of the section - can be used as a fallback for custom sectionRenderer. */ DefaultSectionRenderer: IDashboardLayoutSectionRenderer; /** * Columns rendered by columnRenderer. */ children: ReactNode; /** * Dashboard render mode */ renderMode: RenderMode; /** * Additional section css class name. */ className?: string; /** * Is hidden section? Use this to hide the section without remounting it. */ isHidden?: boolean; /** * Is section with borders. Default true. */ showBorders?: boolean; /** * Data for section export in export mode. */ exportData?: CommonExportDataAttributes; /** * Export styles for export mode. */ exportStyles?: CSSProperties; } /** * Dashboard layout section renderer. * Represents a component for rendering the section. * * @alpha */ export type IDashboardLayoutSectionRenderer = (renderProps: IDashboardLayoutSectionRenderProps & TCustomProps) => ReactElement; /** * Default props provided to {@link IDashboardLayoutSectionHeaderRenderer}. * * @alpha */ export interface IDashboardLayoutSectionHeaderRenderProps { /** * Dashboard layout section. */ section: IDashboardLayoutSectionFacade; /** * The size of layout item in which the section header is nested. Undefined, when section, to which * this header belongs to, is in the root layout. */ parentLayoutItemSize?: IDashboardLayoutSizeByScreenSize; /** * The path to the layout item in which the section is nested. Undefined if the layout is a root layout. */ parentLayoutPath: ILayoutItemPath | undefined; /** * Default renderer of the section header - can be used as a fallback for custom sectionHeaderRenderer. */ DefaultSectionHeaderRenderer: IDashboardLayoutSectionHeaderRenderer; /** * Data for header export in export mode. */ exportData?: HeaderExportData; } /** * Dashboard layout section header renderer. * Represents a component for rendering the section header. * * @alpha */ export type IDashboardLayoutSectionHeaderRenderer = (renderProps: IDashboardLayoutSectionHeaderRenderProps & TCustomProps) => ReactElement | null; /** * Default props provided to {@link IDashboardLayoutItemKeyGetter} * * @alpha */ export interface IDashboardLayoutItemKeyGetterProps { /** * Dashboard layout item. */ item: IDashboardLayoutItemFacade; /** * Current screen type with respect to the set breakpoints. */ screen: ScreenSize; } /** * Dashboard layout item key getter. * This callback is used to determine a unique key of the item. * By this callback, you can avoid unnecessary re-renders of the item components, * the returned unique key is passed to the React "key" property, when rendering columns. * By default, dashboard layout will use columnIndex as a unique key. * * @alpha */ export type IDashboardLayoutItemKeyGetter = (props: IDashboardLayoutItemKeyGetterProps) => string; /** * Default props provided to {@link IDashboardLayoutItemRenderer} * * @alpha */ export interface IDashboardLayoutItemRenderProps { /** * Dashboard layout item. */ item: IDashboardLayoutItemFacade; /** * Default renderer of the item - can be used as a fallback for custom columnRenderer. */ DefaultItemRenderer: IDashboardLayoutItemRenderer; /** * Additional item css class name. */ className?: string; /** * Minimum height of the item. */ minHeight?: number; /** * Is hidden item? Use this to hide the item without remounting it. */ isHidden?: boolean; /** * Widget rendered by widgetRenderer. */ children: ReactNode; /** * Zero-based index of the row in which the item is rendered, */ rowIndex: number; /** * Dashboard render mode */ renderMode?: RenderMode; } /** * Dashboard layout item renderer. * Represents a component for rendering the item. * * @alpha */ export type IDashboardLayoutItemRenderer = (renderProps: IDashboardLayoutItemRenderProps & TCustomProps) => ReactElement; /** * Default props provided to {@link IDashboardLayoutItemRenderer} * * @alpha */ export interface IDashboardLayoutWidgetRenderProps { /** * Dashboard layout item. */ item: IDashboardLayoutItemFacade; /** * React ref to content element. */ contentRef?: RefObject; /** * Additional css class name of the content. */ className?: string; /** * Content to render - widget, insight, or custom content. */ children?: ReactNode; /** * Height of the content. */ height?: CSSProperties["height"]; /** * Minimum height of the content. */ minHeight?: CSSProperties["minHeight"]; /** * Allow vertical overflow? * (This basically sets overflowX to hidden and overflowY to auto) */ allowOverflow?: boolean; /** * Was item size updated by layout sizing strategy? */ isResizedByLayoutSizingStrategy?: boolean; /** * Get dimensions of layout container element */ getLayoutDimensions: () => DOMRect; /** * Default widget renderer - can be used as a fallback for custom widgetRenderer. */ DefaultWidgetRenderer: IDashboardLayoutWidgetRenderer; /** * Zero-based index of the row in which the item is rendered, */ rowIndex: number; } /** * Dashboard layout content renderer. * Represents a component for rendering the item content. * * @alpha */ export type IDashboardLayoutWidgetRenderer = (renderProps: IDashboardLayoutWidgetRenderProps & TCustomProps) => ReactElement; /** * Default props provided to {@link IDashboardLayoutGridRowRenderer} * * @alpha */ export interface IDashboardLayoutGridRowRenderProps { /** * Items rendered in one row. */ children: ReactElement[]; /** * Dashboard layout section. */ section: IDashboardLayoutSectionFacade; /** * Layout items - keep in mind that these items are only items in the current grid row, not the entire section. */ items: IDashboardLayoutItemFacade[]; /** * Dashboard render mode */ renderMode: RenderMode; } /** * Dashboard layout grid row renderer. * Represents a component for rendering the real rendered row * with respect to the item sizing and the current screen size. * * @alpha */ export type IDashboardLayoutGridRowRenderer = (renderProps: IDashboardLayoutGridRowRenderProps & TCustomProps) => ReactElement; /** * Dashboard layout render props. * Represents a customizable interface for rendering the layout. * * @alpha */ export interface IDashboardLayoutRenderProps { /** * Dashboard layout definition to render. */ layout: IDashboardLayout; /** * Callback to determine a unique key of the section. * Check {@link IDashboardLayoutSectionKeyGetter} for more details. */ sectionKeyGetter?: IDashboardLayoutSectionKeyGetter; /** * Render props callback to customize section rendering. */ sectionRenderer?: IDashboardLayoutSectionRenderer; /** * Render props callback to customize section header rendering. */ sectionHeaderRenderer?: IDashboardLayoutSectionHeaderRenderer; /** * Render props callback to customize rendering of the real rendered rows * with respect to the items sizing and the current screen size. */ gridRowRenderer?: IDashboardLayoutGridRowRenderer; /** * Callback to determine a unique key of the item. * Check {@link IDashboardLayoutItemKeyGetter} for more details. */ itemKeyGetter?: IDashboardLayoutItemKeyGetter; /** * Render props callback to customize item rendering. */ itemRenderer?: IDashboardLayoutItemRenderer; /** * Render props callback to specify how to render the layout widget. */ widgetRenderer: IDashboardLayoutWidgetRenderer; /** * Additional css class name for the dashboard layout root element. */ className?: string; /** * Callback called on mouse leave event. */ onMouseLeave?: (e: MouseEvent) => void; /** * Dashboard render mode */ renderMode?: RenderMode; /** * Dashboard focus object. */ focusObject?: IDashboardFocusObject; /** * The size of layout item in which the layout is nested. Undefined, when the layout is the root layout. */ parentLayoutItemSize?: IDashboardLayoutSizeByScreenSize; /** * The path to the layout item in which the section is nested. Undefined if the layout is a root layout. */ parentLayoutPath: ILayoutItemPath | undefined; /** * Transformer for export layout */ exportTransformer?: (layout: IDashboardLayout, focusObject?: IDashboardFocusObject) => IDashboardLayout | undefined; } /** * Dashboard layout renderer. * Represents a component for rendering the layout. * * @alpha */ export type IDashboardLayoutRenderer = (renderProps: IDashboardLayoutRenderProps & TCustomProps) => ReactElement; //# sourceMappingURL=interfaces.d.ts.map