react-sass-inlinesvg
Version:
React library designed to control SVG from Sass.
75 lines (74 loc) • 2.42 kB
TypeScript
import React, { NamedExoticComponent } from "react";
import type { ExoticComponent } from "react";
import { FetchError } from "react-inlinesvg";
export declare const animationNamePrefix = "svg_";
export declare type SpecialName = "NULL" | "NONE" | "HIDDEN";
export declare type PathMap = {
[P in string]: () => string;
};
export declare type ErrorHandler = (error: Error | FetchError) => void;
export declare type LoadHandler = (src: string, hasCache: boolean) => void;
export declare type ExtractProps<T> = T extends ExoticComponent<infer P> ? P : never;
declare type PartialProps = {
title?: string;
description?: string;
onError?: ErrorHandler;
onLoad?: LoadHandler;
};
declare type SvgProps<N extends string> = Omit<React.ComponentProps<"svg">, "onError"> & {
defaultName?: N | SpecialName;
fetchOptions?: RequestInit;
innerRef?: React.Ref<SVGElement>;
} & PartialProps;
export declare type Options = {
fetchOptions?: RequestInit;
uniquifyIDs?: boolean;
uniqueHash?: string;
};
declare type Attribute = {
name: string;
value: string;
};
export declare class ForTest {
protected static state: {
cacheObject: {
[key: string]: {
attributes: Attribute[];
content: string;
};
};
updateQueueObject: {
[key: string]: SVGSVGElement[];
};
aggregation: {
start: {
queue: {
element: SVGSVGElement;
}[];
};
fetch: {
queue: {
svgName: string;
element: SVGSVGElement;
propsRef: React.RefObject<PartialProps>;
}[];
};
render: {
queue: {
render: () => void;
}[];
};
};
setupCompleted: boolean;
};
}
export declare function setup<T extends PathMap>(pathMap: T, options?: Options): {
SVG: NamedExoticComponent<SvgProps<keyof T & string>>;
pathMap: T;
};
export declare function renderStoryCatalog<N extends string>(SVG: React.VFC<SvgProps<N>>, pathMap: PathMap, className: string, useDefault?: boolean): JSX.Element;
export declare function updateTextNode(svg: SVGSVGElement, { title, description }: {
title?: string;
description?: string;
}): void;
export {};