react-grid-layout 1.2.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +1 -3
- package/CHANGELOG.md +22 -0
- package/README.md +51 -11
- package/build/GridItem.js +1 -1
- package/build/ReactGridLayout.js +296 -317
- package/build/ReactGridLayoutPropTypes.js +6 -0
- package/build/ResponsiveReactGridLayout.js +9 -3
- package/build/calculateUtils.js +6 -6
- package/build/components/WidthProvider.js +4 -2
- package/build/fastRGLPropsEqual.js +1 -1
- package/build/utils.js +24 -30
- package/dist/react-grid-layout.min.js +1 -1
- package/dist/react-grid-layout.min.js.map +1 -1
- package/foo.html +388 -0
- package/lib/ReactGridLayout.jsx +93 -58
- package/lib/ReactGridLayoutPropTypes.js +33 -12
- package/lib/ResponsiveReactGridLayout.jsx +7 -1
- package/lib/utils.js +27 -22
- package/package.json +29 -28
package/.flowconfig
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
1.3.0 (Aug 27, 2021)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
### New Features
|
|
7
|
+
- `allowOverlap` prop, when `true`, allows overlapping grid items. [#1470](https://github.com/react-grid-layout/react-grid-layout/pull/1470)
|
|
8
|
+
- Add `onDropDragOver` callback. [#1395](https://github.com/react-grid-layout/react-grid-layout/pull/1395)
|
|
9
|
+
- Use this callback to dynamically adjust the `droppingItem` based on what is being dragged over. Return `w` and `h` to adjust the item. It is then [spread into the dropping placeholder](https://github.com/react-grid-layout/react-grid-layout/pull/1395/files#diff-83ab569936bfd4bf0460a4f23653ecbe8bc88509062c95e75c9402218b2b8733R609).
|
|
10
|
+
- This callback has the type:
|
|
11
|
+
- `onDragOver: (e: DragOverEvent) => { w: number, h: number } | false;`
|
|
12
|
+
- Return `false` to short-circuit the dragover.
|
|
13
|
+
|
|
14
|
+
### Bugfixes
|
|
15
|
+
- Remove sorting when `compactType` is `null`. [#1474](https://github.com/react-grid-layout/react-grid-layout/pull/1474)
|
|
16
|
+
- Droppable fixes for Chrome behavior. [#1442](https://github.com/react-grid-layout/react-grid-layout/issues/1442) [#1448](https://github.com/react-grid-layout/react-grid-layout/issues/1442)
|
|
17
|
+
- Allow `null` children as a convenience so that inline expressions don't break the library. [#1296](https://github.com/react-grid-layout/react-grid-layout/pull/1296)
|
|
18
|
+
- Various dependency upgrades.
|
|
19
|
+
|
|
20
|
+
### Documentation
|
|
21
|
+
- Add docs on using custom components as grid children.
|
|
22
|
+
- Note required class on resizable handles for proper styling.
|
|
23
|
+
|
|
24
|
+
|
|
3
25
|
1.2.5 (May 10, 2021)
|
|
4
26
|
---
|
|
5
27
|
|
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ RGL is React-only and does not require jQuery.
|
|
|
55
55
|
1. [Bounded Layout](https://react-grid-layout.github.io/react-grid-layout/examples/16-bounded.html)
|
|
56
56
|
1. [Resizable Handles](https://react-grid-layout.github.io/react-grid-layout/examples/17-resizable-handles.html)
|
|
57
57
|
1. [Scaled Containers](https://react-grid-layout.github.io/react-grid-layout/examples/18-scale.html)
|
|
58
|
+
1. [Allow Overlap](https://react-grid-layout.github.io/react-grid-layout/examples/19-allow-overlap.html)
|
|
58
59
|
|
|
59
60
|
#### Projects Using React-Grid-Layout
|
|
60
61
|
|
|
@@ -74,6 +75,7 @@ RGL is React-only and does not require jQuery.
|
|
|
74
75
|
- [Hakkiri](https://www.hakkiri.io)
|
|
75
76
|
- [Ubidots](https://help.ubidots.com/en/articles/2400308-create-dashboards-and-widgets)
|
|
76
77
|
- [Statsout](https://statsout.com/)
|
|
78
|
+
- [Datto RMM](https://www.datto.com/uk/products/rmm/)
|
|
77
79
|
|
|
78
80
|
*Know of others? Create a PR to let me know!*
|
|
79
81
|
|
|
@@ -266,6 +268,7 @@ cols: ?number = 12,
|
|
|
266
268
|
// A CSS selector for tags that will not be draggable.
|
|
267
269
|
// For example: draggableCancel:'.MyNonDraggableAreaClassName'
|
|
268
270
|
// If you forget the leading . it will not work.
|
|
271
|
+
// .react-resizable-handle" is always prepended to this value.
|
|
269
272
|
draggableCancel: ?string = '',
|
|
270
273
|
|
|
271
274
|
// A CSS selector for tags that will act as the draggable handle.
|
|
@@ -315,9 +318,12 @@ useCSSTransforms: ?boolean = true,
|
|
|
315
318
|
// we should set scale coefficient to avoid render artefacts while dragging.
|
|
316
319
|
transformScale: ?number = 1,
|
|
317
320
|
|
|
321
|
+
// If true, grid can be placed one over the other.
|
|
322
|
+
allowOverlap: ?boolean = false,
|
|
323
|
+
|
|
318
324
|
// If true, grid items won't change position when being
|
|
319
325
|
// dragged over.
|
|
320
|
-
preventCollision: ?boolean = false
|
|
326
|
+
preventCollision: ?boolean = false,
|
|
321
327
|
|
|
322
328
|
// If true, droppable elements (with `draggable={true}` attribute)
|
|
323
329
|
// can be dropped on the grid. It triggers "onDrop" callback
|
|
@@ -329,7 +335,7 @@ preventCollision: ?boolean = false;
|
|
|
329
335
|
// along with `draggable={true}` otherwise this feature will work incorrect.
|
|
330
336
|
// onDragStart attribute is required for Firefox for a dragging initialization
|
|
331
337
|
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=568313
|
|
332
|
-
isDroppable: ?boolean = false
|
|
338
|
+
isDroppable: ?boolean = false,
|
|
333
339
|
// Defines which resize handles should be rendered
|
|
334
340
|
// Allows for any combination of:
|
|
335
341
|
// 's' - South handle (bottom-center)
|
|
@@ -340,10 +346,12 @@ isDroppable: ?boolean = false
|
|
|
340
346
|
// 'nw' - Northwest handle (top-left)
|
|
341
347
|
// 'se' - Southeast handle (bottom-right)
|
|
342
348
|
// 'ne' - Northeast handle (top-right)
|
|
343
|
-
resizeHandles: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se']
|
|
349
|
+
resizeHandles: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se'],
|
|
344
350
|
// Custom component for resize handles
|
|
345
|
-
// See `handle` as used in https://github.com/react-grid-layout/react-resizable#
|
|
346
|
-
|
|
351
|
+
// See `handle` as used in https://github.com/react-grid-layout/react-resizable#resize-handle
|
|
352
|
+
// Your component should have the class `.react-resizable-handle`, or you should add your custom
|
|
353
|
+
// class to the `draggableCancel` prop.
|
|
354
|
+
resizeHandle?: ReactElement<any> | ((resizeHandleAxis: ResizeHandleAxis, ref: ReactRef<HTMLElement>) => ReactElement<any>),
|
|
347
355
|
|
|
348
356
|
//
|
|
349
357
|
// Callbacks
|
|
@@ -358,7 +366,7 @@ onLayoutChange: (layout: Layout) => void,
|
|
|
358
366
|
// 'start' and 'stop' callbacks pass `undefined` for 'placeholder'.
|
|
359
367
|
//
|
|
360
368
|
type ItemCallback = (layout: Layout, oldItem: LayoutItem, newItem: LayoutItem,
|
|
361
|
-
placeholder: LayoutItem, e: MouseEvent, element: HTMLElement) => void
|
|
369
|
+
placeholder: LayoutItem, e: MouseEvent, element: HTMLElement) => void,
|
|
362
370
|
|
|
363
371
|
// Calls when drag starts.
|
|
364
372
|
onDragStart: ItemCallback,
|
|
@@ -372,12 +380,21 @@ onResizeStart: ItemCallback,
|
|
|
372
380
|
onResize: ItemCallback,
|
|
373
381
|
// Calls when resize is complete.
|
|
374
382
|
onResizeStop: ItemCallback,
|
|
383
|
+
|
|
384
|
+
//
|
|
385
|
+
// Dropover functionality
|
|
386
|
+
//
|
|
387
|
+
|
|
375
388
|
// Calls when an element has been dropped into the grid from outside.
|
|
376
|
-
onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void
|
|
389
|
+
onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void,
|
|
390
|
+
// Calls when an element is being dragged over the grid from outside as above.
|
|
391
|
+
// This callback should return an object to dynamically change the droppingItem size
|
|
392
|
+
// Return false to short-circuit the dragover
|
|
393
|
+
onDropDragOver: (e: DragOverEvent) => ?({|w?: number, h?: number|} | false),
|
|
377
394
|
|
|
378
395
|
// Ref for getting a reference for the grid's wrapping div.
|
|
379
396
|
// You can use this instead of a regular ref and the deprecated `ReactDOM.findDOMNode()`` function.
|
|
380
|
-
innerRef: ?React.Ref<"div"
|
|
397
|
+
innerRef: ?React.Ref<"div">,
|
|
381
398
|
```
|
|
382
399
|
|
|
383
400
|
### Responsive Grid Layout Props
|
|
@@ -395,16 +412,16 @@ cols: ?Object = {lg: 12, md: 10, sm: 6, xs: 4, xxs: 2},
|
|
|
395
412
|
|
|
396
413
|
|
|
397
414
|
// margin (in pixels). Can be specified either as horizontal and vertical margin, e.g. `[10, 10]` or as a breakpoint -> margin map, e.g. `{lg: [10, 10], md: [10, 10], ...}.
|
|
398
|
-
margin: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]}
|
|
415
|
+
margin: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]},
|
|
399
416
|
|
|
400
417
|
|
|
401
418
|
// containerPadding (in pixels). Can be specified either as horizontal and vertical padding, e.g. `[10, 10]` or as a breakpoint -> containerPadding map, e.g. `{lg: [10, 10], md: [10, 10], ...}.
|
|
402
|
-
containerPadding: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]}
|
|
419
|
+
containerPadding: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]},
|
|
403
420
|
|
|
404
421
|
|
|
405
422
|
// layouts is an object mapping breakpoints to layouts.
|
|
406
423
|
// e.g. {lg: Layout, md: Layout, ...}
|
|
407
|
-
layouts: {[key: $Keys<breakpoints>]: Layout}
|
|
424
|
+
layouts: {[key: $Keys<breakpoints>]: Layout},
|
|
408
425
|
|
|
409
426
|
//
|
|
410
427
|
// Callbacks
|
|
@@ -507,6 +524,29 @@ function MyGrid(props) {
|
|
|
507
524
|
|
|
508
525
|
Because the `children` prop doesn't change between rerenders, updates to `<MyGrid>` won't result in new renders, improving performance.
|
|
509
526
|
|
|
527
|
+
### Custom Child Components and Draggable Handles
|
|
528
|
+
|
|
529
|
+
If you use React Components as grid children, they need to do a few things:
|
|
530
|
+
|
|
531
|
+
1. Forward refs to an underlying DOM node, and
|
|
532
|
+
2. Forward `style` and `className` to that same DOM node.
|
|
533
|
+
|
|
534
|
+
For example:
|
|
535
|
+
|
|
536
|
+
```js
|
|
537
|
+
const CustomGridItemComponent = React.forwardRef(({style, className, ...props}, ref) => {
|
|
538
|
+
return (
|
|
539
|
+
<div style={{ /* styles */, ...style}} className={className} ref={ref}>
|
|
540
|
+
{/* Some other content */}
|
|
541
|
+
</div>
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
The same is true of custom elements as draggable handles using the `draggableHandle` prop. This is so that
|
|
547
|
+
the underlying `react-draggable` library can get a reference to the DOM node underneath, manipulate
|
|
548
|
+
positioning via `style`, and set classes.
|
|
549
|
+
|
|
510
550
|
## Contribute
|
|
511
551
|
|
|
512
552
|
If you have a feature request, please add it as an issue or make a pull request.
|
package/build/GridItem.js
CHANGED
|
@@ -41,7 +41,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
41
41
|
|
|
42
42
|
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); }; }
|
|
43
43
|
|
|
44
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
44
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
45
45
|
|
|
46
46
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
47
|
|