react-grid-layout 1.5.0 → 1.5.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/.babelrc.js +1 -1
- package/CHANGELOG.md +13 -0
- package/build/GridItem.js +29 -15
- package/build/ReactGridLayout.js +5 -6
- package/build/ReactGridLayoutPropTypes.js +1 -1
- package/build/ResponsiveReactGridLayout.js +6 -7
- package/build/components/WidthProvider.js +11 -12
- package/build/utils.js +1 -1
- package/dist/react-grid-layout.min.js +1 -1
- package/dist/react-grid-layout.min.js.map +1 -1
- package/lib/GridItem.jsx +30 -13
- package/package.json +20 -14
package/lib/GridItem.jsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
3
4
|
import PropTypes from "prop-types";
|
|
4
5
|
import { DraggableCore } from "react-draggable";
|
|
5
6
|
import { Resizable } from "react-resizable";
|
|
@@ -293,11 +294,15 @@ export default class GridItem extends React.Component<Props, State> {
|
|
|
293
294
|
const deltaX = droppingPosition.left - dragging.left;
|
|
294
295
|
const deltaY = droppingPosition.top - dragging.top;
|
|
295
296
|
|
|
296
|
-
this.onDrag(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
this.onDrag(
|
|
298
|
+
droppingPosition.e,
|
|
299
|
+
{
|
|
300
|
+
node,
|
|
301
|
+
deltaX,
|
|
302
|
+
deltaY
|
|
303
|
+
},
|
|
304
|
+
true // dontFLush: avoid flushSync to temper warnings
|
|
305
|
+
);
|
|
301
306
|
}
|
|
302
307
|
}
|
|
303
308
|
|
|
@@ -481,10 +486,12 @@ export default class GridItem extends React.Component<Props, State> {
|
|
|
481
486
|
* onDrag event handler
|
|
482
487
|
* @param {Event} e event data
|
|
483
488
|
* @param {Object} callbackData an object with node, delta and position information
|
|
489
|
+
* @param {boolean} dontFlush if true, will not call flushSync
|
|
484
490
|
*/
|
|
485
|
-
onDrag: (Event, ReactDraggableCallbackData) => void = (
|
|
491
|
+
onDrag: (Event, ReactDraggableCallbackData, boolean) => void = (
|
|
486
492
|
e,
|
|
487
|
-
{ node, deltaX, deltaY }
|
|
493
|
+
{ node, deltaX, deltaY },
|
|
494
|
+
dontFlush
|
|
488
495
|
) => {
|
|
489
496
|
const { onDrag } = this.props;
|
|
490
497
|
if (!onDrag) return;
|
|
@@ -503,20 +510,28 @@ export default class GridItem extends React.Component<Props, State> {
|
|
|
503
510
|
const { offsetParent } = node;
|
|
504
511
|
|
|
505
512
|
if (offsetParent) {
|
|
506
|
-
const { margin, rowHeight
|
|
513
|
+
const { margin, rowHeight } = this.props;
|
|
507
514
|
const bottomBoundary =
|
|
508
515
|
offsetParent.clientHeight - calcGridItemWHPx(h, rowHeight, margin[1]);
|
|
509
|
-
top = clamp(top
|
|
516
|
+
top = clamp(top, 0, bottomBoundary);
|
|
510
517
|
|
|
511
518
|
const colWidth = calcGridColWidth(positionParams);
|
|
512
519
|
const rightBoundary =
|
|
513
520
|
containerWidth - calcGridItemWHPx(w, colWidth, margin[0]);
|
|
514
|
-
left = clamp(left
|
|
521
|
+
left = clamp(left, 0, rightBoundary);
|
|
515
522
|
}
|
|
516
523
|
}
|
|
517
524
|
|
|
518
525
|
const newPosition: PartialPosition = { top, left };
|
|
519
|
-
|
|
526
|
+
|
|
527
|
+
// dontFlush is set if we're calling from inside
|
|
528
|
+
if (dontFlush) {
|
|
529
|
+
this.setState({ dragging: newPosition });
|
|
530
|
+
} else {
|
|
531
|
+
flushSync(() => {
|
|
532
|
+
this.setState({ dragging: newPosition });
|
|
533
|
+
});
|
|
534
|
+
}
|
|
520
535
|
|
|
521
536
|
// Call callback with this data
|
|
522
537
|
const { x, y } = calcXY(positionParams, top, left, w, h);
|
|
@@ -592,8 +607,10 @@ export default class GridItem extends React.Component<Props, State> {
|
|
|
592
607
|
size,
|
|
593
608
|
containerWidth
|
|
594
609
|
);
|
|
595
|
-
|
|
596
|
-
|
|
610
|
+
flushSync(() => {
|
|
611
|
+
this.setState({
|
|
612
|
+
resizing: handlerName === "onResizeStop" ? null : updatedSize
|
|
613
|
+
});
|
|
597
614
|
});
|
|
598
615
|
}
|
|
599
616
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-grid-layout",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "A draggable and resizable grid layout with responsive breakpoints, for React.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/STRML/react-grid-layout",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"clsx": "^2.
|
|
40
|
+
"clsx": "^2.1.1",
|
|
41
41
|
"fast-equals": "^4.0.3",
|
|
42
42
|
"prop-types": "^15.8.1",
|
|
43
|
-
"react-draggable": "^4.4.
|
|
43
|
+
"react-draggable": "^4.4.6",
|
|
44
44
|
"react-resizable": "^3.0.5",
|
|
45
45
|
"resize-observer-polyfill": "^1.5.1"
|
|
46
46
|
},
|
|
@@ -48,23 +48,23 @@
|
|
|
48
48
|
"fast-equals": "Bug in CRA5 causes fast-equals@5 to fail to import due to .cjs file. See https://github.com/react-grid-layout/react-grid-layout/issues/1904"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/cli": "^7.
|
|
52
|
-
"@babel/core": "^7.
|
|
53
|
-
"@babel/eslint-parser": "^7.
|
|
54
|
-
"@babel/plugin-
|
|
55
|
-
"@babel/plugin-transform-flow-comments": "^7.
|
|
56
|
-
"@babel/preset-env": "^7.
|
|
57
|
-
"@babel/preset-flow": "^7.
|
|
58
|
-
"@babel/preset-react": "^7.
|
|
59
|
-
"@babel/register": "^7.
|
|
51
|
+
"@babel/cli": "^7.27.2",
|
|
52
|
+
"@babel/core": "^7.27.4",
|
|
53
|
+
"@babel/eslint-parser": "^7.27.5",
|
|
54
|
+
"@babel/plugin-transform-class-properties": "^7.18.6",
|
|
55
|
+
"@babel/plugin-transform-flow-comments": "^7.27.3",
|
|
56
|
+
"@babel/preset-env": "^7.27.2",
|
|
57
|
+
"@babel/preset-flow": "^7.27.1",
|
|
58
|
+
"@babel/preset-react": "^7.27.1",
|
|
59
|
+
"@babel/register": "^7.27.1",
|
|
60
60
|
"@webpack-cli/serve": "^2.0.5",
|
|
61
61
|
"babel-jest": "^29.7.0",
|
|
62
62
|
"babel-loader": "^9.1.3",
|
|
63
63
|
"babel-plugin-preval": "^5.1.0",
|
|
64
64
|
"css-loader": "^6.8.1",
|
|
65
|
-
"ejs": "^3.1.
|
|
65
|
+
"ejs": "^3.1.10",
|
|
66
66
|
"enzyme": "^3.11.0",
|
|
67
|
-
"enzyme-adapter-react-16": "^1.15.
|
|
67
|
+
"enzyme-adapter-react-16": "^1.15.8",
|
|
68
68
|
"enzyme-to-json": "^3.6.2",
|
|
69
69
|
"eslint": "^8.54.0",
|
|
70
70
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
@@ -91,6 +91,12 @@
|
|
|
91
91
|
"webpack-cli": "^5.1.4",
|
|
92
92
|
"webpack-dev-server": "^4.15.1"
|
|
93
93
|
},
|
|
94
|
+
"resolutions": {
|
|
95
|
+
"**/cheerio": "npm:cheerio@1.0.0-rc.12"
|
|
96
|
+
},
|
|
97
|
+
"_resolutionNotes": {
|
|
98
|
+
"**/cheerio": "See https://github.com/cheeriojs/cheerio/issues/4618"
|
|
99
|
+
},
|
|
94
100
|
"peerDependencies": {
|
|
95
101
|
"react": ">= 16.3.0",
|
|
96
102
|
"react-dom": ">= 16.3.0"
|