react-grid-layout 1.2.0 → 1.2.4
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 +2 -1
- package/.husky/pre-commit +6 -0
- package/CHANGELOG.md +45 -0
- package/README.md +24 -21
- package/build/GridItem.js +36 -58
- package/build/ReactGridLayout.js +88 -55
- package/build/ReactGridLayoutPropTypes.js +27 -7
- package/build/ResponsiveReactGridLayout.js +33 -13
- package/build/calculateUtils.js +6 -2
- package/build/components/WidthProvider.js +28 -24
- package/build/utils.js +51 -4
- package/dist/react-grid-layout.min.js +2 -6
- package/dist/react-grid-layout.min.js.LICENSE.txt +5 -0
- package/dist/react-grid-layout.min.js.map +1 -1
- package/lib/GridItem.jsx +50 -34
- package/lib/ReactGridLayout.jsx +80 -60
- package/lib/ReactGridLayoutPropTypes.js +27 -10
- package/lib/ResponsiveReactGridLayout.jsx +31 -11
- package/lib/calculateUtils.js +6 -2
- package/lib/components/WidthProvider.jsx +35 -23
- package/lib/responsiveUtils.js +5 -0
- package/lib/utils.js +39 -6
- package/package.json +36 -38
package/build/ReactGridLayout.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = void 0;
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
10
12
|
var _lodash = _interopRequireDefault(require("lodash.isequal"));
|
|
11
13
|
|
|
@@ -21,7 +23,17 @@ var _ReactGridLayoutPropTypes = _interopRequireDefault(require("./ReactGridLayou
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
|
-
function
|
|
26
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
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; }
|
|
29
|
+
|
|
30
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
|
+
|
|
32
|
+
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."); }
|
|
33
|
+
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
|
|
35
|
+
|
|
36
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
37
|
|
|
26
38
|
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; }
|
|
27
39
|
|
|
@@ -55,7 +67,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
55
67
|
|
|
56
68
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
57
69
|
|
|
58
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
70
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
59
71
|
|
|
60
72
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
61
73
|
|
|
@@ -109,13 +121,14 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
109
121
|
|
|
110
122
|
_defineProperty(_assertThisInitialized(_this), "dragEnterCounter", 0);
|
|
111
123
|
|
|
112
|
-
_defineProperty(_assertThisInitialized(_this), "onDragOver", function (e
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
_defineProperty(_assertThisInitialized(_this), "onDragOver", function (e) {
|
|
125
|
+
var _e$nativeEvent$target;
|
|
126
|
+
|
|
115
127
|
// we should ignore events from layout's children in Firefox
|
|
116
128
|
// to avoid unpredictable jumping of a dropping placeholder
|
|
117
129
|
// FIXME remove this hack
|
|
118
|
-
if (isFirefox &&
|
|
130
|
+
if (isFirefox && // $FlowIgnore can't figure this out
|
|
131
|
+
!((_e$nativeEvent$target = e.nativeEvent.target) !== null && _e$nativeEvent$target !== void 0 && _e$nativeEvent$target.classList.contains(layoutClassName))) {
|
|
119
132
|
// without this Firefox will not allow drop if currently over droppingItem
|
|
120
133
|
e.preventDefault();
|
|
121
134
|
return false;
|
|
@@ -154,7 +167,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
154
167
|
var calculatedPosition = (0, _calculateUtils.calcXY)(positionParams, layerY, layerX, droppingItem.w, droppingItem.h);
|
|
155
168
|
|
|
156
169
|
_this.setState({
|
|
157
|
-
droppingDOMNode: /*#__PURE__*/
|
|
170
|
+
droppingDOMNode: /*#__PURE__*/React.createElement("div", {
|
|
158
171
|
key: droppingItem.i
|
|
159
172
|
}),
|
|
160
173
|
droppingPosition: droppingPosition,
|
|
@@ -251,7 +264,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
251
264
|
/*: Props*/
|
|
252
265
|
, nextState
|
|
253
266
|
/*: State*/
|
|
254
|
-
)
|
|
267
|
+
)
|
|
268
|
+
/*: boolean*/
|
|
269
|
+
{
|
|
255
270
|
return (// NOTE: this is almost always unequal. Therefore the only way to get better performance
|
|
256
271
|
// from SCU is if the user intentionally memoizes children. If they do, and they can
|
|
257
272
|
// handle changes properly, performance will increase.
|
|
@@ -278,7 +293,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
278
293
|
|
|
279
294
|
}, {
|
|
280
295
|
key: "containerHeight",
|
|
281
|
-
value: function containerHeight()
|
|
296
|
+
value: function containerHeight()
|
|
297
|
+
/*: ?string*/
|
|
298
|
+
{
|
|
282
299
|
if (!this.props.autoSize) return;
|
|
283
300
|
var nbRow = (0, _utils.bottom)(this.state.layout);
|
|
284
301
|
var containerPaddingY = this.props.containerPadding ? this.props.containerPadding[1] : this.props.margin[1];
|
|
@@ -301,7 +318,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
301
318
|
/*: number*/
|
|
302
319
|
, y
|
|
303
320
|
/*: number*/
|
|
304
|
-
, _ref)
|
|
321
|
+
, _ref)
|
|
322
|
+
/*: void*/
|
|
323
|
+
{
|
|
305
324
|
var e = _ref.e,
|
|
306
325
|
node = _ref.node;
|
|
307
326
|
var layout = this.state.layout;
|
|
@@ -330,7 +349,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
330
349
|
/*: number*/
|
|
331
350
|
, y
|
|
332
351
|
/*: number*/
|
|
333
|
-
, _ref2)
|
|
352
|
+
, _ref2)
|
|
353
|
+
/*: void*/
|
|
354
|
+
{
|
|
334
355
|
var e = _ref2.e,
|
|
335
356
|
node = _ref2.node;
|
|
336
357
|
var oldDragItem = this.state.oldDragItem;
|
|
@@ -373,7 +394,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
373
394
|
/*: number*/
|
|
374
395
|
, y
|
|
375
396
|
/*: number*/
|
|
376
|
-
, _ref3)
|
|
397
|
+
, _ref3)
|
|
398
|
+
/*: void*/
|
|
399
|
+
{
|
|
377
400
|
var e = _ref3.e,
|
|
378
401
|
node = _ref3.node;
|
|
379
402
|
if (!this.state.activeDrag) return;
|
|
@@ -449,42 +472,48 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
449
472
|
var _this$props4 = this.props,
|
|
450
473
|
cols = _this$props4.cols,
|
|
451
474
|
preventCollision = _this$props4.preventCollision;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
})).filter(function (layoutItem) {
|
|
465
|
-
return layoutItem.i !== l.i;
|
|
466
|
-
});
|
|
467
|
-
hasCollisions = collisions.length > 0; // If we're colliding, we need adjust the placeholder.
|
|
468
|
-
|
|
469
|
-
if (hasCollisions) {
|
|
470
|
-
// adjust w && h to maximum allowed space
|
|
471
|
-
var leastX = Infinity,
|
|
472
|
-
leastY = Infinity;
|
|
473
|
-
collisions.forEach(function (layoutItem) {
|
|
474
|
-
if (layoutItem.x > l.x) leastX = Math.min(leastX, layoutItem.x);
|
|
475
|
-
if (layoutItem.y > l.y) leastY = Math.min(leastY, layoutItem.y);
|
|
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;
|
|
476
487
|
});
|
|
477
|
-
|
|
478
|
-
|
|
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
|
+
}
|
|
479
501
|
}
|
|
480
|
-
}
|
|
481
502
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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
|
+
|
|
487
515
|
|
|
516
|
+
if (!l) return; // Create placeholder element (display only)
|
|
488
517
|
|
|
489
518
|
var placeholder = {
|
|
490
519
|
w: l.w,
|
|
@@ -494,10 +523,10 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
494
523
|
static: true,
|
|
495
524
|
i: i
|
|
496
525
|
};
|
|
497
|
-
this.props.onResize(
|
|
526
|
+
this.props.onResize(newLayout, oldResizeItem, l, placeholder, e, node); // Re-compact the newLayout and set the drag placeholder.
|
|
498
527
|
|
|
499
528
|
this.setState({
|
|
500
|
-
layout: (0, _utils.compact)(
|
|
529
|
+
layout: (0, _utils.compact)(newLayout, (0, _utils.compactType)(this.props), cols),
|
|
501
530
|
activeDrag: placeholder
|
|
502
531
|
});
|
|
503
532
|
}
|
|
@@ -551,7 +580,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
551
580
|
useCSSTransforms = _this$props5.useCSSTransforms,
|
|
552
581
|
transformScale = _this$props5.transformScale; // {...this.state.activeDrag} is pretty slow, actually
|
|
553
582
|
|
|
554
|
-
return /*#__PURE__*/
|
|
583
|
+
return /*#__PURE__*/React.createElement(_GridItem.default, {
|
|
555
584
|
w: activeDrag.w,
|
|
556
585
|
h: activeDrag.h,
|
|
557
586
|
x: activeDrag.x,
|
|
@@ -569,7 +598,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
569
598
|
isBounded: false,
|
|
570
599
|
useCSSTransforms: useCSSTransforms,
|
|
571
600
|
transformScale: transformScale
|
|
572
|
-
}, /*#__PURE__*/
|
|
601
|
+
}, /*#__PURE__*/React.createElement("div", null));
|
|
573
602
|
}
|
|
574
603
|
/**
|
|
575
604
|
* Given a grid item, set its style attributes & surround in a <Draggable>.
|
|
@@ -616,7 +645,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
616
645
|
var resizeHandlesOptions = l.resizeHandles || resizeHandles; // isBounded set on child if set on parent, and child is not explicitly false
|
|
617
646
|
|
|
618
647
|
var bounded = draggable && isBounded && l.isBounded !== false;
|
|
619
|
-
return /*#__PURE__*/
|
|
648
|
+
return /*#__PURE__*/React.createElement(_GridItem.default, {
|
|
620
649
|
containerWidth: width,
|
|
621
650
|
cols: cols,
|
|
622
651
|
margin: margin,
|
|
@@ -656,7 +685,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
656
685
|
|
|
657
686
|
}, {
|
|
658
687
|
key: "render",
|
|
659
|
-
value: function render()
|
|
688
|
+
value: function render()
|
|
689
|
+
/*: React.Element<"div">*/
|
|
690
|
+
{
|
|
660
691
|
var _this2 = this;
|
|
661
692
|
|
|
662
693
|
var _this$props7 = this.props,
|
|
@@ -670,7 +701,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
670
701
|
height: this.containerHeight()
|
|
671
702
|
}, style);
|
|
672
703
|
|
|
673
|
-
return /*#__PURE__*/
|
|
704
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
674
705
|
ref: innerRef,
|
|
675
706
|
className: mergedClassName,
|
|
676
707
|
style: mergedStyle,
|
|
@@ -678,7 +709,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
678
709
|
onDragLeave: isDroppable ? this.onDragLeave : _utils.noop,
|
|
679
710
|
onDragEnter: isDroppable ? this.onDragEnter : _utils.noop,
|
|
680
711
|
onDragOver: isDroppable ? this.onDragOver : _utils.noop
|
|
681
|
-
},
|
|
712
|
+
}, React.Children.map(this.props.children, function (child) {
|
|
682
713
|
return _this2.processGridItem(child);
|
|
683
714
|
}), isDroppable && this.state.droppingDOMNode && this.processGridItem(this.state.droppingDOMNode, true), this.placeholder());
|
|
684
715
|
}
|
|
@@ -688,7 +719,9 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
688
719
|
/*: Props*/
|
|
689
720
|
, prevState
|
|
690
721
|
/*: State*/
|
|
691
|
-
)
|
|
722
|
+
)
|
|
723
|
+
/*: $Shape<State> | null*/
|
|
724
|
+
{
|
|
692
725
|
var newLayoutBase;
|
|
693
726
|
|
|
694
727
|
if (prevState.activeDrag) {
|
|
@@ -724,7 +757,7 @@ var ReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
724
757
|
}]);
|
|
725
758
|
|
|
726
759
|
return ReactGridLayout;
|
|
727
|
-
}(
|
|
760
|
+
}(React.Component);
|
|
728
761
|
|
|
729
762
|
exports.default = ReactGridLayout;
|
|
730
763
|
|
|
@@ -21,12 +21,16 @@ 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 resizeHandlesType
|
|
24
|
+
var resizeHandlesType
|
|
25
|
+
/*: ReactPropsChainableTypeChecker*/
|
|
26
|
+
= _propTypes.default.arrayOf(_propTypes.default.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"])); // Custom component for resize handles
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
exports.resizeHandlesType = resizeHandlesType;
|
|
28
30
|
|
|
29
|
-
var resizeHandleType
|
|
31
|
+
var resizeHandleType
|
|
32
|
+
/*: ReactPropsChainableTypeChecker*/
|
|
33
|
+
= _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]);
|
|
30
34
|
/*:: export type Props = {|
|
|
31
35
|
className: string,
|
|
32
36
|
style: Object,
|
|
@@ -66,6 +70,14 @@ var resizeHandleType = _propTypes.default.oneOfType([_propTypes.default.node, _p
|
|
|
66
70
|
innerRef?: Ref<"div">
|
|
67
71
|
|};*/
|
|
68
72
|
|
|
73
|
+
/*:: export type DefaultProps = $Diff<
|
|
74
|
+
Props,
|
|
75
|
+
{
|
|
76
|
+
children: ReactChildrenArray<ReactElement<any>>,
|
|
77
|
+
width: number
|
|
78
|
+
}
|
|
79
|
+
>;*/
|
|
80
|
+
|
|
69
81
|
|
|
70
82
|
exports.resizeHandleType = resizeHandleType;
|
|
71
83
|
var _default = {
|
|
@@ -96,7 +108,9 @@ var _default = {
|
|
|
96
108
|
}
|
|
97
109
|
},
|
|
98
110
|
// Choose vertical or hotizontal compaction
|
|
99
|
-
compactType: _propTypes.default.oneOf(["vertical", "horizontal"])
|
|
111
|
+
compactType: (_propTypes.default.oneOf(["vertical", "horizontal"])
|
|
112
|
+
/*: ReactPropsChainableTypeChecker*/
|
|
113
|
+
),
|
|
100
114
|
// layout is an array of object with the format:
|
|
101
115
|
// {x: Number, y: Number, w: Number, h: Number, i: String}
|
|
102
116
|
layout: function layout(props
|
|
@@ -112,9 +126,13 @@ var _default = {
|
|
|
112
126
|
// Grid Dimensions
|
|
113
127
|
//
|
|
114
128
|
// Margin between items [x, y] in px
|
|
115
|
-
margin: _propTypes.default.arrayOf(_propTypes.default.number)
|
|
129
|
+
margin: (_propTypes.default.arrayOf(_propTypes.default.number)
|
|
130
|
+
/*: ReactPropsChainableTypeChecker*/
|
|
131
|
+
),
|
|
116
132
|
// Padding inside the container [x, y] in px
|
|
117
|
-
containerPadding: _propTypes.default.arrayOf(_propTypes.default.number)
|
|
133
|
+
containerPadding: (_propTypes.default.arrayOf(_propTypes.default.number)
|
|
134
|
+
/*: ReactPropsChainableTypeChecker*/
|
|
135
|
+
),
|
|
118
136
|
// Rows have a static height, but you can change this based on breakpoints if you like
|
|
119
137
|
rowHeight: _propTypes.default.number,
|
|
120
138
|
// Default Infinity, but you can specify a max here if you like.
|
|
@@ -163,11 +181,13 @@ var _default = {
|
|
|
163
181
|
//
|
|
164
182
|
// Other validations
|
|
165
183
|
//
|
|
166
|
-
droppingItem: _propTypes.default.shape({
|
|
184
|
+
droppingItem: (_propTypes.default.shape({
|
|
167
185
|
i: _propTypes.default.string.isRequired,
|
|
168
186
|
w: _propTypes.default.number.isRequired,
|
|
169
187
|
h: _propTypes.default.number.isRequired
|
|
170
|
-
})
|
|
188
|
+
})
|
|
189
|
+
/*: ReactPropsChainableTypeChecker*/
|
|
190
|
+
),
|
|
171
191
|
// Children must not have duplicate keys.
|
|
172
192
|
children: function children(props
|
|
173
193
|
/*: Props*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -23,8 +25,6 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
23
25
|
|
|
24
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; }
|
|
25
27
|
|
|
26
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
27
|
-
|
|
28
28
|
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
29
|
|
|
30
30
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -51,7 +51,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
51
51
|
|
|
52
52
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
53
53
|
|
|
54
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
54
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
55
55
|
|
|
56
56
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
57
57
|
|
|
@@ -78,15 +78,16 @@ function getIndentationValue
|
|
|
78
78
|
)
|
|
79
79
|
/*: T*/
|
|
80
80
|
{
|
|
81
|
-
// $
|
|
82
|
-
if (param == null) return null;
|
|
81
|
+
// $FlowIgnore TODO fix this typedef
|
|
82
|
+
if (param == null) return null; // $FlowIgnore TODO fix this typedef
|
|
83
|
+
|
|
83
84
|
return Array.isArray(param) ? param : param[breakpoint];
|
|
84
85
|
}
|
|
85
86
|
/*:: type State = {
|
|
86
87
|
layout: Layout,
|
|
87
88
|
breakpoint: string,
|
|
88
89
|
cols: number,
|
|
89
|
-
layouts?:
|
|
90
|
+
layouts?: ResponsiveLayout<string>
|
|
90
91
|
};*/
|
|
91
92
|
|
|
92
93
|
/*:: type Props<Breakpoint: string = string> = {|
|
|
@@ -104,7 +105,7 @@ function getIndentationValue
|
|
|
104
105
|
|
|
105
106
|
// Callbacks
|
|
106
107
|
onBreakpointChange: (Breakpoint, cols: number) => void,
|
|
107
|
-
onLayoutChange:
|
|
108
|
+
onLayoutChange: OnLayoutChangeCallback,
|
|
108
109
|
onWidthChange: (
|
|
109
110
|
containerWidth: number,
|
|
110
111
|
margin: [number, number],
|
|
@@ -113,6 +114,20 @@ function getIndentationValue
|
|
|
113
114
|
) => void
|
|
114
115
|
|};*/
|
|
115
116
|
|
|
117
|
+
/*:: type DefaultProps = Pick<
|
|
118
|
+
Props<>,
|
|
119
|
+
{|
|
|
120
|
+
breakpoints: 0,
|
|
121
|
+
cols: 0,
|
|
122
|
+
containerPadding: 0,
|
|
123
|
+
layouts: 0,
|
|
124
|
+
margin: 0,
|
|
125
|
+
onBreakpointChange: 0,
|
|
126
|
+
onLayoutChange: 0,
|
|
127
|
+
onWidthChange: 0
|
|
128
|
+
|}
|
|
129
|
+
>;*/
|
|
130
|
+
|
|
116
131
|
|
|
117
132
|
var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
118
133
|
_inherits(ResponsiveReactGridLayout, _React$Component);
|
|
@@ -177,12 +192,12 @@ var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
177
192
|
|
|
178
193
|
}, {
|
|
179
194
|
key: "onWidthChange",
|
|
180
|
-
|
|
195
|
+
value:
|
|
181
196
|
/**
|
|
182
197
|
* When the width changes work through breakpoints and reset state with the new width & breakpoint.
|
|
183
198
|
* Width changes are necessary to figure out the widget widths.
|
|
184
199
|
*/
|
|
185
|
-
|
|
200
|
+
function onWidthChange(prevProps
|
|
186
201
|
/*: Props<*>*/
|
|
187
202
|
) {
|
|
188
203
|
var _this$props2 = this.props,
|
|
@@ -225,7 +240,9 @@ var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
225
240
|
}
|
|
226
241
|
}, {
|
|
227
242
|
key: "render",
|
|
228
|
-
value: function render()
|
|
243
|
+
value: function render()
|
|
244
|
+
/*: React.Element<typeof ReactGridLayout>*/
|
|
245
|
+
{
|
|
229
246
|
/* eslint-disable no-unused-vars */
|
|
230
247
|
var _this$props3 = this.props,
|
|
231
248
|
breakpoint = _this$props3.breakpoint,
|
|
@@ -242,6 +259,7 @@ var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
242
259
|
|
|
243
260
|
|
|
244
261
|
return /*#__PURE__*/React.createElement(_ReactGridLayout.default, _extends({}, other, {
|
|
262
|
+
// $FlowIgnore should allow nullable here due to DefaultProps
|
|
245
263
|
margin: getIndentationValue(margin, this.state.breakpoint),
|
|
246
264
|
containerPadding: getIndentationValue(containerPadding, this.state.breakpoint),
|
|
247
265
|
onLayoutChange: this.onLayoutChange,
|
|
@@ -255,7 +273,9 @@ var ResponsiveReactGridLayout = /*#__PURE__*/function (_React$Component) {
|
|
|
255
273
|
/*: Props<*>*/
|
|
256
274
|
, prevState
|
|
257
275
|
/*: State*/
|
|
258
|
-
)
|
|
276
|
+
)
|
|
277
|
+
/*: ?$Shape<State>*/
|
|
278
|
+
{
|
|
259
279
|
if (!(0, _lodash.default)(nextProps.layouts, prevState.layouts)) {
|
|
260
280
|
// Allow parent to set layouts directly.
|
|
261
281
|
var breakpoint = prevState.breakpoint,
|
|
@@ -348,8 +368,6 @@ _defineProperty(ResponsiveReactGridLayout, "defaultProps", {
|
|
|
348
368
|
xs: 4,
|
|
349
369
|
xxs: 2
|
|
350
370
|
},
|
|
351
|
-
layouts: {},
|
|
352
|
-
margin: [10, 10],
|
|
353
371
|
containerPadding: {
|
|
354
372
|
lg: null,
|
|
355
373
|
md: null,
|
|
@@ -357,6 +375,8 @@ _defineProperty(ResponsiveReactGridLayout, "defaultProps", {
|
|
|
357
375
|
xs: null,
|
|
358
376
|
xxs: null
|
|
359
377
|
},
|
|
378
|
+
layouts: {},
|
|
379
|
+
margin: [10, 10],
|
|
360
380
|
onBreakpointChange: _utils.noop,
|
|
361
381
|
onLayoutChange: _utils.noop,
|
|
362
382
|
onWidthChange: _utils.noop
|
package/build/calculateUtils.js
CHANGED
|
@@ -43,7 +43,9 @@ function calcGridItemWHPx(gridUnits
|
|
|
43
43
|
/*: number*/
|
|
44
44
|
, marginPx
|
|
45
45
|
/*: number*/
|
|
46
|
-
)
|
|
46
|
+
)
|
|
47
|
+
/*: number*/
|
|
48
|
+
{
|
|
47
49
|
// 0 * Infinity === NaN, which causes problems with resize contraints
|
|
48
50
|
if (!Number.isFinite(gridUnits)) return gridUnits;
|
|
49
51
|
return Math.round(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
|
|
@@ -198,6 +200,8 @@ function clamp(num
|
|
|
198
200
|
/*: number*/
|
|
199
201
|
, upperBound
|
|
200
202
|
/*: number*/
|
|
201
|
-
)
|
|
203
|
+
)
|
|
204
|
+
/*: number*/
|
|
205
|
+
{
|
|
202
206
|
return Math.max(Math.min(num, upperBound), lowerBound);
|
|
203
207
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports.default =
|
|
8
|
+
exports.default = WidthProvideRGL;
|
|
7
9
|
|
|
8
10
|
var React = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
10
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
@@ -17,8 +19,6 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
17
19
|
|
|
18
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; }
|
|
19
21
|
|
|
20
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
21
|
-
|
|
22
22
|
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
23
|
|
|
24
24
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -41,30 +41,26 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
41
41
|
|
|
42
42
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
43
|
|
|
44
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
45
|
|
|
46
46
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
47
47
|
|
|
48
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; }
|
|
49
49
|
|
|
50
|
+
var layoutClassName = "react-grid-layout";
|
|
50
51
|
/*
|
|
51
52
|
* A simple HOC that provides facility for listening to container resizes.
|
|
52
53
|
*
|
|
53
54
|
* 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
55
|
* a flow bug of some sort that causes it to stop typechecking.
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
+
|
|
58
|
+
function WidthProvideRGL
|
|
57
59
|
/*:: <Config>*/
|
|
58
60
|
(ComposedComponent
|
|
59
61
|
/*: React.AbstractComponent<Config>*/
|
|
60
62
|
)
|
|
61
|
-
/*: React.AbstractComponent<
|
|
62
|
-
...Config,
|
|
63
|
-
measureBeforeMount?: boolean,
|
|
64
|
-
className?: string,
|
|
65
|
-
style?: Object,
|
|
66
|
-
width?: number
|
|
67
|
-
|}>*/
|
|
63
|
+
/*: React.AbstractComponent<ComposedProps<Config>>*/
|
|
68
64
|
{
|
|
69
65
|
var _class, _temp;
|
|
70
66
|
|
|
@@ -88,17 +84,21 @@ function WidthProvider
|
|
|
88
84
|
width: 1280
|
|
89
85
|
});
|
|
90
86
|
|
|
87
|
+
_defineProperty(_assertThisInitialized(_this), "elementRef", /*#__PURE__*/React.createRef());
|
|
88
|
+
|
|
91
89
|
_defineProperty(_assertThisInitialized(_this), "mounted", false);
|
|
92
90
|
|
|
93
91
|
_defineProperty(_assertThisInitialized(_this), "onWindowResize", function () {
|
|
94
|
-
if (!_this.mounted) return;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (node instanceof HTMLElement)
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
if (!_this.mounted) return;
|
|
93
|
+
var node = _this.elementRef.current; // Flow casts this to Text | Element
|
|
94
|
+
// fix: grid position error when node or parentNode display is none by window resize
|
|
95
|
+
// #924 #1084
|
|
96
|
+
|
|
97
|
+
if (node instanceof HTMLElement && node.offsetWidth) {
|
|
98
|
+
_this.setState({
|
|
99
|
+
width: node.offsetWidth
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
return _this;
|
|
@@ -129,12 +129,16 @@ function WidthProvider
|
|
|
129
129
|
|
|
130
130
|
if (measureBeforeMount && !this.mounted) {
|
|
131
131
|
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
-
className: this.props.className,
|
|
133
|
-
style: this.props.style
|
|
132
|
+
className: (0, _classnames.default)(this.props.className, layoutClassName),
|
|
133
|
+
style: this.props.style // $FlowIgnore ref types
|
|
134
|
+
,
|
|
135
|
+
ref: this.elementRef
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
return /*#__PURE__*/React.createElement(ComposedComponent, _extends({
|
|
139
|
+
return /*#__PURE__*/React.createElement(ComposedComponent, _extends({
|
|
140
|
+
innerRef: this.elementRef
|
|
141
|
+
}, rest, this.state));
|
|
138
142
|
}
|
|
139
143
|
}]);
|
|
140
144
|
|