1 | import { Signal } from '@lumino/signaling';
|
2 | import { ElementAttrs, VirtualElement, VirtualNode } from '@lumino/virtualdom';
|
3 | import React from 'react';
|
4 | import { LabIconStyle } from '../style';
|
5 | export declare class LabIcon implements LabIcon.ILabIcon, VirtualElement.IRenderer {
|
6 | |
7 |
|
8 |
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | static remove(container: HTMLElement): HTMLElement;
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | static resolve({ icon }: {
|
28 | icon: LabIcon.IResolvable;
|
29 | }): LabIcon;
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | static resolveElement({ icon, iconClass, fallback, ...props }: Partial<LabIcon.IResolverProps> & LabIcon.IProps): HTMLElement;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | static resolveReact({ icon, iconClass, fallback, ...props }: Partial<LabIcon.IResolverProps> & LabIcon.IReactProps): JSX.Element;
|
74 | |
75 |
|
76 |
|
77 | static resolveSvg({ name, svgstr }: LabIcon.IIcon): HTMLElement | null;
|
78 | |
79 |
|
80 |
|
81 |
|
82 |
|
83 | static toggleDebug(debug?: boolean): void;
|
84 | private static _debug;
|
85 | private static _instances;
|
86 | |
87 |
|
88 |
|
89 | constructor({ name, svgstr, render, unrender, _loading }: LabIcon.IOptions & {
|
90 | _loading?: boolean;
|
91 | });
|
92 | /**
|
93 | * Get a view of this icon that is bound to the specified icon/style props
|
94 | *
|
95 | * @param optional icon/style props (same as args for .element
|
96 | * and .react methods). These will be bound to the resulting view
|
97 | *
|
98 | * @returns a view of this LabIcon instance
|
99 | */
|
100 | bindprops(props?: LabIcon.IProps): any;
|
101 | /**
|
102 | * Create an icon as a DOM element
|
103 | *
|
104 | * @param className - a string that will be used as the class
|
105 | * of the container element. Overrides any existing class
|
106 | *
|
107 | * @param container - a preexisting DOM element that
|
108 | * will be used as the container for the svg element
|
109 | *
|
110 | * @param label - text that will be displayed adjacent
|
111 | * to the icon
|
112 | *
|
113 | * @param title - a tooltip for the icon
|
114 | *
|
115 | * @param tag - if container is not explicitly
|
116 | * provided, this tag will be used when creating the container
|
117 | *
|
118 | * @param stylesheet - optional string naming a builtin icon
|
119 | * stylesheet, for example 'menuItem' or `statusBar`. Can also be an
|
120 | * object defining a custom icon stylesheet, or a list of builtin
|
121 | * stylesheet names and/or custom stylesheet objects. If array,
|
122 | * the given stylesheets will be merged.
|
123 | *
|
124 | * See @jupyterlab/ui-components/src/style/icon.ts for details
|
125 | *
|
126 | * @param elementPosition - optional position for the inner svg element
|
127 | *
|
128 | * @param elementSize - optional size for the inner svg element.
|
129 | * Set to 'normal' to get a standard 16px x 16px icon
|
130 | *
|
131 | * @param ...elementCSS - all additional args are treated as
|
132 | * overrides for the CSS props applied to the inner svg element
|
133 | *
|
134 | * @returns A DOM element that contains an (inline) svg element
|
135 | * that displays an icon
|
136 | */
|
137 | element(props?: LabIcon.IProps): HTMLElement;
|
138 | render(container: HTMLElement, options?: LabIcon.IRendererOptions): void;
|
139 | protected get svgElement(): HTMLElement | null;
|
140 | protected get svgInnerHTML(): string | null;
|
141 | protected get svgReactAttrs(): any | null;
|
142 | get svgstr(): string;
|
143 | set svgstr(svgstr: string);
|
144 | unrender?(container: HTMLElement, options?: LabIcon.IRendererOptions): void;
|
145 | protected _initReact(displayName: string): React.ForwardRefExoticComponent<LabIcon.IReactProps>;
|
146 | protected _initRender({ render, unrender }: Partial<VirtualElement.IRenderer>): void;
|
147 | protected _initSvg({ title, uuid }?: {
|
148 | title?: string;
|
149 | uuid?: string;
|
150 | }): HTMLElement | null;
|
151 | readonly name: string;
|
152 | /**
|
153 | * A React component that will create the icon.
|
154 | *
|
155 | * @param className - a string that will be used as the class
|
156 | * of the container element. Overrides any existing class
|
157 | *
|
158 | * @param container - a preexisting DOM element that
|
159 | * will be used as the container for the svg element
|
160 | *
|
161 | * @param label - text that will be displayed adjacent
|
162 | * to the icon
|
163 | *
|
164 | * @param title - a tooltip for the icon
|
165 | *
|
166 | * @param tag - if container is not explicitly
|
167 | * provided, this tag will be used when creating the container
|
168 | *
|
169 | * @param stylesheet - optional string naming a builtin icon
|
170 | * stylesheet, for example 'menuItem' or `statusBar`. Can also be an
|
171 | * object defining a custom icon stylesheet, or a list of builtin
|
172 | * stylesheet names and/or custom stylesheet objects. If array,
|
173 | * the given stylesheets will be merged.
|
174 | *
|
175 | * See @jupyterlab/ui-components/src/style/icon.ts for details
|
176 | *
|
177 | * @param elementPosition - optional position for the inner svg element
|
178 | *
|
179 | * @param elementSize - optional size for the inner svg element.
|
180 | * Set to 'normal' to get a standard 16px x 16px icon
|
181 | *
|
182 | * @param ...elementCSS - all additional args are treated as
|
183 | * overrides for the CSS props applied to the inner svg element
|
184 | *
|
185 | * @param ref - forwarded to the ref prop of the icon's svg element
|
186 | */
|
187 | readonly react: LabIcon.IReact;
|
188 | protected _className: string;
|
189 | protected _loading: boolean;
|
190 | protected _props: LabIcon.IProps;
|
191 | protected _svgReplaced: Signal<this, void>;
|
192 | protected _svgstr: string;
|
193 | protected _uuid: string;
|
194 | /**
|
195 | * Cache for svg parsing intermediates
|
196 | * - undefined: the cache has not yet been populated
|
197 | * - null: a valid, but empty, value
|
198 | */
|
199 | protected _svgElement: HTMLElement | null | undefined;
|
200 | protected _svgInnerHTML: string | null | undefined;
|
201 | protected _svgReactAttrs: any | null | undefined;
|
202 | }
|
203 | /**
|
204 | * A namespace for LabIcon statics.
|
205 | */
|
206 | export declare namespace LabIcon {
|
207 | |
208 |
|
209 |
|
210 | |
211 |
|
212 |
|
213 | interface IIcon {
|
214 | |
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | readonly name: string;
|
221 | |
222 |
|
223 |
|
224 | svgstr: string;
|
225 | }
|
226 | interface IRendererOptions {
|
227 | attrs?: ElementAttrs;
|
228 | children?: ReadonlyArray<VirtualNode>;
|
229 | props?: IProps;
|
230 | }
|
231 | |
232 |
|
233 |
|
234 |
|
235 | interface ILabIcon extends IIcon, VirtualElement.IRenderer {
|
236 | }
|
237 | |
238 |
|
239 |
|
240 |
|
241 | interface IOptions extends IIcon, Partial<VirtualElement.IRenderer> {
|
242 | }
|
243 | |
244 |
|
245 |
|
246 | interface IProps extends LabIconStyle.IProps {
|
247 | |
248 |
|
249 |
|
250 |
|
251 | className?: string;
|
252 | |
253 |
|
254 |
|
255 |
|
256 | container?: HTMLElement;
|
257 | |
258 |
|
259 |
|
260 |
|
261 | label?: string;
|
262 | |
263 |
|
264 |
|
265 |
|
266 | tag?: 'div' | 'span';
|
267 | |
268 |
|
269 |
|
270 | title?: string;
|
271 | }
|
272 | interface IResolverProps {
|
273 | icon?: IMaybeResolvable;
|
274 | iconClass?: string;
|
275 | fallback?: LabIcon;
|
276 | }
|
277 | |
278 |
|
279 |
|
280 | |
281 |
|
282 |
|
283 | type IResolvable = string | (IIcon & Partial<VirtualElement.IRenderer>);
|
284 | |
285 |
|
286 |
|
287 | type IMaybeResolvable = IResolvable | VirtualElement.IRenderer | undefined;
|
288 | |
289 |
|
290 |
|
291 | type IReactRef = React.RefObject<SVGElement>;
|
292 | |
293 |
|
294 |
|
295 |
|
296 | type IReactProps = IProps & React.RefAttributes<SVGElement>;
|
297 | |
298 |
|
299 |
|
300 |
|
301 | type IReact = React.ForwardRefExoticComponent<IReactProps>;
|
302 | }
|
303 | export declare const badIcon: LabIcon;
|
304 | export declare const blankIcon: LabIcon;
|