react-grid-layout 0.18.2 → 1.1.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/.babelrc.js +5 -3
- package/.flowconfig +2 -5
- package/.travis.yml +2 -1
- package/CHANGELOG.md +53 -0
- package/README.md +33 -9
- package/build/GridItem.js +129 -75
- package/build/ReactGridLayout.js +67 -59
- package/build/ReactGridLayoutPropTypes.js +15 -1
- package/build/ResponsiveReactGridLayout.js +33 -24
- package/build/calculateUtils.js +35 -9
- package/build/components/WidthProvider.js +14 -12
- package/build/fastRGLPropsEqual.js +1 -1
- package/build/responsiveUtils.js +5 -5
- package/build/utils.js +36 -10
- package/dist/react-grid-layout.min.js +7 -0
- package/dist/react-grid-layout.min.js.map +1 -0
- package/lib/GridItem.jsx +101 -69
- package/lib/ReactGridLayout.jsx +19 -5
- package/lib/ReactGridLayoutPropTypes.js +29 -14
- package/lib/ResponsiveReactGridLayout.jsx +16 -17
- package/lib/calculateUtils.js +27 -16
- package/lib/responsiveUtils.js +16 -21
- package/lib/utils.js +36 -11
- package/package.json +46 -36
- package/interfaces/classnames.js +0 -16
package/build/ReactGridLayout.js
CHANGED
|
@@ -27,13 +27,17 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
27
27
|
|
|
28
28
|
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; }
|
|
29
29
|
|
|
30
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
30
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
31
31
|
|
|
32
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
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 _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); }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
37
|
+
|
|
38
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
37
41
|
|
|
38
42
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
39
43
|
|
|
@@ -41,15 +45,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
41
45
|
|
|
42
46
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
43
47
|
|
|
44
|
-
function
|
|
48
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
45
49
|
|
|
46
|
-
function
|
|
50
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
51
|
+
|
|
52
|
+
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); }; }
|
|
53
|
+
|
|
54
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
47
55
|
|
|
48
56
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
57
|
|
|
50
|
-
function
|
|
58
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
59
|
|
|
52
|
-
function
|
|
60
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
61
|
|
|
54
62
|
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; }
|
|
55
63
|
|
|
@@ -59,19 +67,19 @@ var isFirefox = false; // Try...catch will protect from navigator not existing (
|
|
|
59
67
|
|
|
60
68
|
try {
|
|
61
69
|
isFirefox = /firefox/i.test(navigator.userAgent);
|
|
62
|
-
} catch (e) {
|
|
63
|
-
/* Ignore */
|
|
64
|
-
|
|
70
|
+
} catch (e) {
|
|
71
|
+
/* Ignore */
|
|
72
|
+
}
|
|
65
73
|
/**
|
|
66
74
|
* A reactive, fluid grid layout with draggable, resizable components.
|
|
67
75
|
*/
|
|
68
76
|
|
|
69
77
|
|
|
70
|
-
var ReactGridLayout =
|
|
71
|
-
/*#__PURE__*/
|
|
72
|
-
function (_React$Component) {
|
|
78
|
+
var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
73
79
|
_inherits(ReactGridLayout, _React$Component);
|
|
74
80
|
|
|
81
|
+
var _super = _createSuper(ReactGridLayout);
|
|
82
|
+
|
|
75
83
|
// TODO publish internal ReactClass displayName transform
|
|
76
84
|
// Refactored to another module to make way for preval
|
|
77
85
|
function ReactGridLayout(props
|
|
@@ -85,7 +93,7 @@ function (_React$Component) {
|
|
|
85
93
|
|
|
86
94
|
_classCallCheck(this, ReactGridLayout);
|
|
87
95
|
|
|
88
|
-
_this =
|
|
96
|
+
_this = _super.call(this, props, context);
|
|
89
97
|
|
|
90
98
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
91
99
|
activeDrag: null,
|
|
@@ -144,11 +152,11 @@ function (_React$Component) {
|
|
|
144
152
|
var calculatedPosition = (0, _calculateUtils.calcXY)(positionParams, layerY, layerX, droppingItem.w, droppingItem.h);
|
|
145
153
|
|
|
146
154
|
_this.setState({
|
|
147
|
-
droppingDOMNode: _react.default.createElement("div", {
|
|
155
|
+
droppingDOMNode: /*#__PURE__*/_react.default.createElement("div", {
|
|
148
156
|
key: droppingItem.i
|
|
149
157
|
}),
|
|
150
158
|
droppingPosition: droppingPosition,
|
|
151
|
-
layout: [].concat(_toConsumableArray(layout), [_objectSpread({}, droppingItem, {
|
|
159
|
+
layout: [].concat(_toConsumableArray(layout), [_objectSpread(_objectSpread({}, droppingItem), {}, {
|
|
152
160
|
x: calculatedPosition.x,
|
|
153
161
|
y: calculatedPosition.y,
|
|
154
162
|
static: false,
|
|
@@ -210,27 +218,15 @@ function (_React$Component) {
|
|
|
210
218
|
) {
|
|
211
219
|
var droppingItem = _this.props.droppingItem;
|
|
212
220
|
var layout = _this.state.layout;
|
|
213
|
-
|
|
214
|
-
var _ref = layout.find(function (l) {
|
|
221
|
+
var item = layout.find(function (l) {
|
|
215
222
|
return l.i === droppingItem.i;
|
|
216
|
-
})
|
|
217
|
-
x = _ref.x,
|
|
218
|
-
y = _ref.y,
|
|
219
|
-
w = _ref.w,
|
|
220
|
-
h = _ref.h; // reset gragEnter counter on drop
|
|
221
|
-
|
|
223
|
+
}); // reset gragEnter counter on drop
|
|
222
224
|
|
|
223
225
|
_this.dragEnterCounter = 0;
|
|
224
226
|
|
|
225
227
|
_this.removeDroppingPlaceholder();
|
|
226
228
|
|
|
227
|
-
_this.props.onDrop(
|
|
228
|
-
x: x,
|
|
229
|
-
y: y,
|
|
230
|
-
w: w,
|
|
231
|
-
h: h,
|
|
232
|
-
e: e
|
|
233
|
-
});
|
|
229
|
+
_this.props.onDrop(layout, item, e);
|
|
234
230
|
});
|
|
235
231
|
|
|
236
232
|
(0, _utils.autoBindHandlers)(_assertThisInitialized(_this), ["onDragStart", "onDrag", "onDragStop", "onResizeStart", "onResize", "onResizeStop"]);
|
|
@@ -257,7 +253,7 @@ function (_React$Component) {
|
|
|
257
253
|
return (// NOTE: this is almost always unequal. Therefore the only way to get better performance
|
|
258
254
|
// from SCU is if the user intentionally memoizes children. If they do, and they can
|
|
259
255
|
// handle changes properly, performance will increase.
|
|
260
|
-
this.props.children !== nextProps.children || !(0, _utils.fastRGLPropsEqual)(this.props, nextProps, _lodash.default) ||
|
|
256
|
+
this.props.children !== nextProps.children || !(0, _utils.fastRGLPropsEqual)(this.props, nextProps, _lodash.default) || this.state.activeDrag !== nextState.activeDrag || this.state.mounted !== nextState.mounted || this.state.droppingPosition !== nextState.droppingPosition
|
|
261
257
|
);
|
|
262
258
|
}
|
|
263
259
|
}, {
|
|
@@ -303,9 +299,9 @@ function (_React$Component) {
|
|
|
303
299
|
/*: number*/
|
|
304
300
|
, y
|
|
305
301
|
/*: number*/
|
|
306
|
-
,
|
|
307
|
-
var e =
|
|
308
|
-
node =
|
|
302
|
+
, _ref) {
|
|
303
|
+
var e = _ref.e,
|
|
304
|
+
node = _ref.node;
|
|
309
305
|
var layout = this.state.layout;
|
|
310
306
|
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
311
307
|
if (!l) return;
|
|
@@ -332,9 +328,9 @@ function (_React$Component) {
|
|
|
332
328
|
/*: number*/
|
|
333
329
|
, y
|
|
334
330
|
/*: number*/
|
|
335
|
-
,
|
|
336
|
-
var e =
|
|
337
|
-
node =
|
|
331
|
+
, _ref2) {
|
|
332
|
+
var e = _ref2.e,
|
|
333
|
+
node = _ref2.node;
|
|
338
334
|
var oldDragItem = this.state.oldDragItem;
|
|
339
335
|
var layout = this.state.layout;
|
|
340
336
|
var cols = this.props.cols;
|
|
@@ -375,9 +371,9 @@ function (_React$Component) {
|
|
|
375
371
|
/*: number*/
|
|
376
372
|
, y
|
|
377
373
|
/*: number*/
|
|
378
|
-
,
|
|
379
|
-
var e =
|
|
380
|
-
node =
|
|
374
|
+
, _ref3) {
|
|
375
|
+
var e = _ref3.e,
|
|
376
|
+
node = _ref3.node;
|
|
381
377
|
if (!this.state.activeDrag) return;
|
|
382
378
|
var oldDragItem = this.state.oldDragItem;
|
|
383
379
|
var layout = this.state.layout;
|
|
@@ -422,9 +418,9 @@ function (_React$Component) {
|
|
|
422
418
|
/*: number*/
|
|
423
419
|
, h
|
|
424
420
|
/*: number*/
|
|
425
|
-
,
|
|
426
|
-
var e =
|
|
427
|
-
node =
|
|
421
|
+
, _ref4) {
|
|
422
|
+
var e = _ref4.e,
|
|
423
|
+
node = _ref4.node;
|
|
428
424
|
var layout = this.state.layout;
|
|
429
425
|
var l = (0, _utils.getLayoutItem)(layout, i);
|
|
430
426
|
if (!l) return;
|
|
@@ -442,9 +438,9 @@ function (_React$Component) {
|
|
|
442
438
|
/*: number*/
|
|
443
439
|
, h
|
|
444
440
|
/*: number*/
|
|
445
|
-
,
|
|
446
|
-
var e =
|
|
447
|
-
node =
|
|
441
|
+
, _ref5) {
|
|
442
|
+
var e = _ref5.e,
|
|
443
|
+
node = _ref5.node;
|
|
448
444
|
var _this$state = this.state,
|
|
449
445
|
layout = _this$state.layout,
|
|
450
446
|
oldResizeItem = _this$state.oldResizeItem;
|
|
@@ -460,7 +456,7 @@ function (_React$Component) {
|
|
|
460
456
|
var hasCollisions;
|
|
461
457
|
|
|
462
458
|
if (preventCollision) {
|
|
463
|
-
var collisions = (0, _utils.getAllCollisions)(layout, _objectSpread({}, l, {
|
|
459
|
+
var collisions = (0, _utils.getAllCollisions)(layout, _objectSpread(_objectSpread({}, l), {}, {
|
|
464
460
|
w: w,
|
|
465
461
|
h: h
|
|
466
462
|
})).filter(function (layoutItem) {
|
|
@@ -511,9 +507,9 @@ function (_React$Component) {
|
|
|
511
507
|
/*: number*/
|
|
512
508
|
, h
|
|
513
509
|
/*: number*/
|
|
514
|
-
,
|
|
515
|
-
var e =
|
|
516
|
-
node =
|
|
510
|
+
, _ref6) {
|
|
511
|
+
var e = _ref6.e,
|
|
512
|
+
node = _ref6.node;
|
|
517
513
|
var _this$state2 = this.state,
|
|
518
514
|
layout = _this$state2.layout,
|
|
519
515
|
oldResizeItem = _this$state2.oldResizeItem;
|
|
@@ -553,7 +549,7 @@ function (_React$Component) {
|
|
|
553
549
|
useCSSTransforms = _this$props5.useCSSTransforms,
|
|
554
550
|
transformScale = _this$props5.transformScale; // {...this.state.activeDrag} is pretty slow, actually
|
|
555
551
|
|
|
556
|
-
return _react.default.createElement(_GridItem.default, {
|
|
552
|
+
return /*#__PURE__*/_react.default.createElement(_GridItem.default, {
|
|
557
553
|
w: activeDrag.w,
|
|
558
554
|
h: activeDrag.h,
|
|
559
555
|
x: activeDrag.x,
|
|
@@ -568,9 +564,10 @@ function (_React$Component) {
|
|
|
568
564
|
rowHeight: rowHeight,
|
|
569
565
|
isDraggable: false,
|
|
570
566
|
isResizable: false,
|
|
567
|
+
isBounded: false,
|
|
571
568
|
useCSSTransforms: useCSSTransforms,
|
|
572
569
|
transformScale: transformScale
|
|
573
|
-
}, _react.default.createElement("div", null));
|
|
570
|
+
}, /*#__PURE__*/_react.default.createElement("div", null));
|
|
574
571
|
}
|
|
575
572
|
/**
|
|
576
573
|
* Given a grid item, set its style attributes & surround in a <Draggable>.
|
|
@@ -599,10 +596,12 @@ function (_React$Component) {
|
|
|
599
596
|
maxRows = _this$props6.maxRows,
|
|
600
597
|
isDraggable = _this$props6.isDraggable,
|
|
601
598
|
isResizable = _this$props6.isResizable,
|
|
599
|
+
isBounded = _this$props6.isBounded,
|
|
602
600
|
useCSSTransforms = _this$props6.useCSSTransforms,
|
|
603
601
|
transformScale = _this$props6.transformScale,
|
|
604
602
|
draggableCancel = _this$props6.draggableCancel,
|
|
605
|
-
draggableHandle = _this$props6.draggableHandle
|
|
603
|
+
draggableHandle = _this$props6.draggableHandle,
|
|
604
|
+
resizeHandles = _this$props6.resizeHandles;
|
|
606
605
|
var _this$state3 = this.state,
|
|
607
606
|
mounted = _this$state3.mounted,
|
|
608
607
|
droppingPosition = _this$state3.droppingPosition; // Determine user manipulations possible.
|
|
@@ -611,7 +610,10 @@ function (_React$Component) {
|
|
|
611
610
|
|
|
612
611
|
var draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
|
|
613
612
|
var resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
|
|
614
|
-
|
|
613
|
+
var resizeHandlesOptions = l.resizeHandles || resizeHandles; // isBounded set on child if set on parent, and child is not explicitly false
|
|
614
|
+
|
|
615
|
+
var bounded = draggable && isBounded && l.isBounded !== false;
|
|
616
|
+
return /*#__PURE__*/_react.default.createElement(_GridItem.default, {
|
|
615
617
|
containerWidth: width,
|
|
616
618
|
cols: cols,
|
|
617
619
|
margin: margin,
|
|
@@ -628,6 +630,7 @@ function (_React$Component) {
|
|
|
628
630
|
onResizeStop: this.onResizeStop,
|
|
629
631
|
isDraggable: draggable,
|
|
630
632
|
isResizable: resizable,
|
|
633
|
+
isBounded: bounded,
|
|
631
634
|
useCSSTransforms: useCSSTransforms && mounted,
|
|
632
635
|
usePercentages: !mounted,
|
|
633
636
|
transformScale: transformScale,
|
|
@@ -641,7 +644,8 @@ function (_React$Component) {
|
|
|
641
644
|
maxH: l.maxH,
|
|
642
645
|
maxW: l.maxW,
|
|
643
646
|
static: l.static,
|
|
644
|
-
droppingPosition: isDroppingItem ? droppingPosition : undefined
|
|
647
|
+
droppingPosition: isDroppingItem ? droppingPosition : undefined,
|
|
648
|
+
resizeHandles: resizeHandlesOptions
|
|
645
649
|
}, child);
|
|
646
650
|
} // Called while dragging an element. Part of browser native drag/drop API.
|
|
647
651
|
// Native event target might be the layout itself, or an element within the layout.
|
|
@@ -654,14 +658,16 @@ function (_React$Component) {
|
|
|
654
658
|
var _this$props7 = this.props,
|
|
655
659
|
className = _this$props7.className,
|
|
656
660
|
style = _this$props7.style,
|
|
657
|
-
isDroppable = _this$props7.isDroppable
|
|
661
|
+
isDroppable = _this$props7.isDroppable,
|
|
662
|
+
innerRef = _this$props7.innerRef;
|
|
658
663
|
var mergedClassName = (0, _classnames.default)(layoutClassName, className);
|
|
659
664
|
|
|
660
665
|
var mergedStyle = _objectSpread({
|
|
661
666
|
height: this.containerHeight()
|
|
662
667
|
}, style);
|
|
663
668
|
|
|
664
|
-
return _react.default.createElement("div", {
|
|
669
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
670
|
+
ref: innerRef,
|
|
665
671
|
className: mergedClassName,
|
|
666
672
|
style: mergedStyle,
|
|
667
673
|
onDrop: isDroppable ? this.onDrop : _utils.noop,
|
|
@@ -735,6 +741,7 @@ _defineProperty(ReactGridLayout, "defaultProps", {
|
|
|
735
741
|
// infinite vertical growth
|
|
736
742
|
layout: [],
|
|
737
743
|
margin: [10, 10],
|
|
744
|
+
isBounded: false,
|
|
738
745
|
isDraggable: true,
|
|
739
746
|
isResizable: true,
|
|
740
747
|
isDroppable: false,
|
|
@@ -748,6 +755,7 @@ _defineProperty(ReactGridLayout, "defaultProps", {
|
|
|
748
755
|
h: 1,
|
|
749
756
|
w: 1
|
|
750
757
|
},
|
|
758
|
+
resizeHandles: ["se"],
|
|
751
759
|
onLayoutChange: _utils.noop,
|
|
752
760
|
onDragStart: _utils.noop,
|
|
753
761
|
onDrag: _utils.noop,
|
|
@@ -69,6 +69,7 @@ var _default = {
|
|
|
69
69
|
//
|
|
70
70
|
// Flags
|
|
71
71
|
//
|
|
72
|
+
isBounded: _propTypes.default.bool,
|
|
72
73
|
isDraggable: _propTypes.default.bool,
|
|
73
74
|
isResizable: _propTypes.default.bool,
|
|
74
75
|
// If true, grid items won't change position when being dragged over.
|
|
@@ -79,6 +80,17 @@ var _default = {
|
|
|
79
80
|
transformScale: _propTypes.default.number,
|
|
80
81
|
// If true, an external element can trigger onDrop callback with a specific grid position as a parameter
|
|
81
82
|
isDroppable: _propTypes.default.bool,
|
|
83
|
+
// Defines which resize handles should be rendered (default: 'se')
|
|
84
|
+
// Allows for any combination of:
|
|
85
|
+
// 's' - South handle (bottom-center)
|
|
86
|
+
// 'w' - West handle (left-center)
|
|
87
|
+
// 'e' - East handle (right-center)
|
|
88
|
+
// 'n' - North handle (top-center)
|
|
89
|
+
// 'sw' - Southwest handle (bottom-left)
|
|
90
|
+
// 'nw' - Northwest handle (top-left)
|
|
91
|
+
// 'se' - Southeast handle (bottom-right)
|
|
92
|
+
// 'ne' - Northeast handle (top-right)
|
|
93
|
+
resizeHandles: _propTypes.default.arrayOf(_propTypes.default.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"])),
|
|
82
94
|
//
|
|
83
95
|
// Callbacks
|
|
84
96
|
//
|
|
@@ -124,6 +136,8 @@ var _default = {
|
|
|
124
136
|
|
|
125
137
|
keys[child.key] = true;
|
|
126
138
|
});
|
|
127
|
-
}
|
|
139
|
+
},
|
|
140
|
+
// Optional ref for getting a reference for the wrapping div.
|
|
141
|
+
innerRef: _propTypes.default.any
|
|
128
142
|
};
|
|
129
143
|
exports.default = _default;
|
|
@@ -41,15 +41,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
41
41
|
|
|
42
42
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
45
45
|
|
|
46
|
-
function
|
|
46
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
47
|
+
|
|
48
|
+
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
|
+
|
|
50
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
47
51
|
|
|
48
52
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
53
|
|
|
50
|
-
function
|
|
54
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
55
|
|
|
52
|
-
function
|
|
56
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
57
|
|
|
54
58
|
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; }
|
|
55
59
|
|
|
@@ -65,11 +69,17 @@ var type = function type(obj) {
|
|
|
65
69
|
*/
|
|
66
70
|
|
|
67
71
|
|
|
68
|
-
function getIndentationValue
|
|
69
|
-
|
|
72
|
+
function getIndentationValue
|
|
73
|
+
/*:: <T: ?[number, number]>*/
|
|
74
|
+
(param
|
|
75
|
+
/*: { [key: string]: T } | T*/
|
|
70
76
|
, breakpoint
|
|
71
77
|
/*: string*/
|
|
72
|
-
)
|
|
78
|
+
)
|
|
79
|
+
/*: T*/
|
|
80
|
+
{
|
|
81
|
+
// $FlowIssue doesn't seem to understand this
|
|
82
|
+
if (param == null) return null;
|
|
73
83
|
return Array.isArray(param) ? param : param[breakpoint];
|
|
74
84
|
}
|
|
75
85
|
/*:: type State = {
|
|
@@ -84,12 +94,13 @@ function getIndentationValue(param
|
|
|
84
94
|
|
|
85
95
|
// Responsive config
|
|
86
96
|
breakpoint?: ?Breakpoint,
|
|
87
|
-
breakpoints:
|
|
97
|
+
breakpoints: Breakpoints<Breakpoint>,
|
|
88
98
|
cols: { [key: Breakpoint]: number },
|
|
89
|
-
layouts:
|
|
99
|
+
layouts: ResponsiveLayout<Breakpoint>,
|
|
90
100
|
width: number,
|
|
91
101
|
margin: { [key: Breakpoint]: [number, number] } | [number, number],
|
|
92
|
-
|
|
102
|
+
/* prettier-ignore *-/
|
|
103
|
+
containerPadding: { [key: Breakpoint]: ?[number, number] } | ?[number, number],
|
|
93
104
|
|
|
94
105
|
// Callbacks
|
|
95
106
|
onBreakpointChange: (Breakpoint, cols: number) => void,
|
|
@@ -98,19 +109,17 @@ function getIndentationValue(param
|
|
|
98
109
|
containerWidth: number,
|
|
99
110
|
margin: [number, number],
|
|
100
111
|
cols: number,
|
|
101
|
-
containerPadding: [number, number]
|
|
112
|
+
containerPadding: ?[number, number]
|
|
102
113
|
) => void
|
|
103
114
|
|};*/
|
|
104
115
|
|
|
105
116
|
|
|
106
|
-
var ResponsiveReactGridLayout =
|
|
107
|
-
/*#__PURE__*/
|
|
108
|
-
function (_React$Component) {
|
|
117
|
+
var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
109
118
|
_inherits(ResponsiveReactGridLayout, _React$Component);
|
|
110
119
|
|
|
111
|
-
|
|
112
|
-
var _getPrototypeOf2;
|
|
120
|
+
var _super = _createSuper(ResponsiveReactGridLayout);
|
|
113
121
|
|
|
122
|
+
function ResponsiveReactGridLayout() {
|
|
114
123
|
var _this;
|
|
115
124
|
|
|
116
125
|
_classCallCheck(this, ResponsiveReactGridLayout);
|
|
@@ -119,14 +128,14 @@ function (_React$Component) {
|
|
|
119
128
|
args[_key] = arguments[_key];
|
|
120
129
|
}
|
|
121
130
|
|
|
122
|
-
_this =
|
|
131
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
123
132
|
|
|
124
133
|
_defineProperty(_assertThisInitialized(_this), "state", _this.generateInitialState());
|
|
125
134
|
|
|
126
135
|
_defineProperty(_assertThisInitialized(_this), "onLayoutChange", function (layout
|
|
127
136
|
/*: Layout*/
|
|
128
137
|
) {
|
|
129
|
-
_this.props.onLayoutChange(layout, _objectSpread({}, _this.props.layouts, _defineProperty({}, _this.state.breakpoint, layout)));
|
|
138
|
+
_this.props.onLayoutChange(layout, _objectSpread(_objectSpread({}, _this.props.layouts), {}, _defineProperty({}, _this.state.breakpoint, layout)));
|
|
130
139
|
});
|
|
131
140
|
|
|
132
141
|
return _this;
|
|
@@ -232,7 +241,7 @@ function (_React$Component) {
|
|
|
232
241
|
/* eslint-enable no-unused-vars */
|
|
233
242
|
|
|
234
243
|
|
|
235
|
-
return React.createElement(_ReactGridLayout.default, _extends({}, other, {
|
|
244
|
+
return /*#__PURE__*/React.createElement(_ReactGridLayout.default, _extends({}, other, {
|
|
236
245
|
margin: getIndentationValue(margin, this.state.breakpoint),
|
|
237
246
|
containerPadding: getIndentationValue(containerPadding, this.state.breakpoint),
|
|
238
247
|
onLayoutChange: this.onLayoutChange,
|
|
@@ -342,11 +351,11 @@ _defineProperty(ResponsiveReactGridLayout, "defaultProps", {
|
|
|
342
351
|
layouts: {},
|
|
343
352
|
margin: [10, 10],
|
|
344
353
|
containerPadding: {
|
|
345
|
-
lg:
|
|
346
|
-
md:
|
|
347
|
-
sm:
|
|
348
|
-
xs:
|
|
349
|
-
xxs:
|
|
354
|
+
lg: null,
|
|
355
|
+
md: null,
|
|
356
|
+
sm: null,
|
|
357
|
+
xs: null,
|
|
358
|
+
xxs: null
|
|
350
359
|
},
|
|
351
360
|
onBreakpointChange: _utils.noop,
|
|
352
361
|
onLayoutChange: _utils.noop,
|
package/build/calculateUtils.js
CHANGED
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calcGridColWidth = calcGridColWidth;
|
|
7
|
+
exports.calcGridItemWHPx = calcGridItemWHPx;
|
|
7
8
|
exports.calcGridItemPosition = calcGridItemPosition;
|
|
8
9
|
exports.calcXY = calcXY;
|
|
9
10
|
exports.calcWH = calcWH;
|
|
11
|
+
exports.clamp = clamp;
|
|
10
12
|
|
|
11
13
|
/*:: import type { Position } from "./utils";*/
|
|
12
14
|
|
|
@@ -29,6 +31,22 @@ function calcGridColWidth(positionParams
|
|
|
29
31
|
containerWidth = positionParams.containerWidth,
|
|
30
32
|
cols = positionParams.cols;
|
|
31
33
|
return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
|
|
34
|
+
} // This can either be called:
|
|
35
|
+
// calcGridItemWHPx(w, colWidth, margin[0])
|
|
36
|
+
// or
|
|
37
|
+
// calcGridItemWHPx(h, rowHeight, margin[1])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function calcGridItemWHPx(gridUnits
|
|
41
|
+
/*: number*/
|
|
42
|
+
, colOrRowSize
|
|
43
|
+
/*: number*/
|
|
44
|
+
, marginPx
|
|
45
|
+
/*: number*/
|
|
46
|
+
) {
|
|
47
|
+
// 0 * Infinity === NaN, which causes problems with resize contraints
|
|
48
|
+
if (!Number.isFinite(gridUnits)) return gridUnits;
|
|
49
|
+
return Math.round(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
|
|
32
50
|
}
|
|
33
51
|
/**
|
|
34
52
|
* Return position on the page given an x, y, w, h.
|
|
@@ -68,11 +86,8 @@ function calcGridItemPosition(positionParams
|
|
|
68
86
|
out.height = Math.round(state.resizing.height);
|
|
69
87
|
} // Otherwise, calculate from grid units.
|
|
70
88
|
else {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Note we do it here rather than later because Math.round(Infinity) causes deopt
|
|
74
|
-
out.width = w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * margin[0]);
|
|
75
|
-
out.height = h === Infinity ? h : Math.round(rowHeight * h + Math.max(0, h - 1) * margin[1]);
|
|
89
|
+
out.width = calcGridItemWHPx(w, colWidth, margin[0]);
|
|
90
|
+
out.height = calcGridItemWHPx(h, rowHeight, margin[1]);
|
|
76
91
|
} // If dragging, use the exact width and height as returned from dragging callbacks.
|
|
77
92
|
|
|
78
93
|
|
|
@@ -126,8 +141,8 @@ function calcXY(positionParams
|
|
|
126
141
|
var x = Math.round((left - margin[0]) / (colWidth + margin[0]));
|
|
127
142
|
var y = Math.round((top - margin[1]) / (rowHeight + margin[1])); // Capping
|
|
128
143
|
|
|
129
|
-
x =
|
|
130
|
-
y =
|
|
144
|
+
x = clamp(x, 0, cols - w);
|
|
145
|
+
y = clamp(y, 0, maxRows - h);
|
|
131
146
|
return {
|
|
132
147
|
x: x,
|
|
133
148
|
y: y
|
|
@@ -168,10 +183,21 @@ function calcWH(positionParams
|
|
|
168
183
|
var w = Math.round((width + margin[0]) / (colWidth + margin[0]));
|
|
169
184
|
var h = Math.round((height + margin[1]) / (rowHeight + margin[1])); // Capping
|
|
170
185
|
|
|
171
|
-
w =
|
|
172
|
-
h =
|
|
186
|
+
w = clamp(w, 0, cols - x);
|
|
187
|
+
h = clamp(h, 0, maxRows - y);
|
|
173
188
|
return {
|
|
174
189
|
w: w,
|
|
175
190
|
h: h
|
|
176
191
|
};
|
|
192
|
+
} // Similar to _.clamp
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
function clamp(num
|
|
196
|
+
/*: number*/
|
|
197
|
+
, lowerBound
|
|
198
|
+
/*: number*/
|
|
199
|
+
, upperBound
|
|
200
|
+
/*: number*/
|
|
201
|
+
) {
|
|
202
|
+
return Math.max(Math.min(num, upperBound), lowerBound);
|
|
177
203
|
}
|
|
@@ -31,15 +31,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
31
31
|
|
|
32
32
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
+
|
|
38
|
+
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
|
+
|
|
40
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
37
41
|
|
|
38
42
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
43
|
|
|
40
|
-
function
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
45
|
|
|
42
|
-
function
|
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
47
|
|
|
44
48
|
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; }
|
|
45
49
|
|
|
@@ -64,14 +68,12 @@ function WidthProvider
|
|
|
64
68
|
{
|
|
65
69
|
var _class, _temp;
|
|
66
70
|
|
|
67
|
-
return _temp = _class =
|
|
68
|
-
/*#__PURE__*/
|
|
69
|
-
function (_React$Component) {
|
|
71
|
+
return _temp = _class = /*#__PURE__*/function (_React$Component) {
|
|
70
72
|
_inherits(WidthProvider, _React$Component);
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
var _getPrototypeOf2;
|
|
74
|
+
var _super = _createSuper(WidthProvider);
|
|
74
75
|
|
|
76
|
+
function WidthProvider() {
|
|
75
77
|
var _this;
|
|
76
78
|
|
|
77
79
|
_classCallCheck(this, WidthProvider);
|
|
@@ -80,7 +82,7 @@ function WidthProvider
|
|
|
80
82
|
args[_key] = arguments[_key];
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
_this =
|
|
85
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
84
86
|
|
|
85
87
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
86
88
|
width: 1280
|
|
@@ -126,13 +128,13 @@ function WidthProvider
|
|
|
126
128
|
rest = _objectWithoutProperties(_this$props, ["measureBeforeMount"]);
|
|
127
129
|
|
|
128
130
|
if (measureBeforeMount && !this.mounted) {
|
|
129
|
-
return React.createElement("div", {
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
130
132
|
className: this.props.className,
|
|
131
133
|
style: this.props.style
|
|
132
134
|
});
|
|
133
135
|
}
|
|
134
136
|
|
|
135
|
-
return React.createElement(ComposedComponent, _extends({}, rest, this.state));
|
|
137
|
+
return /*#__PURE__*/React.createElement(ComposedComponent, _extends({}, rest, this.state));
|
|
136
138
|
}
|
|
137
139
|
}]);
|
|
138
140
|
|
|
@@ -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.isDraggable === b.isDraggable && a.isResizable === b.isResizable && a.preventCollision === b.preventCollision && a.useCSSTransforms === b.useCSSTransforms && a.transformScale === b.transformScale && a.isDroppable === b.isDroppable && 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);
|
|
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) && 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
|
};
|