MCPcopy
hub / github.com/react-grid-layout/react-grid-layout / GridItem

Function GridItem

src/react/components/GridItem.tsx:194–881  ·  view source on GitHub ↗
(props: GridItemProps)

Source from the content-addressed store, hash-verified

192 * Wraps a child element with drag and resize functionality.
193 */
194export function GridItem(props: GridItemProps): ReactElement {
195 const {
196 children,
197 cols,
198 containerWidth,
199 margin,
200 containerPadding,
201 rowHeight,
202 maxRows,
203 isDraggable,
204 isResizable,
205 isBounded,
206 static: isStatic,
207 useCSSTransforms = true,
208 usePercentages = false,
209 transformScale = 1,
210 positionStrategy,
211 dragThreshold = 0,
212 droppingPosition,
213 className = "",
214 style,
215 handle = "",
216 cancel = "",
217 x,
218 y,
219 w,
220 h,
221 minW = 1,
222 maxW = Infinity,
223 minH = 1,
224 maxH = Infinity,
225 i,
226 resizeHandles,
227 resizeHandle,
228 constraints = defaultConstraints,
229 layoutItem,
230 layout = [],
231 onDragStart: onDragStartProp,
232 onDrag: onDragProp,
233 onDragStop: onDragStopProp,
234 onResizeStart: onResizeStartProp,
235 onResize: onResizeProp,
236 onResizeStop: onResizeStopProp
237 } = props;
238
239 // State
240 const [dragging, setDragging] = useState(false);
241 const [resizing, setResizing] = useState(false);
242
243 // Refs for position tracking (avoid state for React 18 batching)
244 const elementRef = useRef<HTMLDivElement>(null);
245 const dragPositionRef = useRef<PartialPosition>({ left: 0, top: 0 });
246 const resizePositionRef = useRef<Position>({
247 top: 0,
248 left: 0,
249 width: 0,
250 height: 0
251 });

Callers

nothing calls this directly

Calls 14

setTransformFunction · 0.85
setTopLeftFunction · 0.85
percFunction · 0.85
calcXYRawFunction · 0.85
applyPositionConstraintsFunction · 0.85
calcGridItemWHPxFunction · 0.85
calcGridColWidthFunction · 0.85
resizeItemInDirectionFunction · 0.85
calcWHRawFunction · 0.85
applySizeConstraintsFunction · 0.85
calcGridItemPositionFunction · 0.85
calcStyleMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…