UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

57 lines • 2.6 kB
import { Actions } from './components/actions'; import { Commands } from './components/commands'; import { NoWidgetsState } from './components/no-widgets-state'; import { WidgetDashboardPolicy } from './components/dashboard-policy'; import type { WidgetDashboardProps } from './types'; /** * Stateless rendering engine for widget dashboards. * * The consumer owns `layout` and `editMode` state; every mutation fires * `onLayoutChange` with the fully updated array. The engine never queries a * widget store; types flow in via the `widgetTypes` prop. * * ```tsx * import { WidgetDashboard } from '@wordpress/widget-dashboard'; * * function MyDashboard() { * const [ layout, setLayout ] = useState( defaultLayout ); * const [ editMode, setEditMode ] = useState( false ); * return ( * <WidgetDashboard * layout={ layout } * onLayoutChange={ setLayout } * widgetTypes={ widgetTypes } * editMode={ editMode } * onEditChange={ setEditMode } * > * <WidgetDashboard.NoWidgetsState> * <p>No widgets yet.</p> * </WidgetDashboard.NoWidgetsState> * <WidgetDashboard.Actions /> * <WidgetDashboard.Widgets /> * <WidgetDashboard.Commands /> * </WidgetDashboard> * ); * } * ``` * * Children compose the dashboard's triggers and chrome: `Actions`, * `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the * widget inserter, the widget settings editor, the reset confirmation) are * mounted by the engine and driven by shared UI state, so a trigger works * wherever it is composed without a matching target in the tree. Omitting * `children` renders the default arrangement. * * `Policy` mounts above one or several dashboards and governs what users * may do on them; every compound asks the resolved policy through the * internal context. */ export declare const WidgetDashboard: (({ layout, onLayoutChange, onLayoutReset, widgetTypes, isResolvingWidgetTypes, editMode, onEditChange, resolveWidgetModule, gridSettings, children, }: WidgetDashboardProps) => import("react").JSX.Element) & { Actions: typeof Actions; Widgets: import("react").ForwardRefExoticComponent<import("./components/widgets/widgets").WidgetsProps & import("react").RefAttributes<HTMLDivElement>>; WidgetChrome: import("react").ForwardRefExoticComponent<import("./components/widget-chrome/widget-chrome").WidgetChromeProps & import("react").RefAttributes<HTMLDivElement>>; NoWidgetsState: typeof NoWidgetsState; Commands: typeof Commands; Policy: typeof WidgetDashboardPolicy; }; //# sourceMappingURL=widget-dashboard.d.ts.map