import { LayoutCommandProps, LayoutConfig, RootLayoutConfig, StudioLayoutButtonConfigProps, StudioLayoutComponentsConfigProps, StudioLayoutSidebarLeftConfigProps } from '../types'; import { PluginWithInit } from '../utils'; import { LayoutSidebarButtonsOptions as LayoutSidebarButtonsOptionsSchema } from './typesSchema'; export interface LayoutSidebarButtonsOptions extends Omit { /** * Customize each sidebar button. * @example * sidebarButton: ({ id, buttonProps, breakpoint, createSidebarButton }) => ({ * ...buttonProps, * // custom icon for panelBlocks button * icon: buttonProps.id === 'panelBlocks' ? '' : buttonProps.icon, * }) */ sidebarButton?: SidebarButtonFn; /** * Add or filter the resultant buttons per breakpoint. * @example * sidebarButtons: ({ breakpoint, sidebarButtons, createSidebarButton }) => { * // Add a new button for the default layout * return !breakpoint ? [...sidebarButtons, createSidebarButton({...})] : sidebarButtons; * } */ sidebarButtons?: SidebarButtonsFn; /** * Customize the layout command object of each sidebar button. * * @example * sidebarLayoutCommand: ({ layoutCommand }) => { * if (layoutCommand.id === 'panelBlocks') { * // Change the default placer to absolute right * return { * ...layoutCommand, * placer: { type: 'absolute', position: 'right' } * }; * } * return layoutCommand; * } */ sidebarLayoutCommand?: SidebarLayoutCommandFn; /** * Customize the root layout per breakpoint. */ rootLayout?: CustomRootLayoutFn; /** * Skip loading the layout config. * This might be useful if you're loading the layout config directly in the config. * @default false */ skipLayoutConfig?: boolean; } export interface BreakpointProps extends Required> { breakpoint: number; } export type SidebarButtonResult = StudioLayoutComponentsConfigProps | undefined | null | false; export type CreateSidebarButtonFn = (props: SidebarButtonProps) => StudioLayoutButtonConfigProps; export interface CreateSidebarButtonOpts { pluginOpts?: LayoutSidebarButtonsOptions; breakpointProps: BreakpointProps; } export type SidebarButtonFn = (props: { id: string; buttonIds: typeof SidebarButtonIds; sidebarButtonProps: SidebarButtonProps; buttonProps: StudioLayoutButtonConfigProps; createSidebarButton: (props: Partial) => StudioLayoutButtonConfigProps; } & BreakpointProps) => SidebarButtonResult; export type SidebarButtonsFn = (props: { buttonIds: typeof SidebarButtonIds; sidebarButtons: StudioLayoutComponentsConfigProps[]; createSidebarButton: CreateSidebarButtonFn; } & BreakpointProps) => SidebarButtonResult[]; export type SidebarLayoutCommandFn = (props: { layoutCommand: LayoutCommandProps; sidebarButtonProps: SidebarButtonProps; } & BreakpointProps) => LayoutCommandProps; export type CustomRootLayoutFn = (props: { sidebarButtons: StudioLayoutComponentsConfigProps[]; rootLayout: RootLayoutConfig; layoutSidebarTarget: RootLayoutConfig; layoutSidebarLeft: StudioLayoutSidebarLeftConfigProps; createSidebarButton: CreateSidebarButtonFn; } & BreakpointProps) => RootLayoutConfig; export interface SidebarButtonProps { id: string; icon: string; label?: string; className?: string; layoutComponent: StudioLayoutComponentsConfigProps; layoutCommand?: Partial>; tooltip?: string; skipSelfClose?: boolean; removeLayouts?: string[]; } export declare enum SidebarButtonIds { panelBlocks = "panelBlocks", panelPagesLayers = "panelPagesLayers", panelGlobalStyles = "panelGlobalStyles", panelSidebarTabs = "panelSidebarTabs", panelAssets = "panelAssets", aiChatPanel = "aiChatPanel", panelDataSources = "panelDataSources" } export interface SDKPluginWithLayoutConfig extends PluginWithInit { createLayoutConfig: (options?: Pick) => LayoutConfig; }