[react-frame-component] Introduce type definitions (#38750)

This commit is contained in:
Alex Bukurov 2019-10-03 02:29:41 +06:00 committed by Ryan Cavanaugh
parent 8501cb5b3e
commit 2ea517f1b6
4 changed files with 75 additions and 0 deletions

27
types/react-frame-component/index.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
// Type definitions for react-frame-component 4.1
// Project: https://github.com/ryanseddon/react-frame-component
// Definitions by: Alex Bukurov <https://github.com/abukurov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
export interface FrameComponentProps extends React.IframeHTMLAttributes<HTMLIFrameElement> {
head?: React.ReactNode;
mountTarget?: string;
initialContent?: string;
contentDidMount?: () => void;
contentDidUpdate?: () => void;
children: React.ReactNode;
}
export default class FrameComponent extends React.Component<FrameComponentProps> {}
export interface FrameContext {
document?: any;
window?: any;
}
export const FrameContextProvider: React.Provider<FrameContext>;
export const FrameContextConsumer: React.Consumer<FrameContext>;

View File

@ -0,0 +1,22 @@
import * as React from 'react';
import Frame, { FrameContextConsumer } from 'react-frame-component';
<div>
<Frame>
<span>content</span>
</Frame>
<Frame
head={<span>head</span>}
mountTarget='#mountHere'
contentDidMount={() => {}}
contentDidUpdate={() => {}}
initialContent='<!DOCTYPE html><html><head></head><body><h1>i wont be changed</h1><div id="mountHere"></div></body></html>'
>
<span>content</span>
</Frame>
<Frame>
<FrameContextConsumer>
{({ document, window }) => <span>content</span>}
</FrameContextConsumer>
</Frame>
</div>;

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"jsx": "react",
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-frame-component-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }