1 | import { IDisposable } from '@lumino/disposable';
|
2 | import { Message } from '@lumino/messaging';
|
3 | import { ISignal, Signal } from '@lumino/signaling';
|
4 | import { Widget } from '@lumino/widgets';
|
5 | import * as React from 'react';
|
6 | type ReactRenderElement = Array<React.ReactElement<any>> | React.ReactElement<any>;
|
7 |
|
8 |
|
9 |
|
10 | export declare abstract class ReactWidget extends Widget {
|
11 | constructor();
|
12 | /**
|
13 | * Creates a new `ReactWidget` that renders a constant element.
|
14 | * @param element React element to render.
|
15 | */
|
16 | static create(element: ReactRenderElement): ReactWidget;
|
17 | /**
|
18 | * Render the content of this widget using the virtual DOM.
|
19 | *
|
20 | * This method will be called anytime the widget needs to be rendered, which
|
21 | * includes layout triggered rendering.
|
22 | *
|
23 | * Subclasses should define this method and return the root React nodes here.
|
24 | */
|
25 | protected abstract render(): ReactRenderElement | null;
|
26 | /**
|
27 | * Called to update the state of the widget.
|
28 | *
|
29 | * The default implementation of this method triggers
|
30 | * VDOM based rendering by calling the `renderDOM` method.
|
31 | */
|
32 | protected onUpdateRequest(msg: Message): void;
|
33 | /**
|
34 | * Called after the widget is attached to the DOM
|
35 | */
|
36 | protected onAfterAttach(msg: Message): void;
|
37 | /**
|
38 | * Called before the widget is detached from the DOM.
|
39 | */
|
40 | protected onBeforeDetach(msg: Message): void;
|
41 | /**
|
42 | * Render the React nodes to the DOM.
|
43 | *
|
44 | * @returns a promise that resolves when the rendering is done.
|
45 | */
|
46 | private renderDOM;
|
47 | renderPromise?: Promise<void>;
|
48 | private _rootDOM;
|
49 | }
|
50 | /**
|
51 | * An abstract ReactWidget with a model.
|
52 | */
|
53 | export declare abstract class VDomRenderer<T extends VDomRenderer.IModel | null = null> extends ReactWidget {
|
54 | |
55 |
|
56 |
|
57 | constructor(model?: T);
|
58 | /**
|
59 | * A signal emitted when the model changes.
|
60 | */
|
61 | get modelChanged(): ISignal<this, void>;
|
62 | /**
|
63 | * Set the model and fire changed signals.
|
64 | */
|
65 | set model(newValue: T);
|
66 | /**
|
67 | * Get the current model.
|
68 | */
|
69 | get model(): T;
|
70 | /**
|
71 | * Dispose this widget.
|
72 | */
|
73 | dispose(): void;
|
74 | private _model;
|
75 | private _modelChanged;
|
76 | }
|
77 | /**
|
78 | * Props for the UseSignal component
|
79 | */
|
80 | export interface IUseSignalProps<SENDER, ARGS> {
|
81 | |
82 |
|
83 |
|
84 | signal: ISignal<SENDER, ARGS>;
|
85 | |
86 |
|
87 |
|
88 |
|
89 | initialSender?: SENDER;
|
90 | |
91 |
|
92 |
|
93 |
|
94 | initialArgs?: ARGS;
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | children: (sender?: SENDER, args?: ARGS) => React.ReactNode;
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | shouldUpdate?: (sender: SENDER, args: ARGS) => boolean;
|
109 | }
|
110 |
|
111 |
|
112 |
|
113 | export interface IUseSignalState<SENDER, ARGS> {
|
114 | value: [SENDER?, ARGS?];
|
115 | }
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | export declare class UseSignal<SENDER, ARGS> extends React.Component<IUseSignalProps<SENDER, ARGS>, IUseSignalState<SENDER, ARGS>> {
|
153 | constructor(props: IUseSignalProps<SENDER, ARGS>);
|
154 | componentDidMount(): void;
|
155 | componentWillUnmount(): void;
|
156 | private slot;
|
157 | render(): React.ReactNode;
|
158 | }
|
159 | /**
|
160 | * The namespace for VDomRenderer statics.
|
161 | */
|
162 | export declare namespace VDomRenderer {
|
163 | |
164 |
|
165 |
|
166 | interface IModel extends IDisposable {
|
167 | |
168 |
|
169 |
|
170 | readonly stateChanged: ISignal<this, void>;
|
171 | }
|
172 | }
|
173 |
|
174 |
|
175 |
|
176 | export declare class VDomModel implements VDomRenderer.IModel {
|
177 | |
178 |
|
179 |
|
180 | readonly stateChanged: Signal<this, void>;
|
181 | |
182 |
|
183 |
|
184 | get isDisposed(): boolean;
|
185 | |
186 |
|
187 |
|
188 | dispose(): void;
|
189 | private _isDisposed;
|
190 | }
|
191 | export {};
|