react-grid-layout 1.2.4 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.js +3 -2
- package/.eslintignore +3 -0
- package/.flowconfig +1 -3
- package/.prettierignore +1 -0
- package/CHANGELOG.md +371 -236
- package/README.md +122 -62
- package/build/GridItem.js +12 -12
- package/build/ReactGridLayout.js +306 -325
- package/build/ReactGridLayoutPropTypes.js +11 -5
- package/build/ResponsiveReactGridLayout.js +16 -10
- package/build/calculateUtils.js +8 -8
- package/build/components/WidthProvider.js +11 -9
- package/build/fastRGLPropsEqual.js +1 -1
- package/build/responsiveUtils.js +1 -1
- package/build/utils.js +48 -53
- package/coverage/clover.xml +761 -0
- package/coverage/coverage-final.json +15 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/react-grid-layout/index-dev.js.html +104 -0
- package/coverage/lcov-report/react-grid-layout/lib/GridItem.jsx.html +2099 -0
- package/coverage/lcov-report/react-grid-layout/lib/ReactGridLayout.jsx.html +2453 -0
- package/coverage/lcov-report/react-grid-layout/lib/ReactGridLayoutPropTypes.js.html +833 -0
- package/coverage/lcov-report/react-grid-layout/lib/ResponsiveReactGridLayout.jsx.html +1133 -0
- package/coverage/lcov-report/react-grid-layout/lib/calculateUtils.js.html +557 -0
- package/coverage/lcov-report/react-grid-layout/lib/components/WidthProvider.jsx.html +410 -0
- package/coverage/lcov-report/react-grid-layout/lib/fastRGLPropsEqual.js.html +224 -0
- package/coverage/lcov-report/react-grid-layout/lib/responsiveUtils.js.html +440 -0
- package/coverage/lcov-report/react-grid-layout/lib/utils.js.html +2456 -0
- package/coverage/lcov-report/react-grid-layout/test/examples/0-showcase.jsx.html +521 -0
- package/coverage/lcov-report/react-grid-layout/test/examples/1-basic.jsx.html +284 -0
- package/coverage/lcov-report/react-grid-layout/test/examples/15-drag-from-outside.jsx.html +506 -0
- package/coverage/lcov-report/react-grid-layout/test/util/deepFreeze.js.html +248 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +1584 -0
- package/dist/react-grid-layout.min.js +1 -2
- package/dist/react-grid-layout.min.js.map +1 -1
- package/index.js +4 -2
- package/lib/GridItem.jsx +15 -10
- package/lib/ReactGridLayout.jsx +101 -62
- package/lib/ReactGridLayoutPropTypes.js +38 -17
- package/lib/ResponsiveReactGridLayout.jsx +7 -1
- package/lib/components/WidthProvider.jsx +2 -2
- package/lib/utils.js +45 -40
- package/package.json +48 -34
- package/.husky/pre-commit +0 -6
- package/.travis.yml +0 -9
- package/dist/react-grid-layout.min.js.LICENSE.txt +0 -5
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.resizeHandleType = exports.resizeHandleAxesType = exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
@@ -21,12 +21,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
// 'nw' - Northwest handle (top-left)
|
|
22
22
|
// 'se' - Southeast handle (bottom-right)
|
|
23
23
|
// 'ne' - Northeast handle (top-right)
|
|
24
|
-
var
|
|
24
|
+
var resizeHandleAxesType
|
|
25
25
|
/*: ReactPropsChainableTypeChecker*/
|
|
26
26
|
= _propTypes.default.arrayOf(_propTypes.default.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"])); // Custom component for resize handles
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
exports.
|
|
29
|
+
exports.resizeHandleAxesType = resizeHandleAxesType;
|
|
30
30
|
|
|
31
31
|
var resizeHandleType
|
|
32
32
|
/*: ReactPropsChainableTypeChecker*/
|
|
@@ -54,8 +54,9 @@ var resizeHandleType
|
|
|
54
54
|
useCSSTransforms: boolean,
|
|
55
55
|
transformScale: number,
|
|
56
56
|
droppingItem: $Shape<LayoutItem>,
|
|
57
|
-
resizeHandles:
|
|
57
|
+
resizeHandles: ResizeHandleAxis[],
|
|
58
58
|
resizeHandle?: ResizeHandle,
|
|
59
|
+
allowOverlap: boolean,
|
|
59
60
|
|
|
60
61
|
// Callbacks
|
|
61
62
|
onLayoutChange: Layout => void,
|
|
@@ -65,6 +66,7 @@ var resizeHandleType
|
|
|
65
66
|
onResize: EventCallback,
|
|
66
67
|
onResizeStart: EventCallback,
|
|
67
68
|
onResizeStop: EventCallback,
|
|
69
|
+
onDropDragOver: (e: DragOverEvent) => ?({| w?: number, h?: number |} | false),
|
|
68
70
|
onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void,
|
|
69
71
|
children: ReactChildrenArray<ReactElement<any>>,
|
|
70
72
|
innerRef?: Ref<"div">
|
|
@@ -147,6 +149,8 @@ var _default = {
|
|
|
147
149
|
isBounded: _propTypes.default.bool,
|
|
148
150
|
isDraggable: _propTypes.default.bool,
|
|
149
151
|
isResizable: _propTypes.default.bool,
|
|
152
|
+
// If true, grid can be placed one over the other.
|
|
153
|
+
allowOverlap: _propTypes.default.bool,
|
|
150
154
|
// If true, grid items won't change position when being dragged over.
|
|
151
155
|
preventCollision: _propTypes.default.bool,
|
|
152
156
|
// Use CSS transforms instead of top/left
|
|
@@ -156,7 +160,7 @@ var _default = {
|
|
|
156
160
|
// If true, an external element can trigger onDrop callback with a specific grid position as a parameter
|
|
157
161
|
isDroppable: _propTypes.default.bool,
|
|
158
162
|
// Resize handle options
|
|
159
|
-
resizeHandles:
|
|
163
|
+
resizeHandles: resizeHandleAxesType,
|
|
160
164
|
resizeHandle: resizeHandleType,
|
|
161
165
|
//
|
|
162
166
|
// Callbacks
|
|
@@ -199,6 +203,8 @@ var _default = {
|
|
|
199
203
|
var keys = {};
|
|
200
204
|
|
|
201
205
|
_react.default.Children.forEach(children, function (child) {
|
|
206
|
+
if ((child === null || child === void 0 ? void 0 : child.key) == null) return;
|
|
207
|
+
|
|
202
208
|
if (keys[child.key]) {
|
|
203
209
|
throw new Error('Duplicate child key "' + child.key + '" found! This will cause problems in ReactGridLayout.');
|
|
204
210
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -19,11 +19,13 @@ var _responsiveUtils = require("./responsiveUtils");
|
|
|
19
19
|
|
|
20
20
|
var _ReactGridLayout = _interopRequireDefault(require("./ReactGridLayout"));
|
|
21
21
|
|
|
22
|
+
var _excluded = ["breakpoint", "breakpoints", "cols", "layouts", "margin", "containerPadding", "onBreakpointChange", "onLayoutChange", "onWidthChange"];
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
27
|
|
|
26
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
28
30
|
function _extends() { _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; }; return _extends.apply(this, arguments); }
|
|
29
31
|
|
|
@@ -31,23 +33,23 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
31
33
|
|
|
32
34
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
33
35
|
|
|
34
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
36
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
37
|
|
|
36
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
38
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
39
|
|
|
38
40
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
39
41
|
|
|
40
42
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
41
43
|
|
|
42
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
44
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
43
45
|
|
|
44
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass
|
|
46
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
45
47
|
|
|
46
48
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
47
49
|
|
|
48
50
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
49
51
|
|
|
50
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
52
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
51
53
|
|
|
52
54
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
53
55
|
|
|
@@ -57,6 +59,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
57
59
|
|
|
58
60
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
59
61
|
|
|
62
|
+
// $FlowFixMe[method-unbinding]
|
|
60
63
|
var type = function type(obj) {
|
|
61
64
|
return Object.prototype.toString.call(obj);
|
|
62
65
|
};
|
|
@@ -117,6 +120,7 @@ function getIndentationValue
|
|
|
117
120
|
/*:: type DefaultProps = Pick<
|
|
118
121
|
Props<>,
|
|
119
122
|
{|
|
|
123
|
+
allowOverlap: 0,
|
|
120
124
|
breakpoints: 0,
|
|
121
125
|
cols: 0,
|
|
122
126
|
containerPadding: 0,
|
|
@@ -220,7 +224,7 @@ var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
220
224
|
|
|
221
225
|
var layout = (0, _responsiveUtils.findOrGenerateResponsiveLayout)(newLayouts, breakpoints, newBreakpoint, lastBreakpoint, newCols, compactType); // This adds missing items.
|
|
222
226
|
|
|
223
|
-
layout = (0, _utils.synchronizeLayoutWithChildren)(layout, this.props.children, newCols, compactType); // Store the new layout.
|
|
227
|
+
layout = (0, _utils.synchronizeLayoutWithChildren)(layout, this.props.children, newCols, compactType, this.props.allowOverlap); // Store the new layout.
|
|
224
228
|
|
|
225
229
|
newLayouts[newBreakpoint] = layout; // callbacks
|
|
226
230
|
|
|
@@ -254,7 +258,7 @@ var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
254
258
|
onBreakpointChange = _this$props3.onBreakpointChange,
|
|
255
259
|
onLayoutChange = _this$props3.onLayoutChange,
|
|
256
260
|
onWidthChange = _this$props3.onWidthChange,
|
|
257
|
-
other = _objectWithoutProperties(_this$props3,
|
|
261
|
+
other = _objectWithoutProperties(_this$props3, _excluded);
|
|
258
262
|
/* eslint-enable no-unused-vars */
|
|
259
263
|
|
|
260
264
|
|
|
@@ -307,6 +311,7 @@ _defineProperty(ResponsiveReactGridLayout, "propTypes", {
|
|
|
307
311
|
breakpoint: _propTypes.default.string,
|
|
308
312
|
// {name: pxVal}, e.g. {lg: 1200, md: 996, sm: 768, xs: 480}
|
|
309
313
|
breakpoints: _propTypes.default.object,
|
|
314
|
+
allowOverlap: _propTypes.default.bool,
|
|
310
315
|
// # of cols. This is a breakpoint -> cols map
|
|
311
316
|
cols: _propTypes.default.object,
|
|
312
317
|
// # of margin. This is a breakpoint -> margin map
|
|
@@ -377,6 +382,7 @@ _defineProperty(ResponsiveReactGridLayout, "defaultProps", {
|
|
|
377
382
|
},
|
|
378
383
|
layouts: {},
|
|
379
384
|
margin: [10, 10],
|
|
385
|
+
allowOverlap: false,
|
|
380
386
|
onBreakpointChange: _utils.noop,
|
|
381
387
|
onLayoutChange: _utils.noop,
|
|
382
388
|
onWidthChange: _utils.noop
|
package/build/calculateUtils.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calcGridColWidth = calcGridColWidth;
|
|
7
|
-
exports.calcGridItemWHPx = calcGridItemWHPx;
|
|
8
7
|
exports.calcGridItemPosition = calcGridItemPosition;
|
|
9
|
-
exports.
|
|
8
|
+
exports.calcGridItemWHPx = calcGridItemWHPx;
|
|
10
9
|
exports.calcWH = calcWH;
|
|
10
|
+
exports.calcXY = calcXY;
|
|
11
11
|
exports.clamp = clamp;
|
|
12
12
|
|
|
13
13
|
/*:: import type { Position } from "./utils";*/
|
|
@@ -88,9 +88,9 @@ function calcGridItemPosition(positionParams
|
|
|
88
88
|
out.height = Math.round(state.resizing.height);
|
|
89
89
|
} // Otherwise, calculate from grid units.
|
|
90
90
|
else {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
out.width = calcGridItemWHPx(w, colWidth, margin[0]);
|
|
92
|
+
out.height = calcGridItemWHPx(h, rowHeight, margin[1]);
|
|
93
|
+
} // If dragging, use the exact width and height as returned from dragging callbacks.
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
if (state && state.dragging) {
|
|
@@ -98,9 +98,9 @@ function calcGridItemPosition(positionParams
|
|
|
98
98
|
out.left = Math.round(state.dragging.left);
|
|
99
99
|
} // Otherwise, calculate from grid units.
|
|
100
100
|
else {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
out.top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
|
|
102
|
+
out.left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
|
|
103
|
+
}
|
|
104
104
|
|
|
105
105
|
return out;
|
|
106
106
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -11,13 +11,15 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
|
+
|
|
16
|
+
var _excluded = ["measureBeforeMount"];
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
21
|
|
|
20
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
23
|
|
|
22
24
|
function _extends() { _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; }; return _extends.apply(this, arguments); }
|
|
23
25
|
|
|
@@ -29,15 +31,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
29
31
|
|
|
30
32
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
33
|
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
34
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
35
|
|
|
34
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass
|
|
36
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
37
|
|
|
36
38
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
39
|
|
|
38
40
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
39
41
|
|
|
40
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
42
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
41
43
|
|
|
42
44
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
45
|
|
|
@@ -125,11 +127,11 @@ function WidthProvideRGL
|
|
|
125
127
|
value: function render() {
|
|
126
128
|
var _this$props = this.props,
|
|
127
129
|
measureBeforeMount = _this$props.measureBeforeMount,
|
|
128
|
-
rest = _objectWithoutProperties(_this$props,
|
|
130
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
129
131
|
|
|
130
132
|
if (measureBeforeMount && !this.mounted) {
|
|
131
133
|
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
-
className: (0,
|
|
134
|
+
className: (0, _clsx.default)(this.props.className, layoutClassName),
|
|
133
135
|
style: this.props.style // $FlowIgnore ref types
|
|
134
136
|
,
|
|
135
137
|
ref: this.elementRef
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// this file was prevaled
|
|
2
2
|
module.exports = function fastRGLPropsEqual(a, b, isEqualImpl) {
|
|
3
3
|
if (a === b) return true;
|
|
4
|
-
return a.className === b.className && isEqualImpl(a.style, b.style) && a.width === b.width && a.autoSize === b.autoSize && a.cols === b.cols && a.draggableCancel === b.draggableCancel && a.draggableHandle === b.draggableHandle && isEqualImpl(a.verticalCompact, b.verticalCompact) && isEqualImpl(a.compactType, b.compactType) && isEqualImpl(a.layout, b.layout) && isEqualImpl(a.margin, b.margin) && isEqualImpl(a.containerPadding, b.containerPadding) && a.rowHeight === b.rowHeight && a.maxRows === b.maxRows && a.isBounded === b.isBounded && a.isDraggable === b.isDraggable && a.isResizable === b.isResizable && a.preventCollision === b.preventCollision && a.useCSSTransforms === b.useCSSTransforms && a.transformScale === b.transformScale && a.isDroppable === b.isDroppable && isEqualImpl(a.resizeHandles, b.resizeHandles) && isEqualImpl(a.resizeHandle, b.resizeHandle) && a.onLayoutChange === b.onLayoutChange && a.onDragStart === b.onDragStart && a.onDrag === b.onDrag && a.onDragStop === b.onDragStop && a.onResizeStart === b.onResizeStart && a.onResize === b.onResize && a.onResizeStop === b.onResizeStop && a.onDrop === b.onDrop && isEqualImpl(a.droppingItem, b.droppingItem) && isEqualImpl(a.innerRef, b.innerRef);
|
|
4
|
+
return a.className === b.className && isEqualImpl(a.style, b.style) && a.width === b.width && a.autoSize === b.autoSize && a.cols === b.cols && a.draggableCancel === b.draggableCancel && a.draggableHandle === b.draggableHandle && isEqualImpl(a.verticalCompact, b.verticalCompact) && isEqualImpl(a.compactType, b.compactType) && isEqualImpl(a.layout, b.layout) && isEqualImpl(a.margin, b.margin) && isEqualImpl(a.containerPadding, b.containerPadding) && a.rowHeight === b.rowHeight && a.maxRows === b.maxRows && a.isBounded === b.isBounded && a.isDraggable === b.isDraggable && a.isResizable === b.isResizable && a.allowOverlap === b.allowOverlap && a.preventCollision === b.preventCollision && a.useCSSTransforms === b.useCSSTransforms && a.transformScale === b.transformScale && a.isDroppable === b.isDroppable && isEqualImpl(a.resizeHandles, b.resizeHandles) && isEqualImpl(a.resizeHandle, b.resizeHandle) && a.onLayoutChange === b.onLayoutChange && a.onDragStart === b.onDragStart && a.onDrag === b.onDrag && a.onDragStop === b.onDragStop && a.onResizeStart === b.onResizeStart && a.onResize === b.onResize && a.onResizeStop === b.onResizeStop && a.onDrop === b.onDrop && isEqualImpl(a.droppingItem, b.droppingItem) && isEqualImpl(a.innerRef, b.innerRef);
|
|
5
5
|
};
|
package/build/responsiveUtils.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
|
|
6
7
|
exports.getBreakpointFromWidth = getBreakpointFromWidth;
|
|
7
8
|
exports.getColsFromBreakpoint = getColsFromBreakpoint;
|
|
8
|
-
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
|
|
9
9
|
exports.sortBreakpoints = sortBreakpoints;
|
|
10
10
|
|
|
11
11
|
var _utils = require("./utils");
|
package/build/utils.js
CHANGED
|
@@ -4,33 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bottom = bottom;
|
|
7
|
+
exports.childrenEqual = childrenEqual;
|
|
7
8
|
exports.cloneLayout = cloneLayout;
|
|
8
|
-
exports.modifyLayout = modifyLayout;
|
|
9
|
-
exports.withLayoutItem = withLayoutItem;
|
|
10
9
|
exports.cloneLayoutItem = cloneLayoutItem;
|
|
11
|
-
exports.childrenEqual = childrenEqual;
|
|
12
|
-
exports.fastPositionEqual = fastPositionEqual;
|
|
13
10
|
exports.collides = collides;
|
|
14
11
|
exports.compact = compact;
|
|
15
12
|
exports.compactItem = compactItem;
|
|
13
|
+
exports.compactType = compactType;
|
|
16
14
|
exports.correctBounds = correctBounds;
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
15
|
+
exports.fastPositionEqual = fastPositionEqual;
|
|
16
|
+
exports.fastRGLPropsEqual = void 0;
|
|
19
17
|
exports.getAllCollisions = getAllCollisions;
|
|
18
|
+
exports.getFirstCollision = getFirstCollision;
|
|
19
|
+
exports.getLayoutItem = getLayoutItem;
|
|
20
20
|
exports.getStatics = getStatics;
|
|
21
|
+
exports.modifyLayout = modifyLayout;
|
|
21
22
|
exports.moveElement = moveElement;
|
|
22
23
|
exports.moveElementAwayFromCollision = moveElementAwayFromCollision;
|
|
24
|
+
exports.noop = void 0;
|
|
23
25
|
exports.perc = perc;
|
|
24
|
-
exports.setTransform = setTransform;
|
|
25
26
|
exports.setTopLeft = setTopLeft;
|
|
27
|
+
exports.setTransform = setTransform;
|
|
26
28
|
exports.sortLayoutItems = sortLayoutItems;
|
|
27
|
-
exports.sortLayoutItemsByRowCol = sortLayoutItemsByRowCol;
|
|
28
29
|
exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow;
|
|
30
|
+
exports.sortLayoutItemsByRowCol = sortLayoutItemsByRowCol;
|
|
29
31
|
exports.synchronizeLayoutWithChildren = synchronizeLayoutWithChildren;
|
|
30
32
|
exports.validateLayout = validateLayout;
|
|
31
|
-
exports.
|
|
32
|
-
exports.autoBindHandlers = autoBindHandlers;
|
|
33
|
-
exports.noop = exports.fastRGLPropsEqual = void 0;
|
|
33
|
+
exports.withLayoutItem = withLayoutItem;
|
|
34
34
|
|
|
35
35
|
var _lodash = _interopRequireDefault(require("lodash.isequal"));
|
|
36
36
|
|
|
@@ -38,9 +38,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
38
38
|
|
|
39
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
40
|
|
|
41
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
41
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
42
42
|
|
|
43
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
43
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
44
44
|
|
|
45
45
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
46
46
|
|
|
@@ -164,9 +164,9 @@ function childrenEqual(a
|
|
|
164
164
|
/*: boolean*/
|
|
165
165
|
{
|
|
166
166
|
return (0, _lodash.default)(_react.default.Children.map(a, function (c) {
|
|
167
|
-
return c.key;
|
|
167
|
+
return c === null || c === void 0 ? void 0 : c.key;
|
|
168
168
|
}), _react.default.Children.map(b, function (c) {
|
|
169
|
-
return c.key;
|
|
169
|
+
return c === null || c === void 0 ? void 0 : c.key;
|
|
170
170
|
}));
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
@@ -362,8 +362,11 @@ function compactItem(compareWith
|
|
|
362
362
|
l.x = cols - l.w;
|
|
363
363
|
l.y++;
|
|
364
364
|
}
|
|
365
|
-
}
|
|
365
|
+
} // Ensure that there are no negative positions
|
|
366
366
|
|
|
367
|
+
|
|
368
|
+
l.y = Math.max(l.y, 0);
|
|
369
|
+
l.x = Math.max(l.x, 0);
|
|
367
370
|
return l;
|
|
368
371
|
}
|
|
369
372
|
/**
|
|
@@ -503,6 +506,8 @@ function moveElement(layout
|
|
|
503
506
|
/*: CompactType*/
|
|
504
507
|
, cols
|
|
505
508
|
/*: number*/
|
|
509
|
+
, allowOverlap
|
|
510
|
+
/*: ?boolean*/
|
|
506
511
|
)
|
|
507
512
|
/*: Layout*/
|
|
508
513
|
{
|
|
@@ -526,14 +531,23 @@ function moveElement(layout
|
|
|
526
531
|
var movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false; // $FlowIgnore acceptable modification of read-only array as it was recently cloned
|
|
527
532
|
|
|
528
533
|
if (movingUp) sorted = sorted.reverse();
|
|
529
|
-
var collisions = getAllCollisions(sorted, l);
|
|
530
|
-
|
|
531
|
-
|
|
534
|
+
var collisions = getAllCollisions(sorted, l);
|
|
535
|
+
var hasCollisions = collisions.length > 0; // We may have collisions. We can short-circuit if we've turned off collisions or
|
|
536
|
+
// allowed overlap.
|
|
537
|
+
|
|
538
|
+
if (hasCollisions && allowOverlap) {
|
|
539
|
+
// Easy, we don't need to resolve collisions. But we *did* change the layout,
|
|
540
|
+
// so clone it on the way out.
|
|
541
|
+
return cloneLayout(layout);
|
|
542
|
+
} else if (hasCollisions && preventCollision) {
|
|
543
|
+
// If we are preventing collision but not allowing overlap, we need to
|
|
544
|
+
// revert the position of this element so it goes to where it came from, rather
|
|
545
|
+
// than the user's desired location.
|
|
532
546
|
log("Collision prevented on ".concat(l.i, ", reverting."));
|
|
533
547
|
l.x = oldX;
|
|
534
548
|
l.y = oldY;
|
|
535
549
|
l.moved = false;
|
|
536
|
-
return layout;
|
|
550
|
+
return layout; // did not change so don't clone
|
|
537
551
|
} // Move each item that collides away from this element.
|
|
538
552
|
|
|
539
553
|
|
|
@@ -674,7 +688,8 @@ function sortLayoutItems(layout
|
|
|
674
688
|
)
|
|
675
689
|
/*: Layout*/
|
|
676
690
|
{
|
|
677
|
-
if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
|
|
691
|
+
if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
|
|
692
|
+
if (compactType === "vertical") return sortLayoutItemsByRowCol(layout);else return layout;
|
|
678
693
|
}
|
|
679
694
|
/**
|
|
680
695
|
* Sort layout items by row ascending and column ascending.
|
|
@@ -741,6 +756,8 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
741
756
|
/*: number*/
|
|
742
757
|
, compactType
|
|
743
758
|
/*: CompactType*/
|
|
759
|
+
, allowOverlap
|
|
760
|
+
/*: ?boolean*/
|
|
744
761
|
)
|
|
745
762
|
/*: Layout*/
|
|
746
763
|
{
|
|
@@ -752,18 +769,17 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
752
769
|
|
|
753
770
|
_react.default.Children.forEach(children, function (child
|
|
754
771
|
/*: ReactElement<any>*/
|
|
755
|
-
, i
|
|
756
|
-
/*: number*/
|
|
757
772
|
) {
|
|
758
|
-
//
|
|
773
|
+
// Child may not exist
|
|
774
|
+
if ((child === null || child === void 0 ? void 0 : child.key) == null) return; // Don't overwrite if it already exists.
|
|
775
|
+
|
|
759
776
|
var exists = getLayoutItem(initialLayout, String(child.key));
|
|
760
777
|
|
|
761
778
|
if (exists) {
|
|
762
|
-
layout
|
|
779
|
+
layout.push(cloneLayoutItem(exists));
|
|
763
780
|
} else {
|
|
764
781
|
if (!isProduction && child.props._grid) {
|
|
765
|
-
console.warn("`_grid` properties on children have been deprecated as of React 15.2. " +
|
|
766
|
-
"Please use `data-grid` or add your properties directly to the `layout`.");
|
|
782
|
+
console.warn("`_grid` properties on children have been deprecated as of React 15.2. " + "Please use `data-grid` or add your properties directly to the `layout`.");
|
|
767
783
|
}
|
|
768
784
|
|
|
769
785
|
var g = child.props["data-grid"] || child.props._grid; // Hey, this item has a data-grid property, use it.
|
|
@@ -774,19 +790,19 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
774
790
|
} // FIXME clone not really necessary here
|
|
775
791
|
|
|
776
792
|
|
|
777
|
-
layout
|
|
793
|
+
layout.push(cloneLayoutItem(_objectSpread(_objectSpread({}, g), {}, {
|
|
778
794
|
i: child.key
|
|
779
|
-
}));
|
|
795
|
+
})));
|
|
780
796
|
} else {
|
|
781
797
|
// Nothing provided: ensure this is added to the bottom
|
|
782
798
|
// FIXME clone not really necessary here
|
|
783
|
-
layout
|
|
799
|
+
layout.push(cloneLayoutItem({
|
|
784
800
|
w: 1,
|
|
785
801
|
h: 1,
|
|
786
802
|
x: 0,
|
|
787
803
|
y: bottom(layout),
|
|
788
804
|
i: String(child.key)
|
|
789
|
-
});
|
|
805
|
+
}));
|
|
790
806
|
}
|
|
791
807
|
}
|
|
792
808
|
}); // Correct the layout.
|
|
@@ -795,7 +811,7 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
795
811
|
var correctedLayout = correctBounds(layout, {
|
|
796
812
|
cols: cols
|
|
797
813
|
});
|
|
798
|
-
return compact(correctedLayout, compactType, cols);
|
|
814
|
+
return allowOverlap ? correctedLayout : compact(correctedLayout, compactType, cols);
|
|
799
815
|
}
|
|
800
816
|
/**
|
|
801
817
|
* Validate a layout. Throws errors.
|
|
@@ -825,14 +841,6 @@ function validateLayout(layout
|
|
|
825
841
|
throw new Error("ReactGridLayout: " + contextName + "[" + i + "]." + subProps[j] + " must be a number!");
|
|
826
842
|
}
|
|
827
843
|
}
|
|
828
|
-
|
|
829
|
-
if (item.i && typeof item.i !== "string") {
|
|
830
|
-
throw new Error("ReactGridLayout: " + contextName + "[" + i + "].i must be a string!");
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
if (item.static !== undefined && typeof item.static !== "boolean") {
|
|
834
|
-
throw new Error("ReactGridLayout: " + contextName + "[" + i + "].static must be a boolean!");
|
|
835
|
-
}
|
|
836
844
|
}
|
|
837
845
|
} // Legacy support for verticalCompact: false
|
|
838
846
|
|
|
@@ -847,19 +855,6 @@ function compactType(props
|
|
|
847
855
|
compactType = _ref3.compactType;
|
|
848
856
|
|
|
849
857
|
return verticalCompact === false ? null : compactType;
|
|
850
|
-
} // Flow can't really figure this out, so we just use Object
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
function autoBindHandlers(el
|
|
854
|
-
/*: Object*/
|
|
855
|
-
, fns
|
|
856
|
-
/*: Array<string>*/
|
|
857
|
-
)
|
|
858
|
-
/*: void*/
|
|
859
|
-
{
|
|
860
|
-
fns.forEach(function (key) {
|
|
861
|
-
return el[key] = el[key].bind(el);
|
|
862
|
-
});
|
|
863
858
|
}
|
|
864
859
|
|
|
865
860
|
function log() {
|