import type { Template, RenderOptions, WidgetFactory, InitOptions, Widget } from '../../types'; export type PanelCSSClasses = Partial<{ /** * CSS classes to add to the root element of the widget. */ root: string | string[]; /** * CSS classes to add to the root element of the widget when there's no refinements. */ noRefinementRoot: string | string[]; /** * CSS classes to add to the root element when collapsible (`collapse` is defined). */ collapsibleRoot: string | string[]; /** * CSS classes to add to the root element when collapsed. */ collapsedRoot: string | string[]; /** * CSS classes to add to the collapse button element. */ collapseButton: string | string[]; /** * CSS classes to add to the collapse icon of the button. */ collapseIcon: string | string[]; /** * CSS classes to add to the header. */ header: string | string[]; /** * CSS classes to add to the body. */ body: string | string[]; /** * CSS classes to add to the footer. */ footer: string | string[]; }>; type AnyWidgetFactory = WidgetFactory<{ $$type: string; }, Record, any>; export type PanelTemplates = Partial<{ /** * Template to use for the header. */ header: Template>; /** * Template to use for the footer. */ footer: Template>; /** * Template to use for collapse button. */ collapseButtonText: Template<{ collapsed: boolean; }>; }>; type GetWidgetRenderState = ReturnType['getWidgetRenderState'] extends (renderOptions: any) => infer TRenderState ? TRenderState extends Record ? TRenderState : never : Record; export type PanelRenderOptions = RenderOptions & GetWidgetRenderState; export type PanelSharedOptions = (InitOptions | RenderOptions) & GetWidgetRenderState; export type PanelWidgetParams = { /** * A function that is called on each render to determine if the * panel should be hidden based on the render options. */ hidden?: (options: PanelRenderOptions) => boolean; /** * A function that is called on each render to determine if the * panel should be collapsed based on the render options. */ collapsed?: (options: PanelRenderOptions) => boolean; /** * The templates to use for the widget. */ templates?: PanelTemplates; /** * The CSS classes to override. */ cssClasses?: PanelCSSClasses; }; type AugmentedWidget = Omit, TOverriddenKeys | 'dependsOn' | 'getWidgetParameters'> & Pick, TOverriddenKeys>; export type PanelWidget = (panelWidgetParams?: PanelWidgetParams) => (widgetFactory: TWidgetFactory) => (widgetParams: Parameters[0]) => AugmentedWidget; /** * The panel widget wraps other widgets in a consistent panel design. * It also reacts, indicates and sets CSS classes when widgets are no longer relevant for refining. */ declare const panel: PanelWidget; export default panel;