UNPKG

3.32 kBTypeScriptView Raw
1// Type definitions for react-helmet 6.1
2// Project: https://github.com/nfl/react-helmet
3// Definitions by: Evan Bremer <https://github.com/evanbb>
4// Isman Usoh <https://github.com/isman-usoh>
5// François Nguyen <https://github.com/lith-light-g>
6// Kok Sam <https://github.com/sammkj>
7// Yui T. <https://github.com/yuit>
8// Yamagishi Kazutoshi <https://github.com/ykzts>
9// Justin Hall <https://github.com/wKovacs64>
10// Andriy2 <https://github.com/Andriy2>
11// Piotr Błażejewicz <https://github.com/peterblazejewicz>
12// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13
14import * as React from "react";
15
16interface OtherElementAttributes {
17 [key: string]: string | number | boolean | null | undefined;
18}
19
20type HtmlProps = JSX.IntrinsicElements["html"] & OtherElementAttributes;
21
22type BodyProps = JSX.IntrinsicElements["body"] & OtherElementAttributes;
23
24type LinkProps = JSX.IntrinsicElements["link"];
25
26type MetaProps = JSX.IntrinsicElements["meta"];
27
28export interface HelmetTags {
29 baseTag: any[];
30 linkTags: HTMLLinkElement[];
31 metaTags: HTMLMetaElement[];
32 noscriptTags: any[];
33 scriptTags: HTMLScriptElement[];
34 styleTags: HTMLStyleElement[];
35}
36
37export interface HelmetProps {
38 async?: boolean | undefined;
39 base?: any;
40 bodyAttributes?: BodyProps | undefined;
41 defaultTitle?: string | undefined;
42 defer?: boolean | undefined;
43 encodeSpecialCharacters?: boolean | undefined;
44 htmlAttributes?: HtmlProps | undefined;
45 onChangeClientState?: ((newState: any, addedTags: HelmetTags, removedTags: HelmetTags) => void) | undefined;
46 link?: LinkProps[] | undefined;
47 meta?: MetaProps[] | undefined;
48 noscript?: any[] | undefined;
49 script?: any[] | undefined;
50 style?: any[] | undefined;
51 title?: string | undefined;
52 titleAttributes?: object | undefined;
53 titleTemplate?: string | undefined;
54}
55
56/**
57 * Used by Helmet.peek()
58 */
59export type HelmetPropsToState = HelmetTags &
60 Pick<
61 HelmetProps,
62 "bodyAttributes" | "defer" | "htmlAttributes" | "onChangeClientState" | "title" | "titleAttributes"
63 > & {
64 encode: Required<HelmetProps["encodeSpecialCharacters"]>;
65 };
66
67declare class Helmet extends React.Component<HelmetProps> {
68 static peek(): HelmetPropsToState;
69 static rewind(): HelmetData;
70 static renderStatic(): HelmetData;
71 static canUseDOM: boolean;
72}
73
74declare const HelmetExport: typeof Helmet;
75
76export { HelmetExport as Helmet };
77export default HelmetExport;
78
79export interface HelmetData {
80 base: HelmetDatum;
81 bodyAttributes: HelmetHTMLBodyDatum;
82 htmlAttributes: HelmetHTMLElementDatum;
83 link: HelmetDatum;
84 meta: HelmetDatum;
85 noscript: HelmetDatum;
86 script: HelmetDatum;
87 style: HelmetDatum;
88 title: HelmetDatum;
89 titleAttributes: HelmetDatum;
90}
91
92export interface HelmetDatum {
93 toString(): string;
94 toComponent(): React.ReactElement;
95}
96
97export interface HelmetHTMLBodyDatum {
98 toString(): string;
99 toComponent(): React.HTMLAttributes<HTMLBodyElement>;
100}
101
102export interface HelmetHTMLElementDatum {
103 toString(): string;
104 toComponent(): React.HTMLAttributes<HTMLHtmlElement>;
105}
106
107export const canUseDOM: boolean;
108
\No newline at end of file