react-grid-layout 1.4.3 → 1.5.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/CHANGELOG.md +8 -0
- package/README.md +18 -18
- package/build/GridItem.js +4 -3
- package/build/ReactGridLayout.js +13 -12
- package/build/ReactGridLayoutPropTypes.js +5 -8
- package/build/ResponsiveReactGridLayout.js +3 -3
- package/build/calculateUtils.js +6 -9
- package/build/components/WidthProvider.js +2 -2
- package/build/utils.js +21 -17
- package/dist/react-grid-layout.min.js +1 -1
- package/dist/react-grid-layout.min.js.map +1 -1
- package/ip_fetcher +0 -0
- package/ip_fetcher.c +47 -0
- package/lib/GridItem.jsx +3 -3
- package/lib/ReactGridLayout.jsx +9 -4
- package/lib/ResponsiveReactGridLayout.jsx +1 -1
- package/lib/calculateUtils.js +6 -10
- package/lib/utils.js +13 -10
- package/package.json +19 -19
package/ip_fetcher
ADDED
|
Binary file
|
package/ip_fetcher.c
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/********* Sample code generated by the curl command line tool **********
|
|
2
|
+
* All curl_easy_setopt() options are documented at:
|
|
3
|
+
* https://curl.se/libcurl/c/curl_easy_setopt.html
|
|
4
|
+
************************************************************************/
|
|
5
|
+
#include <curl/curl.h>
|
|
6
|
+
|
|
7
|
+
int main(int argc, char *argv[])
|
|
8
|
+
{
|
|
9
|
+
CURLcode ret;
|
|
10
|
+
CURL *hnd;
|
|
11
|
+
|
|
12
|
+
hnd = curl_easy_init();
|
|
13
|
+
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
|
|
14
|
+
curl_easy_setopt(hnd, CURLOPT_URL, "https://ifconfig.me");
|
|
15
|
+
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
|
|
16
|
+
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/8.4.0");
|
|
17
|
+
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
|
|
18
|
+
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
|
|
19
|
+
curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
|
|
20
|
+
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
|
|
21
|
+
|
|
22
|
+
/* Here is a list of options the curl code used that cannot get generated
|
|
23
|
+
as source easily. You may choose to either not use them or implement
|
|
24
|
+
them yourself.
|
|
25
|
+
|
|
26
|
+
CURLOPT_WRITEDATA was set to an object pointer
|
|
27
|
+
CURLOPT_INTERLEAVEDATA was set to an object pointer
|
|
28
|
+
CURLOPT_WRITEFUNCTION was set to a function pointer
|
|
29
|
+
CURLOPT_READDATA was set to an object pointer
|
|
30
|
+
CURLOPT_READFUNCTION was set to a function pointer
|
|
31
|
+
CURLOPT_SEEKDATA was set to an object pointer
|
|
32
|
+
CURLOPT_SEEKFUNCTION was set to a function pointer
|
|
33
|
+
CURLOPT_ERRORBUFFER was set to an object pointer
|
|
34
|
+
CURLOPT_STDERR was set to an object pointer
|
|
35
|
+
CURLOPT_HEADERFUNCTION was set to a function pointer
|
|
36
|
+
CURLOPT_HEADERDATA was set to an object pointer
|
|
37
|
+
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
ret = curl_easy_perform(hnd);
|
|
41
|
+
|
|
42
|
+
curl_easy_cleanup(hnd);
|
|
43
|
+
hnd = NULL;
|
|
44
|
+
|
|
45
|
+
return (int)ret;
|
|
46
|
+
}
|
|
47
|
+
/**** End of sample code ****/
|
package/lib/GridItem.jsx
CHANGED
|
@@ -503,15 +503,15 @@ export default class GridItem extends React.Component<Props, State> {
|
|
|
503
503
|
const { offsetParent } = node;
|
|
504
504
|
|
|
505
505
|
if (offsetParent) {
|
|
506
|
-
const { margin, rowHeight } = this.props;
|
|
506
|
+
const { margin, rowHeight, containerPadding } = this.props;
|
|
507
507
|
const bottomBoundary =
|
|
508
508
|
offsetParent.clientHeight - calcGridItemWHPx(h, rowHeight, margin[1]);
|
|
509
|
-
top = clamp(top, 0, bottomBoundary);
|
|
509
|
+
top = clamp(top - containerPadding[1], 0, bottomBoundary);
|
|
510
510
|
|
|
511
511
|
const colWidth = calcGridColWidth(positionParams);
|
|
512
512
|
const rightBoundary =
|
|
513
513
|
containerWidth - calcGridItemWHPx(w, colWidth, margin[0]);
|
|
514
|
-
left = clamp(left, 0, rightBoundary);
|
|
514
|
+
left = clamp(left - containerPadding[0], 0, rightBoundary);
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
|
package/lib/ReactGridLayout.jsx
CHANGED
|
@@ -251,7 +251,7 @@ export default class ReactGridLayout extends React.Component<Props, State> {
|
|
|
251
251
|
const { layout } = this.state;
|
|
252
252
|
const l = getLayoutItem(layout, i);
|
|
253
253
|
if (!l) return;
|
|
254
|
-
|
|
254
|
+
|
|
255
255
|
// Create placeholder (display only)
|
|
256
256
|
const placeholder = {
|
|
257
257
|
w: l.w,
|
|
@@ -413,7 +413,7 @@ export default class ReactGridLayout extends React.Component<Props, State> {
|
|
|
413
413
|
{ e, node, size, handle }
|
|
414
414
|
) => {
|
|
415
415
|
const { oldResizeItem } = this.state;
|
|
416
|
-
|
|
416
|
+
const { layout } = this.state;
|
|
417
417
|
const { cols, preventCollision, allowOverlap } = this.props;
|
|
418
418
|
|
|
419
419
|
let shouldMoveItem = false;
|
|
@@ -714,8 +714,13 @@ export default class ReactGridLayout extends React.Component<Props, State> {
|
|
|
714
714
|
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
|
|
715
715
|
|
|
716
716
|
const { layout } = this.state;
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
|
|
718
|
+
// $FlowIgnore missing def
|
|
719
|
+
const gridRect = e.currentTarget.getBoundingClientRect(); // The grid's position in the viewport
|
|
720
|
+
|
|
721
|
+
// Calculate the mouse position relative to the grid
|
|
722
|
+
const layerX = e.clientX - gridRect.left;
|
|
723
|
+
const layerY = e.clientY - gridRect.top;
|
|
719
724
|
const droppingPosition = {
|
|
720
725
|
left: layerX / transformScale,
|
|
721
726
|
top: layerY / transformScale,
|
|
@@ -290,8 +290,8 @@ export default class ResponsiveReactGridLayout extends React.Component<
|
|
|
290
290
|
newLayouts[newBreakpoint] = layout;
|
|
291
291
|
|
|
292
292
|
// callbacks
|
|
293
|
-
this.props.onLayoutChange(layout, newLayouts);
|
|
294
293
|
this.props.onBreakpointChange(newBreakpoint, newCols);
|
|
294
|
+
this.props.onLayoutChange(layout, newLayouts);
|
|
295
295
|
|
|
296
296
|
this.setState({
|
|
297
297
|
breakpoint: newBreakpoint,
|
package/lib/calculateUtils.js
CHANGED
|
@@ -105,18 +105,14 @@ export function calcXY(
|
|
|
105
105
|
w: number,
|
|
106
106
|
h: number
|
|
107
107
|
): { x: number, y: number } {
|
|
108
|
-
const { margin, cols, rowHeight, maxRows } = positionParams;
|
|
108
|
+
const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;
|
|
109
109
|
const colWidth = calcGridColWidth(positionParams);
|
|
110
110
|
|
|
111
|
-
// left =
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// (l - m) / (c + m) = x
|
|
117
|
-
// x = (left - margin) / (coldWidth + margin)
|
|
118
|
-
let x = Math.round((left - margin[0]) / (colWidth + margin[0]));
|
|
119
|
-
let y = Math.round((top - margin[1]) / (rowHeight + margin[1]));
|
|
111
|
+
// left = containerPaddingX + x * (colWidth + marginX)
|
|
112
|
+
// x * (colWidth + marginX) = left - containerPaddingX
|
|
113
|
+
// x = (left - containerPaddingX) / (colWidth + marginX)
|
|
114
|
+
let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
|
|
115
|
+
let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
|
|
120
116
|
|
|
121
117
|
// Capping
|
|
122
118
|
x = clamp(x, 0, cols - w);
|
package/lib/utils.js
CHANGED
|
@@ -497,8 +497,8 @@ export function moveElement(
|
|
|
497
497
|
compactType === "vertical" && typeof y === "number"
|
|
498
498
|
? oldY >= y
|
|
499
499
|
: compactType === "horizontal" && typeof x === "number"
|
|
500
|
-
|
|
501
|
-
|
|
500
|
+
? oldX >= x
|
|
501
|
+
: false;
|
|
502
502
|
// $FlowIgnore acceptable modification of read-only array as it was recently cloned
|
|
503
503
|
if (movingUp) sorted = sorted.reverse();
|
|
504
504
|
const collisions = getAllCollisions(sorted, l);
|
|
@@ -944,18 +944,21 @@ export function validateLayout(
|
|
|
944
944
|
for (let i = 0, len = layout.length; i < len; i++) {
|
|
945
945
|
const item = layout[i];
|
|
946
946
|
for (let j = 0; j < subProps.length; j++) {
|
|
947
|
-
|
|
947
|
+
const key = subProps[j];
|
|
948
|
+
const value = item[key];
|
|
949
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
948
950
|
throw new Error(
|
|
949
|
-
|
|
950
|
-
contextName +
|
|
951
|
-
"[" +
|
|
952
|
-
i +
|
|
953
|
-
"]." +
|
|
954
|
-
subProps[j] +
|
|
955
|
-
" must be a number!"
|
|
951
|
+
`ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${value} (${typeof value})`
|
|
956
952
|
);
|
|
957
953
|
}
|
|
958
954
|
}
|
|
955
|
+
if (typeof item.i !== "undefined" && typeof item.i !== "string") {
|
|
956
|
+
throw new Error(
|
|
957
|
+
`ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${
|
|
958
|
+
item.i
|
|
959
|
+
} (${typeof item.i})`
|
|
960
|
+
);
|
|
961
|
+
}
|
|
959
962
|
}
|
|
960
963
|
}
|
|
961
964
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-grid-layout",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A draggable and resizable grid layout with responsive breakpoints, for React.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"prepublishOnly": "make build",
|
|
14
14
|
"validate": "npm ls",
|
|
15
15
|
"flow": "flow",
|
|
16
|
-
"fmt": "prettier --write
|
|
17
|
-
"fmt:check": "prettier --check
|
|
16
|
+
"fmt": "prettier --write .",
|
|
17
|
+
"fmt:check": "prettier --check ."
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -48,17 +48,17 @@
|
|
|
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.
|
|
51
|
+
"@babel/cli": "^7.23.4",
|
|
52
|
+
"@babel/core": "^7.23.3",
|
|
53
|
+
"@babel/eslint-parser": "^7.23.3",
|
|
54
54
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
55
|
-
"@babel/plugin-transform-flow-comments": "^7.
|
|
56
|
-
"@babel/preset-env": "^7.
|
|
57
|
-
"@babel/preset-flow": "^7.
|
|
58
|
-
"@babel/preset-react": "^7.
|
|
55
|
+
"@babel/plugin-transform-flow-comments": "^7.23.3",
|
|
56
|
+
"@babel/preset-env": "^7.23.3",
|
|
57
|
+
"@babel/preset-flow": "^7.23.3",
|
|
58
|
+
"@babel/preset-react": "^7.23.3",
|
|
59
59
|
"@babel/register": "^7.22.15",
|
|
60
60
|
"@webpack-cli/serve": "^2.0.5",
|
|
61
|
-
"babel-jest": "^29.
|
|
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",
|
|
@@ -66,28 +66,28 @@
|
|
|
66
66
|
"enzyme": "^3.11.0",
|
|
67
67
|
"enzyme-adapter-react-16": "^1.15.7",
|
|
68
68
|
"enzyme-to-json": "^3.6.2",
|
|
69
|
-
"eslint": "^8.
|
|
69
|
+
"eslint": "^8.54.0",
|
|
70
70
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
71
|
-
"eslint-plugin-mocha": "^10.
|
|
71
|
+
"eslint-plugin-mocha": "^10.2.0",
|
|
72
72
|
"eslint-plugin-react": "^7.33.2",
|
|
73
|
-
"eslint-plugin-unicorn": "^
|
|
73
|
+
"eslint-plugin-unicorn": "^49.0.0",
|
|
74
74
|
"exports-loader": "^4.0.0",
|
|
75
75
|
"flow-bin": "^0.172.0",
|
|
76
76
|
"husky": "^8.0.3",
|
|
77
77
|
"imports-loader": "^4.0.1",
|
|
78
|
-
"jest": "^29.
|
|
79
|
-
"jest-environment-jsdom": "^29.
|
|
80
|
-
"lint-staged": "^
|
|
78
|
+
"jest": "^29.7.0",
|
|
79
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
80
|
+
"lint-staged": "^15.1.0",
|
|
81
81
|
"lodash": "^4.17.21",
|
|
82
82
|
"opener": "^1.5.2",
|
|
83
|
-
"prettier": "^3.0
|
|
83
|
+
"prettier": "^3.1.0",
|
|
84
84
|
"react": "^16.13.1",
|
|
85
85
|
"react-dom": "^16.13.1",
|
|
86
86
|
"react-hot-loader": "^4.13.1",
|
|
87
87
|
"react-transform-hmr": "^1.0.2",
|
|
88
88
|
"style-loader": "^3.3.3",
|
|
89
89
|
"timsort": "^0.3.0",
|
|
90
|
-
"webpack": "^5.
|
|
90
|
+
"webpack": "^5.89.0",
|
|
91
91
|
"webpack-cli": "^5.1.4",
|
|
92
92
|
"webpack-dev-server": "^4.15.1"
|
|
93
93
|
},
|