mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Add type for react-grid-layout
This commit is contained in:
Vendored
+110
@@ -0,0 +1,110 @@
|
||||
// Type definitions for react-grid-layout 0.14
|
||||
// Project: https://github.com/STRML/react-grid-layout
|
||||
// Definitions by: Andrew Birkholz <https://github.com/abirkholz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export as namespace ReactGridLayout;
|
||||
export = ReactGridLayout;
|
||||
|
||||
declare class ReactGridLayout extends React.Component<ReactGridLayout.DefaultProps, any> {
|
||||
constructor(props: any, context: any);
|
||||
|
||||
componentDidMount(): void;
|
||||
componentWillReceiveProps(nextProps: any): void;
|
||||
containerHeight(): any;
|
||||
onDrag(i: number, x: number, y: number, _ref2: any): void;
|
||||
onDragStart(i: number, x: number, y: number, _ref: any): void;
|
||||
onDragStop(i: number, x: number, y: number, _ref3: any): void;
|
||||
onLayoutMaybeChanged(newLayout: any[], oldLayout: any[]): void;
|
||||
onResize(i: number, w: number, h: number, _ref5: any): void;
|
||||
onResizeStart(i: number, w: number, h: number, _ref4: any): void;
|
||||
onResizeStop(i: number, w: number, h: number, _ref6: any): void;
|
||||
placeholder(): any;
|
||||
processGridItem(child: any): any;
|
||||
render(): JSX.Element | null;
|
||||
|
||||
static WidthProvider(ComposedComponent: any, ...args: any[]): any;
|
||||
static displayName: string;
|
||||
}
|
||||
|
||||
declare namespace ReactGridLayout {
|
||||
interface CoreProps {
|
||||
autoSize?: boolean;
|
||||
className?: string;
|
||||
isDraggable?: boolean;
|
||||
isResizable?: boolean;
|
||||
layout?: any[];
|
||||
margin?: number[];
|
||||
maxRows?: number;
|
||||
rowHeight?: number;
|
||||
useCSSTransforms?: boolean;
|
||||
verticalCompact?: boolean;
|
||||
width?: number;
|
||||
|
||||
onDrag?(layout: any, oldItem: any, newItem: any, placeholder: any, e: MouseEvent, element: HTMLElement): any;
|
||||
onDragStart?(layout: any, oldItem: any, newItem: any, placeholder: any, e: MouseEvent, element: HTMLElement): any;
|
||||
onDragStop?(layout: any, oldItem: any, newItem: any, placeholder: any, e: MouseEvent, element: HTMLElement): any;
|
||||
onResize?(layout: any, oldItem: any, newItem: any, placeholder: any, e: MouseEvent, element: HTMLElement): any;
|
||||
onResizeStart?(layout: any, oldItem: any, newItem: any, placeholder: any, e: MouseEvent, element: HTMLElement): any;
|
||||
onResizeStop?(layout: any, oldItem: any, newItem: any, placeholder: any, e: MouseEvent, element: HTMLElement): any;
|
||||
}
|
||||
|
||||
interface DefaultProps extends CoreProps {
|
||||
cols?: number;
|
||||
onLayoutChange?(layout: any): any;
|
||||
}
|
||||
|
||||
interface ResponsiveProps extends CoreProps {
|
||||
breakpoints: {lg: number, md: number, sm: number, xs: number, xxs: number};
|
||||
cols: {lg: number, md: number, sm: number, xs: number, xxs: number};
|
||||
layouts?: {};
|
||||
|
||||
onBreakpointChange?(newBreakpoint: string, newCols: number): any;
|
||||
onLayoutChange?(currentLayout: any, allLayouts: any): any;
|
||||
onWidthChange?(containerWidth: number, margin: [number, number], cols: number, containerPadding: [number, number]): any;
|
||||
}
|
||||
|
||||
class Responsive extends React.Component<ResponsiveProps, any> {
|
||||
constructor(...args: any[]);
|
||||
|
||||
componentWillReceiveProps(nextProps: any): void;
|
||||
generateInitialState(): any;
|
||||
onWidthChange(nextProps: any): void;
|
||||
render(): JSX.Element | null;
|
||||
}
|
||||
|
||||
namespace Responsive {
|
||||
namespace utils {
|
||||
function findOrGenerateResponsiveLayout(layouts: {}, breakpoints: {}, breakpoint: number, lastBreakpoint: number, cols: {}, verticalCompact: boolean): any;
|
||||
function getBreakpointFromWidth(breakpoints: {}, width: number): any;
|
||||
function getColsFromBreakpoint(breakpoint: number, cols: {}): any;
|
||||
function sortBreakpoints(breakpoints: {}): any;
|
||||
}
|
||||
}
|
||||
|
||||
namespace utils {
|
||||
function autoBindHandlers(el: any, fns: any): any;
|
||||
function bottom(layout: any): any;
|
||||
function childrenEqual(a: any, b: any): any;
|
||||
function cloneLayout(layout: any): any;
|
||||
function cloneLayoutItem(layoutItem: any): any;
|
||||
function collides(l1: any, l2: any): any;
|
||||
function compact(layout: any, verticalCompact: any): any;
|
||||
function compactItem(compareWith: any, l: any, verticalCompact: any): any;
|
||||
function correctBounds(layout: any, bounds: any): any;
|
||||
function getAllCollisions(layout: any, layoutItem: any): any;
|
||||
function getFirstCollision(layout: any, layoutItem: any): any;
|
||||
function getLayoutItem(layout: any, id: any): any;
|
||||
function getStatics(layout: any): any;
|
||||
function moveElement(layout: any, l: any, x: any, y: any, isUserAction: any): any;
|
||||
function moveElementAwayFromCollision(layout: any, collidesWith: any, itemToMove: any, isUserAction: any): any;
|
||||
function perc(num: any): any;
|
||||
function setTopLeft(_ref2: any): any;
|
||||
function setTransform(_ref: any): any;
|
||||
function sortLayoutItemsByRowCol(layout: any): any;
|
||||
function synchronizeLayoutWithChildren(initialLayout: any, children: any, cols: any, verticalCompact: any): any;
|
||||
function validateLayout(layout: any, contextName: any): void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactGridLayout from 'react-grid-layout';
|
||||
|
||||
const ReactGridLayoutResponsive = ReactGridLayout.Responsive;
|
||||
const ReactGridLayoutResponsiveWidth = ReactGridLayout.WidthProvider(ReactGridLayout.Responsive);
|
||||
|
||||
class DefaultGridTest extends React.Component<any, any> {
|
||||
render() {
|
||||
const layout = [
|
||||
{i: 'a', x: 0, y: 0, w: 1, h: 2, static: true},
|
||||
{i: 'b', x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4},
|
||||
{i: 'c', x: 4, y: 0, w: 1, h: 2}
|
||||
];
|
||||
|
||||
return (
|
||||
<ReactGridLayout
|
||||
cols={12}
|
||||
rowHeight={30}
|
||||
width={1200}
|
||||
layout={layout}
|
||||
autoSize={true}
|
||||
verticalCompact={true}
|
||||
>
|
||||
<div key={'a'}>a</div>
|
||||
<div key={'b'}>b</div>
|
||||
<div key={'c'}>c</div>
|
||||
</ReactGridLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ResponsiveGridTest extends React.Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<ReactGridLayoutResponsive
|
||||
width={800}
|
||||
breakpoints={{lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0}}
|
||||
cols={{lg: 12, md: 10, sm: 6, xs: 4, xxs: 2}}
|
||||
>
|
||||
<div key="1">a</div>
|
||||
<div key="2">b</div>
|
||||
<div key="3">c</div>
|
||||
</ReactGridLayoutResponsive>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ResponsiveGridWidthProviderTest extends React.Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<ReactGridLayoutResponsiveWidth
|
||||
breakpoints={{lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0}}
|
||||
cols={{lg: 12, md: 10, sm: 6, xs: 4, xxs: 2}}
|
||||
>
|
||||
<div key="1">a</div>
|
||||
<div key="2">b</div>
|
||||
<div key="3">c</div>
|
||||
</ReactGridLayoutResponsiveWidth>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-grid-layout-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user