/// import type { WidgetsOptions, WidgetsPanelLayout } from '../../../../domains/dashboarding/dashboard-model/types.js'; import { type WidgetProps } from '../../../../domains/widgets/components/widget/types.js'; import type { DashboardPersistenceManager } from '../../persistence/types.js'; /** Setter for widgets array (e.g. React setState or updater function). */ export type SetWidgets = React.Dispatch>; /** Setter for widgets options array (e.g. React setState or updater function). */ export type SetWidgetsOptions = React.Dispatch>; /** Setter for widgets panel layout. */ export type SetWidgetsLayout = (newLayout: WidgetsPanelLayout) => void; /** Options for the duplicate widget middleware hook. */ export type UseDuplicateWidgetMenuItemParams = { /** Current widgets. */ widgets: WidgetProps[]; /** Setter to update widgets (e.g. from parent state). */ setWidgets: SetWidgets; /** Current widgets panel layout. */ widgetsLayout: WidgetsPanelLayout; /** Setter to update widgets layout (e.g. from parent state). */ setWidgetsLayout: SetWidgetsLayout; /** When false, returns widgets unchanged (no menu item added). */ enabled?: boolean; /** Dashboard-level widget options (applied to cloned widget when persisting). */ widgetsOptions?: WidgetsOptions; /** Setter to update widgets options (e.g. from parent state). */ setWidgetsOptions: SetWidgetsOptions; persistence?: Pick; }; /** Output of the duplicate widget middleware. */ export type DuplicateWidgetMiddlewareOutput = { widgets: WidgetProps[]; }; /** * Middleware hook that adds a "Duplicate widget" header menu item to each widget. * On click, clones the widget and updates the layout (inserts new cell in the same row). * * @param options - Options containing widgets, layout, setters, and enabled flag. * @returns Updated props with widgets augmented with the duplicate menu item (or unchanged when disabled). * * @example * ```ts * const [widgets, setWidgets] = useSyncedState(initialWidgets); * const [widgetsLayout, setWidgetsLayout] = useSyncedState(initialLayout); * const { widgets: widgetsWithDuplicate, widgetsLayout: widgetsLayoutWithDuplicate } = useDuplicateWidgetMenuItem({ * widgets, * setWidgets, * widgetsLayout, * setWidgetsLayout, * enabled: true, * }); * const { layout: widgetsLayout, setLayout: setWidgetsLayout } = useWidgetsLayoutManagement({ * layout: widgetsLayoutWithDuplicate, * layoutManagers: [tabberLayoutManager], * }); * ``` */ export declare function useDuplicateWidgetMenuItem(params: UseDuplicateWidgetMenuItemParams): DuplicateWidgetMiddlewareOutput;