forked from FormidableLabs/react-live
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-live.d.ts
More file actions
47 lines (35 loc) · 1.28 KB
/
Copy pathreact-live.d.ts
File metadata and controls
47 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { ComponentClass, StatelessComponent, HTMLProps } from 'react'
// React union type
type Component<P> = ComponentClass<P> | StatelessComponent<P>
// Helper types
type KeyType = string | number | symbol;
type Diff<T extends KeyType, U extends KeyType> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>
// React Element Props
type DivProps = HTMLProps<HTMLDivElement>
type PreProps = HTMLProps<HTMLPreElement>
// LiveProvider
export type LiveProviderProps = Omit<DivProps, 'scope'> & {
scope?: { [key: string]: any };
code?: string;
mountStylesheet?: boolean;
noInline?: boolean;
transformCode?: (code: string) => string;
}
export const LiveProvider: ComponentClass<LiveProviderProps>
// Editor
export type EditorProps = PreProps & {
ignoreTabKey?: boolean;
}
export const Editor: ComponentClass<EditorProps>
// LiveEditor
export type LiveEditorProps = Omit<EditorProps, 'onChange'> & {
onChange?: (code: string) => void
}
export const LiveEditor: ComponentClass<LiveEditorProps>
// LiveError
export const LiveError: ComponentClass<DivProps>
// LivePreview
export const LivePreview: ComponentClass<DivProps>
// withLive HOC
export function withLive<P>(wrappedComponent: Component<P>): ComponentClass<P>