react-sass-inlinesvg
Version:
React library designed to control SVG from Sass.
74 lines (73 loc) • 2.3 kB
TypeScript
import React, { NamedExoticComponent } from "react";
import type { ExoticComponent } from "react";
export declare const animationNamePrefix = "svg_";
export type SpecialName = "NULL" | "NONE" | "HIDDEN";
export type PathMap = {
[P in string]: () => string;
};
export type ErrorHandler = (error: Error) => void;
export type LoadHandler = (src: string, hasCache: boolean) => void;
export type ExtractProps<T> = T extends ExoticComponent<infer P> ? P : never;
type PartialProps = {
title?: string;
description?: string;
onError?: ErrorHandler;
onLoad?: LoadHandler;
};
type SvgProps<N extends string> = Omit<React.ComponentProps<"svg">, "onError"> & {
defaultName?: N | SpecialName;
fetchOptions?: RequestInit;
innerRef?: React.Ref<SVGElement>;
} & PartialProps;
export type Options = {
fetchOptions?: RequestInit;
uniquifyIDs?: boolean;
uniqueHash?: string;
};
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 | null>;
}[];
};
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.FC<SvgProps<N>>, pathMap: PathMap, className: string, useDefault?: boolean): React.JSX.Element;
export declare function updateTextNode(svg: SVGSVGElement, { title, description }: {
title?: string;
description?: string;
}): void;
export {};