import type { MinimalComponentType } from '@ui-schema/react/Widget'; import type { ReactNode } from 'react'; import type { WidgetPluginProps } from './WidgetPlugin.js'; export type NextWidgetPlugin

= { Component: (props: P2) => ReactNode; plugin: any; index: number; name: string; }; /** * Super simple PoC for `Next` wrapped widget plugin stack, which should be materialized in binding/context, * still using index to provide compatibility with non migrated plugins. * @todo finalize, move out of here, be sure to adjust memo like explained above to work here, do we want to memo the first component here?! * * the only "less overhead" with the same DX is using render functions - which are no longer JSX elements themself, * which brings a lot of draw backs in terms of types, hot reload and (imho.) general react best practice, * and I think could even break hook usage, due to it being possible that the widgetPlugins change dynamically, * which wouldn't be (i think) recognized with normal react un/mounts. * * type PluginRenderFn = (props: PluginProps, next: PluginRenderFn | null) => ReactNode; * * function renderPluginChain(plugins: PluginRenderFn[], props: PluginProps): ReactNode { * const invoke = (i: number): ReactNode => { * if (i >= plugins.length) return null * const plugin = plugins[i] * return plugin(props, (nextProps) => invoke(i + 1)) * } * return invoke(0) * } * * // here `Next` is the second argument and no longer in `props` itself * const MyPlugin: PluginRenderFn = (props, Next) => { * // ... do something with props * return

* {Next ? Next(props) : null} *
* } */ export declare const useNext: (WidgetRenderer: MinimalComponentType | undefined | null, widgetPlugins: MinimalComponentType[] | undefined | null) => NextWidgetPlugin>; export declare const makeNext: (WidgetRenderer: MinimalComponentType | undefined | null, widgetPlugins: MinimalComponentType[] | undefined | null) => NextWidgetPlugin>; export declare const NextPlugin:

(props: P) => ReactNode; export declare const NextPluginMemo:

(props: P) => ReactNode;