Completely updated React, fixed #11, (hopefully)
This commit is contained in:
145
goTorrentWebUI/node_modules/react-grid-layout/build/ReactGridLayout.js
generated
vendored
145
goTorrentWebUI/node_modules/react-grid-layout/build/ReactGridLayout.js
generated
vendored
@@ -1,28 +1,28 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
var _react = require('react');
|
||||
var _react = require("react");
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
var _propTypes = require("prop-types");
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _lodash = require('lodash.isequal');
|
||||
var _lodash = require("lodash.isequal");
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _classnames = require('classnames');
|
||||
var _classnames = require("classnames");
|
||||
|
||||
var _classnames2 = _interopRequireDefault(_classnames);
|
||||
|
||||
var _utils = require('./utils');
|
||||
var _utils = require("./utils");
|
||||
|
||||
var _GridItem = require('./GridItem');
|
||||
var _GridItem = require("./GridItem");
|
||||
|
||||
var _GridItem2 = _interopRequireDefault(_GridItem);
|
||||
|
||||
@@ -34,16 +34,13 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
// Types
|
||||
|
||||
// End Types
|
||||
|
||||
/**
|
||||
* A reactive, fluid grid layout with draggable, resizable components.
|
||||
*/
|
||||
|
||||
// Types
|
||||
var ReactGridLayout = function (_React$Component) {
|
||||
_inherits(ReactGridLayout, _React$Component);
|
||||
|
||||
@@ -55,7 +52,7 @@ var ReactGridLayout = function (_React$Component) {
|
||||
|
||||
_initialiseProps.call(_this);
|
||||
|
||||
(0, _utils.autoBindHandlers)(_this, ['onDragStart', 'onDrag', 'onDragStop', 'onResizeStart', 'onResize', 'onResizeStop']);
|
||||
(0, _utils.autoBindHandlers)(_this, ["onDragStart", "onDrag", "onDragStop", "onResizeStart", "onResize", "onResizeStop"]);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -72,15 +69,13 @@ var ReactGridLayout = function (_React$Component) {
|
||||
// Allow parent to set layout directly.
|
||||
if (!(0, _lodash2.default)(nextProps.layout, this.props.layout) || nextProps.compactType !== this.props.compactType) {
|
||||
newLayoutBase = nextProps.layout;
|
||||
} else if (!(0, _utils.childrenEqual)(this.props.children, nextProps.children)) {
|
||||
// If children change, also regenerate the layout. Use our state
|
||||
// as the base in case because it may be more up to date than
|
||||
// what is in props.
|
||||
newLayoutBase = this.state.layout;
|
||||
}
|
||||
|
||||
// If children change, also regenerate the layout. Use our state
|
||||
// as the base in case because it may be more up to date than
|
||||
// what is in props.
|
||||
else if (!(0, _utils.childrenEqual)(this.props.children, nextProps.children)) {
|
||||
newLayoutBase = this.state.layout;
|
||||
}
|
||||
|
||||
// We need to regenerate the layout.
|
||||
if (newLayoutBase) {
|
||||
var newLayout = (0, _utils.synchronizeLayoutWithChildren)(newLayoutBase, nextProps.children, nextProps.cols, this.compactType(nextProps));
|
||||
@@ -100,7 +95,7 @@ var ReactGridLayout = function (_React$Component) {
|
||||
if (!this.props.autoSize) return;
|
||||
var nbRow = (0, _utils.bottom)(this.state.layout);
|
||||
var containerPaddingY = this.props.containerPadding ? this.props.containerPadding[1] : this.props.margin[1];
|
||||
return nbRow * this.props.rowHeight + (nbRow - 1) * this.props.margin[1] + containerPaddingY * 2 + 'px';
|
||||
return nbRow * this.props.rowHeight + (nbRow - 1) * this.props.margin[1] + containerPaddingY * 2 + "px";
|
||||
};
|
||||
|
||||
ReactGridLayout.prototype.compactType = function compactType(props) {
|
||||
@@ -126,9 +121,12 @@ var ReactGridLayout = function (_React$Component) {
|
||||
var l = (0, _utils.getLayoutItem)(layout, i);
|
||||
if (!l) return;
|
||||
|
||||
this.setState({ oldDragItem: (0, _utils.cloneLayoutItem)(l), oldLayout: this.state.layout });
|
||||
this.setState({
|
||||
oldDragItem: (0, _utils.cloneLayoutItem)(l),
|
||||
oldLayout: this.state.layout
|
||||
});
|
||||
|
||||
this.props.onDragStart(layout, l, l, null, e, node);
|
||||
return this.props.onDragStart(layout, l, l, null, e, node);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -153,7 +151,12 @@ var ReactGridLayout = function (_React$Component) {
|
||||
|
||||
// Create placeholder (display only)
|
||||
var placeholder = {
|
||||
w: l.w, h: l.h, x: l.x, y: l.y, placeholder: true, i: i
|
||||
w: l.w,
|
||||
h: l.h,
|
||||
x: l.x,
|
||||
y: l.y,
|
||||
placeholder: true,
|
||||
i: i
|
||||
};
|
||||
|
||||
// Move the element to the dragged location.
|
||||
@@ -246,18 +249,44 @@ var ReactGridLayout = function (_React$Component) {
|
||||
var l = (0, _utils.getLayoutItem)(layout, i);
|
||||
if (!l) return;
|
||||
|
||||
// Short circuit if there is a collision in no rearrangement mode.
|
||||
if (preventCollision && (0, _utils.getFirstCollision)(layout, _extends({}, l, { w: w, h: h }))) {
|
||||
return;
|
||||
// Something like quad tree should be used
|
||||
// to find collisions faster
|
||||
var hasCollisions = void 0;
|
||||
if (preventCollision) {
|
||||
var collisions = (0, _utils.getAllCollisions)(layout, _extends({}, l, { w: w, h: h })).filter(function (layoutItem) {
|
||||
return layoutItem.i !== l.i;
|
||||
});
|
||||
hasCollisions = collisions.length > 0;
|
||||
|
||||
// If we're colliding, we need adjust the placeholder.
|
||||
if (hasCollisions) {
|
||||
// adjust w && h to maximum allowed space
|
||||
var leastX = Infinity,
|
||||
leastY = Infinity;
|
||||
collisions.forEach(function (layoutItem) {
|
||||
if (layoutItem.x > l.x) leastX = Math.min(leastX, layoutItem.x);
|
||||
if (layoutItem.y > l.y) leastY = Math.min(leastY, layoutItem.y);
|
||||
});
|
||||
|
||||
if (Number.isFinite(leastX)) l.w = leastX - l.x;
|
||||
if (Number.isFinite(leastY)) l.h = leastY - l.y;
|
||||
}
|
||||
}
|
||||
|
||||
// Set new width and height.
|
||||
l.w = w;
|
||||
l.h = h;
|
||||
if (!hasCollisions) {
|
||||
// Set new width and height.
|
||||
l.w = w;
|
||||
l.h = h;
|
||||
}
|
||||
|
||||
// Create placeholder element (display only)
|
||||
var placeholder = {
|
||||
w: w, h: h, x: l.x, y: l.y, static: true, i: i
|
||||
w: l.w,
|
||||
h: l.h,
|
||||
x: l.x,
|
||||
y: l.y,
|
||||
static: true,
|
||||
i: i
|
||||
};
|
||||
|
||||
this.props.onResize(layout, oldResizeItem, l, placeholder, e, node);
|
||||
@@ -324,7 +353,7 @@ var ReactGridLayout = function (_React$Component) {
|
||||
x: activeDrag.x,
|
||||
y: activeDrag.y,
|
||||
i: activeDrag.i,
|
||||
className: 'react-grid-placeholder',
|
||||
className: "react-grid-placeholder",
|
||||
containerWidth: width,
|
||||
cols: cols,
|
||||
margin: margin,
|
||||
@@ -333,8 +362,9 @@ var ReactGridLayout = function (_React$Component) {
|
||||
rowHeight: rowHeight,
|
||||
isDraggable: false,
|
||||
isResizable: false,
|
||||
useCSSTransforms: useCSSTransforms },
|
||||
_react2.default.createElement('div', null)
|
||||
useCSSTransforms: useCSSTransforms
|
||||
},
|
||||
_react2.default.createElement("div", null)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -346,7 +376,7 @@ var ReactGridLayout = function (_React$Component) {
|
||||
|
||||
|
||||
ReactGridLayout.prototype.processGridItem = function processGridItem(child) {
|
||||
if (!child.key) return;
|
||||
if (!child || !child.key) return;
|
||||
var l = (0, _utils.getLayoutItem)(this.state.layout, String(child.key));
|
||||
if (!l) return null;
|
||||
var _props4 = this.props,
|
||||
@@ -389,7 +419,6 @@ var ReactGridLayout = function (_React$Component) {
|
||||
isResizable: resizable,
|
||||
useCSSTransforms: useCSSTransforms && mounted,
|
||||
usePercentages: !mounted,
|
||||
|
||||
w: l.w,
|
||||
h: l.h,
|
||||
x: l.x,
|
||||
@@ -399,7 +428,7 @@ var ReactGridLayout = function (_React$Component) {
|
||||
minW: l.minW,
|
||||
maxH: l.maxH,
|
||||
maxW: l.maxW,
|
||||
'static': l.static
|
||||
"static": l.static
|
||||
},
|
||||
child
|
||||
);
|
||||
@@ -413,15 +442,14 @@ var ReactGridLayout = function (_React$Component) {
|
||||
style = _props5.style;
|
||||
|
||||
|
||||
var mergedClassName = (0, _classnames2.default)("react-grid-layout", className);
|
||||
var mergedStyle = _extends({
|
||||
height: this.containerHeight()
|
||||
}, style);
|
||||
|
||||
return _react2.default.createElement(
|
||||
'div',
|
||||
{ className: (0, _classnames2.default)('react-grid-layout', className), style: mergedStyle },
|
||||
|
||||
// $FlowIgnore: Appears to think map calls back w/array
|
||||
"div",
|
||||
{ className: mergedClassName, style: mergedStyle },
|
||||
_react2.default.Children.map(this.props.children, function (child) {
|
||||
return _this2.processGridItem(child);
|
||||
}),
|
||||
@@ -457,13 +485,14 @@ ReactGridLayout.propTypes = {
|
||||
|
||||
// Deprecated
|
||||
verticalCompact: function verticalCompact(props) {
|
||||
if (props.verticalCompact === false && process.env.NODE_ENV !== 'production') {
|
||||
console.warn( // eslint-disable-line no-console
|
||||
'`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. ' + 'Use `compactType`: "horizontal" | "vertical" | null.');
|
||||
if (props.verticalCompact === false && process.env.NODE_ENV !== "production") {
|
||||
console.warn(
|
||||
// eslint-disable-line no-console
|
||||
"`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. " + 'Use `compactType`: "horizontal" | "vertical" | null.');
|
||||
}
|
||||
},
|
||||
// Choose vertical or hotizontal compaction
|
||||
compactType: _propTypes2.default.oneOf(['vertical', 'horizontal']),
|
||||
compactType: _propTypes2.default.oneOf(["vertical", "horizontal"]),
|
||||
|
||||
// layout is an array of object with the format:
|
||||
// {x: Number, y: Number, w: Number, h: Number, i: String}
|
||||
@@ -471,7 +500,7 @@ ReactGridLayout.propTypes = {
|
||||
var layout = props.layout;
|
||||
// I hope you're setting the data-grid property on the grid items
|
||||
if (layout === undefined) return;
|
||||
(0, _utils.validateLayout)(layout, 'layout');
|
||||
(0, _utils.validateLayout)(layout, "layout");
|
||||
},
|
||||
|
||||
//
|
||||
@@ -527,14 +556,14 @@ ReactGridLayout.propTypes = {
|
||||
//
|
||||
|
||||
// Children must not have duplicate keys.
|
||||
children: function children(props, propName, _componentName) {
|
||||
children: function children(props, propName) {
|
||||
var children = props[propName];
|
||||
|
||||
// Check children keys for duplicates. Throw if found.
|
||||
var keys = {};
|
||||
_react2.default.Children.forEach(children, function (child) {
|
||||
if (keys[child.key]) {
|
||||
throw new Error("Duplicate child key \"" + child.key + "\" found! This will cause problems in ReactGridLayout.");
|
||||
throw new Error('Duplicate child key "' + child.key + '" found! This will cause problems in ReactGridLayout.');
|
||||
}
|
||||
keys[child.key] = true;
|
||||
});
|
||||
@@ -543,7 +572,11 @@ ReactGridLayout.propTypes = {
|
||||
ReactGridLayout.defaultProps = {
|
||||
autoSize: true,
|
||||
cols: 12,
|
||||
className: '',
|
||||
className: "",
|
||||
style: {},
|
||||
draggableHandle: "",
|
||||
draggableCancel: "",
|
||||
containerPadding: null,
|
||||
rowHeight: 150,
|
||||
maxRows: Infinity, // infinite vertical growth
|
||||
layout: [],
|
||||
@@ -552,15 +585,15 @@ ReactGridLayout.defaultProps = {
|
||||
isResizable: true,
|
||||
useCSSTransforms: true,
|
||||
verticalCompact: true,
|
||||
compactType: 'vertical',
|
||||
compactType: "vertical",
|
||||
preventCollision: false,
|
||||
onLayoutChange: noop,
|
||||
onDragStart: noop,
|
||||
onDrag: noop,
|
||||
onDragStop: noop,
|
||||
onResizeStart: noop,
|
||||
onResize: noop,
|
||||
onResizeStop: noop
|
||||
onLayoutChange: _utils.noop,
|
||||
onDragStart: _utils.noop,
|
||||
onDrag: _utils.noop,
|
||||
onDragStop: _utils.noop,
|
||||
onResizeStart: _utils.noop,
|
||||
onResize: _utils.noop,
|
||||
onResizeStop: _utils.noop
|
||||
};
|
||||
|
||||
var _initialiseProps = function _initialiseProps() {
|
||||
|
Reference in New Issue
Block a user