1 | import * as React from "react";
|
2 | import { DefaultSVGIconProps, IconName, IconSize, SVGIconProps } from "@blueprintjs/icons";
|
3 | import { IntentProps, MaybeElement, Props } from "../../common";
|
4 | export { IconName, IconSize };
|
5 | export interface IconOwnProps {
|
6 | /**
|
7 | * Whether the component should automatically load icon contents using an async import.
|
8 | *
|
9 | * @default true
|
10 | */
|
11 | autoLoad?: boolean;
|
12 | /**
|
13 | * Name of a Blueprint UI icon, or an icon element, to render. This prop is
|
14 | * required because it determines the content of the component, but it can
|
15 | * be explicitly set to falsy values to render nothing.
|
16 | *
|
17 | * - If `null` or `undefined` or `false`, this component will render nothing.
|
18 | * - If given an `IconName` (a string literal union of all icon names), that
|
19 | * icon will be rendered as an `<svg>` with `<path>` tags. Unknown strings
|
20 | * will render a blank icon to occupy space.
|
21 | * - If given a `JSX.Element`, that element will be rendered and _all other
|
22 | * props on this component are ignored._ This type is supported to
|
23 | * simplify icon support in other Blueprint components. As a consumer, you
|
24 | * should avoid using `<Icon icon={<Element />}` directly; simply render
|
25 | * `<Element />` instead.
|
26 | */
|
27 | icon: IconName | MaybeElement;
|
28 | /**
|
29 | * Alias for `size` prop. Kept around for backwards-compatibility with Blueprint v4.x,
|
30 | * will be removed in v6.0.
|
31 | *
|
32 | * @deprecated use `size` prop instead
|
33 | */
|
34 | iconSize?: number;
|
35 | /** Props to apply to the `SVG` element */
|
36 | svgProps?: React.HTMLAttributes<SVGElement>;
|
37 | }
|
38 | /**
|
39 | * Generic interface for the `<Icon>` component which may be parameterized by its root element type.
|
40 | *
|
41 | * @see https://blueprintjs.com/docs/#core/components/icon.dom-attributes
|
42 | */
|
43 | export type IconProps<T extends Element = Element> = IntentProps & Props & SVGIconProps<T> & IconOwnProps;
|
44 | /**
|
45 | * The default `<Icon>` props interface, equivalent to `IconProps` with its default type parameter.
|
46 | * This is primarly exported for documentation purposes; users should reference `IconProps<T>` instead.
|
47 | */
|
48 | export interface DefaultIconProps extends IntentProps, Props, DefaultSVGIconProps, IconOwnProps {
|
49 | }
|
50 | /**
|
51 | * Generic icon component type. This is essentially a type hack required to make forwardRef work with generic
|
52 | * components. Note that this slows down TypeScript compilation, but it better than the alternative of globally
|
53 | * augmenting "@types/react".
|
54 | *
|
55 | * @see https://stackoverflow.com/a/73795494/7406866
|
56 | */
|
57 | export interface IconComponent extends React.FC<IconProps<Element>> {
|
58 | <T extends Element = Element>(props: IconProps<T>): React.ReactElement | null;
|
59 | }
|
60 | /**
|
61 | * Icon component.
|
62 | *
|
63 | * @see https://blueprintjs.com/docs/#core/components/icon
|
64 | */
|
65 | export declare const Icon: IconComponent;
|