mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Fix react-grid-layout Type Definition (#18433)
+ each property of `Layouts` should be in shape of `Layout[]`
+ Refs:
+ https://github.com/STRML/react-grid-layout/blob/master/test/examples/0-showcase.jsx#L55
+ https://github.com/STRML/react-grid-layout/blob/master/test/examples/0-showcase.jsx#L84
+ https://github.com/STRML/react-grid-layout/blob/master/lib/responsiveUtils.js#L71
+ https://github.com/STRML/react-grid-layout/blob/master/lib/utils.js#L39
This commit is contained in:
8
types/react-grid-layout/index.d.ts
vendored
8
types/react-grid-layout/index.d.ts
vendored
@@ -1,6 +1,8 @@
|
||||
// Type definitions for react-grid-layout 0.14
|
||||
// Project: https://github.com/STRML/react-grid-layout
|
||||
// Definitions by: Andrew Birkholz <https://github.com/abirkholz>, Ali Taheri <https://github.com/alitaheri>
|
||||
// Definitions by: Andrew Birkholz <https://github.com/abirkholz>,
|
||||
// Ali Taheri <https://github.com/alitaheri>,
|
||||
// Zheyang Song <https://github.com/ZheyangSong>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -78,7 +80,7 @@ declare namespace ReactGridLayout {
|
||||
}
|
||||
|
||||
type Layouts = {
|
||||
[P in Breakpoints]: Layout;
|
||||
[P in Breakpoints]?: Layout[];
|
||||
};
|
||||
|
||||
type ItemCallback = (
|
||||
@@ -250,7 +252,7 @@ declare namespace ReactGridLayout {
|
||||
/**
|
||||
* layouts is an object mapping breakpoints to layouts.
|
||||
*
|
||||
* e.g. `{lg: Layout, md: Layout, ...}`
|
||||
* e.g. `{lg: Layout[], md: Layout[], ...}`
|
||||
*/
|
||||
layouts?: Layouts;
|
||||
|
||||
|
||||
@@ -31,8 +31,17 @@ class DefaultGridTest extends React.Component {
|
||||
|
||||
class ResponsiveGridTest extends React.Component {
|
||||
render() {
|
||||
const layouts = {
|
||||
lg: [
|
||||
{ i: '1', x: 0, y: 0, w: 1, h: 2, static: true },
|
||||
{ i: '2', x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 },
|
||||
{ i: '3', x: 4, y: 0, w: 1, h: 2 }
|
||||
]
|
||||
};
|
||||
|
||||
return (
|
||||
<Responsive
|
||||
layouts={layouts}
|
||||
width={800}
|
||||
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
|
||||
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
|
||||
|
||||
Reference in New Issue
Block a user