react-grid-layout 1.2.3 → 1.3.1
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 +48 -0
- package/README.md +56 -16
- 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 +30 -17
- package/build/fastRGLPropsEqual.js +1 -1
- package/build/responsiveUtils.js +1 -1
- package/build/utils.js +47 -43
- package/dist/react-grid-layout.min.js +1 -2
- package/dist/react-grid-layout.min.js.map +1 -1
- package/foo.html +388 -0
- package/lib/GridItem.jsx +7 -7
- package/lib/ReactGridLayout.jsx +101 -62
- package/lib/ReactGridLayoutPropTypes.js +38 -17
- package/lib/ResponsiveReactGridLayout.jsx +7 -1
- package/lib/components/WidthProvider.jsx +17 -3
- package/lib/utils.js +44 -25
- package/package.json +31 -29
- package/.husky/pre-commit +0 -6
- package/.travis.yml +0 -9
- package/dist/react-grid-layout.min.js.LICENSE.txt +0 -5
package/build/ReactGridLayout.js
CHANGED
|
@@ -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,7 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash.isequal"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
15
|
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
|
|
@@ -23,47 +23,47 @@ var _ReactGridLayoutPropTypes = _interopRequireDefault(require("./ReactGridLayou
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
26
|
-
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); }
|
|
27
27
|
|
|
28
|
-
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; }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
37
37
|
|
|
38
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
38
|
+
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; }
|
|
39
39
|
|
|
40
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
40
|
+
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; }
|
|
41
41
|
|
|
42
|
-
function
|
|
42
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
45
|
|
|
46
46
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
49
49
|
|
|
50
|
-
function
|
|
50
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
51
51
|
|
|
52
|
-
function
|
|
52
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
53
53
|
|
|
54
54
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
55
55
|
|
|
56
56
|
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); } }
|
|
57
57
|
|
|
58
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
58
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
59
59
|
|
|
60
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass
|
|
60
|
+
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); }
|
|
61
61
|
|
|
62
62
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
63
63
|
|
|
64
64
|
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); }; }
|
|
65
65
|
|
|
66
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
66
|
+
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); }
|
|
67
67
|
|
|
68
68
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
69
69
|
|
|
@@ -92,25 +92,21 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
92
92
|
|
|
93
93
|
var _super = _createSuper(ReactGridLayout);
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
// Refactored to another module to make way for preval
|
|
97
|
-
function ReactGridLayout(props
|
|
98
|
-
/*: Props*/
|
|
99
|
-
, context
|
|
100
|
-
/*: any*/
|
|
101
|
-
)
|
|
102
|
-
/*: void*/
|
|
103
|
-
{
|
|
95
|
+
function ReactGridLayout() {
|
|
104
96
|
var _this;
|
|
105
97
|
|
|
106
98
|
_classCallCheck(this, ReactGridLayout);
|
|
107
99
|
|
|
108
|
-
|
|
100
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
101
|
+
args[_key] = arguments[_key];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
109
105
|
|
|
110
106
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
111
107
|
activeDrag: null,
|
|
112
108
|
layout: (0, _utils.synchronizeLayoutWithChildren)(_this.props.layout, _this.props.children, _this.props.cols, // Legacy support for verticalCompact: false
|
|
113
|
-
(0, _utils.compactType)(_this.props)),
|
|
109
|
+
(0, _utils.compactType)(_this.props), _this.props.allowOverlap),
|
|
114
110
|
mounted: false,
|
|
115
111
|
oldDragItem: null,
|
|
116
112
|
oldLayout: null,
|
|
@@ -121,35 +117,251 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
121
117
|
|
|
122
118
|
_defineProperty(_assertThisInitialized(_this), "dragEnterCounter", 0);
|
|
123
119
|
|
|
120
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStart", function (i
|
|
121
|
+
/*: string*/
|
|
122
|
+
, x
|
|
123
|
+
/*: number*/
|
|
124
|
+
, y
|
|
125
|
+
/*: number*/
|
|
126
|
+
, _ref) {
|
|
127
|
+
var e = _ref.e,
|
|
128
|
+
node = _ref.node;
|
|
129
|
+
var layout = _this.state.layout;
|
|
130
|
+
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
131
|
+
if (!l) return;
|
|
132
|
+
|
|
133
|
+
_this.setState({
|
|
134
|
+
oldDragItem: (0, _utils.cloneLayoutItem)(l),
|
|
135
|
+
oldLayout: layout
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return _this.props.onDragStart(layout, l, l, null, e, node);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
_defineProperty(_assertThisInitialized(_this), "onDrag", function (i, x, y, _ref2) {
|
|
142
|
+
var e = _ref2.e,
|
|
143
|
+
node = _ref2.node;
|
|
144
|
+
var oldDragItem = _this.state.oldDragItem;
|
|
145
|
+
var layout = _this.state.layout;
|
|
146
|
+
var _this$props = _this.props,
|
|
147
|
+
cols = _this$props.cols,
|
|
148
|
+
allowOverlap = _this$props.allowOverlap,
|
|
149
|
+
preventCollision = _this$props.preventCollision;
|
|
150
|
+
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
151
|
+
if (!l) return; // Create placeholder (display only)
|
|
152
|
+
|
|
153
|
+
var placeholder = {
|
|
154
|
+
w: l.w,
|
|
155
|
+
h: l.h,
|
|
156
|
+
x: l.x,
|
|
157
|
+
y: l.y,
|
|
158
|
+
placeholder: true,
|
|
159
|
+
i: i
|
|
160
|
+
}; // Move the element to the dragged location.
|
|
161
|
+
|
|
162
|
+
var isUserAction = true;
|
|
163
|
+
layout = (0, _utils.moveElement)(layout, l, x, y, isUserAction, preventCollision, (0, _utils.compactType)(_this.props), cols, allowOverlap);
|
|
164
|
+
|
|
165
|
+
_this.props.onDrag(layout, oldDragItem, l, placeholder, e, node);
|
|
166
|
+
|
|
167
|
+
_this.setState({
|
|
168
|
+
layout: allowOverlap ? layout : (0, _utils.compact)(layout, (0, _utils.compactType)(_this.props), cols),
|
|
169
|
+
activeDrag: placeholder
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStop", function (i, x, y, _ref3) {
|
|
174
|
+
var e = _ref3.e,
|
|
175
|
+
node = _ref3.node;
|
|
176
|
+
if (!_this.state.activeDrag) return;
|
|
177
|
+
var oldDragItem = _this.state.oldDragItem;
|
|
178
|
+
var layout = _this.state.layout;
|
|
179
|
+
var _this$props2 = _this.props,
|
|
180
|
+
cols = _this$props2.cols,
|
|
181
|
+
preventCollision = _this$props2.preventCollision,
|
|
182
|
+
allowOverlap = _this$props2.allowOverlap;
|
|
183
|
+
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
184
|
+
if (!l) return; // Move the element here
|
|
185
|
+
|
|
186
|
+
var isUserAction = true;
|
|
187
|
+
layout = (0, _utils.moveElement)(layout, l, x, y, isUserAction, preventCollision, (0, _utils.compactType)(_this.props), cols, allowOverlap);
|
|
188
|
+
|
|
189
|
+
_this.props.onDragStop(layout, oldDragItem, l, null, e, node); // Set state
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
var newLayout = allowOverlap ? layout : (0, _utils.compact)(layout, (0, _utils.compactType)(_this.props), cols);
|
|
193
|
+
var oldLayout = _this.state.oldLayout;
|
|
194
|
+
|
|
195
|
+
_this.setState({
|
|
196
|
+
activeDrag: null,
|
|
197
|
+
layout: newLayout,
|
|
198
|
+
oldDragItem: null,
|
|
199
|
+
oldLayout: null
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
_this.onLayoutMaybeChanged(newLayout, oldLayout);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
_defineProperty(_assertThisInitialized(_this), "onResizeStart", function (i, w, h, _ref4) {
|
|
206
|
+
var e = _ref4.e,
|
|
207
|
+
node = _ref4.node;
|
|
208
|
+
var layout = _this.state.layout;
|
|
209
|
+
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
210
|
+
if (!l) return;
|
|
211
|
+
|
|
212
|
+
_this.setState({
|
|
213
|
+
oldResizeItem: (0, _utils.cloneLayoutItem)(l),
|
|
214
|
+
oldLayout: _this.state.layout
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
_this.props.onResizeStart(layout, l, l, null, e, node);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
_defineProperty(_assertThisInitialized(_this), "onResize", function (i, w, h, _ref5) {
|
|
221
|
+
var e = _ref5.e,
|
|
222
|
+
node = _ref5.node;
|
|
223
|
+
var _this$state = _this.state,
|
|
224
|
+
layout = _this$state.layout,
|
|
225
|
+
oldResizeItem = _this$state.oldResizeItem;
|
|
226
|
+
var _this$props3 = _this.props,
|
|
227
|
+
cols = _this$props3.cols,
|
|
228
|
+
preventCollision = _this$props3.preventCollision,
|
|
229
|
+
allowOverlap = _this$props3.allowOverlap;
|
|
230
|
+
|
|
231
|
+
var _withLayoutItem = (0, _utils.withLayoutItem)(layout, i, function (l) {
|
|
232
|
+
// Something like quad tree should be used
|
|
233
|
+
// to find collisions faster
|
|
234
|
+
var hasCollisions;
|
|
235
|
+
|
|
236
|
+
if (preventCollision && !allowOverlap) {
|
|
237
|
+
var collisions = (0, _utils.getAllCollisions)(layout, _objectSpread(_objectSpread({}, l), {}, {
|
|
238
|
+
w: w,
|
|
239
|
+
h: h
|
|
240
|
+
})).filter(function (layoutItem) {
|
|
241
|
+
return layoutItem.i !== l.i;
|
|
242
|
+
});
|
|
243
|
+
hasCollisions = collisions.length > 0; // If we're colliding, we need adjust the placeholder.
|
|
244
|
+
|
|
245
|
+
// If we're colliding, we need adjust the placeholder.
|
|
246
|
+
if (hasCollisions) {
|
|
247
|
+
// adjust w && h to maximum allowed space
|
|
248
|
+
var leastX = Infinity,
|
|
249
|
+
leastY = Infinity;
|
|
250
|
+
collisions.forEach(function (layoutItem) {
|
|
251
|
+
if (layoutItem.x > l.x) leastX = Math.min(leastX, layoutItem.x);
|
|
252
|
+
if (layoutItem.y > l.y) leastY = Math.min(leastY, layoutItem.y);
|
|
253
|
+
});
|
|
254
|
+
if (Number.isFinite(leastX)) l.w = leastX - l.x;
|
|
255
|
+
if (Number.isFinite(leastY)) l.h = leastY - l.y;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (!hasCollisions) {
|
|
260
|
+
// Set new width and height.
|
|
261
|
+
l.w = w;
|
|
262
|
+
l.h = h;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return l;
|
|
266
|
+
}),
|
|
267
|
+
_withLayoutItem2 = _slicedToArray(_withLayoutItem, 2),
|
|
268
|
+
newLayout = _withLayoutItem2[0],
|
|
269
|
+
l = _withLayoutItem2[1]; // Shouldn't ever happen, but typechecking makes it necessary
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
if (!l) return; // Create placeholder element (display only)
|
|
273
|
+
|
|
274
|
+
var placeholder = {
|
|
275
|
+
w: l.w,
|
|
276
|
+
h: l.h,
|
|
277
|
+
x: l.x,
|
|
278
|
+
y: l.y,
|
|
279
|
+
static: true,
|
|
280
|
+
i: i
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
_this.props.onResize(newLayout, oldResizeItem, l, placeholder, e, node); // Re-compact the newLayout and set the drag placeholder.
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
_this.setState({
|
|
287
|
+
layout: allowOverlap ? newLayout : (0, _utils.compact)(newLayout, (0, _utils.compactType)(_this.props), cols),
|
|
288
|
+
activeDrag: placeholder
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
_defineProperty(_assertThisInitialized(_this), "onResizeStop", function (i, w, h, _ref6) {
|
|
293
|
+
var e = _ref6.e,
|
|
294
|
+
node = _ref6.node;
|
|
295
|
+
var _this$state2 = _this.state,
|
|
296
|
+
layout = _this$state2.layout,
|
|
297
|
+
oldResizeItem = _this$state2.oldResizeItem;
|
|
298
|
+
var _this$props4 = _this.props,
|
|
299
|
+
cols = _this$props4.cols,
|
|
300
|
+
allowOverlap = _this$props4.allowOverlap;
|
|
301
|
+
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
302
|
+
|
|
303
|
+
_this.props.onResizeStop(layout, oldResizeItem, l, null, e, node); // Set state
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
var newLayout = allowOverlap ? layout : (0, _utils.compact)(layout, (0, _utils.compactType)(_this.props), cols);
|
|
307
|
+
var oldLayout = _this.state.oldLayout;
|
|
308
|
+
|
|
309
|
+
_this.setState({
|
|
310
|
+
activeDrag: null,
|
|
311
|
+
layout: newLayout,
|
|
312
|
+
oldResizeItem: null,
|
|
313
|
+
oldLayout: null
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
_this.onLayoutMaybeChanged(newLayout, oldLayout);
|
|
317
|
+
});
|
|
318
|
+
|
|
124
319
|
_defineProperty(_assertThisInitialized(_this), "onDragOver", function (e) {
|
|
125
320
|
var _e$nativeEvent$target;
|
|
126
321
|
|
|
127
|
-
//
|
|
322
|
+
e.preventDefault(); // Prevent any browser native action
|
|
323
|
+
|
|
324
|
+
e.stopPropagation(); // we should ignore events from layout's children in Firefox
|
|
128
325
|
// to avoid unpredictable jumping of a dropping placeholder
|
|
129
326
|
// FIXME remove this hack
|
|
327
|
+
|
|
130
328
|
if (isFirefox && // $FlowIgnore can't figure this out
|
|
131
329
|
!((_e$nativeEvent$target = e.nativeEvent.target) !== null && _e$nativeEvent$target !== void 0 && _e$nativeEvent$target.classList.contains(layoutClassName))) {
|
|
132
|
-
// without this Firefox will not allow drop if currently over droppingItem
|
|
133
|
-
e.preventDefault();
|
|
134
330
|
return false;
|
|
135
331
|
}
|
|
136
332
|
|
|
137
|
-
var _this$
|
|
138
|
-
droppingItem = _this$
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
333
|
+
var _this$props5 = _this.props,
|
|
334
|
+
droppingItem = _this$props5.droppingItem,
|
|
335
|
+
onDropDragOver = _this$props5.onDropDragOver,
|
|
336
|
+
margin = _this$props5.margin,
|
|
337
|
+
cols = _this$props5.cols,
|
|
338
|
+
rowHeight = _this$props5.rowHeight,
|
|
339
|
+
maxRows = _this$props5.maxRows,
|
|
340
|
+
width = _this$props5.width,
|
|
341
|
+
containerPadding = _this$props5.containerPadding,
|
|
342
|
+
transformScale = _this$props5.transformScale; // Allow user to customize the dropping item or short-circuit the drop based on the results
|
|
343
|
+
// of the `onDragOver(e: Event)` callback.
|
|
344
|
+
|
|
345
|
+
var onDragOverResult = onDropDragOver === null || onDropDragOver === void 0 ? void 0 : onDropDragOver(e);
|
|
346
|
+
|
|
347
|
+
if (onDragOverResult === false) {
|
|
348
|
+
if (_this.state.droppingDOMNode) {
|
|
349
|
+
_this.removeDroppingPlaceholder();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var finalDroppingItem = _objectSpread(_objectSpread({}, droppingItem), onDragOverResult);
|
|
356
|
+
|
|
145
357
|
var layout = _this.state.layout; // This is relative to the DOM element that this event fired for.
|
|
146
358
|
|
|
147
359
|
var _e$nativeEvent = e.nativeEvent,
|
|
148
360
|
layerX = _e$nativeEvent.layerX,
|
|
149
361
|
layerY = _e$nativeEvent.layerY;
|
|
150
362
|
var droppingPosition = {
|
|
151
|
-
left: layerX,
|
|
152
|
-
top: layerY,
|
|
363
|
+
left: layerX / transformScale,
|
|
364
|
+
top: layerY / transformScale,
|
|
153
365
|
e: e
|
|
154
366
|
};
|
|
155
367
|
|
|
@@ -164,14 +376,14 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
164
376
|
containerWidth: width,
|
|
165
377
|
containerPadding: containerPadding || margin
|
|
166
378
|
};
|
|
167
|
-
var calculatedPosition = (0, _calculateUtils.calcXY)(positionParams, layerY, layerX,
|
|
379
|
+
var calculatedPosition = (0, _calculateUtils.calcXY)(positionParams, layerY, layerX, finalDroppingItem.w, finalDroppingItem.h);
|
|
168
380
|
|
|
169
381
|
_this.setState({
|
|
170
382
|
droppingDOMNode: /*#__PURE__*/React.createElement("div", {
|
|
171
|
-
key:
|
|
383
|
+
key: finalDroppingItem.i
|
|
172
384
|
}),
|
|
173
385
|
droppingPosition: droppingPosition,
|
|
174
|
-
layout: [].concat(_toConsumableArray(layout), [_objectSpread(_objectSpread({},
|
|
386
|
+
layout: [].concat(_toConsumableArray(layout), [_objectSpread(_objectSpread({}, finalDroppingItem), {}, {
|
|
175
387
|
x: calculatedPosition.x,
|
|
176
388
|
y: calculatedPosition.y,
|
|
177
389
|
static: false,
|
|
@@ -190,15 +402,12 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
190
402
|
});
|
|
191
403
|
}
|
|
192
404
|
}
|
|
193
|
-
|
|
194
|
-
e.stopPropagation();
|
|
195
|
-
e.preventDefault();
|
|
196
405
|
});
|
|
197
406
|
|
|
198
407
|
_defineProperty(_assertThisInitialized(_this), "removeDroppingPlaceholder", function () {
|
|
199
|
-
var _this$
|
|
200
|
-
droppingItem = _this$
|
|
201
|
-
cols = _this$
|
|
408
|
+
var _this$props6 = _this.props,
|
|
409
|
+
droppingItem = _this$props6.droppingItem,
|
|
410
|
+
cols = _this$props6.cols;
|
|
202
411
|
var layout = _this.state.layout;
|
|
203
412
|
var newLayout = (0, _utils.compact)(layout.filter(function (l) {
|
|
204
413
|
return l.i !== droppingItem.i;
|
|
@@ -212,7 +421,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
212
421
|
});
|
|
213
422
|
});
|
|
214
423
|
|
|
215
|
-
_defineProperty(_assertThisInitialized(_this), "onDragLeave", function () {
|
|
424
|
+
_defineProperty(_assertThisInitialized(_this), "onDragLeave", function (e) {
|
|
425
|
+
e.preventDefault(); // Prevent any browser native action
|
|
426
|
+
|
|
216
427
|
_this.dragEnterCounter--; // onDragLeave can be triggered on each layout's child.
|
|
217
428
|
// But we know that count of dragEnter and dragLeave events
|
|
218
429
|
// will be balanced after leaving the layout's container
|
|
@@ -224,13 +435,17 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
224
435
|
}
|
|
225
436
|
});
|
|
226
437
|
|
|
227
|
-
_defineProperty(_assertThisInitialized(_this), "onDragEnter", function () {
|
|
438
|
+
_defineProperty(_assertThisInitialized(_this), "onDragEnter", function (e) {
|
|
439
|
+
e.preventDefault(); // Prevent any browser native action
|
|
440
|
+
|
|
228
441
|
_this.dragEnterCounter++;
|
|
229
442
|
});
|
|
230
443
|
|
|
231
444
|
_defineProperty(_assertThisInitialized(_this), "onDrop", function (e
|
|
232
445
|
/*: Event*/
|
|
233
446
|
) {
|
|
447
|
+
e.preventDefault(); // Prevent any browser native action
|
|
448
|
+
|
|
234
449
|
var droppingItem = _this.props.droppingItem;
|
|
235
450
|
var layout = _this.state.layout;
|
|
236
451
|
var item = layout.find(function (l) {
|
|
@@ -244,7 +459,6 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
244
459
|
_this.props.onDrop(layout, item, e);
|
|
245
460
|
});
|
|
246
461
|
|
|
247
|
-
(0, _utils.autoBindHandlers)(_assertThisInitialized(_this), ["onDragStart", "onDrag", "onDragStop", "onResizeStart", "onResize", "onResizeStop"]);
|
|
248
462
|
return _this;
|
|
249
463
|
}
|
|
250
464
|
|
|
@@ -310,118 +524,6 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
310
524
|
* @param {Element} node The current dragging DOM element
|
|
311
525
|
*/
|
|
312
526
|
|
|
313
|
-
}, {
|
|
314
|
-
key: "onDragStart",
|
|
315
|
-
value: function onDragStart(i
|
|
316
|
-
/*: string*/
|
|
317
|
-
, x
|
|
318
|
-
/*: number*/
|
|
319
|
-
, y
|
|
320
|
-
/*: number*/
|
|
321
|
-
, _ref)
|
|
322
|
-
/*: void*/
|
|
323
|
-
{
|
|
324
|
-
var e = _ref.e,
|
|
325
|
-
node = _ref.node;
|
|
326
|
-
var layout = this.state.layout;
|
|
327
|
-
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
328
|
-
if (!l) return;
|
|
329
|
-
this.setState({
|
|
330
|
-
oldDragItem: (0, _utils.cloneLayoutItem)(l),
|
|
331
|
-
oldLayout: this.state.layout
|
|
332
|
-
});
|
|
333
|
-
return this.props.onDragStart(layout, l, l, null, e, node);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Each drag movement create a new dragelement and move the element to the dragged location
|
|
337
|
-
* @param {String} i Id of the child
|
|
338
|
-
* @param {Number} x X position of the move
|
|
339
|
-
* @param {Number} y Y position of the move
|
|
340
|
-
* @param {Event} e The mousedown event
|
|
341
|
-
* @param {Element} node The current dragging DOM element
|
|
342
|
-
*/
|
|
343
|
-
|
|
344
|
-
}, {
|
|
345
|
-
key: "onDrag",
|
|
346
|
-
value: function onDrag(i
|
|
347
|
-
/*: string*/
|
|
348
|
-
, x
|
|
349
|
-
/*: number*/
|
|
350
|
-
, y
|
|
351
|
-
/*: number*/
|
|
352
|
-
, _ref2)
|
|
353
|
-
/*: void*/
|
|
354
|
-
{
|
|
355
|
-
var e = _ref2.e,
|
|
356
|
-
node = _ref2.node;
|
|
357
|
-
var oldDragItem = this.state.oldDragItem;
|
|
358
|
-
var layout = this.state.layout;
|
|
359
|
-
var cols = this.props.cols;
|
|
360
|
-
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
361
|
-
if (!l) return; // Create placeholder (display only)
|
|
362
|
-
|
|
363
|
-
var placeholder = {
|
|
364
|
-
w: l.w,
|
|
365
|
-
h: l.h,
|
|
366
|
-
x: l.x,
|
|
367
|
-
y: l.y,
|
|
368
|
-
placeholder: true,
|
|
369
|
-
i: i
|
|
370
|
-
}; // Move the element to the dragged location.
|
|
371
|
-
|
|
372
|
-
var isUserAction = true;
|
|
373
|
-
layout = (0, _utils.moveElement)(layout, l, x, y, isUserAction, this.props.preventCollision, (0, _utils.compactType)(this.props), cols);
|
|
374
|
-
this.props.onDrag(layout, oldDragItem, l, placeholder, e, node);
|
|
375
|
-
this.setState({
|
|
376
|
-
layout: (0, _utils.compact)(layout, (0, _utils.compactType)(this.props), cols),
|
|
377
|
-
activeDrag: placeholder
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* When dragging stops, figure out which position the element is closest to and update its x and y.
|
|
382
|
-
* @param {String} i Index of the child.
|
|
383
|
-
* @param {Number} x X position of the move
|
|
384
|
-
* @param {Number} y Y position of the move
|
|
385
|
-
* @param {Event} e The mousedown event
|
|
386
|
-
* @param {Element} node The current dragging DOM element
|
|
387
|
-
*/
|
|
388
|
-
|
|
389
|
-
}, {
|
|
390
|
-
key: "onDragStop",
|
|
391
|
-
value: function onDragStop(i
|
|
392
|
-
/*: string*/
|
|
393
|
-
, x
|
|
394
|
-
/*: number*/
|
|
395
|
-
, y
|
|
396
|
-
/*: number*/
|
|
397
|
-
, _ref3)
|
|
398
|
-
/*: void*/
|
|
399
|
-
{
|
|
400
|
-
var e = _ref3.e,
|
|
401
|
-
node = _ref3.node;
|
|
402
|
-
if (!this.state.activeDrag) return;
|
|
403
|
-
var oldDragItem = this.state.oldDragItem;
|
|
404
|
-
var layout = this.state.layout;
|
|
405
|
-
var _this$props3 = this.props,
|
|
406
|
-
cols = _this$props3.cols,
|
|
407
|
-
preventCollision = _this$props3.preventCollision;
|
|
408
|
-
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
409
|
-
if (!l) return; // Move the element here
|
|
410
|
-
|
|
411
|
-
var isUserAction = true;
|
|
412
|
-
layout = (0, _utils.moveElement)(layout, l, x, y, isUserAction, preventCollision, (0, _utils.compactType)(this.props), cols);
|
|
413
|
-
this.props.onDragStop(layout, oldDragItem, l, null, e, node); // Set state
|
|
414
|
-
|
|
415
|
-
var newLayout = (0, _utils.compact)(layout, (0, _utils.compactType)(this.props), cols);
|
|
416
|
-
var oldLayout = this.state.oldLayout;
|
|
417
|
-
this.setState({
|
|
418
|
-
activeDrag: null,
|
|
419
|
-
layout: newLayout,
|
|
420
|
-
oldDragItem: null,
|
|
421
|
-
oldLayout: null
|
|
422
|
-
});
|
|
423
|
-
this.onLayoutMaybeChanged(newLayout, oldLayout);
|
|
424
|
-
}
|
|
425
527
|
}, {
|
|
426
528
|
key: "onLayoutMaybeChanged",
|
|
427
529
|
value: function onLayoutMaybeChanged(newLayout
|
|
@@ -436,149 +538,26 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
436
538
|
}
|
|
437
539
|
}
|
|
438
540
|
}, {
|
|
439
|
-
key: "
|
|
440
|
-
value:
|
|
441
|
-
/*: string*/
|
|
442
|
-
, w
|
|
443
|
-
/*: number*/
|
|
444
|
-
, h
|
|
445
|
-
/*: number*/
|
|
446
|
-
, _ref4) {
|
|
447
|
-
var e = _ref4.e,
|
|
448
|
-
node = _ref4.node;
|
|
449
|
-
var layout = this.state.layout;
|
|
450
|
-
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
451
|
-
if (!l) return;
|
|
452
|
-
this.setState({
|
|
453
|
-
oldResizeItem: (0, _utils.cloneLayoutItem)(l),
|
|
454
|
-
oldLayout: this.state.layout
|
|
455
|
-
});
|
|
456
|
-
this.props.onResizeStart(layout, l, l, null, e, node);
|
|
457
|
-
}
|
|
458
|
-
}, {
|
|
459
|
-
key: "onResize",
|
|
460
|
-
value: function onResize(i
|
|
461
|
-
/*: string*/
|
|
462
|
-
, w
|
|
463
|
-
/*: number*/
|
|
464
|
-
, h
|
|
465
|
-
/*: number*/
|
|
466
|
-
, _ref5) {
|
|
467
|
-
var e = _ref5.e,
|
|
468
|
-
node = _ref5.node;
|
|
469
|
-
var _this$state = this.state,
|
|
470
|
-
layout = _this$state.layout,
|
|
471
|
-
oldResizeItem = _this$state.oldResizeItem;
|
|
472
|
-
var _this$props4 = this.props,
|
|
473
|
-
cols = _this$props4.cols,
|
|
474
|
-
preventCollision = _this$props4.preventCollision;
|
|
475
|
-
|
|
476
|
-
var _withLayoutItem = (0, _utils.withLayoutItem)(layout, i, function (l) {
|
|
477
|
-
// Something like quad tree should be used
|
|
478
|
-
// to find collisions faster
|
|
479
|
-
var hasCollisions;
|
|
480
|
-
|
|
481
|
-
if (preventCollision) {
|
|
482
|
-
var collisions = (0, _utils.getAllCollisions)(layout, _objectSpread(_objectSpread({}, l), {}, {
|
|
483
|
-
w: w,
|
|
484
|
-
h: h
|
|
485
|
-
})).filter(function (layoutItem) {
|
|
486
|
-
return layoutItem.i !== l.i;
|
|
487
|
-
});
|
|
488
|
-
hasCollisions = collisions.length > 0; // If we're colliding, we need adjust the placeholder.
|
|
489
|
-
|
|
490
|
-
if (hasCollisions) {
|
|
491
|
-
// adjust w && h to maximum allowed space
|
|
492
|
-
var leastX = Infinity,
|
|
493
|
-
leastY = Infinity;
|
|
494
|
-
collisions.forEach(function (layoutItem) {
|
|
495
|
-
if (layoutItem.x > l.x) leastX = Math.min(leastX, layoutItem.x);
|
|
496
|
-
if (layoutItem.y > l.y) leastY = Math.min(leastY, layoutItem.y);
|
|
497
|
-
});
|
|
498
|
-
if (Number.isFinite(leastX)) l.w = leastX - l.x;
|
|
499
|
-
if (Number.isFinite(leastY)) l.h = leastY - l.y;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
if (!hasCollisions) {
|
|
504
|
-
// Set new width and height.
|
|
505
|
-
l.w = w;
|
|
506
|
-
l.h = h;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return l;
|
|
510
|
-
}),
|
|
511
|
-
_withLayoutItem2 = _slicedToArray(_withLayoutItem, 2),
|
|
512
|
-
newLayout = _withLayoutItem2[0],
|
|
513
|
-
l = _withLayoutItem2[1]; // Shouldn't ever happen, but typechecking makes it necessary
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
if (!l) return; // Create placeholder element (display only)
|
|
517
|
-
|
|
518
|
-
var placeholder = {
|
|
519
|
-
w: l.w,
|
|
520
|
-
h: l.h,
|
|
521
|
-
x: l.x,
|
|
522
|
-
y: l.y,
|
|
523
|
-
static: true,
|
|
524
|
-
i: i
|
|
525
|
-
};
|
|
526
|
-
this.props.onResize(newLayout, oldResizeItem, l, placeholder, e, node); // Re-compact the newLayout and set the drag placeholder.
|
|
527
|
-
|
|
528
|
-
this.setState({
|
|
529
|
-
layout: (0, _utils.compact)(newLayout, (0, _utils.compactType)(this.props), cols),
|
|
530
|
-
activeDrag: placeholder
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
}, {
|
|
534
|
-
key: "onResizeStop",
|
|
535
|
-
value: function onResizeStop(i
|
|
536
|
-
/*: string*/
|
|
537
|
-
, w
|
|
538
|
-
/*: number*/
|
|
539
|
-
, h
|
|
540
|
-
/*: number*/
|
|
541
|
-
, _ref6) {
|
|
542
|
-
var e = _ref6.e,
|
|
543
|
-
node = _ref6.node;
|
|
544
|
-
var _this$state2 = this.state,
|
|
545
|
-
layout = _this$state2.layout,
|
|
546
|
-
oldResizeItem = _this$state2.oldResizeItem;
|
|
547
|
-
var cols = this.props.cols;
|
|
548
|
-
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
549
|
-
this.props.onResizeStop(layout, oldResizeItem, l, null, e, node); // Set state
|
|
550
|
-
|
|
551
|
-
var newLayout = (0, _utils.compact)(layout, (0, _utils.compactType)(this.props), cols);
|
|
552
|
-
var oldLayout = this.state.oldLayout;
|
|
553
|
-
this.setState({
|
|
554
|
-
activeDrag: null,
|
|
555
|
-
layout: newLayout,
|
|
556
|
-
oldResizeItem: null,
|
|
557
|
-
oldLayout: null
|
|
558
|
-
});
|
|
559
|
-
this.onLayoutMaybeChanged(newLayout, oldLayout);
|
|
560
|
-
}
|
|
541
|
+
key: "placeholder",
|
|
542
|
+
value:
|
|
561
543
|
/**
|
|
562
544
|
* Create a placeholder object.
|
|
563
545
|
* @return {Element} Placeholder div.
|
|
564
546
|
*/
|
|
565
|
-
|
|
566
|
-
}, {
|
|
567
|
-
key: "placeholder",
|
|
568
|
-
value: function placeholder()
|
|
547
|
+
function placeholder()
|
|
569
548
|
/*: ?ReactElement<any>*/
|
|
570
549
|
{
|
|
571
550
|
var activeDrag = this.state.activeDrag;
|
|
572
551
|
if (!activeDrag) return null;
|
|
573
|
-
var _this$
|
|
574
|
-
width = _this$
|
|
575
|
-
cols = _this$
|
|
576
|
-
margin = _this$
|
|
577
|
-
containerPadding = _this$
|
|
578
|
-
rowHeight = _this$
|
|
579
|
-
maxRows = _this$
|
|
580
|
-
useCSSTransforms = _this$
|
|
581
|
-
transformScale = _this$
|
|
552
|
+
var _this$props7 = this.props,
|
|
553
|
+
width = _this$props7.width,
|
|
554
|
+
cols = _this$props7.cols,
|
|
555
|
+
margin = _this$props7.margin,
|
|
556
|
+
containerPadding = _this$props7.containerPadding,
|
|
557
|
+
rowHeight = _this$props7.rowHeight,
|
|
558
|
+
maxRows = _this$props7.maxRows,
|
|
559
|
+
useCSSTransforms = _this$props7.useCSSTransforms,
|
|
560
|
+
transformScale = _this$props7.transformScale; // {...this.state.activeDrag} is pretty slow, actually
|
|
582
561
|
|
|
583
562
|
return /*#__PURE__*/React.createElement(_GridItem.default, {
|
|
584
563
|
w: activeDrag.w,
|
|
@@ -618,22 +597,22 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
618
597
|
if (!child || !child.key) return;
|
|
619
598
|
var l = (0, _utils.getLayoutItem)(this.state.layout, String(child.key));
|
|
620
599
|
if (!l) return null;
|
|
621
|
-
var _this$
|
|
622
|
-
width = _this$
|
|
623
|
-
cols = _this$
|
|
624
|
-
margin = _this$
|
|
625
|
-
containerPadding = _this$
|
|
626
|
-
rowHeight = _this$
|
|
627
|
-
maxRows = _this$
|
|
628
|
-
isDraggable = _this$
|
|
629
|
-
isResizable = _this$
|
|
630
|
-
isBounded = _this$
|
|
631
|
-
useCSSTransforms = _this$
|
|
632
|
-
transformScale = _this$
|
|
633
|
-
draggableCancel = _this$
|
|
634
|
-
draggableHandle = _this$
|
|
635
|
-
resizeHandles = _this$
|
|
636
|
-
resizeHandle = _this$
|
|
600
|
+
var _this$props8 = this.props,
|
|
601
|
+
width = _this$props8.width,
|
|
602
|
+
cols = _this$props8.cols,
|
|
603
|
+
margin = _this$props8.margin,
|
|
604
|
+
containerPadding = _this$props8.containerPadding,
|
|
605
|
+
rowHeight = _this$props8.rowHeight,
|
|
606
|
+
maxRows = _this$props8.maxRows,
|
|
607
|
+
isDraggable = _this$props8.isDraggable,
|
|
608
|
+
isResizable = _this$props8.isResizable,
|
|
609
|
+
isBounded = _this$props8.isBounded,
|
|
610
|
+
useCSSTransforms = _this$props8.useCSSTransforms,
|
|
611
|
+
transformScale = _this$props8.transformScale,
|
|
612
|
+
draggableCancel = _this$props8.draggableCancel,
|
|
613
|
+
draggableHandle = _this$props8.draggableHandle,
|
|
614
|
+
resizeHandles = _this$props8.resizeHandles,
|
|
615
|
+
resizeHandle = _this$props8.resizeHandle;
|
|
637
616
|
var _this$state3 = this.state,
|
|
638
617
|
mounted = _this$state3.mounted,
|
|
639
618
|
droppingPosition = _this$state3.droppingPosition; // Determine user manipulations possible.
|
|
@@ -690,12 +669,12 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
690
669
|
{
|
|
691
670
|
var _this2 = this;
|
|
692
671
|
|
|
693
|
-
var _this$
|
|
694
|
-
className = _this$
|
|
695
|
-
style = _this$
|
|
696
|
-
isDroppable = _this$
|
|
697
|
-
innerRef = _this$
|
|
698
|
-
var mergedClassName = (0,
|
|
672
|
+
var _this$props9 = this.props,
|
|
673
|
+
className = _this$props9.className,
|
|
674
|
+
style = _this$props9.style,
|
|
675
|
+
isDroppable = _this$props9.isDroppable,
|
|
676
|
+
innerRef = _this$props9.innerRef;
|
|
677
|
+
var mergedClassName = (0, _clsx.default)(layoutClassName, className);
|
|
699
678
|
|
|
700
679
|
var mergedStyle = _objectSpread({
|
|
701
680
|
height: this.containerHeight()
|
|
@@ -741,7 +720,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
741
720
|
|
|
742
721
|
|
|
743
722
|
if (newLayoutBase) {
|
|
744
|
-
var newLayout = (0, _utils.synchronizeLayoutWithChildren)(newLayoutBase, nextProps.children, nextProps.cols, (0, _utils.compactType)(nextProps));
|
|
723
|
+
var newLayout = (0, _utils.synchronizeLayoutWithChildren)(newLayoutBase, nextProps.children, nextProps.cols, (0, _utils.compactType)(nextProps), nextProps.allowOverlap);
|
|
745
724
|
return {
|
|
746
725
|
layout: newLayout,
|
|
747
726
|
// We need to save these props to state for using
|
|
@@ -781,6 +760,7 @@ _defineProperty(ReactGridLayout, "defaultProps", {
|
|
|
781
760
|
isBounded: false,
|
|
782
761
|
isDraggable: true,
|
|
783
762
|
isResizable: true,
|
|
763
|
+
allowOverlap: false,
|
|
784
764
|
isDroppable: false,
|
|
785
765
|
useCSSTransforms: true,
|
|
786
766
|
transformScale: 1,
|
|
@@ -800,5 +780,6 @@ _defineProperty(ReactGridLayout, "defaultProps", {
|
|
|
800
780
|
onResizeStart: _utils.noop,
|
|
801
781
|
onResize: _utils.noop,
|
|
802
782
|
onResizeStop: _utils.noop,
|
|
803
|
-
onDrop: _utils.noop
|
|
783
|
+
onDrop: _utils.noop,
|
|
784
|
+
onDropDragOver: _utils.noop
|
|
804
785
|
});
|