react-grid-layout 1.2.2 → 1.3.0
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/.flowconfig +1 -3
- package/CHANGELOG.md +55 -0
- package/README.md +55 -16
- package/build/GridItem.js +14 -20
- package/build/ReactGridLayout.js +299 -319
- package/build/ReactGridLayoutPropTypes.js +11 -5
- package/build/ResponsiveReactGridLayout.js +12 -6
- package/build/calculateUtils.js +6 -6
- package/build/components/WidthProvider.js +31 -25
- package/build/fastRGLPropsEqual.js +1 -1
- package/build/utils.js +29 -32
- package/dist/react-grid-layout.min.js +1 -1
- package/dist/react-grid-layout.min.js.LICENSE.txt +1 -1
- package/dist/react-grid-layout.min.js.map +1 -1
- package/foo.html +388 -0
- package/lib/GridItem.jsx +18 -14
- package/lib/ReactGridLayout.jsx +93 -58
- package/lib/ReactGridLayoutPropTypes.js +40 -14
- package/lib/ResponsiveReactGridLayout.jsx +7 -1
- package/lib/components/WidthProvider.jsx +35 -23
- package/lib/utils.js +30 -20
- package/package.json +35 -29
- package/.husky/pre-commit +0 -6
- package/.travis.yml +0 -9
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.resizeHandleType = exports.
|
|
6
|
+
exports.default = exports.resizeHandleType = exports.resizeHandleAxesType = 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
|
}
|
|
@@ -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,7 +33,7 @@ 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); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
36
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
35
37
|
|
|
36
38
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
37
39
|
|
|
@@ -47,7 +49,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
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
|
@@ -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
|
}
|
|
@@ -5,19 +5,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = WidthProvideRGL;
|
|
9
9
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
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
|
|
|
@@ -37,7 +39,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
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
|
|
|
@@ -47,24 +49,20 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
47
49
|
|
|
48
50
|
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; }
|
|
49
51
|
|
|
52
|
+
var layoutClassName = "react-grid-layout";
|
|
50
53
|
/*
|
|
51
54
|
* A simple HOC that provides facility for listening to container resizes.
|
|
52
55
|
*
|
|
53
56
|
* The Flow type is pretty janky here. I can't just spread `WPProps` into this returned object - I wish I could - but it triggers
|
|
54
57
|
* a flow bug of some sort that causes it to stop typechecking.
|
|
55
58
|
*/
|
|
56
|
-
|
|
59
|
+
|
|
60
|
+
function WidthProvideRGL
|
|
57
61
|
/*:: <Config>*/
|
|
58
62
|
(ComposedComponent
|
|
59
63
|
/*: React.AbstractComponent<Config>*/
|
|
60
64
|
)
|
|
61
|
-
/*: React.AbstractComponent<
|
|
62
|
-
...Config,
|
|
63
|
-
measureBeforeMount?: boolean,
|
|
64
|
-
className?: string,
|
|
65
|
-
style?: Object,
|
|
66
|
-
width?: number
|
|
67
|
-
|}>*/
|
|
65
|
+
/*: React.AbstractComponent<ComposedProps<Config>>*/
|
|
68
66
|
{
|
|
69
67
|
var _class, _temp;
|
|
70
68
|
|
|
@@ -88,17 +86,21 @@ function WidthProvider
|
|
|
88
86
|
width: 1280
|
|
89
87
|
});
|
|
90
88
|
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "elementRef", /*#__PURE__*/React.createRef());
|
|
90
|
+
|
|
91
91
|
_defineProperty(_assertThisInitialized(_this), "mounted", false);
|
|
92
92
|
|
|
93
93
|
_defineProperty(_assertThisInitialized(_this), "onWindowResize", function () {
|
|
94
|
-
if (!_this.mounted) return;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (node instanceof HTMLElement)
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
if (!_this.mounted) return;
|
|
95
|
+
var node = _this.elementRef.current; // Flow casts this to Text | Element
|
|
96
|
+
// fix: grid position error when node or parentNode display is none by window resize
|
|
97
|
+
// #924 #1084
|
|
98
|
+
|
|
99
|
+
if (node instanceof HTMLElement && node.offsetWidth) {
|
|
100
|
+
_this.setState({
|
|
101
|
+
width: node.offsetWidth
|
|
102
|
+
});
|
|
103
|
+
}
|
|
102
104
|
});
|
|
103
105
|
|
|
104
106
|
return _this;
|
|
@@ -125,16 +127,20 @@ function WidthProvider
|
|
|
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: this.props.className,
|
|
133
|
-
style: this.props.style
|
|
134
|
+
className: (0, _classnames.default)(this.props.className, layoutClassName),
|
|
135
|
+
style: this.props.style // $FlowIgnore ref types
|
|
136
|
+
,
|
|
137
|
+
ref: this.elementRef
|
|
134
138
|
});
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
return /*#__PURE__*/React.createElement(ComposedComponent, _extends({
|
|
141
|
+
return /*#__PURE__*/React.createElement(ComposedComponent, _extends({
|
|
142
|
+
innerRef: this.elementRef
|
|
143
|
+
}, rest, this.state));
|
|
138
144
|
}
|
|
139
145
|
}]);
|
|
140
146
|
|
|
@@ -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/utils.js
CHANGED
|
@@ -29,7 +29,6 @@ exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow;
|
|
|
29
29
|
exports.synchronizeLayoutWithChildren = synchronizeLayoutWithChildren;
|
|
30
30
|
exports.validateLayout = validateLayout;
|
|
31
31
|
exports.compactType = compactType;
|
|
32
|
-
exports.autoBindHandlers = autoBindHandlers;
|
|
33
32
|
exports.noop = exports.fastRGLPropsEqual = void 0;
|
|
34
33
|
|
|
35
34
|
var _lodash = _interopRequireDefault(require("lodash.isequal"));
|
|
@@ -38,7 +37,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
38
37
|
|
|
39
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
39
|
|
|
41
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
42
41
|
|
|
43
42
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
44
43
|
|
|
@@ -164,9 +163,9 @@ function childrenEqual(a
|
|
|
164
163
|
/*: boolean*/
|
|
165
164
|
{
|
|
166
165
|
return (0, _lodash.default)(_react.default.Children.map(a, function (c) {
|
|
167
|
-
return c.key;
|
|
166
|
+
return c === null || c === void 0 ? void 0 : c.key;
|
|
168
167
|
}), _react.default.Children.map(b, function (c) {
|
|
169
|
-
return c.key;
|
|
168
|
+
return c === null || c === void 0 ? void 0 : c.key;
|
|
170
169
|
}));
|
|
171
170
|
}
|
|
172
171
|
/**
|
|
@@ -362,8 +361,11 @@ function compactItem(compareWith
|
|
|
362
361
|
l.x = cols - l.w;
|
|
363
362
|
l.y++;
|
|
364
363
|
}
|
|
365
|
-
}
|
|
364
|
+
} // Ensure that there are no negative positions
|
|
365
|
+
|
|
366
366
|
|
|
367
|
+
l.y = Math.max(l.y, 0);
|
|
368
|
+
l.x = Math.max(l.x, 0);
|
|
367
369
|
return l;
|
|
368
370
|
}
|
|
369
371
|
/**
|
|
@@ -503,6 +505,8 @@ function moveElement(layout
|
|
|
503
505
|
/*: CompactType*/
|
|
504
506
|
, cols
|
|
505
507
|
/*: number*/
|
|
508
|
+
, allowOverlap
|
|
509
|
+
/*: ?boolean*/
|
|
506
510
|
)
|
|
507
511
|
/*: Layout*/
|
|
508
512
|
{
|
|
@@ -529,10 +533,13 @@ function moveElement(layout
|
|
|
529
533
|
var collisions = getAllCollisions(sorted, l); // There was a collision; abort
|
|
530
534
|
|
|
531
535
|
if (preventCollision && collisions.length) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
+
if (!allowOverlap) {
|
|
537
|
+
log("Collision prevented on ".concat(l.i, ", reverting."));
|
|
538
|
+
l.x = oldX;
|
|
539
|
+
l.y = oldY;
|
|
540
|
+
l.moved = false;
|
|
541
|
+
}
|
|
542
|
+
|
|
536
543
|
return layout;
|
|
537
544
|
} // Move each item that collides away from this element.
|
|
538
545
|
|
|
@@ -674,7 +681,8 @@ function sortLayoutItems(layout
|
|
|
674
681
|
)
|
|
675
682
|
/*: Layout*/
|
|
676
683
|
{
|
|
677
|
-
if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
|
|
684
|
+
if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
|
|
685
|
+
if (compactType === "vertical") return sortLayoutItemsByRowCol(layout);else return layout;
|
|
678
686
|
}
|
|
679
687
|
/**
|
|
680
688
|
* Sort layout items by row ascending and column ascending.
|
|
@@ -741,6 +749,8 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
741
749
|
/*: number*/
|
|
742
750
|
, compactType
|
|
743
751
|
/*: CompactType*/
|
|
752
|
+
, allowOverlap
|
|
753
|
+
/*: ?boolean*/
|
|
744
754
|
)
|
|
745
755
|
/*: Layout*/
|
|
746
756
|
{
|
|
@@ -752,14 +762,14 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
752
762
|
|
|
753
763
|
_react.default.Children.forEach(children, function (child
|
|
754
764
|
/*: ReactElement<any>*/
|
|
755
|
-
, i
|
|
756
|
-
/*: number*/
|
|
757
765
|
) {
|
|
758
|
-
//
|
|
766
|
+
// Child may not exist
|
|
767
|
+
if ((child === null || child === void 0 ? void 0 : child.key) == null) return; // Don't overwrite if it already exists.
|
|
768
|
+
|
|
759
769
|
var exists = getLayoutItem(initialLayout, String(child.key));
|
|
760
770
|
|
|
761
771
|
if (exists) {
|
|
762
|
-
layout
|
|
772
|
+
layout.push(cloneLayoutItem(exists));
|
|
763
773
|
} else {
|
|
764
774
|
if (!isProduction && child.props._grid) {
|
|
765
775
|
console.warn("`_grid` properties on children have been deprecated as of React 15.2. " + // eslint-disable-line
|
|
@@ -774,19 +784,19 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
774
784
|
} // FIXME clone not really necessary here
|
|
775
785
|
|
|
776
786
|
|
|
777
|
-
layout
|
|
787
|
+
layout.push(cloneLayoutItem(_objectSpread(_objectSpread({}, g), {}, {
|
|
778
788
|
i: child.key
|
|
779
|
-
}));
|
|
789
|
+
})));
|
|
780
790
|
} else {
|
|
781
791
|
// Nothing provided: ensure this is added to the bottom
|
|
782
792
|
// FIXME clone not really necessary here
|
|
783
|
-
layout
|
|
793
|
+
layout.push(cloneLayoutItem({
|
|
784
794
|
w: 1,
|
|
785
795
|
h: 1,
|
|
786
796
|
x: 0,
|
|
787
797
|
y: bottom(layout),
|
|
788
798
|
i: String(child.key)
|
|
789
|
-
});
|
|
799
|
+
}));
|
|
790
800
|
}
|
|
791
801
|
}
|
|
792
802
|
}); // Correct the layout.
|
|
@@ -795,7 +805,7 @@ function synchronizeLayoutWithChildren(initialLayout
|
|
|
795
805
|
var correctedLayout = correctBounds(layout, {
|
|
796
806
|
cols: cols
|
|
797
807
|
});
|
|
798
|
-
return compact(correctedLayout, compactType, cols);
|
|
808
|
+
return allowOverlap ? correctedLayout : compact(correctedLayout, compactType, cols);
|
|
799
809
|
}
|
|
800
810
|
/**
|
|
801
811
|
* Validate a layout. Throws errors.
|
|
@@ -847,19 +857,6 @@ function compactType(props
|
|
|
847
857
|
compactType = _ref3.compactType;
|
|
848
858
|
|
|
849
859
|
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
860
|
}
|
|
864
861
|
|
|
865
862
|
function log() {
|