2021-08-16 02:04:15 +00:00
|
|
|
import type { HTMLProps, RefAttributes } from 'react';
|
2021-04-23 15:06:49 +00:00
|
|
|
import type { IconifyIcon } from '@iconify/types';
|
2021-05-24 10:25:02 +00:00
|
|
|
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
2021-05-11 20:27:13 +00:00
|
|
|
|
|
|
|
export { RawIconCustomisations };
|
2021-04-23 15:06:49 +00:00
|
|
|
|
|
|
|
// Allow rotation to be string
|
|
|
|
/**
|
|
|
|
* Icon customisations
|
|
|
|
*/
|
2021-08-16 01:50:00 +00:00
|
|
|
export type IconifyIconCustomisations = Omit<RawIconCustomisations, "rotate"> & {
|
2021-04-23 15:06:49 +00:00
|
|
|
rotate?: string | number;
|
|
|
|
};
|
|
|
|
|
2021-05-11 20:27:13 +00:00
|
|
|
/**
|
|
|
|
* Callback for when icon has been loaded (only triggered for icons loaded from API)
|
|
|
|
*/
|
|
|
|
export type IconifyIconOnLoad = (name: string) => void;
|
|
|
|
|
2021-04-23 15:06:49 +00:00
|
|
|
/**
|
|
|
|
* Icon properties
|
|
|
|
*/
|
|
|
|
export interface IconifyIconProps extends IconifyIconCustomisations {
|
|
|
|
// Icon object or icon name (must be added to storage using addIcon for offline package)
|
|
|
|
icon: IconifyIcon | string;
|
|
|
|
|
|
|
|
// Style
|
|
|
|
color?: string;
|
|
|
|
|
|
|
|
// Shorthand properties
|
|
|
|
flip?: string;
|
|
|
|
align?: string;
|
|
|
|
|
|
|
|
// Unique id, used as base for ids for shapes. Use it to get consistent ids for server side rendering
|
|
|
|
id?: string;
|
2021-05-11 20:27:13 +00:00
|
|
|
|
|
|
|
// Callback to call when icon data has been loaded. Used only for icons loaded from API
|
|
|
|
onLoad?: IconifyIconOnLoad;
|
2021-04-23 15:06:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component properties: generic element for Icon component, SVG for generated component
|
|
|
|
*/
|
2021-08-16 02:04:15 +00:00
|
|
|
type IconifyElementProps = HTMLProps<SVGSVGElement>;
|
2021-04-23 15:06:49 +00:00
|
|
|
|
2021-08-16 02:04:15 +00:00
|
|
|
export type IconRef = RefAttributes<SVGSVGElement>;
|
2021-04-23 15:06:49 +00:00
|
|
|
|
|
|
|
export interface ReactRefProp {
|
|
|
|
ref?: IconRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-16 02:04:15 +00:00
|
|
|
* Mix of icon properties and SVGSVGElement properties
|
2021-04-23 15:06:49 +00:00
|
|
|
*/
|
|
|
|
export type IconProps = IconifyElementProps & IconifyIconProps & ReactRefProp;
|