diff --git a/types/react-lazylog/build/LazyLog.d.ts b/types/react-lazylog/build/LazyLog.d.ts new file mode 100644 index 0000000000..21b42f8030 --- /dev/null +++ b/types/react-lazylog/build/LazyLog.d.ts @@ -0,0 +1,28 @@ +import { Component, ReactNode, CSSProperties } from "react"; +import { Range } from "immutable"; + +export interface LazyLogProps { + url: string; + fetchOptions?: RequestInit; + stream?: boolean; + height?: string | number; + width?: string | number; + follow?: boolean; + scrollToLine?: number; + highlight?: number | number[]; + selectableLines?: boolean; + formatPart?: (text: string) => ReactNode; + onLoad?: () => any; + onError?: (error: any) => any; + onHighlight?: (range: Range) => any; + rowHeight?: number; + overscanRowCount?: number; + containerStyle?: CSSProperties; + style?: CSSProperties; +} + +export class LazyLog extends Component { + static defaultProps: Partial; +} + +export default LazyLog; diff --git a/types/react-lazylog/build/Line.d.ts b/types/react-lazylog/build/Line.d.ts new file mode 100644 index 0000000000..85c3444289 --- /dev/null +++ b/types/react-lazylog/build/Line.d.ts @@ -0,0 +1,22 @@ +import { Component, ReactNode, CSSProperties, MouseEventHandler } from "react"; + +export interface LineProps { + data: Array<{ text: string }>; + number: number; + rowHeight: number; + highlight?: boolean; + selectable?: boolean; + style?: CSSProperties; + formatPart?: (text: string) => ReactNode; + onLineNumberClick?: MouseEventHandler; + + /** + * This is never called + * https://github.com/mozilla-frontend-infra/react-lazylog/issues/18 + */ + onRowClick?: () => any; +} + +export default class Line extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/LineContent.d.ts b/types/react-lazylog/build/LineContent.d.ts new file mode 100644 index 0000000000..1bece45340 --- /dev/null +++ b/types/react-lazylog/build/LineContent.d.ts @@ -0,0 +1,12 @@ +import { Component, ReactNode, CSSProperties } from "react"; + +export interface LineContentProps { + data: Array<{ text: string }>; + number: number; + formatPart?: (text: string) => ReactNode; + style?: CSSProperties; +} + +export default class LineContent extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/LineNumber.d.ts b/types/react-lazylog/build/LineNumber.d.ts new file mode 100644 index 0000000000..4a7aa396d4 --- /dev/null +++ b/types/react-lazylog/build/LineNumber.d.ts @@ -0,0 +1,12 @@ +import { Component, ReactNode, CSSProperties, MouseEventHandler } from "react"; + +export interface LineNumberProps { + number: number; + highlight?: boolean; + onClick?: MouseEventHandler; + style?: CSSProperties; +} + +export default class LinePart extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/LinePart.d.ts b/types/react-lazylog/build/LinePart.d.ts new file mode 100644 index 0000000000..4b0ff946a2 --- /dev/null +++ b/types/react-lazylog/build/LinePart.d.ts @@ -0,0 +1,11 @@ +import { Component, ReactNode, CSSProperties } from "react"; + +export interface LinePartProps { + part: { text: string }; + format?: (text: string) => ReactNode; + style?: CSSProperties; +} + +export default class LinePart extends Component { + static defaultProps: Partial; +} diff --git a/types/react-lazylog/build/Loading.d.ts b/types/react-lazylog/build/Loading.d.ts new file mode 100644 index 0000000000..45d1f38f15 --- /dev/null +++ b/types/react-lazylog/build/Loading.d.ts @@ -0,0 +1,3 @@ +import { Component } from "react"; + +export default class Loading extends Component {} diff --git a/types/react-lazylog/build/ScrollFollow.d.ts b/types/react-lazylog/build/ScrollFollow.d.ts new file mode 100644 index 0000000000..c2da7f0fb2 --- /dev/null +++ b/types/react-lazylog/build/ScrollFollow.d.ts @@ -0,0 +1,19 @@ +import { Component, ReactNode } from "react"; + +export interface ScrollFollowRenderProps { + onScroll: ( + args: { scrollTop: number; scrollHeight: number; clientHeight: number } + ) => void; + follow: boolean; + startFollowing: () => void; + stopFollowing: () => void; +} + +export interface ScrollFollowProps { + render: (props: ScrollFollowRenderProps) => ReactNode; + startFollowing?: boolean; +} + +export class ScrollFollow extends Component {} + +export default ScrollFollow; diff --git a/types/react-lazylog/index.d.ts b/types/react-lazylog/index.d.ts new file mode 100644 index 0000000000..57c7b623a1 --- /dev/null +++ b/types/react-lazylog/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for react-lazylog 3.1 +// Project: https://github.com/mozilla-frontend-infra/react-lazylog +// Definitions by: Benjamin Romano +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +export * from "./build/LazyLog"; +export * from "./build/ScrollFollow"; diff --git a/types/react-lazylog/package.json b/types/react-lazylog/package.json new file mode 100644 index 0000000000..c658c73862 --- /dev/null +++ b/types/react-lazylog/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "immutable": ">=3.8.2" + } +} diff --git a/types/react-lazylog/react-lazylog-tests.tsx b/types/react-lazylog/react-lazylog-tests.tsx new file mode 100644 index 0000000000..3c66c82b55 --- /dev/null +++ b/types/react-lazylog/react-lazylog-tests.tsx @@ -0,0 +1,38 @@ +import * as React from "react"; +import LinePart, { LinePartProps } from "react-lazylog/build/LinePart"; +import LineNumber, { LineNumberProps } from "react-lazylog/build/LineNumber"; +import LineContent, { LineContentProps } from "react-lazylog/build/LineContent"; +import Line, { LineProps } from "react-lazylog/build/Line"; +import Loading from "react-lazylog/build/Loading"; +import { + LazyLog, + LazyLogProps, + ScrollFollow, + ScrollFollowProps, + ScrollFollowRenderProps +} from "react-lazylog"; + +LinePart.defaultProps.style = { color: "green" }; +const linePart = ; + +LineNumber.defaultProps.style = { color: "green" }; +const lineNumber = ; + +LineContent.defaultProps.style = { color: "green" }; +const lineContent = ; + +Line.defaultProps.style = { color: "green" }; +const line = ; + +const loading = ; + +const scrollFollow = ( + ( +
+ )} + /> +); + +LazyLog.defaultProps.style = { color: "green" }; +const lazyLog = ; diff --git a/types/react-lazylog/tsconfig.json b/types/react-lazylog/tsconfig.json new file mode 100644 index 0000000000..856e2e40aa --- /dev/null +++ b/types/react-lazylog/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "react-lazylog-tests.tsx", + "index.d.ts", + "build/Line.d.ts", + "build/LineContent.d.ts", + "build/LineNumber.d.ts", + "build/LinePart.d.ts", + "build/Loading.d.ts" + ] +} diff --git a/types/react-lazylog/tslint.json b/types/react-lazylog/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-lazylog/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }