Completely updated React, fixed #11, (hopefully)
This commit is contained in:
57
goTorrentWebUI/node_modules/react-grid-layout/build/responsiveUtils.js.flow
generated
vendored
57
goTorrentWebUI/node_modules/react-grid-layout/build/responsiveUtils.js.flow
generated
vendored
@@ -1,11 +1,26 @@
|
||||
// @flow
|
||||
|
||||
import {cloneLayout, compact, correctBounds} from './utils';
|
||||
import { cloneLayout, compact, correctBounds } from "./utils";
|
||||
|
||||
import type { CompactType, Layout } from "./utils";
|
||||
|
||||
export type ResponsiveLayout = {
|
||||
lg?: Layout,
|
||||
md?: Layout,
|
||||
sm?: Layout,
|
||||
xs?: Layout,
|
||||
xxs?: Layout
|
||||
};
|
||||
|
||||
import type {CompactType, Layout} from './utils';
|
||||
export type ResponsiveLayout = {lg?: Layout, md?: Layout, sm?: Layout, xs?: Layout, xxs?: Layout};
|
||||
type Breakpoint = string;
|
||||
type Breakpoints = {lg?: number, md?: number, sm?: number, xs?: number, xxs?: number};
|
||||
|
||||
type Breakpoints = {
|
||||
lg?: number,
|
||||
md?: number,
|
||||
sm?: number,
|
||||
xs?: number,
|
||||
xxs?: number
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a width, find the highest breakpoint that matches is valid for it (width > breakpoint).
|
||||
@@ -14,7 +29,10 @@ type Breakpoints = {lg?: number, md?: number, sm?: number, xs?: number, xxs?: nu
|
||||
* @param {Number} width Screen width.
|
||||
* @return {String} Highest breakpoint that is less than width.
|
||||
*/
|
||||
export function getBreakpointFromWidth(breakpoints: Breakpoints, width: number): Breakpoint {
|
||||
export function getBreakpointFromWidth(
|
||||
breakpoints: Breakpoints,
|
||||
width: number
|
||||
): Breakpoint {
|
||||
const sorted = sortBreakpoints(breakpoints);
|
||||
let matching = sorted[0];
|
||||
for (let i = 1, len = sorted.length; i < len; i++) {
|
||||
@@ -24,16 +42,22 @@ export function getBreakpointFromWidth(breakpoints: Breakpoints, width: number):
|
||||
return matching;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given a breakpoint, get the # of cols set for it.
|
||||
* @param {String} breakpoint Breakpoint name.
|
||||
* @param {Object} cols Map of breakpoints to cols.
|
||||
* @return {Number} Number of cols.
|
||||
*/
|
||||
export function getColsFromBreakpoint(breakpoint: Breakpoint, cols: Breakpoints): number {
|
||||
export function getColsFromBreakpoint(
|
||||
breakpoint: Breakpoint,
|
||||
cols: Breakpoints
|
||||
): number {
|
||||
if (!cols[breakpoint]) {
|
||||
throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint " + breakpoint + " is missing!");
|
||||
throw new Error(
|
||||
"ResponsiveReactGridLayout: `cols` entry for breakpoint " +
|
||||
breakpoint +
|
||||
" is missing!"
|
||||
);
|
||||
}
|
||||
return cols[breakpoint];
|
||||
}
|
||||
@@ -52,15 +76,22 @@ export function getColsFromBreakpoint(breakpoint: Breakpoint, cols: Breakpoints)
|
||||
* vertically.
|
||||
* @return {Array} New layout.
|
||||
*/
|
||||
export function findOrGenerateResponsiveLayout(layouts: ResponsiveLayout, breakpoints: Breakpoints,
|
||||
breakpoint: Breakpoint, lastBreakpoint: Breakpoint,
|
||||
cols: number, compactType: CompactType): Layout {
|
||||
export function findOrGenerateResponsiveLayout(
|
||||
layouts: ResponsiveLayout,
|
||||
breakpoints: Breakpoints,
|
||||
breakpoint: Breakpoint,
|
||||
lastBreakpoint: Breakpoint,
|
||||
cols: number,
|
||||
compactType: CompactType
|
||||
): Layout {
|
||||
// If it already exists, just return it.
|
||||
if (layouts[breakpoint]) return cloneLayout(layouts[breakpoint]);
|
||||
// Find or generate the next layout
|
||||
let layout = layouts[lastBreakpoint];
|
||||
const breakpointsSorted = sortBreakpoints(breakpoints);
|
||||
const breakpointsAbove = breakpointsSorted.slice(breakpointsSorted.indexOf(breakpoint));
|
||||
const breakpointsAbove = breakpointsSorted.slice(
|
||||
breakpointsSorted.indexOf(breakpoint)
|
||||
);
|
||||
for (let i = 0, len = breakpointsAbove.length; i < len; i++) {
|
||||
const b = breakpointsAbove[i];
|
||||
if (layouts[b]) {
|
||||
@@ -69,7 +100,7 @@ export function findOrGenerateResponsiveLayout(layouts: ResponsiveLayout, breakp
|
||||
}
|
||||
}
|
||||
layout = cloneLayout(layout || []); // clone layout so we don't modify existing items
|
||||
return compact(correctBounds(layout, {cols: cols}), compactType, cols);
|
||||
return compact(correctBounds(layout, { cols: cols }), compactType, cols);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user