react-grid-layout 1.4.4 → 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/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
@@ -519,14 +519,7 @@ export default class GridItem extends React.Component<Props, State> {
519
519
  this.setState({ dragging: newPosition });
520
520
 
521
521
  // Call callback with this data
522
- const { containerPadding } = this.props;
523
- const { x, y } = calcXY(
524
- positionParams,
525
- top - containerPadding[1],
526
- left - containerPadding[0],
527
- w,
528
- h
529
- );
522
+ const { x, y } = calcXY(positionParams, top, left, w, h);
530
523
  return onDrag.call(this, i, x, y, {
531
524
  e,
532
525
  node,
@@ -546,18 +539,12 @@ export default class GridItem extends React.Component<Props, State> {
546
539
  if (!this.state.dragging) {
547
540
  throw new Error("onDragEnd called before onDragStart.");
548
541
  }
549
- const { w, h, i, containerPadding } = this.props;
542
+ const { w, h, i } = this.props;
550
543
  const { left, top } = this.state.dragging;
551
544
  const newPosition: PartialPosition = { top, left };
552
545
  this.setState({ dragging: null });
553
546
 
554
- const { x, y } = calcXY(
555
- this.getPositionParams(),
556
- top - containerPadding[1],
557
- left - containerPadding[0],
558
- w,
559
- h
560
- );
547
+ const { x, y } = calcXY(this.getPositionParams(), top, left, w, h);
561
548
 
562
549
  return onDragStop.call(this, i, x, y, {
563
550
  e,
@@ -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,
@@ -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 = colWidth * x + margin * (x + 1)
112
- // l = cx + m(x+1)
113
- // l = cx + mx + m
114
- // l - m = cx + mx
115
- // l - m = x(c + m)
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
@@ -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
- if (typeof item[subProps[j]] !== "number") {
947
+ const key = subProps[j];
948
+ const value = item[key];
949
+ if (typeof value !== "number" || Number.isNaN(value)) {
948
950
  throw new Error(
949
- "ReactGridLayout: " +
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.4.4",
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": {