@@ -35,10 +35,7 @@ function Simple() {
35
35
}));
36
36
37
37
return (
38
- <GridStackContainer
39
- initialOptions = { uncontrolledInitialOptions }
40
- renderRawContent
41
- >
38
+ <GridStackContainer initialOptions = { uncontrolledInitialOptions } >
42
39
<GridStackItem id = " item1" >
43
40
<div style = { { color: " yellow" }} >hello</div >
44
41
</GridStackItem >
@@ -70,7 +67,7 @@ function Simple() {
70
67
{ /* Custom toolbar component. Access to grid stack context by useGridStackContext hook. */ }
71
68
<Toolbar />
72
69
73
- <GridStackRender renderRawContent >
70
+ <GridStackRender >
74
71
<GridStackItem id = " item1" >
75
72
<div style = { { color: " yellow" }} >hello</div >
76
73
</GridStackItem >
@@ -84,6 +81,61 @@ function Simple() {
84
81
}
85
82
```
86
83
84
+ ** Drag In**
85
+
86
+ Drag items from outside into the grid.
87
+
88
+ Code here: [ src/examples/004-drag-in/index.tsx] ( src/examples/004-drag-in/index.tsx )
89
+
90
+ ``` tsx
91
+ function DragIn() {
92
+ const [uncontrolledInitialOptions] = useState <GridStackOptions >(() => ({
93
+ ... defaultGridOptions ,
94
+ children: [
95
+ { id: " 004-item1" , h: 2 , w: 2 , x: 0 , y: 0 },
96
+ { id: " 004-item2" , h: 2 , w: 2 , x: 2 , y: 0 },
97
+ ],
98
+ }));
99
+
100
+ return (
101
+ <div >
102
+ <div
103
+ style = { {
104
+ padding: " 10px" ,
105
+ display: " flex" ,
106
+ flexDirection: " row" ,
107
+ gap: " 10px" ,
108
+ border: " 1px solid gray" ,
109
+ marginBottom: " 10px" ,
110
+ }}
111
+ >
112
+ <GridStackDragInItem widget = { { h: 2 , w: 2 }} >
113
+ <div
114
+ style = { {
115
+ border: " 1px dashed green " ,
116
+ backgroundColor: " lime" ,
117
+ padding: " 0 10px" ,
118
+ }}
119
+ >
120
+ Drag me add to the grid
121
+ </div >
122
+ </GridStackDragInItem >
123
+ </div >
124
+
125
+ <GridStackContainer initialOptions = { uncontrolledInitialOptions } >
126
+ <GridStackItem id = " 004-item1" >
127
+ <div style = { { color: " yellow" }} >hello</div >
128
+ </GridStackItem >
129
+
130
+ <GridStackItem id = " 004-item2" >
131
+ <div style = { { color: " blue" }} >grid</div >
132
+ </GridStackItem >
133
+ </GridStackContainer >
134
+ </div >
135
+ );
136
+ }
137
+ ```
138
+
87
139
** Advanced**
88
140
89
141
Render item with widget map component info.
@@ -219,7 +271,7 @@ function CustomHandle() {
219
271
220
272
return (
221
273
<GridStackProvider initialOptions = { uncontrolledInitialOptions } >
222
- <GridStackRender renderRawContent >
274
+ <GridStackRender >
223
275
<GridStackItem id = " item1" >
224
276
<div >Custom Handle</div >
225
277
@@ -268,8 +320,6 @@ Render GridStack root container component.
268
320
269
321
``` typescript
270
322
type GridStackRenderProps = {
271
- renderRawContent? : boolean ;
272
-
273
323
children: React .ReactNode ;
274
324
};
275
325
```
@@ -295,6 +345,20 @@ type GridStackHandleReInitializerProps = {
295
345
};
296
346
```
297
347
348
+ #### GridStackDragInItem
349
+
350
+ Experimental component for dragging items from outside into the grid.
351
+
352
+ ``` typescript
353
+ type GridStackDragInItemProps = {
354
+ widget: Omit <GridStackWidget , " content" >; // Widget configuration without content
355
+ dragOptions? : DDDragOpt ; // Drag options
356
+ content? : ReactNode ; // Optional content to render in the dragged clone
357
+ children: React .ReactNode ;
358
+ // Plus other div props
359
+ };
360
+ ```
361
+
298
362
### Contexts
299
363
300
364
#### GridStackContext
@@ -342,7 +406,7 @@ Provide rendering related functionality context.
342
406
343
407
``` typescript
344
408
type GridStackRenderContextType = {
345
- getWidgetContainer : (widgetId : string ) => HTMLElement | null ;
409
+ getContainerByWidgetId : (widgetId : string ) => HTMLElement | null ;
346
410
};
347
411
```
348
412
@@ -383,5 +447,6 @@ export type {
383
447
GridStackItemProps ,
384
448
GridStackItemContextType ,
385
449
GridStackHandleReInitializerProps ,
450
+ GridStackDragInItemProps ,
386
451
};
387
452
```
0 commit comments