react-grid-layout 1.1.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.flowconfig CHANGED
@@ -1,5 +1,5 @@
1
1
  [version]
2
- ^0.133.0
2
+ ^0.145.0
3
3
 
4
4
  [ignore]
5
5
  <PROJECT_ROOT>/build/.*
@@ -15,5 +15,6 @@ interfaces/
15
15
  flow-typed/
16
16
 
17
17
  [options]
18
+ sharedmemory.heap_size=3221225472
18
19
  emoji=true
19
20
  module.use_strict=true
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ yarn lint-staged
5
+ make lint
6
+ make test
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ 1.2.2 (Mar 1, 2021)
4
+ ---
5
+
6
+ ### Bugfixes
7
+ - `onResize` as changed in 1.2.1 did not correctly save the layout. This is now fixed.
8
+ - As you might guess, we need more test coverage! PRs are very welcome, I'll buy you beers on Cashapp or Patreon or whatever you like.
9
+
10
+ 1.2.1 (Mar 1, 2021)
11
+ ---
12
+
13
+ ## Organization Changes
14
+
15
+ We have created the [React-Grid-Layout Organization](https://github.com/react-grid-layout)! Therefore the repository
16
+ [has moved](https://github.com/react-grid-layout/react-grid-layout).
17
+
18
+ This organization will grow as time goes on, and also contains the dependencies of RGL.
19
+
20
+ ### Bugfixes
21
+ - Use `classList` in Firefox onDragOver hack. [#1310](https://github.com/STRML/react-grid-layout/pull/1310)
22
+ - Fix `scale` property. As `scale` support was added to dependencies, this caused double-compensation for scale, causing the dragged element not to follow the cursor. [#1393](https://github.com/STRML/react-grid-layout/pull/1393)
23
+ - Fix horizontal compact mode issue where it inadventently would compact the bottom of the grid. This is not useful nor intended. Thanks @s4m3. [#1390](https://github.com/STRML/react-grid-layout/pull/1390)
24
+ - Fix `onLayoutChange` sometimes not triggering on resize. We weren't cloning the layout item before modifying it. Thanks @xcqwan. [#1289](https://github.com/react-grid-layout/react-grid-layout/pull/1289)
25
+
26
+ ### Internal Refactors
27
+ - Updated to the latest versions of all dependencies (enzyme, webpack, jest, flow).
28
+ - Held back React@17 as enzyme is [not yet ready](https://github.com/enzymejs/enzyme/issues/2429).
29
+
30
+ 1.2.0 (Nov 17, 2020)
31
+ ---
32
+
33
+ ### New Features
34
+ - You can now customize your resizable handle component as supported by [`react-resizable`](https://github.com/STRML/react-resizable/blob/09fd865c0e1cc570caa8d67e44a2e56172d3d816/examples/ExampleLayout.js#L72). For example:
35
+ ```js
36
+ <ReactGridLayout resizeHandle={<span className="custom-handle custom-handle-se" />} {...props} />
37
+ ````
38
+ Thanks @typeetfunc [#1303](https://github.com/STRML/react-grid-layout/pull/1303)
39
+
40
+ ### Bugfixes
41
+ - Fix `onDrop` handler not firing on Firefox if you drop over the placeholder.
42
+ - Thanks @Charles-Lamoureux [#1333](https://github.com/STRML/react-grid-layout/pull/1333)
43
+ - Various example style fixes [#1283](https://github.com/STRML/react-grid-layout/pull/1283) [#1299](https://github.com/STRML/react-grid-layout/pull/1299)
44
+
45
+ 1.1.1 (Sep 10, 2020)
46
+ ---
47
+
48
+ Republish to add `dist/` folder for unpkg use.
49
+
3
50
  1.1.0 (Sep 3, 2020)
4
51
  ---
5
52
 
@@ -26,10 +73,10 @@
26
73
  React-Grid-Layout has been in `0.x` status for far too long. With the addition of some new features in this version and a breaking change, I thought it was time to move to a stable semver.
27
74
 
28
75
  ### Breaking Changes
29
- - `onDrop` callback now has a form more consistent with other callbacks.
30
- - Previous type: `(elemParams: { x: number, y: number, w: number, h: number, e: Event }) => void`
31
- - New type: `(layout: Layout, item: ?LayoutItem, e: Event) => void`
32
- - Thanks @ceberhar [#1169](https://github.com/STRML/react-grid-layout/pull/1169)
76
+ - `onDrop` callback now has a form more consistent with other callbacks.
77
+ - Previous type: `(elemParams: { x: number, y: number, w: number, h: number, e: Event }) => void`
78
+ - New type: `(layout: Layout, item: ?LayoutItem, e: Event) => void`
79
+ - Thanks @ceberhar [#1169](https://github.com/STRML/react-grid-layout/pull/1169)
33
80
  - Dropping Node 8 compatibility and testing due to devDep incompatibilities
34
81
 
35
82
  ### New Features
package/README.md CHANGED
@@ -16,7 +16,7 @@ RGL is React-only and does not require jQuery.
16
16
  ![BitMEX UI](http://i.imgur.com/oo1NT6c.gif)
17
17
  > GIF from production usage on [BitMEX.com](https://www.bitmex.com)
18
18
 
19
- [**[Demo](https://strml.github.io/react-grid-layout/examples/0-showcase.html) | [Changelog](/CHANGELOG.md) | [CodeSandbox Editable demo](https://codesandbox.io/s/5wy3rz5z1x?module=%2Fsrc%2FShowcaseLayout.js)**]
19
+ [**[Demo](https://react-grid-layout.github.io/react-grid-layout/examples/0-showcase.html) | [Changelog](/CHANGELOG.md) | [CodeSandbox Editable demo](https://codesandbox.io/s/5wy3rz5z1x?module=%2Fsrc%2FShowcaseLayout.js)**]
20
20
 
21
21
  ## Table of Contents
22
22
 
@@ -36,24 +36,25 @@ RGL is React-only and does not require jQuery.
36
36
 
37
37
  ## Demos
38
38
 
39
- 1. [Showcase](https://strml.github.io/react-grid-layout/examples/0-showcase.html)
40
- 1. [Basic](https://strml.github.io/react-grid-layout/examples/1-basic.html)
41
- 1. [No Dragging/Resizing (Layout Only)](https://strml.github.io/react-grid-layout/examples/2-no-dragging.html)
42
- 1. [Messy Layout Autocorrect](https://strml.github.io/react-grid-layout/examples/3-messy.html)
43
- 1. [Layout Defined on Children](https://strml.github.io/react-grid-layout/examples/4-grid-property.html)
44
- 1. [Static Elements](https://strml.github.io/react-grid-layout/examples/5-static-elements.html)
45
- 1. [Adding/Removing Elements](https://strml.github.io/react-grid-layout/examples/6-dynamic-add-remove.html)
46
- 1. [Saving Layout to LocalStorage](https://strml.github.io/react-grid-layout/examples/7-localstorage.html)
47
- 1. [Saving a Responsive Layout to LocalStorage](https://strml.github.io/react-grid-layout/examples/8-localstorage-responsive.html)
48
- 1. [Minimum and Maximum Width/Height](https://strml.github.io/react-grid-layout/examples/9-min-max-wh.html)
49
- 1. [Dynamic Minimum and Maximum Width/Height](https://strml.github.io/react-grid-layout/examples/10-dynamic-min-max-wh.html)
50
- 1. [No Vertical Compacting (Free Movement)](https://strml.github.io/react-grid-layout/examples/11-no-vertical-compact.html)
51
- 1. [Prevent Collision](https://strml.github.io/react-grid-layout/examples/12-prevent-collision.html)
52
- 1. [Error Case](https://strml.github.io/react-grid-layout/examples/13-error-case.html)
53
- 1. [Toolbox](https://strml.github.io/react-grid-layout/examples/14-toolbox.html)
54
- 1. [Drag From Outside](https://strml.github.io/react-grid-layout/examples/15-drag-from-outside.html)
55
- 1. [Bounded Layout](https://strml.github.io/react-grid-layout/examples/16-bounded.html)
56
- 1. [Resizable Handles](https://strml.github.io/react-grid-layout/examples/17-resizable-handles.html)
39
+ 1. [Showcase](https://react-grid-layout.github.io/react-grid-layout/examples/0-showcase.html)
40
+ 1. [Basic](https://react-grid-layout.github.io/react-grid-layout/examples/1-basic.html)
41
+ 1. [No Dragging/Resizing (Layout Only)](https://react-grid-layout.github.io/react-grid-layout/examples/2-no-dragging.html)
42
+ 1. [Messy Layout Autocorrect](https://react-grid-layout.github.io/react-grid-layout/examples/3-messy.html)
43
+ 1. [Layout Defined on Children](https://react-grid-layout.github.io/react-grid-layout/examples/4-grid-property.html)
44
+ 1. [Static Elements](https://react-grid-layout.github.io/react-grid-layout/examples/5-static-elements.html)
45
+ 1. [Adding/Removing Elements](https://react-grid-layout.github.io/react-grid-layout/examples/6-dynamic-add-remove.html)
46
+ 1. [Saving Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/7-localstorage.html)
47
+ 1. [Saving a Responsive Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/8-localstorage-responsive.html)
48
+ 1. [Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/9-min-max-wh.html)
49
+ 1. [Dynamic Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/10-dynamic-min-max-wh.html)
50
+ 1. [No Vertical Compacting (Free Movement)](https://react-grid-layout.github.io/react-grid-layout/examples/11-no-vertical-compact.html)
51
+ 1. [Prevent Collision](https://react-grid-layout.github.io/react-grid-layout/examples/12-prevent-collision.html)
52
+ 1. [Error Case](https://react-grid-layout.github.io/react-grid-layout/examples/13-error-case.html)
53
+ 1. [Toolbox](https://react-grid-layout.github.io/react-grid-layout/examples/14-toolbox.html)
54
+ 1. [Drag From Outside](https://react-grid-layout.github.io/react-grid-layout/examples/15-drag-from-outside.html)
55
+ 1. [Bounded Layout](https://react-grid-layout.github.io/react-grid-layout/examples/16-bounded.html)
56
+ 1. [Resizable Handles](https://react-grid-layout.github.io/react-grid-layout/examples/17-resizable-handles.html)
57
+ 1. [Scaled Containers](https://react-grid-layout.github.io/react-grid-layout/examples/18-scale.html)
57
58
 
58
59
  #### Projects Using React-Grid-Layout
59
60
 
@@ -71,6 +72,8 @@ RGL is React-only and does not require jQuery.
71
72
  - [Monday](https://support.monday.com/hc/en-us/articles/360002187819-What-are-the-Dashboards-)
72
73
  - [Quadency](https://quadency.com/)
73
74
  - [Hakkiri](https://www.hakkiri.io)
75
+ - [Ubidots](https://help.ubidots.com/en/articles/2400308-create-dashboards-and-widgets)
76
+ - [Statsout](https://statsout.com/)
74
77
 
75
78
  *Know of others? Create a PR to let me know!*
76
79
 
@@ -340,6 +343,8 @@ isDroppable: ?boolean = false
340
343
  // 'se' - Southeast handle (bottom-right)
341
344
  // 'ne' - Northeast handle (top-right)
342
345
  resizeHandles: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se']
346
+ // Custom component for resize handles
347
+ resizeHandle?: ReactElement<any> | ((resizeHandleAxis: ResizeHandleAxis) => ReactElement<any>)
343
348
 
344
349
  //
345
350
  // Callbacks
package/build/GridItem.js CHANGED
@@ -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
  });
@@ -19,12 +21,12 @@ var _utils = require("./utils");
19
21
 
20
22
  var _calculateUtils = require("./calculateUtils");
21
23
 
24
+ var _ReactGridLayoutPropTypes = require("./ReactGridLayoutPropTypes");
25
+
22
26
  var _classnames = _interopRequireDefault(require("classnames"));
23
27
 
24
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
29
 
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
30
  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; }
29
31
 
30
32
  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; }
@@ -45,7 +47,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
45
47
 
46
48
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
49
 
48
- 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; } }
50
+ 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; } }
49
51
 
50
52
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
51
53
 
@@ -78,11 +80,11 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
78
80
 
79
81
  _defineProperty(_assertThisInitialized(_this), "currentNode", void 0);
80
82
 
81
- _defineProperty(_assertThisInitialized(_this), "onDragStart", function (e
82
- /*: Event*/
83
- , _ref) {
83
+ _defineProperty(_assertThisInitialized(_this), "onDragStart", function (e, _ref) {
84
84
  var node = _ref.node;
85
- var onDragStart = _this.props.onDragStart;
85
+ var _this$props = _this.props,
86
+ onDragStart = _this$props.onDragStart,
87
+ transformScale = _this$props.transformScale;
86
88
  if (!onDragStart) return;
87
89
  var newPosition
88
90
  /*: PartialPosition*/
@@ -95,10 +97,10 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
95
97
  if (!offsetParent) return;
96
98
  var parentRect = offsetParent.getBoundingClientRect();
97
99
  var clientRect = node.getBoundingClientRect();
98
- var cLeft = clientRect.left / _this.props.transformScale;
99
- var pLeft = parentRect.left / _this.props.transformScale;
100
- var cTop = clientRect.top / _this.props.transformScale;
101
- var pTop = parentRect.top / _this.props.transformScale;
100
+ var cLeft = clientRect.left / transformScale;
101
+ var pLeft = parentRect.left / transformScale;
102
+ var cTop = clientRect.top / transformScale;
103
+ var pTop = parentRect.top / transformScale;
102
104
  newPosition.left = cLeft - pLeft + offsetParent.scrollLeft;
103
105
  newPosition.top = cTop - pTop + offsetParent.scrollTop;
104
106
 
@@ -118,18 +120,12 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
118
120
  });
119
121
  });
120
122
 
121
- _defineProperty(_assertThisInitialized(_this), "onDrag", function (e
122
- /*: Event*/
123
- , _ref2) {
123
+ _defineProperty(_assertThisInitialized(_this), "onDrag", function (e, _ref2) {
124
124
  var node = _ref2.node,
125
125
  deltaX = _ref2.deltaX,
126
126
  deltaY = _ref2.deltaY;
127
- var _this$props = _this.props,
128
- onDrag = _this$props.onDrag,
129
- transformScale = _this$props.transformScale;
127
+ var onDrag = _this.props.onDrag;
130
128
  if (!onDrag) return;
131
- deltaX /= transformScale;
132
- deltaY /= transformScale;
133
129
 
134
130
  if (!_this.state.dragging) {
135
131
  throw new Error("onDrag called before onDragStart.");
@@ -185,9 +181,7 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
185
181
  });
186
182
  });
187
183
 
188
- _defineProperty(_assertThisInitialized(_this), "onDragStop", function (e
189
- /*: Event*/
190
- , _ref3) {
184
+ _defineProperty(_assertThisInitialized(_this), "onDragStop", function (e, _ref3) {
191
185
  var node = _ref3.node;
192
186
  var onDragStop = _this.props.onDragStop;
193
187
  if (!onDragStop) return;
@@ -225,27 +219,15 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
225
219
  });
226
220
  });
227
221
 
228
- _defineProperty(_assertThisInitialized(_this), "onResizeStop", function (e
229
- /*: Event*/
230
- , callbackData
231
- /*: { node: HTMLElement, size: Position }*/
232
- ) {
222
+ _defineProperty(_assertThisInitialized(_this), "onResizeStop", function (e, callbackData) {
233
223
  _this.onResizeHandler(e, callbackData, "onResizeStop");
234
224
  });
235
225
 
236
- _defineProperty(_assertThisInitialized(_this), "onResizeStart", function (e
237
- /*: Event*/
238
- , callbackData
239
- /*: { node: HTMLElement, size: Position }*/
240
- ) {
226
+ _defineProperty(_assertThisInitialized(_this), "onResizeStart", function (e, callbackData) {
241
227
  _this.onResizeHandler(e, callbackData, "onResizeStart");
242
228
  });
243
229
 
244
- _defineProperty(_assertThisInitialized(_this), "onResize", function (e
245
- /*: Event*/
246
- , callbackData
247
- /*: { node: HTMLElement, size: Position }*/
248
- ) {
230
+ _defineProperty(_assertThisInitialized(_this), "onResize", function (e, callbackData) {
249
231
  _this.onResizeHandler(e, callbackData, "onResize");
250
232
  });
251
233
 
@@ -258,7 +240,9 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
258
240
  /*: Props*/
259
241
  , nextState
260
242
  /*: State*/
261
- ) {
243
+ )
244
+ /*: boolean*/
245
+ {
262
246
  // We can't deeply compare children. If the developer memoizes them, we can
263
247
  // use this optimization.
264
248
  if (this.props.children !== nextProps.children) return true;
@@ -428,7 +412,8 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
428
412
  maxW = _this$props6.maxW,
429
413
  maxH = _this$props6.maxH,
430
414
  transformScale = _this$props6.transformScale,
431
- resizeHandles = _this$props6.resizeHandles;
415
+ resizeHandles = _this$props6.resizeHandles,
416
+ resizeHandle = _this$props6.resizeHandle;
432
417
  var positionParams = this.getPositionParams(); // This is the max possible width - doesn't go to infinity because of the width of the window
433
418
 
434
419
  var maxWidth = (0, _calculateUtils.calcGridItemPosition)(positionParams, 0, 0, cols - x, 0).width; // Calculate min/max constraints using our min & maxes
@@ -450,7 +435,8 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
450
435
  onResizeStart: this.onResizeStart,
451
436
  onResize: this.onResize,
452
437
  transformScale: transformScale,
453
- resizeHandles: resizeHandles
438
+ resizeHandles: resizeHandles,
439
+ handle: resizeHandle
454
440
  }, child);
455
441
  }
456
442
  /**
@@ -461,7 +447,7 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
461
447
 
462
448
  }, {
463
449
  key: "onResizeHandler",
464
-
450
+ value:
465
451
  /**
466
452
  * Wrapper around drag events to provide more useful data.
467
453
  * All drag events call the function with the given handler name,
@@ -470,11 +456,13 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
470
456
  * @param {String} handlerName Handler name to wrap.
471
457
  * @return {Function} Handler function.
472
458
  */
473
- value: function onResizeHandler(e
459
+ function onResizeHandler(e
474
460
  /*: Event*/
475
461
  , _ref4, handlerName
476
462
  /*: string*/
477
- ) {
463
+ )
464
+ /*: void*/
465
+ {
478
466
  var node = _ref4.node,
479
467
  size = _ref4.size;
480
468
  var handler = this.props[handlerName];
@@ -609,6 +597,9 @@ _defineProperty(GridItem, "propTypes", {
609
597
  },
610
598
  // ID is nice to have for callbacks
611
599
  i: _propTypes.default.string.isRequired,
600
+ // Resize handle options
601
+ resizeHandles: _ReactGridLayoutPropTypes.resizeHandlesType,
602
+ resizeHandle: _ReactGridLayoutPropTypes.resizeHandleType,
612
603
  // Functions
613
604
  onDragStop: _propTypes.default.func,
614
605
  onDragStart: _propTypes.default.func,