react-grid-layout 1.2.4 → 1.3.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 +3 -2
- package/.eslintignore +3 -0
- package/.flowconfig +1 -3
- package/.prettierignore +1 -0
- package/CHANGELOG.md +371 -236
- package/README.md +122 -62
- package/build/GridItem.js +12 -12
- package/build/ReactGridLayout.js +306 -325
- package/build/ReactGridLayoutPropTypes.js +11 -5
- package/build/ResponsiveReactGridLayout.js +16 -10
- package/build/calculateUtils.js +8 -8
- package/build/components/WidthProvider.js +11 -9
- package/build/fastRGLPropsEqual.js +1 -1
- package/build/responsiveUtils.js +1 -1
- package/build/utils.js +48 -53
- package/coverage/clover.xml +761 -0
- package/coverage/coverage-final.json +15 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/react-grid-layout/index-dev.js.html +104 -0
- package/coverage/lcov-report/react-grid-layout/lib/GridItem.jsx.html +2099 -0
- package/coverage/lcov-report/react-grid-layout/lib/ReactGridLayout.jsx.html +2453 -0
- package/coverage/lcov-report/react-grid-layout/lib/ReactGridLayoutPropTypes.js.html +833 -0
- package/coverage/lcov-report/react-grid-layout/lib/ResponsiveReactGridLayout.jsx.html +1133 -0
- package/coverage/lcov-report/react-grid-layout/lib/calculateUtils.js.html +557 -0
- package/coverage/lcov-report/react-grid-layout/lib/components/WidthProvider.jsx.html +410 -0
- package/coverage/lcov-report/react-grid-layout/lib/fastRGLPropsEqual.js.html +224 -0
- package/coverage/lcov-report/react-grid-layout/lib/responsiveUtils.js.html +440 -0
- package/coverage/lcov-report/react-grid-layout/lib/utils.js.html +2456 -0
- package/coverage/lcov-report/react-grid-layout/test/examples/0-showcase.jsx.html +521 -0
- package/coverage/lcov-report/react-grid-layout/test/examples/1-basic.jsx.html +284 -0
- package/coverage/lcov-report/react-grid-layout/test/examples/15-drag-from-outside.jsx.html +506 -0
- package/coverage/lcov-report/react-grid-layout/test/util/deepFreeze.js.html +248 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +1584 -0
- package/dist/react-grid-layout.min.js +1 -2
- package/dist/react-grid-layout.min.js.map +1 -1
- package/index.js +4 -2
- package/lib/GridItem.jsx +15 -10
- package/lib/ReactGridLayout.jsx +101 -62
- package/lib/ReactGridLayoutPropTypes.js +38 -17
- package/lib/ResponsiveReactGridLayout.jsx +7 -1
- package/lib/components/WidthProvider.jsx +2 -2
- package/lib/utils.js +45 -40
- package/package.json +48 -34
- package/.husky/pre-commit +0 -6
- package/.travis.yml +0 -9
- package/dist/react-grid-layout.min.js.LICENSE.txt +0 -5
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ or autogenerated.
|
|
|
14
14
|
RGL is React-only and does not require jQuery.
|
|
15
15
|
|
|
16
16
|

|
|
17
|
+
|
|
17
18
|
> GIF from production usage on [BitMEX.com](https://www.bitmex.com)
|
|
18
19
|
|
|
19
20
|
[**[Demo](https://react-grid-layout.github.io/react-grid-layout/) | [Changelog](/CHANGELOG.md) | [CodeSandbox Editable demo](https://codesandbox.io/s/5wy3rz5z1x?module=%2Fsrc%2FShowcaseLayout.js)**]
|
|
@@ -55,6 +56,7 @@ RGL is React-only and does not require jQuery.
|
|
|
55
56
|
1. [Bounded Layout](https://react-grid-layout.github.io/react-grid-layout/examples/16-bounded.html)
|
|
56
57
|
1. [Resizable Handles](https://react-grid-layout.github.io/react-grid-layout/examples/17-resizable-handles.html)
|
|
57
58
|
1. [Scaled Containers](https://react-grid-layout.github.io/react-grid-layout/examples/18-scale.html)
|
|
59
|
+
1. [Allow Overlap](https://react-grid-layout.github.io/react-grid-layout/examples/19-allow-overlap.html)
|
|
58
60
|
|
|
59
61
|
#### Projects Using React-Grid-Layout
|
|
60
62
|
|
|
@@ -74,33 +76,34 @@ RGL is React-only and does not require jQuery.
|
|
|
74
76
|
- [Hakkiri](https://www.hakkiri.io)
|
|
75
77
|
- [Ubidots](https://help.ubidots.com/en/articles/2400308-create-dashboards-and-widgets)
|
|
76
78
|
- [Statsout](https://statsout.com/)
|
|
79
|
+
- [Datto RMM](https://www.datto.com/uk/products/rmm/)
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
_Know of others? Create a PR to let me know!_
|
|
79
82
|
|
|
80
83
|
## Features
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|Version
|
|
98
|
-
|
|
99
|
-
| >= 0.17.0
|
|
100
|
-
| >= 0.11.3
|
|
101
|
-
| >= 0.10.0
|
|
102
|
-
| 0.8. - 0.9.2
|
|
103
|
-
| < 0.8
|
|
85
|
+
- 100% React - no jQuery
|
|
86
|
+
- Compatible with server-rendered apps
|
|
87
|
+
- Draggable widgets
|
|
88
|
+
- Resizable widgets
|
|
89
|
+
- Static widgets
|
|
90
|
+
- Configurable packing: horizontal, vertical, or off
|
|
91
|
+
- Bounds checking for dragging and resizing
|
|
92
|
+
- Widgets may be added or removed without rebuilding grid
|
|
93
|
+
- Layout can be serialized and restored
|
|
94
|
+
- Responsive breakpoints
|
|
95
|
+
- Separate layouts per responsive breakpoint
|
|
96
|
+
- Grid Items placed using CSS Transforms
|
|
97
|
+
- Performance with CSS Transforms: [on](http://i.imgur.com/FTogpLp.jpg) / [off](http://i.imgur.com/gOveMm8.jpg), note paint (green) as % of time
|
|
98
|
+
- Compatibility with `<React.StrictMode>`
|
|
99
|
+
|
|
100
|
+
| Version | Compatibility |
|
|
101
|
+
| ------------ | --------------- |
|
|
102
|
+
| >= 0.17.0 | React 16 & 17 |
|
|
103
|
+
| >= 0.11.3 | React 0.14 & 15 |
|
|
104
|
+
| >= 0.10.0 | React 0.14 |
|
|
105
|
+
| 0.8. - 0.9.2 | React 0.13 |
|
|
106
|
+
| < 0.8 | React 0.12 |
|
|
104
107
|
|
|
105
108
|
## Installation
|
|
106
109
|
|
|
@@ -127,23 +130,29 @@ produce a grid with three items where:
|
|
|
127
130
|
- users will be able to freely drag and resize item `c`
|
|
128
131
|
|
|
129
132
|
```js
|
|
130
|
-
import GridLayout from
|
|
133
|
+
import GridLayout from "react-grid-layout";
|
|
131
134
|
|
|
132
135
|
class MyFirstGrid extends React.Component {
|
|
133
136
|
render() {
|
|
134
137
|
// layout is an array of objects, see the demo for more complete usage
|
|
135
138
|
const layout = [
|
|
136
|
-
{i:
|
|
137
|
-
{i:
|
|
138
|
-
{i:
|
|
139
|
+
{ i: "a", x: 0, y: 0, w: 1, h: 2, static: true },
|
|
140
|
+
{ i: "b", x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 },
|
|
141
|
+
{ i: "c", x: 4, y: 0, w: 1, h: 2 }
|
|
139
142
|
];
|
|
140
143
|
return (
|
|
141
|
-
<GridLayout
|
|
144
|
+
<GridLayout
|
|
145
|
+
className="layout"
|
|
146
|
+
layout={layout}
|
|
147
|
+
cols={12}
|
|
148
|
+
rowHeight={30}
|
|
149
|
+
width={1200}
|
|
150
|
+
>
|
|
142
151
|
<div key="a">a</div>
|
|
143
152
|
<div key="b">b</div>
|
|
144
153
|
<div key="c">c</div>
|
|
145
154
|
</GridLayout>
|
|
146
|
-
)
|
|
155
|
+
);
|
|
147
156
|
}
|
|
148
157
|
}
|
|
149
158
|
```
|
|
@@ -151,17 +160,23 @@ class MyFirstGrid extends React.Component {
|
|
|
151
160
|
You may also choose to set layout properties directly on the children:
|
|
152
161
|
|
|
153
162
|
```js
|
|
154
|
-
import GridLayout from
|
|
163
|
+
import GridLayout from "react-grid-layout";
|
|
155
164
|
|
|
156
165
|
class MyFirstGrid extends React.Component {
|
|
157
166
|
render() {
|
|
158
167
|
return (
|
|
159
168
|
<GridLayout className="layout" cols={12} rowHeight={30} width={1200}>
|
|
160
|
-
<div key="a" data-grid={{x: 0, y: 0, w: 1, h: 2, static: true}}>
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
<div key="a" data-grid={{ x: 0, y: 0, w: 1, h: 2, static: true }}>
|
|
170
|
+
a
|
|
171
|
+
</div>
|
|
172
|
+
<div key="b" data-grid={{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }}>
|
|
173
|
+
b
|
|
174
|
+
</div>
|
|
175
|
+
<div key="c" data-grid={{ x: 4, y: 0, w: 1, h: 2 }}>
|
|
176
|
+
c
|
|
177
|
+
</div>
|
|
163
178
|
</GridLayout>
|
|
164
|
-
)
|
|
179
|
+
);
|
|
165
180
|
}
|
|
166
181
|
}
|
|
167
182
|
```
|
|
@@ -176,21 +191,24 @@ excludes `React`, so it must be otherwise available in your application, either
|
|
|
176
191
|
To make RGL responsive, use the `<ResponsiveReactGridLayout>` element:
|
|
177
192
|
|
|
178
193
|
```js
|
|
179
|
-
import { Responsive as ResponsiveGridLayout } from
|
|
194
|
+
import { Responsive as ResponsiveGridLayout } from "react-grid-layout";
|
|
180
195
|
|
|
181
196
|
class MyResponsiveGrid extends React.Component {
|
|
182
197
|
render() {
|
|
183
198
|
// {lg: layout1, md: layout2, ...}
|
|
184
199
|
const layouts = getLayoutsFromSomewhere();
|
|
185
200
|
return (
|
|
186
|
-
<ResponsiveGridLayout
|
|
187
|
-
|
|
188
|
-
|
|
201
|
+
<ResponsiveGridLayout
|
|
202
|
+
className="layout"
|
|
203
|
+
layouts={layouts}
|
|
204
|
+
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
|
|
205
|
+
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
|
|
206
|
+
>
|
|
189
207
|
<div key="1">1</div>
|
|
190
208
|
<div key="2">2</div>
|
|
191
209
|
<div key="3">3</div>
|
|
192
210
|
</ResponsiveGridLayout>
|
|
193
|
-
)
|
|
211
|
+
);
|
|
194
212
|
}
|
|
195
213
|
}
|
|
196
214
|
```
|
|
@@ -213,7 +231,7 @@ positions on drag events. In simple cases a HOC `WidthProvider` can be used to a
|
|
|
213
231
|
width upon initialization and window resize events.
|
|
214
232
|
|
|
215
233
|
```js
|
|
216
|
-
import { Responsive, WidthProvider } from
|
|
234
|
+
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
217
235
|
|
|
218
236
|
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
219
237
|
|
|
@@ -222,14 +240,17 @@ class MyResponsiveGrid extends React.Component {
|
|
|
222
240
|
// {lg: layout1, md: layout2, ...}
|
|
223
241
|
var layouts = getLayoutsFromSomewhere();
|
|
224
242
|
return (
|
|
225
|
-
<ResponsiveGridLayout
|
|
226
|
-
|
|
227
|
-
|
|
243
|
+
<ResponsiveGridLayout
|
|
244
|
+
className="layout"
|
|
245
|
+
layouts={layouts}
|
|
246
|
+
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
|
|
247
|
+
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
|
|
248
|
+
>
|
|
228
249
|
<div key="1">1</div>
|
|
229
250
|
<div key="2">2</div>
|
|
230
251
|
<div key="3">3</div>
|
|
231
252
|
</ResponsiveGridLayout>
|
|
232
|
-
)
|
|
253
|
+
);
|
|
233
254
|
}
|
|
234
255
|
}
|
|
235
256
|
```
|
|
@@ -266,6 +287,7 @@ cols: ?number = 12,
|
|
|
266
287
|
// A CSS selector for tags that will not be draggable.
|
|
267
288
|
// For example: draggableCancel:'.MyNonDraggableAreaClassName'
|
|
268
289
|
// If you forget the leading . it will not work.
|
|
290
|
+
// .react-resizable-handle" is always prepended to this value.
|
|
269
291
|
draggableCancel: ?string = '',
|
|
270
292
|
|
|
271
293
|
// A CSS selector for tags that will act as the draggable handle.
|
|
@@ -273,9 +295,6 @@ draggableCancel: ?string = '',
|
|
|
273
295
|
// If you forget the leading . it will not work.
|
|
274
296
|
draggableHandle: ?string = '',
|
|
275
297
|
|
|
276
|
-
// If true, the layout will compact vertically
|
|
277
|
-
verticalCompact: ?boolean = true,
|
|
278
|
-
|
|
279
298
|
// Compaction type.
|
|
280
299
|
compactType: ?('vertical' | 'horizontal') = 'vertical';
|
|
281
300
|
|
|
@@ -318,9 +337,14 @@ useCSSTransforms: ?boolean = true,
|
|
|
318
337
|
// we should set scale coefficient to avoid render artefacts while dragging.
|
|
319
338
|
transformScale: ?number = 1,
|
|
320
339
|
|
|
340
|
+
// If true, grid can be placed one over the other.
|
|
341
|
+
// If set, implies `preventCollision`.
|
|
342
|
+
allowOverlap: ?boolean = false,
|
|
343
|
+
|
|
321
344
|
// If true, grid items won't change position when being
|
|
322
|
-
// dragged over.
|
|
323
|
-
|
|
345
|
+
// dragged over. If `allowOverlap` is still false,
|
|
346
|
+
// this simply won't allow one to drop on an existing object.
|
|
347
|
+
preventCollision: ?boolean = false,
|
|
324
348
|
|
|
325
349
|
// If true, droppable elements (with `draggable={true}` attribute)
|
|
326
350
|
// can be dropped on the grid. It triggers "onDrop" callback
|
|
@@ -332,7 +356,7 @@ preventCollision: ?boolean = false;
|
|
|
332
356
|
// along with `draggable={true}` otherwise this feature will work incorrect.
|
|
333
357
|
// onDragStart attribute is required for Firefox for a dragging initialization
|
|
334
358
|
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=568313
|
|
335
|
-
isDroppable: ?boolean = false
|
|
359
|
+
isDroppable: ?boolean = false,
|
|
336
360
|
// Defines which resize handles should be rendered
|
|
337
361
|
// Allows for any combination of:
|
|
338
362
|
// 's' - South handle (bottom-center)
|
|
@@ -343,9 +367,12 @@ isDroppable: ?boolean = false
|
|
|
343
367
|
// 'nw' - Northwest handle (top-left)
|
|
344
368
|
// 'se' - Southeast handle (bottom-right)
|
|
345
369
|
// 'ne' - Northeast handle (top-right)
|
|
346
|
-
resizeHandles: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se']
|
|
370
|
+
resizeHandles: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se'],
|
|
347
371
|
// Custom component for resize handles
|
|
348
|
-
|
|
372
|
+
// See `handle` as used in https://github.com/react-grid-layout/react-resizable#resize-handle
|
|
373
|
+
// Your component should have the class `.react-resizable-handle`, or you should add your custom
|
|
374
|
+
// class to the `draggableCancel` prop.
|
|
375
|
+
resizeHandle?: ReactElement<any> | ((resizeHandleAxis: ResizeHandleAxis, ref: ReactRef<HTMLElement>) => ReactElement<any>),
|
|
349
376
|
|
|
350
377
|
//
|
|
351
378
|
// Callbacks
|
|
@@ -360,7 +387,7 @@ onLayoutChange: (layout: Layout) => void,
|
|
|
360
387
|
// 'start' and 'stop' callbacks pass `undefined` for 'placeholder'.
|
|
361
388
|
//
|
|
362
389
|
type ItemCallback = (layout: Layout, oldItem: LayoutItem, newItem: LayoutItem,
|
|
363
|
-
placeholder: LayoutItem, e: MouseEvent, element: HTMLElement) => void
|
|
390
|
+
placeholder: LayoutItem, e: MouseEvent, element: HTMLElement) => void,
|
|
364
391
|
|
|
365
392
|
// Calls when drag starts.
|
|
366
393
|
onDragStart: ItemCallback,
|
|
@@ -374,12 +401,23 @@ onResizeStart: ItemCallback,
|
|
|
374
401
|
onResize: ItemCallback,
|
|
375
402
|
// Calls when resize is complete.
|
|
376
403
|
onResizeStop: ItemCallback,
|
|
404
|
+
|
|
405
|
+
//
|
|
406
|
+
// Dropover functionality
|
|
407
|
+
//
|
|
408
|
+
|
|
377
409
|
// Calls when an element has been dropped into the grid from outside.
|
|
378
|
-
onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void
|
|
410
|
+
onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void,
|
|
411
|
+
// Calls when an element is being dragged over the grid from outside as above.
|
|
412
|
+
// This callback should return an object to dynamically change the droppingItem size
|
|
413
|
+
// Return false to short-circuit the dragover
|
|
414
|
+
onDropDragOver: (e: DragOverEvent) => ?({|w?: number, h?: number|} | false),
|
|
379
415
|
|
|
380
416
|
// Ref for getting a reference for the grid's wrapping div.
|
|
381
417
|
// You can use this instead of a regular ref and the deprecated `ReactDOM.findDOMNode()`` function.
|
|
382
|
-
|
|
418
|
+
// Note that this type is React.Ref<HTMLDivElement> in TypeScript, Flow has a bug here
|
|
419
|
+
// https://github.com/facebook/flow/issues/8671#issuecomment-862634865
|
|
420
|
+
innerRef: {current: null | HTMLDivElement},
|
|
383
421
|
```
|
|
384
422
|
|
|
385
423
|
### Responsive Grid Layout Props
|
|
@@ -397,16 +435,16 @@ cols: ?Object = {lg: 12, md: 10, sm: 6, xs: 4, xxs: 2},
|
|
|
397
435
|
|
|
398
436
|
|
|
399
437
|
// 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], ...}.
|
|
400
|
-
margin: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]}
|
|
438
|
+
margin: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]},
|
|
401
439
|
|
|
402
440
|
|
|
403
441
|
// 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], ...}.
|
|
404
|
-
containerPadding: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]}
|
|
442
|
+
containerPadding: [number, number] | {[breakpoint: $Keys<breakpoints>]: [number, number]},
|
|
405
443
|
|
|
406
444
|
|
|
407
445
|
// layouts is an object mapping breakpoints to layouts.
|
|
408
446
|
// e.g. {lg: Layout, md: Layout, ...}
|
|
409
|
-
layouts: {[key: $Keys<breakpoints>]: Layout}
|
|
447
|
+
layouts: {[key: $Keys<breakpoints>]: Layout},
|
|
410
448
|
|
|
411
449
|
//
|
|
412
450
|
// Callbacks
|
|
@@ -477,7 +515,6 @@ will be draggable, even if the item is marked `static: true`.
|
|
|
477
515
|
|
|
478
516
|
`<ReactGridLayout>` has [an optimized `shouldComponentUpdate` implementation](lib/ReactGridLayout.jsx), but it relies on the user memoizing the `children` array:
|
|
479
517
|
|
|
480
|
-
|
|
481
518
|
```js
|
|
482
519
|
// lib/ReactGridLayout.jsx
|
|
483
520
|
// ...
|
|
@@ -500,7 +537,7 @@ If you memoize your children, you can take advantage of this, and reap faster re
|
|
|
500
537
|
function MyGrid(props) {
|
|
501
538
|
const children = React.useMemo(() => {
|
|
502
539
|
return new Array(props.count).fill(undefined).map((val, idx) => {
|
|
503
|
-
return <div key={idx} data-grid={{x: idx, y: 1, w: 1, h: 1}} />;
|
|
540
|
+
return <div key={idx} data-grid={{ x: idx, y: 1, w: 1, h: 1 }} />;
|
|
504
541
|
});
|
|
505
542
|
}, [props.count]);
|
|
506
543
|
return <ReactGridLayout cols={12}>{children}</ReactGridLayout>;
|
|
@@ -509,11 +546,34 @@ function MyGrid(props) {
|
|
|
509
546
|
|
|
510
547
|
Because the `children` prop doesn't change between rerenders, updates to `<MyGrid>` won't result in new renders, improving performance.
|
|
511
548
|
|
|
549
|
+
### Custom Child Components and Draggable Handles
|
|
550
|
+
|
|
551
|
+
If you use React Components as grid children, they need to do a few things:
|
|
552
|
+
|
|
553
|
+
1. Forward refs to an underlying DOM node, and
|
|
554
|
+
2. Forward `style` and `className` to that same DOM node.
|
|
555
|
+
|
|
556
|
+
For example:
|
|
557
|
+
|
|
558
|
+
```js
|
|
559
|
+
const CustomGridItemComponent = React.forwardRef(({style, className, ...props}, ref) => {
|
|
560
|
+
return (
|
|
561
|
+
<div style={{ /* styles */, ...style}} className={className} ref={ref}>
|
|
562
|
+
{/* Some other content */}
|
|
563
|
+
</div>
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
The same is true of custom elements as draggable handles using the `draggableHandle` prop. This is so that
|
|
569
|
+
the underlying `react-draggable` library can get a reference to the DOM node underneath, manipulate
|
|
570
|
+
positioning via `style`, and set classes.
|
|
571
|
+
|
|
512
572
|
## Contribute
|
|
513
573
|
|
|
514
574
|
If you have a feature request, please add it as an issue or make a pull request.
|
|
515
575
|
|
|
516
|
-
If you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/s/
|
|
576
|
+
If you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/s/staging-bush-3lvt7?file=/src/ShowcaseLayout.js) to help
|
|
517
577
|
us easily isolate it.
|
|
518
578
|
|
|
519
579
|
## TODO List
|
|
@@ -529,5 +589,5 @@ us easily isolate it.
|
|
|
529
589
|
- [x] Static elements
|
|
530
590
|
- [x] Persistent id per item for predictable localstorage restores, even when # items changes
|
|
531
591
|
- [x] Min/max w/h per item
|
|
532
|
-
- [
|
|
592
|
+
- [x] Resizable handles on other corners
|
|
533
593
|
- [ ] Configurable w/h per breakpoint
|
package/build/GridItem.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -21,27 +21,27 @@ var _calculateUtils = require("./calculateUtils");
|
|
|
21
21
|
|
|
22
22
|
var _ReactGridLayoutPropTypes = require("./ReactGridLayoutPropTypes");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
|
|
28
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
29
|
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
31
|
|
|
32
32
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
33
|
|
|
34
34
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
35
35
|
|
|
36
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
36
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
37
37
|
|
|
38
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass
|
|
38
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
39
39
|
|
|
40
40
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
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
|
|
|
@@ -414,10 +414,10 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
|
|
|
414
414
|
var maxes = (0, _calculateUtils.calcGridItemPosition)(positionParams, 0, 0, maxW, maxH);
|
|
415
415
|
var minConstraints = [mins.width, mins.height];
|
|
416
416
|
var maxConstraints = [Math.min(maxes.width, maxWidth), Math.min(maxes.height, Infinity)];
|
|
417
|
-
return /*#__PURE__*/_react.default.createElement(_reactResizable.Resizable
|
|
417
|
+
return /*#__PURE__*/_react.default.createElement(_reactResizable.Resizable // These are opts for the resize handle itself
|
|
418
|
+
, {
|
|
418
419
|
draggableOpts: {
|
|
419
|
-
disabled: !isResizable
|
|
420
|
-
nodeRef: this.elementRef
|
|
420
|
+
disabled: !isResizable
|
|
421
421
|
},
|
|
422
422
|
className: isResizable ? undefined : "react-resizable-hide",
|
|
423
423
|
width: position.width,
|
|
@@ -512,7 +512,7 @@ var GridItem = /*#__PURE__*/function (_React$Component) {
|
|
|
512
512
|
|
|
513
513
|
var newChild = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
514
514
|
ref: this.elementRef,
|
|
515
|
-
className: (0,
|
|
515
|
+
className: (0, _clsx.default)("react-grid-item", child.props.className, this.props.className, {
|
|
516
516
|
static: this.props.static,
|
|
517
517
|
resizing: Boolean(this.state.resizing),
|
|
518
518
|
"react-draggable": isDraggable,
|
|
@@ -592,7 +592,7 @@ _defineProperty(GridItem, "propTypes", {
|
|
|
592
592
|
// ID is nice to have for callbacks
|
|
593
593
|
i: _propTypes.default.string.isRequired,
|
|
594
594
|
// Resize handle options
|
|
595
|
-
resizeHandles: _ReactGridLayoutPropTypes.
|
|
595
|
+
resizeHandles: _ReactGridLayoutPropTypes.resizeHandleAxesType,
|
|
596
596
|
resizeHandle: _ReactGridLayoutPropTypes.resizeHandleType,
|
|
597
597
|
// Functions
|
|
598
598
|
onDragStop: _propTypes.default.func,
|