@@ -35,10 +35,7 @@ function Simple() {
3535 }));
3636
3737 return (
38- <GridStackContainer
39- initialOptions = { uncontrolledInitialOptions }
40- renderRawContent
41- >
38+ <GridStackContainer initialOptions = { uncontrolledInitialOptions } >
4239 <GridStackItem id = " item1" >
4340 <div style = { { color: " yellow" }} >hello</div >
4441 </GridStackItem >
@@ -70,7 +67,7 @@ function Simple() {
7067 { /* Custom toolbar component. Access to grid stack context by useGridStackContext hook. */ }
7168 <Toolbar />
7269
73- <GridStackRender renderRawContent >
70+ <GridStackRender >
7471 <GridStackItem id = " item1" >
7572 <div style = { { color: " yellow" }} >hello</div >
7673 </GridStackItem >
@@ -84,6 +81,61 @@ function Simple() {
8481}
8582```
8683
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+
87139** Advanced**
88140
89141Render item with widget map component info.
@@ -219,7 +271,7 @@ function CustomHandle() {
219271
220272 return (
221273 <GridStackProvider initialOptions = { uncontrolledInitialOptions } >
222- <GridStackRender renderRawContent >
274+ <GridStackRender >
223275 <GridStackItem id = " item1" >
224276 <div >Custom Handle</div >
225277
@@ -268,8 +320,6 @@ Render GridStack root container component.
268320
269321``` typescript
270322type GridStackRenderProps = {
271- renderRawContent? : boolean ;
272-
273323 children: React .ReactNode ;
274324};
275325```
@@ -295,6 +345,20 @@ type GridStackHandleReInitializerProps = {
295345};
296346```
297347
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+
298362### Contexts
299363
300364#### GridStackContext
@@ -342,7 +406,7 @@ Provide rendering related functionality context.
342406
343407``` typescript
344408type GridStackRenderContextType = {
345- getWidgetContainer : (widgetId : string ) => HTMLElement | null ;
409+ getContainerByWidgetId : (widgetId : string ) => HTMLElement | null ;
346410};
347411```
348412
@@ -383,5 +447,6 @@ export type {
383447 GridStackItemProps ,
384448 GridStackItemContextType ,
385449 GridStackHandleReInitializerProps ,
450+ GridStackDragInItemProps ,
386451};
387452```
0 commit comments