react-grid-layout 1.5.3 → 2.1.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.
Files changed (95) hide show
  1. package/README.md +1156 -442
  2. package/css/styles.css +5 -4
  3. package/dist/ResponsiveGridLayout-BkHF9YHa.d.mts +133 -0
  4. package/dist/ResponsiveGridLayout-CLn16-X3.d.ts +133 -0
  5. package/dist/calculate-DsVTldEE.d.ts +196 -0
  6. package/dist/calculate-DwbL1D06.d.mts +196 -0
  7. package/dist/chunk-2O3ZME4Q.mjs +703 -0
  8. package/dist/chunk-2O3ZME4Q.mjs.map +1 -0
  9. package/dist/chunk-526JND3R.mjs +3 -0
  10. package/dist/chunk-526JND3R.mjs.map +1 -0
  11. package/dist/chunk-7ELO5FRW.js +4 -0
  12. package/dist/chunk-7ELO5FRW.js.map +1 -0
  13. package/dist/chunk-AWM66AWF.mjs +422 -0
  14. package/dist/chunk-AWM66AWF.mjs.map +1 -0
  15. package/dist/chunk-BJFPTW5Q.js +449 -0
  16. package/dist/chunk-BJFPTW5Q.js.map +1 -0
  17. package/dist/chunk-FN6MIZ24.js +744 -0
  18. package/dist/chunk-FN6MIZ24.js.map +1 -0
  19. package/dist/chunk-GPZBANOK.js +435 -0
  20. package/dist/chunk-GPZBANOK.js.map +1 -0
  21. package/dist/chunk-LWF5EYMO.mjs +429 -0
  22. package/dist/chunk-LWF5EYMO.mjs.map +1 -0
  23. package/dist/chunk-MXXN7GUE.mjs +1408 -0
  24. package/dist/chunk-MXXN7GUE.mjs.map +1 -0
  25. package/dist/chunk-QRW3ND4U.js +1417 -0
  26. package/dist/chunk-QRW3ND4U.js.map +1 -0
  27. package/dist/core.d.mts +186 -0
  28. package/dist/core.d.ts +186 -0
  29. package/dist/core.js +274 -0
  30. package/dist/core.js.map +1 -0
  31. package/dist/core.mjs +5 -0
  32. package/dist/core.mjs.map +1 -0
  33. package/dist/extras.d.mts +208 -0
  34. package/dist/extras.d.ts +208 -0
  35. package/dist/extras.js +462 -0
  36. package/dist/extras.js.map +1 -0
  37. package/dist/extras.mjs +454 -0
  38. package/dist/extras.mjs.map +1 -0
  39. package/dist/index.d.mts +7 -0
  40. package/dist/index.d.ts +7 -0
  41. package/dist/index.js +154 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/index.mjs +7 -0
  44. package/dist/index.mjs.map +1 -0
  45. package/dist/legacy.d.mts +163 -0
  46. package/dist/legacy.d.ts +163 -0
  47. package/dist/legacy.js +320 -0
  48. package/dist/legacy.js.map +1 -0
  49. package/dist/legacy.mjs +308 -0
  50. package/dist/legacy.mjs.map +1 -0
  51. package/dist/position-C8a5g6bb.d.mts +324 -0
  52. package/dist/position-H8tBL91b.d.ts +324 -0
  53. package/dist/react.d.mts +357 -0
  54. package/dist/react.d.ts +357 -0
  55. package/dist/react.js +96 -0
  56. package/dist/react.js.map +1 -0
  57. package/dist/react.mjs +7 -0
  58. package/dist/react.mjs.map +1 -0
  59. package/dist/responsive-BB5d98xz.d.mts +145 -0
  60. package/dist/responsive-BXI-GCXG.d.ts +145 -0
  61. package/dist/types-CokovIMH.d.mts +469 -0
  62. package/dist/types-CokovIMH.d.ts +469 -0
  63. package/index-dev.js +24 -0
  64. package/package.json +133 -40
  65. package/.babelrc.js +0 -22
  66. package/.browserslistrc +0 -3
  67. package/.eslintignore +0 -4
  68. package/.flowconfig +0 -20
  69. package/.prettierignore +0 -4
  70. package/.prettierrc +0 -17
  71. package/CHANGELOG.md +0 -985
  72. package/build/GridItem.js +0 -638
  73. package/build/ReactGridLayout.js +0 -741
  74. package/build/ReactGridLayoutPropTypes.js +0 -210
  75. package/build/ResponsiveReactGridLayout.js +0 -297
  76. package/build/calculateUtils.js +0 -165
  77. package/build/components/WidthProvider.js +0 -115
  78. package/build/fastRGLPropsEqual.js +0 -5
  79. package/build/responsiveUtils.js +0 -101
  80. package/build/utils.js +0 -842
  81. package/dist/react-grid-layout.min.js +0 -2
  82. package/dist/react-grid-layout.min.js.map +0 -1
  83. package/index.js.flow +0 -8
  84. package/ip_fetcher +0 -0
  85. package/ip_fetcher.c +0 -47
  86. package/lib/GridItem.jsx +0 -689
  87. package/lib/ReactGridLayout.jsx +0 -855
  88. package/lib/ReactGridLayoutPropTypes.js +0 -241
  89. package/lib/ResponsiveReactGridLayout.jsx +0 -349
  90. package/lib/calculateUtils.js +0 -169
  91. package/lib/components/WidthProvider.jsx +0 -110
  92. package/lib/fastRGLPropsEqual.js +0 -46
  93. package/lib/responsiveUtils.js +0 -118
  94. package/lib/utils.js +0 -995
  95. package/yarn-error.log +0 -7780
@@ -1,241 +0,0 @@
1
- // @flow
2
- import PropTypes from "prop-types";
3
- import React from "react";
4
- import type {
5
- Ref,
6
- ChildrenArray as ReactChildrenArray,
7
- Element as ReactElement
8
- } from "react";
9
- import type {
10
- DragOverEvent,
11
- EventCallback,
12
- CompactType,
13
- Layout,
14
- LayoutItem,
15
- ResizeHandleAxis
16
- } from "./utils";
17
-
18
- // util
19
- export type ReactRef<T: HTMLElement> = {|
20
- +current: T | null
21
- |};
22
-
23
- export type ResizeHandle =
24
- | ReactElement<any>
25
- | ((
26
- resizeHandleAxis: ResizeHandleAxis,
27
- ref: ReactRef<HTMLElement>
28
- ) => ReactElement<any>);
29
-
30
- // Defines which resize handles should be rendered (default: 'se')
31
- // Allows for any combination of:
32
- // 's' - South handle (bottom-center)
33
- // 'w' - West handle (left-center)
34
- // 'e' - East handle (right-center)
35
- // 'n' - North handle (top-center)
36
- // 'sw' - Southwest handle (bottom-left)
37
- // 'nw' - Northwest handle (top-left)
38
- // 'se' - Southeast handle (bottom-right)
39
- // 'ne' - Northeast handle (top-right)
40
- export const resizeHandleAxesType: ReactPropsChainableTypeChecker =
41
- PropTypes.arrayOf(
42
- PropTypes.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"])
43
- );
44
- // Custom component for resize handles
45
- export const resizeHandleType: ReactPropsChainableTypeChecker =
46
- PropTypes.oneOfType([PropTypes.node, PropTypes.func]);
47
-
48
- export type Props = {|
49
- className: string,
50
- style: Object,
51
- width: number,
52
- autoSize: boolean,
53
- cols: number,
54
- draggableCancel: string,
55
- draggableHandle: string,
56
- verticalCompact: boolean,
57
- compactType: CompactType,
58
- layout: Layout,
59
- margin: [number, number],
60
- containerPadding: ?[number, number],
61
- rowHeight: number,
62
- maxRows: number,
63
- isBounded: boolean,
64
- isDraggable: boolean,
65
- isResizable: boolean,
66
- isDroppable: boolean,
67
- preventCollision: boolean,
68
- useCSSTransforms: boolean,
69
- transformScale: number,
70
- droppingItem: $Shape<LayoutItem>,
71
- resizeHandles: ResizeHandleAxis[],
72
- resizeHandle?: ResizeHandle,
73
- allowOverlap: boolean,
74
-
75
- // Callbacks
76
- onLayoutChange: Layout => void,
77
- onDrag: EventCallback,
78
- onDragStart: EventCallback,
79
- onDragStop: EventCallback,
80
- onResize: EventCallback,
81
- onResizeStart: EventCallback,
82
- onResizeStop: EventCallback,
83
- onDropDragOver: (e: DragOverEvent) => ?({| w?: number, h?: number |} | false),
84
- onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void,
85
- children: ReactChildrenArray<ReactElement<any>>,
86
- innerRef?: Ref<"div">
87
- |};
88
-
89
- export type DefaultProps = $Diff<
90
- Props,
91
- {
92
- children: ReactChildrenArray<ReactElement<any>>,
93
- width: number
94
- }
95
- >;
96
-
97
- export default {
98
- //
99
- // Basic props
100
- //
101
- className: PropTypes.string,
102
- style: PropTypes.object,
103
-
104
- // This can be set explicitly. If it is not set, it will automatically
105
- // be set to the container width. Note that resizes will *not* cause this to adjust.
106
- // If you need that behavior, use WidthProvider.
107
- width: PropTypes.number,
108
-
109
- // If true, the container height swells and contracts to fit contents
110
- autoSize: PropTypes.bool,
111
- // # of cols.
112
- cols: PropTypes.number,
113
-
114
- // A selector that will not be draggable.
115
- draggableCancel: PropTypes.string,
116
- // A selector for the draggable handler
117
- draggableHandle: PropTypes.string,
118
-
119
- // Deprecated
120
- verticalCompact: function (props: Props) {
121
- if (
122
- props.verticalCompact === false &&
123
- process.env.NODE_ENV !== "production"
124
- ) {
125
- console.warn(
126
- // eslint-disable-line no-console
127
- "`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. " +
128
- 'Use `compactType`: "horizontal" | "vertical" | null.'
129
- );
130
- }
131
- },
132
- // Choose vertical or hotizontal compaction
133
- compactType: (PropTypes.oneOf([
134
- "vertical",
135
- "horizontal"
136
- ]): ReactPropsChainableTypeChecker),
137
-
138
- // layout is an array of object with the format:
139
- // {x: Number, y: Number, w: Number, h: Number, i: String}
140
- layout: function (props: Props) {
141
- var layout = props.layout;
142
- // I hope you're setting the data-grid property on the grid items
143
- if (layout === undefined) return;
144
- require("./utils").validateLayout(layout, "layout");
145
- },
146
-
147
- //
148
- // Grid Dimensions
149
- //
150
-
151
- // Margin between items [x, y] in px
152
- margin: (PropTypes.arrayOf(PropTypes.number): ReactPropsChainableTypeChecker),
153
- // Padding inside the container [x, y] in px
154
- containerPadding: (PropTypes.arrayOf(
155
- PropTypes.number
156
- ): ReactPropsChainableTypeChecker),
157
- // Rows have a static height, but you can change this based on breakpoints if you like
158
- rowHeight: PropTypes.number,
159
- // Default Infinity, but you can specify a max here if you like.
160
- // Note that this isn't fully fleshed out and won't error if you specify a layout that
161
- // extends beyond the row capacity. It will, however, not allow users to drag/resize
162
- // an item past the barrier. They can push items beyond the barrier, though.
163
- // Intentionally not documented for this reason.
164
- maxRows: PropTypes.number,
165
-
166
- //
167
- // Flags
168
- //
169
- isBounded: PropTypes.bool,
170
- isDraggable: PropTypes.bool,
171
- isResizable: PropTypes.bool,
172
- // If true, grid can be placed one over the other.
173
- allowOverlap: PropTypes.bool,
174
- // If true, grid items won't change position when being dragged over.
175
- preventCollision: PropTypes.bool,
176
- // Use CSS transforms instead of top/left
177
- useCSSTransforms: PropTypes.bool,
178
- // parent layout transform scale
179
- transformScale: PropTypes.number,
180
- // If true, an external element can trigger onDrop callback with a specific grid position as a parameter
181
- isDroppable: PropTypes.bool,
182
-
183
- // Resize handle options
184
- resizeHandles: resizeHandleAxesType,
185
- resizeHandle: resizeHandleType,
186
-
187
- //
188
- // Callbacks
189
- //
190
-
191
- // Callback so you can save the layout. Calls after each drag & resize stops.
192
- onLayoutChange: PropTypes.func,
193
-
194
- // Calls when drag starts. Callback is of the signature (layout, oldItem, newItem, placeholder, e, ?node).
195
- // All callbacks below have the same signature. 'start' and 'stop' callbacks omit the 'placeholder'.
196
- onDragStart: PropTypes.func,
197
- // Calls on each drag movement.
198
- onDrag: PropTypes.func,
199
- // Calls when drag is complete.
200
- onDragStop: PropTypes.func,
201
- //Calls when resize starts.
202
- onResizeStart: PropTypes.func,
203
- // Calls when resize movement happens.
204
- onResize: PropTypes.func,
205
- // Calls when resize is complete.
206
- onResizeStop: PropTypes.func,
207
- // Calls when some element is dropped.
208
- onDrop: PropTypes.func,
209
-
210
- //
211
- // Other validations
212
- //
213
-
214
- droppingItem: (PropTypes.shape({
215
- i: PropTypes.string.isRequired,
216
- w: PropTypes.number.isRequired,
217
- h: PropTypes.number.isRequired
218
- }): ReactPropsChainableTypeChecker),
219
-
220
- // Children must not have duplicate keys.
221
- children: function (props: Props, propName: string) {
222
- const children = props[propName];
223
-
224
- // Check children keys for duplicates. Throw if found.
225
- const keys = {};
226
- React.Children.forEach(children, function (child) {
227
- if (child?.key == null) return;
228
- if (keys[child.key]) {
229
- throw new Error(
230
- 'Duplicate child key "' +
231
- child.key +
232
- '" found! This will cause problems in ReactGridLayout.'
233
- );
234
- }
235
- keys[child.key] = true;
236
- });
237
- },
238
-
239
- // Optional ref for getting a reference for the wrapping div.
240
- innerRef: PropTypes.any
241
- };
@@ -1,349 +0,0 @@
1
- // @flow
2
- import * as React from "react";
3
- import PropTypes from "prop-types";
4
- import { deepEqual } from "fast-equals";
5
-
6
- import {
7
- cloneLayout,
8
- synchronizeLayoutWithChildren,
9
- validateLayout,
10
- noop,
11
- type Layout,
12
- type Pick
13
- } from "./utils";
14
- import {
15
- getBreakpointFromWidth,
16
- getColsFromBreakpoint,
17
- findOrGenerateResponsiveLayout,
18
- type ResponsiveLayout,
19
- type OnLayoutChangeCallback,
20
- type Breakpoints
21
- } from "./responsiveUtils";
22
- import ReactGridLayout from "./ReactGridLayout";
23
-
24
- // $FlowFixMe[method-unbinding]
25
- const type = obj => Object.prototype.toString.call(obj);
26
-
27
- /**
28
- * Get a value of margin or containerPadding.
29
- *
30
- * @param {Array | Object} param Margin | containerPadding, e.g. [10, 10] | {lg: [10, 10], ...}.
31
- * @param {String} breakpoint Breakpoint: lg, md, sm, xs and etc.
32
- * @return {Array}
33
- */
34
- function getIndentationValue<T: ?[number, number]>(
35
- param: { [key: string]: T } | T,
36
- breakpoint: string
37
- ): T {
38
- // $FlowIgnore TODO fix this typedef
39
- if (param == null) return null;
40
- // $FlowIgnore TODO fix this typedef
41
- return Array.isArray(param) ? param : param[breakpoint];
42
- }
43
-
44
- type State = {
45
- layout: Layout,
46
- breakpoint: string,
47
- cols: number,
48
- layouts?: ResponsiveLayout<string>
49
- };
50
-
51
- type Props<Breakpoint: string = string> = {|
52
- ...React.ElementConfig<typeof ReactGridLayout>,
53
-
54
- // Responsive config
55
- breakpoint?: ?Breakpoint,
56
- breakpoints: Breakpoints<Breakpoint>,
57
- cols: { [key: Breakpoint]: number },
58
- layouts: ResponsiveLayout<Breakpoint>,
59
- width: number,
60
- margin: { [key: Breakpoint]: [number, number] } | [number, number],
61
- /* prettier-ignore */
62
- containerPadding: { [key: Breakpoint]: ?[number, number] } | ?[number, number],
63
-
64
- // Callbacks
65
- onBreakpointChange: (Breakpoint, cols: number) => void,
66
- onLayoutChange: OnLayoutChangeCallback,
67
- onWidthChange: (
68
- containerWidth: number,
69
- margin: [number, number],
70
- cols: number,
71
- containerPadding: ?[number, number]
72
- ) => void
73
- |};
74
-
75
- type DefaultProps = Pick<
76
- Props<>,
77
- {|
78
- allowOverlap: 0,
79
- breakpoints: 0,
80
- cols: 0,
81
- containerPadding: 0,
82
- layouts: 0,
83
- margin: 0,
84
- onBreakpointChange: 0,
85
- onLayoutChange: 0,
86
- onWidthChange: 0
87
- |}
88
- >;
89
-
90
- export default class ResponsiveReactGridLayout extends React.Component<
91
- Props<>,
92
- State
93
- > {
94
- // This should only include propTypes needed in this code; RGL itself
95
- // will do validation of the rest props passed to it.
96
- static propTypes = {
97
- //
98
- // Basic props
99
- //
100
-
101
- // Optional, but if you are managing width yourself you may want to set the breakpoint
102
- // yourself as well.
103
- breakpoint: PropTypes.string,
104
-
105
- // {name: pxVal}, e.g. {lg: 1200, md: 996, sm: 768, xs: 480}
106
- breakpoints: PropTypes.object,
107
-
108
- allowOverlap: PropTypes.bool,
109
-
110
- // # of cols. This is a breakpoint -> cols map
111
- cols: PropTypes.object,
112
-
113
- // # of margin. This is a breakpoint -> margin map
114
- // e.g. { lg: [5, 5], md: [10, 10], sm: [15, 15] }
115
- // Margin between items [x, y] in px
116
- // e.g. [10, 10]
117
- margin: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
118
-
119
- // # of containerPadding. This is a breakpoint -> containerPadding map
120
- // e.g. { lg: [5, 5], md: [10, 10], sm: [15, 15] }
121
- // Padding inside the container [x, y] in px
122
- // e.g. [10, 10]
123
- containerPadding: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
124
-
125
- // layouts is an object mapping breakpoints to layouts.
126
- // e.g. {lg: Layout, md: Layout, ...}
127
- layouts(props: Props<>, propName: string) {
128
- if (type(props[propName]) !== "[object Object]") {
129
- throw new Error(
130
- "Layout property must be an object. Received: " +
131
- type(props[propName])
132
- );
133
- }
134
- Object.keys(props[propName]).forEach(key => {
135
- if (!(key in props.breakpoints)) {
136
- throw new Error(
137
- "Each key in layouts must align with a key in breakpoints."
138
- );
139
- }
140
- validateLayout(props.layouts[key], "layouts." + key);
141
- });
142
- },
143
-
144
- // The width of this component.
145
- // Required in this propTypes stanza because generateInitialState() will fail without it.
146
- width: PropTypes.number.isRequired,
147
-
148
- //
149
- // Callbacks
150
- //
151
-
152
- // Calls back with breakpoint and new # cols
153
- onBreakpointChange: PropTypes.func,
154
-
155
- // Callback so you can save the layout.
156
- // Calls back with (currentLayout, allLayouts). allLayouts are keyed by breakpoint.
157
- onLayoutChange: PropTypes.func,
158
-
159
- // Calls back with (containerWidth, margin, cols, containerPadding)
160
- onWidthChange: PropTypes.func
161
- };
162
-
163
- static defaultProps: DefaultProps = {
164
- breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 },
165
- cols: { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 },
166
- containerPadding: { lg: null, md: null, sm: null, xs: null, xxs: null },
167
- layouts: {},
168
- margin: [10, 10],
169
- allowOverlap: false,
170
- onBreakpointChange: noop,
171
- onLayoutChange: noop,
172
- onWidthChange: noop
173
- };
174
-
175
- state: State = this.generateInitialState();
176
-
177
- generateInitialState(): State {
178
- const { width, breakpoints, layouts, cols } = this.props;
179
- const breakpoint = getBreakpointFromWidth(breakpoints, width);
180
- const colNo = getColsFromBreakpoint(breakpoint, cols);
181
- // verticalCompact compatibility, now deprecated
182
- const compactType =
183
- this.props.verticalCompact === false ? null : this.props.compactType;
184
- // Get the initial layout. This can tricky; we try to generate one however possible if one doesn't exist
185
- // for this layout.
186
- const initialLayout = findOrGenerateResponsiveLayout(
187
- layouts,
188
- breakpoints,
189
- breakpoint,
190
- breakpoint,
191
- colNo,
192
- compactType
193
- );
194
-
195
- return {
196
- layout: initialLayout,
197
- breakpoint: breakpoint,
198
- cols: colNo
199
- };
200
- }
201
-
202
- static getDerivedStateFromProps(
203
- nextProps: Props<*>,
204
- prevState: State
205
- ): ?$Shape<State> {
206
- if (!deepEqual(nextProps.layouts, prevState.layouts)) {
207
- // Allow parent to set layouts directly.
208
- const { breakpoint, cols } = prevState;
209
-
210
- // Since we're setting an entirely new layout object, we must generate a new responsive layout
211
- // if one does not exist.
212
- const newLayout = findOrGenerateResponsiveLayout(
213
- nextProps.layouts,
214
- nextProps.breakpoints,
215
- breakpoint,
216
- breakpoint,
217
- cols,
218
- nextProps.compactType
219
- );
220
- return { layout: newLayout, layouts: nextProps.layouts };
221
- }
222
-
223
- return null;
224
- }
225
-
226
- componentDidUpdate(prevProps: Props<*>) {
227
- // Allow parent to set width or breakpoint directly.
228
- if (
229
- this.props.width != prevProps.width ||
230
- this.props.breakpoint !== prevProps.breakpoint ||
231
- !deepEqual(this.props.breakpoints, prevProps.breakpoints) ||
232
- !deepEqual(this.props.cols, prevProps.cols)
233
- ) {
234
- this.onWidthChange(prevProps);
235
- }
236
- }
237
-
238
- // wrap layouts so we do not need to pass layouts to child
239
- onLayoutChange: Layout => void = (layout: Layout) => {
240
- this.props.onLayoutChange(layout, {
241
- ...this.props.layouts,
242
- [this.state.breakpoint]: layout
243
- });
244
- };
245
-
246
- /**
247
- * When the width changes work through breakpoints and reset state with the new width & breakpoint.
248
- * Width changes are necessary to figure out the widget widths.
249
- */
250
- onWidthChange(prevProps: Props<*>) {
251
- const { breakpoints, cols, layouts, compactType } = this.props;
252
- const newBreakpoint =
253
- this.props.breakpoint ||
254
- getBreakpointFromWidth(this.props.breakpoints, this.props.width);
255
-
256
- const lastBreakpoint = this.state.breakpoint;
257
- const newCols: number = getColsFromBreakpoint(newBreakpoint, cols);
258
- const newLayouts = { ...layouts };
259
-
260
- // Breakpoint change
261
- if (
262
- lastBreakpoint !== newBreakpoint ||
263
- prevProps.breakpoints !== breakpoints ||
264
- prevProps.cols !== cols
265
- ) {
266
- // Preserve the current layout if the current breakpoint is not present in the next layouts.
267
- if (!(lastBreakpoint in newLayouts))
268
- newLayouts[lastBreakpoint] = cloneLayout(this.state.layout);
269
-
270
- // Find or generate a new layout.
271
- let layout = findOrGenerateResponsiveLayout(
272
- newLayouts,
273
- breakpoints,
274
- newBreakpoint,
275
- lastBreakpoint,
276
- newCols,
277
- compactType
278
- );
279
-
280
- // This adds missing items.
281
- layout = synchronizeLayoutWithChildren(
282
- layout,
283
- this.props.children,
284
- newCols,
285
- compactType,
286
- this.props.allowOverlap
287
- );
288
-
289
- // Store the new layout.
290
- newLayouts[newBreakpoint] = layout;
291
-
292
- // callbacks
293
- this.props.onBreakpointChange(newBreakpoint, newCols);
294
- this.props.onLayoutChange(layout, newLayouts);
295
-
296
- this.setState({
297
- breakpoint: newBreakpoint,
298
- layout: layout,
299
- cols: newCols
300
- });
301
- }
302
-
303
- const margin = getIndentationValue(this.props.margin, newBreakpoint);
304
- const containerPadding = getIndentationValue(
305
- this.props.containerPadding,
306
- newBreakpoint
307
- );
308
-
309
- //call onWidthChange on every change of width, not only on breakpoint changes
310
- this.props.onWidthChange(
311
- this.props.width,
312
- margin,
313
- newCols,
314
- containerPadding
315
- );
316
- }
317
-
318
- render(): React.Element<typeof ReactGridLayout> {
319
- /* eslint-disable no-unused-vars */
320
- const {
321
- breakpoint,
322
- breakpoints,
323
- cols,
324
- layouts,
325
- margin,
326
- containerPadding,
327
- onBreakpointChange,
328
- onLayoutChange,
329
- onWidthChange,
330
- ...other
331
- } = this.props;
332
- /* eslint-enable no-unused-vars */
333
-
334
- return (
335
- <ReactGridLayout
336
- {...other}
337
- // $FlowIgnore should allow nullable here due to DefaultProps
338
- margin={getIndentationValue(margin, this.state.breakpoint)}
339
- containerPadding={getIndentationValue(
340
- containerPadding,
341
- this.state.breakpoint
342
- )}
343
- onLayoutChange={this.onLayoutChange}
344
- layout={this.state.layout}
345
- cols={this.state.cols}
346
- />
347
- );
348
- }
349
- }