🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

react-grid-layout

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-grid-layout - npm Package Compare versions

Comparing version
2.2.2
to
2.2.3
+196
dist/calculate-DH4EVtn1.d.mts
import { P as Position, R as ResizeHandleAxis } from './types-jd8MiKM1.mjs';
/**
* Grid calculation utilities.
*
* These functions convert between grid units and pixel positions.
*/
/**
* Parameters needed for position calculations.
*/
interface PositionParams {
readonly margin: readonly [number, number];
readonly containerPadding: readonly [number, number];
readonly containerWidth: number;
readonly cols: number;
readonly rowHeight: number;
readonly maxRows: number;
}
/**
* Calculate the width of a single grid column in pixels.
*
* @param positionParams - Grid parameters
* @returns Column width in pixels
*/
declare function calcGridColWidth(positionParams: PositionParams): number;
/**
* Calculate the pixel size for a grid unit dimension (width or height).
*
* Can be called as:
* - calcGridItemWHPx(w, colWidth, margin[0]) for width
* - calcGridItemWHPx(h, rowHeight, margin[1]) for height
*
* @param gridUnits - Size in grid units
* @param colOrRowSize - Column width or row height in pixels
* @param marginPx - Margin between items in pixels
* @returns Size in pixels
*/
declare function calcGridItemWHPx(gridUnits: number, colOrRowSize: number, marginPx: number): number;
/**
* Calculate pixel position for a grid item.
*
* Returns left, top, width, height in pixels.
*
* @param positionParams - Grid parameters
* @param x - X coordinate in grid units
* @param y - Y coordinate in grid units
* @param w - Width in grid units
* @param h - Height in grid units
* @param dragPosition - If present, use exact left/top from drag callbacks
* @param resizePosition - If present, use exact dimensions from resize callbacks
* @returns Position in pixels
*/
declare function calcGridItemPosition(positionParams: PositionParams, x: number, y: number, w: number, h: number, dragPosition?: {
top: number;
left: number;
} | null, resizePosition?: {
top: number;
left: number;
height: number;
width: number;
} | null): Position;
/**
* Translate pixel coordinates to grid units.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @param w - Width in grid units (for clamping)
* @param h - Height in grid units (for clamping)
* @returns x and y in grid units
*/
declare function calcXY(positionParams: PositionParams, top: number, left: number, w: number, h: number): {
x: number;
y: number;
};
/**
* Translate pixel coordinates to grid units without clamping.
*
* Use this with the constraint system for custom boundary control.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @returns x and y in grid units (unclamped)
*/
declare function calcXYRaw(positionParams: PositionParams, top: number, left: number): {
x: number;
y: number;
};
/**
* Calculate grid units from pixel dimensions.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @param x - X coordinate in grid units (for clamping)
* @param y - Y coordinate in grid units (for clamping)
* @param handle - Resize handle being used
* @returns w, h in grid units
*/
declare function calcWH(positionParams: PositionParams, width: number, height: number, x: number, y: number, handle: ResizeHandleAxis): {
w: number;
h: number;
};
/**
* Calculate grid units from pixel dimensions without clamping.
*
* Use this with the constraint system for custom size control.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @returns w, h in grid units (unclamped, minimum 1)
*/
declare function calcWHRaw(positionParams: PositionParams, width: number, height: number): {
w: number;
h: number;
};
/**
* Clamp a number between bounds.
*
* @param num - Number to clamp
* @param lowerBound - Minimum value
* @param upperBound - Maximum value
* @returns Clamped value
*/
declare function clamp(num: number, lowerBound: number, upperBound: number): number;
/**
* Grid cell dimension information for rendering backgrounds or overlays.
*/
interface GridCellDimensions {
/** Width of a single cell in pixels */
readonly cellWidth: number;
/** Height of a single cell in pixels */
readonly cellHeight: number;
/** Horizontal offset from container edge to first cell */
readonly offsetX: number;
/** Vertical offset from container edge to first cell */
readonly offsetY: number;
/** Horizontal gap between cells */
readonly gapX: number;
/** Vertical gap between cells */
readonly gapY: number;
/** Number of columns */
readonly cols: number;
/** Total container width */
readonly containerWidth: number;
}
/**
* Configuration for grid cell dimension calculation.
*/
interface GridCellConfig {
/** Container width in pixels */
width: number;
/** Number of columns */
cols: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] */
margin?: readonly [number, number];
/** Container padding [x, y], defaults to margin if not specified */
containerPadding?: readonly [number, number] | null;
}
/**
* Calculate grid cell dimensions for rendering backgrounds or overlays.
*
* This function provides all the measurements needed to render a visual
* grid background that aligns with the actual grid cells.
*
* @param config - Grid configuration
* @returns Cell dimensions and offsets
*
* @example
* ```tsx
* import { calcGridCellDimensions } from 'react-grid-layout/core';
*
* const dims = calcGridCellDimensions({
* width: 1200,
* cols: 12,
* rowHeight: 30,
* margin: [10, 10],
* containerPadding: [10, 10]
* });
*
* // dims.cellWidth = 88.33...
* // dims.cellHeight = 30
* // dims.offsetX = 10 (containerPadding[0])
* // dims.offsetY = 10 (containerPadding[1])
* // dims.gapX = 10 (margin[0])
* // dims.gapY = 10 (margin[1])
* ```
*/
declare function calcGridCellDimensions(config: GridCellConfig): GridCellDimensions;
export { type GridCellConfig as G, type PositionParams as P, calcWH as a, calcXY as b, calcGridItemPosition as c, type GridCellDimensions as d, calcGridCellDimensions as e, calcGridColWidth as f, calcGridItemWHPx as g, calcWHRaw as h, calcXYRaw as i, clamp as j };
import { P as Position, R as ResizeHandleAxis } from './types-jd8MiKM1.js';
/**
* Grid calculation utilities.
*
* These functions convert between grid units and pixel positions.
*/
/**
* Parameters needed for position calculations.
*/
interface PositionParams {
readonly margin: readonly [number, number];
readonly containerPadding: readonly [number, number];
readonly containerWidth: number;
readonly cols: number;
readonly rowHeight: number;
readonly maxRows: number;
}
/**
* Calculate the width of a single grid column in pixels.
*
* @param positionParams - Grid parameters
* @returns Column width in pixels
*/
declare function calcGridColWidth(positionParams: PositionParams): number;
/**
* Calculate the pixel size for a grid unit dimension (width or height).
*
* Can be called as:
* - calcGridItemWHPx(w, colWidth, margin[0]) for width
* - calcGridItemWHPx(h, rowHeight, margin[1]) for height
*
* @param gridUnits - Size in grid units
* @param colOrRowSize - Column width or row height in pixels
* @param marginPx - Margin between items in pixels
* @returns Size in pixels
*/
declare function calcGridItemWHPx(gridUnits: number, colOrRowSize: number, marginPx: number): number;
/**
* Calculate pixel position for a grid item.
*
* Returns left, top, width, height in pixels.
*
* @param positionParams - Grid parameters
* @param x - X coordinate in grid units
* @param y - Y coordinate in grid units
* @param w - Width in grid units
* @param h - Height in grid units
* @param dragPosition - If present, use exact left/top from drag callbacks
* @param resizePosition - If present, use exact dimensions from resize callbacks
* @returns Position in pixels
*/
declare function calcGridItemPosition(positionParams: PositionParams, x: number, y: number, w: number, h: number, dragPosition?: {
top: number;
left: number;
} | null, resizePosition?: {
top: number;
left: number;
height: number;
width: number;
} | null): Position;
/**
* Translate pixel coordinates to grid units.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @param w - Width in grid units (for clamping)
* @param h - Height in grid units (for clamping)
* @returns x and y in grid units
*/
declare function calcXY(positionParams: PositionParams, top: number, left: number, w: number, h: number): {
x: number;
y: number;
};
/**
* Translate pixel coordinates to grid units without clamping.
*
* Use this with the constraint system for custom boundary control.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @returns x and y in grid units (unclamped)
*/
declare function calcXYRaw(positionParams: PositionParams, top: number, left: number): {
x: number;
y: number;
};
/**
* Calculate grid units from pixel dimensions.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @param x - X coordinate in grid units (for clamping)
* @param y - Y coordinate in grid units (for clamping)
* @param handle - Resize handle being used
* @returns w, h in grid units
*/
declare function calcWH(positionParams: PositionParams, width: number, height: number, x: number, y: number, handle: ResizeHandleAxis): {
w: number;
h: number;
};
/**
* Calculate grid units from pixel dimensions without clamping.
*
* Use this with the constraint system for custom size control.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @returns w, h in grid units (unclamped, minimum 1)
*/
declare function calcWHRaw(positionParams: PositionParams, width: number, height: number): {
w: number;
h: number;
};
/**
* Clamp a number between bounds.
*
* @param num - Number to clamp
* @param lowerBound - Minimum value
* @param upperBound - Maximum value
* @returns Clamped value
*/
declare function clamp(num: number, lowerBound: number, upperBound: number): number;
/**
* Grid cell dimension information for rendering backgrounds or overlays.
*/
interface GridCellDimensions {
/** Width of a single cell in pixels */
readonly cellWidth: number;
/** Height of a single cell in pixels */
readonly cellHeight: number;
/** Horizontal offset from container edge to first cell */
readonly offsetX: number;
/** Vertical offset from container edge to first cell */
readonly offsetY: number;
/** Horizontal gap between cells */
readonly gapX: number;
/** Vertical gap between cells */
readonly gapY: number;
/** Number of columns */
readonly cols: number;
/** Total container width */
readonly containerWidth: number;
}
/**
* Configuration for grid cell dimension calculation.
*/
interface GridCellConfig {
/** Container width in pixels */
width: number;
/** Number of columns */
cols: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] */
margin?: readonly [number, number];
/** Container padding [x, y], defaults to margin if not specified */
containerPadding?: readonly [number, number] | null;
}
/**
* Calculate grid cell dimensions for rendering backgrounds or overlays.
*
* This function provides all the measurements needed to render a visual
* grid background that aligns with the actual grid cells.
*
* @param config - Grid configuration
* @returns Cell dimensions and offsets
*
* @example
* ```tsx
* import { calcGridCellDimensions } from 'react-grid-layout/core';
*
* const dims = calcGridCellDimensions({
* width: 1200,
* cols: 12,
* rowHeight: 30,
* margin: [10, 10],
* containerPadding: [10, 10]
* });
*
* // dims.cellWidth = 88.33...
* // dims.cellHeight = 30
* // dims.offsetX = 10 (containerPadding[0])
* // dims.offsetY = 10 (containerPadding[1])
* // dims.gapX = 10 (margin[0])
* // dims.gapY = 10 (margin[1])
* ```
*/
declare function calcGridCellDimensions(config: GridCellConfig): GridCellDimensions;
export { type GridCellConfig as G, type PositionParams as P, calcWH as a, calcXY as b, calcGridItemPosition as c, type GridCellDimensions as d, calcGridCellDimensions as e, calcGridColWidth as f, calcGridItemWHPx as g, calcWHRaw as h, calcXYRaw as i, clamp as j };
'use strict';
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');
// src/core/constraints.ts
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
var gridBounds = {
name: "gridBounds",
constrainPosition(item, x, y, { cols, maxRows }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
},
constrainSize(item, w, h, handle, { cols, maxRows }) {
const maxW = handle === "w" || handle === "nw" || handle === "sw" ? item.x + item.w : cols - item.x;
const maxH = handle === "n" || handle === "nw" || handle === "ne" ? item.y + item.h : maxRows - item.y;
return {
w: clamp(w, 1, Math.max(1, maxW)),
h: clamp(h, 1, Math.max(1, maxH))
};
}
};
var minMaxSize = {
name: "minMaxSize",
constrainSize(item, w, h) {
return {
w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),
h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)
};
}
};
var containerBounds = {
name: "containerBounds",
constrainPosition(item, x, y, { cols, maxRows, containerHeight, rowHeight, margin }) {
const visibleRows = containerHeight > 0 ? Math.floor((containerHeight + margin[1]) / (rowHeight + margin[1])) : maxRows;
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, visibleRows - item.h))
};
}
};
var boundedX = {
name: "boundedX",
constrainPosition(item, x, y, { cols }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y
};
}
};
var boundedY = {
name: "boundedY",
constrainPosition(item, x, y, { maxRows }) {
return {
x,
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
}
};
function aspectRatio(ratio) {
return {
name: `aspectRatio(${ratio})`,
constrainSize(_item, w, _h, _handle, context) {
const { cols, containerWidth, rowHeight, margin } = context;
const colWidth = (containerWidth - margin[0] * (cols - 1)) / cols;
const pixelWidth = colWidth * w + margin[0] * Math.max(0, w - 1);
const pixelHeight = pixelWidth / ratio;
const h = Math.max(
1,
Math.round((pixelHeight + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
};
}
function snapToGrid(stepX, stepY = stepX) {
if (stepX <= 0 || stepY <= 0) {
throw new Error(
`snapToGrid: step values must be positive (got stepX=${stepX}, stepY=${stepY})`
);
}
return {
name: `snapToGrid(${stepX}, ${stepY})`,
constrainPosition(_item, x, y) {
return {
x: Math.round(x / stepX) * stepX,
y: Math.round(y / stepY) * stepY
};
}
};
}
function minSize(minW, minH) {
return {
name: `minSize(${minW}, ${minH})`,
constrainSize(_item, w, h) {
return {
w: Math.max(minW, w),
h: Math.max(minH, h)
};
}
};
}
function maxSize(maxW, maxH) {
return {
name: `maxSize(${maxW}, ${maxH})`,
constrainSize(_item, w, h) {
return {
w: Math.min(maxW, w),
h: Math.min(maxH, h)
};
}
};
}
var defaultConstraints = [gridBounds, minMaxSize];
function applyPositionConstraints(constraints, item, x, y, context) {
let result = { x, y };
for (const constraint of constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(item, result.x, result.y, context);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(
item,
result.x,
result.y,
context
);
}
}
}
return result;
}
function applySizeConstraints(constraints, item, w, h, handle, context) {
let result = { w, h };
for (const constraint of constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
}
return result;
}
// src/core/position.ts
function setTransform({
top,
left,
width,
height
}) {
const translate = `translate(${left}px,${top}px)`;
return {
transform: translate,
WebkitTransform: translate,
MozTransform: translate,
msTransform: translate,
OTransform: translate,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function setTopLeft({
top,
left,
width,
height
}) {
return {
top: `${top}px`,
left: `${left}px`,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function perc(num) {
return num * 100 + "%";
}
function constrainWidth(left, currentWidth, newWidth, containerWidth) {
return left + newWidth > containerWidth ? currentWidth : newWidth;
}
function constrainHeight(top, currentHeight, newHeight) {
return top < 0 ? currentHeight : newHeight;
}
function constrainLeft(left) {
return Math.max(0, left);
}
function constrainTop(top) {
return Math.max(0, top);
}
var resizeNorth = (currentSize, newSize, _containerWidth) => {
const { left, height, width } = newSize;
const top = currentSize.top - (height - currentSize.height);
return {
left,
width,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeEast = (currentSize, newSize, containerWidth) => {
const { top, left, height, width } = newSize;
return {
top,
height,
width: constrainWidth(
currentSize.left,
currentSize.width,
width,
containerWidth
),
left: constrainLeft(left)
};
};
var resizeWest = (currentSize, newSize, _containerWidth) => {
const { top, height, width } = newSize;
const left = currentSize.left + currentSize.width - width;
if (left < 0) {
return {
height,
width: currentSize.left + currentSize.width,
top: constrainTop(top),
left: 0
};
}
return {
height,
width,
top: constrainTop(top),
left
};
};
var resizeSouth = (currentSize, newSize, _containerWidth) => {
const { top, left, height, width } = newSize;
return {
width,
left,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeNorthEast = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeNorthWest = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeWest(currentSize, newSize));
var resizeSouthEast = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeSouthWest = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeWest(currentSize, newSize));
var resizeHandlerMap = {
n: resizeNorth,
ne: resizeNorthEast,
e: resizeEast,
se: resizeSouthEast,
s: resizeSouth,
sw: resizeSouthWest,
w: resizeWest,
nw: resizeNorthWest
};
function resizeItemInDirection(direction, currentSize, newSize, containerWidth) {
const handler = resizeHandlerMap[direction];
if (!handler) {
return newSize;
}
return handler(currentSize, { ...currentSize, ...newSize }, containerWidth);
}
var transformStrategy = {
type: "transform",
scale: 1,
calcStyle(pos) {
return setTransform(pos);
}
};
var absoluteStrategy = {
type: "absolute",
scale: 1,
calcStyle(pos) {
return setTopLeft(pos);
}
};
function createScaledStrategy(scale) {
return {
type: "transform",
scale,
calcStyle(pos) {
return setTransform(pos);
},
calcDragPosition(clientX, clientY, offsetX, offsetY) {
return {
left: (clientX - offsetX) / scale,
top: (clientY - offsetY) / scale
};
}
};
}
var defaultPositionStrategy = transformStrategy;
// src/core/types.ts
var defaultGridConfig = {
cols: 12,
rowHeight: 150,
margin: [10, 10],
containerPadding: null,
maxRows: Infinity
};
var defaultDragConfig = {
enabled: true,
bounded: false,
threshold: 3
};
var defaultResizeConfig = {
enabled: true,
handles: ["se"]
};
var defaultDropConfig = {
enabled: false,
defaultItem: { w: 1, h: 1 }
};
// src/core/compactors.ts
function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
const sizeProp = axis === "x" ? "w" : "h";
item[axis] += 1;
const itemIndex = layout.findIndex((l) => l.i === item.i);
const layoutHasStatics = hasStatics ?? chunkA5WIFECI_js.getStatics(layout).length > 0;
for (let i = itemIndex + 1; i < layout.length; i++) {
const otherItem = layout[i];
if (otherItem === void 0) continue;
if (otherItem.static) continue;
if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
if (chunkA5WIFECI_js.collides(item, otherItem)) {
resolveCompactionCollision(
layout,
otherItem,
moveToCoord + item[sizeProp],
axis,
layoutHasStatics
);
}
}
item[axis] = moveToCoord;
}
function compactItemVertical(compareWith, l, fullLayout, maxY) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
l.y = Math.min(maxY, l.y);
while (l.y > 0 && !chunkA5WIFECI_js.getFirstCollision(compareWith, l)) {
l.y--;
}
let collision;
while ((collision = chunkA5WIFECI_js.getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y");
}
l.y = Math.max(l.y, 0);
return l;
}
function compactItemHorizontal(compareWith, l, cols, fullLayout) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
while (l.x > 0 && !chunkA5WIFECI_js.getFirstCollision(compareWith, l)) {
l.x--;
}
let collision;
while ((collision = chunkA5WIFECI_js.getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
if (l.x + l.w > cols) {
l.x = cols - l.w;
l.y++;
while (l.x > 0 && !chunkA5WIFECI_js.getFirstCollision(compareWith, l)) {
l.x--;
}
}
}
l.x = Math.max(l.x, 0);
return l;
}
var verticalCompactor = {
type: "vertical",
allowOverlap: false,
compact(layout, _cols) {
const compareWith = chunkA5WIFECI_js.getStatics(layout);
let maxY = chunkA5WIFECI_js.bottom(compareWith);
const sorted = chunkA5WIFECI_js.sortLayoutItemsByRowCol(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = chunkA5WIFECI_js.cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemVertical(compareWith, l, sorted, maxY);
maxY = Math.max(maxY, l.y + l.h);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var horizontalCompactor = {
type: "horizontal",
allowOverlap: false,
compact(layout, cols) {
const compareWith = chunkA5WIFECI_js.getStatics(layout);
const sorted = chunkA5WIFECI_js.sortLayoutItemsByColRow(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = chunkA5WIFECI_js.cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemHorizontal(compareWith, l, cols, sorted);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var noCompactor = {
type: null,
allowOverlap: false,
compact(layout, _cols) {
return chunkA5WIFECI_js.cloneLayout(layout);
}
};
var verticalOverlapCompactor = {
...verticalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return chunkA5WIFECI_js.cloneLayout(layout);
}
};
var horizontalOverlapCompactor = {
...horizontalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return chunkA5WIFECI_js.cloneLayout(layout);
}
};
var noOverlapCompactor = {
...noCompactor,
allowOverlap: true
};
function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
let baseCompactor;
if (allowOverlap) {
if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
else if (compactType === "horizontal")
baseCompactor = horizontalOverlapCompactor;
else baseCompactor = noOverlapCompactor;
} else {
if (compactType === "vertical") baseCompactor = verticalCompactor;
else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
else baseCompactor = noCompactor;
}
if (preventCollision) {
return { ...baseCompactor, preventCollision };
}
return baseCompactor;
}
// src/core/responsive.ts
function sortBreakpoints(breakpoints) {
const keys = Object.keys(breakpoints);
return keys.sort((a, b) => breakpoints[a] - breakpoints[b]);
}
function getBreakpointFromWidth(breakpoints, width) {
const sorted = sortBreakpoints(breakpoints);
let matching = sorted[0];
if (matching === void 0) {
throw new Error("No breakpoints defined");
}
for (let i = 1; i < sorted.length; i++) {
const breakpointName = sorted[i];
if (breakpointName === void 0) continue;
const breakpointWidth = breakpoints[breakpointName];
if (width > breakpointWidth) {
matching = breakpointName;
}
}
return matching;
}
function getColsFromBreakpoint(breakpoint, cols) {
const colCount = cols[breakpoint];
if (colCount === void 0) {
throw new Error(
`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(breakpoint)} is missing!`
);
}
return colCount;
}
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactTypeOrCompactor) {
const existingLayout = layouts[breakpoint];
if (existingLayout) {
return chunkA5WIFECI_js.cloneLayout(existingLayout);
}
let layout = layouts[lastBreakpoint];
const breakpointsSorted = sortBreakpoints(breakpoints);
const breakpointsAbove = breakpointsSorted.slice(
breakpointsSorted.indexOf(breakpoint)
);
for (let i = 0; i < breakpointsAbove.length; i++) {
const b = breakpointsAbove[i];
if (b === void 0) continue;
const layoutForBreakpoint = layouts[b];
if (layoutForBreakpoint) {
layout = layoutForBreakpoint;
break;
}
}
const clonedLayout = chunkA5WIFECI_js.cloneLayout(layout || []);
const corrected = chunkA5WIFECI_js.correctBounds(clonedLayout, { cols });
const compactor = typeof compactTypeOrCompactor === "object" && compactTypeOrCompactor !== null ? compactTypeOrCompactor : getCompactor(compactTypeOrCompactor);
return compactor.compact(corrected, cols);
}
function getIndentationValue(value, breakpoint) {
if (Array.isArray(value)) {
return value;
}
const breakpointMap = value;
const breakpointValue = breakpointMap[breakpoint];
if (breakpointValue !== void 0) {
return breakpointValue;
}
const keys = Object.keys(breakpointMap);
for (const key of keys) {
const v = breakpointMap[key];
if (v !== void 0) {
return v;
}
}
return [10, 10];
}
exports.absoluteStrategy = absoluteStrategy;
exports.applyPositionConstraints = applyPositionConstraints;
exports.applySizeConstraints = applySizeConstraints;
exports.aspectRatio = aspectRatio;
exports.boundedX = boundedX;
exports.boundedY = boundedY;
exports.compactItemHorizontal = compactItemHorizontal;
exports.compactItemVertical = compactItemVertical;
exports.containerBounds = containerBounds;
exports.createScaledStrategy = createScaledStrategy;
exports.defaultConstraints = defaultConstraints;
exports.defaultDragConfig = defaultDragConfig;
exports.defaultDropConfig = defaultDropConfig;
exports.defaultGridConfig = defaultGridConfig;
exports.defaultPositionStrategy = defaultPositionStrategy;
exports.defaultResizeConfig = defaultResizeConfig;
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
exports.getBreakpointFromWidth = getBreakpointFromWidth;
exports.getColsFromBreakpoint = getColsFromBreakpoint;
exports.getCompactor = getCompactor;
exports.getIndentationValue = getIndentationValue;
exports.gridBounds = gridBounds;
exports.horizontalCompactor = horizontalCompactor;
exports.horizontalOverlapCompactor = horizontalOverlapCompactor;
exports.maxSize = maxSize;
exports.minMaxSize = minMaxSize;
exports.minSize = minSize;
exports.noCompactor = noCompactor;
exports.noOverlapCompactor = noOverlapCompactor;
exports.perc = perc;
exports.resizeItemInDirection = resizeItemInDirection;
exports.resolveCompactionCollision = resolveCompactionCollision;
exports.setTopLeft = setTopLeft;
exports.setTransform = setTransform;
exports.snapToGrid = snapToGrid;
exports.sortBreakpoints = sortBreakpoints;
exports.transformStrategy = transformStrategy;
exports.verticalCompactor = verticalCompactor;
exports.verticalOverlapCompactor = verticalOverlapCompactor;
// src/core/calculate.ts
function calcGridColWidth(positionParams) {
const { margin, containerPadding, containerWidth, cols } = positionParams;
return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
}
function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
if (!Number.isFinite(gridUnits)) return gridUnits;
return Math.round(
colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx
);
}
function calcGridItemPosition(positionParams, x, y, w, h, dragPosition, resizePosition) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let width;
let height;
let top;
let left;
if (resizePosition) {
width = Math.round(resizePosition.width);
height = Math.round(resizePosition.height);
} else {
width = calcGridItemWHPx(w, colWidth, margin[0]);
height = calcGridItemWHPx(h, rowHeight, margin[1]);
}
if (dragPosition) {
top = Math.round(dragPosition.top);
left = Math.round(dragPosition.left);
} else if (resizePosition) {
top = Math.round(resizePosition.top);
left = Math.round(resizePosition.left);
} else {
top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
}
if (!dragPosition && !resizePosition) {
if (Number.isFinite(w)) {
const siblingLeft = Math.round(
(colWidth + margin[0]) * (x + w) + containerPadding[0]
);
const actualMarginRight = siblingLeft - left - width;
if (actualMarginRight !== margin[0]) {
width += actualMarginRight - margin[0];
}
}
if (Number.isFinite(h)) {
const siblingTop = Math.round(
(rowHeight + margin[1]) * (y + h) + containerPadding[1]
);
const actualMarginBottom = siblingTop - top - height;
if (actualMarginBottom !== margin[1]) {
height += actualMarginBottom - margin[1];
}
}
}
return { top, left, width, height };
}
function calcXY(positionParams, top, left, w, h) {
const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
x = clamp(x, 0, cols - w);
y = clamp(y, 0, maxRows - h);
return { x, y };
}
function calcXYRaw(positionParams, top, left) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
return { x, y };
}
function calcWH(positionParams, width, height, x, y, handle) {
const { margin, maxRows, cols, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.round((width + margin[0]) / (colWidth + margin[0]));
const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));
let _w = clamp(w, 0, cols - x);
let _h = clamp(h, 0, maxRows - y);
if (handle === "sw" || handle === "w" || handle === "nw") {
_w = clamp(w, 0, cols);
}
if (handle === "nw" || handle === "n" || handle === "ne") {
_h = clamp(h, 0, maxRows);
}
return { w: _w, h: _h };
}
function calcWHRaw(positionParams, width, height) {
const { margin, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.max(
1,
Math.round((width + margin[0]) / (colWidth + margin[0]))
);
const h = Math.max(
1,
Math.round((height + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
function clamp(num, lowerBound, upperBound) {
return Math.max(Math.min(num, upperBound), lowerBound);
}
function calcGridCellDimensions(config) {
const {
width,
cols,
rowHeight,
margin = [10, 10],
containerPadding
} = config;
const padding = containerPadding ?? margin;
const cellWidth = (width - padding[0] * 2 - margin[0] * (cols - 1)) / cols;
const cellHeight = rowHeight;
return {
cellWidth,
cellHeight,
offsetX: padding[0],
offsetY: padding[1],
gapX: margin[0],
gapY: margin[1],
cols,
containerWidth: width
};
}
// src/core/collision.ts
function collides(l1, l2) {
if (l1.i === l2.i) return false;
if (l1.x + l1.w <= l2.x) return false;
if (l1.x >= l2.x + l2.w) return false;
if (l1.y + l1.h <= l2.y) return false;
if (l1.y >= l2.y + l2.h) return false;
return true;
}
function getFirstCollision(layout, layoutItem) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && collides(item, layoutItem)) {
return item;
}
}
return void 0;
}
function getAllCollisions(layout, layoutItem) {
return layout.filter((l) => collides(l, layoutItem));
}
// src/core/sort.ts
function sortLayoutItems(layout, compactType) {
if (compactType === "horizontal") {
return sortLayoutItemsByColRow(layout);
}
if (compactType === "vertical") {
return sortLayoutItemsByRowCol(layout);
}
if (compactType === "wrap") {
return sortLayoutItemsByRowCol(layout);
}
return [...layout];
}
function sortLayoutItemsByRowCol(layout) {
return [...layout].sort((a, b) => {
if (a.y !== b.y) {
return a.y - b.y;
}
return a.x - b.x;
});
}
function sortLayoutItemsByColRow(layout) {
return [...layout].sort((a, b) => {
if (a.x !== b.x) {
return a.x - b.x;
}
return a.y - b.y;
});
}
// src/core/layout.ts
function bottom(layout) {
let max = 0;
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
const bottomY = item.y + item.h;
if (bottomY > max) max = bottomY;
}
}
return max;
}
function getLayoutItem(layout, id) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && item.i === id) {
return item;
}
}
return void 0;
}
function getStatics(layout) {
return layout.filter((l) => l.static === true);
}
function cloneLayoutItem(layoutItem) {
return {
i: layoutItem.i,
x: layoutItem.x,
y: layoutItem.y,
w: layoutItem.w,
h: layoutItem.h,
minW: layoutItem.minW,
maxW: layoutItem.maxW,
minH: layoutItem.minH,
maxH: layoutItem.maxH,
moved: Boolean(layoutItem.moved),
static: Boolean(layoutItem.static),
isDraggable: layoutItem.isDraggable,
isResizable: layoutItem.isResizable,
resizeHandles: layoutItem.resizeHandles,
constraints: layoutItem.constraints,
isBounded: layoutItem.isBounded
};
}
function cloneLayout(layout) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
newLayout[i] = cloneLayoutItem(item);
}
}
return newLayout;
}
function modifyLayout(layout, layoutItem) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
if (layoutItem.i === item.i) {
newLayout[i] = layoutItem;
} else {
newLayout[i] = item;
}
}
}
return newLayout;
}
function withLayoutItem(layout, itemKey, cb) {
let item = getLayoutItem(layout, itemKey);
if (!item) {
return [[...layout], null];
}
item = cb(cloneLayoutItem(item));
const newLayout = modifyLayout(layout, item);
return [newLayout, item];
}
function correctBounds(layout, bounds) {
const collidesWith = getStatics(layout);
for (let i = 0; i < layout.length; i++) {
const l = layout[i];
if (l === void 0) continue;
if (l.x + l.w > bounds.cols) {
l.x = bounds.cols - l.w;
}
if (l.x < 0) {
l.x = 0;
l.w = bounds.cols;
}
if (!l.static) {
collidesWith.push(l);
} else {
while (getFirstCollision(collidesWith, l)) {
l.y++;
}
}
}
return layout;
}
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, allowOverlap) {
if (l.static && l.isDraggable !== true) {
return [...layout];
}
if (l.y === y && l.x === x) {
return [...layout];
}
const oldX = l.x;
const oldY = l.y;
if (typeof x === "number") l.x = x;
if (typeof y === "number") l.y = y;
l.moved = true;
let sorted = sortLayoutItems(layout, compactType);
const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
if (movingUp) {
sorted = sorted.reverse();
}
const collisions = getAllCollisions(sorted, l);
const hasCollisions = collisions.length > 0;
if (hasCollisions && allowOverlap) {
return cloneLayout(layout);
}
if (hasCollisions && preventCollision) {
l.x = oldX;
l.y = oldY;
l.moved = false;
return layout;
}
let resultLayout = [...layout];
for (let i = 0; i < collisions.length; i++) {
const collision = collisions[i];
if (collision === void 0) continue;
if (collision.moved) continue;
if (collision.static) {
resultLayout = moveElementAwayFromCollision(
resultLayout,
collision,
l,
isUserAction,
compactType);
} else {
resultLayout = moveElementAwayFromCollision(
resultLayout,
l,
collision,
isUserAction,
compactType);
}
}
return resultLayout;
}
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols) {
const compactH = compactType === "horizontal";
const compactV = compactType === "vertical";
const preventCollision = collidesWith.static;
if (isUserAction) {
isUserAction = false;
const fakeItem = {
x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
w: itemToMove.w,
h: itemToMove.h,
i: "-1"
};
const firstCollision = getFirstCollision(layout, fakeItem);
const collisionNorth = firstCollision !== void 0 && firstCollision.y + firstCollision.h > collidesWith.y;
const collisionWest = firstCollision !== void 0 && collidesWith.x + collidesWith.w > firstCollision.x;
if (!firstCollision) {
return moveElement(
layout,
itemToMove,
compactH ? fakeItem.x : void 0,
compactV ? fakeItem.y : void 0,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactV) {
return moveElement(
layout,
itemToMove,
void 0,
itemToMove.y + 1,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactType === null) {
collidesWith.y = itemToMove.y;
itemToMove.y = itemToMove.y + itemToMove.h;
return [...layout];
}
if (collisionWest && compactH) {
return moveElement(
layout,
collidesWith,
itemToMove.x,
void 0,
isUserAction,
preventCollision,
compactType);
}
}
const newX = compactH ? itemToMove.x + 1 : void 0;
const newY = compactV ? itemToMove.y + 1 : void 0;
if (newX === void 0 && newY === void 0) {
return [...layout];
}
return moveElement(
layout,
itemToMove,
newX,
newY,
isUserAction,
preventCollision,
compactType);
}
function validateLayout(layout, contextName = "Layout") {
const requiredProps = ["x", "y", "w", "h"];
if (!Array.isArray(layout)) {
throw new Error(`${contextName} must be an array!`);
}
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item === void 0) continue;
for (const key of requiredProps) {
const value = item[key];
if (typeof value !== "number" || Number.isNaN(value)) {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${String(value)} (${typeof value})`
);
}
}
if (item.i !== void 0 && typeof item.i !== "string") {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${String(item.i)} (${typeof item.i})`
);
}
}
}
export { bottom, calcGridCellDimensions, calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcWHRaw, calcXY, calcXYRaw, clamp, cloneLayout, cloneLayoutItem, collides, correctBounds, getAllCollisions, getFirstCollision, getLayoutItem, getStatics, modifyLayout, moveElement, moveElementAwayFromCollision, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout, withLayoutItem };
'use strict';
var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');
var react = require('react');
var fastEquals = require('fast-equals');
function useContainerWidth(options = {}) {
const { measureBeforeMount = false, initialWidth = 1280 } = options;
const [width, setWidth] = react.useState(initialWidth);
const [mounted, setMounted] = react.useState(!measureBeforeMount);
const containerRef = react.useRef(null);
const observerRef = react.useRef(null);
const measureWidth = react.useCallback(() => {
const node = containerRef.current;
if (node) {
const newWidth = node.offsetWidth;
setWidth(newWidth);
if (!mounted) {
setMounted(true);
}
}
}, [mounted]);
react.useEffect(() => {
const node = containerRef.current;
if (!node) return;
measureWidth();
if (typeof ResizeObserver !== "undefined") {
let rafId = null;
observerRef.current = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry) {
const newWidth = entry.contentRect.width;
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
rafId = requestAnimationFrame(() => {
setWidth(newWidth);
rafId = null;
});
}
});
observerRef.current.observe(node);
return () => {
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
};
}
return () => {
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
};
}, [measureWidth]);
return {
width,
mounted,
containerRef,
measureWidth
};
}
function useGridLayout(options) {
const {
layout: propsLayout,
cols,
preventCollision = false,
onLayoutChange,
compactor = chunk55DQUWLA_js.verticalCompactor
} = options;
const isDraggingRef = react.useRef(false);
const [layout, setLayoutState] = react.useState(() => {
const corrected = chunkA5WIFECI_js.correctBounds(chunkA5WIFECI_js.cloneLayout(propsLayout), { cols });
return compactor.compact(corrected, cols);
});
const [dragState, setDragState] = react.useState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
const [resizeState, setResizeState] = react.useState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
const [dropState, setDropState] = react.useState({
droppingDOMNode: null,
droppingPosition: null
});
const prevLayoutRef = react.useRef(layout);
const setLayout = react.useCallback(
(newLayout) => {
const corrected = chunkA5WIFECI_js.correctBounds(chunkA5WIFECI_js.cloneLayout(newLayout), { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[cols, compactor]
);
react.useEffect(() => {
if (isDraggingRef.current) return;
if (!fastEquals.deepEqual(propsLayout, prevLayoutRef.current)) {
setLayout(propsLayout);
}
}, [propsLayout, setLayout]);
react.useEffect(() => {
if (!fastEquals.deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
onLayoutChange?.(layout);
}
}, [layout, onLayoutChange]);
const onDragStart = react.useCallback(
(itemId, x, y) => {
const item = chunkA5WIFECI_js.getLayoutItem(layout, itemId);
if (!item) return null;
isDraggingRef.current = true;
const placeholder = {
...chunkA5WIFECI_js.cloneLayoutItem(item),
x,
y,
static: false,
moved: false
};
setDragState({
activeDrag: placeholder,
oldDragItem: chunkA5WIFECI_js.cloneLayoutItem(item),
oldLayout: chunkA5WIFECI_js.cloneLayout(layout)
});
return placeholder;
},
[layout]
);
const onDrag = react.useCallback(
(itemId, x, y) => {
const item = chunkA5WIFECI_js.getLayoutItem(layout, itemId);
if (!item) return;
setDragState((prev) => ({
...prev,
activeDrag: prev.activeDrag ? { ...prev.activeDrag, x, y } : null
}));
const newLayout = chunkA5WIFECI_js.moveElement(
layout,
item,
x,
y,
true,
// isUserAction
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onDragStop = react.useCallback(
(itemId, x, y) => {
const item = chunkA5WIFECI_js.getLayoutItem(layout, itemId);
if (!item) return;
const newLayout = chunkA5WIFECI_js.moveElement(
layout,
item,
x,
y,
true,
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
isDraggingRef.current = false;
setDragState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onResizeStart = react.useCallback(
(itemId) => {
const item = chunkA5WIFECI_js.getLayoutItem(layout, itemId);
if (!item) return null;
setResizeState({
resizing: true,
oldResizeItem: chunkA5WIFECI_js.cloneLayoutItem(item),
oldLayout: chunkA5WIFECI_js.cloneLayout(layout)
});
return item;
},
[layout]
);
const onResize = react.useCallback(
(itemId, w, h, x, y) => {
const newLayout = layout.map((item) => {
if (item.i === itemId) {
const updated = {
...item,
w,
h
};
if (x !== void 0) updated.x = x;
if (y !== void 0) updated.y = y;
return updated;
}
return item;
});
const corrected = chunkA5WIFECI_js.correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[layout, cols, compactor]
);
const onResizeStop = react.useCallback(
(itemId, w, h) => {
onResize(itemId, w, h);
setResizeState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
},
[onResize]
);
const onDropDragOver = react.useCallback(
(droppingItem, position) => {
const existingItem = chunkA5WIFECI_js.getLayoutItem(layout, droppingItem.i);
if (!existingItem) {
const newLayout = [...layout, droppingItem];
const corrected = chunkA5WIFECI_js.correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
}
setDropState({
droppingDOMNode: null,
// Will be set by component
droppingPosition: position
});
},
[layout, cols, compactor]
);
const onDropDragLeave = react.useCallback(() => {
const newLayout = layout.filter((item) => item.i !== "__dropping-elem__");
setLayoutState(newLayout);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
}, [layout]);
const onDrop = react.useCallback(
(droppingItem) => {
const newLayout = layout.map((item) => {
if (item.i === "__dropping-elem__") {
return {
...item,
i: droppingItem.i,
static: false
};
}
return item;
});
const corrected = chunkA5WIFECI_js.correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
},
[layout, cols, compactor]
);
const containerHeight = react.useMemo(() => chunkA5WIFECI_js.bottom(layout), [layout]);
const isInteracting = dragState.activeDrag !== null || resizeState.resizing || dropState.droppingPosition !== null;
return {
layout,
setLayout,
dragState,
resizeState,
dropState,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
onDropDragOver,
onDropDragLeave,
onDrop,
containerHeight,
isInteracting,
compactor
};
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
function useResponsiveLayout(options) {
const {
width,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
compactor = chunk55DQUWLA_js.verticalCompactor,
onBreakpointChange,
onLayoutChange,
onWidthChange
} = options;
const sortedBreakpoints = react.useMemo(
() => chunk55DQUWLA_js.sortBreakpoints(breakpoints),
[breakpoints]
);
const initialBreakpoint = react.useMemo(
() => chunk55DQUWLA_js.getBreakpointFromWidth(breakpoints, width),
// Only calculate on mount, not on width changes
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
const initialCols = react.useMemo(
() => chunk55DQUWLA_js.getColsFromBreakpoint(initialBreakpoint, colsConfig),
[initialBreakpoint, colsConfig]
);
const [breakpoint, setBreakpoint] = react.useState(initialBreakpoint);
const [cols, setCols] = react.useState(initialCols);
const [layouts, setLayoutsState] = react.useState(() => {
const cloned = {};
for (const bp of sortedBreakpoints) {
const layout2 = propsLayouts[bp];
if (layout2) {
cloned[bp] = chunkA5WIFECI_js.cloneLayout(layout2);
}
}
return cloned;
});
const prevWidthRef = react.useRef(width);
const prevBreakpointRef = react.useRef(breakpoint);
const prevPropsLayoutsRef = react.useRef(propsLayouts);
const prevLayoutsRef = react.useRef(layouts);
const layout = react.useMemo(() => {
return chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
layouts,
breakpoints,
breakpoint,
prevBreakpointRef.current,
cols,
compactor
);
}, [layouts, breakpoints, breakpoint, cols, compactor]);
const setLayoutForBreakpoint = react.useCallback((bp, newLayout) => {
setLayoutsState((prev) => ({
...prev,
[bp]: chunkA5WIFECI_js.cloneLayout(newLayout)
}));
}, []);
const setLayouts = react.useCallback((newLayouts) => {
const cloned = {};
for (const bp of Object.keys(newLayouts)) {
const layoutForBp = newLayouts[bp];
if (layoutForBp) {
cloned[bp] = chunkA5WIFECI_js.cloneLayout(layoutForBp);
}
}
setLayoutsState(cloned);
}, []);
react.useEffect(() => {
if (prevWidthRef.current === width) return;
prevWidthRef.current = width;
const newBreakpoint = chunk55DQUWLA_js.getBreakpointFromWidth(breakpoints, width);
const newCols = chunk55DQUWLA_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
onWidthChange?.(width, [10, 10], newCols, null);
if (newBreakpoint !== breakpoint) {
const newLayout = chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
layouts,
breakpoints,
newBreakpoint,
breakpoint,
newCols,
compactor
);
const updatedLayouts = {
...layouts,
[newBreakpoint]: newLayout
};
setLayoutsState(updatedLayouts);
setBreakpoint(newBreakpoint);
setCols(newCols);
onBreakpointChange?.(newBreakpoint, newCols);
prevBreakpointRef.current = newBreakpoint;
}
}, [
width,
breakpoints,
colsConfig,
breakpoint,
layouts,
compactor,
onBreakpointChange,
onWidthChange
]);
react.useEffect(() => {
if (!fastEquals.deepEqual(propsLayouts, prevPropsLayoutsRef.current)) {
setLayouts(propsLayouts);
prevPropsLayoutsRef.current = propsLayouts;
}
}, [propsLayouts, setLayouts]);
react.useEffect(() => {
if (!fastEquals.deepEqual(layouts, prevLayoutsRef.current)) {
prevLayoutsRef.current = layouts;
onLayoutChange?.(layout, layouts);
}
}, [layout, layouts, onLayoutChange]);
return {
layout,
layouts,
breakpoint,
cols,
setLayoutForBreakpoint,
setLayouts,
sortedBreakpoints
};
}
exports.DEFAULT_BREAKPOINTS = DEFAULT_BREAKPOINTS;
exports.DEFAULT_COLS = DEFAULT_COLS;
exports.useContainerWidth = useContainerWidth;
exports.useGridLayout = useGridLayout;
exports.useResponsiveLayout = useResponsiveLayout;
'use strict';
// src/core/calculate.ts
function calcGridColWidth(positionParams) {
const { margin, containerPadding, containerWidth, cols } = positionParams;
return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
}
function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
if (!Number.isFinite(gridUnits)) return gridUnits;
return Math.round(
colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx
);
}
function calcGridItemPosition(positionParams, x, y, w, h, dragPosition, resizePosition) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let width;
let height;
let top;
let left;
if (resizePosition) {
width = Math.round(resizePosition.width);
height = Math.round(resizePosition.height);
} else {
width = calcGridItemWHPx(w, colWidth, margin[0]);
height = calcGridItemWHPx(h, rowHeight, margin[1]);
}
if (dragPosition) {
top = Math.round(dragPosition.top);
left = Math.round(dragPosition.left);
} else if (resizePosition) {
top = Math.round(resizePosition.top);
left = Math.round(resizePosition.left);
} else {
top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
}
if (!dragPosition && !resizePosition) {
if (Number.isFinite(w)) {
const siblingLeft = Math.round(
(colWidth + margin[0]) * (x + w) + containerPadding[0]
);
const actualMarginRight = siblingLeft - left - width;
if (actualMarginRight !== margin[0]) {
width += actualMarginRight - margin[0];
}
}
if (Number.isFinite(h)) {
const siblingTop = Math.round(
(rowHeight + margin[1]) * (y + h) + containerPadding[1]
);
const actualMarginBottom = siblingTop - top - height;
if (actualMarginBottom !== margin[1]) {
height += actualMarginBottom - margin[1];
}
}
}
return { top, left, width, height };
}
function calcXY(positionParams, top, left, w, h) {
const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
x = clamp(x, 0, cols - w);
y = clamp(y, 0, maxRows - h);
return { x, y };
}
function calcXYRaw(positionParams, top, left) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
return { x, y };
}
function calcWH(positionParams, width, height, x, y, handle) {
const { margin, maxRows, cols, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.round((width + margin[0]) / (colWidth + margin[0]));
const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));
let _w = clamp(w, 0, cols - x);
let _h = clamp(h, 0, maxRows - y);
if (handle === "sw" || handle === "w" || handle === "nw") {
_w = clamp(w, 0, cols);
}
if (handle === "nw" || handle === "n" || handle === "ne") {
_h = clamp(h, 0, maxRows);
}
return { w: _w, h: _h };
}
function calcWHRaw(positionParams, width, height) {
const { margin, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.max(
1,
Math.round((width + margin[0]) / (colWidth + margin[0]))
);
const h = Math.max(
1,
Math.round((height + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
function clamp(num, lowerBound, upperBound) {
return Math.max(Math.min(num, upperBound), lowerBound);
}
function calcGridCellDimensions(config) {
const {
width,
cols,
rowHeight,
margin = [10, 10],
containerPadding
} = config;
const padding = containerPadding ?? margin;
const cellWidth = (width - padding[0] * 2 - margin[0] * (cols - 1)) / cols;
const cellHeight = rowHeight;
return {
cellWidth,
cellHeight,
offsetX: padding[0],
offsetY: padding[1],
gapX: margin[0],
gapY: margin[1],
cols,
containerWidth: width
};
}
// src/core/collision.ts
function collides(l1, l2) {
if (l1.i === l2.i) return false;
if (l1.x + l1.w <= l2.x) return false;
if (l1.x >= l2.x + l2.w) return false;
if (l1.y + l1.h <= l2.y) return false;
if (l1.y >= l2.y + l2.h) return false;
return true;
}
function getFirstCollision(layout, layoutItem) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && collides(item, layoutItem)) {
return item;
}
}
return void 0;
}
function getAllCollisions(layout, layoutItem) {
return layout.filter((l) => collides(l, layoutItem));
}
// src/core/sort.ts
function sortLayoutItems(layout, compactType) {
if (compactType === "horizontal") {
return sortLayoutItemsByColRow(layout);
}
if (compactType === "vertical") {
return sortLayoutItemsByRowCol(layout);
}
if (compactType === "wrap") {
return sortLayoutItemsByRowCol(layout);
}
return [...layout];
}
function sortLayoutItemsByRowCol(layout) {
return [...layout].sort((a, b) => {
if (a.y !== b.y) {
return a.y - b.y;
}
return a.x - b.x;
});
}
function sortLayoutItemsByColRow(layout) {
return [...layout].sort((a, b) => {
if (a.x !== b.x) {
return a.x - b.x;
}
return a.y - b.y;
});
}
// src/core/layout.ts
function bottom(layout) {
let max = 0;
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
const bottomY = item.y + item.h;
if (bottomY > max) max = bottomY;
}
}
return max;
}
function getLayoutItem(layout, id) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && item.i === id) {
return item;
}
}
return void 0;
}
function getStatics(layout) {
return layout.filter((l) => l.static === true);
}
function cloneLayoutItem(layoutItem) {
return {
i: layoutItem.i,
x: layoutItem.x,
y: layoutItem.y,
w: layoutItem.w,
h: layoutItem.h,
minW: layoutItem.minW,
maxW: layoutItem.maxW,
minH: layoutItem.minH,
maxH: layoutItem.maxH,
moved: Boolean(layoutItem.moved),
static: Boolean(layoutItem.static),
isDraggable: layoutItem.isDraggable,
isResizable: layoutItem.isResizable,
resizeHandles: layoutItem.resizeHandles,
constraints: layoutItem.constraints,
isBounded: layoutItem.isBounded
};
}
function cloneLayout(layout) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
newLayout[i] = cloneLayoutItem(item);
}
}
return newLayout;
}
function modifyLayout(layout, layoutItem) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
if (layoutItem.i === item.i) {
newLayout[i] = layoutItem;
} else {
newLayout[i] = item;
}
}
}
return newLayout;
}
function withLayoutItem(layout, itemKey, cb) {
let item = getLayoutItem(layout, itemKey);
if (!item) {
return [[...layout], null];
}
item = cb(cloneLayoutItem(item));
const newLayout = modifyLayout(layout, item);
return [newLayout, item];
}
function correctBounds(layout, bounds) {
const collidesWith = getStatics(layout);
for (let i = 0; i < layout.length; i++) {
const l = layout[i];
if (l === void 0) continue;
if (l.x + l.w > bounds.cols) {
l.x = bounds.cols - l.w;
}
if (l.x < 0) {
l.x = 0;
l.w = bounds.cols;
}
if (!l.static) {
collidesWith.push(l);
} else {
while (getFirstCollision(collidesWith, l)) {
l.y++;
}
}
}
return layout;
}
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, allowOverlap) {
if (l.static && l.isDraggable !== true) {
return [...layout];
}
if (l.y === y && l.x === x) {
return [...layout];
}
const oldX = l.x;
const oldY = l.y;
if (typeof x === "number") l.x = x;
if (typeof y === "number") l.y = y;
l.moved = true;
let sorted = sortLayoutItems(layout, compactType);
const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
if (movingUp) {
sorted = sorted.reverse();
}
const collisions = getAllCollisions(sorted, l);
const hasCollisions = collisions.length > 0;
if (hasCollisions && allowOverlap) {
return cloneLayout(layout);
}
if (hasCollisions && preventCollision) {
l.x = oldX;
l.y = oldY;
l.moved = false;
return layout;
}
let resultLayout = [...layout];
for (let i = 0; i < collisions.length; i++) {
const collision = collisions[i];
if (collision === void 0) continue;
if (collision.moved) continue;
if (collision.static) {
resultLayout = moveElementAwayFromCollision(
resultLayout,
collision,
l,
isUserAction,
compactType);
} else {
resultLayout = moveElementAwayFromCollision(
resultLayout,
l,
collision,
isUserAction,
compactType);
}
}
return resultLayout;
}
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols) {
const compactH = compactType === "horizontal";
const compactV = compactType === "vertical";
const preventCollision = collidesWith.static;
if (isUserAction) {
isUserAction = false;
const fakeItem = {
x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
w: itemToMove.w,
h: itemToMove.h,
i: "-1"
};
const firstCollision = getFirstCollision(layout, fakeItem);
const collisionNorth = firstCollision !== void 0 && firstCollision.y + firstCollision.h > collidesWith.y;
const collisionWest = firstCollision !== void 0 && collidesWith.x + collidesWith.w > firstCollision.x;
if (!firstCollision) {
return moveElement(
layout,
itemToMove,
compactH ? fakeItem.x : void 0,
compactV ? fakeItem.y : void 0,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactV) {
return moveElement(
layout,
itemToMove,
void 0,
itemToMove.y + 1,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactType === null) {
collidesWith.y = itemToMove.y;
itemToMove.y = itemToMove.y + itemToMove.h;
return [...layout];
}
if (collisionWest && compactH) {
return moveElement(
layout,
collidesWith,
itemToMove.x,
void 0,
isUserAction,
preventCollision,
compactType);
}
}
const newX = compactH ? itemToMove.x + 1 : void 0;
const newY = compactV ? itemToMove.y + 1 : void 0;
if (newX === void 0 && newY === void 0) {
return [...layout];
}
return moveElement(
layout,
itemToMove,
newX,
newY,
isUserAction,
preventCollision,
compactType);
}
function validateLayout(layout, contextName = "Layout") {
const requiredProps = ["x", "y", "w", "h"];
if (!Array.isArray(layout)) {
throw new Error(`${contextName} must be an array!`);
}
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item === void 0) continue;
for (const key of requiredProps) {
const value = item[key];
if (typeof value !== "number" || Number.isNaN(value)) {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${String(value)} (${typeof value})`
);
}
}
if (item.i !== void 0 && typeof item.i !== "string") {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${String(item.i)} (${typeof item.i})`
);
}
}
}
exports.bottom = bottom;
exports.calcGridCellDimensions = calcGridCellDimensions;
exports.calcGridColWidth = calcGridColWidth;
exports.calcGridItemPosition = calcGridItemPosition;
exports.calcGridItemWHPx = calcGridItemWHPx;
exports.calcWH = calcWH;
exports.calcWHRaw = calcWHRaw;
exports.calcXY = calcXY;
exports.calcXYRaw = calcXYRaw;
exports.clamp = clamp;
exports.cloneLayout = cloneLayout;
exports.cloneLayoutItem = cloneLayoutItem;
exports.collides = collides;
exports.correctBounds = correctBounds;
exports.getAllCollisions = getAllCollisions;
exports.getFirstCollision = getFirstCollision;
exports.getLayoutItem = getLayoutItem;
exports.getStatics = getStatics;
exports.modifyLayout = modifyLayout;
exports.moveElement = moveElement;
exports.moveElementAwayFromCollision = moveElementAwayFromCollision;
exports.sortLayoutItems = sortLayoutItems;
exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow;
exports.sortLayoutItemsByRowCol = sortLayoutItemsByRowCol;
exports.validateLayout = validateLayout;
exports.withLayoutItem = withLayoutItem;
'use strict';
var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');
var React2 = require('react');
var reactDraggable = require('react-draggable');
var reactResizable = require('react-resizable');
var clsx = require('clsx');
var jsxRuntime = require('react/jsx-runtime');
var fastEquals = require('fast-equals');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var React2__default = /*#__PURE__*/_interopDefault(React2);
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
function GridItem(props) {
const {
children,
cols,
containerWidth,
margin,
containerPadding,
rowHeight,
maxRows,
isDraggable,
isResizable,
isBounded,
static: isStatic,
useCSSTransforms = true,
usePercentages = false,
transformScale = 1,
positionStrategy,
dragThreshold = 0,
droppingPosition,
className = "",
style,
handle = "",
cancel = "",
x,
y,
w,
h,
minW = 1,
maxW = Infinity,
minH = 1,
maxH = Infinity,
i,
resizeHandles,
resizeHandle,
constraints = chunk55DQUWLA_js.defaultConstraints,
layoutItem,
layout = [],
onDragStart: onDragStartProp,
onDrag: onDragProp,
onDragStop: onDragStopProp,
onResizeStart: onResizeStartProp,
onResize: onResizeProp,
onResizeStop: onResizeStopProp
} = props;
const [dragging, setDragging] = React2.useState(false);
const [resizing, setResizing] = React2.useState(false);
const elementRef = React2.useRef(null);
const dragPositionRef = React2.useRef({ left: 0, top: 0 });
const resizePositionRef = React2.useRef({
top: 0,
left: 0,
width: 0,
height: 0
});
const prevDroppingPositionRef = React2.useRef(
void 0
);
const layoutRef = React2.useRef(layout);
layoutRef.current = layout;
const onDragStartRef = React2.useRef(null);
const onDragRef = React2.useRef(null);
const dragPendingRef = React2.useRef(false);
const initialDragClientRef = React2.useRef({ x: 0, y: 0 });
const thresholdExceededRef = React2.useRef(false);
const positionParams = React2.useMemo(
() => ({
cols,
containerPadding,
containerWidth,
margin,
maxRows,
rowHeight
}),
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
);
const constraintContext = React2.useMemo(
() => ({
cols,
maxRows,
containerWidth,
containerHeight: 0,
// Auto-height grids don't have a fixed container height
rowHeight,
margin,
// Use empty layout here - the actual layout will be accessed via layoutRef when needed
// This prevents the context from changing when layout changes, avoiding callback recreation
layout: []
}),
[cols, maxRows, containerWidth, rowHeight, margin]
);
const getConstraintContext = React2.useCallback(
() => ({
...constraintContext,
layout: layoutRef.current
}),
[constraintContext]
);
const effectiveLayoutItem = React2.useMemo(
() => layoutItem ?? {
i,
x,
y,
w,
h,
minW,
maxW,
minH,
maxH
},
[layoutItem, i, x, y, w, h, minW, maxW, minH, maxH]
);
const createStyle = React2.useCallback(
(pos2) => {
if (positionStrategy?.calcStyle) {
return positionStrategy.calcStyle(pos2);
}
if (useCSSTransforms) {
return chunk55DQUWLA_js.setTransform(pos2);
}
const styleObj = chunk55DQUWLA_js.setTopLeft(pos2);
if (usePercentages) {
return {
...styleObj,
left: chunk55DQUWLA_js.perc(pos2.left / containerWidth),
width: chunk55DQUWLA_js.perc(pos2.width / containerWidth)
};
}
return styleObj;
},
[positionStrategy, useCSSTransforms, usePercentages, containerWidth]
);
const onDragStart = React2.useCallback(
(e, { node }) => {
if (!onDragStartProp) return;
const { offsetParent } = node;
if (!offsetParent) return;
const parentRect = offsetParent.getBoundingClientRect();
const clientRect = node.getBoundingClientRect();
const cLeft = clientRect.left / transformScale;
const pLeft = parentRect.left / transformScale;
const cTop = clientRect.top / transformScale;
const pTop = parentRect.top / transformScale;
let newPosition;
if (positionStrategy?.calcDragPosition) {
const mouseEvent = e;
newPosition = positionStrategy.calcDragPosition(
mouseEvent.clientX,
mouseEvent.clientY,
mouseEvent.clientX - clientRect.left,
mouseEvent.clientY - clientRect.top
);
} else {
newPosition = {
left: cLeft - pLeft + offsetParent.scrollLeft,
top: cTop - pTop + offsetParent.scrollTop
};
}
dragPositionRef.current = newPosition;
if (dragThreshold > 0) {
const mouseEvent = e;
initialDragClientRef.current = {
x: mouseEvent.clientX,
y: mouseEvent.clientY
};
dragPendingRef.current = true;
thresholdExceededRef.current = false;
setDragging(true);
return;
}
setDragging(true);
const rawPos = chunkA5WIFECI_js.calcXYRaw(
positionParams,
newPosition.top,
newPosition.left
);
const { x: newX, y: newY } = chunk55DQUWLA_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStartProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStartProp,
transformScale,
positionParams,
positionStrategy,
dragThreshold,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
const onDrag = React2.useCallback(
(e, { node, deltaX, deltaY }) => {
if (!onDragProp || !dragging) return;
const mouseEvent = e;
if (dragPendingRef.current && !thresholdExceededRef.current) {
const dx = mouseEvent.clientX - initialDragClientRef.current.x;
const dy = mouseEvent.clientY - initialDragClientRef.current.y;
const distance = Math.hypot(dx, dy);
if (distance < dragThreshold) {
return;
}
thresholdExceededRef.current = true;
dragPendingRef.current = false;
if (onDragStartProp) {
const rawPos2 = chunkA5WIFECI_js.calcXYRaw(
positionParams,
dragPositionRef.current.top,
dragPositionRef.current.left
);
const { x: startX, y: startY } = chunk55DQUWLA_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos2.x,
rawPos2.y,
getConstraintContext()
);
onDragStartProp(i, startX, startY, {
e,
node,
newPosition: dragPositionRef.current
});
}
}
let top = dragPositionRef.current.top + deltaY;
let left = dragPositionRef.current.left + deltaX;
if (isBounded) {
const { offsetParent } = node;
if (offsetParent) {
const bottomBoundary = offsetParent.clientHeight - chunkA5WIFECI_js.calcGridItemWHPx(h, rowHeight, margin[1]);
top = chunkA5WIFECI_js.clamp(top, 0, bottomBoundary);
const colWidth2 = chunkA5WIFECI_js.calcGridColWidth(positionParams);
const rightBoundary = containerWidth - chunkA5WIFECI_js.calcGridItemWHPx(w, colWidth2, margin[0]);
left = chunkA5WIFECI_js.clamp(left, 0, rightBoundary);
}
}
const newPosition = { top, left };
dragPositionRef.current = newPosition;
const rawPos = chunkA5WIFECI_js.calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = chunk55DQUWLA_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragProp,
onDragStartProp,
dragging,
dragThreshold,
isBounded,
h,
rowHeight,
margin,
positionParams,
containerWidth,
w,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const onDragStop = React2.useCallback(
(e, { node }) => {
if (!onDragStopProp || !dragging) return;
const wasPending = dragPendingRef.current;
dragPendingRef.current = false;
thresholdExceededRef.current = false;
initialDragClientRef.current = { x: 0, y: 0 };
if (wasPending) {
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
return;
}
const { left, top } = dragPositionRef.current;
const newPosition = { top, left };
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
const rawPos = chunkA5WIFECI_js.calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = chunk55DQUWLA_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStopProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStopProp,
dragging,
positionParams,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
onDragStartRef.current = onDragStart;
onDragRef.current = onDrag;
const onResizeHandler = React2.useCallback(
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
if (!handler) return;
let updatedSize;
if (node) {
updatedSize = chunk55DQUWLA_js.resizeItemInDirection(
resizeHandle2,
position,
size,
containerWidth
);
} else {
updatedSize = {
...size,
top: position.top,
left: position.left
};
}
resizePositionRef.current = updatedSize;
const rawSize = chunkA5WIFECI_js.calcWHRaw(
positionParams,
updatedSize.width,
updatedSize.height
);
const { w: newW, h: newH } = chunk55DQUWLA_js.applySizeConstraints(
constraints,
effectiveLayoutItem,
rawSize.w,
rawSize.h,
resizeHandle2,
getConstraintContext()
);
handler(i, newW, newH, {
e: e.nativeEvent,
node,
size: updatedSize,
handle: resizeHandle2
});
},
[
onResizeStartProp,
onResizeProp,
onResizeStopProp,
containerWidth,
positionParams,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const handleResizeStart = React2.useCallback(
(e, data) => {
setResizing(true);
const pos2 = chunkA5WIFECI_js.calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStart");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResize = React2.useCallback(
(e, data) => {
const pos2 = chunkA5WIFECI_js.calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResize");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResizeStop = React2.useCallback(
(e, data) => {
setResizing(false);
resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
const pos2 = chunkA5WIFECI_js.calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStop");
},
[onResizeHandler, positionParams, x, y, w, h]
);
React2.useEffect(() => {
if (!droppingPosition) return;
const node = elementRef.current;
if (!node) return;
const prevDroppingPosition = prevDroppingPositionRef.current || {
left: 0,
top: 0
};
const shouldDrag = dragging && (droppingPosition.left !== prevDroppingPosition.left || droppingPosition.top !== prevDroppingPosition.top);
if (!dragging) {
const fakeData = {
node,
deltaX: droppingPosition.left,
deltaY: droppingPosition.top,
lastX: 0,
lastY: 0,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragStartRef.current?.(
droppingPosition.e,
fakeData
);
} else if (shouldDrag) {
const deltaX = droppingPosition.left - dragPositionRef.current.left;
const deltaY = droppingPosition.top - dragPositionRef.current.top;
const fakeData = {
node,
deltaX,
deltaY,
lastX: dragPositionRef.current.left,
lastY: dragPositionRef.current.top,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragRef.current?.(
droppingPosition.e,
fakeData
);
}
prevDroppingPositionRef.current = droppingPosition;
}, [droppingPosition, dragging, i]);
const pos = chunkA5WIFECI_js.calcGridItemPosition(
positionParams,
x,
y,
w,
h,
dragging ? dragPositionRef.current : null,
resizing ? resizePositionRef.current : null
);
const child = React2__default.default.Children.only(children);
const colWidth = chunkA5WIFECI_js.calcGridColWidth(positionParams);
const minConstraints = [
chunkA5WIFECI_js.calcGridItemWHPx(minW, colWidth, margin[0]),
chunkA5WIFECI_js.calcGridItemWHPx(minH, rowHeight, margin[1])
];
const maxConstraints = [
chunkA5WIFECI_js.calcGridItemWHPx(maxW, colWidth, margin[0]),
chunkA5WIFECI_js.calcGridItemWHPx(maxH, rowHeight, margin[1])
];
const childProps = child.props;
const childClassName = childProps["className"];
const childStyle = childProps["style"];
let newChild = React2__default.default.cloneElement(child, {
ref: elementRef,
className: clsx__default.default("react-grid-item", childClassName, className, {
static: isStatic,
resizing,
"react-draggable": isDraggable,
"react-draggable-dragging": dragging,
dropping: Boolean(droppingPosition),
cssTransforms: useCSSTransforms
}),
style: {
...style,
...childStyle,
...createStyle(pos)
}
});
const resizableHandle = resizeHandle;
newChild = /* @__PURE__ */ jsxRuntime.jsx(
reactResizable.Resizable,
{
draggableOpts: { disabled: !isResizable },
className: isResizable ? void 0 : "react-resizable-hide",
width: pos.width,
height: pos.height,
minConstraints,
maxConstraints,
onResizeStart: handleResizeStart,
onResize: handleResize,
onResizeStop: handleResizeStop,
transformScale,
resizeHandles,
handle: resizableHandle,
children: newChild
}
);
newChild = /* @__PURE__ */ jsxRuntime.jsx(
reactDraggable.DraggableCore,
{
disabled: !isDraggable,
onStart: onDragStart,
onDrag,
onStop: onDragStop,
handle,
cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
scale: transformScale,
nodeRef: elementRef,
children: newChild
}
);
return newChild;
}
var noop = () => {
};
var layoutClassName = "react-grid-layout";
var isFirefox = false;
try {
isFirefox = /firefox/i.test(navigator.userAgent);
} catch {
}
function childrenEqual(a, b) {
const aArr = React2__default.default.Children.toArray(a);
const bArr = React2__default.default.Children.toArray(b);
if (aArr.length !== bArr.length) return false;
for (let i = 0; i < aArr.length; i++) {
const aChild = aArr[i];
const bChild = bArr[i];
if (aChild?.key !== bChild?.key) return false;
}
return true;
}
function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
const layout = [];
const childKeys = /* @__PURE__ */ new Set();
React2__default.default.Children.forEach(children, (child) => {
if (!React2__default.default.isValidElement(child) || child.key === null) return;
const key = String(child.key);
childKeys.add(key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push(chunkA5WIFECI_js.cloneLayoutItem(existingItem));
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: chunkA5WIFECI_js.bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = chunkA5WIFECI_js.correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function GridLayout(props) {
const {
// Required
children,
width,
// Composable config interfaces
gridConfig: gridConfigProp,
dragConfig: dragConfigProp,
resizeConfig: resizeConfigProp,
dropConfig: dropConfigProp,
positionStrategy = chunk55DQUWLA_js.defaultPositionStrategy,
compactor: compactorProp,
constraints = chunk55DQUWLA_js.defaultConstraints,
// Layout data
layout: propsLayout = [],
droppingItem: droppingItemProp,
// Container props
autoSize = true,
className = "",
style = {},
innerRef,
// Callbacks
onLayoutChange = noop,
onDragStart: onDragStartProp = noop,
onDrag: onDragProp = noop,
onDragStop: onDragStopProp = noop,
onResizeStart: onResizeStartProp = noop,
onResize: onResizeProp = noop,
onResizeStop: onResizeStopProp = noop,
onDrop: onDropProp = noop,
onDropDragOver: onDropDragOverProp = noop
} = props;
const gridConfig = React2.useMemo(
() => ({ ...chunk55DQUWLA_js.defaultGridConfig, ...gridConfigProp }),
[gridConfigProp]
);
const dragConfig = React2.useMemo(
() => ({ ...chunk55DQUWLA_js.defaultDragConfig, ...dragConfigProp }),
[dragConfigProp]
);
const resizeConfig = React2.useMemo(
() => ({ ...chunk55DQUWLA_js.defaultResizeConfig, ...resizeConfigProp }),
[resizeConfigProp]
);
const dropConfig = React2.useMemo(
() => ({ ...chunk55DQUWLA_js.defaultDropConfig, ...dropConfigProp }),
[dropConfigProp]
);
const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
const {
enabled: isDraggable,
bounded: isBounded,
handle: draggableHandle,
cancel: draggableCancel,
threshold: dragThreshold
} = dragConfig;
const {
enabled: isResizable,
handles: resizeHandles,
handleComponent: resizeHandle
} = resizeConfig;
const {
enabled: isDroppable,
defaultItem: defaultDropItem,
onDragOver: dropConfigOnDragOver
} = dropConfig;
const compactor = compactorProp ?? chunk55DQUWLA_js.getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const preventCollision = compactor.preventCollision ?? false;
const droppingItem = React2.useMemo(
() => droppingItemProp ?? {
i: "__dropping-elem__",
...defaultDropItem
},
[droppingItemProp, defaultDropItem]
);
const useCSSTransforms = positionStrategy.type === "transform";
const transformScale = positionStrategy.scale;
const effectiveContainerPadding = containerPadding ?? margin;
const [mounted, setMounted] = React2.useState(false);
const [layout, setLayout] = React2.useState(
() => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor)
);
const [activeDrag, setActiveDrag] = React2.useState(null);
const [resizing, setResizing] = React2.useState(false);
const [droppingDOMNode, setDroppingDOMNode] = React2.useState(
null
);
const [droppingPosition, setDroppingPosition] = React2.useState();
const oldDragItemRef = React2.useRef(null);
const oldResizeItemRef = React2.useRef(null);
const oldLayoutRef = React2.useRef(null);
const dragEnterCounterRef = React2.useRef(0);
const prevLayoutRef = React2.useRef(layout);
const prevPropsLayoutRef = React2.useRef(propsLayout);
const prevChildrenRef = React2.useRef(children);
const prevCompactTypeRef = React2.useRef(compactType);
const layoutRef = React2.useRef(layout);
layoutRef.current = layout;
React2.useEffect(() => {
setMounted(true);
if (!fastEquals.deepEqual(layout, propsLayout)) {
onLayoutChange(layout);
}
}, []);
React2.useEffect(() => {
if (activeDrag) return;
if (droppingDOMNode) return;
const layoutChanged = !fastEquals.deepEqual(propsLayout, prevPropsLayoutRef.current);
const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
const compactTypeChanged = compactType !== prevCompactTypeRef.current;
if (layoutChanged || childrenChanged || compactTypeChanged) {
const baseLayout = layoutChanged ? propsLayout : layout;
const newLayout = synchronizeLayoutWithChildren(
baseLayout,
children,
cols,
compactor
);
if (!fastEquals.deepEqual(newLayout, layout)) {
setLayout(newLayout);
}
}
prevPropsLayoutRef.current = propsLayout;
prevChildrenRef.current = children;
prevCompactTypeRef.current = compactType;
}, [
propsLayout,
children,
cols,
compactType,
compactor,
activeDrag,
droppingDOMNode,
layout
]);
React2.useEffect(() => {
if (!activeDrag && !fastEquals.deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
const publicLayout = layout.filter((l) => l.i !== droppingItem.i);
onLayoutChange(publicLayout);
}
}, [layout, activeDrag, onLayoutChange, droppingItem.i]);
const containerHeight = React2.useMemo(() => {
if (!autoSize) return void 0;
const nbRow = chunkA5WIFECI_js.bottom(layout);
const containerPaddingY = effectiveContainerPadding[1];
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
}, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
const onDragStart = React2.useCallback(
(i, _x, _y, data) => {
const currentLayout = layoutRef.current;
const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
oldDragItemRef.current = chunkA5WIFECI_js.cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setActiveDrag(placeholder);
onDragStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onDragStartProp]
);
const onDrag = React2.useCallback(
(i, x, y, data) => {
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
const newLayout = chunkA5WIFECI_js.moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
setLayout(compactor.compact(newLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
);
const onDragStop = React2.useCallback(
(i, x, y, data) => {
if (!activeDrag) return;
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
if (!l) return;
const newLayout = chunkA5WIFECI_js.moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
const finalLayout = compactor.compact(newLayout, cols);
onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
const oldLayout = oldLayoutRef.current;
oldDragItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setLayout(finalLayout);
if (oldLayout && !fastEquals.deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[
activeDrag,
preventCollision,
compactType,
cols,
allowOverlap,
compactor,
onDragStopProp,
onLayoutChange
]
);
const onResizeStart = React2.useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
if (!l) return;
oldResizeItemRef.current = chunkA5WIFECI_js.cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setResizing(true);
onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onResizeStartProp]
);
const onResize = React2.useCallback(
(i, w, h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const { handle } = data;
let shouldMoveItem = false;
let newX;
let newY;
const [newLayout, l] = chunkA5WIFECI_js.withLayoutItem(currentLayout, i, (item) => {
newX = item.x;
newY = item.y;
if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
if (["sw", "nw", "w"].includes(handle)) {
newX = item.x + (item.w - w);
w = item.x !== newX && newX < 0 ? item.w : w;
newX = newX < 0 ? 0 : newX;
}
if (["ne", "n", "nw"].includes(handle)) {
newY = item.y + (item.h - h);
h = item.y !== newY && newY < 0 ? item.h : h;
newY = newY < 0 ? 0 : newY;
}
shouldMoveItem = true;
}
if (preventCollision && !allowOverlap) {
const collisions = chunkA5WIFECI_js.getAllCollisions(currentLayout, {
...item,
w,
h,
x: newX ?? item.x,
y: newY ?? item.y
}).filter((layoutItem) => layoutItem.i !== item.i);
if (collisions.length > 0) {
newY = item.y;
h = item.h;
newX = item.x;
w = item.w;
shouldMoveItem = false;
}
}
item.w = w;
item.h = h;
return item;
});
if (!l) return;
let finalLayout = newLayout;
if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
finalLayout = chunkA5WIFECI_js.moveElement(
newLayout,
l,
newX,
newY,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
}
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i,
static: true
};
onResizeProp(
finalLayout,
oldResizeItem,
l,
placeholder,
data.e,
data.node
);
setLayout(compactor.compact(finalLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
);
const onResizeStop = React2.useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
const finalLayout = compactor.compact(currentLayout, cols);
onResizeStopProp(
finalLayout,
oldResizeItem,
l ?? null,
null,
data.e,
data.node
);
const oldLayout = oldLayoutRef.current;
oldResizeItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setResizing(false);
setLayout(finalLayout);
if (oldLayout && !fastEquals.deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[cols, compactor, onResizeStopProp, onLayoutChange]
);
const removeDroppingPlaceholder = React2.useCallback(() => {
const currentLayout = layoutRef.current;
const hasDroppingItem = currentLayout.some((l) => l.i === droppingItem.i);
if (!hasDroppingItem) {
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
return;
}
const newLayout = compactor.compact(
currentLayout.filter((l) => l.i !== droppingItem.i),
cols
);
setLayout(newLayout);
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
}, [droppingItem.i, cols, compactor]);
const handleDragOver = React2.useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
if (isFirefox && !e.nativeEvent.target?.classList.contains(
layoutClassName
)) {
return false;
}
const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
if (rawResult === false) {
if (droppingDOMNode) {
removeDroppingPlaceholder();
}
return false;
}
const {
dragOffsetX = 0,
dragOffsetY = 0,
...onDragOverResult
} = rawResult ?? {};
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
const gridRect = e.currentTarget.getBoundingClientRect();
const positionParams = {
cols,
margin,
maxRows,
rowHeight,
containerWidth: width,
containerPadding: effectiveContainerPadding
};
const actualColWidth = chunkA5WIFECI_js.calcGridColWidth(positionParams);
const itemPixelWidth = chunkA5WIFECI_js.calcGridItemWHPx(
finalDroppingItem.w,
actualColWidth,
margin[0]
);
const itemPixelHeight = chunkA5WIFECI_js.calcGridItemWHPx(
finalDroppingItem.h,
rowHeight,
margin[1]
);
const itemCenterOffsetX = itemPixelWidth / 2;
const itemCenterOffsetY = itemPixelHeight / 2;
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
const clampedGridX = Math.max(0, rawGridX);
const clampedGridY = Math.max(0, rawGridY);
const newDroppingPosition = {
left: clampedGridX / transformScale,
top: clampedGridY / transformScale,
e: e.nativeEvent
};
if (!droppingDOMNode) {
const calculatedPosition = chunkA5WIFECI_js.calcXY(
positionParams,
clampedGridY,
clampedGridX,
finalDroppingItem.w,
finalDroppingItem.h
);
setDroppingDOMNode(/* @__PURE__ */ jsxRuntime.jsx("div", {}, finalDroppingItem.i));
setDroppingPosition(newDroppingPosition);
const baseLayout = layoutRef.current.filter(
(l) => l.i !== finalDroppingItem.i
);
setLayout([
...baseLayout,
{
...finalDroppingItem,
x: calculatedPosition.x,
y: calculatedPosition.y,
static: false,
isDraggable: true
}
]);
} else if (droppingPosition) {
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
if (shouldUpdate) {
setDroppingPosition(newDroppingPosition);
}
}
},
[
droppingDOMNode,
droppingPosition,
droppingItem,
dropConfigOnDragOver,
onDropDragOverProp,
removeDroppingPlaceholder,
transformScale,
cols,
margin,
maxRows,
rowHeight,
width,
effectiveContainerPadding
]
);
const handleDragLeave = React2.useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current--;
if (dragEnterCounterRef.current < 0) {
dragEnterCounterRef.current = 0;
}
if (dragEnterCounterRef.current === 0) {
removeDroppingPlaceholder();
}
},
[removeDroppingPlaceholder]
);
const handleDragEnter = React2.useCallback((e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current++;
}, []);
const handleDrop = React2.useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
const currentLayout = layoutRef.current;
const item = currentLayout.find((l) => l.i === droppingItem.i);
dragEnterCounterRef.current = 0;
removeDroppingPlaceholder();
onDropProp(currentLayout, item, e.nativeEvent);
},
[droppingItem.i, removeDroppingPlaceholder, onDropProp]
);
const processGridItem = React2.useCallback(
(child, isDroppingItem) => {
if (!child || !child.key) return null;
const l = chunkA5WIFECI_js.getLayoutItem(layout, String(child.key));
if (!l) return null;
const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
const resizeHandlesOptions = l.resizeHandles || [...resizeHandles];
const bounded = draggable && isBounded && l.isBounded !== false;
const resizeHandleElement = resizeHandle;
return /* @__PURE__ */ jsxRuntime.jsx(
GridItem,
{
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
cancel: draggableCancel,
handle: draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable: draggable,
isResizable: resizable,
isBounded: bounded,
useCSSTransforms: useCSSTransforms && mounted,
usePercentages: !mounted,
transformScale,
positionStrategy,
dragThreshold,
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i: l.i,
minH: l.minH,
minW: l.minW,
maxH: l.maxH,
maxW: l.maxW,
static: l.static,
droppingPosition: isDroppingItem ? droppingPosition : void 0,
resizeHandles: resizeHandlesOptions,
resizeHandle: resizeHandleElement,
constraints,
layoutItem: l,
layout,
children: child
},
l.i
);
},
[
layout,
width,
cols,
margin,
effectiveContainerPadding,
maxRows,
rowHeight,
draggableCancel,
draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable,
isResizable,
isBounded,
useCSSTransforms,
mounted,
transformScale,
positionStrategy,
dragThreshold,
droppingPosition,
resizeHandles,
resizeHandle,
constraints
]
);
const renderPlaceholder = () => {
if (!activeDrag) return null;
return /* @__PURE__ */ jsxRuntime.jsx(
GridItem,
{
w: activeDrag.w,
h: activeDrag.h,
x: activeDrag.x,
y: activeDrag.y,
i: activeDrag.i,
className: `react-grid-placeholder ${resizing ? "placeholder-resizing" : ""}`,
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
isDraggable: false,
isResizable: false,
isBounded: false,
useCSSTransforms,
transformScale,
constraints,
layout,
children: /* @__PURE__ */ jsxRuntime.jsx("div", {})
}
);
};
const mergedClassName = clsx__default.default(layoutClassName, className);
const mergedStyle = {
height: containerHeight,
...style
};
return /* @__PURE__ */ jsxRuntime.jsxs(
"div",
{
ref: innerRef,
className: mergedClassName,
style: mergedStyle,
onDrop: isDroppable ? handleDrop : void 0,
onDragLeave: isDroppable ? handleDragLeave : void 0,
onDragEnter: isDroppable ? handleDragEnter : void 0,
onDragOver: isDroppable ? handleDragOver : void 0,
children: [
React2__default.default.Children.map(children, (child) => {
if (!React2__default.default.isValidElement(child)) return null;
return processGridItem(child);
}),
isDroppable && droppingDOMNode && processGridItem(droppingDOMNode, true),
renderPlaceholder()
]
}
);
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
var noop2 = () => {
};
function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor) {
const layout = [];
React2__default.default.Children.forEach(children, (child) => {
if (!React2__default.default.isValidElement(child) || child.key === null) return;
const key = String(child.key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push({
...existingItem,
i: key
});
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: chunkA5WIFECI_js.bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = chunkA5WIFECI_js.correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function ResponsiveGridLayout(props) {
const {
children,
width,
breakpoint: propBreakpoint,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
rowHeight = 150,
maxRows = Infinity,
margin: propMargin = [10, 10],
containerPadding: propContainerPadding = null,
compactor: compactorProp,
onBreakpointChange = noop2,
onLayoutChange = noop2,
onWidthChange = noop2,
...restProps
} = props;
const compactor = compactorProp ?? chunk55DQUWLA_js.getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const initialBreakpoint = React2.useMemo(() => {
return propBreakpoint ?? chunk55DQUWLA_js.getBreakpointFromWidth(breakpoints, width);
}, []);
const initialCols = React2.useMemo(() => {
return chunk55DQUWLA_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
}, [initialBreakpoint, colsConfig]);
const initialLayout = React2.useMemo(() => {
return chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
initialBreakpoint,
initialBreakpoint,
initialCols,
compactType
);
}, []);
const [breakpoint, setBreakpoint] = React2.useState(initialBreakpoint);
const [cols, setCols] = React2.useState(initialCols);
const [layout, setLayout] = React2.useState(initialLayout);
const [layouts, setLayouts] = React2.useState(propsLayouts);
const prevWidthRef = React2.useRef(width);
const prevBreakpointRef = React2.useRef(propBreakpoint);
const prevBreakpointsRef = React2.useRef(breakpoints);
const prevColsRef = React2.useRef(colsConfig);
const prevLayoutsRef = React2.useRef(propsLayouts);
const prevCompactTypeRef = React2.useRef(compactType);
const layoutsRef = React2.useRef(layouts);
React2.useEffect(() => {
layoutsRef.current = layouts;
}, [layouts]);
const derivedLayout = React2.useMemo(() => {
if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
return chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
breakpoint,
breakpoint,
cols,
compactor
);
}
return null;
}, [propsLayouts, breakpoints, breakpoint, cols, compactor]);
const effectiveLayout = derivedLayout ?? layout;
React2.useEffect(() => {
if (derivedLayout !== null) {
setLayout(derivedLayout);
setLayouts(propsLayouts);
layoutsRef.current = propsLayouts;
prevLayoutsRef.current = propsLayouts;
}
}, [derivedLayout, propsLayouts]);
React2.useEffect(() => {
if (compactType !== prevCompactTypeRef.current) {
const newLayout = compactor.compact(chunkA5WIFECI_js.cloneLayout(effectiveLayout), cols);
const newLayouts = {
...layoutsRef.current,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
prevCompactTypeRef.current = compactType;
}
}, [
compactType,
compactor,
effectiveLayout,
cols,
allowOverlap,
breakpoint,
onLayoutChange
]);
React2.useEffect(() => {
const widthChanged = width !== prevWidthRef.current;
const breakpointPropChanged = propBreakpoint !== prevBreakpointRef.current;
const breakpointsChanged = !fastEquals.deepEqual(
breakpoints,
prevBreakpointsRef.current
);
const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
const newBreakpoint = propBreakpoint ?? chunk55DQUWLA_js.getBreakpointFromWidth(breakpoints, width);
const newCols = chunk55DQUWLA_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
const lastBreakpoint = breakpoint;
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
const newLayouts = { ...layoutsRef.current };
if (!newLayouts[lastBreakpoint]) {
newLayouts[lastBreakpoint] = chunkA5WIFECI_js.cloneLayout(layout);
}
let newLayout = chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
newLayouts,
breakpoints,
newBreakpoint,
lastBreakpoint,
newCols,
compactor
);
newLayout = synchronizeLayoutWithChildren2(
newLayout,
children,
newCols,
compactor
);
newLayouts[newBreakpoint] = newLayout;
setBreakpoint(newBreakpoint);
setCols(newCols);
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onBreakpointChange(newBreakpoint, newCols);
onLayoutChange(newLayout, newLayouts);
}
const currentMargin2 = chunk55DQUWLA_js.getIndentationValue(
propMargin,
newBreakpoint
);
const currentPadding = propContainerPadding ? chunk55DQUWLA_js.getIndentationValue(
propContainerPadding,
newBreakpoint
) : null;
onWidthChange(width, currentMargin2, newCols, currentPadding);
prevWidthRef.current = width;
prevBreakpointRef.current = propBreakpoint;
prevBreakpointsRef.current = breakpoints;
prevColsRef.current = colsConfig;
}
}, [
width,
propBreakpoint,
breakpoints,
colsConfig,
breakpoint,
cols,
layout,
children,
compactor,
compactType,
allowOverlap,
propMargin,
propContainerPadding,
onBreakpointChange,
onLayoutChange,
onWidthChange
]);
const handleLayoutChange = React2.useCallback(
(newLayout) => {
const currentLayouts = layoutsRef.current;
const newLayouts = {
...currentLayouts,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
},
[breakpoint, onLayoutChange]
);
const currentMargin = React2.useMemo(() => {
return chunk55DQUWLA_js.getIndentationValue(
propMargin,
breakpoint
);
}, [propMargin, breakpoint]);
const currentContainerPadding = React2.useMemo(() => {
if (propContainerPadding === null) return null;
return chunk55DQUWLA_js.getIndentationValue(
propContainerPadding,
breakpoint
);
}, [propContainerPadding, breakpoint]);
const gridConfig = React2.useMemo(
() => ({
cols,
rowHeight,
maxRows,
margin: currentMargin,
containerPadding: currentContainerPadding
}),
[cols, rowHeight, maxRows, currentMargin, currentContainerPadding]
);
return /* @__PURE__ */ jsxRuntime.jsx(
GridLayout,
{
...restProps,
width,
gridConfig,
compactor,
onLayoutChange: handleLayoutChange,
layout: effectiveLayout,
children
}
);
}
exports.GridItem = GridItem;
exports.GridLayout = GridLayout;
exports.ResponsiveGridLayout = ResponsiveGridLayout;
import { getStatics, collides, getFirstCollision, bottom, sortLayoutItemsByRowCol, cloneLayoutItem, sortLayoutItemsByColRow, cloneLayout, correctBounds } from './chunk-76RTO6EO.mjs';
// src/core/constraints.ts
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
var gridBounds = {
name: "gridBounds",
constrainPosition(item, x, y, { cols, maxRows }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
},
constrainSize(item, w, h, handle, { cols, maxRows }) {
const maxW = handle === "w" || handle === "nw" || handle === "sw" ? item.x + item.w : cols - item.x;
const maxH = handle === "n" || handle === "nw" || handle === "ne" ? item.y + item.h : maxRows - item.y;
return {
w: clamp(w, 1, Math.max(1, maxW)),
h: clamp(h, 1, Math.max(1, maxH))
};
}
};
var minMaxSize = {
name: "minMaxSize",
constrainSize(item, w, h) {
return {
w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),
h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)
};
}
};
var containerBounds = {
name: "containerBounds",
constrainPosition(item, x, y, { cols, maxRows, containerHeight, rowHeight, margin }) {
const visibleRows = containerHeight > 0 ? Math.floor((containerHeight + margin[1]) / (rowHeight + margin[1])) : maxRows;
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, visibleRows - item.h))
};
}
};
var boundedX = {
name: "boundedX",
constrainPosition(item, x, y, { cols }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y
};
}
};
var boundedY = {
name: "boundedY",
constrainPosition(item, x, y, { maxRows }) {
return {
x,
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
}
};
function aspectRatio(ratio) {
return {
name: `aspectRatio(${ratio})`,
constrainSize(_item, w, _h, _handle, context) {
const { cols, containerWidth, rowHeight, margin } = context;
const colWidth = (containerWidth - margin[0] * (cols - 1)) / cols;
const pixelWidth = colWidth * w + margin[0] * Math.max(0, w - 1);
const pixelHeight = pixelWidth / ratio;
const h = Math.max(
1,
Math.round((pixelHeight + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
};
}
function snapToGrid(stepX, stepY = stepX) {
if (stepX <= 0 || stepY <= 0) {
throw new Error(
`snapToGrid: step values must be positive (got stepX=${stepX}, stepY=${stepY})`
);
}
return {
name: `snapToGrid(${stepX}, ${stepY})`,
constrainPosition(_item, x, y) {
return {
x: Math.round(x / stepX) * stepX,
y: Math.round(y / stepY) * stepY
};
}
};
}
function minSize(minW, minH) {
return {
name: `minSize(${minW}, ${minH})`,
constrainSize(_item, w, h) {
return {
w: Math.max(minW, w),
h: Math.max(minH, h)
};
}
};
}
function maxSize(maxW, maxH) {
return {
name: `maxSize(${maxW}, ${maxH})`,
constrainSize(_item, w, h) {
return {
w: Math.min(maxW, w),
h: Math.min(maxH, h)
};
}
};
}
var defaultConstraints = [gridBounds, minMaxSize];
function applyPositionConstraints(constraints, item, x, y, context) {
let result = { x, y };
for (const constraint of constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(item, result.x, result.y, context);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(
item,
result.x,
result.y,
context
);
}
}
}
return result;
}
function applySizeConstraints(constraints, item, w, h, handle, context) {
let result = { w, h };
for (const constraint of constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
}
return result;
}
// src/core/position.ts
function setTransform({
top,
left,
width,
height
}) {
const translate = `translate(${left}px,${top}px)`;
return {
transform: translate,
WebkitTransform: translate,
MozTransform: translate,
msTransform: translate,
OTransform: translate,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function setTopLeft({
top,
left,
width,
height
}) {
return {
top: `${top}px`,
left: `${left}px`,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function perc(num) {
return num * 100 + "%";
}
function constrainWidth(left, currentWidth, newWidth, containerWidth) {
return left + newWidth > containerWidth ? currentWidth : newWidth;
}
function constrainHeight(top, currentHeight, newHeight) {
return top < 0 ? currentHeight : newHeight;
}
function constrainLeft(left) {
return Math.max(0, left);
}
function constrainTop(top) {
return Math.max(0, top);
}
var resizeNorth = (currentSize, newSize, _containerWidth) => {
const { left, height, width } = newSize;
const top = currentSize.top - (height - currentSize.height);
return {
left,
width,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeEast = (currentSize, newSize, containerWidth) => {
const { top, left, height, width } = newSize;
return {
top,
height,
width: constrainWidth(
currentSize.left,
currentSize.width,
width,
containerWidth
),
left: constrainLeft(left)
};
};
var resizeWest = (currentSize, newSize, _containerWidth) => {
const { top, height, width } = newSize;
const left = currentSize.left + currentSize.width - width;
if (left < 0) {
return {
height,
width: currentSize.left + currentSize.width,
top: constrainTop(top),
left: 0
};
}
return {
height,
width,
top: constrainTop(top),
left
};
};
var resizeSouth = (currentSize, newSize, _containerWidth) => {
const { top, left, height, width } = newSize;
return {
width,
left,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeNorthEast = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeNorthWest = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeWest(currentSize, newSize));
var resizeSouthEast = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeSouthWest = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeWest(currentSize, newSize));
var resizeHandlerMap = {
n: resizeNorth,
ne: resizeNorthEast,
e: resizeEast,
se: resizeSouthEast,
s: resizeSouth,
sw: resizeSouthWest,
w: resizeWest,
nw: resizeNorthWest
};
function resizeItemInDirection(direction, currentSize, newSize, containerWidth) {
const handler = resizeHandlerMap[direction];
if (!handler) {
return newSize;
}
return handler(currentSize, { ...currentSize, ...newSize }, containerWidth);
}
var transformStrategy = {
type: "transform",
scale: 1,
calcStyle(pos) {
return setTransform(pos);
}
};
var absoluteStrategy = {
type: "absolute",
scale: 1,
calcStyle(pos) {
return setTopLeft(pos);
}
};
function createScaledStrategy(scale) {
return {
type: "transform",
scale,
calcStyle(pos) {
return setTransform(pos);
},
calcDragPosition(clientX, clientY, offsetX, offsetY) {
return {
left: (clientX - offsetX) / scale,
top: (clientY - offsetY) / scale
};
}
};
}
var defaultPositionStrategy = transformStrategy;
// src/core/types.ts
var defaultGridConfig = {
cols: 12,
rowHeight: 150,
margin: [10, 10],
containerPadding: null,
maxRows: Infinity
};
var defaultDragConfig = {
enabled: true,
bounded: false,
threshold: 3
};
var defaultResizeConfig = {
enabled: true,
handles: ["se"]
};
var defaultDropConfig = {
enabled: false,
defaultItem: { w: 1, h: 1 }
};
// src/core/compactors.ts
function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
const sizeProp = axis === "x" ? "w" : "h";
item[axis] += 1;
const itemIndex = layout.findIndex((l) => l.i === item.i);
const layoutHasStatics = hasStatics ?? getStatics(layout).length > 0;
for (let i = itemIndex + 1; i < layout.length; i++) {
const otherItem = layout[i];
if (otherItem === void 0) continue;
if (otherItem.static) continue;
if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
if (collides(item, otherItem)) {
resolveCompactionCollision(
layout,
otherItem,
moveToCoord + item[sizeProp],
axis,
layoutHasStatics
);
}
}
item[axis] = moveToCoord;
}
function compactItemVertical(compareWith, l, fullLayout, maxY) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
l.y = Math.min(maxY, l.y);
while (l.y > 0 && !getFirstCollision(compareWith, l)) {
l.y--;
}
let collision;
while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y");
}
l.y = Math.max(l.y, 0);
return l;
}
function compactItemHorizontal(compareWith, l, cols, fullLayout) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
while (l.x > 0 && !getFirstCollision(compareWith, l)) {
l.x--;
}
let collision;
while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
if (l.x + l.w > cols) {
l.x = cols - l.w;
l.y++;
while (l.x > 0 && !getFirstCollision(compareWith, l)) {
l.x--;
}
}
}
l.x = Math.max(l.x, 0);
return l;
}
var verticalCompactor = {
type: "vertical",
allowOverlap: false,
compact(layout, _cols) {
const compareWith = getStatics(layout);
let maxY = bottom(compareWith);
const sorted = sortLayoutItemsByRowCol(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemVertical(compareWith, l, sorted, maxY);
maxY = Math.max(maxY, l.y + l.h);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var horizontalCompactor = {
type: "horizontal",
allowOverlap: false,
compact(layout, cols) {
const compareWith = getStatics(layout);
const sorted = sortLayoutItemsByColRow(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemHorizontal(compareWith, l, cols, sorted);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var noCompactor = {
type: null,
allowOverlap: false,
compact(layout, _cols) {
return cloneLayout(layout);
}
};
var verticalOverlapCompactor = {
...verticalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return cloneLayout(layout);
}
};
var horizontalOverlapCompactor = {
...horizontalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return cloneLayout(layout);
}
};
var noOverlapCompactor = {
...noCompactor,
allowOverlap: true
};
function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
let baseCompactor;
if (allowOverlap) {
if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
else if (compactType === "horizontal")
baseCompactor = horizontalOverlapCompactor;
else baseCompactor = noOverlapCompactor;
} else {
if (compactType === "vertical") baseCompactor = verticalCompactor;
else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
else baseCompactor = noCompactor;
}
if (preventCollision) {
return { ...baseCompactor, preventCollision };
}
return baseCompactor;
}
// src/core/responsive.ts
function sortBreakpoints(breakpoints) {
const keys = Object.keys(breakpoints);
return keys.sort((a, b) => breakpoints[a] - breakpoints[b]);
}
function getBreakpointFromWidth(breakpoints, width) {
const sorted = sortBreakpoints(breakpoints);
let matching = sorted[0];
if (matching === void 0) {
throw new Error("No breakpoints defined");
}
for (let i = 1; i < sorted.length; i++) {
const breakpointName = sorted[i];
if (breakpointName === void 0) continue;
const breakpointWidth = breakpoints[breakpointName];
if (width > breakpointWidth) {
matching = breakpointName;
}
}
return matching;
}
function getColsFromBreakpoint(breakpoint, cols) {
const colCount = cols[breakpoint];
if (colCount === void 0) {
throw new Error(
`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(breakpoint)} is missing!`
);
}
return colCount;
}
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactTypeOrCompactor) {
const existingLayout = layouts[breakpoint];
if (existingLayout) {
return cloneLayout(existingLayout);
}
let layout = layouts[lastBreakpoint];
const breakpointsSorted = sortBreakpoints(breakpoints);
const breakpointsAbove = breakpointsSorted.slice(
breakpointsSorted.indexOf(breakpoint)
);
for (let i = 0; i < breakpointsAbove.length; i++) {
const b = breakpointsAbove[i];
if (b === void 0) continue;
const layoutForBreakpoint = layouts[b];
if (layoutForBreakpoint) {
layout = layoutForBreakpoint;
break;
}
}
const clonedLayout = cloneLayout(layout || []);
const corrected = correctBounds(clonedLayout, { cols });
const compactor = typeof compactTypeOrCompactor === "object" && compactTypeOrCompactor !== null ? compactTypeOrCompactor : getCompactor(compactTypeOrCompactor);
return compactor.compact(corrected, cols);
}
function getIndentationValue(value, breakpoint) {
if (Array.isArray(value)) {
return value;
}
const breakpointMap = value;
const breakpointValue = breakpointMap[breakpoint];
if (breakpointValue !== void 0) {
return breakpointValue;
}
const keys = Object.keys(breakpointMap);
for (const key of keys) {
const v = breakpointMap[key];
if (v !== void 0) {
return v;
}
}
return [10, 10];
}
export { absoluteStrategy, applyPositionConstraints, applySizeConstraints, aspectRatio, boundedX, boundedY, compactItemHorizontal, compactItemVertical, containerBounds, createScaledStrategy, defaultConstraints, defaultDragConfig, defaultDropConfig, defaultGridConfig, defaultPositionStrategy, defaultResizeConfig, findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, getIndentationValue, gridBounds, horizontalCompactor, horizontalOverlapCompactor, maxSize, minMaxSize, minSize, noCompactor, noOverlapCompactor, perc, resizeItemInDirection, resolveCompactionCollision, setTopLeft, setTransform, snapToGrid, sortBreakpoints, transformStrategy, verticalCompactor, verticalOverlapCompactor };
import { verticalCompactor, sortBreakpoints, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout } from './chunk-KDANGDDL.mjs';
import { correctBounds, cloneLayout, getLayoutItem, cloneLayoutItem, moveElement, bottom } from './chunk-76RTO6EO.mjs';
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
import { deepEqual } from 'fast-equals';
function useContainerWidth(options = {}) {
const { measureBeforeMount = false, initialWidth = 1280 } = options;
const [width, setWidth] = useState(initialWidth);
const [mounted, setMounted] = useState(!measureBeforeMount);
const containerRef = useRef(null);
const observerRef = useRef(null);
const measureWidth = useCallback(() => {
const node = containerRef.current;
if (node) {
const newWidth = node.offsetWidth;
setWidth(newWidth);
if (!mounted) {
setMounted(true);
}
}
}, [mounted]);
useEffect(() => {
const node = containerRef.current;
if (!node) return;
measureWidth();
if (typeof ResizeObserver !== "undefined") {
let rafId = null;
observerRef.current = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry) {
const newWidth = entry.contentRect.width;
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
rafId = requestAnimationFrame(() => {
setWidth(newWidth);
rafId = null;
});
}
});
observerRef.current.observe(node);
return () => {
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
};
}
return () => {
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
};
}, [measureWidth]);
return {
width,
mounted,
containerRef,
measureWidth
};
}
function useGridLayout(options) {
const {
layout: propsLayout,
cols,
preventCollision = false,
onLayoutChange,
compactor = verticalCompactor
} = options;
const isDraggingRef = useRef(false);
const [layout, setLayoutState] = useState(() => {
const corrected = correctBounds(cloneLayout(propsLayout), { cols });
return compactor.compact(corrected, cols);
});
const [dragState, setDragState] = useState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
const [resizeState, setResizeState] = useState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
const [dropState, setDropState] = useState({
droppingDOMNode: null,
droppingPosition: null
});
const prevLayoutRef = useRef(layout);
const setLayout = useCallback(
(newLayout) => {
const corrected = correctBounds(cloneLayout(newLayout), { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[cols, compactor]
);
useEffect(() => {
if (isDraggingRef.current) return;
if (!deepEqual(propsLayout, prevLayoutRef.current)) {
setLayout(propsLayout);
}
}, [propsLayout, setLayout]);
useEffect(() => {
if (!deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
onLayoutChange?.(layout);
}
}, [layout, onLayoutChange]);
const onDragStart = useCallback(
(itemId, x, y) => {
const item = getLayoutItem(layout, itemId);
if (!item) return null;
isDraggingRef.current = true;
const placeholder = {
...cloneLayoutItem(item),
x,
y,
static: false,
moved: false
};
setDragState({
activeDrag: placeholder,
oldDragItem: cloneLayoutItem(item),
oldLayout: cloneLayout(layout)
});
return placeholder;
},
[layout]
);
const onDrag = useCallback(
(itemId, x, y) => {
const item = getLayoutItem(layout, itemId);
if (!item) return;
setDragState((prev) => ({
...prev,
activeDrag: prev.activeDrag ? { ...prev.activeDrag, x, y } : null
}));
const newLayout = moveElement(
layout,
item,
x,
y,
true,
// isUserAction
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onDragStop = useCallback(
(itemId, x, y) => {
const item = getLayoutItem(layout, itemId);
if (!item) return;
const newLayout = moveElement(
layout,
item,
x,
y,
true,
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
isDraggingRef.current = false;
setDragState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onResizeStart = useCallback(
(itemId) => {
const item = getLayoutItem(layout, itemId);
if (!item) return null;
setResizeState({
resizing: true,
oldResizeItem: cloneLayoutItem(item),
oldLayout: cloneLayout(layout)
});
return item;
},
[layout]
);
const onResize = useCallback(
(itemId, w, h, x, y) => {
const newLayout = layout.map((item) => {
if (item.i === itemId) {
const updated = {
...item,
w,
h
};
if (x !== void 0) updated.x = x;
if (y !== void 0) updated.y = y;
return updated;
}
return item;
});
const corrected = correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[layout, cols, compactor]
);
const onResizeStop = useCallback(
(itemId, w, h) => {
onResize(itemId, w, h);
setResizeState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
},
[onResize]
);
const onDropDragOver = useCallback(
(droppingItem, position) => {
const existingItem = getLayoutItem(layout, droppingItem.i);
if (!existingItem) {
const newLayout = [...layout, droppingItem];
const corrected = correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
}
setDropState({
droppingDOMNode: null,
// Will be set by component
droppingPosition: position
});
},
[layout, cols, compactor]
);
const onDropDragLeave = useCallback(() => {
const newLayout = layout.filter((item) => item.i !== "__dropping-elem__");
setLayoutState(newLayout);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
}, [layout]);
const onDrop = useCallback(
(droppingItem) => {
const newLayout = layout.map((item) => {
if (item.i === "__dropping-elem__") {
return {
...item,
i: droppingItem.i,
static: false
};
}
return item;
});
const corrected = correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
},
[layout, cols, compactor]
);
const containerHeight = useMemo(() => bottom(layout), [layout]);
const isInteracting = dragState.activeDrag !== null || resizeState.resizing || dropState.droppingPosition !== null;
return {
layout,
setLayout,
dragState,
resizeState,
dropState,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
onDropDragOver,
onDropDragLeave,
onDrop,
containerHeight,
isInteracting,
compactor
};
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
function useResponsiveLayout(options) {
const {
width,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
compactor = verticalCompactor,
onBreakpointChange,
onLayoutChange,
onWidthChange
} = options;
const sortedBreakpoints = useMemo(
() => sortBreakpoints(breakpoints),
[breakpoints]
);
const initialBreakpoint = useMemo(
() => getBreakpointFromWidth(breakpoints, width),
// Only calculate on mount, not on width changes
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
const initialCols = useMemo(
() => getColsFromBreakpoint(initialBreakpoint, colsConfig),
[initialBreakpoint, colsConfig]
);
const [breakpoint, setBreakpoint] = useState(initialBreakpoint);
const [cols, setCols] = useState(initialCols);
const [layouts, setLayoutsState] = useState(() => {
const cloned = {};
for (const bp of sortedBreakpoints) {
const layout2 = propsLayouts[bp];
if (layout2) {
cloned[bp] = cloneLayout(layout2);
}
}
return cloned;
});
const prevWidthRef = useRef(width);
const prevBreakpointRef = useRef(breakpoint);
const prevPropsLayoutsRef = useRef(propsLayouts);
const prevLayoutsRef = useRef(layouts);
const layout = useMemo(() => {
return findOrGenerateResponsiveLayout(
layouts,
breakpoints,
breakpoint,
prevBreakpointRef.current,
cols,
compactor
);
}, [layouts, breakpoints, breakpoint, cols, compactor]);
const setLayoutForBreakpoint = useCallback((bp, newLayout) => {
setLayoutsState((prev) => ({
...prev,
[bp]: cloneLayout(newLayout)
}));
}, []);
const setLayouts = useCallback((newLayouts) => {
const cloned = {};
for (const bp of Object.keys(newLayouts)) {
const layoutForBp = newLayouts[bp];
if (layoutForBp) {
cloned[bp] = cloneLayout(layoutForBp);
}
}
setLayoutsState(cloned);
}, []);
useEffect(() => {
if (prevWidthRef.current === width) return;
prevWidthRef.current = width;
const newBreakpoint = getBreakpointFromWidth(breakpoints, width);
const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);
onWidthChange?.(width, [10, 10], newCols, null);
if (newBreakpoint !== breakpoint) {
const newLayout = findOrGenerateResponsiveLayout(
layouts,
breakpoints,
newBreakpoint,
breakpoint,
newCols,
compactor
);
const updatedLayouts = {
...layouts,
[newBreakpoint]: newLayout
};
setLayoutsState(updatedLayouts);
setBreakpoint(newBreakpoint);
setCols(newCols);
onBreakpointChange?.(newBreakpoint, newCols);
prevBreakpointRef.current = newBreakpoint;
}
}, [
width,
breakpoints,
colsConfig,
breakpoint,
layouts,
compactor,
onBreakpointChange,
onWidthChange
]);
useEffect(() => {
if (!deepEqual(propsLayouts, prevPropsLayoutsRef.current)) {
setLayouts(propsLayouts);
prevPropsLayoutsRef.current = propsLayouts;
}
}, [propsLayouts, setLayouts]);
useEffect(() => {
if (!deepEqual(layouts, prevLayoutsRef.current)) {
prevLayoutsRef.current = layouts;
onLayoutChange?.(layout, layouts);
}
}, [layout, layouts, onLayoutChange]);
return {
layout,
layouts,
breakpoint,
cols,
setLayoutForBreakpoint,
setLayouts,
sortedBreakpoints
};
}
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout };
import { defaultConstraints, setTransform, setTopLeft, perc, applyPositionConstraints, resizeItemInDirection, applySizeConstraints, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout, getIndentationValue } from './chunk-KDANGDDL.mjs';
import { calcXYRaw, calcGridItemWHPx, clamp, calcGridColWidth, calcWHRaw, calcGridItemPosition, bottom, getLayoutItem, cloneLayoutItem, moveElement, withLayoutItem, getAllCollisions, calcXY, cloneLayout, correctBounds } from './chunk-76RTO6EO.mjs';
import React2, { useState, useRef, useMemo, useCallback, useEffect } from 'react';
import { DraggableCore } from 'react-draggable';
import { Resizable } from 'react-resizable';
import clsx from 'clsx';
import { jsx, jsxs } from 'react/jsx-runtime';
import { deepEqual } from 'fast-equals';
function GridItem(props) {
const {
children,
cols,
containerWidth,
margin,
containerPadding,
rowHeight,
maxRows,
isDraggable,
isResizable,
isBounded,
static: isStatic,
useCSSTransforms = true,
usePercentages = false,
transformScale = 1,
positionStrategy,
dragThreshold = 0,
droppingPosition,
className = "",
style,
handle = "",
cancel = "",
x,
y,
w,
h,
minW = 1,
maxW = Infinity,
minH = 1,
maxH = Infinity,
i,
resizeHandles,
resizeHandle,
constraints = defaultConstraints,
layoutItem,
layout = [],
onDragStart: onDragStartProp,
onDrag: onDragProp,
onDragStop: onDragStopProp,
onResizeStart: onResizeStartProp,
onResize: onResizeProp,
onResizeStop: onResizeStopProp
} = props;
const [dragging, setDragging] = useState(false);
const [resizing, setResizing] = useState(false);
const elementRef = useRef(null);
const dragPositionRef = useRef({ left: 0, top: 0 });
const resizePositionRef = useRef({
top: 0,
left: 0,
width: 0,
height: 0
});
const prevDroppingPositionRef = useRef(
void 0
);
const layoutRef = useRef(layout);
layoutRef.current = layout;
const onDragStartRef = useRef(null);
const onDragRef = useRef(null);
const dragPendingRef = useRef(false);
const initialDragClientRef = useRef({ x: 0, y: 0 });
const thresholdExceededRef = useRef(false);
const positionParams = useMemo(
() => ({
cols,
containerPadding,
containerWidth,
margin,
maxRows,
rowHeight
}),
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
);
const constraintContext = useMemo(
() => ({
cols,
maxRows,
containerWidth,
containerHeight: 0,
// Auto-height grids don't have a fixed container height
rowHeight,
margin,
// Use empty layout here - the actual layout will be accessed via layoutRef when needed
// This prevents the context from changing when layout changes, avoiding callback recreation
layout: []
}),
[cols, maxRows, containerWidth, rowHeight, margin]
);
const getConstraintContext = useCallback(
() => ({
...constraintContext,
layout: layoutRef.current
}),
[constraintContext]
);
const effectiveLayoutItem = useMemo(
() => layoutItem ?? {
i,
x,
y,
w,
h,
minW,
maxW,
minH,
maxH
},
[layoutItem, i, x, y, w, h, minW, maxW, minH, maxH]
);
const createStyle = useCallback(
(pos2) => {
if (positionStrategy?.calcStyle) {
return positionStrategy.calcStyle(pos2);
}
if (useCSSTransforms) {
return setTransform(pos2);
}
const styleObj = setTopLeft(pos2);
if (usePercentages) {
return {
...styleObj,
left: perc(pos2.left / containerWidth),
width: perc(pos2.width / containerWidth)
};
}
return styleObj;
},
[positionStrategy, useCSSTransforms, usePercentages, containerWidth]
);
const onDragStart = useCallback(
(e, { node }) => {
if (!onDragStartProp) return;
const { offsetParent } = node;
if (!offsetParent) return;
const parentRect = offsetParent.getBoundingClientRect();
const clientRect = node.getBoundingClientRect();
const cLeft = clientRect.left / transformScale;
const pLeft = parentRect.left / transformScale;
const cTop = clientRect.top / transformScale;
const pTop = parentRect.top / transformScale;
let newPosition;
if (positionStrategy?.calcDragPosition) {
const mouseEvent = e;
newPosition = positionStrategy.calcDragPosition(
mouseEvent.clientX,
mouseEvent.clientY,
mouseEvent.clientX - clientRect.left,
mouseEvent.clientY - clientRect.top
);
} else {
newPosition = {
left: cLeft - pLeft + offsetParent.scrollLeft,
top: cTop - pTop + offsetParent.scrollTop
};
}
dragPositionRef.current = newPosition;
if (dragThreshold > 0) {
const mouseEvent = e;
initialDragClientRef.current = {
x: mouseEvent.clientX,
y: mouseEvent.clientY
};
dragPendingRef.current = true;
thresholdExceededRef.current = false;
setDragging(true);
return;
}
setDragging(true);
const rawPos = calcXYRaw(
positionParams,
newPosition.top,
newPosition.left
);
const { x: newX, y: newY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStartProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStartProp,
transformScale,
positionParams,
positionStrategy,
dragThreshold,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
const onDrag = useCallback(
(e, { node, deltaX, deltaY }) => {
if (!onDragProp || !dragging) return;
const mouseEvent = e;
if (dragPendingRef.current && !thresholdExceededRef.current) {
const dx = mouseEvent.clientX - initialDragClientRef.current.x;
const dy = mouseEvent.clientY - initialDragClientRef.current.y;
const distance = Math.hypot(dx, dy);
if (distance < dragThreshold) {
return;
}
thresholdExceededRef.current = true;
dragPendingRef.current = false;
if (onDragStartProp) {
const rawPos2 = calcXYRaw(
positionParams,
dragPositionRef.current.top,
dragPositionRef.current.left
);
const { x: startX, y: startY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos2.x,
rawPos2.y,
getConstraintContext()
);
onDragStartProp(i, startX, startY, {
e,
node,
newPosition: dragPositionRef.current
});
}
}
let top = dragPositionRef.current.top + deltaY;
let left = dragPositionRef.current.left + deltaX;
if (isBounded) {
const { offsetParent } = node;
if (offsetParent) {
const bottomBoundary = offsetParent.clientHeight - calcGridItemWHPx(h, rowHeight, margin[1]);
top = clamp(top, 0, bottomBoundary);
const colWidth2 = calcGridColWidth(positionParams);
const rightBoundary = containerWidth - calcGridItemWHPx(w, colWidth2, margin[0]);
left = clamp(left, 0, rightBoundary);
}
}
const newPosition = { top, left };
dragPositionRef.current = newPosition;
const rawPos = calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragProp,
onDragStartProp,
dragging,
dragThreshold,
isBounded,
h,
rowHeight,
margin,
positionParams,
containerWidth,
w,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const onDragStop = useCallback(
(e, { node }) => {
if (!onDragStopProp || !dragging) return;
const wasPending = dragPendingRef.current;
dragPendingRef.current = false;
thresholdExceededRef.current = false;
initialDragClientRef.current = { x: 0, y: 0 };
if (wasPending) {
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
return;
}
const { left, top } = dragPositionRef.current;
const newPosition = { top, left };
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
const rawPos = calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStopProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStopProp,
dragging,
positionParams,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
onDragStartRef.current = onDragStart;
onDragRef.current = onDrag;
const onResizeHandler = useCallback(
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
if (!handler) return;
let updatedSize;
if (node) {
updatedSize = resizeItemInDirection(
resizeHandle2,
position,
size,
containerWidth
);
} else {
updatedSize = {
...size,
top: position.top,
left: position.left
};
}
resizePositionRef.current = updatedSize;
const rawSize = calcWHRaw(
positionParams,
updatedSize.width,
updatedSize.height
);
const { w: newW, h: newH } = applySizeConstraints(
constraints,
effectiveLayoutItem,
rawSize.w,
rawSize.h,
resizeHandle2,
getConstraintContext()
);
handler(i, newW, newH, {
e: e.nativeEvent,
node,
size: updatedSize,
handle: resizeHandle2
});
},
[
onResizeStartProp,
onResizeProp,
onResizeStopProp,
containerWidth,
positionParams,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const handleResizeStart = useCallback(
(e, data) => {
setResizing(true);
const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStart");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResize = useCallback(
(e, data) => {
const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResize");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResizeStop = useCallback(
(e, data) => {
setResizing(false);
resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStop");
},
[onResizeHandler, positionParams, x, y, w, h]
);
useEffect(() => {
if (!droppingPosition) return;
const node = elementRef.current;
if (!node) return;
const prevDroppingPosition = prevDroppingPositionRef.current || {
left: 0,
top: 0
};
const shouldDrag = dragging && (droppingPosition.left !== prevDroppingPosition.left || droppingPosition.top !== prevDroppingPosition.top);
if (!dragging) {
const fakeData = {
node,
deltaX: droppingPosition.left,
deltaY: droppingPosition.top,
lastX: 0,
lastY: 0,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragStartRef.current?.(
droppingPosition.e,
fakeData
);
} else if (shouldDrag) {
const deltaX = droppingPosition.left - dragPositionRef.current.left;
const deltaY = droppingPosition.top - dragPositionRef.current.top;
const fakeData = {
node,
deltaX,
deltaY,
lastX: dragPositionRef.current.left,
lastY: dragPositionRef.current.top,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragRef.current?.(
droppingPosition.e,
fakeData
);
}
prevDroppingPositionRef.current = droppingPosition;
}, [droppingPosition, dragging, i]);
const pos = calcGridItemPosition(
positionParams,
x,
y,
w,
h,
dragging ? dragPositionRef.current : null,
resizing ? resizePositionRef.current : null
);
const child = React2.Children.only(children);
const colWidth = calcGridColWidth(positionParams);
const minConstraints = [
calcGridItemWHPx(minW, colWidth, margin[0]),
calcGridItemWHPx(minH, rowHeight, margin[1])
];
const maxConstraints = [
calcGridItemWHPx(maxW, colWidth, margin[0]),
calcGridItemWHPx(maxH, rowHeight, margin[1])
];
const childProps = child.props;
const childClassName = childProps["className"];
const childStyle = childProps["style"];
let newChild = React2.cloneElement(child, {
ref: elementRef,
className: clsx("react-grid-item", childClassName, className, {
static: isStatic,
resizing,
"react-draggable": isDraggable,
"react-draggable-dragging": dragging,
dropping: Boolean(droppingPosition),
cssTransforms: useCSSTransforms
}),
style: {
...style,
...childStyle,
...createStyle(pos)
}
});
const resizableHandle = resizeHandle;
newChild = /* @__PURE__ */ jsx(
Resizable,
{
draggableOpts: { disabled: !isResizable },
className: isResizable ? void 0 : "react-resizable-hide",
width: pos.width,
height: pos.height,
minConstraints,
maxConstraints,
onResizeStart: handleResizeStart,
onResize: handleResize,
onResizeStop: handleResizeStop,
transformScale,
resizeHandles,
handle: resizableHandle,
children: newChild
}
);
newChild = /* @__PURE__ */ jsx(
DraggableCore,
{
disabled: !isDraggable,
onStart: onDragStart,
onDrag,
onStop: onDragStop,
handle,
cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
scale: transformScale,
nodeRef: elementRef,
children: newChild
}
);
return newChild;
}
var noop = () => {
};
var layoutClassName = "react-grid-layout";
var isFirefox = false;
try {
isFirefox = /firefox/i.test(navigator.userAgent);
} catch {
}
function childrenEqual(a, b) {
const aArr = React2.Children.toArray(a);
const bArr = React2.Children.toArray(b);
if (aArr.length !== bArr.length) return false;
for (let i = 0; i < aArr.length; i++) {
const aChild = aArr[i];
const bChild = bArr[i];
if (aChild?.key !== bChild?.key) return false;
}
return true;
}
function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
const layout = [];
const childKeys = /* @__PURE__ */ new Set();
React2.Children.forEach(children, (child) => {
if (!React2.isValidElement(child) || child.key === null) return;
const key = String(child.key);
childKeys.add(key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push(cloneLayoutItem(existingItem));
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function GridLayout(props) {
const {
// Required
children,
width,
// Composable config interfaces
gridConfig: gridConfigProp,
dragConfig: dragConfigProp,
resizeConfig: resizeConfigProp,
dropConfig: dropConfigProp,
positionStrategy = defaultPositionStrategy,
compactor: compactorProp,
constraints = defaultConstraints,
// Layout data
layout: propsLayout = [],
droppingItem: droppingItemProp,
// Container props
autoSize = true,
className = "",
style = {},
innerRef,
// Callbacks
onLayoutChange = noop,
onDragStart: onDragStartProp = noop,
onDrag: onDragProp = noop,
onDragStop: onDragStopProp = noop,
onResizeStart: onResizeStartProp = noop,
onResize: onResizeProp = noop,
onResizeStop: onResizeStopProp = noop,
onDrop: onDropProp = noop,
onDropDragOver: onDropDragOverProp = noop
} = props;
const gridConfig = useMemo(
() => ({ ...defaultGridConfig, ...gridConfigProp }),
[gridConfigProp]
);
const dragConfig = useMemo(
() => ({ ...defaultDragConfig, ...dragConfigProp }),
[dragConfigProp]
);
const resizeConfig = useMemo(
() => ({ ...defaultResizeConfig, ...resizeConfigProp }),
[resizeConfigProp]
);
const dropConfig = useMemo(
() => ({ ...defaultDropConfig, ...dropConfigProp }),
[dropConfigProp]
);
const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
const {
enabled: isDraggable,
bounded: isBounded,
handle: draggableHandle,
cancel: draggableCancel,
threshold: dragThreshold
} = dragConfig;
const {
enabled: isResizable,
handles: resizeHandles,
handleComponent: resizeHandle
} = resizeConfig;
const {
enabled: isDroppable,
defaultItem: defaultDropItem,
onDragOver: dropConfigOnDragOver
} = dropConfig;
const compactor = compactorProp ?? getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const preventCollision = compactor.preventCollision ?? false;
const droppingItem = useMemo(
() => droppingItemProp ?? {
i: "__dropping-elem__",
...defaultDropItem
},
[droppingItemProp, defaultDropItem]
);
const useCSSTransforms = positionStrategy.type === "transform";
const transformScale = positionStrategy.scale;
const effectiveContainerPadding = containerPadding ?? margin;
const [mounted, setMounted] = useState(false);
const [layout, setLayout] = useState(
() => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor)
);
const [activeDrag, setActiveDrag] = useState(null);
const [resizing, setResizing] = useState(false);
const [droppingDOMNode, setDroppingDOMNode] = useState(
null
);
const [droppingPosition, setDroppingPosition] = useState();
const oldDragItemRef = useRef(null);
const oldResizeItemRef = useRef(null);
const oldLayoutRef = useRef(null);
const dragEnterCounterRef = useRef(0);
const prevLayoutRef = useRef(layout);
const prevPropsLayoutRef = useRef(propsLayout);
const prevChildrenRef = useRef(children);
const prevCompactTypeRef = useRef(compactType);
const layoutRef = useRef(layout);
layoutRef.current = layout;
useEffect(() => {
setMounted(true);
if (!deepEqual(layout, propsLayout)) {
onLayoutChange(layout);
}
}, []);
useEffect(() => {
if (activeDrag) return;
if (droppingDOMNode) return;
const layoutChanged = !deepEqual(propsLayout, prevPropsLayoutRef.current);
const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
const compactTypeChanged = compactType !== prevCompactTypeRef.current;
if (layoutChanged || childrenChanged || compactTypeChanged) {
const baseLayout = layoutChanged ? propsLayout : layout;
const newLayout = synchronizeLayoutWithChildren(
baseLayout,
children,
cols,
compactor
);
if (!deepEqual(newLayout, layout)) {
setLayout(newLayout);
}
}
prevPropsLayoutRef.current = propsLayout;
prevChildrenRef.current = children;
prevCompactTypeRef.current = compactType;
}, [
propsLayout,
children,
cols,
compactType,
compactor,
activeDrag,
droppingDOMNode,
layout
]);
useEffect(() => {
if (!activeDrag && !deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
const publicLayout = layout.filter((l) => l.i !== droppingItem.i);
onLayoutChange(publicLayout);
}
}, [layout, activeDrag, onLayoutChange, droppingItem.i]);
const containerHeight = useMemo(() => {
if (!autoSize) return void 0;
const nbRow = bottom(layout);
const containerPaddingY = effectiveContainerPadding[1];
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
}, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
const onDragStart = useCallback(
(i, _x, _y, data) => {
const currentLayout = layoutRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
oldDragItemRef.current = cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setActiveDrag(placeholder);
onDragStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onDragStartProp]
);
const onDrag = useCallback(
(i, x, y, data) => {
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
const newLayout = moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
setLayout(compactor.compact(newLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
);
const onDragStop = useCallback(
(i, x, y, data) => {
if (!activeDrag) return;
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
const newLayout = moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
const finalLayout = compactor.compact(newLayout, cols);
onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
const oldLayout = oldLayoutRef.current;
oldDragItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setLayout(finalLayout);
if (oldLayout && !deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[
activeDrag,
preventCollision,
compactType,
cols,
allowOverlap,
compactor,
onDragStopProp,
onLayoutChange
]
);
const onResizeStart = useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
oldResizeItemRef.current = cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setResizing(true);
onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onResizeStartProp]
);
const onResize = useCallback(
(i, w, h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const { handle } = data;
let shouldMoveItem = false;
let newX;
let newY;
const [newLayout, l] = withLayoutItem(currentLayout, i, (item) => {
newX = item.x;
newY = item.y;
if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
if (["sw", "nw", "w"].includes(handle)) {
newX = item.x + (item.w - w);
w = item.x !== newX && newX < 0 ? item.w : w;
newX = newX < 0 ? 0 : newX;
}
if (["ne", "n", "nw"].includes(handle)) {
newY = item.y + (item.h - h);
h = item.y !== newY && newY < 0 ? item.h : h;
newY = newY < 0 ? 0 : newY;
}
shouldMoveItem = true;
}
if (preventCollision && !allowOverlap) {
const collisions = getAllCollisions(currentLayout, {
...item,
w,
h,
x: newX ?? item.x,
y: newY ?? item.y
}).filter((layoutItem) => layoutItem.i !== item.i);
if (collisions.length > 0) {
newY = item.y;
h = item.h;
newX = item.x;
w = item.w;
shouldMoveItem = false;
}
}
item.w = w;
item.h = h;
return item;
});
if (!l) return;
let finalLayout = newLayout;
if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
finalLayout = moveElement(
newLayout,
l,
newX,
newY,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
}
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i,
static: true
};
onResizeProp(
finalLayout,
oldResizeItem,
l,
placeholder,
data.e,
data.node
);
setLayout(compactor.compact(finalLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
);
const onResizeStop = useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const l = getLayoutItem(currentLayout, i);
const finalLayout = compactor.compact(currentLayout, cols);
onResizeStopProp(
finalLayout,
oldResizeItem,
l ?? null,
null,
data.e,
data.node
);
const oldLayout = oldLayoutRef.current;
oldResizeItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setResizing(false);
setLayout(finalLayout);
if (oldLayout && !deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[cols, compactor, onResizeStopProp, onLayoutChange]
);
const removeDroppingPlaceholder = useCallback(() => {
const currentLayout = layoutRef.current;
const hasDroppingItem = currentLayout.some((l) => l.i === droppingItem.i);
if (!hasDroppingItem) {
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
return;
}
const newLayout = compactor.compact(
currentLayout.filter((l) => l.i !== droppingItem.i),
cols
);
setLayout(newLayout);
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
}, [droppingItem.i, cols, compactor]);
const handleDragOver = useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
if (isFirefox && !e.nativeEvent.target?.classList.contains(
layoutClassName
)) {
return false;
}
const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
if (rawResult === false) {
if (droppingDOMNode) {
removeDroppingPlaceholder();
}
return false;
}
const {
dragOffsetX = 0,
dragOffsetY = 0,
...onDragOverResult
} = rawResult ?? {};
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
const gridRect = e.currentTarget.getBoundingClientRect();
const positionParams = {
cols,
margin,
maxRows,
rowHeight,
containerWidth: width,
containerPadding: effectiveContainerPadding
};
const actualColWidth = calcGridColWidth(positionParams);
const itemPixelWidth = calcGridItemWHPx(
finalDroppingItem.w,
actualColWidth,
margin[0]
);
const itemPixelHeight = calcGridItemWHPx(
finalDroppingItem.h,
rowHeight,
margin[1]
);
const itemCenterOffsetX = itemPixelWidth / 2;
const itemCenterOffsetY = itemPixelHeight / 2;
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
const clampedGridX = Math.max(0, rawGridX);
const clampedGridY = Math.max(0, rawGridY);
const newDroppingPosition = {
left: clampedGridX / transformScale,
top: clampedGridY / transformScale,
e: e.nativeEvent
};
if (!droppingDOMNode) {
const calculatedPosition = calcXY(
positionParams,
clampedGridY,
clampedGridX,
finalDroppingItem.w,
finalDroppingItem.h
);
setDroppingDOMNode(/* @__PURE__ */ jsx("div", {}, finalDroppingItem.i));
setDroppingPosition(newDroppingPosition);
const baseLayout = layoutRef.current.filter(
(l) => l.i !== finalDroppingItem.i
);
setLayout([
...baseLayout,
{
...finalDroppingItem,
x: calculatedPosition.x,
y: calculatedPosition.y,
static: false,
isDraggable: true
}
]);
} else if (droppingPosition) {
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
if (shouldUpdate) {
setDroppingPosition(newDroppingPosition);
}
}
},
[
droppingDOMNode,
droppingPosition,
droppingItem,
dropConfigOnDragOver,
onDropDragOverProp,
removeDroppingPlaceholder,
transformScale,
cols,
margin,
maxRows,
rowHeight,
width,
effectiveContainerPadding
]
);
const handleDragLeave = useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current--;
if (dragEnterCounterRef.current < 0) {
dragEnterCounterRef.current = 0;
}
if (dragEnterCounterRef.current === 0) {
removeDroppingPlaceholder();
}
},
[removeDroppingPlaceholder]
);
const handleDragEnter = useCallback((e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current++;
}, []);
const handleDrop = useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
const currentLayout = layoutRef.current;
const item = currentLayout.find((l) => l.i === droppingItem.i);
dragEnterCounterRef.current = 0;
removeDroppingPlaceholder();
onDropProp(currentLayout, item, e.nativeEvent);
},
[droppingItem.i, removeDroppingPlaceholder, onDropProp]
);
const processGridItem = useCallback(
(child, isDroppingItem) => {
if (!child || !child.key) return null;
const l = getLayoutItem(layout, String(child.key));
if (!l) return null;
const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
const resizeHandlesOptions = l.resizeHandles || [...resizeHandles];
const bounded = draggable && isBounded && l.isBounded !== false;
const resizeHandleElement = resizeHandle;
return /* @__PURE__ */ jsx(
GridItem,
{
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
cancel: draggableCancel,
handle: draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable: draggable,
isResizable: resizable,
isBounded: bounded,
useCSSTransforms: useCSSTransforms && mounted,
usePercentages: !mounted,
transformScale,
positionStrategy,
dragThreshold,
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i: l.i,
minH: l.minH,
minW: l.minW,
maxH: l.maxH,
maxW: l.maxW,
static: l.static,
droppingPosition: isDroppingItem ? droppingPosition : void 0,
resizeHandles: resizeHandlesOptions,
resizeHandle: resizeHandleElement,
constraints,
layoutItem: l,
layout,
children: child
},
l.i
);
},
[
layout,
width,
cols,
margin,
effectiveContainerPadding,
maxRows,
rowHeight,
draggableCancel,
draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable,
isResizable,
isBounded,
useCSSTransforms,
mounted,
transformScale,
positionStrategy,
dragThreshold,
droppingPosition,
resizeHandles,
resizeHandle,
constraints
]
);
const renderPlaceholder = () => {
if (!activeDrag) return null;
return /* @__PURE__ */ jsx(
GridItem,
{
w: activeDrag.w,
h: activeDrag.h,
x: activeDrag.x,
y: activeDrag.y,
i: activeDrag.i,
className: `react-grid-placeholder ${resizing ? "placeholder-resizing" : ""}`,
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
isDraggable: false,
isResizable: false,
isBounded: false,
useCSSTransforms,
transformScale,
constraints,
layout,
children: /* @__PURE__ */ jsx("div", {})
}
);
};
const mergedClassName = clsx(layoutClassName, className);
const mergedStyle = {
height: containerHeight,
...style
};
return /* @__PURE__ */ jsxs(
"div",
{
ref: innerRef,
className: mergedClassName,
style: mergedStyle,
onDrop: isDroppable ? handleDrop : void 0,
onDragLeave: isDroppable ? handleDragLeave : void 0,
onDragEnter: isDroppable ? handleDragEnter : void 0,
onDragOver: isDroppable ? handleDragOver : void 0,
children: [
React2.Children.map(children, (child) => {
if (!React2.isValidElement(child)) return null;
return processGridItem(child);
}),
isDroppable && droppingDOMNode && processGridItem(droppingDOMNode, true),
renderPlaceholder()
]
}
);
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
var noop2 = () => {
};
function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor) {
const layout = [];
React2.Children.forEach(children, (child) => {
if (!React2.isValidElement(child) || child.key === null) return;
const key = String(child.key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push({
...existingItem,
i: key
});
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function ResponsiveGridLayout(props) {
const {
children,
width,
breakpoint: propBreakpoint,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
rowHeight = 150,
maxRows = Infinity,
margin: propMargin = [10, 10],
containerPadding: propContainerPadding = null,
compactor: compactorProp,
onBreakpointChange = noop2,
onLayoutChange = noop2,
onWidthChange = noop2,
...restProps
} = props;
const compactor = compactorProp ?? getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const initialBreakpoint = useMemo(() => {
return propBreakpoint ?? getBreakpointFromWidth(breakpoints, width);
}, []);
const initialCols = useMemo(() => {
return getColsFromBreakpoint(initialBreakpoint, colsConfig);
}, [initialBreakpoint, colsConfig]);
const initialLayout = useMemo(() => {
return findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
initialBreakpoint,
initialBreakpoint,
initialCols,
compactType
);
}, []);
const [breakpoint, setBreakpoint] = useState(initialBreakpoint);
const [cols, setCols] = useState(initialCols);
const [layout, setLayout] = useState(initialLayout);
const [layouts, setLayouts] = useState(propsLayouts);
const prevWidthRef = useRef(width);
const prevBreakpointRef = useRef(propBreakpoint);
const prevBreakpointsRef = useRef(breakpoints);
const prevColsRef = useRef(colsConfig);
const prevLayoutsRef = useRef(propsLayouts);
const prevCompactTypeRef = useRef(compactType);
const layoutsRef = useRef(layouts);
useEffect(() => {
layoutsRef.current = layouts;
}, [layouts]);
const derivedLayout = useMemo(() => {
if (!deepEqual(propsLayouts, prevLayoutsRef.current)) {
return findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
breakpoint,
breakpoint,
cols,
compactor
);
}
return null;
}, [propsLayouts, breakpoints, breakpoint, cols, compactor]);
const effectiveLayout = derivedLayout ?? layout;
useEffect(() => {
if (derivedLayout !== null) {
setLayout(derivedLayout);
setLayouts(propsLayouts);
layoutsRef.current = propsLayouts;
prevLayoutsRef.current = propsLayouts;
}
}, [derivedLayout, propsLayouts]);
useEffect(() => {
if (compactType !== prevCompactTypeRef.current) {
const newLayout = compactor.compact(cloneLayout(effectiveLayout), cols);
const newLayouts = {
...layoutsRef.current,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
prevCompactTypeRef.current = compactType;
}
}, [
compactType,
compactor,
effectiveLayout,
cols,
allowOverlap,
breakpoint,
onLayoutChange
]);
useEffect(() => {
const widthChanged = width !== prevWidthRef.current;
const breakpointPropChanged = propBreakpoint !== prevBreakpointRef.current;
const breakpointsChanged = !deepEqual(
breakpoints,
prevBreakpointsRef.current
);
const colsChanged = !deepEqual(colsConfig, prevColsRef.current);
if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
const newBreakpoint = propBreakpoint ?? getBreakpointFromWidth(breakpoints, width);
const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);
const lastBreakpoint = breakpoint;
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
const newLayouts = { ...layoutsRef.current };
if (!newLayouts[lastBreakpoint]) {
newLayouts[lastBreakpoint] = cloneLayout(layout);
}
let newLayout = findOrGenerateResponsiveLayout(
newLayouts,
breakpoints,
newBreakpoint,
lastBreakpoint,
newCols,
compactor
);
newLayout = synchronizeLayoutWithChildren2(
newLayout,
children,
newCols,
compactor
);
newLayouts[newBreakpoint] = newLayout;
setBreakpoint(newBreakpoint);
setCols(newCols);
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onBreakpointChange(newBreakpoint, newCols);
onLayoutChange(newLayout, newLayouts);
}
const currentMargin2 = getIndentationValue(
propMargin,
newBreakpoint
);
const currentPadding = propContainerPadding ? getIndentationValue(
propContainerPadding,
newBreakpoint
) : null;
onWidthChange(width, currentMargin2, newCols, currentPadding);
prevWidthRef.current = width;
prevBreakpointRef.current = propBreakpoint;
prevBreakpointsRef.current = breakpoints;
prevColsRef.current = colsConfig;
}
}, [
width,
propBreakpoint,
breakpoints,
colsConfig,
breakpoint,
cols,
layout,
children,
compactor,
compactType,
allowOverlap,
propMargin,
propContainerPadding,
onBreakpointChange,
onLayoutChange,
onWidthChange
]);
const handleLayoutChange = useCallback(
(newLayout) => {
const currentLayouts = layoutsRef.current;
const newLayouts = {
...currentLayouts,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
},
[breakpoint, onLayoutChange]
);
const currentMargin = useMemo(() => {
return getIndentationValue(
propMargin,
breakpoint
);
}, [propMargin, breakpoint]);
const currentContainerPadding = useMemo(() => {
if (propContainerPadding === null) return null;
return getIndentationValue(
propContainerPadding,
breakpoint
);
}, [propContainerPadding, breakpoint]);
const gridConfig = useMemo(
() => ({
cols,
rowHeight,
maxRows,
margin: currentMargin,
containerPadding: currentContainerPadding
}),
[cols, rowHeight, maxRows, currentMargin, currentContainerPadding]
);
return /* @__PURE__ */ jsx(
GridLayout,
{
...restProps,
width,
gridConfig,
compactor,
onLayoutChange: handleLayoutChange,
layout: effectiveLayout,
children
}
);
}
export { GridItem, GridLayout, ResponsiveGridLayout };
'use strict';
import { L as Layout, d as LayoutItem, C as CompactType, M as Mutable, b as Compactor, P as Position, p as PositionStrategy, R as ResizeHandleAxis } from './types-jd8MiKM1.mjs';
/**
* Core layout manipulation utilities.
*
* These functions create, modify, and query grid layouts.
* All functions treat layouts as immutable - they return new arrays/objects.
*/
/**
* Get the bottom-most Y coordinate of the layout.
*
* This is the Y position plus height of the lowest item.
*
* @param layout - Layout to measure
* @returns The bottom Y coordinate (0 if layout is empty)
*/
declare function bottom(layout: Layout): number;
/**
* Get a layout item by its ID.
*
* @param layout - Layout to search
* @param id - Item ID to find
* @returns The layout item, or undefined if not found
*/
declare function getLayoutItem(layout: Layout, id: string): LayoutItem | undefined;
/**
* Get all static items from the layout.
*
* Static items cannot be moved or resized by the user.
*
* @param layout - Layout to filter
* @returns Array of static layout items
*/
declare function getStatics(layout: Layout): LayoutItem[];
/**
* Clone a layout item.
*
* Creates a shallow copy with all properties preserved.
* Boolean properties are normalized (undefined becomes false).
*
* @param layoutItem - Item to clone
* @returns A new layout item with the same properties
*/
declare function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem;
/**
* Clone an entire layout.
*
* Creates a new array with cloned items.
*
* @param layout - Layout to clone
* @returns A new layout with cloned items
*/
declare function cloneLayout(layout: Layout): LayoutItem[];
/**
* Replace a layout item in a layout.
*
* Returns a new layout with the item replaced. Other items are not cloned.
*
* @param layout - Layout to modify
* @param layoutItem - New item (matched by `i` property)
* @returns New layout with the item replaced
*/
declare function modifyLayout(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Apply a transformation to a layout item.
*
* Finds the item by key, clones it, applies the callback, and returns
* a new layout with the modified item.
*
* @param layout - Layout to modify
* @param itemKey - Key of the item to modify
* @param cb - Callback that receives the cloned item and returns the modified item
* @returns Tuple of [new layout, modified item or null if not found]
*/
declare function withLayoutItem(layout: Layout, itemKey: string, cb: (item: LayoutItem) => LayoutItem): [LayoutItem[], LayoutItem | null];
/**
* Ensure all layout items fit within the grid bounds.
*
* - Items overflowing right are moved left
* - Items overflowing left are moved to x=0 and clamped to grid width
* - Static items that collide with other statics are moved down
*
* **IMPORTANT**: This function mutates the layout items in place for performance.
* The type signature uses `Mutable<LayoutItem>[]` to make this explicit.
* Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.
*
* @param layout - Layout to correct (items WILL be mutated)
* @param bounds - Grid bounds
* @returns The same layout array (for chaining)
*/
declare function correctBounds(layout: Mutable<LayoutItem>[], bounds: {
cols: number;
}): LayoutItem[];
/**
* Move a layout element to a new position.
*
* Handles collision detection and cascading movements.
* Does not compact the layout - call `compact()` separately.
*
* **Note**: This function mutates the `l` parameter directly for performance.
* The item's x, y, and moved properties will be modified. Callers should
* ideally pass a cloned item if they need to preserve the original.
*
* @param layout - Full layout
* @param l - Item to move (will be mutated)
* @param x - New X position (or undefined to keep current)
* @param y - New Y position (or undefined to keep current)
* @param isUserAction - True if this is a direct user action (affects collision resolution)
* @param preventCollision - True to block movement into occupied space (item snaps back). No effect if allowOverlap is true.
* @param compactType - Compaction type for collision resolution
* @param cols - Number of columns in the grid
* @param allowOverlap - True to allow items to stack on top of each other
* @returns The updated layout
*/
declare function moveElement(layout: Layout, l: LayoutItem, x: number | undefined, y: number | undefined, isUserAction: boolean | undefined, preventCollision: boolean | undefined, compactType: CompactType, cols: number, allowOverlap?: boolean): LayoutItem[];
/**
* Move an item away from a collision.
*
* Attempts to move the item up/left first if there's room,
* otherwise moves it down/right.
*
* @param layout - Full layout
* @param collidesWith - The item being collided with
* @param itemToMove - The item to move away
* @param isUserAction - True if this is a direct user action
* @param compactType - Compaction type
* @param cols - Number of columns
* @returns Updated layout
*/
declare function moveElementAwayFromCollision(layout: Layout, collidesWith: LayoutItem, itemToMove: LayoutItem, isUserAction: boolean | undefined, compactType: CompactType, cols: number): LayoutItem[];
/**
* Validate that a layout has the required properties.
*
* @param layout - Layout to validate
* @param contextName - Name for error messages
* @throws Error if layout is invalid
*/
declare function validateLayout(layout: Layout, contextName?: string): void;
/**
* Compactor implementations.
*
* Compactors are pluggable strategies for removing gaps between grid items.
* Use the Compactor interface to create custom compaction algorithms.
*/
/**
* Resolve a compaction collision by moving items.
*
* Before moving an item to a position, checks if that movement would
* cause collisions and recursively moves those items first.
*
* Useful for implementing custom compactors.
*
* @param layout - Full layout (must be sorted for optimization)
* @param item - Item being moved (will be mutated)
* @param moveToCoord - Target coordinate
* @param axis - Which axis to move on ('x' or 'y')
* @param hasStatics - Whether layout contains static items (disables early break optimization)
*/
declare function resolveCompactionCollision(layout: Layout, item: LayoutItem, moveToCoord: number, axis: "x" | "y", hasStatics?: boolean): void;
/**
* Compact a single item vertically (move up).
*
* Moves the item as far up as possible without colliding.
* Useful for implementing custom vertical compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param fullLayout - Full layout for collision resolution
* @param maxY - Maximum Y to start from
* @returns The compacted item
*/
declare function compactItemVertical(compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number): LayoutItem;
/**
* Compact a single item horizontally (move left).
*
* Moves the item as far left as possible without colliding.
* Wraps to the next row if it overflows.
* Useful for implementing custom horizontal compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param cols - Number of columns in the grid
* @param fullLayout - Full layout for collision resolution
* @returns The compacted item
*/
declare function compactItemHorizontal(compareWith: Layout, l: LayoutItem, cols: number, fullLayout: Layout): LayoutItem;
/**
* Vertical compactor - moves items up to fill gaps.
*
* Items are sorted by row then column, and each item is moved
* as far up as possible without overlapping other items.
*
* This is the default compaction mode for react-grid-layout.
*/
declare const verticalCompactor: Compactor;
/**
* Horizontal compactor - moves items left to fill gaps.
*
* Items are sorted by column then row, and each item is moved
* as far left as possible without overlapping other items.
*/
declare const horizontalCompactor: Compactor;
/**
* No compaction - items stay where placed.
*
* Use this for free-form layouts where items can be placed anywhere.
* Items will not automatically move to fill gaps.
*/
declare const noCompactor: Compactor;
/**
* Vertical compactor that allows overlapping items.
*
* Items compact upward but are allowed to overlap each other.
* Useful for layered layouts or when collision detection is handled externally.
*/
declare const verticalOverlapCompactor: Compactor;
/**
* Horizontal compactor that allows overlapping items.
*/
declare const horizontalOverlapCompactor: Compactor;
/**
* No compaction, with overlapping allowed.
*
* Items stay where placed and can overlap each other.
*/
declare const noOverlapCompactor: Compactor;
/**
* Get a compactor by type.
*
* This is a convenience function for backwards compatibility with the
* string-based compactType API.
*
* Note: For 'wrap' mode, import `wrapCompactor` from 'react-grid-layout/extras'
* and pass it directly to the `compactor` prop. This function returns
* `noCompactor` for 'wrap' type since the wrap compactor is tree-shakeable.
*
* @param compactType - 'vertical', 'horizontal', 'wrap', or null
* @param allowOverlap - Whether to allow overlapping items
* @returns The appropriate Compactor
*/
declare function getCompactor(compactType: CompactType, allowOverlap?: boolean, preventCollision?: boolean): Compactor;
/**
* Position calculation utilities.
*
* These functions convert between grid units and pixel positions,
* and generate CSS styles for grid items.
*/
/**
* Generate CSS transform-based positioning styles.
*
* Using transforms is more performant than top/left positioning
* because it doesn't trigger layout recalculations.
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTransform({ top, left, width, height }: Position): Record<string, string>;
/**
* Generate CSS top/left positioning styles.
*
* Use this when transforms are not suitable (e.g., for printing
* or when transform causes issues with child elements).
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTopLeft({ top, left, width, height }: Position): Record<string, string>;
/**
* Convert a number to a percentage string.
*
* @param num - Number to convert (0-1 range typically)
* @returns Percentage string (e.g., "50%")
*/
declare function perc(num: number): string;
/**
* Resize an item in a specific direction, clamping to container bounds.
*
* This handles the complex logic of resizing from different edges/corners,
* ensuring the item doesn't overflow the container.
*
* @param direction - Which edge/corner is being dragged
* @param currentSize - Current position and size
* @param newSize - Requested new position and size
* @param containerWidth - Width of the container
* @returns Constrained position and size
*/
declare function resizeItemInDirection(direction: ResizeHandleAxis, currentSize: Position, newSize: Position, containerWidth: number): Position;
/**
* CSS transform-based positioning strategy.
*
* Uses CSS transforms for positioning, which is more performant
* as it doesn't trigger layout recalculations.
*
* This is the default strategy.
*/
declare const transformStrategy: PositionStrategy;
/**
* Absolute (top/left) positioning strategy.
*
* Uses CSS top/left for positioning. Use this when CSS transforms
* cause issues (e.g., printing, certain child element positioning).
*/
declare const absoluteStrategy: PositionStrategy;
/**
* Create a scaled transform strategy.
*
* Use this when the grid container is inside a scaled element
* (e.g., `transform: scale(0.5)`). The scale factor adjusts
* drag/resize calculations to account for the parent transform.
*
* @param scale - Scale factor (e.g., 0.5 for half size)
* @returns Position strategy with scaled calculations
*
* @example
* ```tsx
* <div style={{ transform: 'scale(0.5)' }}>
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* </div>
* ```
*/
declare function createScaledStrategy(scale: number): PositionStrategy;
/** Default position strategy (transform-based) */
declare const defaultPositionStrategy: PositionStrategy;
export { transformStrategy as A, verticalOverlapCompactor as B, withLayoutItem as C, cloneLayoutItem as a, bottom as b, cloneLayout as c, getLayoutItem as d, setTransform as e, verticalCompactor as f, getCompactor as g, horizontalCompactor as h, absoluteStrategy as i, compactItemHorizontal as j, compactItemVertical as k, correctBounds as l, moveElement as m, noCompactor as n, createScaledStrategy as o, defaultPositionStrategy as p, getStatics as q, horizontalOverlapCompactor as r, setTopLeft as s, modifyLayout as t, moveElementAwayFromCollision as u, validateLayout as v, noOverlapCompactor as w, perc as x, resizeItemInDirection as y, resolveCompactionCollision as z };
import { L as Layout, d as LayoutItem, C as CompactType, M as Mutable, b as Compactor, P as Position, p as PositionStrategy, R as ResizeHandleAxis } from './types-jd8MiKM1.js';
/**
* Core layout manipulation utilities.
*
* These functions create, modify, and query grid layouts.
* All functions treat layouts as immutable - they return new arrays/objects.
*/
/**
* Get the bottom-most Y coordinate of the layout.
*
* This is the Y position plus height of the lowest item.
*
* @param layout - Layout to measure
* @returns The bottom Y coordinate (0 if layout is empty)
*/
declare function bottom(layout: Layout): number;
/**
* Get a layout item by its ID.
*
* @param layout - Layout to search
* @param id - Item ID to find
* @returns The layout item, or undefined if not found
*/
declare function getLayoutItem(layout: Layout, id: string): LayoutItem | undefined;
/**
* Get all static items from the layout.
*
* Static items cannot be moved or resized by the user.
*
* @param layout - Layout to filter
* @returns Array of static layout items
*/
declare function getStatics(layout: Layout): LayoutItem[];
/**
* Clone a layout item.
*
* Creates a shallow copy with all properties preserved.
* Boolean properties are normalized (undefined becomes false).
*
* @param layoutItem - Item to clone
* @returns A new layout item with the same properties
*/
declare function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem;
/**
* Clone an entire layout.
*
* Creates a new array with cloned items.
*
* @param layout - Layout to clone
* @returns A new layout with cloned items
*/
declare function cloneLayout(layout: Layout): LayoutItem[];
/**
* Replace a layout item in a layout.
*
* Returns a new layout with the item replaced. Other items are not cloned.
*
* @param layout - Layout to modify
* @param layoutItem - New item (matched by `i` property)
* @returns New layout with the item replaced
*/
declare function modifyLayout(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Apply a transformation to a layout item.
*
* Finds the item by key, clones it, applies the callback, and returns
* a new layout with the modified item.
*
* @param layout - Layout to modify
* @param itemKey - Key of the item to modify
* @param cb - Callback that receives the cloned item and returns the modified item
* @returns Tuple of [new layout, modified item or null if not found]
*/
declare function withLayoutItem(layout: Layout, itemKey: string, cb: (item: LayoutItem) => LayoutItem): [LayoutItem[], LayoutItem | null];
/**
* Ensure all layout items fit within the grid bounds.
*
* - Items overflowing right are moved left
* - Items overflowing left are moved to x=0 and clamped to grid width
* - Static items that collide with other statics are moved down
*
* **IMPORTANT**: This function mutates the layout items in place for performance.
* The type signature uses `Mutable<LayoutItem>[]` to make this explicit.
* Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.
*
* @param layout - Layout to correct (items WILL be mutated)
* @param bounds - Grid bounds
* @returns The same layout array (for chaining)
*/
declare function correctBounds(layout: Mutable<LayoutItem>[], bounds: {
cols: number;
}): LayoutItem[];
/**
* Move a layout element to a new position.
*
* Handles collision detection and cascading movements.
* Does not compact the layout - call `compact()` separately.
*
* **Note**: This function mutates the `l` parameter directly for performance.
* The item's x, y, and moved properties will be modified. Callers should
* ideally pass a cloned item if they need to preserve the original.
*
* @param layout - Full layout
* @param l - Item to move (will be mutated)
* @param x - New X position (or undefined to keep current)
* @param y - New Y position (or undefined to keep current)
* @param isUserAction - True if this is a direct user action (affects collision resolution)
* @param preventCollision - True to block movement into occupied space (item snaps back). No effect if allowOverlap is true.
* @param compactType - Compaction type for collision resolution
* @param cols - Number of columns in the grid
* @param allowOverlap - True to allow items to stack on top of each other
* @returns The updated layout
*/
declare function moveElement(layout: Layout, l: LayoutItem, x: number | undefined, y: number | undefined, isUserAction: boolean | undefined, preventCollision: boolean | undefined, compactType: CompactType, cols: number, allowOverlap?: boolean): LayoutItem[];
/**
* Move an item away from a collision.
*
* Attempts to move the item up/left first if there's room,
* otherwise moves it down/right.
*
* @param layout - Full layout
* @param collidesWith - The item being collided with
* @param itemToMove - The item to move away
* @param isUserAction - True if this is a direct user action
* @param compactType - Compaction type
* @param cols - Number of columns
* @returns Updated layout
*/
declare function moveElementAwayFromCollision(layout: Layout, collidesWith: LayoutItem, itemToMove: LayoutItem, isUserAction: boolean | undefined, compactType: CompactType, cols: number): LayoutItem[];
/**
* Validate that a layout has the required properties.
*
* @param layout - Layout to validate
* @param contextName - Name for error messages
* @throws Error if layout is invalid
*/
declare function validateLayout(layout: Layout, contextName?: string): void;
/**
* Compactor implementations.
*
* Compactors are pluggable strategies for removing gaps between grid items.
* Use the Compactor interface to create custom compaction algorithms.
*/
/**
* Resolve a compaction collision by moving items.
*
* Before moving an item to a position, checks if that movement would
* cause collisions and recursively moves those items first.
*
* Useful for implementing custom compactors.
*
* @param layout - Full layout (must be sorted for optimization)
* @param item - Item being moved (will be mutated)
* @param moveToCoord - Target coordinate
* @param axis - Which axis to move on ('x' or 'y')
* @param hasStatics - Whether layout contains static items (disables early break optimization)
*/
declare function resolveCompactionCollision(layout: Layout, item: LayoutItem, moveToCoord: number, axis: "x" | "y", hasStatics?: boolean): void;
/**
* Compact a single item vertically (move up).
*
* Moves the item as far up as possible without colliding.
* Useful for implementing custom vertical compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param fullLayout - Full layout for collision resolution
* @param maxY - Maximum Y to start from
* @returns The compacted item
*/
declare function compactItemVertical(compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number): LayoutItem;
/**
* Compact a single item horizontally (move left).
*
* Moves the item as far left as possible without colliding.
* Wraps to the next row if it overflows.
* Useful for implementing custom horizontal compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param cols - Number of columns in the grid
* @param fullLayout - Full layout for collision resolution
* @returns The compacted item
*/
declare function compactItemHorizontal(compareWith: Layout, l: LayoutItem, cols: number, fullLayout: Layout): LayoutItem;
/**
* Vertical compactor - moves items up to fill gaps.
*
* Items are sorted by row then column, and each item is moved
* as far up as possible without overlapping other items.
*
* This is the default compaction mode for react-grid-layout.
*/
declare const verticalCompactor: Compactor;
/**
* Horizontal compactor - moves items left to fill gaps.
*
* Items are sorted by column then row, and each item is moved
* as far left as possible without overlapping other items.
*/
declare const horizontalCompactor: Compactor;
/**
* No compaction - items stay where placed.
*
* Use this for free-form layouts where items can be placed anywhere.
* Items will not automatically move to fill gaps.
*/
declare const noCompactor: Compactor;
/**
* Vertical compactor that allows overlapping items.
*
* Items compact upward but are allowed to overlap each other.
* Useful for layered layouts or when collision detection is handled externally.
*/
declare const verticalOverlapCompactor: Compactor;
/**
* Horizontal compactor that allows overlapping items.
*/
declare const horizontalOverlapCompactor: Compactor;
/**
* No compaction, with overlapping allowed.
*
* Items stay where placed and can overlap each other.
*/
declare const noOverlapCompactor: Compactor;
/**
* Get a compactor by type.
*
* This is a convenience function for backwards compatibility with the
* string-based compactType API.
*
* Note: For 'wrap' mode, import `wrapCompactor` from 'react-grid-layout/extras'
* and pass it directly to the `compactor` prop. This function returns
* `noCompactor` for 'wrap' type since the wrap compactor is tree-shakeable.
*
* @param compactType - 'vertical', 'horizontal', 'wrap', or null
* @param allowOverlap - Whether to allow overlapping items
* @returns The appropriate Compactor
*/
declare function getCompactor(compactType: CompactType, allowOverlap?: boolean, preventCollision?: boolean): Compactor;
/**
* Position calculation utilities.
*
* These functions convert between grid units and pixel positions,
* and generate CSS styles for grid items.
*/
/**
* Generate CSS transform-based positioning styles.
*
* Using transforms is more performant than top/left positioning
* because it doesn't trigger layout recalculations.
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTransform({ top, left, width, height }: Position): Record<string, string>;
/**
* Generate CSS top/left positioning styles.
*
* Use this when transforms are not suitable (e.g., for printing
* or when transform causes issues with child elements).
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTopLeft({ top, left, width, height }: Position): Record<string, string>;
/**
* Convert a number to a percentage string.
*
* @param num - Number to convert (0-1 range typically)
* @returns Percentage string (e.g., "50%")
*/
declare function perc(num: number): string;
/**
* Resize an item in a specific direction, clamping to container bounds.
*
* This handles the complex logic of resizing from different edges/corners,
* ensuring the item doesn't overflow the container.
*
* @param direction - Which edge/corner is being dragged
* @param currentSize - Current position and size
* @param newSize - Requested new position and size
* @param containerWidth - Width of the container
* @returns Constrained position and size
*/
declare function resizeItemInDirection(direction: ResizeHandleAxis, currentSize: Position, newSize: Position, containerWidth: number): Position;
/**
* CSS transform-based positioning strategy.
*
* Uses CSS transforms for positioning, which is more performant
* as it doesn't trigger layout recalculations.
*
* This is the default strategy.
*/
declare const transformStrategy: PositionStrategy;
/**
* Absolute (top/left) positioning strategy.
*
* Uses CSS top/left for positioning. Use this when CSS transforms
* cause issues (e.g., printing, certain child element positioning).
*/
declare const absoluteStrategy: PositionStrategy;
/**
* Create a scaled transform strategy.
*
* Use this when the grid container is inside a scaled element
* (e.g., `transform: scale(0.5)`). The scale factor adjusts
* drag/resize calculations to account for the parent transform.
*
* @param scale - Scale factor (e.g., 0.5 for half size)
* @returns Position strategy with scaled calculations
*
* @example
* ```tsx
* <div style={{ transform: 'scale(0.5)' }}>
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* </div>
* ```
*/
declare function createScaledStrategy(scale: number): PositionStrategy;
/** Default position strategy (transform-based) */
declare const defaultPositionStrategy: PositionStrategy;
export { transformStrategy as A, verticalOverlapCompactor as B, withLayoutItem as C, cloneLayoutItem as a, bottom as b, cloneLayout as c, getLayoutItem as d, setTransform as e, verticalCompactor as f, getCompactor as g, horizontalCompactor as h, absoluteStrategy as i, compactItemHorizontal as j, compactItemVertical as k, correctBounds as l, moveElement as m, noCompactor as n, createScaledStrategy as o, defaultPositionStrategy as p, getStatics as q, horizontalOverlapCompactor as r, setTopLeft as s, modifyLayout as t, moveElementAwayFromCollision as u, validateLayout as v, noOverlapCompactor as w, perc as x, resizeItemInDirection as y, resolveCompactionCollision as z };
import { d as LayoutItem, L as Layout, C as CompactType, B as Breakpoint, e as ResponsiveLayouts, a as Breakpoints, b as Compactor } from './types-jd8MiKM1.mjs';
/**
* Collision detection utilities for grid layouts.
*
* These functions determine if and where layout items overlap.
*/
/**
* Check if two layout items collide (overlap).
*
* Two items collide if their bounding boxes overlap and they are
* not the same item.
*
* @param l1 - First layout item
* @param l2 - Second layout item
* @returns true if the items collide
*/
declare function collides(l1: LayoutItem, l2: LayoutItem): boolean;
/**
* Find the first item in the layout that collides with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns The first colliding item, or undefined if none
*/
declare function getFirstCollision(layout: Layout, layoutItem: LayoutItem): LayoutItem | undefined;
/**
* Find all items in the layout that collide with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns Array of all colliding items (may be empty)
*/
declare function getAllCollisions(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Sorting utilities for grid layouts.
*
* These functions sort layout items for compaction and iteration.
*/
/**
* Sort layout items based on the compaction type.
*
* - Vertical compaction: sort by row (y) then column (x)
* - Horizontal compaction: sort by column (x) then row (y)
* - No compaction (null): return original order
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @param compactType - Type of compaction
* @returns Sorted layout
*/
declare function sortLayoutItems(layout: Layout, compactType: CompactType): LayoutItem[];
/**
* Sort layout items by row ascending, then column ascending.
*
* Items are ordered from top-left to bottom-right, row by row.
* This is the natural reading order for vertical compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByRowCol(layout: Layout): LayoutItem[];
/**
* Sort layout items by column ascending, then row ascending.
*
* Items are ordered from top-left to bottom-right, column by column.
* This is the natural order for horizontal compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByColRow(layout: Layout): LayoutItem[];
/**
* Responsive layout utilities.
*
* Functions for handling responsive breakpoints and layout generation.
*/
/**
* Sort breakpoints by width (ascending).
*
* Returns an array of breakpoint names sorted from smallest to largest.
* E.g., ['xxs', 'xs', 'sm', 'md', 'lg']
*
* @param breakpoints - Map of breakpoint names to widths
* @returns Sorted array of breakpoint names
*/
declare function sortBreakpoints<B extends Breakpoint>(breakpoints: Breakpoints<B>): B[];
/**
* Get the active breakpoint for a given width.
*
* Returns the highest breakpoint that is valid for the width (width > breakpoint).
*
* @param breakpoints - Map of breakpoint names to widths
* @param width - Container width in pixels
* @returns Active breakpoint name
*/
declare function getBreakpointFromWidth<B extends Breakpoint>(breakpoints: Breakpoints<B>, width: number): B;
/**
* Get the column count for a breakpoint.
*
* @param breakpoint - Breakpoint name
* @param cols - Map of breakpoint names to column counts
* @returns Number of columns for the breakpoint
* @throws Error if breakpoint is not defined in cols
*/
declare function getColsFromBreakpoint<B extends Breakpoint>(breakpoint: B, cols: Breakpoints<B>): number;
/**
* Find or generate a layout for a breakpoint.
*
* If a layout exists for the breakpoint, returns a clone.
* Otherwise, generates a new layout from the nearest larger breakpoint.
*
* @param layouts - Existing layouts by breakpoint
* @param breakpoints - Breakpoint definitions
* @param breakpoint - Target breakpoint
* @param lastBreakpoint - Previous breakpoint (for fallback)
* @param cols - Column count for the target breakpoint
* @param compactTypeOrCompactor - Compaction type string (legacy) or Compactor object
* @returns Layout for the breakpoint
*/
declare function findOrGenerateResponsiveLayout<B extends Breakpoint>(layouts: ResponsiveLayouts<B>, breakpoints: Breakpoints<B>, breakpoint: B, lastBreakpoint: B, cols: number, compactTypeOrCompactor: CompactType | Compactor): Layout;
type IndentationValue<B extends Breakpoint> = readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/**
* Get margin or padding value for a breakpoint.
*
* Supports both fixed values ([x, y]) and breakpoint-specific values
* ({ lg: [x, y], md: [x, y], ... }).
*
* @param value - Fixed value or breakpoint-specific map
* @param breakpoint - Current breakpoint
* @returns Margin/padding tuple [x, y]
*/
declare function getIndentationValue<B extends Breakpoint>(value: IndentationValue<B>, breakpoint: B): readonly [number, number];
export { getBreakpointFromWidth as a, getColsFromBreakpoint as b, collides as c, getFirstCollision as d, sortLayoutItemsByColRow as e, findOrGenerateResponsiveLayout as f, getAllCollisions as g, sortLayoutItemsByRowCol as h, getIndentationValue as i, sortBreakpoints as j, sortLayoutItems as s };
import { d as LayoutItem, L as Layout, C as CompactType, B as Breakpoint, e as ResponsiveLayouts, a as Breakpoints, b as Compactor } from './types-jd8MiKM1.js';
/**
* Collision detection utilities for grid layouts.
*
* These functions determine if and where layout items overlap.
*/
/**
* Check if two layout items collide (overlap).
*
* Two items collide if their bounding boxes overlap and they are
* not the same item.
*
* @param l1 - First layout item
* @param l2 - Second layout item
* @returns true if the items collide
*/
declare function collides(l1: LayoutItem, l2: LayoutItem): boolean;
/**
* Find the first item in the layout that collides with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns The first colliding item, or undefined if none
*/
declare function getFirstCollision(layout: Layout, layoutItem: LayoutItem): LayoutItem | undefined;
/**
* Find all items in the layout that collide with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns Array of all colliding items (may be empty)
*/
declare function getAllCollisions(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Sorting utilities for grid layouts.
*
* These functions sort layout items for compaction and iteration.
*/
/**
* Sort layout items based on the compaction type.
*
* - Vertical compaction: sort by row (y) then column (x)
* - Horizontal compaction: sort by column (x) then row (y)
* - No compaction (null): return original order
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @param compactType - Type of compaction
* @returns Sorted layout
*/
declare function sortLayoutItems(layout: Layout, compactType: CompactType): LayoutItem[];
/**
* Sort layout items by row ascending, then column ascending.
*
* Items are ordered from top-left to bottom-right, row by row.
* This is the natural reading order for vertical compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByRowCol(layout: Layout): LayoutItem[];
/**
* Sort layout items by column ascending, then row ascending.
*
* Items are ordered from top-left to bottom-right, column by column.
* This is the natural order for horizontal compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByColRow(layout: Layout): LayoutItem[];
/**
* Responsive layout utilities.
*
* Functions for handling responsive breakpoints and layout generation.
*/
/**
* Sort breakpoints by width (ascending).
*
* Returns an array of breakpoint names sorted from smallest to largest.
* E.g., ['xxs', 'xs', 'sm', 'md', 'lg']
*
* @param breakpoints - Map of breakpoint names to widths
* @returns Sorted array of breakpoint names
*/
declare function sortBreakpoints<B extends Breakpoint>(breakpoints: Breakpoints<B>): B[];
/**
* Get the active breakpoint for a given width.
*
* Returns the highest breakpoint that is valid for the width (width > breakpoint).
*
* @param breakpoints - Map of breakpoint names to widths
* @param width - Container width in pixels
* @returns Active breakpoint name
*/
declare function getBreakpointFromWidth<B extends Breakpoint>(breakpoints: Breakpoints<B>, width: number): B;
/**
* Get the column count for a breakpoint.
*
* @param breakpoint - Breakpoint name
* @param cols - Map of breakpoint names to column counts
* @returns Number of columns for the breakpoint
* @throws Error if breakpoint is not defined in cols
*/
declare function getColsFromBreakpoint<B extends Breakpoint>(breakpoint: B, cols: Breakpoints<B>): number;
/**
* Find or generate a layout for a breakpoint.
*
* If a layout exists for the breakpoint, returns a clone.
* Otherwise, generates a new layout from the nearest larger breakpoint.
*
* @param layouts - Existing layouts by breakpoint
* @param breakpoints - Breakpoint definitions
* @param breakpoint - Target breakpoint
* @param lastBreakpoint - Previous breakpoint (for fallback)
* @param cols - Column count for the target breakpoint
* @param compactTypeOrCompactor - Compaction type string (legacy) or Compactor object
* @returns Layout for the breakpoint
*/
declare function findOrGenerateResponsiveLayout<B extends Breakpoint>(layouts: ResponsiveLayouts<B>, breakpoints: Breakpoints<B>, breakpoint: B, lastBreakpoint: B, cols: number, compactTypeOrCompactor: CompactType | Compactor): Layout;
type IndentationValue<B extends Breakpoint> = readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/**
* Get margin or padding value for a breakpoint.
*
* Supports both fixed values ([x, y]) and breakpoint-specific values
* ({ lg: [x, y], md: [x, y], ... }).
*
* @param value - Fixed value or breakpoint-specific map
* @param breakpoint - Current breakpoint
* @returns Margin/padding tuple [x, y]
*/
declare function getIndentationValue<B extends Breakpoint>(value: IndentationValue<B>, breakpoint: B): readonly [number, number];
export { getBreakpointFromWidth as a, getColsFromBreakpoint as b, collides as c, getFirstCollision as d, sortLayoutItemsByColRow as e, findOrGenerateResponsiveLayout as f, getAllCollisions as g, sortLayoutItemsByRowCol as h, getIndentationValue as i, sortBreakpoints as j, sortLayoutItems as s };
import React__default, { CSSProperties, DragEvent, ReactElement } from 'react';
import { m as GridConfig, j as DragConfig, r as ResizeConfig, l as DropConfig, p as PositionStrategy, b as Compactor, f as LayoutConstraint, L as Layout, d as LayoutItem, E as EventCallback, B as Breakpoint, a as Breakpoints, e as ResponsiveLayouts } from './types-jd8MiKM1.mjs';
/**
* GridLayout component
*
* A reactive, fluid grid layout with draggable, resizable components.
*/
interface GridLayoutProps {
/** Child elements to render in the grid */
children: React__default.ReactNode;
/** Width of the container in pixels */
width: number;
/**
* Grid measurement configuration.
* @see GridConfig
*/
gridConfig?: Partial<GridConfig>;
/**
* Drag behavior configuration.
* @see DragConfig
*/
dragConfig?: Partial<DragConfig>;
/**
* Resize behavior configuration.
* @see ResizeConfig
*/
resizeConfig?: Partial<ResizeConfig>;
/**
* External drop configuration.
* @see DropConfig
*/
dropConfig?: Partial<DropConfig>;
/**
* CSS positioning strategy.
* Use transformStrategy (default), absoluteStrategy, or createScaledStrategy(scale).
* @see PositionStrategy
*/
positionStrategy?: PositionStrategy;
/**
* Layout compaction strategy.
* Use verticalCompactor (default), horizontalCompactor, or noCompactor.
* @see Compactor
*/
compactor?: Compactor;
/**
* Layout constraints for position and size limiting.
* Applied during drag/resize operations.
* Default: [gridBounds, minMaxSize]
* @see LayoutConstraint
*/
constraints?: LayoutConstraint[];
/** Layout definition */
layout?: Layout;
/** Item to use when dropping from outside */
droppingItem?: LayoutItem;
/** Whether to auto-size the container height */
autoSize?: boolean;
/** Additional class name */
className?: string;
/** Additional styles */
style?: CSSProperties;
/** Ref to the container element */
innerRef?: React__default.Ref<HTMLDivElement>;
/** Called when layout changes */
onLayoutChange?: (layout: Layout) => void;
/** Called when drag starts */
onDragStart?: EventCallback;
/** Called during drag */
onDrag?: EventCallback;
/** Called when drag stops */
onDragStop?: EventCallback;
/** Called when resize starts */
onResizeStart?: EventCallback;
/** Called during resize */
onResize?: EventCallback;
/** Called when resize stops */
onResizeStop?: EventCallback;
/** Called when an item is dropped from outside */
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
/** Called when dragging over the grid */
onDropDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/**
* GridLayout - A reactive, fluid grid layout with draggable, resizable components.
*/
declare function GridLayout(props: GridLayoutProps): ReactElement;
/**
* ResponsiveGridLayout component
*
* A responsive grid layout that automatically adjusts to container width.
*/
interface ResponsiveGridLayoutProps<B extends Breakpoint = string> extends Omit<GridLayoutProps, "gridConfig" | "layout" | "onLayoutChange"> {
/** Current breakpoint (optional, auto-detected from width) */
breakpoint?: B;
/** Breakpoint definitions (name → min-width) */
breakpoints?: Breakpoints<B>;
/** Column counts per breakpoint */
cols?: Breakpoints<B>;
/** Layouts for each breakpoint */
layouts?: ResponsiveLayouts<B>;
/** Row height (default: 150) */
rowHeight?: number;
/** Maximum rows (default: Infinity) */
maxRows?: number;
/** Margin between items - can be fixed or per-breakpoint */
margin?: readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/** Container padding - can be fixed or per-breakpoint */
containerPadding?: readonly [number, number] | Partial<Record<B, readonly [number, number] | null>> | null;
/** Compactor for layout compaction */
compactor?: Compactor;
/** Called when breakpoint changes */
onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
/** Called when layout changes */
onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
/** Called when width changes */
onWidthChange?: (containerWidth: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
}
/**
* ResponsiveGridLayout - A responsive grid layout that adjusts to container width.
*/
declare function ResponsiveGridLayout<B extends Breakpoint = string>(props: ResponsiveGridLayoutProps<B>): ReactElement;
export { GridLayout as G, ResponsiveGridLayout as R, type GridLayoutProps as a, type ResponsiveGridLayoutProps as b };
import React__default, { CSSProperties, DragEvent, ReactElement } from 'react';
import { m as GridConfig, j as DragConfig, r as ResizeConfig, l as DropConfig, p as PositionStrategy, b as Compactor, f as LayoutConstraint, L as Layout, d as LayoutItem, E as EventCallback, B as Breakpoint, a as Breakpoints, e as ResponsiveLayouts } from './types-jd8MiKM1.js';
/**
* GridLayout component
*
* A reactive, fluid grid layout with draggable, resizable components.
*/
interface GridLayoutProps {
/** Child elements to render in the grid */
children: React__default.ReactNode;
/** Width of the container in pixels */
width: number;
/**
* Grid measurement configuration.
* @see GridConfig
*/
gridConfig?: Partial<GridConfig>;
/**
* Drag behavior configuration.
* @see DragConfig
*/
dragConfig?: Partial<DragConfig>;
/**
* Resize behavior configuration.
* @see ResizeConfig
*/
resizeConfig?: Partial<ResizeConfig>;
/**
* External drop configuration.
* @see DropConfig
*/
dropConfig?: Partial<DropConfig>;
/**
* CSS positioning strategy.
* Use transformStrategy (default), absoluteStrategy, or createScaledStrategy(scale).
* @see PositionStrategy
*/
positionStrategy?: PositionStrategy;
/**
* Layout compaction strategy.
* Use verticalCompactor (default), horizontalCompactor, or noCompactor.
* @see Compactor
*/
compactor?: Compactor;
/**
* Layout constraints for position and size limiting.
* Applied during drag/resize operations.
* Default: [gridBounds, minMaxSize]
* @see LayoutConstraint
*/
constraints?: LayoutConstraint[];
/** Layout definition */
layout?: Layout;
/** Item to use when dropping from outside */
droppingItem?: LayoutItem;
/** Whether to auto-size the container height */
autoSize?: boolean;
/** Additional class name */
className?: string;
/** Additional styles */
style?: CSSProperties;
/** Ref to the container element */
innerRef?: React__default.Ref<HTMLDivElement>;
/** Called when layout changes */
onLayoutChange?: (layout: Layout) => void;
/** Called when drag starts */
onDragStart?: EventCallback;
/** Called during drag */
onDrag?: EventCallback;
/** Called when drag stops */
onDragStop?: EventCallback;
/** Called when resize starts */
onResizeStart?: EventCallback;
/** Called during resize */
onResize?: EventCallback;
/** Called when resize stops */
onResizeStop?: EventCallback;
/** Called when an item is dropped from outside */
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
/** Called when dragging over the grid */
onDropDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/**
* GridLayout - A reactive, fluid grid layout with draggable, resizable components.
*/
declare function GridLayout(props: GridLayoutProps): ReactElement;
/**
* ResponsiveGridLayout component
*
* A responsive grid layout that automatically adjusts to container width.
*/
interface ResponsiveGridLayoutProps<B extends Breakpoint = string> extends Omit<GridLayoutProps, "gridConfig" | "layout" | "onLayoutChange"> {
/** Current breakpoint (optional, auto-detected from width) */
breakpoint?: B;
/** Breakpoint definitions (name → min-width) */
breakpoints?: Breakpoints<B>;
/** Column counts per breakpoint */
cols?: Breakpoints<B>;
/** Layouts for each breakpoint */
layouts?: ResponsiveLayouts<B>;
/** Row height (default: 150) */
rowHeight?: number;
/** Maximum rows (default: Infinity) */
maxRows?: number;
/** Margin between items - can be fixed or per-breakpoint */
margin?: readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/** Container padding - can be fixed or per-breakpoint */
containerPadding?: readonly [number, number] | Partial<Record<B, readonly [number, number] | null>> | null;
/** Compactor for layout compaction */
compactor?: Compactor;
/** Called when breakpoint changes */
onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
/** Called when layout changes */
onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
/** Called when width changes */
onWidthChange?: (containerWidth: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
}
/**
* ResponsiveGridLayout - A responsive grid layout that adjusts to container width.
*/
declare function ResponsiveGridLayout<B extends Breakpoint = string>(props: ResponsiveGridLayoutProps<B>): ReactElement;
export { GridLayout as G, ResponsiveGridLayout as R, type GridLayoutProps as a, type ResponsiveGridLayoutProps as b };
/**
* Core types for react-grid-layout v2
*
* These types are framework-agnostic and define the data structures
* used by the layout algorithms.
*/
/**
* Axis identifiers for resize handles.
* - Cardinal: 'n', 's', 'e', 'w' (north, south, east, west)
* - Diagonal: 'ne', 'nw', 'se', 'sw'
*/
type ResizeHandleAxis = "s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne";
/**
* A single item in the grid layout.
*
* Position (x, y) is in grid units, not pixels.
* Size (w, h) is in grid units.
*/
interface LayoutItem {
/** Unique identifier for this item */
i: string;
/** X position in grid units (0-indexed from left) */
x: number;
/** Y position in grid units (0-indexed from top) */
y: number;
/** Width in grid units */
w: number;
/** Height in grid units */
h: number;
/** Minimum width in grid units */
minW?: number;
/** Minimum height in grid units */
minH?: number;
/** Maximum width in grid units */
maxW?: number;
/** Maximum height in grid units */
maxH?: number;
/**
* If true, item cannot be dragged or resized, and other items
* will move around it during compaction.
*/
static?: boolean;
/**
* If false, item cannot be dragged (but may still be resizable).
* Overrides grid-level isDraggable for this item.
*/
isDraggable?: boolean;
/**
* If false, item cannot be resized (but may still be draggable).
* Overrides grid-level isResizable for this item.
*/
isResizable?: boolean;
/**
* Which resize handles to show for this item.
* Overrides grid-level resizeHandles for this item.
*/
resizeHandles?: ResizeHandleAxis[];
/**
* If true, item is constrained to the grid container bounds.
* Overrides grid-level isBounded for this item.
*/
isBounded?: boolean;
/**
* Internal flag set during drag/resize operations to indicate
* the item has moved from its original position.
* @internal
*/
moved?: boolean;
/**
* Per-item layout constraints.
* Applied in addition to grid-level constraints.
*/
constraints?: LayoutConstraint[];
}
/**
* A layout is a readonly array of layout items.
* Layouts should be treated as immutable.
*/
type Layout = readonly LayoutItem[];
/**
* Pixel position and size of an element.
*/
interface Position {
left: number;
top: number;
width: number;
height: number;
}
/**
* Partial position (just coordinates, no size).
*/
interface PartialPosition {
left: number;
top: number;
}
/**
* Size in pixels.
*/
interface Size {
width: number;
height: number;
}
/**
* Position when dropping an external element onto the grid.
*/
interface DroppingPosition {
left: number;
top: number;
e: Event;
}
/**
* Data provided by react-draggable during drag operations.
*/
interface ReactDraggableCallbackData {
node: HTMLElement;
x?: number;
y?: number;
deltaX: number;
deltaY: number;
lastX?: number;
lastY?: number;
}
/**
* Grid-level drag event data.
*/
interface GridDragEvent {
e: Event;
node: HTMLElement;
newPosition: PartialPosition;
}
/**
* Grid-level resize event data.
*/
interface GridResizeEvent {
e: Event;
node: HTMLElement;
size: Size;
handle: ResizeHandleAxis;
}
/**
* Drag-over event with layer coordinates.
*/
interface DragOverEvent extends MouseEvent {
nativeEvent: Event & {
layerX: number;
layerY: number;
};
}
/**
* Type of compaction to apply to the layout.
* - 'vertical': Items compact upward (default)
* - 'horizontal': Items compact leftward
* - 'wrap': Items arranged in wrapped-paragraph style (like words in text)
* - null: No compaction (free-form positioning)
*/
type CompactType = "horizontal" | "vertical" | "wrap" | null;
/**
* Standard callback signature for layout change events.
*
* @param layout - The current layout after the change
* @param oldItem - The item before the change (null if not applicable)
* @param newItem - The item after the change (null if not applicable)
* @param placeholder - The placeholder item during drag/resize (null at start)
* @param event - The DOM event that triggered the change
* @param element - The DOM element being manipulated (null if not applicable)
*/
type EventCallback = (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null, placeholder: LayoutItem | null, event: Event, element: HTMLElement | null) => void;
/**
* Callback when layout changes for any reason.
*/
type OnLayoutChangeCallback = (layout: Layout) => void;
/**
* Interface for layout compaction strategies.
*
* Implement this interface to create custom compaction algorithms.
*
* @example
* ```typescript
* const myCompactor: Compactor = {
* type: 'vertical',
* allowOverlap: false,
* compact(layout, cols) {
* // Custom compaction logic
* return compactedLayout;
* }
* };
* ```
*/
interface Compactor {
/** Compaction type identifier */
readonly type: CompactType;
/**
* Whether items can overlap (stack on top of each other).
*
* When true:
* - Items can be placed on top of other items
* - Dragging into another item does NOT push it away
* - Compaction is skipped after drag/resize
*/
readonly allowOverlap: boolean;
/**
* Whether to block movement that would cause collision.
*
* When true (and allowOverlap is false):
* - Dragging into another item is blocked (item snaps back)
* - Other items are NOT pushed away
* - Only affects drag/resize, not compaction
*
* Has no effect when allowOverlap is true.
*/
readonly preventCollision?: boolean;
/**
* Compact the layout.
*
* @param layout - The layout to compact
* @param cols - Number of columns in the grid
* @returns The compacted layout
*/
compact(layout: Layout, cols: number): Layout;
}
/**
* Interface for CSS positioning strategies.
*
* Implement this interface to customize how items are positioned in the DOM.
* Built-in strategies: transformStrategy, absoluteStrategy.
*
* @example
* ```typescript
* // Use transform-based positioning (default, better performance)
* <GridLayout positionStrategy={transformStrategy} />
*
* // Use top/left positioning (for environments where transforms cause issues)
* <GridLayout positionStrategy={absoluteStrategy} />
*
* // Use scaled transforms (for scaled containers)
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* ```
*/
interface PositionStrategy {
/** Strategy type identifier */
readonly type: "transform" | "absolute";
/** Scale factor for drag/resize calculations */
readonly scale: number;
/**
* Convert pixel position to CSS style object.
*
* @param pos - Position in pixels
* @returns CSS properties for positioning the element
*/
calcStyle(pos: Position): React.CSSProperties;
/**
* Calculate position during drag operations, accounting for transforms and scale.
*
* This method is optional. When not provided, react-draggable uses its built-in
* parent-relative coordinate calculation. Only override this when you need custom
* coordinate handling, such as for scaled containers.
*
* @param clientX - Mouse client X position
* @param clientY - Mouse client Y position
* @param offsetX - Offset from element origin X
* @param offsetY - Offset from element origin Y
* @returns Adjusted left/top position
*/
calcDragPosition?(clientX: number, clientY: number, offsetX: number, offsetY: number): PartialPosition;
}
/**
* Context provided to constraint functions during drag/resize operations.
*/
interface ConstraintContext {
/** Number of columns in the grid */
cols: number;
/** Maximum number of rows (Infinity if unbounded) */
maxRows: number;
/** Container width in pixels */
containerWidth: number;
/** Container height in pixels (may be 0 if auto-height) */
containerHeight: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] in pixels */
margin: readonly [number, number];
/** Current layout state */
layout: Layout;
}
/**
* Interface for layout constraints.
*
* Implement this interface to create custom position/size constraints.
* Built-in constraints: gridBounds, minMaxSize, containerBounds, boundedX, boundedY.
*
* @example
* ```typescript
* // Grid-level constraints
* <GridLayout constraints={[gridBounds, minMaxSize, aspectRatio(16/9)]} />
*
* // Per-item constraints
* const layout = [
* { i: 'video', x: 0, y: 0, w: 4, h: 2, constraints: [aspectRatio(16/9)] }
* ];
* ```
*/
interface LayoutConstraint {
/** Constraint identifier for debugging */
readonly name: string;
/**
* Constrain position during drag operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being dragged
* @param x - Proposed x position in grid units
* @param y - Proposed y position in grid units
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained x, y position
*/
constrainPosition?(item: LayoutItem, x: number, y: number, context: ConstraintContext): {
x: number;
y: number;
};
/**
* Constrain size during resize operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being resized
* @param w - Proposed width in grid units
* @param h - Proposed height in grid units
* @param handle - Which resize handle is being used
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained w, h size
*/
constrainSize?(item: LayoutItem, w: number, h: number, handle: ResizeHandleAxis, context: ConstraintContext): {
w: number;
h: number;
};
}
/**
* Grid measurement configuration.
* Groups all grid metrics (columns, row height, margins).
*/
interface GridConfig {
/** Number of columns in the grid (default: 12) */
cols: number;
/** Height of a single row in pixels (default: 150) */
rowHeight: number;
/** [horizontal, vertical] margin between items in pixels (default: [10, 10]) */
margin: readonly [number, number];
/** [horizontal, vertical] padding inside the container (default: null, uses margin) */
containerPadding: readonly [number, number] | null;
/** Maximum number of rows (default: Infinity) */
maxRows: number;
}
/** Default grid configuration */
declare const defaultGridConfig: GridConfig;
/**
* Drag behavior configuration.
* Groups all drag-related settings.
*/
interface DragConfig {
/** Whether items can be dragged (default: true) */
enabled: boolean;
/** Whether items are bounded to the container (default: false) */
bounded: boolean;
/** CSS selector for drag handle (e.g., '.drag-handle') */
handle?: string;
/** CSS selector for elements that should not trigger drag */
cancel?: string;
/**
* Minimum pixels to move before drag starts.
* Helps distinguish click from drag (fixes #1341, #1401).
* @default 3
*/
threshold: number;
}
/** Default drag configuration */
declare const defaultDragConfig: DragConfig;
/**
* Resize behavior configuration.
* Groups all resize-related settings.
*/
interface ResizeConfig {
/** Whether items can be resized (default: true) */
enabled: boolean;
/** Which resize handles to show (default: ['se']) */
handles: readonly ResizeHandleAxis[];
/**
* Custom resize handle component.
* Can be a React node or a function that receives the axis.
*/
handleComponent?: React.ReactNode | ((axis: ResizeHandleAxis, ref: React.Ref<HTMLElement>) => React.ReactNode);
}
/** Default resize configuration */
declare const defaultResizeConfig: ResizeConfig;
/**
* Drop configuration (for dropping external elements).
* Groups all drop-related settings.
*/
interface DropConfig {
/** Whether external elements can be dropped on the grid (default: false) */
enabled: boolean;
/** Default size for dropped items (default: { w: 1, h: 1 }) */
defaultItem: {
w: number;
h: number;
};
/**
* Called when dragging over the grid.
* Return dimensions to override defaultItem, or false to reject the drop.
* Can also return dragOffsetX/dragOffsetY to specify cursor offset for centering.
*/
onDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/** Default drop configuration */
declare const defaultDropConfig: DropConfig;
/**
* Breakpoint name (e.g., 'lg', 'md', 'sm', 'xs', 'xxs').
*/
type Breakpoint = string;
/**
* Map of breakpoint name to pixel width.
* Generic type B allows custom breakpoint strings.
*/
type Breakpoints<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to number of columns.
* Generic type B allows custom breakpoint strings.
*/
type BreakpointCols<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to layout.
* Generic type B allows custom breakpoint strings.
*/
type ResponsiveLayouts<B extends Breakpoint = Breakpoint> = Partial<Record<B, Layout>>;
/**
* Callback when breakpoint changes.
*/
type OnBreakpointChangeCallback<B extends Breakpoint = Breakpoint> = (newBreakpoint: B, cols: number) => void;
/**
* Makes all properties in T mutable (removes readonly).
*/
type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
/**
* Deep partial - all properties and nested properties are optional.
*/
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
/**
* Extract the element type from an array type.
*/
type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
export { type ArrayElement as A, type Breakpoint as B, type CompactType as C, type DroppingPosition as D, type EventCallback as E, type GridDragEvent as G, type Layout as L, type Mutable as M, type OnBreakpointChangeCallback as O, type Position as P, type ResizeHandleAxis as R, type Size as S, type Breakpoints as a, type Compactor as b, type GridResizeEvent as c, type LayoutItem as d, type ResponsiveLayouts as e, type LayoutConstraint as f, type ConstraintContext as g, type BreakpointCols as h, type DeepPartial as i, type DragConfig as j, type DragOverEvent as k, type DropConfig as l, type GridConfig as m, type OnLayoutChangeCallback as n, type PartialPosition as o, type PositionStrategy as p, type ReactDraggableCallbackData as q, type ResizeConfig as r, defaultDragConfig as s, defaultDropConfig as t, defaultGridConfig as u, defaultResizeConfig as v };
/**
* Core types for react-grid-layout v2
*
* These types are framework-agnostic and define the data structures
* used by the layout algorithms.
*/
/**
* Axis identifiers for resize handles.
* - Cardinal: 'n', 's', 'e', 'w' (north, south, east, west)
* - Diagonal: 'ne', 'nw', 'se', 'sw'
*/
type ResizeHandleAxis = "s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne";
/**
* A single item in the grid layout.
*
* Position (x, y) is in grid units, not pixels.
* Size (w, h) is in grid units.
*/
interface LayoutItem {
/** Unique identifier for this item */
i: string;
/** X position in grid units (0-indexed from left) */
x: number;
/** Y position in grid units (0-indexed from top) */
y: number;
/** Width in grid units */
w: number;
/** Height in grid units */
h: number;
/** Minimum width in grid units */
minW?: number;
/** Minimum height in grid units */
minH?: number;
/** Maximum width in grid units */
maxW?: number;
/** Maximum height in grid units */
maxH?: number;
/**
* If true, item cannot be dragged or resized, and other items
* will move around it during compaction.
*/
static?: boolean;
/**
* If false, item cannot be dragged (but may still be resizable).
* Overrides grid-level isDraggable for this item.
*/
isDraggable?: boolean;
/**
* If false, item cannot be resized (but may still be draggable).
* Overrides grid-level isResizable for this item.
*/
isResizable?: boolean;
/**
* Which resize handles to show for this item.
* Overrides grid-level resizeHandles for this item.
*/
resizeHandles?: ResizeHandleAxis[];
/**
* If true, item is constrained to the grid container bounds.
* Overrides grid-level isBounded for this item.
*/
isBounded?: boolean;
/**
* Internal flag set during drag/resize operations to indicate
* the item has moved from its original position.
* @internal
*/
moved?: boolean;
/**
* Per-item layout constraints.
* Applied in addition to grid-level constraints.
*/
constraints?: LayoutConstraint[];
}
/**
* A layout is a readonly array of layout items.
* Layouts should be treated as immutable.
*/
type Layout = readonly LayoutItem[];
/**
* Pixel position and size of an element.
*/
interface Position {
left: number;
top: number;
width: number;
height: number;
}
/**
* Partial position (just coordinates, no size).
*/
interface PartialPosition {
left: number;
top: number;
}
/**
* Size in pixels.
*/
interface Size {
width: number;
height: number;
}
/**
* Position when dropping an external element onto the grid.
*/
interface DroppingPosition {
left: number;
top: number;
e: Event;
}
/**
* Data provided by react-draggable during drag operations.
*/
interface ReactDraggableCallbackData {
node: HTMLElement;
x?: number;
y?: number;
deltaX: number;
deltaY: number;
lastX?: number;
lastY?: number;
}
/**
* Grid-level drag event data.
*/
interface GridDragEvent {
e: Event;
node: HTMLElement;
newPosition: PartialPosition;
}
/**
* Grid-level resize event data.
*/
interface GridResizeEvent {
e: Event;
node: HTMLElement;
size: Size;
handle: ResizeHandleAxis;
}
/**
* Drag-over event with layer coordinates.
*/
interface DragOverEvent extends MouseEvent {
nativeEvent: Event & {
layerX: number;
layerY: number;
};
}
/**
* Type of compaction to apply to the layout.
* - 'vertical': Items compact upward (default)
* - 'horizontal': Items compact leftward
* - 'wrap': Items arranged in wrapped-paragraph style (like words in text)
* - null: No compaction (free-form positioning)
*/
type CompactType = "horizontal" | "vertical" | "wrap" | null;
/**
* Standard callback signature for layout change events.
*
* @param layout - The current layout after the change
* @param oldItem - The item before the change (null if not applicable)
* @param newItem - The item after the change (null if not applicable)
* @param placeholder - The placeholder item during drag/resize (null at start)
* @param event - The DOM event that triggered the change
* @param element - The DOM element being manipulated (null if not applicable)
*/
type EventCallback = (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null, placeholder: LayoutItem | null, event: Event, element: HTMLElement | null) => void;
/**
* Callback when layout changes for any reason.
*/
type OnLayoutChangeCallback = (layout: Layout) => void;
/**
* Interface for layout compaction strategies.
*
* Implement this interface to create custom compaction algorithms.
*
* @example
* ```typescript
* const myCompactor: Compactor = {
* type: 'vertical',
* allowOverlap: false,
* compact(layout, cols) {
* // Custom compaction logic
* return compactedLayout;
* }
* };
* ```
*/
interface Compactor {
/** Compaction type identifier */
readonly type: CompactType;
/**
* Whether items can overlap (stack on top of each other).
*
* When true:
* - Items can be placed on top of other items
* - Dragging into another item does NOT push it away
* - Compaction is skipped after drag/resize
*/
readonly allowOverlap: boolean;
/**
* Whether to block movement that would cause collision.
*
* When true (and allowOverlap is false):
* - Dragging into another item is blocked (item snaps back)
* - Other items are NOT pushed away
* - Only affects drag/resize, not compaction
*
* Has no effect when allowOverlap is true.
*/
readonly preventCollision?: boolean;
/**
* Compact the layout.
*
* @param layout - The layout to compact
* @param cols - Number of columns in the grid
* @returns The compacted layout
*/
compact(layout: Layout, cols: number): Layout;
}
/**
* Interface for CSS positioning strategies.
*
* Implement this interface to customize how items are positioned in the DOM.
* Built-in strategies: transformStrategy, absoluteStrategy.
*
* @example
* ```typescript
* // Use transform-based positioning (default, better performance)
* <GridLayout positionStrategy={transformStrategy} />
*
* // Use top/left positioning (for environments where transforms cause issues)
* <GridLayout positionStrategy={absoluteStrategy} />
*
* // Use scaled transforms (for scaled containers)
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* ```
*/
interface PositionStrategy {
/** Strategy type identifier */
readonly type: "transform" | "absolute";
/** Scale factor for drag/resize calculations */
readonly scale: number;
/**
* Convert pixel position to CSS style object.
*
* @param pos - Position in pixels
* @returns CSS properties for positioning the element
*/
calcStyle(pos: Position): React.CSSProperties;
/**
* Calculate position during drag operations, accounting for transforms and scale.
*
* This method is optional. When not provided, react-draggable uses its built-in
* parent-relative coordinate calculation. Only override this when you need custom
* coordinate handling, such as for scaled containers.
*
* @param clientX - Mouse client X position
* @param clientY - Mouse client Y position
* @param offsetX - Offset from element origin X
* @param offsetY - Offset from element origin Y
* @returns Adjusted left/top position
*/
calcDragPosition?(clientX: number, clientY: number, offsetX: number, offsetY: number): PartialPosition;
}
/**
* Context provided to constraint functions during drag/resize operations.
*/
interface ConstraintContext {
/** Number of columns in the grid */
cols: number;
/** Maximum number of rows (Infinity if unbounded) */
maxRows: number;
/** Container width in pixels */
containerWidth: number;
/** Container height in pixels (may be 0 if auto-height) */
containerHeight: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] in pixels */
margin: readonly [number, number];
/** Current layout state */
layout: Layout;
}
/**
* Interface for layout constraints.
*
* Implement this interface to create custom position/size constraints.
* Built-in constraints: gridBounds, minMaxSize, containerBounds, boundedX, boundedY.
*
* @example
* ```typescript
* // Grid-level constraints
* <GridLayout constraints={[gridBounds, minMaxSize, aspectRatio(16/9)]} />
*
* // Per-item constraints
* const layout = [
* { i: 'video', x: 0, y: 0, w: 4, h: 2, constraints: [aspectRatio(16/9)] }
* ];
* ```
*/
interface LayoutConstraint {
/** Constraint identifier for debugging */
readonly name: string;
/**
* Constrain position during drag operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being dragged
* @param x - Proposed x position in grid units
* @param y - Proposed y position in grid units
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained x, y position
*/
constrainPosition?(item: LayoutItem, x: number, y: number, context: ConstraintContext): {
x: number;
y: number;
};
/**
* Constrain size during resize operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being resized
* @param w - Proposed width in grid units
* @param h - Proposed height in grid units
* @param handle - Which resize handle is being used
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained w, h size
*/
constrainSize?(item: LayoutItem, w: number, h: number, handle: ResizeHandleAxis, context: ConstraintContext): {
w: number;
h: number;
};
}
/**
* Grid measurement configuration.
* Groups all grid metrics (columns, row height, margins).
*/
interface GridConfig {
/** Number of columns in the grid (default: 12) */
cols: number;
/** Height of a single row in pixels (default: 150) */
rowHeight: number;
/** [horizontal, vertical] margin between items in pixels (default: [10, 10]) */
margin: readonly [number, number];
/** [horizontal, vertical] padding inside the container (default: null, uses margin) */
containerPadding: readonly [number, number] | null;
/** Maximum number of rows (default: Infinity) */
maxRows: number;
}
/** Default grid configuration */
declare const defaultGridConfig: GridConfig;
/**
* Drag behavior configuration.
* Groups all drag-related settings.
*/
interface DragConfig {
/** Whether items can be dragged (default: true) */
enabled: boolean;
/** Whether items are bounded to the container (default: false) */
bounded: boolean;
/** CSS selector for drag handle (e.g., '.drag-handle') */
handle?: string;
/** CSS selector for elements that should not trigger drag */
cancel?: string;
/**
* Minimum pixels to move before drag starts.
* Helps distinguish click from drag (fixes #1341, #1401).
* @default 3
*/
threshold: number;
}
/** Default drag configuration */
declare const defaultDragConfig: DragConfig;
/**
* Resize behavior configuration.
* Groups all resize-related settings.
*/
interface ResizeConfig {
/** Whether items can be resized (default: true) */
enabled: boolean;
/** Which resize handles to show (default: ['se']) */
handles: readonly ResizeHandleAxis[];
/**
* Custom resize handle component.
* Can be a React node or a function that receives the axis.
*/
handleComponent?: React.ReactNode | ((axis: ResizeHandleAxis, ref: React.Ref<HTMLElement>) => React.ReactNode);
}
/** Default resize configuration */
declare const defaultResizeConfig: ResizeConfig;
/**
* Drop configuration (for dropping external elements).
* Groups all drop-related settings.
*/
interface DropConfig {
/** Whether external elements can be dropped on the grid (default: false) */
enabled: boolean;
/** Default size for dropped items (default: { w: 1, h: 1 }) */
defaultItem: {
w: number;
h: number;
};
/**
* Called when dragging over the grid.
* Return dimensions to override defaultItem, or false to reject the drop.
* Can also return dragOffsetX/dragOffsetY to specify cursor offset for centering.
*/
onDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/** Default drop configuration */
declare const defaultDropConfig: DropConfig;
/**
* Breakpoint name (e.g., 'lg', 'md', 'sm', 'xs', 'xxs').
*/
type Breakpoint = string;
/**
* Map of breakpoint name to pixel width.
* Generic type B allows custom breakpoint strings.
*/
type Breakpoints<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to number of columns.
* Generic type B allows custom breakpoint strings.
*/
type BreakpointCols<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to layout.
* Generic type B allows custom breakpoint strings.
*/
type ResponsiveLayouts<B extends Breakpoint = Breakpoint> = Partial<Record<B, Layout>>;
/**
* Callback when breakpoint changes.
*/
type OnBreakpointChangeCallback<B extends Breakpoint = Breakpoint> = (newBreakpoint: B, cols: number) => void;
/**
* Makes all properties in T mutable (removes readonly).
*/
type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
/**
* Deep partial - all properties and nested properties are optional.
*/
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
/**
* Extract the element type from an array type.
*/
type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
export { type ArrayElement as A, type Breakpoint as B, type CompactType as C, type DroppingPosition as D, type EventCallback as E, type GridDragEvent as G, type Layout as L, type Mutable as M, type OnBreakpointChangeCallback as O, type Position as P, type ResizeHandleAxis as R, type Size as S, type Breakpoints as a, type Compactor as b, type GridResizeEvent as c, type LayoutItem as d, type ResponsiveLayouts as e, type LayoutConstraint as f, type ConstraintContext as g, type BreakpointCols as h, type DeepPartial as i, type DragConfig as j, type DragOverEvent as k, type DropConfig as l, type GridConfig as m, type OnLayoutChangeCallback as n, type PartialPosition as o, type PositionStrategy as p, type ReactDraggableCallbackData as q, type ResizeConfig as r, defaultDragConfig as s, defaultDropConfig as t, defaultGridConfig as u, defaultResizeConfig as v };
+5
-5

@@ -1,6 +0,6 @@

import { f as LayoutConstraint, a as LayoutItem, g as ConstraintContext, d as ResizeHandleAxis } from './types-BiXsdXr7.mjs';
export { A as ArrayElement, B as Breakpoint, p as BreakpointCols, b as Breakpoints, C as CompactType, c as Compactor, r as DeepPartial, m as DragConfig, j as DragOverEvent, o as DropConfig, D as DroppingPosition, E as EventCallback, l as GridConfig, G as GridDragEvent, e as GridResizeEvent, L as Layout, M as Mutable, q as OnBreakpointChangeCallback, O as OnLayoutChangeCallback, h as PartialPosition, P as Position, k as PositionStrategy, i as ReactDraggableCallbackData, n as ResizeConfig, R as ResponsiveLayouts, S as Size, t as defaultDragConfig, v as defaultDropConfig, s as defaultGridConfig, u as defaultResizeConfig } from './types-BiXsdXr7.mjs';
export { c as collides, h as findOrGenerateResponsiveLayout, a as getAllCollisions, e as getBreakpointFromWidth, f as getColsFromBreakpoint, g as getFirstCollision, j as getIndentationValue, i as sortBreakpoints, s as sortLayoutItems, d as sortLayoutItemsByColRow, b as sortLayoutItemsByRowCol } from './responsive-T0N0GmBB.mjs';
export { A as absoluteStrategy, b as bottom, c as cloneLayout, a as cloneLayoutItem, u as compactItemHorizontal, t as compactItemVertical, k as correctBounds, B as createScaledStrategy, C as defaultPositionStrategy, d as getCompactor, g as getLayoutItem, i as getStatics, h as horizontalCompactor, p as horizontalOverlapCompactor, j as modifyLayout, m as moveElement, l as moveElementAwayFromCollision, n as noCompactor, q as noOverlapCompactor, x as perc, y as resizeItemInDirection, r as resolveCompactionCollision, f as setTopLeft, s as setTransform, z as transformStrategy, v as validateLayout, e as verticalCompactor, o as verticalOverlapCompactor, w as withLayoutItem } from './position-CetgOHhD.mjs';
export { d as GridCellConfig, G as GridCellDimensions, P as PositionParams, j as calcGridCellDimensions, e as calcGridColWidth, c as calcGridItemPosition, f as calcGridItemWHPx, b as calcWH, h as calcWHRaw, a as calcXY, g as calcXYRaw, i as clamp } from './calculate-FbCWy8x1.mjs';
import { f as LayoutConstraint, d as LayoutItem, g as ConstraintContext, R as ResizeHandleAxis } from './types-jd8MiKM1.mjs';
export { A as ArrayElement, B as Breakpoint, h as BreakpointCols, a as Breakpoints, C as CompactType, b as Compactor, i as DeepPartial, j as DragConfig, k as DragOverEvent, l as DropConfig, D as DroppingPosition, E as EventCallback, m as GridConfig, G as GridDragEvent, c as GridResizeEvent, L as Layout, M as Mutable, O as OnBreakpointChangeCallback, n as OnLayoutChangeCallback, o as PartialPosition, P as Position, p as PositionStrategy, q as ReactDraggableCallbackData, r as ResizeConfig, e as ResponsiveLayouts, S as Size, s as defaultDragConfig, t as defaultDropConfig, u as defaultGridConfig, v as defaultResizeConfig } from './types-jd8MiKM1.mjs';
export { c as collides, f as findOrGenerateResponsiveLayout, g as getAllCollisions, a as getBreakpointFromWidth, b as getColsFromBreakpoint, d as getFirstCollision, i as getIndentationValue, j as sortBreakpoints, s as sortLayoutItems, e as sortLayoutItemsByColRow, h as sortLayoutItemsByRowCol } from './responsive-BrTV_0tK.mjs';
export { i as absoluteStrategy, b as bottom, c as cloneLayout, a as cloneLayoutItem, j as compactItemHorizontal, k as compactItemVertical, l as correctBounds, o as createScaledStrategy, p as defaultPositionStrategy, g as getCompactor, d as getLayoutItem, q as getStatics, h as horizontalCompactor, r as horizontalOverlapCompactor, t as modifyLayout, m as moveElement, u as moveElementAwayFromCollision, n as noCompactor, w as noOverlapCompactor, x as perc, y as resizeItemInDirection, z as resolveCompactionCollision, s as setTopLeft, e as setTransform, A as transformStrategy, v as validateLayout, f as verticalCompactor, B as verticalOverlapCompactor, C as withLayoutItem } from './position-BV-g3Ezg.mjs';
export { G as GridCellConfig, d as GridCellDimensions, P as PositionParams, e as calcGridCellDimensions, f as calcGridColWidth, c as calcGridItemPosition, g as calcGridItemWHPx, a as calcWH, h as calcWHRaw, b as calcXY, i as calcXYRaw, j as clamp } from './calculate-DH4EVtn1.mjs';

@@ -7,0 +7,0 @@ /**

@@ -1,6 +0,6 @@

import { f as LayoutConstraint, a as LayoutItem, g as ConstraintContext, d as ResizeHandleAxis } from './types-BiXsdXr7.js';
export { A as ArrayElement, B as Breakpoint, p as BreakpointCols, b as Breakpoints, C as CompactType, c as Compactor, r as DeepPartial, m as DragConfig, j as DragOverEvent, o as DropConfig, D as DroppingPosition, E as EventCallback, l as GridConfig, G as GridDragEvent, e as GridResizeEvent, L as Layout, M as Mutable, q as OnBreakpointChangeCallback, O as OnLayoutChangeCallback, h as PartialPosition, P as Position, k as PositionStrategy, i as ReactDraggableCallbackData, n as ResizeConfig, R as ResponsiveLayouts, S as Size, t as defaultDragConfig, v as defaultDropConfig, s as defaultGridConfig, u as defaultResizeConfig } from './types-BiXsdXr7.js';
export { c as collides, h as findOrGenerateResponsiveLayout, a as getAllCollisions, e as getBreakpointFromWidth, f as getColsFromBreakpoint, g as getFirstCollision, j as getIndentationValue, i as sortBreakpoints, s as sortLayoutItems, d as sortLayoutItemsByColRow, b as sortLayoutItemsByRowCol } from './responsive-DLRtE8v8.js';
export { A as absoluteStrategy, b as bottom, c as cloneLayout, a as cloneLayoutItem, u as compactItemHorizontal, t as compactItemVertical, k as correctBounds, B as createScaledStrategy, C as defaultPositionStrategy, d as getCompactor, g as getLayoutItem, i as getStatics, h as horizontalCompactor, p as horizontalOverlapCompactor, j as modifyLayout, m as moveElement, l as moveElementAwayFromCollision, n as noCompactor, q as noOverlapCompactor, x as perc, y as resizeItemInDirection, r as resolveCompactionCollision, f as setTopLeft, s as setTransform, z as transformStrategy, v as validateLayout, e as verticalCompactor, o as verticalOverlapCompactor, w as withLayoutItem } from './position-DhZqWO1-.js';
export { d as GridCellConfig, G as GridCellDimensions, P as PositionParams, j as calcGridCellDimensions, e as calcGridColWidth, c as calcGridItemPosition, f as calcGridItemWHPx, b as calcWH, h as calcWHRaw, a as calcXY, g as calcXYRaw, i as clamp } from './calculate-9RxGrt-U.js';
import { f as LayoutConstraint, d as LayoutItem, g as ConstraintContext, R as ResizeHandleAxis } from './types-jd8MiKM1.js';
export { A as ArrayElement, B as Breakpoint, h as BreakpointCols, a as Breakpoints, C as CompactType, b as Compactor, i as DeepPartial, j as DragConfig, k as DragOverEvent, l as DropConfig, D as DroppingPosition, E as EventCallback, m as GridConfig, G as GridDragEvent, c as GridResizeEvent, L as Layout, M as Mutable, O as OnBreakpointChangeCallback, n as OnLayoutChangeCallback, o as PartialPosition, P as Position, p as PositionStrategy, q as ReactDraggableCallbackData, r as ResizeConfig, e as ResponsiveLayouts, S as Size, s as defaultDragConfig, t as defaultDropConfig, u as defaultGridConfig, v as defaultResizeConfig } from './types-jd8MiKM1.js';
export { c as collides, f as findOrGenerateResponsiveLayout, g as getAllCollisions, a as getBreakpointFromWidth, b as getColsFromBreakpoint, d as getFirstCollision, i as getIndentationValue, j as sortBreakpoints, s as sortLayoutItems, e as sortLayoutItemsByColRow, h as sortLayoutItemsByRowCol } from './responsive-C_YtBQYq.js';
export { i as absoluteStrategy, b as bottom, c as cloneLayout, a as cloneLayoutItem, j as compactItemHorizontal, k as compactItemVertical, l as correctBounds, o as createScaledStrategy, p as defaultPositionStrategy, g as getCompactor, d as getLayoutItem, q as getStatics, h as horizontalCompactor, r as horizontalOverlapCompactor, t as modifyLayout, m as moveElement, u as moveElementAwayFromCollision, n as noCompactor, w as noOverlapCompactor, x as perc, y as resizeItemInDirection, z as resolveCompactionCollision, s as setTopLeft, e as setTransform, A as transformStrategy, v as validateLayout, f as verticalCompactor, B as verticalOverlapCompactor, C as withLayoutItem } from './position-CSgQSjwQ.js';
export { G as GridCellConfig, d as GridCellDimensions, P as PositionParams, e as calcGridCellDimensions, f as calcGridColWidth, c as calcGridItemPosition, g as calcGridItemWHPx, a as calcWH, h as calcWHRaw, b as calcXY, i as calcXYRaw, j as clamp } from './calculate-rP3DHexe.js';

@@ -7,0 +7,0 @@ /**

'use strict';
require('./chunk-PBQSHIID.js');
var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
require('./chunk-ZJHF4QM5.js');
var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');

@@ -11,261 +11,259 @@

enumerable: true,
get: function () { return chunk2DDROKB2_js.absoluteStrategy; }
get: function () { return chunk55DQUWLA_js.absoluteStrategy; }
});
Object.defineProperty(exports, "applyPositionConstraints", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.applyPositionConstraints; }
get: function () { return chunk55DQUWLA_js.applyPositionConstraints; }
});
Object.defineProperty(exports, "applySizeConstraints", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.applySizeConstraints; }
get: function () { return chunk55DQUWLA_js.applySizeConstraints; }
});
Object.defineProperty(exports, "aspectRatio", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.aspectRatio; }
get: function () { return chunk55DQUWLA_js.aspectRatio; }
});
Object.defineProperty(exports, "boundedX", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.boundedX; }
get: function () { return chunk55DQUWLA_js.boundedX; }
});
Object.defineProperty(exports, "boundedY", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.boundedY; }
get: function () { return chunk55DQUWLA_js.boundedY; }
});
Object.defineProperty(exports, "compactItemHorizontal", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.compactItemHorizontal; }
get: function () { return chunk55DQUWLA_js.compactItemHorizontal; }
});
Object.defineProperty(exports, "compactItemVertical", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.compactItemVertical; }
get: function () { return chunk55DQUWLA_js.compactItemVertical; }
});
Object.defineProperty(exports, "containerBounds", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.containerBounds; }
get: function () { return chunk55DQUWLA_js.containerBounds; }
});
Object.defineProperty(exports, "createScaledStrategy", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.createScaledStrategy; }
get: function () { return chunk55DQUWLA_js.createScaledStrategy; }
});
Object.defineProperty(exports, "defaultConstraints", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.defaultConstraints; }
get: function () { return chunk55DQUWLA_js.defaultConstraints; }
});
Object.defineProperty(exports, "defaultDragConfig", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.defaultDragConfig; }
get: function () { return chunk55DQUWLA_js.defaultDragConfig; }
});
Object.defineProperty(exports, "defaultDropConfig", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.defaultDropConfig; }
get: function () { return chunk55DQUWLA_js.defaultDropConfig; }
});
Object.defineProperty(exports, "defaultGridConfig", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.defaultGridConfig; }
get: function () { return chunk55DQUWLA_js.defaultGridConfig; }
});
Object.defineProperty(exports, "defaultPositionStrategy", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.defaultPositionStrategy; }
get: function () { return chunk55DQUWLA_js.defaultPositionStrategy; }
});
Object.defineProperty(exports, "defaultResizeConfig", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.defaultResizeConfig; }
get: function () { return chunk55DQUWLA_js.defaultResizeConfig; }
});
Object.defineProperty(exports, "findOrGenerateResponsiveLayout", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.findOrGenerateResponsiveLayout; }
get: function () { return chunk55DQUWLA_js.findOrGenerateResponsiveLayout; }
});
Object.defineProperty(exports, "getBreakpointFromWidth", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getBreakpointFromWidth; }
get: function () { return chunk55DQUWLA_js.getBreakpointFromWidth; }
});
Object.defineProperty(exports, "getColsFromBreakpoint", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getColsFromBreakpoint; }
get: function () { return chunk55DQUWLA_js.getColsFromBreakpoint; }
});
Object.defineProperty(exports, "getCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getCompactor; }
get: function () { return chunk55DQUWLA_js.getCompactor; }
});
Object.defineProperty(exports, "getIndentationValue", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getIndentationValue; }
get: function () { return chunk55DQUWLA_js.getIndentationValue; }
});
Object.defineProperty(exports, "gridBounds", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.gridBounds; }
get: function () { return chunk55DQUWLA_js.gridBounds; }
});
Object.defineProperty(exports, "horizontalCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.horizontalCompactor; }
get: function () { return chunk55DQUWLA_js.horizontalCompactor; }
});
Object.defineProperty(exports, "horizontalOverlapCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.horizontalOverlapCompactor; }
get: function () { return chunk55DQUWLA_js.horizontalOverlapCompactor; }
});
Object.defineProperty(exports, "maxSize", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.maxSize; }
get: function () { return chunk55DQUWLA_js.maxSize; }
});
Object.defineProperty(exports, "minMaxSize", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.minMaxSize; }
get: function () { return chunk55DQUWLA_js.minMaxSize; }
});
Object.defineProperty(exports, "minSize", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.minSize; }
get: function () { return chunk55DQUWLA_js.minSize; }
});
Object.defineProperty(exports, "noCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.noCompactor; }
get: function () { return chunk55DQUWLA_js.noCompactor; }
});
Object.defineProperty(exports, "noOverlapCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.noOverlapCompactor; }
get: function () { return chunk55DQUWLA_js.noOverlapCompactor; }
});
Object.defineProperty(exports, "perc", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.perc; }
get: function () { return chunk55DQUWLA_js.perc; }
});
Object.defineProperty(exports, "resizeItemInDirection", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.resizeItemInDirection; }
get: function () { return chunk55DQUWLA_js.resizeItemInDirection; }
});
Object.defineProperty(exports, "resolveCompactionCollision", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.resolveCompactionCollision; }
get: function () { return chunk55DQUWLA_js.resolveCompactionCollision; }
});
Object.defineProperty(exports, "setTopLeft", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.setTopLeft; }
get: function () { return chunk55DQUWLA_js.setTopLeft; }
});
Object.defineProperty(exports, "setTransform", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.setTransform; }
get: function () { return chunk55DQUWLA_js.setTransform; }
});
Object.defineProperty(exports, "snapToGrid", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.snapToGrid; }
get: function () { return chunk55DQUWLA_js.snapToGrid; }
});
Object.defineProperty(exports, "sortBreakpoints", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.sortBreakpoints; }
get: function () { return chunk55DQUWLA_js.sortBreakpoints; }
});
Object.defineProperty(exports, "transformStrategy", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.transformStrategy; }
get: function () { return chunk55DQUWLA_js.transformStrategy; }
});
Object.defineProperty(exports, "verticalCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.verticalCompactor; }
get: function () { return chunk55DQUWLA_js.verticalCompactor; }
});
Object.defineProperty(exports, "verticalOverlapCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.verticalOverlapCompactor; }
get: function () { return chunk55DQUWLA_js.verticalOverlapCompactor; }
});
Object.defineProperty(exports, "bottom", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.bottom; }
get: function () { return chunkA5WIFECI_js.bottom; }
});
Object.defineProperty(exports, "calcGridCellDimensions", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcGridCellDimensions; }
get: function () { return chunkA5WIFECI_js.calcGridCellDimensions; }
});
Object.defineProperty(exports, "calcGridColWidth", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcGridColWidth; }
get: function () { return chunkA5WIFECI_js.calcGridColWidth; }
});
Object.defineProperty(exports, "calcGridItemPosition", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcGridItemPosition; }
get: function () { return chunkA5WIFECI_js.calcGridItemPosition; }
});
Object.defineProperty(exports, "calcGridItemWHPx", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcGridItemWHPx; }
get: function () { return chunkA5WIFECI_js.calcGridItemWHPx; }
});
Object.defineProperty(exports, "calcWH", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcWH; }
get: function () { return chunkA5WIFECI_js.calcWH; }
});
Object.defineProperty(exports, "calcWHRaw", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcWHRaw; }
get: function () { return chunkA5WIFECI_js.calcWHRaw; }
});
Object.defineProperty(exports, "calcXY", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcXY; }
get: function () { return chunkA5WIFECI_js.calcXY; }
});
Object.defineProperty(exports, "calcXYRaw", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcXYRaw; }
get: function () { return chunkA5WIFECI_js.calcXYRaw; }
});
Object.defineProperty(exports, "clamp", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.clamp; }
get: function () { return chunkA5WIFECI_js.clamp; }
});
Object.defineProperty(exports, "cloneLayout", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.cloneLayout; }
get: function () { return chunkA5WIFECI_js.cloneLayout; }
});
Object.defineProperty(exports, "cloneLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.cloneLayoutItem; }
get: function () { return chunkA5WIFECI_js.cloneLayoutItem; }
});
Object.defineProperty(exports, "collides", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.collides; }
get: function () { return chunkA5WIFECI_js.collides; }
});
Object.defineProperty(exports, "correctBounds", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.correctBounds; }
get: function () { return chunkA5WIFECI_js.correctBounds; }
});
Object.defineProperty(exports, "getAllCollisions", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getAllCollisions; }
get: function () { return chunkA5WIFECI_js.getAllCollisions; }
});
Object.defineProperty(exports, "getFirstCollision", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getFirstCollision; }
get: function () { return chunkA5WIFECI_js.getFirstCollision; }
});
Object.defineProperty(exports, "getLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getLayoutItem; }
get: function () { return chunkA5WIFECI_js.getLayoutItem; }
});
Object.defineProperty(exports, "getStatics", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getStatics; }
get: function () { return chunkA5WIFECI_js.getStatics; }
});
Object.defineProperty(exports, "modifyLayout", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.modifyLayout; }
get: function () { return chunkA5WIFECI_js.modifyLayout; }
});
Object.defineProperty(exports, "moveElement", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.moveElement; }
get: function () { return chunkA5WIFECI_js.moveElement; }
});
Object.defineProperty(exports, "moveElementAwayFromCollision", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.moveElementAwayFromCollision; }
get: function () { return chunkA5WIFECI_js.moveElementAwayFromCollision; }
});
Object.defineProperty(exports, "sortLayoutItems", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.sortLayoutItems; }
get: function () { return chunkA5WIFECI_js.sortLayoutItems; }
});
Object.defineProperty(exports, "sortLayoutItemsByColRow", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.sortLayoutItemsByColRow; }
get: function () { return chunkA5WIFECI_js.sortLayoutItemsByColRow; }
});
Object.defineProperty(exports, "sortLayoutItemsByRowCol", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.sortLayoutItemsByRowCol; }
get: function () { return chunkA5WIFECI_js.sortLayoutItemsByRowCol; }
});
Object.defineProperty(exports, "validateLayout", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.validateLayout; }
get: function () { return chunkA5WIFECI_js.validateLayout; }
});
Object.defineProperty(exports, "withLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.withLayoutItem; }
get: function () { return chunkA5WIFECI_js.withLayoutItem; }
});
//# sourceMappingURL=core.js.map
//# sourceMappingURL=core.js.map

@@ -1,5 +0,3 @@

import './chunk-ZWN22PS2.mjs';
export { absoluteStrategy, applyPositionConstraints, applySizeConstraints, aspectRatio, boundedX, boundedY, compactItemHorizontal, compactItemVertical, containerBounds, createScaledStrategy, defaultConstraints, defaultDragConfig, defaultDropConfig, defaultGridConfig, defaultPositionStrategy, defaultResizeConfig, findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, getIndentationValue, gridBounds, horizontalCompactor, horizontalOverlapCompactor, maxSize, minMaxSize, minSize, noCompactor, noOverlapCompactor, perc, resizeItemInDirection, resolveCompactionCollision, setTopLeft, setTransform, snapToGrid, sortBreakpoints, transformStrategy, verticalCompactor, verticalOverlapCompactor } from './chunk-XYPIYYYQ.mjs';
export { bottom, calcGridCellDimensions, calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcWHRaw, calcXY, calcXYRaw, clamp, cloneLayout, cloneLayoutItem, collides, correctBounds, getAllCollisions, getFirstCollision, getLayoutItem, getStatics, modifyLayout, moveElement, moveElementAwayFromCollision, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout, withLayoutItem } from './chunk-AWM66AWF.mjs';
//# sourceMappingURL=core.mjs.map
//# sourceMappingURL=core.mjs.map
import './chunk-O3KX3VYW.mjs';
export { absoluteStrategy, applyPositionConstraints, applySizeConstraints, aspectRatio, boundedX, boundedY, compactItemHorizontal, compactItemVertical, containerBounds, createScaledStrategy, defaultConstraints, defaultDragConfig, defaultDropConfig, defaultGridConfig, defaultPositionStrategy, defaultResizeConfig, findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, getIndentationValue, gridBounds, horizontalCompactor, horizontalOverlapCompactor, maxSize, minMaxSize, minSize, noCompactor, noOverlapCompactor, perc, resizeItemInDirection, resolveCompactionCollision, setTopLeft, setTransform, snapToGrid, sortBreakpoints, transformStrategy, verticalCompactor, verticalOverlapCompactor } from './chunk-KDANGDDL.mjs';
export { bottom, calcGridCellDimensions, calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcWHRaw, calcXY, calcXYRaw, clamp, cloneLayout, cloneLayoutItem, collides, correctBounds, getAllCollisions, getFirstCollision, getLayoutItem, getStatics, modifyLayout, moveElement, moveElementAwayFromCollision, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout, withLayoutItem } from './chunk-76RTO6EO.mjs';
import * as React from 'react';
import { d as GridCellConfig } from './calculate-FbCWy8x1.mjs';
import { c as Compactor } from './types-BiXsdXr7.mjs';
import { G as GridCellConfig } from './calculate-DH4EVtn1.mjs';
import { b as Compactor } from './types-jd8MiKM1.mjs';

@@ -5,0 +5,0 @@ /**

import * as React from 'react';
import { d as GridCellConfig } from './calculate-9RxGrt-U.js';
import { c as Compactor } from './types-BiXsdXr7.js';
import { G as GridCellConfig } from './calculate-rP3DHexe.js';
import { b as Compactor } from './types-jd8MiKM1.js';

@@ -5,0 +5,0 @@ /**

'use strict';
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');
var react = require('react');

@@ -21,3 +21,3 @@ var jsxRuntime = require('react/jsx-runtime');

const dims = react.useMemo(
() => chunkBJFPTW5Q_js.calcGridCellDimensions({
() => chunkA5WIFECI_js.calcGridCellDimensions({
width,

@@ -158,3 +158,3 @@ cols,

compact(layout, cols) {
const out = chunkBJFPTW5Q_js.cloneLayout(layout);
const out = chunkA5WIFECI_js.cloneLayout(layout);
compactVerticalFast(out, cols, false);

@@ -168,3 +168,3 @@ return out;

compact(layout, cols) {
const out = chunkBJFPTW5Q_js.cloneLayout(layout);
const out = chunkA5WIFECI_js.cloneLayout(layout);
compactVerticalFast(out, cols, true);

@@ -298,3 +298,3 @@ return out;

compact(layout, cols) {
const out = chunkBJFPTW5Q_js.cloneLayout(layout);
const out = chunkA5WIFECI_js.cloneLayout(layout);
compactHorizontalFast(out, cols, false);

@@ -308,3 +308,3 @@ return out;

compact(layout, cols) {
const out = chunkBJFPTW5Q_js.cloneLayout(layout);
const out = chunkA5WIFECI_js.cloneLayout(layout);
compactHorizontalFast(out, cols, true);

@@ -345,3 +345,3 @@ return out;

if (sortedItem === void 0) continue;
const l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
const l = chunkA5WIFECI_js.cloneLayoutItem(sortedItem);
if (l.static) {

@@ -384,3 +384,3 @@ const originalIndex2 = layout.indexOf(sortedItem);

compact(layout, _cols) {
return chunkBJFPTW5Q_js.cloneLayout(layout);
return chunkA5WIFECI_js.cloneLayout(layout);
}

@@ -396,3 +396,1 @@ };

exports.wrapOverlapCompactor = wrapOverlapCompactor;
//# sourceMappingURL=extras.js.map
//# sourceMappingURL=extras.js.map

@@ -1,2 +0,2 @@

import { calcGridCellDimensions, cloneLayout, cloneLayoutItem } from './chunk-AWM66AWF.mjs';
import { calcGridCellDimensions, cloneLayout, cloneLayoutItem } from './chunk-76RTO6EO.mjs';
import { useMemo } from 'react';

@@ -381,3 +381,1 @@ import { jsx } from 'react/jsx-runtime';

export { GridBackground, fastHorizontalCompactor, fastHorizontalOverlapCompactor, fastVerticalCompactor, fastVerticalOverlapCompactor, wrapCompactor, wrapOverlapCompactor };
//# sourceMappingURL=extras.mjs.map
//# sourceMappingURL=extras.mjs.map
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, DefaultBreakpoints, DragState, DropState, GridItem, GridItemCallback, GridItemProps, ResizeHandle, ResizeState, UseContainerWidthOptions, UseContainerWidthResult, UseGridLayoutOptions, UseGridLayoutResult, UseResponsiveLayoutOptions, UseResponsiveLayoutResult, useContainerWidth, useGridLayout, useResponsiveLayout } from './react.mjs';
export { G as GridLayout, a as GridLayoutProps, G as ReactGridLayout, a as ReactGridLayoutProps, R as Responsive, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps, b as ResponsiveProps, G as default } from './ResponsiveGridLayout-DqK__izz.mjs';
export { B as Breakpoint, b as Breakpoints, C as CompactType, c as Compactor, D as DroppingPosition, E as EventCallback, G as GridDragEvent, e as GridResizeEvent, L as Layout, a as LayoutItem, P as Position, d as ResizeHandleAxis, R as ResponsiveLayouts } from './types-BiXsdXr7.mjs';
export { c as collides, h as findOrGenerateResponsiveLayout, a as getAllCollisions, e as getBreakpointFromWidth, f as getColsFromBreakpoint, g as getFirstCollision, s as sortLayoutItems, d as sortLayoutItemsByColRow, b as sortLayoutItemsByRowCol } from './responsive-T0N0GmBB.mjs';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, d as getCompactor, g as getLayoutItem, h as horizontalCompactor, m as moveElement, n as noCompactor, f as setTopLeft, s as setTransform, v as validateLayout, e as verticalCompactor } from './position-CetgOHhD.mjs';
export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-FbCWy8x1.mjs';
export { G as GridLayout, a as GridLayoutProps, G as ReactGridLayout, a as ReactGridLayoutProps, R as Responsive, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps, b as ResponsiveProps, G as default } from './ResponsiveGridLayout-BjVraYMQ.mjs';
export { B as Breakpoint, a as Breakpoints, C as CompactType, b as Compactor, D as DroppingPosition, E as EventCallback, G as GridDragEvent, c as GridResizeEvent, L as Layout, d as LayoutItem, P as Position, R as ResizeHandleAxis, e as ResponsiveLayouts } from './types-jd8MiKM1.mjs';
export { c as collides, f as findOrGenerateResponsiveLayout, g as getAllCollisions, a as getBreakpointFromWidth, b as getColsFromBreakpoint, d as getFirstCollision, s as sortLayoutItems, e as sortLayoutItemsByColRow, h as sortLayoutItemsByRowCol } from './responsive-BrTV_0tK.mjs';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, g as getCompactor, d as getLayoutItem, h as horizontalCompactor, m as moveElement, n as noCompactor, s as setTopLeft, e as setTransform, v as validateLayout, f as verticalCompactor } from './position-BV-g3Ezg.mjs';
export { c as calcGridItemPosition, a as calcWH, b as calcXY } from './calculate-DH4EVtn1.mjs';
import 'react';
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, DefaultBreakpoints, DragState, DropState, GridItem, GridItemCallback, GridItemProps, ResizeHandle, ResizeState, UseContainerWidthOptions, UseContainerWidthResult, UseGridLayoutOptions, UseGridLayoutResult, UseResponsiveLayoutOptions, UseResponsiveLayoutResult, useContainerWidth, useGridLayout, useResponsiveLayout } from './react.js';
export { G as GridLayout, a as GridLayoutProps, G as ReactGridLayout, a as ReactGridLayoutProps, R as Responsive, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps, b as ResponsiveProps, G as default } from './ResponsiveGridLayout-MbDNfJ8M.js';
export { B as Breakpoint, b as Breakpoints, C as CompactType, c as Compactor, D as DroppingPosition, E as EventCallback, G as GridDragEvent, e as GridResizeEvent, L as Layout, a as LayoutItem, P as Position, d as ResizeHandleAxis, R as ResponsiveLayouts } from './types-BiXsdXr7.js';
export { c as collides, h as findOrGenerateResponsiveLayout, a as getAllCollisions, e as getBreakpointFromWidth, f as getColsFromBreakpoint, g as getFirstCollision, s as sortLayoutItems, d as sortLayoutItemsByColRow, b as sortLayoutItemsByRowCol } from './responsive-DLRtE8v8.js';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, d as getCompactor, g as getLayoutItem, h as horizontalCompactor, m as moveElement, n as noCompactor, f as setTopLeft, s as setTransform, v as validateLayout, e as verticalCompactor } from './position-DhZqWO1-.js';
export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-9RxGrt-U.js';
export { G as GridLayout, a as GridLayoutProps, G as ReactGridLayout, a as ReactGridLayoutProps, R as Responsive, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps, b as ResponsiveProps, G as default } from './ResponsiveGridLayout-BrhkSyZk.js';
export { B as Breakpoint, a as Breakpoints, C as CompactType, b as Compactor, D as DroppingPosition, E as EventCallback, G as GridDragEvent, c as GridResizeEvent, L as Layout, d as LayoutItem, P as Position, R as ResizeHandleAxis, e as ResponsiveLayouts } from './types-jd8MiKM1.js';
export { c as collides, f as findOrGenerateResponsiveLayout, g as getAllCollisions, a as getBreakpointFromWidth, b as getColsFromBreakpoint, d as getFirstCollision, s as sortLayoutItems, e as sortLayoutItemsByColRow, h as sortLayoutItemsByRowCol } from './responsive-C_YtBQYq.js';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, g as getCompactor, d as getLayoutItem, h as horizontalCompactor, m as moveElement, n as noCompactor, s as setTopLeft, e as setTransform, v as validateLayout, f as verticalCompactor } from './position-CSgQSjwQ.js';
export { c as calcGridItemPosition, a as calcWH, b as calcXY } from './calculate-rP3DHexe.js';
import 'react';

@@ -5,7 +5,7 @@ 'use strict';

var chunkQGXQSZII_js = require('./chunk-QGXQSZII.js');
require('./chunk-PBQSHIID.js');
var chunkKEM2G3LX_js = require('./chunk-KEM2G3LX.js');
var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
var chunk7MZZ6T4J_js = require('./chunk-7MZZ6T4J.js');
require('./chunk-ZJHF4QM5.js');
var chunkBPZQUJ7Y_js = require('./chunk-BPZQUJ7Y.js');
var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');

@@ -16,141 +16,139 @@

enumerable: true,
get: function () { return chunkQGXQSZII_js.DEFAULT_BREAKPOINTS; }
get: function () { return chunk7MZZ6T4J_js.DEFAULT_BREAKPOINTS; }
});
Object.defineProperty(exports, "DEFAULT_COLS", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.DEFAULT_COLS; }
get: function () { return chunk7MZZ6T4J_js.DEFAULT_COLS; }
});
Object.defineProperty(exports, "useContainerWidth", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.useContainerWidth; }
get: function () { return chunk7MZZ6T4J_js.useContainerWidth; }
});
Object.defineProperty(exports, "useGridLayout", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.useGridLayout; }
get: function () { return chunk7MZZ6T4J_js.useGridLayout; }
});
Object.defineProperty(exports, "useResponsiveLayout", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.useResponsiveLayout; }
get: function () { return chunk7MZZ6T4J_js.useResponsiveLayout; }
});
Object.defineProperty(exports, "GridItem", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.GridItem; }
get: function () { return chunkBPZQUJ7Y_js.GridItem; }
});
Object.defineProperty(exports, "GridLayout", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.GridLayout; }
get: function () { return chunkBPZQUJ7Y_js.GridLayout; }
});
Object.defineProperty(exports, "ReactGridLayout", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.GridLayout; }
get: function () { return chunkBPZQUJ7Y_js.GridLayout; }
});
Object.defineProperty(exports, "Responsive", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.ResponsiveGridLayout; }
get: function () { return chunkBPZQUJ7Y_js.ResponsiveGridLayout; }
});
Object.defineProperty(exports, "ResponsiveGridLayout", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.ResponsiveGridLayout; }
get: function () { return chunkBPZQUJ7Y_js.ResponsiveGridLayout; }
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.GridLayout; }
get: function () { return chunkBPZQUJ7Y_js.GridLayout; }
});
Object.defineProperty(exports, "findOrGenerateResponsiveLayout", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.findOrGenerateResponsiveLayout; }
get: function () { return chunk55DQUWLA_js.findOrGenerateResponsiveLayout; }
});
Object.defineProperty(exports, "getBreakpointFromWidth", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getBreakpointFromWidth; }
get: function () { return chunk55DQUWLA_js.getBreakpointFromWidth; }
});
Object.defineProperty(exports, "getColsFromBreakpoint", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getColsFromBreakpoint; }
get: function () { return chunk55DQUWLA_js.getColsFromBreakpoint; }
});
Object.defineProperty(exports, "getCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getCompactor; }
get: function () { return chunk55DQUWLA_js.getCompactor; }
});
Object.defineProperty(exports, "horizontalCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.horizontalCompactor; }
get: function () { return chunk55DQUWLA_js.horizontalCompactor; }
});
Object.defineProperty(exports, "noCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.noCompactor; }
get: function () { return chunk55DQUWLA_js.noCompactor; }
});
Object.defineProperty(exports, "setTopLeft", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.setTopLeft; }
get: function () { return chunk55DQUWLA_js.setTopLeft; }
});
Object.defineProperty(exports, "setTransform", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.setTransform; }
get: function () { return chunk55DQUWLA_js.setTransform; }
});
Object.defineProperty(exports, "verticalCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.verticalCompactor; }
get: function () { return chunk55DQUWLA_js.verticalCompactor; }
});
Object.defineProperty(exports, "bottom", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.bottom; }
get: function () { return chunkA5WIFECI_js.bottom; }
});
Object.defineProperty(exports, "calcGridItemPosition", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcGridItemPosition; }
get: function () { return chunkA5WIFECI_js.calcGridItemPosition; }
});
Object.defineProperty(exports, "calcWH", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcWH; }
get: function () { return chunkA5WIFECI_js.calcWH; }
});
Object.defineProperty(exports, "calcXY", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcXY; }
get: function () { return chunkA5WIFECI_js.calcXY; }
});
Object.defineProperty(exports, "cloneLayout", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.cloneLayout; }
get: function () { return chunkA5WIFECI_js.cloneLayout; }
});
Object.defineProperty(exports, "cloneLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.cloneLayoutItem; }
get: function () { return chunkA5WIFECI_js.cloneLayoutItem; }
});
Object.defineProperty(exports, "collides", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.collides; }
get: function () { return chunkA5WIFECI_js.collides; }
});
Object.defineProperty(exports, "getAllCollisions", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getAllCollisions; }
get: function () { return chunkA5WIFECI_js.getAllCollisions; }
});
Object.defineProperty(exports, "getFirstCollision", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getFirstCollision; }
get: function () { return chunkA5WIFECI_js.getFirstCollision; }
});
Object.defineProperty(exports, "getLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getLayoutItem; }
get: function () { return chunkA5WIFECI_js.getLayoutItem; }
});
Object.defineProperty(exports, "moveElement", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.moveElement; }
get: function () { return chunkA5WIFECI_js.moveElement; }
});
Object.defineProperty(exports, "sortLayoutItems", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.sortLayoutItems; }
get: function () { return chunkA5WIFECI_js.sortLayoutItems; }
});
Object.defineProperty(exports, "sortLayoutItemsByColRow", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.sortLayoutItemsByColRow; }
get: function () { return chunkA5WIFECI_js.sortLayoutItemsByColRow; }
});
Object.defineProperty(exports, "sortLayoutItemsByRowCol", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.sortLayoutItemsByRowCol; }
get: function () { return chunkA5WIFECI_js.sortLayoutItemsByRowCol; }
});
Object.defineProperty(exports, "validateLayout", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.validateLayout; }
get: function () { return chunkA5WIFECI_js.validateLayout; }
});
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

@@ -1,7 +0,5 @@

export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout } from './chunk-YFVX5RDK.mjs';
import './chunk-ZWN22PS2.mjs';
export { GridItem, GridLayout, GridLayout as ReactGridLayout, ResponsiveGridLayout as Responsive, ResponsiveGridLayout, GridLayout as default } from './chunk-XM2M6TC6.mjs';
export { findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, horizontalCompactor, noCompactor, setTopLeft, setTransform, verticalCompactor } from './chunk-XYPIYYYQ.mjs';
export { bottom, calcGridItemPosition, calcWH, calcXY, cloneLayout, cloneLayoutItem, collides, getAllCollisions, getFirstCollision, getLayoutItem, moveElement, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout } from './chunk-AWM66AWF.mjs';
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout } from './chunk-PZLKKWSX.mjs';
import './chunk-O3KX3VYW.mjs';
export { GridItem, GridLayout, GridLayout as ReactGridLayout, ResponsiveGridLayout as Responsive, ResponsiveGridLayout, GridLayout as default } from './chunk-WGL5FSZH.mjs';
export { findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, horizontalCompactor, noCompactor, setTopLeft, setTransform, verticalCompactor } from './chunk-KDANGDDL.mjs';
export { bottom, calcGridItemPosition, calcWH, calcXY, cloneLayout, cloneLayoutItem, collides, getAllCollisions, getFirstCollision, getLayoutItem, moveElement, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout } from './chunk-76RTO6EO.mjs';
import * as react_jsx_runtime from 'react/jsx-runtime';
import React__default, { ComponentType } from 'react';
import { a as GridLayoutProps, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-DqK__izz.mjs';
import { L as Layout, a as LayoutItem, C as CompactType, d as ResizeHandleAxis, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-BiXsdXr7.mjs';
import { a as GridLayoutProps, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-BjVraYMQ.mjs';
import { L as Layout, d as LayoutItem, C as CompactType, R as ResizeHandleAxis, B as Breakpoint, a as Breakpoints, e as ResponsiveLayouts } from './types-jd8MiKM1.mjs';

@@ -6,0 +6,0 @@ /**

import * as react_jsx_runtime from 'react/jsx-runtime';
import React__default, { ComponentType } from 'react';
import { a as GridLayoutProps, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-MbDNfJ8M.js';
import { L as Layout, a as LayoutItem, C as CompactType, d as ResizeHandleAxis, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-BiXsdXr7.js';
import { a as GridLayoutProps, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-BrhkSyZk.js';
import { L as Layout, d as LayoutItem, C as CompactType, R as ResizeHandleAxis, B as Breakpoint, a as Breakpoints, e as ResponsiveLayouts } from './types-jd8MiKM1.js';

@@ -6,0 +6,0 @@ /**

@@ -5,5 +5,5 @@ 'use strict';

var chunkKEM2G3LX_js = require('./chunk-KEM2G3LX.js');
var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
require('./chunk-BJFPTW5Q.js');
var chunkBPZQUJ7Y_js = require('./chunk-BPZQUJ7Y.js');
var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
require('./chunk-A5WIFECI.js');
var react = require('react');

@@ -101,12 +101,12 @@ var jsxRuntime = require('react/jsx-runtime');

if (!useCSSTransforms) {
positionStrategy = chunk2DDROKB2_js.absoluteStrategy;
positionStrategy = chunk55DQUWLA_js.absoluteStrategy;
} else if (transformScale !== 1) {
positionStrategy = chunk2DDROKB2_js.createScaledStrategy(transformScale);
positionStrategy = chunk55DQUWLA_js.createScaledStrategy(transformScale);
} else {
positionStrategy = chunk2DDROKB2_js.transformStrategy;
positionStrategy = chunk55DQUWLA_js.transformStrategy;
}
const compactor = chunk2DDROKB2_js.getCompactor(compactType, allowOverlap, preventCollision);
const constraints = isBounded ? [...chunk2DDROKB2_js.defaultConstraints, chunk2DDROKB2_js.containerBounds] : chunk2DDROKB2_js.defaultConstraints;
const compactor = chunk55DQUWLA_js.getCompactor(compactType, allowOverlap, preventCollision);
const constraints = isBounded ? [...chunk55DQUWLA_js.defaultConstraints, chunk55DQUWLA_js.containerBounds] : chunk55DQUWLA_js.defaultConstraints;
return /* @__PURE__ */ jsxRuntime.jsx(
chunkKEM2G3LX_js.GridLayout,
chunkBPZQUJ7Y_js.GridLayout,
{

@@ -221,11 +221,11 @@ width,

if (!useCSSTransforms) {
positionStrategy = chunk2DDROKB2_js.absoluteStrategy;
positionStrategy = chunk55DQUWLA_js.absoluteStrategy;
} else if (transformScale !== 1) {
positionStrategy = chunk2DDROKB2_js.createScaledStrategy(transformScale);
positionStrategy = chunk55DQUWLA_js.createScaledStrategy(transformScale);
} else {
positionStrategy = chunk2DDROKB2_js.transformStrategy;
positionStrategy = chunk55DQUWLA_js.transformStrategy;
}
const compactor = chunk2DDROKB2_js.getCompactor(compactType, allowOverlap, preventCollision);
const compactor = chunk55DQUWLA_js.getCompactor(compactType, allowOverlap, preventCollision);
return /* @__PURE__ */ jsxRuntime.jsx(
chunkKEM2G3LX_js.ResponsiveGridLayout,
chunkBPZQUJ7Y_js.ResponsiveGridLayout,
{

@@ -282,6 +282,13 @@ width,

if (!(node instanceof HTMLElement)) return;
let rafId = null;
const observer = new ResizeObserver((entries) => {
if (entries[0]) {
const newWidth = entries[0].contentRect.width;
setWidth(newWidth);
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
rafId = requestAnimationFrame(() => {
setWidth(newWidth);
rafId = null;
});
}

@@ -292,2 +299,5 @@ });

return () => {
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
observer.unobserve(node);

@@ -327,3 +337,1 @@ observer.disconnect();

exports.default = ReactGridLayout_default;
//# sourceMappingURL=legacy.js.map
//# sourceMappingURL=legacy.js.map

@@ -1,4 +0,4 @@

import { GridLayout, ResponsiveGridLayout } from './chunk-XM2M6TC6.mjs';
import { createScaledStrategy, getCompactor, defaultConstraints, containerBounds, absoluteStrategy, transformStrategy } from './chunk-XYPIYYYQ.mjs';
import './chunk-AWM66AWF.mjs';
import { GridLayout, ResponsiveGridLayout } from './chunk-WGL5FSZH.mjs';
import { createScaledStrategy, getCompactor, defaultConstraints, containerBounds, absoluteStrategy, transformStrategy } from './chunk-KDANGDDL.mjs';
import './chunk-76RTO6EO.mjs';
import { useState, useRef, useEffect } from 'react';

@@ -271,6 +271,13 @@ import { jsx } from 'react/jsx-runtime';

if (!(node instanceof HTMLElement)) return;
let rafId = null;
const observer = new ResizeObserver((entries) => {
if (entries[0]) {
const newWidth = entries[0].contentRect.width;
setWidth(newWidth);
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
rafId = requestAnimationFrame(() => {
setWidth(newWidth);
rafId = null;
});
}

@@ -281,2 +288,5 @@ });

return () => {
if (rafId !== null) {
cancelAnimationFrame(rafId);
}
observer.unobserve(node);

@@ -312,3 +322,1 @@ observer.disconnect();

export { ReactGridLayout, ResponsiveReactGridLayout_default as Responsive, ResponsiveReactGridLayout, WidthProvider, ReactGridLayout_default as default };
//# sourceMappingURL=legacy.mjs.map
//# sourceMappingURL=legacy.mjs.map
import React__default, { ReactElement, CSSProperties, RefObject } from 'react';
import { k as PositionStrategy, D as DroppingPosition, d as ResizeHandleAxis, f as LayoutConstraint, a as LayoutItem, L as Layout, G as GridDragEvent, e as GridResizeEvent, c as Compactor, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-BiXsdXr7.mjs';
export { C as CompactType, P as Position } from './types-BiXsdXr7.mjs';
export { E as EventCallback, G as GridLayout, a as GridLayoutProps, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-DqK__izz.mjs';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, d as getCompactor, g as getLayoutItem, h as horizontalCompactor, n as noCompactor, f as setTopLeft, s as setTransform, e as verticalCompactor } from './position-CetgOHhD.mjs';
export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-FbCWy8x1.mjs';
import { p as PositionStrategy, D as DroppingPosition, R as ResizeHandleAxis, f as LayoutConstraint, d as LayoutItem, L as Layout, G as GridDragEvent, c as GridResizeEvent, b as Compactor, a as Breakpoints, B as Breakpoint, e as ResponsiveLayouts } from './types-jd8MiKM1.mjs';
export { C as CompactType, E as EventCallback, P as Position } from './types-jd8MiKM1.mjs';
export { G as GridLayout, a as GridLayoutProps, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-BjVraYMQ.mjs';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, g as getCompactor, d as getLayoutItem, h as horizontalCompactor, n as noCompactor, s as setTopLeft, e as setTransform, f as verticalCompactor } from './position-BV-g3Ezg.mjs';
export { c as calcGridItemPosition, a as calcWH, b as calcXY } from './calculate-DH4EVtn1.mjs';

@@ -8,0 +8,0 @@ /**

import React__default, { ReactElement, CSSProperties, RefObject } from 'react';
import { k as PositionStrategy, D as DroppingPosition, d as ResizeHandleAxis, f as LayoutConstraint, a as LayoutItem, L as Layout, G as GridDragEvent, e as GridResizeEvent, c as Compactor, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-BiXsdXr7.js';
export { C as CompactType, P as Position } from './types-BiXsdXr7.js';
export { E as EventCallback, G as GridLayout, a as GridLayoutProps, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-MbDNfJ8M.js';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, d as getCompactor, g as getLayoutItem, h as horizontalCompactor, n as noCompactor, f as setTopLeft, s as setTransform, e as verticalCompactor } from './position-DhZqWO1-.js';
export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-9RxGrt-U.js';
import { p as PositionStrategy, D as DroppingPosition, R as ResizeHandleAxis, f as LayoutConstraint, d as LayoutItem, L as Layout, G as GridDragEvent, c as GridResizeEvent, b as Compactor, a as Breakpoints, B as Breakpoint, e as ResponsiveLayouts } from './types-jd8MiKM1.js';
export { C as CompactType, E as EventCallback, P as Position } from './types-jd8MiKM1.js';
export { G as GridLayout, a as GridLayoutProps, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-BrhkSyZk.js';
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, g as getCompactor, d as getLayoutItem, h as horizontalCompactor, n as noCompactor, s as setTopLeft, e as setTransform, f as verticalCompactor } from './position-CSgQSjwQ.js';
export { c as calcGridItemPosition, a as calcWH, b as calcXY } from './calculate-rP3DHexe.js';

@@ -8,0 +8,0 @@ /**

'use strict';
var chunkQGXQSZII_js = require('./chunk-QGXQSZII.js');
require('./chunk-PBQSHIID.js');
var chunkKEM2G3LX_js = require('./chunk-KEM2G3LX.js');
var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
var chunk7MZZ6T4J_js = require('./chunk-7MZZ6T4J.js');
require('./chunk-ZJHF4QM5.js');
var chunkBPZQUJ7Y_js = require('./chunk-BPZQUJ7Y.js');
var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');

@@ -13,85 +13,83 @@

enumerable: true,
get: function () { return chunkQGXQSZII_js.DEFAULT_BREAKPOINTS; }
get: function () { return chunk7MZZ6T4J_js.DEFAULT_BREAKPOINTS; }
});
Object.defineProperty(exports, "DEFAULT_COLS", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.DEFAULT_COLS; }
get: function () { return chunk7MZZ6T4J_js.DEFAULT_COLS; }
});
Object.defineProperty(exports, "useContainerWidth", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.useContainerWidth; }
get: function () { return chunk7MZZ6T4J_js.useContainerWidth; }
});
Object.defineProperty(exports, "useGridLayout", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.useGridLayout; }
get: function () { return chunk7MZZ6T4J_js.useGridLayout; }
});
Object.defineProperty(exports, "useResponsiveLayout", {
enumerable: true,
get: function () { return chunkQGXQSZII_js.useResponsiveLayout; }
get: function () { return chunk7MZZ6T4J_js.useResponsiveLayout; }
});
Object.defineProperty(exports, "GridItem", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.GridItem; }
get: function () { return chunkBPZQUJ7Y_js.GridItem; }
});
Object.defineProperty(exports, "GridLayout", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.GridLayout; }
get: function () { return chunkBPZQUJ7Y_js.GridLayout; }
});
Object.defineProperty(exports, "ResponsiveGridLayout", {
enumerable: true,
get: function () { return chunkKEM2G3LX_js.ResponsiveGridLayout; }
get: function () { return chunkBPZQUJ7Y_js.ResponsiveGridLayout; }
});
Object.defineProperty(exports, "getCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.getCompactor; }
get: function () { return chunk55DQUWLA_js.getCompactor; }
});
Object.defineProperty(exports, "horizontalCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.horizontalCompactor; }
get: function () { return chunk55DQUWLA_js.horizontalCompactor; }
});
Object.defineProperty(exports, "noCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.noCompactor; }
get: function () { return chunk55DQUWLA_js.noCompactor; }
});
Object.defineProperty(exports, "setTopLeft", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.setTopLeft; }
get: function () { return chunk55DQUWLA_js.setTopLeft; }
});
Object.defineProperty(exports, "setTransform", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.setTransform; }
get: function () { return chunk55DQUWLA_js.setTransform; }
});
Object.defineProperty(exports, "verticalCompactor", {
enumerable: true,
get: function () { return chunk2DDROKB2_js.verticalCompactor; }
get: function () { return chunk55DQUWLA_js.verticalCompactor; }
});
Object.defineProperty(exports, "bottom", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.bottom; }
get: function () { return chunkA5WIFECI_js.bottom; }
});
Object.defineProperty(exports, "calcGridItemPosition", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcGridItemPosition; }
get: function () { return chunkA5WIFECI_js.calcGridItemPosition; }
});
Object.defineProperty(exports, "calcWH", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcWH; }
get: function () { return chunkA5WIFECI_js.calcWH; }
});
Object.defineProperty(exports, "calcXY", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.calcXY; }
get: function () { return chunkA5WIFECI_js.calcXY; }
});
Object.defineProperty(exports, "cloneLayout", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.cloneLayout; }
get: function () { return chunkA5WIFECI_js.cloneLayout; }
});
Object.defineProperty(exports, "cloneLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.cloneLayoutItem; }
get: function () { return chunkA5WIFECI_js.cloneLayoutItem; }
});
Object.defineProperty(exports, "getLayoutItem", {
enumerable: true,
get: function () { return chunkBJFPTW5Q_js.getLayoutItem; }
get: function () { return chunkA5WIFECI_js.getLayoutItem; }
});
//# sourceMappingURL=react.js.map
//# sourceMappingURL=react.js.map

@@ -1,7 +0,5 @@

export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout } from './chunk-YFVX5RDK.mjs';
import './chunk-ZWN22PS2.mjs';
export { GridItem, GridLayout, ResponsiveGridLayout } from './chunk-XM2M6TC6.mjs';
export { getCompactor, horizontalCompactor, noCompactor, setTopLeft, setTransform, verticalCompactor } from './chunk-XYPIYYYQ.mjs';
export { bottom, calcGridItemPosition, calcWH, calcXY, cloneLayout, cloneLayoutItem, getLayoutItem } from './chunk-AWM66AWF.mjs';
//# sourceMappingURL=react.mjs.map
//# sourceMappingURL=react.mjs.map
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout } from './chunk-PZLKKWSX.mjs';
import './chunk-O3KX3VYW.mjs';
export { GridItem, GridLayout, ResponsiveGridLayout } from './chunk-WGL5FSZH.mjs';
export { getCompactor, horizontalCompactor, noCompactor, setTopLeft, setTransform, verticalCompactor } from './chunk-KDANGDDL.mjs';
export { bottom, calcGridItemPosition, calcWH, calcXY, cloneLayout, cloneLayoutItem, getLayoutItem } from './chunk-76RTO6EO.mjs';
{
"name": "react-grid-layout",
"version": "2.2.2",
"version": "2.2.3",
"description": "A draggable and resizable grid layout with responsive breakpoints, for React.",

@@ -112,3 +112,3 @@ "main": "dist/index.js",

"react-draggable": "^4.4.6",
"react-resizable": "^3.0.5",
"react-resizable": "^3.1.3",
"resize-observer-polyfill": "^1.5.1"

@@ -120,17 +120,17 @@ },

"devDependencies": {
"@babel/cli": "^7.27.2",
"@babel/core": "^7.27.4",
"@babel/eslint-parser": "^7.27.5",
"@babel/plugin-transform-class-properties": "^7.18.6",
"@babel/preset-env": "^7.27.2",
"@babel/cli": "^7.28.6",
"@babel/core": "^7.29.0",
"@babel/eslint-parser": "^7.28.6",
"@babel/plugin-transform-class-properties": "^7.28.6",
"@babel/preset-env": "^7.29.0",
"@babel/preset-react": "^7.27.1",
"@babel/preset-typescript": "^7.28.5",
"@babel/register": "^7.27.1",
"@eslint/compat": "^1.2.0",
"@eslint/js": "^9.0.0",
"@babel/register": "^7.28.6",
"@eslint/compat": "^2.0.2",
"@eslint/js": "^9.39.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/node": "^24.10.1",
"@types/react": "^19.2.7",
"@testing-library/react": "^16.3.2",
"@types/node": "^25.2.3",
"@types/react": "^19.2.14",
"@webpack-cli/serve": "^3.0.1",

@@ -140,11 +140,11 @@ "babel-jest": "^30.2.0",

"babel-plugin-preval": "^5.1.0",
"css-loader": "^7.1.2",
"ejs": "^3.1.10",
"eslint": "^9.39.1",
"css-loader": "^7.1.3",
"ejs": "^4.0.1",
"eslint": "^9.39.2",
"eslint-plugin-mocha": "^11.2.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-unicorn": "^62.0.0",
"eslint-plugin-unicorn": "^63.0.0",
"exports-loader": "^5.0.0",
"globals": "^16.0.0",
"globals": "^17.3.0",
"husky": "^9.1.7",

@@ -157,3 +157,3 @@ "imports-loader": "^5.0.0",

"opener": "^1.5.2",
"prettier": "^3.1.0",
"prettier": "^3.8.1",
"react": "^18.3.1",

@@ -168,6 +168,6 @@ "react-dom": "^18.3.1",

"typescript": "^5.9.3",
"typescript-eslint": "^8.49.0",
"webpack": "^5.92.0",
"typescript-eslint": "^8.55.0",
"webpack": "^5.105.2",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2"
"webpack-dev-server": "^5.2.3"
},

@@ -174,0 +174,0 @@ "resolutions": {

import { P as Position, d as ResizeHandleAxis } from './types-BiXsdXr7.js';
/**
* Grid calculation utilities.
*
* These functions convert between grid units and pixel positions.
*/
/**
* Parameters needed for position calculations.
*/
interface PositionParams {
readonly margin: readonly [number, number];
readonly containerPadding: readonly [number, number];
readonly containerWidth: number;
readonly cols: number;
readonly rowHeight: number;
readonly maxRows: number;
}
/**
* Calculate the width of a single grid column in pixels.
*
* @param positionParams - Grid parameters
* @returns Column width in pixels
*/
declare function calcGridColWidth(positionParams: PositionParams): number;
/**
* Calculate the pixel size for a grid unit dimension (width or height).
*
* Can be called as:
* - calcGridItemWHPx(w, colWidth, margin[0]) for width
* - calcGridItemWHPx(h, rowHeight, margin[1]) for height
*
* @param gridUnits - Size in grid units
* @param colOrRowSize - Column width or row height in pixels
* @param marginPx - Margin between items in pixels
* @returns Size in pixels
*/
declare function calcGridItemWHPx(gridUnits: number, colOrRowSize: number, marginPx: number): number;
/**
* Calculate pixel position for a grid item.
*
* Returns left, top, width, height in pixels.
*
* @param positionParams - Grid parameters
* @param x - X coordinate in grid units
* @param y - Y coordinate in grid units
* @param w - Width in grid units
* @param h - Height in grid units
* @param dragPosition - If present, use exact left/top from drag callbacks
* @param resizePosition - If present, use exact dimensions from resize callbacks
* @returns Position in pixels
*/
declare function calcGridItemPosition(positionParams: PositionParams, x: number, y: number, w: number, h: number, dragPosition?: {
top: number;
left: number;
} | null, resizePosition?: {
top: number;
left: number;
height: number;
width: number;
} | null): Position;
/**
* Translate pixel coordinates to grid units.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @param w - Width in grid units (for clamping)
* @param h - Height in grid units (for clamping)
* @returns x and y in grid units
*/
declare function calcXY(positionParams: PositionParams, top: number, left: number, w: number, h: number): {
x: number;
y: number;
};
/**
* Translate pixel coordinates to grid units without clamping.
*
* Use this with the constraint system for custom boundary control.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @returns x and y in grid units (unclamped)
*/
declare function calcXYRaw(positionParams: PositionParams, top: number, left: number): {
x: number;
y: number;
};
/**
* Calculate grid units from pixel dimensions.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @param x - X coordinate in grid units (for clamping)
* @param y - Y coordinate in grid units (for clamping)
* @param handle - Resize handle being used
* @returns w, h in grid units
*/
declare function calcWH(positionParams: PositionParams, width: number, height: number, x: number, y: number, handle: ResizeHandleAxis): {
w: number;
h: number;
};
/**
* Calculate grid units from pixel dimensions without clamping.
*
* Use this with the constraint system for custom size control.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @returns w, h in grid units (unclamped, minimum 1)
*/
declare function calcWHRaw(positionParams: PositionParams, width: number, height: number): {
w: number;
h: number;
};
/**
* Clamp a number between bounds.
*
* @param num - Number to clamp
* @param lowerBound - Minimum value
* @param upperBound - Maximum value
* @returns Clamped value
*/
declare function clamp(num: number, lowerBound: number, upperBound: number): number;
/**
* Grid cell dimension information for rendering backgrounds or overlays.
*/
interface GridCellDimensions {
/** Width of a single cell in pixels */
readonly cellWidth: number;
/** Height of a single cell in pixels */
readonly cellHeight: number;
/** Horizontal offset from container edge to first cell */
readonly offsetX: number;
/** Vertical offset from container edge to first cell */
readonly offsetY: number;
/** Horizontal gap between cells */
readonly gapX: number;
/** Vertical gap between cells */
readonly gapY: number;
/** Number of columns */
readonly cols: number;
/** Total container width */
readonly containerWidth: number;
}
/**
* Configuration for grid cell dimension calculation.
*/
interface GridCellConfig {
/** Container width in pixels */
width: number;
/** Number of columns */
cols: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] */
margin?: readonly [number, number];
/** Container padding [x, y], defaults to margin if not specified */
containerPadding?: readonly [number, number] | null;
}
/**
* Calculate grid cell dimensions for rendering backgrounds or overlays.
*
* This function provides all the measurements needed to render a visual
* grid background that aligns with the actual grid cells.
*
* @param config - Grid configuration
* @returns Cell dimensions and offsets
*
* @example
* ```tsx
* import { calcGridCellDimensions } from 'react-grid-layout/core';
*
* const dims = calcGridCellDimensions({
* width: 1200,
* cols: 12,
* rowHeight: 30,
* margin: [10, 10],
* containerPadding: [10, 10]
* });
*
* // dims.cellWidth = 88.33...
* // dims.cellHeight = 30
* // dims.offsetX = 10 (containerPadding[0])
* // dims.offsetY = 10 (containerPadding[1])
* // dims.gapX = 10 (margin[0])
* // dims.gapY = 10 (margin[1])
* ```
*/
declare function calcGridCellDimensions(config: GridCellConfig): GridCellDimensions;
export { type GridCellDimensions as G, type PositionParams as P, calcXY as a, calcWH as b, calcGridItemPosition as c, type GridCellConfig as d, calcGridColWidth as e, calcGridItemWHPx as f, calcXYRaw as g, calcWHRaw as h, clamp as i, calcGridCellDimensions as j };
import { P as Position, d as ResizeHandleAxis } from './types-BiXsdXr7.mjs';
/**
* Grid calculation utilities.
*
* These functions convert between grid units and pixel positions.
*/
/**
* Parameters needed for position calculations.
*/
interface PositionParams {
readonly margin: readonly [number, number];
readonly containerPadding: readonly [number, number];
readonly containerWidth: number;
readonly cols: number;
readonly rowHeight: number;
readonly maxRows: number;
}
/**
* Calculate the width of a single grid column in pixels.
*
* @param positionParams - Grid parameters
* @returns Column width in pixels
*/
declare function calcGridColWidth(positionParams: PositionParams): number;
/**
* Calculate the pixel size for a grid unit dimension (width or height).
*
* Can be called as:
* - calcGridItemWHPx(w, colWidth, margin[0]) for width
* - calcGridItemWHPx(h, rowHeight, margin[1]) for height
*
* @param gridUnits - Size in grid units
* @param colOrRowSize - Column width or row height in pixels
* @param marginPx - Margin between items in pixels
* @returns Size in pixels
*/
declare function calcGridItemWHPx(gridUnits: number, colOrRowSize: number, marginPx: number): number;
/**
* Calculate pixel position for a grid item.
*
* Returns left, top, width, height in pixels.
*
* @param positionParams - Grid parameters
* @param x - X coordinate in grid units
* @param y - Y coordinate in grid units
* @param w - Width in grid units
* @param h - Height in grid units
* @param dragPosition - If present, use exact left/top from drag callbacks
* @param resizePosition - If present, use exact dimensions from resize callbacks
* @returns Position in pixels
*/
declare function calcGridItemPosition(positionParams: PositionParams, x: number, y: number, w: number, h: number, dragPosition?: {
top: number;
left: number;
} | null, resizePosition?: {
top: number;
left: number;
height: number;
width: number;
} | null): Position;
/**
* Translate pixel coordinates to grid units.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @param w - Width in grid units (for clamping)
* @param h - Height in grid units (for clamping)
* @returns x and y in grid units
*/
declare function calcXY(positionParams: PositionParams, top: number, left: number, w: number, h: number): {
x: number;
y: number;
};
/**
* Translate pixel coordinates to grid units without clamping.
*
* Use this with the constraint system for custom boundary control.
*
* @param positionParams - Grid parameters
* @param top - Top position in pixels (relative to parent)
* @param left - Left position in pixels (relative to parent)
* @returns x and y in grid units (unclamped)
*/
declare function calcXYRaw(positionParams: PositionParams, top: number, left: number): {
x: number;
y: number;
};
/**
* Calculate grid units from pixel dimensions.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @param x - X coordinate in grid units (for clamping)
* @param y - Y coordinate in grid units (for clamping)
* @param handle - Resize handle being used
* @returns w, h in grid units
*/
declare function calcWH(positionParams: PositionParams, width: number, height: number, x: number, y: number, handle: ResizeHandleAxis): {
w: number;
h: number;
};
/**
* Calculate grid units from pixel dimensions without clamping.
*
* Use this with the constraint system for custom size control.
*
* @param positionParams - Grid parameters
* @param width - Width in pixels
* @param height - Height in pixels
* @returns w, h in grid units (unclamped, minimum 1)
*/
declare function calcWHRaw(positionParams: PositionParams, width: number, height: number): {
w: number;
h: number;
};
/**
* Clamp a number between bounds.
*
* @param num - Number to clamp
* @param lowerBound - Minimum value
* @param upperBound - Maximum value
* @returns Clamped value
*/
declare function clamp(num: number, lowerBound: number, upperBound: number): number;
/**
* Grid cell dimension information for rendering backgrounds or overlays.
*/
interface GridCellDimensions {
/** Width of a single cell in pixels */
readonly cellWidth: number;
/** Height of a single cell in pixels */
readonly cellHeight: number;
/** Horizontal offset from container edge to first cell */
readonly offsetX: number;
/** Vertical offset from container edge to first cell */
readonly offsetY: number;
/** Horizontal gap between cells */
readonly gapX: number;
/** Vertical gap between cells */
readonly gapY: number;
/** Number of columns */
readonly cols: number;
/** Total container width */
readonly containerWidth: number;
}
/**
* Configuration for grid cell dimension calculation.
*/
interface GridCellConfig {
/** Container width in pixels */
width: number;
/** Number of columns */
cols: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] */
margin?: readonly [number, number];
/** Container padding [x, y], defaults to margin if not specified */
containerPadding?: readonly [number, number] | null;
}
/**
* Calculate grid cell dimensions for rendering backgrounds or overlays.
*
* This function provides all the measurements needed to render a visual
* grid background that aligns with the actual grid cells.
*
* @param config - Grid configuration
* @returns Cell dimensions and offsets
*
* @example
* ```tsx
* import { calcGridCellDimensions } from 'react-grid-layout/core';
*
* const dims = calcGridCellDimensions({
* width: 1200,
* cols: 12,
* rowHeight: 30,
* margin: [10, 10],
* containerPadding: [10, 10]
* });
*
* // dims.cellWidth = 88.33...
* // dims.cellHeight = 30
* // dims.offsetX = 10 (containerPadding[0])
* // dims.offsetY = 10 (containerPadding[1])
* // dims.gapX = 10 (margin[0])
* // dims.gapY = 10 (margin[1])
* ```
*/
declare function calcGridCellDimensions(config: GridCellConfig): GridCellDimensions;
export { type GridCellDimensions as G, type PositionParams as P, calcXY as a, calcWH as b, calcGridItemPosition as c, type GridCellConfig as d, calcGridColWidth as e, calcGridItemWHPx as f, calcXYRaw as g, calcWHRaw as h, clamp as i, calcGridCellDimensions as j };
'use strict';
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
// src/core/constraints.ts
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
var gridBounds = {
name: "gridBounds",
constrainPosition(item, x, y, { cols, maxRows }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
},
constrainSize(item, w, h, handle, { cols, maxRows }) {
const maxW = handle === "w" || handle === "nw" || handle === "sw" ? item.x + item.w : cols - item.x;
const maxH = handle === "n" || handle === "nw" || handle === "ne" ? item.y + item.h : maxRows - item.y;
return {
w: clamp(w, 1, Math.max(1, maxW)),
h: clamp(h, 1, Math.max(1, maxH))
};
}
};
var minMaxSize = {
name: "minMaxSize",
constrainSize(item, w, h) {
return {
w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),
h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)
};
}
};
var containerBounds = {
name: "containerBounds",
constrainPosition(item, x, y, { cols, maxRows, containerHeight, rowHeight, margin }) {
const visibleRows = containerHeight > 0 ? Math.floor((containerHeight + margin[1]) / (rowHeight + margin[1])) : maxRows;
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, visibleRows - item.h))
};
}
};
var boundedX = {
name: "boundedX",
constrainPosition(item, x, y, { cols }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y
};
}
};
var boundedY = {
name: "boundedY",
constrainPosition(item, x, y, { maxRows }) {
return {
x,
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
}
};
function aspectRatio(ratio) {
return {
name: `aspectRatio(${ratio})`,
constrainSize(_item, w, _h, _handle, context) {
const { cols, containerWidth, rowHeight, margin } = context;
const colWidth = (containerWidth - margin[0] * (cols - 1)) / cols;
const pixelWidth = colWidth * w + margin[0] * Math.max(0, w - 1);
const pixelHeight = pixelWidth / ratio;
const h = Math.max(
1,
Math.round((pixelHeight + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
};
}
function snapToGrid(stepX, stepY = stepX) {
if (stepX <= 0 || stepY <= 0) {
throw new Error(
`snapToGrid: step values must be positive (got stepX=${stepX}, stepY=${stepY})`
);
}
return {
name: `snapToGrid(${stepX}, ${stepY})`,
constrainPosition(_item, x, y) {
return {
x: Math.round(x / stepX) * stepX,
y: Math.round(y / stepY) * stepY
};
}
};
}
function minSize(minW, minH) {
return {
name: `minSize(${minW}, ${minH})`,
constrainSize(_item, w, h) {
return {
w: Math.max(minW, w),
h: Math.max(minH, h)
};
}
};
}
function maxSize(maxW, maxH) {
return {
name: `maxSize(${maxW}, ${maxH})`,
constrainSize(_item, w, h) {
return {
w: Math.min(maxW, w),
h: Math.min(maxH, h)
};
}
};
}
var defaultConstraints = [gridBounds, minMaxSize];
function applyPositionConstraints(constraints, item, x, y, context) {
let result = { x, y };
for (const constraint of constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(item, result.x, result.y, context);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(
item,
result.x,
result.y,
context
);
}
}
}
return result;
}
function applySizeConstraints(constraints, item, w, h, handle, context) {
let result = { w, h };
for (const constraint of constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
}
return result;
}
// src/core/position.ts
function setTransform({
top,
left,
width,
height
}) {
const translate = `translate(${left}px,${top}px)`;
return {
transform: translate,
WebkitTransform: translate,
MozTransform: translate,
msTransform: translate,
OTransform: translate,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function setTopLeft({
top,
left,
width,
height
}) {
return {
top: `${top}px`,
left: `${left}px`,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function perc(num) {
return num * 100 + "%";
}
function constrainWidth(left, currentWidth, newWidth, containerWidth) {
return left + newWidth > containerWidth ? currentWidth : newWidth;
}
function constrainHeight(top, currentHeight, newHeight) {
return top < 0 ? currentHeight : newHeight;
}
function constrainLeft(left) {
return Math.max(0, left);
}
function constrainTop(top) {
return Math.max(0, top);
}
var resizeNorth = (currentSize, newSize, _containerWidth) => {
const { left, height, width } = newSize;
const top = currentSize.top - (height - currentSize.height);
return {
left,
width,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeEast = (currentSize, newSize, containerWidth) => {
const { top, left, height, width } = newSize;
return {
top,
height,
width: constrainWidth(
currentSize.left,
currentSize.width,
width,
containerWidth
),
left: constrainLeft(left)
};
};
var resizeWest = (currentSize, newSize, _containerWidth) => {
const { top, height, width } = newSize;
const left = currentSize.left + currentSize.width - width;
if (left < 0) {
return {
height,
width: currentSize.left + currentSize.width,
top: constrainTop(top),
left: 0
};
}
return {
height,
width,
top: constrainTop(top),
left
};
};
var resizeSouth = (currentSize, newSize, _containerWidth) => {
const { top, left, height, width } = newSize;
return {
width,
left,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeNorthEast = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeNorthWest = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeWest(currentSize, newSize));
var resizeSouthEast = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeSouthWest = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeWest(currentSize, newSize));
var resizeHandlerMap = {
n: resizeNorth,
ne: resizeNorthEast,
e: resizeEast,
se: resizeSouthEast,
s: resizeSouth,
sw: resizeSouthWest,
w: resizeWest,
nw: resizeNorthWest
};
function resizeItemInDirection(direction, currentSize, newSize, containerWidth) {
const handler = resizeHandlerMap[direction];
if (!handler) {
return newSize;
}
return handler(currentSize, { ...currentSize, ...newSize }, containerWidth);
}
var transformStrategy = {
type: "transform",
scale: 1,
calcStyle(pos) {
return setTransform(pos);
}
};
var absoluteStrategy = {
type: "absolute",
scale: 1,
calcStyle(pos) {
return setTopLeft(pos);
}
};
function createScaledStrategy(scale) {
return {
type: "transform",
scale,
calcStyle(pos) {
return setTransform(pos);
},
calcDragPosition(clientX, clientY, offsetX, offsetY) {
return {
left: (clientX - offsetX) / scale,
top: (clientY - offsetY) / scale
};
}
};
}
var defaultPositionStrategy = transformStrategy;
// src/core/types.ts
var defaultGridConfig = {
cols: 12,
rowHeight: 150,
margin: [10, 10],
containerPadding: null,
maxRows: Infinity
};
var defaultDragConfig = {
enabled: true,
bounded: false,
threshold: 3
};
var defaultResizeConfig = {
enabled: true,
handles: ["se"]
};
var defaultDropConfig = {
enabled: false,
defaultItem: { w: 1, h: 1 }
};
// src/core/compactors.ts
function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
const sizeProp = axis === "x" ? "w" : "h";
item[axis] += 1;
const itemIndex = layout.findIndex((l) => l.i === item.i);
const layoutHasStatics = hasStatics ?? chunkBJFPTW5Q_js.getStatics(layout).length > 0;
for (let i = itemIndex + 1; i < layout.length; i++) {
const otherItem = layout[i];
if (otherItem === void 0) continue;
if (otherItem.static) continue;
if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
if (chunkBJFPTW5Q_js.collides(item, otherItem)) {
resolveCompactionCollision(
layout,
otherItem,
moveToCoord + item[sizeProp],
axis,
layoutHasStatics
);
}
}
item[axis] = moveToCoord;
}
function compactItemVertical(compareWith, l, fullLayout, maxY) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
l.y = Math.min(maxY, l.y);
while (l.y > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
l.y--;
}
let collision;
while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y");
}
l.y = Math.max(l.y, 0);
return l;
}
function compactItemHorizontal(compareWith, l, cols, fullLayout) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
l.x--;
}
let collision;
while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
if (l.x + l.w > cols) {
l.x = cols - l.w;
l.y++;
while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
l.x--;
}
}
}
l.x = Math.max(l.x, 0);
return l;
}
var verticalCompactor = {
type: "vertical",
allowOverlap: false,
compact(layout, _cols) {
const compareWith = chunkBJFPTW5Q_js.getStatics(layout);
let maxY = chunkBJFPTW5Q_js.bottom(compareWith);
const sorted = chunkBJFPTW5Q_js.sortLayoutItemsByRowCol(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemVertical(compareWith, l, sorted, maxY);
maxY = Math.max(maxY, l.y + l.h);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var horizontalCompactor = {
type: "horizontal",
allowOverlap: false,
compact(layout, cols) {
const compareWith = chunkBJFPTW5Q_js.getStatics(layout);
const sorted = chunkBJFPTW5Q_js.sortLayoutItemsByColRow(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemHorizontal(compareWith, l, cols, sorted);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var noCompactor = {
type: null,
allowOverlap: false,
compact(layout, _cols) {
return chunkBJFPTW5Q_js.cloneLayout(layout);
}
};
var verticalOverlapCompactor = {
...verticalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return chunkBJFPTW5Q_js.cloneLayout(layout);
}
};
var horizontalOverlapCompactor = {
...horizontalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return chunkBJFPTW5Q_js.cloneLayout(layout);
}
};
var noOverlapCompactor = {
...noCompactor,
allowOverlap: true
};
function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
let baseCompactor;
if (allowOverlap) {
if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
else if (compactType === "horizontal")
baseCompactor = horizontalOverlapCompactor;
else baseCompactor = noOverlapCompactor;
} else {
if (compactType === "vertical") baseCompactor = verticalCompactor;
else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
else baseCompactor = noCompactor;
}
if (preventCollision) {
return { ...baseCompactor, preventCollision };
}
return baseCompactor;
}
// src/core/responsive.ts
function sortBreakpoints(breakpoints) {
const keys = Object.keys(breakpoints);
return keys.sort((a, b) => breakpoints[a] - breakpoints[b]);
}
function getBreakpointFromWidth(breakpoints, width) {
const sorted = sortBreakpoints(breakpoints);
let matching = sorted[0];
if (matching === void 0) {
throw new Error("No breakpoints defined");
}
for (let i = 1; i < sorted.length; i++) {
const breakpointName = sorted[i];
if (breakpointName === void 0) continue;
const breakpointWidth = breakpoints[breakpointName];
if (width > breakpointWidth) {
matching = breakpointName;
}
}
return matching;
}
function getColsFromBreakpoint(breakpoint, cols) {
const colCount = cols[breakpoint];
if (colCount === void 0) {
throw new Error(
`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(breakpoint)} is missing!`
);
}
return colCount;
}
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactTypeOrCompactor) {
const existingLayout = layouts[breakpoint];
if (existingLayout) {
return chunkBJFPTW5Q_js.cloneLayout(existingLayout);
}
let layout = layouts[lastBreakpoint];
const breakpointsSorted = sortBreakpoints(breakpoints);
const breakpointsAbove = breakpointsSorted.slice(
breakpointsSorted.indexOf(breakpoint)
);
for (let i = 0; i < breakpointsAbove.length; i++) {
const b = breakpointsAbove[i];
if (b === void 0) continue;
const layoutForBreakpoint = layouts[b];
if (layoutForBreakpoint) {
layout = layoutForBreakpoint;
break;
}
}
const clonedLayout = chunkBJFPTW5Q_js.cloneLayout(layout || []);
const corrected = chunkBJFPTW5Q_js.correctBounds(clonedLayout, { cols });
const compactor = typeof compactTypeOrCompactor === "object" && compactTypeOrCompactor !== null ? compactTypeOrCompactor : getCompactor(compactTypeOrCompactor);
return compactor.compact(corrected, cols);
}
function getIndentationValue(value, breakpoint) {
if (Array.isArray(value)) {
return value;
}
const breakpointMap = value;
const breakpointValue = breakpointMap[breakpoint];
if (breakpointValue !== void 0) {
return breakpointValue;
}
const keys = Object.keys(breakpointMap);
for (const key of keys) {
const v = breakpointMap[key];
if (v !== void 0) {
return v;
}
}
return [10, 10];
}
exports.absoluteStrategy = absoluteStrategy;
exports.applyPositionConstraints = applyPositionConstraints;
exports.applySizeConstraints = applySizeConstraints;
exports.aspectRatio = aspectRatio;
exports.boundedX = boundedX;
exports.boundedY = boundedY;
exports.compactItemHorizontal = compactItemHorizontal;
exports.compactItemVertical = compactItemVertical;
exports.containerBounds = containerBounds;
exports.createScaledStrategy = createScaledStrategy;
exports.defaultConstraints = defaultConstraints;
exports.defaultDragConfig = defaultDragConfig;
exports.defaultDropConfig = defaultDropConfig;
exports.defaultGridConfig = defaultGridConfig;
exports.defaultPositionStrategy = defaultPositionStrategy;
exports.defaultResizeConfig = defaultResizeConfig;
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
exports.getBreakpointFromWidth = getBreakpointFromWidth;
exports.getColsFromBreakpoint = getColsFromBreakpoint;
exports.getCompactor = getCompactor;
exports.getIndentationValue = getIndentationValue;
exports.gridBounds = gridBounds;
exports.horizontalCompactor = horizontalCompactor;
exports.horizontalOverlapCompactor = horizontalOverlapCompactor;
exports.maxSize = maxSize;
exports.minMaxSize = minMaxSize;
exports.minSize = minSize;
exports.noCompactor = noCompactor;
exports.noOverlapCompactor = noOverlapCompactor;
exports.perc = perc;
exports.resizeItemInDirection = resizeItemInDirection;
exports.resolveCompactionCollision = resolveCompactionCollision;
exports.setTopLeft = setTopLeft;
exports.setTransform = setTransform;
exports.snapToGrid = snapToGrid;
exports.sortBreakpoints = sortBreakpoints;
exports.transformStrategy = transformStrategy;
exports.verticalCompactor = verticalCompactor;
exports.verticalOverlapCompactor = verticalOverlapCompactor;
//# sourceMappingURL=chunk-2DDROKB2.js.map
//# sourceMappingURL=chunk-2DDROKB2.js.map

Sorry, the diff of this file is too big to display

// src/core/calculate.ts
function calcGridColWidth(positionParams) {
const { margin, containerPadding, containerWidth, cols } = positionParams;
return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
}
function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
if (!Number.isFinite(gridUnits)) return gridUnits;
return Math.round(
colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx
);
}
function calcGridItemPosition(positionParams, x, y, w, h, dragPosition, resizePosition) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let width;
let height;
let top;
let left;
if (resizePosition) {
width = Math.round(resizePosition.width);
height = Math.round(resizePosition.height);
} else {
width = calcGridItemWHPx(w, colWidth, margin[0]);
height = calcGridItemWHPx(h, rowHeight, margin[1]);
}
if (dragPosition) {
top = Math.round(dragPosition.top);
left = Math.round(dragPosition.left);
} else if (resizePosition) {
top = Math.round(resizePosition.top);
left = Math.round(resizePosition.left);
} else {
top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
}
if (!dragPosition && !resizePosition) {
if (Number.isFinite(w)) {
const siblingLeft = Math.round(
(colWidth + margin[0]) * (x + w) + containerPadding[0]
);
const actualMarginRight = siblingLeft - left - width;
if (actualMarginRight !== margin[0]) {
width += actualMarginRight - margin[0];
}
}
if (Number.isFinite(h)) {
const siblingTop = Math.round(
(rowHeight + margin[1]) * (y + h) + containerPadding[1]
);
const actualMarginBottom = siblingTop - top - height;
if (actualMarginBottom !== margin[1]) {
height += actualMarginBottom - margin[1];
}
}
}
return { top, left, width, height };
}
function calcXY(positionParams, top, left, w, h) {
const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
x = clamp(x, 0, cols - w);
y = clamp(y, 0, maxRows - h);
return { x, y };
}
function calcXYRaw(positionParams, top, left) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
return { x, y };
}
function calcWH(positionParams, width, height, x, y, handle) {
const { margin, maxRows, cols, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.round((width + margin[0]) / (colWidth + margin[0]));
const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));
let _w = clamp(w, 0, cols - x);
let _h = clamp(h, 0, maxRows - y);
if (handle === "sw" || handle === "w" || handle === "nw") {
_w = clamp(w, 0, cols);
}
if (handle === "nw" || handle === "n" || handle === "ne") {
_h = clamp(h, 0, maxRows);
}
return { w: _w, h: _h };
}
function calcWHRaw(positionParams, width, height) {
const { margin, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.max(
1,
Math.round((width + margin[0]) / (colWidth + margin[0]))
);
const h = Math.max(
1,
Math.round((height + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
function clamp(num, lowerBound, upperBound) {
return Math.max(Math.min(num, upperBound), lowerBound);
}
function calcGridCellDimensions(config) {
const {
width,
cols,
rowHeight,
margin = [10, 10],
containerPadding
} = config;
const padding = containerPadding ?? margin;
const cellWidth = (width - padding[0] * 2 - margin[0] * (cols - 1)) / cols;
const cellHeight = rowHeight;
return {
cellWidth,
cellHeight,
offsetX: padding[0],
offsetY: padding[1],
gapX: margin[0],
gapY: margin[1],
cols,
containerWidth: width
};
}
// src/core/collision.ts
function collides(l1, l2) {
if (l1.i === l2.i) return false;
if (l1.x + l1.w <= l2.x) return false;
if (l1.x >= l2.x + l2.w) return false;
if (l1.y + l1.h <= l2.y) return false;
if (l1.y >= l2.y + l2.h) return false;
return true;
}
function getFirstCollision(layout, layoutItem) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && collides(item, layoutItem)) {
return item;
}
}
return void 0;
}
function getAllCollisions(layout, layoutItem) {
return layout.filter((l) => collides(l, layoutItem));
}
// src/core/sort.ts
function sortLayoutItems(layout, compactType) {
if (compactType === "horizontal") {
return sortLayoutItemsByColRow(layout);
}
if (compactType === "vertical") {
return sortLayoutItemsByRowCol(layout);
}
if (compactType === "wrap") {
return sortLayoutItemsByRowCol(layout);
}
return [...layout];
}
function sortLayoutItemsByRowCol(layout) {
return [...layout].sort((a, b) => {
if (a.y !== b.y) {
return a.y - b.y;
}
return a.x - b.x;
});
}
function sortLayoutItemsByColRow(layout) {
return [...layout].sort((a, b) => {
if (a.x !== b.x) {
return a.x - b.x;
}
return a.y - b.y;
});
}
// src/core/layout.ts
function bottom(layout) {
let max = 0;
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
const bottomY = item.y + item.h;
if (bottomY > max) max = bottomY;
}
}
return max;
}
function getLayoutItem(layout, id) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && item.i === id) {
return item;
}
}
return void 0;
}
function getStatics(layout) {
return layout.filter((l) => l.static === true);
}
function cloneLayoutItem(layoutItem) {
return {
i: layoutItem.i,
x: layoutItem.x,
y: layoutItem.y,
w: layoutItem.w,
h: layoutItem.h,
minW: layoutItem.minW,
maxW: layoutItem.maxW,
minH: layoutItem.minH,
maxH: layoutItem.maxH,
moved: Boolean(layoutItem.moved),
static: Boolean(layoutItem.static),
isDraggable: layoutItem.isDraggable,
isResizable: layoutItem.isResizable,
resizeHandles: layoutItem.resizeHandles,
constraints: layoutItem.constraints,
isBounded: layoutItem.isBounded
};
}
function cloneLayout(layout) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
newLayout[i] = cloneLayoutItem(item);
}
}
return newLayout;
}
function modifyLayout(layout, layoutItem) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
if (layoutItem.i === item.i) {
newLayout[i] = layoutItem;
} else {
newLayout[i] = item;
}
}
}
return newLayout;
}
function withLayoutItem(layout, itemKey, cb) {
let item = getLayoutItem(layout, itemKey);
if (!item) {
return [[...layout], null];
}
item = cb(cloneLayoutItem(item));
const newLayout = modifyLayout(layout, item);
return [newLayout, item];
}
function correctBounds(layout, bounds) {
const collidesWith = getStatics(layout);
for (let i = 0; i < layout.length; i++) {
const l = layout[i];
if (l === void 0) continue;
if (l.x + l.w > bounds.cols) {
l.x = bounds.cols - l.w;
}
if (l.x < 0) {
l.x = 0;
l.w = bounds.cols;
}
if (!l.static) {
collidesWith.push(l);
} else {
while (getFirstCollision(collidesWith, l)) {
l.y++;
}
}
}
return layout;
}
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, allowOverlap) {
if (l.static && l.isDraggable !== true) {
return [...layout];
}
if (l.y === y && l.x === x) {
return [...layout];
}
const oldX = l.x;
const oldY = l.y;
if (typeof x === "number") l.x = x;
if (typeof y === "number") l.y = y;
l.moved = true;
let sorted = sortLayoutItems(layout, compactType);
const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
if (movingUp) {
sorted = sorted.reverse();
}
const collisions = getAllCollisions(sorted, l);
const hasCollisions = collisions.length > 0;
if (hasCollisions && allowOverlap) {
return cloneLayout(layout);
}
if (hasCollisions && preventCollision) {
l.x = oldX;
l.y = oldY;
l.moved = false;
return layout;
}
let resultLayout = [...layout];
for (let i = 0; i < collisions.length; i++) {
const collision = collisions[i];
if (collision === void 0) continue;
if (collision.moved) continue;
if (collision.static) {
resultLayout = moveElementAwayFromCollision(
resultLayout,
collision,
l,
isUserAction,
compactType);
} else {
resultLayout = moveElementAwayFromCollision(
resultLayout,
l,
collision,
isUserAction,
compactType);
}
}
return resultLayout;
}
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols) {
const compactH = compactType === "horizontal";
const compactV = compactType === "vertical";
const preventCollision = collidesWith.static;
if (isUserAction) {
isUserAction = false;
const fakeItem = {
x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
w: itemToMove.w,
h: itemToMove.h,
i: "-1"
};
const firstCollision = getFirstCollision(layout, fakeItem);
const collisionNorth = firstCollision !== void 0 && firstCollision.y + firstCollision.h > collidesWith.y;
const collisionWest = firstCollision !== void 0 && collidesWith.x + collidesWith.w > firstCollision.x;
if (!firstCollision) {
return moveElement(
layout,
itemToMove,
compactH ? fakeItem.x : void 0,
compactV ? fakeItem.y : void 0,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactV) {
return moveElement(
layout,
itemToMove,
void 0,
itemToMove.y + 1,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactType === null) {
collidesWith.y = itemToMove.y;
itemToMove.y = itemToMove.y + itemToMove.h;
return [...layout];
}
if (collisionWest && compactH) {
return moveElement(
layout,
collidesWith,
itemToMove.x,
void 0,
isUserAction,
preventCollision,
compactType);
}
}
const newX = compactH ? itemToMove.x + 1 : void 0;
const newY = compactV ? itemToMove.y + 1 : void 0;
if (newX === void 0 && newY === void 0) {
return [...layout];
}
return moveElement(
layout,
itemToMove,
newX,
newY,
isUserAction,
preventCollision,
compactType);
}
function validateLayout(layout, contextName = "Layout") {
const requiredProps = ["x", "y", "w", "h"];
if (!Array.isArray(layout)) {
throw new Error(`${contextName} must be an array!`);
}
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item === void 0) continue;
for (const key of requiredProps) {
const value = item[key];
if (typeof value !== "number" || Number.isNaN(value)) {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${String(value)} (${typeof value})`
);
}
}
if (item.i !== void 0 && typeof item.i !== "string") {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${String(item.i)} (${typeof item.i})`
);
}
}
}
export { bottom, calcGridCellDimensions, calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcWHRaw, calcXY, calcXYRaw, clamp, cloneLayout, cloneLayoutItem, collides, correctBounds, getAllCollisions, getFirstCollision, getLayoutItem, getStatics, modifyLayout, moveElement, moveElementAwayFromCollision, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout, withLayoutItem };
//# sourceMappingURL=chunk-AWM66AWF.mjs.map
//# sourceMappingURL=chunk-AWM66AWF.mjs.map
{"version":3,"sources":["../src/core/calculate.ts","../src/core/collision.ts","../src/core/sort.ts","../src/core/layout.ts"],"names":[],"mappings":";AAkCO,SAAS,iBAAiB,cAAA,EAAwC;AACvE,EAAA,MAAM,EAAE,MAAA,EAAQ,gBAAA,EAAkB,cAAA,EAAgB,MAAK,GAAI,cAAA;AAC3D,EAAA,OAAA,CACG,cAAA,GAAiB,OAAO,CAAC,CAAA,IAAK,OAAO,CAAA,CAAA,GAAK,gBAAA,CAAiB,CAAC,CAAA,GAAI,CAAA,IAAK,IAAA;AAE1E;AAcO,SAAS,gBAAA,CACd,SAAA,EACA,YAAA,EACA,QAAA,EACQ;AAER,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,SAAS,GAAG,OAAO,SAAA;AACxC,EAAA,OAAO,IAAA,CAAK,KAAA;AAAA,IACV,eAAe,SAAA,GAAY,IAAA,CAAK,IAAI,CAAA,EAAG,SAAA,GAAY,CAAC,CAAA,GAAI;AAAA,GA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AAAA,IACF;AAEA,IAAA,IAAI,KAAK,CAAA,KAAM,MAAA,IAAa,OAAO,IAAA,CAAK,MAAM,QAAA,EAAU;AACtD,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,iBAAA,EAAoB,WAAW,CAAA,CAAA,EAAI,CAAC,CAAA,gCAAA,EACrB,MAAA,CAAO,IAAA,CAAK,CAAC,CAAC,CAAA,EAAA,EAAK,OAAO,IAAA,CAAK,CAAC,CAAA,CAAA;AAAA,OACjD;AAAA,IACF;AAAA,EACF;AACF","file":"chunk-AWM66AWF.mjs","sourcesContent":["/**\n * Grid calculation utilities.\n *\n * These functions convert between grid units and pixel positions.\n */\n\nimport type { Position, ResizeHandleAxis } from \"./types.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parameters needed for position calculations.\n */\nexport interface PositionParams {\n readonly margin: readonly [number, number];\n readonly containerPadding: readonly [number, number];\n readonly containerWidth: number;\n readonly cols: number;\n readonly rowHeight: number;\n readonly maxRows: number;\n}\n\n// ============================================================================\n// Grid Column/Row Calculations\n// ============================================================================\n\n/**\n * Calculate the width of a single grid column in pixels.\n *\n * @param positionParams - Grid parameters\n * @returns Column width in pixels\n */\nexport function calcGridColWidth(positionParams: PositionParams): number {\n const { margin, containerPadding, containerWidth, cols } = positionParams;\n return (\n (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols\n );\n}\n\n/**\n * Calculate the pixel size for a grid unit dimension (width or height).\n *\n * Can be called as:\n * - calcGridItemWHPx(w, colWidth, margin[0]) for width\n * - calcGridItemWHPx(h, rowHeight, margin[1]) for height\n *\n * @param gridUnits - Size in grid units\n * @param colOrRowSize - Column width or row height in pixels\n * @param marginPx - Margin between items in pixels\n * @returns Size in pixels\n */\nexport function calcGridItemWHPx(\n gridUnits: number,\n colOrRowSize: number,\n marginPx: number\n): number {\n // 0 * Infinity === NaN, which causes problems with resize constraints\n if (!Number.isFinite(gridUnits)) return gridUnits;\n return Math.round(\n colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx\n );\n}\n\n// ============================================================================\n// Position Calculations\n// ============================================================================\n\n/**\n * Calculate pixel position for a grid item.\n *\n * Returns left, top, width, height in pixels.\n *\n * @param positionParams - Grid parameters\n * @param x - X coordinate in grid units\n * @param y - Y coordinate in grid units\n * @param w - Width in grid units\n * @param h - Height in grid units\n * @param dragPosition - If present, use exact left/top from drag callbacks\n * @param resizePosition - If present, use exact dimensions from resize callbacks\n * @returns Position in pixels\n */\nexport function calcGridItemPosition(\n positionParams: PositionParams,\n x: number,\n y: number,\n w: number,\n h: number,\n dragPosition?: { top: number; left: number } | null,\n resizePosition?: {\n top: number;\n left: number;\n height: number;\n width: number;\n } | null\n): Position {\n const { margin, containerPadding, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n let width: number;\n let height: number;\n let top: number;\n let left: number;\n\n // If resizing, use the exact width and height from resize callbacks\n if (resizePosition) {\n width = Math.round(resizePosition.width);\n height = Math.round(resizePosition.height);\n } else {\n // Calculate from grid units\n width = calcGridItemWHPx(w, colWidth, margin[0]);\n height = calcGridItemWHPx(h, rowHeight, margin[1]);\n }\n\n // If dragging, use the exact left/top from drag callbacks\n if (dragPosition) {\n top = Math.round(dragPosition.top);\n left = Math.round(dragPosition.left);\n } else if (resizePosition) {\n // If resizing, use the exact left/top from resize position\n top = Math.round(resizePosition.top);\n left = Math.round(resizePosition.left);\n } else {\n // Calculate from grid units\n top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);\n left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);\n }\n\n // When not dragging or resizing, fix margin inconsistencies caused by rounding.\n // Due to Math.round(), the gap between adjacent items can differ from the\n // expected margin (e.g., 0px or 2px instead of 1px). We fix this by comparing\n // where the next sibling would start vs where this item ends, and adjusting\n // the width/height to maintain consistent margins.\n if (!dragPosition && !resizePosition) {\n if (Number.isFinite(w)) {\n // Calculate where the next column's item would start\n const siblingLeft = Math.round(\n (colWidth + margin[0]) * (x + w) + containerPadding[0]\n );\n // Calculate actual margin: sibling start - (our left + our width)\n const actualMarginRight = siblingLeft - left - width;\n // Adjust width if margin doesn't match\n if (actualMarginRight !== margin[0]) {\n width += actualMarginRight - margin[0];\n }\n }\n\n if (Number.isFinite(h)) {\n // Calculate where the next row's item would start\n const siblingTop = Math.round(\n (rowHeight + margin[1]) * (y + h) + containerPadding[1]\n );\n // Calculate actual margin: sibling start - (our top + our height)\n const actualMarginBottom = siblingTop - top - height;\n // Adjust height if margin doesn't match\n if (actualMarginBottom !== margin[1]) {\n height += actualMarginBottom - margin[1];\n }\n }\n }\n\n return { top, left, width, height };\n}\n\n/**\n * Translate pixel coordinates to grid units.\n *\n * @param positionParams - Grid parameters\n * @param top - Top position in pixels (relative to parent)\n * @param left - Left position in pixels (relative to parent)\n * @param w - Width in grid units (for clamping)\n * @param h - Height in grid units (for clamping)\n * @returns x and y in grid units\n */\nexport function calcXY(\n positionParams: PositionParams,\n top: number,\n left: number,\n w: number,\n h: number\n): { x: number; y: number } {\n const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n // left = containerPaddingX + x * (colWidth + marginX)\n // x = (left - containerPaddingX) / (colWidth + marginX)\n let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));\n let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));\n\n // Clamp to grid bounds\n x = clamp(x, 0, cols - w);\n y = clamp(y, 0, maxRows - h);\n\n return { x, y };\n}\n\n/**\n * Translate pixel coordinates to grid units without clamping.\n *\n * Use this with the constraint system for custom boundary control.\n *\n * @param positionParams - Grid parameters\n * @param top - Top position in pixels (relative to parent)\n * @param left - Left position in pixels (relative to parent)\n * @returns x and y in grid units (unclamped)\n */\nexport function calcXYRaw(\n positionParams: PositionParams,\n top: number,\n left: number\n): { x: number; y: number } {\n const { margin, containerPadding, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));\n const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));\n\n return { x, y };\n}\n\n/**\n * Calculate grid units from pixel dimensions.\n *\n * @param positionParams - Grid parameters\n * @param width - Width in pixels\n * @param height - Height in pixels\n * @param x - X coordinate in grid units (for clamping)\n * @param y - Y coordinate in grid units (for clamping)\n * @param handle - Resize handle being used\n * @returns w, h in grid units\n */\nexport function calcWH(\n positionParams: PositionParams,\n width: number,\n height: number,\n x: number,\n y: number,\n handle: ResizeHandleAxis\n): { w: number; h: number } {\n const { margin, maxRows, cols, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n // width = colWidth * w - (margin * (w - 1))\n // w = (width + margin) / (colWidth + margin)\n const w = Math.round((width + margin[0]) / (colWidth + margin[0]));\n const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));\n\n // Clamp based on resize handle direction\n let _w = clamp(w, 0, cols - x);\n let _h = clamp(h, 0, maxRows - y);\n\n // West handles can resize to full width\n if (handle === \"sw\" || handle === \"w\" || handle === \"nw\") {\n _w = clamp(w, 0, cols);\n }\n\n // North handles can resize to full height\n if (handle === \"nw\" || handle === \"n\" || handle === \"ne\") {\n _h = clamp(h, 0, maxRows);\n }\n\n return { w: _w, h: _h };\n}\n\n/**\n * Calculate grid units from pixel dimensions without clamping.\n *\n * Use this with the constraint system for custom size control.\n *\n * @param positionParams - Grid parameters\n * @param width - Width in pixels\n * @param height - Height in pixels\n * @returns w, h in grid units (unclamped, minimum 1)\n */\nexport function calcWHRaw(\n positionParams: PositionParams,\n width: number,\n height: number\n): { w: number; h: number } {\n const { margin, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n // width = colWidth * w - (margin * (w - 1))\n // w = (width + margin) / (colWidth + margin)\n const w = Math.max(\n 1,\n Math.round((width + margin[0]) / (colWidth + margin[0]))\n );\n const h = Math.max(\n 1,\n Math.round((height + margin[1]) / (rowHeight + margin[1]))\n );\n\n return { w, h };\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Clamp a number between bounds.\n *\n * @param num - Number to clamp\n * @param lowerBound - Minimum value\n * @param upperBound - Maximum value\n * @returns Clamped value\n */\nexport function clamp(\n num: number,\n lowerBound: number,\n upperBound: number\n): number {\n return Math.max(Math.min(num, upperBound), lowerBound);\n}\n\n// ============================================================================\n// Grid Background Calculations\n// ============================================================================\n\n/**\n * Grid cell dimension information for rendering backgrounds or overlays.\n */\nexport interface GridCellDimensions {\n /** Width of a single cell in pixels */\n readonly cellWidth: number;\n /** Height of a single cell in pixels */\n readonly cellHeight: number;\n /** Horizontal offset from container edge to first cell */\n readonly offsetX: number;\n /** Vertical offset from container edge to first cell */\n readonly offsetY: number;\n /** Horizontal gap between cells */\n readonly gapX: number;\n /** Vertical gap between cells */\n readonly gapY: number;\n /** Number of columns */\n readonly cols: number;\n /** Total container width */\n readonly containerWidth: number;\n}\n\n/**\n * Configuration for grid cell dimension calculation.\n */\nexport interface GridCellConfig {\n /** Container width in pixels */\n width: number;\n /** Number of columns */\n cols: number;\n /** Row height in pixels */\n rowHeight: number;\n /** Margin between items [x, y] */\n margin?: readonly [number, number];\n /** Container padding [x, y], defaults to margin if not specified */\n containerPadding?: readonly [number, number] | null;\n}\n\n/**\n * Calculate grid cell dimensions for rendering backgrounds or overlays.\n *\n * This function provides all the measurements needed to render a visual\n * grid background that aligns with the actual grid cells.\n *\n * @param config - Grid configuration\n * @returns Cell dimensions and offsets\n *\n * @example\n * ```tsx\n * import { calcGridCellDimensions } from 'react-grid-layout/core';\n *\n * const dims = calcGridCellDimensions({\n * width: 1200,\n * cols: 12,\n * rowHeight: 30,\n * margin: [10, 10],\n * containerPadding: [10, 10]\n * });\n *\n * // dims.cellWidth = 88.33...\n * // dims.cellHeight = 30\n * // dims.offsetX = 10 (containerPadding[0])\n * // dims.offsetY = 10 (containerPadding[1])\n * // dims.gapX = 10 (margin[0])\n * // dims.gapY = 10 (margin[1])\n * ```\n */\nexport function calcGridCellDimensions(\n config: GridCellConfig\n): GridCellDimensions {\n const {\n width,\n cols,\n rowHeight,\n margin = [10, 10],\n containerPadding\n } = config;\n\n // Container padding defaults to margin if not specified\n const padding = containerPadding ?? margin;\n\n // Calculate cell width: total width minus padding and gaps, divided by columns\n // Formula: width = 2*padding + cols*cellWidth + (cols-1)*gap\n // Solving for cellWidth: cellWidth = (width - 2*padding - (cols-1)*gap) / cols\n const cellWidth = (width - padding[0] * 2 - margin[0] * (cols - 1)) / cols;\n const cellHeight = rowHeight;\n\n return {\n cellWidth,\n cellHeight,\n offsetX: padding[0],\n offsetY: padding[1],\n gapX: margin[0],\n gapY: margin[1],\n cols,\n containerWidth: width\n };\n}\n","/**\n * Collision detection utilities for grid layouts.\n *\n * These functions determine if and where layout items overlap.\n */\n\nimport type { Layout, LayoutItem } from \"./types.js\";\n\n/**\n * Check if two layout items collide (overlap).\n *\n * Two items collide if their bounding boxes overlap and they are\n * not the same item.\n *\n * @param l1 - First layout item\n * @param l2 - Second layout item\n * @returns true if the items collide\n */\nexport function collides(l1: LayoutItem, l2: LayoutItem): boolean {\n // Same element - can't collide with itself\n if (l1.i === l2.i) return false;\n\n // Check if bounding boxes don't overlap (any gap means no collision)\n if (l1.x + l1.w <= l2.x) return false; // l1 is completely left of l2\n if (l1.x >= l2.x + l2.w) return false; // l1 is completely right of l2\n if (l1.y + l1.h <= l2.y) return false; // l1 is completely above l2\n if (l1.y >= l2.y + l2.h) return false; // l1 is completely below l2\n\n // Bounding boxes overlap\n return true;\n}\n\n/**\n * Find the first item in the layout that collides with the given item.\n *\n * @param layout - Layout to search\n * @param layoutItem - Item to check for collisions\n * @returns The first colliding item, or undefined if none\n */\nexport function getFirstCollision(\n layout: Layout,\n layoutItem: LayoutItem\n): LayoutItem | undefined {\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined && collides(item, layoutItem)) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * Find all items in the layout that collide with the given item.\n *\n * @param layout - Layout to search\n * @param layoutItem - Item to check for collisions\n * @returns Array of all colliding items (may be empty)\n */\nexport function getAllCollisions(\n layout: Layout,\n layoutItem: LayoutItem\n): LayoutItem[] {\n return layout.filter((l): l is LayoutItem => collides(l, layoutItem));\n}\n","/**\n * Sorting utilities for grid layouts.\n *\n * These functions sort layout items for compaction and iteration.\n */\n\nimport type { CompactType, Layout, LayoutItem } from \"./types.js\";\n\n/**\n * Sort layout items based on the compaction type.\n *\n * - Vertical compaction: sort by row (y) then column (x)\n * - Horizontal compaction: sort by column (x) then row (y)\n * - No compaction (null): return original order\n *\n * Does not modify the original layout.\n *\n * @param layout - Layout to sort\n * @param compactType - Type of compaction\n * @returns Sorted layout\n */\nexport function sortLayoutItems(\n layout: Layout,\n compactType: CompactType\n): LayoutItem[] {\n if (compactType === \"horizontal\") {\n return sortLayoutItemsByColRow(layout);\n }\n if (compactType === \"vertical\") {\n return sortLayoutItemsByRowCol(layout);\n }\n if (compactType === \"wrap\") {\n // Wrap mode uses row-col order (reading order: left-to-right, top-to-bottom)\n return sortLayoutItemsByRowCol(layout);\n }\n // No compaction - return a copy to maintain immutability\n return [...layout];\n}\n\n/**\n * Sort layout items by row ascending, then column ascending.\n *\n * Items are ordered from top-left to bottom-right, row by row.\n * This is the natural reading order for vertical compaction.\n *\n * Does not modify the original layout.\n *\n * @param layout - Layout to sort\n * @returns Sorted array of layout items\n */\nexport function sortLayoutItemsByRowCol(layout: Layout): LayoutItem[] {\n return [...layout].sort((a, b) => {\n // Primary sort by row (y)\n if (a.y !== b.y) {\n return a.y - b.y;\n }\n // Secondary sort by column (x)\n return a.x - b.x;\n });\n}\n\n/**\n * Sort layout items by column ascending, then row ascending.\n *\n * Items are ordered from top-left to bottom-right, column by column.\n * This is the natural order for horizontal compaction.\n *\n * Does not modify the original layout.\n *\n * @param layout - Layout to sort\n * @returns Sorted array of layout items\n */\nexport function sortLayoutItemsByColRow(layout: Layout): LayoutItem[] {\n return [...layout].sort((a, b) => {\n // Primary sort by column (x)\n if (a.x !== b.x) {\n return a.x - b.x;\n }\n // Secondary sort by row (y)\n return a.y - b.y;\n });\n}\n","/**\n * Core layout manipulation utilities.\n *\n * These functions create, modify, and query grid layouts.\n * All functions treat layouts as immutable - they return new arrays/objects.\n */\n\nimport type { CompactType, Layout, LayoutItem, Mutable } from \"./types.js\";\nimport { getAllCollisions, getFirstCollision } from \"./collision.js\";\nimport { sortLayoutItems } from \"./sort.js\";\n\n// ============================================================================\n// Layout Queries\n// ============================================================================\n\n/**\n * Get the bottom-most Y coordinate of the layout.\n *\n * This is the Y position plus height of the lowest item.\n *\n * @param layout - Layout to measure\n * @returns The bottom Y coordinate (0 if layout is empty)\n */\nexport function bottom(layout: Layout): number {\n let max = 0;\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined) {\n const bottomY = item.y + item.h;\n if (bottomY > max) max = bottomY;\n }\n }\n return max;\n}\n\n/**\n * Get a layout item by its ID.\n *\n * @param layout - Layout to search\n * @param id - Item ID to find\n * @returns The layout item, or undefined if not found\n */\nexport function getLayoutItem(\n layout: Layout,\n id: string\n): LayoutItem | undefined {\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined && item.i === id) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * Get all static items from the layout.\n *\n * Static items cannot be moved or resized by the user.\n *\n * @param layout - Layout to filter\n * @returns Array of static layout items\n */\nexport function getStatics(layout: Layout): LayoutItem[] {\n return layout.filter((l): l is LayoutItem => l.static === true);\n}\n\n// ============================================================================\n// Layout Cloning\n// ============================================================================\n\n/**\n * Clone a layout item.\n *\n * Creates a shallow copy with all properties preserved.\n * Boolean properties are normalized (undefined becomes false).\n *\n * @param layoutItem - Item to clone\n * @returns A new layout item with the same properties\n */\nexport function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem {\n return {\n i: layoutItem.i,\n x: layoutItem.x,\n y: layoutItem.y,\n w: layoutItem.w,\n h: layoutItem.h,\n minW: layoutItem.minW,\n maxW: layoutItem.maxW,\n minH: layoutItem.minH,\n maxH: layoutItem.maxH,\n moved: Boolean(layoutItem.moved),\n static: Boolean(layoutItem.static),\n isDraggable: layoutItem.isDraggable,\n isResizable: layoutItem.isResizable,\n resizeHandles: layoutItem.resizeHandles,\n constraints: layoutItem.constraints,\n isBounded: layoutItem.isBounded\n };\n}\n\n/**\n * Clone an entire layout.\n *\n * Creates a new array with cloned items.\n *\n * @param layout - Layout to clone\n * @returns A new layout with cloned items\n */\nexport function cloneLayout(layout: Layout): LayoutItem[] {\n const newLayout: LayoutItem[] = new Array(layout.length);\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined) {\n newLayout[i] = cloneLayoutItem(item);\n }\n }\n return newLayout;\n}\n\n// ============================================================================\n// Layout Modification\n// ============================================================================\n\n/**\n * Replace a layout item in a layout.\n *\n * Returns a new layout with the item replaced. Other items are not cloned.\n *\n * @param layout - Layout to modify\n * @param layoutItem - New item (matched by `i` property)\n * @returns New layout with the item replaced\n */\nexport function modifyLayout(\n layout: Layout,\n layoutItem: LayoutItem\n): LayoutItem[] {\n const newLayout: LayoutItem[] = new Array(layout.length);\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined) {\n if (layoutItem.i === item.i) {\n newLayout[i] = layoutItem;\n } else {\n newLayout[i] = item;\n }\n }\n }\n return newLayout;\n}\n\n/**\n * Apply a transformation to a layout item.\n *\n * Finds the item by key, clones it, applies the callback, and returns\n * a new layout with the modified item.\n *\n * @param layout - Layout to modify\n * @param itemKey - Key of the item to modify\n * @param cb - Callback that receives the cloned item and returns the modified item\n * @returns Tuple of [new layout, modified item or null if not found]\n */\nexport function withLayoutItem(\n layout: Layout,\n itemKey: string,\n cb: (item: LayoutItem) => LayoutItem\n): [LayoutItem[], LayoutItem | null] {\n let item = getLayoutItem(layout, itemKey);\n if (!item) {\n return [[...layout], null];\n }\n\n // Clone, then modify via callback\n item = cb(cloneLayoutItem(item));\n const newLayout = modifyLayout(layout, item);\n\n return [newLayout, item];\n}\n\n// ============================================================================\n// Bounds Correction\n// ============================================================================\n\n/**\n * Ensure all layout items fit within the grid bounds.\n *\n * - Items overflowing right are moved left\n * - Items overflowing left are moved to x=0 and clamped to grid width\n * - Static items that collide with other statics are moved down\n *\n * **IMPORTANT**: This function mutates the layout items in place for performance.\n * The type signature uses `Mutable<LayoutItem>[]` to make this explicit.\n * Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.\n *\n * @param layout - Layout to correct (items WILL be mutated)\n * @param bounds - Grid bounds\n * @returns The same layout array (for chaining)\n */\nexport function correctBounds(\n layout: Mutable<LayoutItem>[],\n bounds: { cols: number }\n): LayoutItem[] {\n const collidesWith = getStatics(layout);\n\n for (let i = 0; i < layout.length; i++) {\n const l = layout[i];\n if (l === undefined) continue;\n\n // Overflows right\n if (l.x + l.w > bounds.cols) {\n l.x = bounds.cols - l.w;\n }\n\n // Overflows left\n if (l.x < 0) {\n l.x = 0;\n l.w = bounds.cols;\n }\n\n if (!l.static) {\n collidesWith.push(l);\n } else {\n // Static items that collide with other statics must be moved down\n while (getFirstCollision(collidesWith, l)) {\n l.y++;\n }\n }\n }\n\n return layout;\n}\n\n// ============================================================================\n// Move Operations\n// ============================================================================\n\n/**\n * Move a layout element to a new position.\n *\n * Handles collision detection and cascading movements.\n * Does not compact the layout - call `compact()` separately.\n *\n * **Note**: This function mutates the `l` parameter directly for performance.\n * The item's x, y, and moved properties will be modified. Callers should\n * ideally pass a cloned item if they need to preserve the original.\n *\n * @param layout - Full layout\n * @param l - Item to move (will be mutated)\n * @param x - New X position (or undefined to keep current)\n * @param y - New Y position (or undefined to keep current)\n * @param isUserAction - True if this is a direct user action (affects collision resolution)\n * @param preventCollision - True to block movement into occupied space (item snaps back). No effect if allowOverlap is true.\n * @param compactType - Compaction type for collision resolution\n * @param cols - Number of columns in the grid\n * @param allowOverlap - True to allow items to stack on top of each other\n * @returns The updated layout\n */\nexport function moveElement(\n layout: Layout,\n l: LayoutItem,\n x: number | undefined,\n y: number | undefined,\n isUserAction: boolean | undefined,\n preventCollision: boolean | undefined,\n compactType: CompactType,\n cols: number,\n allowOverlap?: boolean\n): LayoutItem[] {\n // Static items can't be moved unless explicitly draggable\n if (l.static && l.isDraggable !== true) {\n return [...layout];\n }\n\n // Short-circuit if position unchanged\n if (l.y === y && l.x === x) {\n return [...layout];\n }\n\n const oldX = l.x;\n const oldY = l.y;\n\n // Update position (mutates l directly - see JSDoc note)\n if (typeof x === \"number\") (l as Mutable<LayoutItem>).x = x;\n if (typeof y === \"number\") (l as Mutable<LayoutItem>).y = y;\n (l as Mutable<LayoutItem>).moved = true;\n\n // Sort for proper collision detection order\n let sorted = sortLayoutItems(layout, compactType);\n const movingUp =\n compactType === \"vertical\" && typeof y === \"number\"\n ? oldY >= y\n : compactType === \"horizontal\" && typeof x === \"number\"\n ? oldX >= x\n : false;\n\n if (movingUp) {\n sorted = sorted.reverse();\n }\n\n const collisions = getAllCollisions(sorted, l);\n const hasCollisions = collisions.length > 0;\n\n // Handle overlap mode - just clone and return\n if (hasCollisions && allowOverlap) {\n return cloneLayout(layout);\n }\n\n // Handle prevent collision mode - revert position\n // Return same reference to signal no change occurred\n if (hasCollisions && preventCollision) {\n (l as Mutable<LayoutItem>).x = oldX;\n (l as Mutable<LayoutItem>).y = oldY;\n (l as Mutable<LayoutItem>).moved = false;\n return layout as LayoutItem[];\n }\n\n // Resolve collisions by moving other items\n let resultLayout: LayoutItem[] = [...layout];\n for (let i = 0; i < collisions.length; i++) {\n const collision = collisions[i];\n if (collision === undefined) continue;\n\n // Skip already-moved items to prevent infinite loops\n if (collision.moved) continue;\n\n // Static items can't be moved - move the dragged item instead\n if (collision.static) {\n resultLayout = moveElementAwayFromCollision(\n resultLayout,\n collision,\n l,\n isUserAction,\n compactType,\n cols\n );\n } else {\n resultLayout = moveElementAwayFromCollision(\n resultLayout,\n l,\n collision,\n isUserAction,\n compactType,\n cols\n );\n }\n }\n\n return resultLayout;\n}\n\n/**\n * Move an item away from a collision.\n *\n * Attempts to move the item up/left first if there's room,\n * otherwise moves it down/right.\n *\n * @param layout - Full layout\n * @param collidesWith - The item being collided with\n * @param itemToMove - The item to move away\n * @param isUserAction - True if this is a direct user action\n * @param compactType - Compaction type\n * @param cols - Number of columns\n * @returns Updated layout\n */\nexport function moveElementAwayFromCollision(\n layout: Layout,\n collidesWith: LayoutItem,\n itemToMove: LayoutItem,\n isUserAction: boolean | undefined,\n compactType: CompactType,\n cols: number\n): LayoutItem[] {\n const compactH = compactType === \"horizontal\";\n const compactV = compactType === \"vertical\";\n const preventCollision = collidesWith.static;\n\n // Try to move up/left first (only on primary collision from user action)\n if (isUserAction) {\n isUserAction = false; // Only try this once\n\n // Create a fake item to test if there's room above/left\n const fakeItem: LayoutItem = {\n x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,\n y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,\n w: itemToMove.w,\n h: itemToMove.h,\n i: \"-1\"\n };\n\n const firstCollision = getFirstCollision(layout, fakeItem);\n const collisionNorth =\n firstCollision !== undefined &&\n firstCollision.y + firstCollision.h > collidesWith.y;\n const collisionWest =\n firstCollision !== undefined &&\n collidesWith.x + collidesWith.w > firstCollision.x;\n\n // No collision above/left - we can move there\n if (!firstCollision) {\n return moveElement(\n layout,\n itemToMove,\n compactH ? fakeItem.x : undefined,\n compactV ? fakeItem.y : undefined,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n }\n\n // Handle specific collision cases\n if (collisionNorth && compactV) {\n return moveElement(\n layout,\n itemToMove,\n undefined,\n itemToMove.y + 1,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n }\n\n if (collisionNorth && compactType === null) {\n // Swap positions in free-form mode\n (collidesWith as Mutable<LayoutItem>).y = itemToMove.y;\n (itemToMove as Mutable<LayoutItem>).y = itemToMove.y + itemToMove.h;\n return [...layout];\n }\n\n if (collisionWest && compactH) {\n return moveElement(\n layout,\n collidesWith,\n itemToMove.x,\n undefined,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n }\n }\n\n // Default: move down/right by 1\n const newX = compactH ? itemToMove.x + 1 : undefined;\n const newY = compactV ? itemToMove.y + 1 : undefined;\n\n if (newX === undefined && newY === undefined) {\n return [...layout];\n }\n\n return moveElement(\n layout,\n itemToMove,\n newX,\n newY,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n}\n\n// ============================================================================\n// Validation\n// ============================================================================\n\n/**\n * Validate that a layout has the required properties.\n *\n * @param layout - Layout to validate\n * @param contextName - Name for error messages\n * @throws Error if layout is invalid\n */\nexport function validateLayout(\n layout: Layout,\n contextName: string = \"Layout\"\n): void {\n const requiredProps = [\"x\", \"y\", \"w\", \"h\"] as const;\n\n if (!Array.isArray(layout)) {\n throw new Error(`${contextName} must be an array!`);\n }\n\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item === undefined) continue;\n\n for (const key of requiredProps) {\n const value = item[key];\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new Error(\n `ReactGridLayout: ${contextName}[${i}].${key} must be a number! ` +\n `Received: ${String(value)} (${typeof value})`\n );\n }\n }\n\n if (item.i !== undefined && typeof item.i !== \"string\") {\n throw new Error(\n `ReactGridLayout: ${contextName}[${i}].i must be a string! ` +\n `Received: ${String(item.i)} (${typeof item.i})`\n );\n }\n }\n}\n"]}
'use strict';
// src/core/calculate.ts
function calcGridColWidth(positionParams) {
const { margin, containerPadding, containerWidth, cols } = positionParams;
return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
}
function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
if (!Number.isFinite(gridUnits)) return gridUnits;
return Math.round(
colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx
);
}
function calcGridItemPosition(positionParams, x, y, w, h, dragPosition, resizePosition) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let width;
let height;
let top;
let left;
if (resizePosition) {
width = Math.round(resizePosition.width);
height = Math.round(resizePosition.height);
} else {
width = calcGridItemWHPx(w, colWidth, margin[0]);
height = calcGridItemWHPx(h, rowHeight, margin[1]);
}
if (dragPosition) {
top = Math.round(dragPosition.top);
left = Math.round(dragPosition.left);
} else if (resizePosition) {
top = Math.round(resizePosition.top);
left = Math.round(resizePosition.left);
} else {
top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
}
if (!dragPosition && !resizePosition) {
if (Number.isFinite(w)) {
const siblingLeft = Math.round(
(colWidth + margin[0]) * (x + w) + containerPadding[0]
);
const actualMarginRight = siblingLeft - left - width;
if (actualMarginRight !== margin[0]) {
width += actualMarginRight - margin[0];
}
}
if (Number.isFinite(h)) {
const siblingTop = Math.round(
(rowHeight + margin[1]) * (y + h) + containerPadding[1]
);
const actualMarginBottom = siblingTop - top - height;
if (actualMarginBottom !== margin[1]) {
height += actualMarginBottom - margin[1];
}
}
}
return { top, left, width, height };
}
function calcXY(positionParams, top, left, w, h) {
const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;
const colWidth = calcGridColWidth(positionParams);
let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
x = clamp(x, 0, cols - w);
y = clamp(y, 0, maxRows - h);
return { x, y };
}
function calcXYRaw(positionParams, top, left) {
const { margin, containerPadding, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
return { x, y };
}
function calcWH(positionParams, width, height, x, y, handle) {
const { margin, maxRows, cols, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.round((width + margin[0]) / (colWidth + margin[0]));
const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));
let _w = clamp(w, 0, cols - x);
let _h = clamp(h, 0, maxRows - y);
if (handle === "sw" || handle === "w" || handle === "nw") {
_w = clamp(w, 0, cols);
}
if (handle === "nw" || handle === "n" || handle === "ne") {
_h = clamp(h, 0, maxRows);
}
return { w: _w, h: _h };
}
function calcWHRaw(positionParams, width, height) {
const { margin, rowHeight } = positionParams;
const colWidth = calcGridColWidth(positionParams);
const w = Math.max(
1,
Math.round((width + margin[0]) / (colWidth + margin[0]))
);
const h = Math.max(
1,
Math.round((height + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
function clamp(num, lowerBound, upperBound) {
return Math.max(Math.min(num, upperBound), lowerBound);
}
function calcGridCellDimensions(config) {
const {
width,
cols,
rowHeight,
margin = [10, 10],
containerPadding
} = config;
const padding = containerPadding ?? margin;
const cellWidth = (width - padding[0] * 2 - margin[0] * (cols - 1)) / cols;
const cellHeight = rowHeight;
return {
cellWidth,
cellHeight,
offsetX: padding[0],
offsetY: padding[1],
gapX: margin[0],
gapY: margin[1],
cols,
containerWidth: width
};
}
// src/core/collision.ts
function collides(l1, l2) {
if (l1.i === l2.i) return false;
if (l1.x + l1.w <= l2.x) return false;
if (l1.x >= l2.x + l2.w) return false;
if (l1.y + l1.h <= l2.y) return false;
if (l1.y >= l2.y + l2.h) return false;
return true;
}
function getFirstCollision(layout, layoutItem) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && collides(item, layoutItem)) {
return item;
}
}
return void 0;
}
function getAllCollisions(layout, layoutItem) {
return layout.filter((l) => collides(l, layoutItem));
}
// src/core/sort.ts
function sortLayoutItems(layout, compactType) {
if (compactType === "horizontal") {
return sortLayoutItemsByColRow(layout);
}
if (compactType === "vertical") {
return sortLayoutItemsByRowCol(layout);
}
if (compactType === "wrap") {
return sortLayoutItemsByRowCol(layout);
}
return [...layout];
}
function sortLayoutItemsByRowCol(layout) {
return [...layout].sort((a, b) => {
if (a.y !== b.y) {
return a.y - b.y;
}
return a.x - b.x;
});
}
function sortLayoutItemsByColRow(layout) {
return [...layout].sort((a, b) => {
if (a.x !== b.x) {
return a.x - b.x;
}
return a.y - b.y;
});
}
// src/core/layout.ts
function bottom(layout) {
let max = 0;
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
const bottomY = item.y + item.h;
if (bottomY > max) max = bottomY;
}
}
return max;
}
function getLayoutItem(layout, id) {
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0 && item.i === id) {
return item;
}
}
return void 0;
}
function getStatics(layout) {
return layout.filter((l) => l.static === true);
}
function cloneLayoutItem(layoutItem) {
return {
i: layoutItem.i,
x: layoutItem.x,
y: layoutItem.y,
w: layoutItem.w,
h: layoutItem.h,
minW: layoutItem.minW,
maxW: layoutItem.maxW,
minH: layoutItem.minH,
maxH: layoutItem.maxH,
moved: Boolean(layoutItem.moved),
static: Boolean(layoutItem.static),
isDraggable: layoutItem.isDraggable,
isResizable: layoutItem.isResizable,
resizeHandles: layoutItem.resizeHandles,
constraints: layoutItem.constraints,
isBounded: layoutItem.isBounded
};
}
function cloneLayout(layout) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
newLayout[i] = cloneLayoutItem(item);
}
}
return newLayout;
}
function modifyLayout(layout, layoutItem) {
const newLayout = new Array(layout.length);
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item !== void 0) {
if (layoutItem.i === item.i) {
newLayout[i] = layoutItem;
} else {
newLayout[i] = item;
}
}
}
return newLayout;
}
function withLayoutItem(layout, itemKey, cb) {
let item = getLayoutItem(layout, itemKey);
if (!item) {
return [[...layout], null];
}
item = cb(cloneLayoutItem(item));
const newLayout = modifyLayout(layout, item);
return [newLayout, item];
}
function correctBounds(layout, bounds) {
const collidesWith = getStatics(layout);
for (let i = 0; i < layout.length; i++) {
const l = layout[i];
if (l === void 0) continue;
if (l.x + l.w > bounds.cols) {
l.x = bounds.cols - l.w;
}
if (l.x < 0) {
l.x = 0;
l.w = bounds.cols;
}
if (!l.static) {
collidesWith.push(l);
} else {
while (getFirstCollision(collidesWith, l)) {
l.y++;
}
}
}
return layout;
}
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, allowOverlap) {
if (l.static && l.isDraggable !== true) {
return [...layout];
}
if (l.y === y && l.x === x) {
return [...layout];
}
const oldX = l.x;
const oldY = l.y;
if (typeof x === "number") l.x = x;
if (typeof y === "number") l.y = y;
l.moved = true;
let sorted = sortLayoutItems(layout, compactType);
const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
if (movingUp) {
sorted = sorted.reverse();
}
const collisions = getAllCollisions(sorted, l);
const hasCollisions = collisions.length > 0;
if (hasCollisions && allowOverlap) {
return cloneLayout(layout);
}
if (hasCollisions && preventCollision) {
l.x = oldX;
l.y = oldY;
l.moved = false;
return layout;
}
let resultLayout = [...layout];
for (let i = 0; i < collisions.length; i++) {
const collision = collisions[i];
if (collision === void 0) continue;
if (collision.moved) continue;
if (collision.static) {
resultLayout = moveElementAwayFromCollision(
resultLayout,
collision,
l,
isUserAction,
compactType);
} else {
resultLayout = moveElementAwayFromCollision(
resultLayout,
l,
collision,
isUserAction,
compactType);
}
}
return resultLayout;
}
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols) {
const compactH = compactType === "horizontal";
const compactV = compactType === "vertical";
const preventCollision = collidesWith.static;
if (isUserAction) {
isUserAction = false;
const fakeItem = {
x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
w: itemToMove.w,
h: itemToMove.h,
i: "-1"
};
const firstCollision = getFirstCollision(layout, fakeItem);
const collisionNorth = firstCollision !== void 0 && firstCollision.y + firstCollision.h > collidesWith.y;
const collisionWest = firstCollision !== void 0 && collidesWith.x + collidesWith.w > firstCollision.x;
if (!firstCollision) {
return moveElement(
layout,
itemToMove,
compactH ? fakeItem.x : void 0,
compactV ? fakeItem.y : void 0,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactV) {
return moveElement(
layout,
itemToMove,
void 0,
itemToMove.y + 1,
isUserAction,
preventCollision,
compactType);
}
if (collisionNorth && compactType === null) {
collidesWith.y = itemToMove.y;
itemToMove.y = itemToMove.y + itemToMove.h;
return [...layout];
}
if (collisionWest && compactH) {
return moveElement(
layout,
collidesWith,
itemToMove.x,
void 0,
isUserAction,
preventCollision,
compactType);
}
}
const newX = compactH ? itemToMove.x + 1 : void 0;
const newY = compactV ? itemToMove.y + 1 : void 0;
if (newX === void 0 && newY === void 0) {
return [...layout];
}
return moveElement(
layout,
itemToMove,
newX,
newY,
isUserAction,
preventCollision,
compactType);
}
function validateLayout(layout, contextName = "Layout") {
const requiredProps = ["x", "y", "w", "h"];
if (!Array.isArray(layout)) {
throw new Error(`${contextName} must be an array!`);
}
for (let i = 0; i < layout.length; i++) {
const item = layout[i];
if (item === void 0) continue;
for (const key of requiredProps) {
const value = item[key];
if (typeof value !== "number" || Number.isNaN(value)) {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${String(value)} (${typeof value})`
);
}
}
if (item.i !== void 0 && typeof item.i !== "string") {
throw new Error(
`ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${String(item.i)} (${typeof item.i})`
);
}
}
}
exports.bottom = bottom;
exports.calcGridCellDimensions = calcGridCellDimensions;
exports.calcGridColWidth = calcGridColWidth;
exports.calcGridItemPosition = calcGridItemPosition;
exports.calcGridItemWHPx = calcGridItemWHPx;
exports.calcWH = calcWH;
exports.calcWHRaw = calcWHRaw;
exports.calcXY = calcXY;
exports.calcXYRaw = calcXYRaw;
exports.clamp = clamp;
exports.cloneLayout = cloneLayout;
exports.cloneLayoutItem = cloneLayoutItem;
exports.collides = collides;
exports.correctBounds = correctBounds;
exports.getAllCollisions = getAllCollisions;
exports.getFirstCollision = getFirstCollision;
exports.getLayoutItem = getLayoutItem;
exports.getStatics = getStatics;
exports.modifyLayout = modifyLayout;
exports.moveElement = moveElement;
exports.moveElementAwayFromCollision = moveElementAwayFromCollision;
exports.sortLayoutItems = sortLayoutItems;
exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow;
exports.sortLayoutItemsByRowCol = sortLayoutItemsByRowCol;
exports.validateLayout = validateLayout;
exports.withLayoutItem = withLayoutItem;
//# sourceMappingURL=chunk-BJFPTW5Q.js.map
//# sourceMappingURL=chunk-BJFPTW5Q.js.map
{"version":3,"sources":["../src/core/calculate.ts","../src/core/collision.ts","../src/core/sort.ts","../src/core/layout.ts"],"names":[],"mappings":";;;AAkCO,SAAS,iBAAiB,cAAA,EAAwC;AACvE,EAAA,MAAM,EAAE,MAAA,EAAQ,gBAAA,EAAkB,cAAA,EAAgB,MAAK,GAAI,cAAA;AAC3D,EAAA,OAAA,CACG,cAAA,GAAiB,OAAO,CAAC,CAAA,IAAK,OAAO,CAAA,CAAA,GAAK,gBAAA,CAAiB,CAAC,CAAA,GAAI,CAAA,IAAK,IAAA;AAE1E;AAcO,SAAS,gBAAA,CACd,SAAA,EACA,YAAA,EACA,QAAA,EACQ;AAER,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,SAAS,GAAG,OAAO,SAAA;AACxC,EAAA,OAAO,IAAA,CAAK,KAAA;AAAA,IACV,eAAe,SAAA,GAAY,IAAA,CAAK,IAAI,CAAA,EAAG,SAAA,GAAY,CAAC,CAAA,GAAI;AAAA,GAC1D;AACF;AAoBO,SAAS,qBACd,cAAA,EACA,CAAA,EACA,GACA,CAAA,EACA,CAAA,EACA,cACA,cAAA,EAMU;AACV,EAAA,MAAM,EAAE,MAAA,EAAQ,gBAAA,EAAkB,SAAA,EAAU,GAAI,cAAA;AAChD,EAAA,MAAM,QAAA,GAAW,iBAAiB,cAAc,CAAA;AAEhD,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI,IAAA;AAG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AAA,EACF;AACF","file":"chunk-BJFPTW5Q.js","sourcesContent":["/**\n * Grid calculation utilities.\n *\n * These functions convert between grid units and pixel positions.\n */\n\nimport type { Position, ResizeHandleAxis } from \"./types.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parameters needed for position calculations.\n */\nexport interface PositionParams {\n readonly margin: readonly [number, number];\n readonly containerPadding: readonly [number, number];\n readonly containerWidth: number;\n readonly cols: number;\n readonly rowHeight: number;\n readonly maxRows: number;\n}\n\n// ============================================================================\n// Grid Column/Row Calculations\n// ============================================================================\n\n/**\n * Calculate the width of a single grid column in pixels.\n *\n * @param positionParams - Grid parameters\n * @returns Column width in pixels\n */\nexport function calcGridColWidth(positionParams: PositionParams): number {\n const { margin, containerPadding, containerWidth, cols } = positionParams;\n return (\n (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols\n );\n}\n\n/**\n * Calculate the pixel size for a grid unit dimension (width or height).\n *\n * Can be called as:\n * - calcGridItemWHPx(w, colWidth, margin[0]) for width\n * - calcGridItemWHPx(h, rowHeight, margin[1]) for height\n *\n * @param gridUnits - Size in grid units\n * @param colOrRowSize - Column width or row height in pixels\n * @param marginPx - Margin between items in pixels\n * @returns Size in pixels\n */\nexport function calcGridItemWHPx(\n gridUnits: number,\n colOrRowSize: number,\n marginPx: number\n): number {\n // 0 * Infinity === NaN, which causes problems with resize constraints\n if (!Number.isFinite(gridUnits)) return gridUnits;\n return Math.round(\n colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx\n );\n}\n\n// ============================================================================\n// Position Calculations\n// ============================================================================\n\n/**\n * Calculate pixel position for a grid item.\n *\n * Returns left, top, width, height in pixels.\n *\n * @param positionParams - Grid parameters\n * @param x - X coordinate in grid units\n * @param y - Y coordinate in grid units\n * @param w - Width in grid units\n * @param h - Height in grid units\n * @param dragPosition - If present, use exact left/top from drag callbacks\n * @param resizePosition - If present, use exact dimensions from resize callbacks\n * @returns Position in pixels\n */\nexport function calcGridItemPosition(\n positionParams: PositionParams,\n x: number,\n y: number,\n w: number,\n h: number,\n dragPosition?: { top: number; left: number } | null,\n resizePosition?: {\n top: number;\n left: number;\n height: number;\n width: number;\n } | null\n): Position {\n const { margin, containerPadding, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n let width: number;\n let height: number;\n let top: number;\n let left: number;\n\n // If resizing, use the exact width and height from resize callbacks\n if (resizePosition) {\n width = Math.round(resizePosition.width);\n height = Math.round(resizePosition.height);\n } else {\n // Calculate from grid units\n width = calcGridItemWHPx(w, colWidth, margin[0]);\n height = calcGridItemWHPx(h, rowHeight, margin[1]);\n }\n\n // If dragging, use the exact left/top from drag callbacks\n if (dragPosition) {\n top = Math.round(dragPosition.top);\n left = Math.round(dragPosition.left);\n } else if (resizePosition) {\n // If resizing, use the exact left/top from resize position\n top = Math.round(resizePosition.top);\n left = Math.round(resizePosition.left);\n } else {\n // Calculate from grid units\n top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);\n left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);\n }\n\n // When not dragging or resizing, fix margin inconsistencies caused by rounding.\n // Due to Math.round(), the gap between adjacent items can differ from the\n // expected margin (e.g., 0px or 2px instead of 1px). We fix this by comparing\n // where the next sibling would start vs where this item ends, and adjusting\n // the width/height to maintain consistent margins.\n if (!dragPosition && !resizePosition) {\n if (Number.isFinite(w)) {\n // Calculate where the next column's item would start\n const siblingLeft = Math.round(\n (colWidth + margin[0]) * (x + w) + containerPadding[0]\n );\n // Calculate actual margin: sibling start - (our left + our width)\n const actualMarginRight = siblingLeft - left - width;\n // Adjust width if margin doesn't match\n if (actualMarginRight !== margin[0]) {\n width += actualMarginRight - margin[0];\n }\n }\n\n if (Number.isFinite(h)) {\n // Calculate where the next row's item would start\n const siblingTop = Math.round(\n (rowHeight + margin[1]) * (y + h) + containerPadding[1]\n );\n // Calculate actual margin: sibling start - (our top + our height)\n const actualMarginBottom = siblingTop - top - height;\n // Adjust height if margin doesn't match\n if (actualMarginBottom !== margin[1]) {\n height += actualMarginBottom - margin[1];\n }\n }\n }\n\n return { top, left, width, height };\n}\n\n/**\n * Translate pixel coordinates to grid units.\n *\n * @param positionParams - Grid parameters\n * @param top - Top position in pixels (relative to parent)\n * @param left - Left position in pixels (relative to parent)\n * @param w - Width in grid units (for clamping)\n * @param h - Height in grid units (for clamping)\n * @returns x and y in grid units\n */\nexport function calcXY(\n positionParams: PositionParams,\n top: number,\n left: number,\n w: number,\n h: number\n): { x: number; y: number } {\n const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n // left = containerPaddingX + x * (colWidth + marginX)\n // x = (left - containerPaddingX) / (colWidth + marginX)\n let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));\n let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));\n\n // Clamp to grid bounds\n x = clamp(x, 0, cols - w);\n y = clamp(y, 0, maxRows - h);\n\n return { x, y };\n}\n\n/**\n * Translate pixel coordinates to grid units without clamping.\n *\n * Use this with the constraint system for custom boundary control.\n *\n * @param positionParams - Grid parameters\n * @param top - Top position in pixels (relative to parent)\n * @param left - Left position in pixels (relative to parent)\n * @returns x and y in grid units (unclamped)\n */\nexport function calcXYRaw(\n positionParams: PositionParams,\n top: number,\n left: number\n): { x: number; y: number } {\n const { margin, containerPadding, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));\n const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));\n\n return { x, y };\n}\n\n/**\n * Calculate grid units from pixel dimensions.\n *\n * @param positionParams - Grid parameters\n * @param width - Width in pixels\n * @param height - Height in pixels\n * @param x - X coordinate in grid units (for clamping)\n * @param y - Y coordinate in grid units (for clamping)\n * @param handle - Resize handle being used\n * @returns w, h in grid units\n */\nexport function calcWH(\n positionParams: PositionParams,\n width: number,\n height: number,\n x: number,\n y: number,\n handle: ResizeHandleAxis\n): { w: number; h: number } {\n const { margin, maxRows, cols, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n // width = colWidth * w - (margin * (w - 1))\n // w = (width + margin) / (colWidth + margin)\n const w = Math.round((width + margin[0]) / (colWidth + margin[0]));\n const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));\n\n // Clamp based on resize handle direction\n let _w = clamp(w, 0, cols - x);\n let _h = clamp(h, 0, maxRows - y);\n\n // West handles can resize to full width\n if (handle === \"sw\" || handle === \"w\" || handle === \"nw\") {\n _w = clamp(w, 0, cols);\n }\n\n // North handles can resize to full height\n if (handle === \"nw\" || handle === \"n\" || handle === \"ne\") {\n _h = clamp(h, 0, maxRows);\n }\n\n return { w: _w, h: _h };\n}\n\n/**\n * Calculate grid units from pixel dimensions without clamping.\n *\n * Use this with the constraint system for custom size control.\n *\n * @param positionParams - Grid parameters\n * @param width - Width in pixels\n * @param height - Height in pixels\n * @returns w, h in grid units (unclamped, minimum 1)\n */\nexport function calcWHRaw(\n positionParams: PositionParams,\n width: number,\n height: number\n): { w: number; h: number } {\n const { margin, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n // width = colWidth * w - (margin * (w - 1))\n // w = (width + margin) / (colWidth + margin)\n const w = Math.max(\n 1,\n Math.round((width + margin[0]) / (colWidth + margin[0]))\n );\n const h = Math.max(\n 1,\n Math.round((height + margin[1]) / (rowHeight + margin[1]))\n );\n\n return { w, h };\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Clamp a number between bounds.\n *\n * @param num - Number to clamp\n * @param lowerBound - Minimum value\n * @param upperBound - Maximum value\n * @returns Clamped value\n */\nexport function clamp(\n num: number,\n lowerBound: number,\n upperBound: number\n): number {\n return Math.max(Math.min(num, upperBound), lowerBound);\n}\n\n// ============================================================================\n// Grid Background Calculations\n// ============================================================================\n\n/**\n * Grid cell dimension information for rendering backgrounds or overlays.\n */\nexport interface GridCellDimensions {\n /** Width of a single cell in pixels */\n readonly cellWidth: number;\n /** Height of a single cell in pixels */\n readonly cellHeight: number;\n /** Horizontal offset from container edge to first cell */\n readonly offsetX: number;\n /** Vertical offset from container edge to first cell */\n readonly offsetY: number;\n /** Horizontal gap between cells */\n readonly gapX: number;\n /** Vertical gap between cells */\n readonly gapY: number;\n /** Number of columns */\n readonly cols: number;\n /** Total container width */\n readonly containerWidth: number;\n}\n\n/**\n * Configuration for grid cell dimension calculation.\n */\nexport interface GridCellConfig {\n /** Container width in pixels */\n width: number;\n /** Number of columns */\n cols: number;\n /** Row height in pixels */\n rowHeight: number;\n /** Margin between items [x, y] */\n margin?: readonly [number, number];\n /** Container padding [x, y], defaults to margin if not specified */\n containerPadding?: readonly [number, number] | null;\n}\n\n/**\n * Calculate grid cell dimensions for rendering backgrounds or overlays.\n *\n * This function provides all the measurements needed to render a visual\n * grid background that aligns with the actual grid cells.\n *\n * @param config - Grid configuration\n * @returns Cell dimensions and offsets\n *\n * @example\n * ```tsx\n * import { calcGridCellDimensions } from 'react-grid-layout/core';\n *\n * const dims = calcGridCellDimensions({\n * width: 1200,\n * cols: 12,\n * rowHeight: 30,\n * margin: [10, 10],\n * containerPadding: [10, 10]\n * });\n *\n * // dims.cellWidth = 88.33...\n * // dims.cellHeight = 30\n * // dims.offsetX = 10 (containerPadding[0])\n * // dims.offsetY = 10 (containerPadding[1])\n * // dims.gapX = 10 (margin[0])\n * // dims.gapY = 10 (margin[1])\n * ```\n */\nexport function calcGridCellDimensions(\n config: GridCellConfig\n): GridCellDimensions {\n const {\n width,\n cols,\n rowHeight,\n margin = [10, 10],\n containerPadding\n } = config;\n\n // Container padding defaults to margin if not specified\n const padding = containerPadding ?? margin;\n\n // Calculate cell width: total width minus padding and gaps, divided by columns\n // Formula: width = 2*padding + cols*cellWidth + (cols-1)*gap\n // Solving for cellWidth: cellWidth = (width - 2*padding - (cols-1)*gap) / cols\n const cellWidth = (width - padding[0] * 2 - margin[0] * (cols - 1)) / cols;\n const cellHeight = rowHeight;\n\n return {\n cellWidth,\n cellHeight,\n offsetX: padding[0],\n offsetY: padding[1],\n gapX: margin[0],\n gapY: margin[1],\n cols,\n containerWidth: width\n };\n}\n","/**\n * Collision detection utilities for grid layouts.\n *\n * These functions determine if and where layout items overlap.\n */\n\nimport type { Layout, LayoutItem } from \"./types.js\";\n\n/**\n * Check if two layout items collide (overlap).\n *\n * Two items collide if their bounding boxes overlap and they are\n * not the same item.\n *\n * @param l1 - First layout item\n * @param l2 - Second layout item\n * @returns true if the items collide\n */\nexport function collides(l1: LayoutItem, l2: LayoutItem): boolean {\n // Same element - can't collide with itself\n if (l1.i === l2.i) return false;\n\n // Check if bounding boxes don't overlap (any gap means no collision)\n if (l1.x + l1.w <= l2.x) return false; // l1 is completely left of l2\n if (l1.x >= l2.x + l2.w) return false; // l1 is completely right of l2\n if (l1.y + l1.h <= l2.y) return false; // l1 is completely above l2\n if (l1.y >= l2.y + l2.h) return false; // l1 is completely below l2\n\n // Bounding boxes overlap\n return true;\n}\n\n/**\n * Find the first item in the layout that collides with the given item.\n *\n * @param layout - Layout to search\n * @param layoutItem - Item to check for collisions\n * @returns The first colliding item, or undefined if none\n */\nexport function getFirstCollision(\n layout: Layout,\n layoutItem: LayoutItem\n): LayoutItem | undefined {\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined && collides(item, layoutItem)) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * Find all items in the layout that collide with the given item.\n *\n * @param layout - Layout to search\n * @param layoutItem - Item to check for collisions\n * @returns Array of all colliding items (may be empty)\n */\nexport function getAllCollisions(\n layout: Layout,\n layoutItem: LayoutItem\n): LayoutItem[] {\n return layout.filter((l): l is LayoutItem => collides(l, layoutItem));\n}\n","/**\n * Sorting utilities for grid layouts.\n *\n * These functions sort layout items for compaction and iteration.\n */\n\nimport type { CompactType, Layout, LayoutItem } from \"./types.js\";\n\n/**\n * Sort layout items based on the compaction type.\n *\n * - Vertical compaction: sort by row (y) then column (x)\n * - Horizontal compaction: sort by column (x) then row (y)\n * - No compaction (null): return original order\n *\n * Does not modify the original layout.\n *\n * @param layout - Layout to sort\n * @param compactType - Type of compaction\n * @returns Sorted layout\n */\nexport function sortLayoutItems(\n layout: Layout,\n compactType: CompactType\n): LayoutItem[] {\n if (compactType === \"horizontal\") {\n return sortLayoutItemsByColRow(layout);\n }\n if (compactType === \"vertical\") {\n return sortLayoutItemsByRowCol(layout);\n }\n if (compactType === \"wrap\") {\n // Wrap mode uses row-col order (reading order: left-to-right, top-to-bottom)\n return sortLayoutItemsByRowCol(layout);\n }\n // No compaction - return a copy to maintain immutability\n return [...layout];\n}\n\n/**\n * Sort layout items by row ascending, then column ascending.\n *\n * Items are ordered from top-left to bottom-right, row by row.\n * This is the natural reading order for vertical compaction.\n *\n * Does not modify the original layout.\n *\n * @param layout - Layout to sort\n * @returns Sorted array of layout items\n */\nexport function sortLayoutItemsByRowCol(layout: Layout): LayoutItem[] {\n return [...layout].sort((a, b) => {\n // Primary sort by row (y)\n if (a.y !== b.y) {\n return a.y - b.y;\n }\n // Secondary sort by column (x)\n return a.x - b.x;\n });\n}\n\n/**\n * Sort layout items by column ascending, then row ascending.\n *\n * Items are ordered from top-left to bottom-right, column by column.\n * This is the natural order for horizontal compaction.\n *\n * Does not modify the original layout.\n *\n * @param layout - Layout to sort\n * @returns Sorted array of layout items\n */\nexport function sortLayoutItemsByColRow(layout: Layout): LayoutItem[] {\n return [...layout].sort((a, b) => {\n // Primary sort by column (x)\n if (a.x !== b.x) {\n return a.x - b.x;\n }\n // Secondary sort by row (y)\n return a.y - b.y;\n });\n}\n","/**\n * Core layout manipulation utilities.\n *\n * These functions create, modify, and query grid layouts.\n * All functions treat layouts as immutable - they return new arrays/objects.\n */\n\nimport type { CompactType, Layout, LayoutItem, Mutable } from \"./types.js\";\nimport { getAllCollisions, getFirstCollision } from \"./collision.js\";\nimport { sortLayoutItems } from \"./sort.js\";\n\n// ============================================================================\n// Layout Queries\n// ============================================================================\n\n/**\n * Get the bottom-most Y coordinate of the layout.\n *\n * This is the Y position plus height of the lowest item.\n *\n * @param layout - Layout to measure\n * @returns The bottom Y coordinate (0 if layout is empty)\n */\nexport function bottom(layout: Layout): number {\n let max = 0;\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined) {\n const bottomY = item.y + item.h;\n if (bottomY > max) max = bottomY;\n }\n }\n return max;\n}\n\n/**\n * Get a layout item by its ID.\n *\n * @param layout - Layout to search\n * @param id - Item ID to find\n * @returns The layout item, or undefined if not found\n */\nexport function getLayoutItem(\n layout: Layout,\n id: string\n): LayoutItem | undefined {\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined && item.i === id) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * Get all static items from the layout.\n *\n * Static items cannot be moved or resized by the user.\n *\n * @param layout - Layout to filter\n * @returns Array of static layout items\n */\nexport function getStatics(layout: Layout): LayoutItem[] {\n return layout.filter((l): l is LayoutItem => l.static === true);\n}\n\n// ============================================================================\n// Layout Cloning\n// ============================================================================\n\n/**\n * Clone a layout item.\n *\n * Creates a shallow copy with all properties preserved.\n * Boolean properties are normalized (undefined becomes false).\n *\n * @param layoutItem - Item to clone\n * @returns A new layout item with the same properties\n */\nexport function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem {\n return {\n i: layoutItem.i,\n x: layoutItem.x,\n y: layoutItem.y,\n w: layoutItem.w,\n h: layoutItem.h,\n minW: layoutItem.minW,\n maxW: layoutItem.maxW,\n minH: layoutItem.minH,\n maxH: layoutItem.maxH,\n moved: Boolean(layoutItem.moved),\n static: Boolean(layoutItem.static),\n isDraggable: layoutItem.isDraggable,\n isResizable: layoutItem.isResizable,\n resizeHandles: layoutItem.resizeHandles,\n constraints: layoutItem.constraints,\n isBounded: layoutItem.isBounded\n };\n}\n\n/**\n * Clone an entire layout.\n *\n * Creates a new array with cloned items.\n *\n * @param layout - Layout to clone\n * @returns A new layout with cloned items\n */\nexport function cloneLayout(layout: Layout): LayoutItem[] {\n const newLayout: LayoutItem[] = new Array(layout.length);\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined) {\n newLayout[i] = cloneLayoutItem(item);\n }\n }\n return newLayout;\n}\n\n// ============================================================================\n// Layout Modification\n// ============================================================================\n\n/**\n * Replace a layout item in a layout.\n *\n * Returns a new layout with the item replaced. Other items are not cloned.\n *\n * @param layout - Layout to modify\n * @param layoutItem - New item (matched by `i` property)\n * @returns New layout with the item replaced\n */\nexport function modifyLayout(\n layout: Layout,\n layoutItem: LayoutItem\n): LayoutItem[] {\n const newLayout: LayoutItem[] = new Array(layout.length);\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined) {\n if (layoutItem.i === item.i) {\n newLayout[i] = layoutItem;\n } else {\n newLayout[i] = item;\n }\n }\n }\n return newLayout;\n}\n\n/**\n * Apply a transformation to a layout item.\n *\n * Finds the item by key, clones it, applies the callback, and returns\n * a new layout with the modified item.\n *\n * @param layout - Layout to modify\n * @param itemKey - Key of the item to modify\n * @param cb - Callback that receives the cloned item and returns the modified item\n * @returns Tuple of [new layout, modified item or null if not found]\n */\nexport function withLayoutItem(\n layout: Layout,\n itemKey: string,\n cb: (item: LayoutItem) => LayoutItem\n): [LayoutItem[], LayoutItem | null] {\n let item = getLayoutItem(layout, itemKey);\n if (!item) {\n return [[...layout], null];\n }\n\n // Clone, then modify via callback\n item = cb(cloneLayoutItem(item));\n const newLayout = modifyLayout(layout, item);\n\n return [newLayout, item];\n}\n\n// ============================================================================\n// Bounds Correction\n// ============================================================================\n\n/**\n * Ensure all layout items fit within the grid bounds.\n *\n * - Items overflowing right are moved left\n * - Items overflowing left are moved to x=0 and clamped to grid width\n * - Static items that collide with other statics are moved down\n *\n * **IMPORTANT**: This function mutates the layout items in place for performance.\n * The type signature uses `Mutable<LayoutItem>[]` to make this explicit.\n * Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.\n *\n * @param layout - Layout to correct (items WILL be mutated)\n * @param bounds - Grid bounds\n * @returns The same layout array (for chaining)\n */\nexport function correctBounds(\n layout: Mutable<LayoutItem>[],\n bounds: { cols: number }\n): LayoutItem[] {\n const collidesWith = getStatics(layout);\n\n for (let i = 0; i < layout.length; i++) {\n const l = layout[i];\n if (l === undefined) continue;\n\n // Overflows right\n if (l.x + l.w > bounds.cols) {\n l.x = bounds.cols - l.w;\n }\n\n // Overflows left\n if (l.x < 0) {\n l.x = 0;\n l.w = bounds.cols;\n }\n\n if (!l.static) {\n collidesWith.push(l);\n } else {\n // Static items that collide with other statics must be moved down\n while (getFirstCollision(collidesWith, l)) {\n l.y++;\n }\n }\n }\n\n return layout;\n}\n\n// ============================================================================\n// Move Operations\n// ============================================================================\n\n/**\n * Move a layout element to a new position.\n *\n * Handles collision detection and cascading movements.\n * Does not compact the layout - call `compact()` separately.\n *\n * **Note**: This function mutates the `l` parameter directly for performance.\n * The item's x, y, and moved properties will be modified. Callers should\n * ideally pass a cloned item if they need to preserve the original.\n *\n * @param layout - Full layout\n * @param l - Item to move (will be mutated)\n * @param x - New X position (or undefined to keep current)\n * @param y - New Y position (or undefined to keep current)\n * @param isUserAction - True if this is a direct user action (affects collision resolution)\n * @param preventCollision - True to block movement into occupied space (item snaps back). No effect if allowOverlap is true.\n * @param compactType - Compaction type for collision resolution\n * @param cols - Number of columns in the grid\n * @param allowOverlap - True to allow items to stack on top of each other\n * @returns The updated layout\n */\nexport function moveElement(\n layout: Layout,\n l: LayoutItem,\n x: number | undefined,\n y: number | undefined,\n isUserAction: boolean | undefined,\n preventCollision: boolean | undefined,\n compactType: CompactType,\n cols: number,\n allowOverlap?: boolean\n): LayoutItem[] {\n // Static items can't be moved unless explicitly draggable\n if (l.static && l.isDraggable !== true) {\n return [...layout];\n }\n\n // Short-circuit if position unchanged\n if (l.y === y && l.x === x) {\n return [...layout];\n }\n\n const oldX = l.x;\n const oldY = l.y;\n\n // Update position (mutates l directly - see JSDoc note)\n if (typeof x === \"number\") (l as Mutable<LayoutItem>).x = x;\n if (typeof y === \"number\") (l as Mutable<LayoutItem>).y = y;\n (l as Mutable<LayoutItem>).moved = true;\n\n // Sort for proper collision detection order\n let sorted = sortLayoutItems(layout, compactType);\n const movingUp =\n compactType === \"vertical\" && typeof y === \"number\"\n ? oldY >= y\n : compactType === \"horizontal\" && typeof x === \"number\"\n ? oldX >= x\n : false;\n\n if (movingUp) {\n sorted = sorted.reverse();\n }\n\n const collisions = getAllCollisions(sorted, l);\n const hasCollisions = collisions.length > 0;\n\n // Handle overlap mode - just clone and return\n if (hasCollisions && allowOverlap) {\n return cloneLayout(layout);\n }\n\n // Handle prevent collision mode - revert position\n // Return same reference to signal no change occurred\n if (hasCollisions && preventCollision) {\n (l as Mutable<LayoutItem>).x = oldX;\n (l as Mutable<LayoutItem>).y = oldY;\n (l as Mutable<LayoutItem>).moved = false;\n return layout as LayoutItem[];\n }\n\n // Resolve collisions by moving other items\n let resultLayout: LayoutItem[] = [...layout];\n for (let i = 0; i < collisions.length; i++) {\n const collision = collisions[i];\n if (collision === undefined) continue;\n\n // Skip already-moved items to prevent infinite loops\n if (collision.moved) continue;\n\n // Static items can't be moved - move the dragged item instead\n if (collision.static) {\n resultLayout = moveElementAwayFromCollision(\n resultLayout,\n collision,\n l,\n isUserAction,\n compactType,\n cols\n );\n } else {\n resultLayout = moveElementAwayFromCollision(\n resultLayout,\n l,\n collision,\n isUserAction,\n compactType,\n cols\n );\n }\n }\n\n return resultLayout;\n}\n\n/**\n * Move an item away from a collision.\n *\n * Attempts to move the item up/left first if there's room,\n * otherwise moves it down/right.\n *\n * @param layout - Full layout\n * @param collidesWith - The item being collided with\n * @param itemToMove - The item to move away\n * @param isUserAction - True if this is a direct user action\n * @param compactType - Compaction type\n * @param cols - Number of columns\n * @returns Updated layout\n */\nexport function moveElementAwayFromCollision(\n layout: Layout,\n collidesWith: LayoutItem,\n itemToMove: LayoutItem,\n isUserAction: boolean | undefined,\n compactType: CompactType,\n cols: number\n): LayoutItem[] {\n const compactH = compactType === \"horizontal\";\n const compactV = compactType === \"vertical\";\n const preventCollision = collidesWith.static;\n\n // Try to move up/left first (only on primary collision from user action)\n if (isUserAction) {\n isUserAction = false; // Only try this once\n\n // Create a fake item to test if there's room above/left\n const fakeItem: LayoutItem = {\n x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,\n y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,\n w: itemToMove.w,\n h: itemToMove.h,\n i: \"-1\"\n };\n\n const firstCollision = getFirstCollision(layout, fakeItem);\n const collisionNorth =\n firstCollision !== undefined &&\n firstCollision.y + firstCollision.h > collidesWith.y;\n const collisionWest =\n firstCollision !== undefined &&\n collidesWith.x + collidesWith.w > firstCollision.x;\n\n // No collision above/left - we can move there\n if (!firstCollision) {\n return moveElement(\n layout,\n itemToMove,\n compactH ? fakeItem.x : undefined,\n compactV ? fakeItem.y : undefined,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n }\n\n // Handle specific collision cases\n if (collisionNorth && compactV) {\n return moveElement(\n layout,\n itemToMove,\n undefined,\n itemToMove.y + 1,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n }\n\n if (collisionNorth && compactType === null) {\n // Swap positions in free-form mode\n (collidesWith as Mutable<LayoutItem>).y = itemToMove.y;\n (itemToMove as Mutable<LayoutItem>).y = itemToMove.y + itemToMove.h;\n return [...layout];\n }\n\n if (collisionWest && compactH) {\n return moveElement(\n layout,\n collidesWith,\n itemToMove.x,\n undefined,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n }\n }\n\n // Default: move down/right by 1\n const newX = compactH ? itemToMove.x + 1 : undefined;\n const newY = compactV ? itemToMove.y + 1 : undefined;\n\n if (newX === undefined && newY === undefined) {\n return [...layout];\n }\n\n return moveElement(\n layout,\n itemToMove,\n newX,\n newY,\n isUserAction,\n preventCollision,\n compactType,\n cols\n );\n}\n\n// ============================================================================\n// Validation\n// ============================================================================\n\n/**\n * Validate that a layout has the required properties.\n *\n * @param layout - Layout to validate\n * @param contextName - Name for error messages\n * @throws Error if layout is invalid\n */\nexport function validateLayout(\n layout: Layout,\n contextName: string = \"Layout\"\n): void {\n const requiredProps = [\"x\", \"y\", \"w\", \"h\"] as const;\n\n if (!Array.isArray(layout)) {\n throw new Error(`${contextName} must be an array!`);\n }\n\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item === undefined) continue;\n\n for (const key of requiredProps) {\n const value = item[key];\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new Error(\n `ReactGridLayout: ${contextName}[${i}].${key} must be a number! ` +\n `Received: ${String(value)} (${typeof value})`\n );\n }\n }\n\n if (item.i !== undefined && typeof item.i !== \"string\") {\n throw new Error(\n `ReactGridLayout: ${contextName}[${i}].i must be a string! ` +\n `Received: ${String(item.i)} (${typeof item.i})`\n );\n }\n }\n}\n"]}
'use strict';
var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
var React2 = require('react');
var reactDraggable = require('react-draggable');
var reactResizable = require('react-resizable');
var clsx = require('clsx');
var jsxRuntime = require('react/jsx-runtime');
var fastEquals = require('fast-equals');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var React2__default = /*#__PURE__*/_interopDefault(React2);
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
function GridItem(props) {
const {
children,
cols,
containerWidth,
margin,
containerPadding,
rowHeight,
maxRows,
isDraggable,
isResizable,
isBounded,
static: isStatic,
useCSSTransforms = true,
usePercentages = false,
transformScale = 1,
positionStrategy,
dragThreshold = 0,
droppingPosition,
className = "",
style,
handle = "",
cancel = "",
x,
y,
w,
h,
minW = 1,
maxW = Infinity,
minH = 1,
maxH = Infinity,
i,
resizeHandles,
resizeHandle,
constraints = chunk2DDROKB2_js.defaultConstraints,
layoutItem,
layout = [],
onDragStart: onDragStartProp,
onDrag: onDragProp,
onDragStop: onDragStopProp,
onResizeStart: onResizeStartProp,
onResize: onResizeProp,
onResizeStop: onResizeStopProp
} = props;
const [dragging, setDragging] = React2.useState(false);
const [resizing, setResizing] = React2.useState(false);
const elementRef = React2.useRef(null);
const dragPositionRef = React2.useRef({ left: 0, top: 0 });
const resizePositionRef = React2.useRef({
top: 0,
left: 0,
width: 0,
height: 0
});
const prevDroppingPositionRef = React2.useRef(
void 0
);
const layoutRef = React2.useRef(layout);
layoutRef.current = layout;
const onDragStartRef = React2.useRef(null);
const onDragRef = React2.useRef(null);
const dragPendingRef = React2.useRef(false);
const initialDragClientRef = React2.useRef({ x: 0, y: 0 });
const thresholdExceededRef = React2.useRef(false);
const positionParams = React2.useMemo(
() => ({
cols,
containerPadding,
containerWidth,
margin,
maxRows,
rowHeight
}),
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
);
const constraintContext = React2.useMemo(
() => ({
cols,
maxRows,
containerWidth,
containerHeight: 0,
// Auto-height grids don't have a fixed container height
rowHeight,
margin,
// Use empty layout here - the actual layout will be accessed via layoutRef when needed
// This prevents the context from changing when layout changes, avoiding callback recreation
layout: []
}),
[cols, maxRows, containerWidth, rowHeight, margin]
);
const getConstraintContext = React2.useCallback(
() => ({
...constraintContext,
layout: layoutRef.current
}),
[constraintContext]
);
const effectiveLayoutItem = React2.useMemo(
() => layoutItem ?? {
i,
x,
y,
w,
h,
minW,
maxW,
minH,
maxH
},
[layoutItem, i, x, y, w, h, minW, maxW, minH, maxH]
);
const createStyle = React2.useCallback(
(pos2) => {
if (positionStrategy?.calcStyle) {
return positionStrategy.calcStyle(pos2);
}
if (useCSSTransforms) {
return chunk2DDROKB2_js.setTransform(pos2);
}
const styleObj = chunk2DDROKB2_js.setTopLeft(pos2);
if (usePercentages) {
return {
...styleObj,
left: chunk2DDROKB2_js.perc(pos2.left / containerWidth),
width: chunk2DDROKB2_js.perc(pos2.width / containerWidth)
};
}
return styleObj;
},
[positionStrategy, useCSSTransforms, usePercentages, containerWidth]
);
const onDragStart = React2.useCallback(
(e, { node }) => {
if (!onDragStartProp) return;
const { offsetParent } = node;
if (!offsetParent) return;
const parentRect = offsetParent.getBoundingClientRect();
const clientRect = node.getBoundingClientRect();
const cLeft = clientRect.left / transformScale;
const pLeft = parentRect.left / transformScale;
const cTop = clientRect.top / transformScale;
const pTop = parentRect.top / transformScale;
let newPosition;
if (positionStrategy?.calcDragPosition) {
const mouseEvent = e;
newPosition = positionStrategy.calcDragPosition(
mouseEvent.clientX,
mouseEvent.clientY,
mouseEvent.clientX - clientRect.left,
mouseEvent.clientY - clientRect.top
);
} else {
newPosition = {
left: cLeft - pLeft + offsetParent.scrollLeft,
top: cTop - pTop + offsetParent.scrollTop
};
}
dragPositionRef.current = newPosition;
if (dragThreshold > 0) {
const mouseEvent = e;
initialDragClientRef.current = {
x: mouseEvent.clientX,
y: mouseEvent.clientY
};
dragPendingRef.current = true;
thresholdExceededRef.current = false;
setDragging(true);
return;
}
setDragging(true);
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(
positionParams,
newPosition.top,
newPosition.left
);
const { x: newX, y: newY } = chunk2DDROKB2_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStartProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStartProp,
transformScale,
positionParams,
positionStrategy,
dragThreshold,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
const onDrag = React2.useCallback(
(e, { node, deltaX, deltaY }) => {
if (!onDragProp || !dragging) return;
const mouseEvent = e;
if (dragPendingRef.current && !thresholdExceededRef.current) {
const dx = mouseEvent.clientX - initialDragClientRef.current.x;
const dy = mouseEvent.clientY - initialDragClientRef.current.y;
const distance = Math.hypot(dx, dy);
if (distance < dragThreshold) {
return;
}
thresholdExceededRef.current = true;
dragPendingRef.current = false;
if (onDragStartProp) {
const rawPos2 = chunkBJFPTW5Q_js.calcXYRaw(
positionParams,
dragPositionRef.current.top,
dragPositionRef.current.left
);
const { x: startX, y: startY } = chunk2DDROKB2_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos2.x,
rawPos2.y,
getConstraintContext()
);
onDragStartProp(i, startX, startY, {
e,
node,
newPosition: dragPositionRef.current
});
}
}
let top = dragPositionRef.current.top + deltaY;
let left = dragPositionRef.current.left + deltaX;
if (isBounded) {
const { offsetParent } = node;
if (offsetParent) {
const bottomBoundary = offsetParent.clientHeight - chunkBJFPTW5Q_js.calcGridItemWHPx(h, rowHeight, margin[1]);
top = chunkBJFPTW5Q_js.clamp(top, 0, bottomBoundary);
const colWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
const rightBoundary = containerWidth - chunkBJFPTW5Q_js.calcGridItemWHPx(w, colWidth, margin[0]);
left = chunkBJFPTW5Q_js.clamp(left, 0, rightBoundary);
}
}
const newPosition = { top, left };
dragPositionRef.current = newPosition;
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = chunk2DDROKB2_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragProp,
onDragStartProp,
dragging,
dragThreshold,
isBounded,
h,
rowHeight,
margin,
positionParams,
containerWidth,
w,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const onDragStop = React2.useCallback(
(e, { node }) => {
if (!onDragStopProp || !dragging) return;
const wasPending = dragPendingRef.current;
dragPendingRef.current = false;
thresholdExceededRef.current = false;
initialDragClientRef.current = { x: 0, y: 0 };
if (wasPending) {
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
return;
}
const { left, top } = dragPositionRef.current;
const newPosition = { top, left };
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = chunk2DDROKB2_js.applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStopProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStopProp,
dragging,
positionParams,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
onDragStartRef.current = onDragStart;
onDragRef.current = onDrag;
const onResizeHandler = React2.useCallback(
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
if (!handler) return;
let updatedSize;
if (node) {
updatedSize = chunk2DDROKB2_js.resizeItemInDirection(
resizeHandle2,
position,
size,
containerWidth
);
} else {
updatedSize = {
...size,
top: position.top,
left: position.left
};
}
resizePositionRef.current = updatedSize;
const rawSize = chunkBJFPTW5Q_js.calcWHRaw(
positionParams,
updatedSize.width,
updatedSize.height
);
const { w: newW, h: newH } = chunk2DDROKB2_js.applySizeConstraints(
constraints,
effectiveLayoutItem,
rawSize.w,
rawSize.h,
resizeHandle2,
getConstraintContext()
);
handler(i, newW, newH, {
e: e.nativeEvent,
node,
size: updatedSize,
handle: resizeHandle2
});
},
[
onResizeStartProp,
onResizeProp,
onResizeStopProp,
containerWidth,
positionParams,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const handleResizeStart = React2.useCallback(
(e, data) => {
setResizing(true);
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStart");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResize = React2.useCallback(
(e, data) => {
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResize");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResizeStop = React2.useCallback(
(e, data) => {
setResizing(false);
resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStop");
},
[onResizeHandler, positionParams, x, y, w, h]
);
React2.useEffect(() => {
if (!droppingPosition) return;
const node = elementRef.current;
if (!node) return;
const prevDroppingPosition = prevDroppingPositionRef.current || {
left: 0,
top: 0
};
const shouldDrag = dragging && (droppingPosition.left !== prevDroppingPosition.left || droppingPosition.top !== prevDroppingPosition.top);
if (!dragging) {
const fakeData = {
node,
deltaX: droppingPosition.left,
deltaY: droppingPosition.top,
lastX: 0,
lastY: 0,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragStartRef.current?.(
droppingPosition.e,
fakeData
);
} else if (shouldDrag) {
const deltaX = droppingPosition.left - dragPositionRef.current.left;
const deltaY = droppingPosition.top - dragPositionRef.current.top;
const fakeData = {
node,
deltaX,
deltaY,
lastX: dragPositionRef.current.left,
lastY: dragPositionRef.current.top,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragRef.current?.(
droppingPosition.e,
fakeData
);
}
prevDroppingPositionRef.current = droppingPosition;
}, [droppingPosition, dragging, i]);
const pos = chunkBJFPTW5Q_js.calcGridItemPosition(
positionParams,
x,
y,
w,
h,
dragging ? dragPositionRef.current : null,
resizing ? resizePositionRef.current : null
);
const child = React2__default.default.Children.only(children);
const minGridUnit = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, 0, 0, 1, 1);
const minConstraints = [
minGridUnit.width,
minGridUnit.height
];
const maxConstraints = [Infinity, Infinity];
const childProps = child.props;
const childClassName = childProps["className"];
const childStyle = childProps["style"];
let newChild = React2__default.default.cloneElement(child, {
ref: elementRef,
className: clsx__default.default("react-grid-item", childClassName, className, {
static: isStatic,
resizing,
"react-draggable": isDraggable,
"react-draggable-dragging": dragging,
dropping: Boolean(droppingPosition),
cssTransforms: useCSSTransforms
}),
style: {
...style,
...childStyle,
...createStyle(pos)
}
});
const resizableHandle = resizeHandle;
newChild = /* @__PURE__ */ jsxRuntime.jsx(
reactResizable.Resizable,
{
draggableOpts: { disabled: !isResizable },
className: isResizable ? void 0 : "react-resizable-hide",
width: pos.width,
height: pos.height,
minConstraints,
maxConstraints,
onResizeStart: handleResizeStart,
onResize: handleResize,
onResizeStop: handleResizeStop,
transformScale,
resizeHandles,
handle: resizableHandle,
children: newChild
}
);
newChild = /* @__PURE__ */ jsxRuntime.jsx(
reactDraggable.DraggableCore,
{
disabled: !isDraggable,
onStart: onDragStart,
onDrag,
onStop: onDragStop,
handle,
cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
scale: transformScale,
nodeRef: elementRef,
children: newChild
}
);
return newChild;
}
var noop = () => {
};
var layoutClassName = "react-grid-layout";
var isFirefox = false;
try {
isFirefox = /firefox/i.test(navigator.userAgent);
} catch {
}
function childrenEqual(a, b) {
const aArr = React2__default.default.Children.toArray(a);
const bArr = React2__default.default.Children.toArray(b);
if (aArr.length !== bArr.length) return false;
for (let i = 0; i < aArr.length; i++) {
const aChild = aArr[i];
const bChild = bArr[i];
if (aChild?.key !== bChild?.key) return false;
}
return true;
}
function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
const layout = [];
const childKeys = /* @__PURE__ */ new Set();
React2__default.default.Children.forEach(children, (child) => {
if (!React2__default.default.isValidElement(child) || child.key === null) return;
const key = String(child.key);
childKeys.add(key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push(chunkBJFPTW5Q_js.cloneLayoutItem(existingItem));
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: chunkBJFPTW5Q_js.bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function GridLayout(props) {
const {
// Required
children,
width,
// Composable config interfaces
gridConfig: gridConfigProp,
dragConfig: dragConfigProp,
resizeConfig: resizeConfigProp,
dropConfig: dropConfigProp,
positionStrategy = chunk2DDROKB2_js.defaultPositionStrategy,
compactor: compactorProp,
constraints = chunk2DDROKB2_js.defaultConstraints,
// Layout data
layout: propsLayout = [],
droppingItem: droppingItemProp,
// Container props
autoSize = true,
className = "",
style = {},
innerRef,
// Callbacks
onLayoutChange = noop,
onDragStart: onDragStartProp = noop,
onDrag: onDragProp = noop,
onDragStop: onDragStopProp = noop,
onResizeStart: onResizeStartProp = noop,
onResize: onResizeProp = noop,
onResizeStop: onResizeStopProp = noop,
onDrop: onDropProp = noop,
onDropDragOver: onDropDragOverProp = noop
} = props;
const gridConfig = React2.useMemo(
() => ({ ...chunk2DDROKB2_js.defaultGridConfig, ...gridConfigProp }),
[gridConfigProp]
);
const dragConfig = React2.useMemo(
() => ({ ...chunk2DDROKB2_js.defaultDragConfig, ...dragConfigProp }),
[dragConfigProp]
);
const resizeConfig = React2.useMemo(
() => ({ ...chunk2DDROKB2_js.defaultResizeConfig, ...resizeConfigProp }),
[resizeConfigProp]
);
const dropConfig = React2.useMemo(
() => ({ ...chunk2DDROKB2_js.defaultDropConfig, ...dropConfigProp }),
[dropConfigProp]
);
const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
const {
enabled: isDraggable,
bounded: isBounded,
handle: draggableHandle,
cancel: draggableCancel,
threshold: dragThreshold
} = dragConfig;
const {
enabled: isResizable,
handles: resizeHandles,
handleComponent: resizeHandle
} = resizeConfig;
const {
enabled: isDroppable,
defaultItem: defaultDropItem,
onDragOver: dropConfigOnDragOver
} = dropConfig;
const compactor = compactorProp ?? chunk2DDROKB2_js.getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const preventCollision = compactor.preventCollision ?? false;
const droppingItem = React2.useMemo(
() => droppingItemProp ?? {
i: "__dropping-elem__",
...defaultDropItem
},
[droppingItemProp, defaultDropItem]
);
const useCSSTransforms = positionStrategy.type === "transform";
const transformScale = positionStrategy.scale;
const effectiveContainerPadding = containerPadding ?? margin;
const [mounted, setMounted] = React2.useState(false);
const [layout, setLayout] = React2.useState(
() => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor)
);
const [activeDrag, setActiveDrag] = React2.useState(null);
const [resizing, setResizing] = React2.useState(false);
const [droppingDOMNode, setDroppingDOMNode] = React2.useState(
null
);
const [droppingPosition, setDroppingPosition] = React2.useState();
const oldDragItemRef = React2.useRef(null);
const oldResizeItemRef = React2.useRef(null);
const oldLayoutRef = React2.useRef(null);
const dragEnterCounterRef = React2.useRef(0);
const prevLayoutRef = React2.useRef(layout);
const prevPropsLayoutRef = React2.useRef(propsLayout);
const prevChildrenRef = React2.useRef(children);
const prevCompactTypeRef = React2.useRef(compactType);
const layoutRef = React2.useRef(layout);
layoutRef.current = layout;
React2.useEffect(() => {
setMounted(true);
if (!fastEquals.deepEqual(layout, propsLayout)) {
onLayoutChange(layout);
}
}, []);
React2.useEffect(() => {
if (activeDrag) return;
if (droppingDOMNode) return;
const layoutChanged = !fastEquals.deepEqual(propsLayout, prevPropsLayoutRef.current);
const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
const compactTypeChanged = compactType !== prevCompactTypeRef.current;
if (layoutChanged || childrenChanged || compactTypeChanged) {
const baseLayout = layoutChanged ? propsLayout : layout;
const newLayout = synchronizeLayoutWithChildren(
baseLayout,
children,
cols,
compactor
);
if (!fastEquals.deepEqual(newLayout, layout)) {
setLayout(newLayout);
}
}
prevPropsLayoutRef.current = propsLayout;
prevChildrenRef.current = children;
prevCompactTypeRef.current = compactType;
}, [
propsLayout,
children,
cols,
compactType,
compactor,
activeDrag,
droppingDOMNode,
layout
]);
React2.useEffect(() => {
if (!activeDrag && !fastEquals.deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
const publicLayout = layout.filter((l) => l.i !== droppingItem.i);
onLayoutChange(publicLayout);
}
}, [layout, activeDrag, onLayoutChange, droppingItem.i]);
const containerHeight = React2.useMemo(() => {
if (!autoSize) return void 0;
const nbRow = chunkBJFPTW5Q_js.bottom(layout);
const containerPaddingY = effectiveContainerPadding[1];
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
}, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
const onDragStart = React2.useCallback(
(i, _x, _y, data) => {
const currentLayout = layoutRef.current;
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
oldDragItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setActiveDrag(placeholder);
onDragStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onDragStartProp]
);
const onDrag = React2.useCallback(
(i, x, y, data) => {
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
const newLayout = chunkBJFPTW5Q_js.moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
setLayout(compactor.compact(newLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
);
const onDragStop = React2.useCallback(
(i, x, y, data) => {
if (!activeDrag) return;
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
if (!l) return;
const newLayout = chunkBJFPTW5Q_js.moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
const finalLayout = compactor.compact(newLayout, cols);
onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
const oldLayout = oldLayoutRef.current;
oldDragItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setLayout(finalLayout);
if (oldLayout && !fastEquals.deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[
activeDrag,
preventCollision,
compactType,
cols,
allowOverlap,
compactor,
onDragStopProp,
onLayoutChange
]
);
const onResizeStart = React2.useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
if (!l) return;
oldResizeItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setResizing(true);
onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onResizeStartProp]
);
const onResize = React2.useCallback(
(i, w, h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const { handle } = data;
let shouldMoveItem = false;
let newX;
let newY;
const [newLayout, l] = chunkBJFPTW5Q_js.withLayoutItem(currentLayout, i, (item) => {
newX = item.x;
newY = item.y;
if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
if (["sw", "nw", "w"].includes(handle)) {
newX = item.x + (item.w - w);
w = item.x !== newX && newX < 0 ? item.w : w;
newX = newX < 0 ? 0 : newX;
}
if (["ne", "n", "nw"].includes(handle)) {
newY = item.y + (item.h - h);
h = item.y !== newY && newY < 0 ? item.h : h;
newY = newY < 0 ? 0 : newY;
}
shouldMoveItem = true;
}
if (preventCollision && !allowOverlap) {
const collisions = chunkBJFPTW5Q_js.getAllCollisions(currentLayout, {
...item,
w,
h,
x: newX ?? item.x,
y: newY ?? item.y
}).filter((layoutItem) => layoutItem.i !== item.i);
if (collisions.length > 0) {
newY = item.y;
h = item.h;
newX = item.x;
w = item.w;
shouldMoveItem = false;
}
}
item.w = w;
item.h = h;
return item;
});
if (!l) return;
let finalLayout = newLayout;
if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
finalLayout = chunkBJFPTW5Q_js.moveElement(
newLayout,
l,
newX,
newY,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
}
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i,
static: true
};
onResizeProp(
finalLayout,
oldResizeItem,
l,
placeholder,
data.e,
data.node
);
setLayout(compactor.compact(finalLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
);
const onResizeStop = React2.useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
const finalLayout = compactor.compact(currentLayout, cols);
onResizeStopProp(
finalLayout,
oldResizeItem,
l ?? null,
null,
data.e,
data.node
);
const oldLayout = oldLayoutRef.current;
oldResizeItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setResizing(false);
setLayout(finalLayout);
if (oldLayout && !fastEquals.deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[cols, compactor, onResizeStopProp, onLayoutChange]
);
const removeDroppingPlaceholder = React2.useCallback(() => {
const currentLayout = layoutRef.current;
const hasDroppingItem = currentLayout.some((l) => l.i === droppingItem.i);
if (!hasDroppingItem) {
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
return;
}
const newLayout = compactor.compact(
currentLayout.filter((l) => l.i !== droppingItem.i),
cols
);
setLayout(newLayout);
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
}, [droppingItem.i, cols, compactor]);
const handleDragOver = React2.useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
if (isFirefox && !e.nativeEvent.target?.classList.contains(
layoutClassName
)) {
return false;
}
const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
if (rawResult === false) {
if (droppingDOMNode) {
removeDroppingPlaceholder();
}
return false;
}
const {
dragOffsetX = 0,
dragOffsetY = 0,
...onDragOverResult
} = rawResult ?? {};
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
const gridRect = e.currentTarget.getBoundingClientRect();
const positionParams = {
cols,
margin,
maxRows,
rowHeight,
containerWidth: width,
containerPadding: effectiveContainerPadding
};
const actualColWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
const itemPixelWidth = chunkBJFPTW5Q_js.calcGridItemWHPx(
finalDroppingItem.w,
actualColWidth,
margin[0]
);
const itemPixelHeight = chunkBJFPTW5Q_js.calcGridItemWHPx(
finalDroppingItem.h,
rowHeight,
margin[1]
);
const itemCenterOffsetX = itemPixelWidth / 2;
const itemCenterOffsetY = itemPixelHeight / 2;
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
const clampedGridX = Math.max(0, rawGridX);
const clampedGridY = Math.max(0, rawGridY);
const newDroppingPosition = {
left: clampedGridX / transformScale,
top: clampedGridY / transformScale,
e: e.nativeEvent
};
if (!droppingDOMNode) {
const calculatedPosition = chunkBJFPTW5Q_js.calcXY(
positionParams,
clampedGridY,
clampedGridX,
finalDroppingItem.w,
finalDroppingItem.h
);
setDroppingDOMNode(/* @__PURE__ */ jsxRuntime.jsx("div", {}, finalDroppingItem.i));
setDroppingPosition(newDroppingPosition);
setLayout([
...layoutRef.current,
{
...finalDroppingItem,
x: calculatedPosition.x,
y: calculatedPosition.y,
static: false,
isDraggable: true
}
]);
} else if (droppingPosition) {
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
if (shouldUpdate) {
setDroppingPosition(newDroppingPosition);
}
}
},
[
droppingDOMNode,
droppingPosition,
droppingItem,
dropConfigOnDragOver,
onDropDragOverProp,
removeDroppingPlaceholder,
transformScale,
cols,
margin,
maxRows,
rowHeight,
width,
effectiveContainerPadding
]
);
const handleDragLeave = React2.useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current--;
if (dragEnterCounterRef.current < 0) {
dragEnterCounterRef.current = 0;
}
if (dragEnterCounterRef.current === 0) {
removeDroppingPlaceholder();
}
},
[removeDroppingPlaceholder]
);
const handleDragEnter = React2.useCallback((e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current++;
}, []);
const handleDrop = React2.useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
const currentLayout = layoutRef.current;
const item = currentLayout.find((l) => l.i === droppingItem.i);
dragEnterCounterRef.current = 0;
removeDroppingPlaceholder();
onDropProp(currentLayout, item, e.nativeEvent);
},
[droppingItem.i, removeDroppingPlaceholder, onDropProp]
);
const processGridItem = React2.useCallback(
(child, isDroppingItem) => {
if (!child || !child.key) return null;
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, String(child.key));
if (!l) return null;
const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
const resizeHandlesOptions = l.resizeHandles || [...resizeHandles];
const bounded = draggable && isBounded && l.isBounded !== false;
const resizeHandleElement = resizeHandle;
return /* @__PURE__ */ jsxRuntime.jsx(
GridItem,
{
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
cancel: draggableCancel,
handle: draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable: draggable,
isResizable: resizable,
isBounded: bounded,
useCSSTransforms: useCSSTransforms && mounted,
usePercentages: !mounted,
transformScale,
positionStrategy,
dragThreshold,
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i: l.i,
minH: l.minH,
minW: l.minW,
maxH: l.maxH,
maxW: l.maxW,
static: l.static,
droppingPosition: isDroppingItem ? droppingPosition : void 0,
resizeHandles: resizeHandlesOptions,
resizeHandle: resizeHandleElement,
constraints,
layoutItem: l,
layout,
children: child
},
l.i
);
},
[
layout,
width,
cols,
margin,
effectiveContainerPadding,
maxRows,
rowHeight,
draggableCancel,
draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable,
isResizable,
isBounded,
useCSSTransforms,
mounted,
transformScale,
positionStrategy,
dragThreshold,
droppingPosition,
resizeHandles,
resizeHandle,
constraints
]
);
const renderPlaceholder = () => {
if (!activeDrag) return null;
return /* @__PURE__ */ jsxRuntime.jsx(
GridItem,
{
w: activeDrag.w,
h: activeDrag.h,
x: activeDrag.x,
y: activeDrag.y,
i: activeDrag.i,
className: `react-grid-placeholder ${resizing ? "placeholder-resizing" : ""}`,
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
isDraggable: false,
isResizable: false,
isBounded: false,
useCSSTransforms,
transformScale,
constraints,
layout,
children: /* @__PURE__ */ jsxRuntime.jsx("div", {})
}
);
};
const mergedClassName = clsx__default.default(layoutClassName, className);
const mergedStyle = {
height: containerHeight,
...style
};
return /* @__PURE__ */ jsxRuntime.jsxs(
"div",
{
ref: innerRef,
className: mergedClassName,
style: mergedStyle,
onDrop: isDroppable ? handleDrop : void 0,
onDragLeave: isDroppable ? handleDragLeave : void 0,
onDragEnter: isDroppable ? handleDragEnter : void 0,
onDragOver: isDroppable ? handleDragOver : void 0,
children: [
React2__default.default.Children.map(children, (child) => {
if (!React2__default.default.isValidElement(child)) return null;
return processGridItem(child);
}),
isDroppable && droppingDOMNode && processGridItem(droppingDOMNode, true),
renderPlaceholder()
]
}
);
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
var noop2 = () => {
};
function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor) {
const layout = [];
React2__default.default.Children.forEach(children, (child) => {
if (!React2__default.default.isValidElement(child) || child.key === null) return;
const key = String(child.key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push({
...existingItem,
i: key
});
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: chunkBJFPTW5Q_js.bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function ResponsiveGridLayout(props) {
const {
children,
width,
breakpoint: propBreakpoint,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
rowHeight = 150,
maxRows = Infinity,
margin: propMargin = [10, 10],
containerPadding: propContainerPadding = null,
compactor: compactorProp,
onBreakpointChange = noop2,
onLayoutChange = noop2,
onWidthChange = noop2,
...restProps
} = props;
const compactor = compactorProp ?? chunk2DDROKB2_js.getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const initialBreakpoint = React2.useMemo(() => {
return propBreakpoint ?? chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
}, []);
const initialCols = React2.useMemo(() => {
return chunk2DDROKB2_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
}, [initialBreakpoint, colsConfig]);
const initialLayout = React2.useMemo(() => {
return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
initialBreakpoint,
initialBreakpoint,
initialCols,
compactType
);
}, []);
const [breakpoint, setBreakpoint] = React2.useState(initialBreakpoint);
const [cols, setCols] = React2.useState(initialCols);
const [layout, setLayout] = React2.useState(initialLayout);
const [layouts, setLayouts] = React2.useState(propsLayouts);
const prevWidthRef = React2.useRef(width);
const prevBreakpointRef = React2.useRef(propBreakpoint);
const prevBreakpointsRef = React2.useRef(breakpoints);
const prevColsRef = React2.useRef(colsConfig);
const prevLayoutsRef = React2.useRef(propsLayouts);
const prevCompactTypeRef = React2.useRef(compactType);
const layoutsRef = React2.useRef(layouts);
React2.useEffect(() => {
layoutsRef.current = layouts;
}, [layouts]);
const derivedLayout = React2.useMemo(() => {
if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
breakpoint,
breakpoint,
cols,
compactor
);
}
return null;
}, [propsLayouts, breakpoints, breakpoint, cols, compactor]);
const effectiveLayout = derivedLayout ?? layout;
React2.useEffect(() => {
if (derivedLayout !== null) {
setLayout(derivedLayout);
setLayouts(propsLayouts);
layoutsRef.current = propsLayouts;
prevLayoutsRef.current = propsLayouts;
}
}, [derivedLayout, propsLayouts]);
React2.useEffect(() => {
if (compactType !== prevCompactTypeRef.current) {
const newLayout = compactor.compact(chunkBJFPTW5Q_js.cloneLayout(effectiveLayout), cols);
const newLayouts = {
...layoutsRef.current,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
prevCompactTypeRef.current = compactType;
}
}, [
compactType,
compactor,
effectiveLayout,
cols,
allowOverlap,
breakpoint,
onLayoutChange
]);
React2.useEffect(() => {
const widthChanged = width !== prevWidthRef.current;
const breakpointPropChanged = propBreakpoint !== prevBreakpointRef.current;
const breakpointsChanged = !fastEquals.deepEqual(
breakpoints,
prevBreakpointsRef.current
);
const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
const newBreakpoint = propBreakpoint ?? chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
const newCols = chunk2DDROKB2_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
const lastBreakpoint = breakpoint;
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
const newLayouts = { ...layoutsRef.current };
if (!newLayouts[lastBreakpoint]) {
newLayouts[lastBreakpoint] = chunkBJFPTW5Q_js.cloneLayout(layout);
}
let newLayout = chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
newLayouts,
breakpoints,
newBreakpoint,
lastBreakpoint,
newCols,
compactor
);
newLayout = synchronizeLayoutWithChildren2(
newLayout,
children,
newCols,
compactor
);
newLayouts[newBreakpoint] = newLayout;
setBreakpoint(newBreakpoint);
setCols(newCols);
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onBreakpointChange(newBreakpoint, newCols);
onLayoutChange(newLayout, newLayouts);
}
const currentMargin2 = chunk2DDROKB2_js.getIndentationValue(
propMargin,
newBreakpoint
);
const currentPadding = propContainerPadding ? chunk2DDROKB2_js.getIndentationValue(
propContainerPadding,
newBreakpoint
) : null;
onWidthChange(width, currentMargin2, newCols, currentPadding);
prevWidthRef.current = width;
prevBreakpointRef.current = propBreakpoint;
prevBreakpointsRef.current = breakpoints;
prevColsRef.current = colsConfig;
}
}, [
width,
propBreakpoint,
breakpoints,
colsConfig,
breakpoint,
cols,
layout,
children,
compactor,
compactType,
allowOverlap,
propMargin,
propContainerPadding,
onBreakpointChange,
onLayoutChange,
onWidthChange
]);
const handleLayoutChange = React2.useCallback(
(newLayout) => {
const currentLayouts = layoutsRef.current;
const newLayouts = {
...currentLayouts,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
},
[breakpoint, onLayoutChange]
);
const currentMargin = React2.useMemo(() => {
return chunk2DDROKB2_js.getIndentationValue(
propMargin,
breakpoint
);
}, [propMargin, breakpoint]);
const currentContainerPadding = React2.useMemo(() => {
if (propContainerPadding === null) return null;
return chunk2DDROKB2_js.getIndentationValue(
propContainerPadding,
breakpoint
);
}, [propContainerPadding, breakpoint]);
const gridConfig = React2.useMemo(
() => ({
cols,
rowHeight,
maxRows,
margin: currentMargin,
containerPadding: currentContainerPadding
}),
[cols, rowHeight, maxRows, currentMargin, currentContainerPadding]
);
return /* @__PURE__ */ jsxRuntime.jsx(
GridLayout,
{
...restProps,
width,
gridConfig,
compactor,
onLayoutChange: handleLayoutChange,
layout: effectiveLayout,
children
}
);
}
exports.GridItem = GridItem;
exports.GridLayout = GridLayout;
exports.ResponsiveGridLayout = ResponsiveGridLayout;
//# sourceMappingURL=chunk-KEM2G3LX.js.map
//# sourceMappingURL=chunk-KEM2G3LX.js.map

Sorry, the diff of this file is too big to display

'use strict';
//# sourceMappingURL=chunk-PBQSHIID.js.map
//# sourceMappingURL=chunk-PBQSHIID.js.map
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-PBQSHIID.js"}
'use strict';
var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
var react = require('react');
var fastEquals = require('fast-equals');
function useContainerWidth(options = {}) {
const { measureBeforeMount = false, initialWidth = 1280 } = options;
const [width, setWidth] = react.useState(initialWidth);
const [mounted, setMounted] = react.useState(!measureBeforeMount);
const containerRef = react.useRef(null);
const observerRef = react.useRef(null);
const measureWidth = react.useCallback(() => {
const node = containerRef.current;
if (node) {
const newWidth = node.offsetWidth;
setWidth(newWidth);
if (!mounted) {
setMounted(true);
}
}
}, [mounted]);
react.useEffect(() => {
const node = containerRef.current;
if (!node) return;
measureWidth();
if (typeof ResizeObserver !== "undefined") {
observerRef.current = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry) {
const newWidth = entry.contentRect.width;
setWidth(newWidth);
}
});
observerRef.current.observe(node);
}
return () => {
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
};
}, [measureWidth]);
return {
width,
mounted,
containerRef,
measureWidth
};
}
function useGridLayout(options) {
const {
layout: propsLayout,
cols,
preventCollision = false,
onLayoutChange,
compactor = chunk2DDROKB2_js.verticalCompactor
} = options;
const isDraggingRef = react.useRef(false);
const [layout, setLayoutState] = react.useState(() => {
const corrected = chunkBJFPTW5Q_js.correctBounds(chunkBJFPTW5Q_js.cloneLayout(propsLayout), { cols });
return compactor.compact(corrected, cols);
});
const [dragState, setDragState] = react.useState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
const [resizeState, setResizeState] = react.useState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
const [dropState, setDropState] = react.useState({
droppingDOMNode: null,
droppingPosition: null
});
const prevLayoutRef = react.useRef(layout);
const setLayout = react.useCallback(
(newLayout) => {
const corrected = chunkBJFPTW5Q_js.correctBounds(chunkBJFPTW5Q_js.cloneLayout(newLayout), { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[cols, compactor]
);
react.useEffect(() => {
if (isDraggingRef.current) return;
if (!fastEquals.deepEqual(propsLayout, prevLayoutRef.current)) {
setLayout(propsLayout);
}
}, [propsLayout, setLayout]);
react.useEffect(() => {
if (!fastEquals.deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
onLayoutChange?.(layout);
}
}, [layout, onLayoutChange]);
const onDragStart = react.useCallback(
(itemId, x, y) => {
const item = chunkBJFPTW5Q_js.getLayoutItem(layout, itemId);
if (!item) return null;
isDraggingRef.current = true;
const placeholder = {
...chunkBJFPTW5Q_js.cloneLayoutItem(item),
x,
y,
static: false,
moved: false
};
setDragState({
activeDrag: placeholder,
oldDragItem: chunkBJFPTW5Q_js.cloneLayoutItem(item),
oldLayout: chunkBJFPTW5Q_js.cloneLayout(layout)
});
return placeholder;
},
[layout]
);
const onDrag = react.useCallback(
(itemId, x, y) => {
const item = chunkBJFPTW5Q_js.getLayoutItem(layout, itemId);
if (!item) return;
setDragState((prev) => ({
...prev,
activeDrag: prev.activeDrag ? { ...prev.activeDrag, x, y } : null
}));
const newLayout = chunkBJFPTW5Q_js.moveElement(
layout,
item,
x,
y,
true,
// isUserAction
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onDragStop = react.useCallback(
(itemId, x, y) => {
const item = chunkBJFPTW5Q_js.getLayoutItem(layout, itemId);
if (!item) return;
const newLayout = chunkBJFPTW5Q_js.moveElement(
layout,
item,
x,
y,
true,
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
isDraggingRef.current = false;
setDragState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onResizeStart = react.useCallback(
(itemId) => {
const item = chunkBJFPTW5Q_js.getLayoutItem(layout, itemId);
if (!item) return null;
setResizeState({
resizing: true,
oldResizeItem: chunkBJFPTW5Q_js.cloneLayoutItem(item),
oldLayout: chunkBJFPTW5Q_js.cloneLayout(layout)
});
return item;
},
[layout]
);
const onResize = react.useCallback(
(itemId, w, h, x, y) => {
const newLayout = layout.map((item) => {
if (item.i === itemId) {
const updated = {
...item,
w,
h
};
if (x !== void 0) updated.x = x;
if (y !== void 0) updated.y = y;
return updated;
}
return item;
});
const corrected = chunkBJFPTW5Q_js.correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[layout, cols, compactor]
);
const onResizeStop = react.useCallback(
(itemId, w, h) => {
onResize(itemId, w, h);
setResizeState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
},
[onResize]
);
const onDropDragOver = react.useCallback(
(droppingItem, position) => {
const existingItem = chunkBJFPTW5Q_js.getLayoutItem(layout, droppingItem.i);
if (!existingItem) {
const newLayout = [...layout, droppingItem];
const corrected = chunkBJFPTW5Q_js.correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
}
setDropState({
droppingDOMNode: null,
// Will be set by component
droppingPosition: position
});
},
[layout, cols, compactor]
);
const onDropDragLeave = react.useCallback(() => {
const newLayout = layout.filter((item) => item.i !== "__dropping-elem__");
setLayoutState(newLayout);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
}, [layout]);
const onDrop = react.useCallback(
(droppingItem) => {
const newLayout = layout.map((item) => {
if (item.i === "__dropping-elem__") {
return {
...item,
i: droppingItem.i,
static: false
};
}
return item;
});
const corrected = chunkBJFPTW5Q_js.correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
},
[layout, cols, compactor]
);
const containerHeight = react.useMemo(() => chunkBJFPTW5Q_js.bottom(layout), [layout]);
const isInteracting = dragState.activeDrag !== null || resizeState.resizing || dropState.droppingPosition !== null;
return {
layout,
setLayout,
dragState,
resizeState,
dropState,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
onDropDragOver,
onDropDragLeave,
onDrop,
containerHeight,
isInteracting,
compactor
};
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
function useResponsiveLayout(options) {
const {
width,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
compactor = chunk2DDROKB2_js.verticalCompactor,
onBreakpointChange,
onLayoutChange,
onWidthChange
} = options;
const sortedBreakpoints = react.useMemo(
() => chunk2DDROKB2_js.sortBreakpoints(breakpoints),
[breakpoints]
);
const initialBreakpoint = react.useMemo(
() => chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width),
// Only calculate on mount, not on width changes
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
const initialCols = react.useMemo(
() => chunk2DDROKB2_js.getColsFromBreakpoint(initialBreakpoint, colsConfig),
[initialBreakpoint, colsConfig]
);
const [breakpoint, setBreakpoint] = react.useState(initialBreakpoint);
const [cols, setCols] = react.useState(initialCols);
const [layouts, setLayoutsState] = react.useState(() => {
const cloned = {};
for (const bp of sortedBreakpoints) {
const layout2 = propsLayouts[bp];
if (layout2) {
cloned[bp] = chunkBJFPTW5Q_js.cloneLayout(layout2);
}
}
return cloned;
});
const prevWidthRef = react.useRef(width);
const prevBreakpointRef = react.useRef(breakpoint);
const prevPropsLayoutsRef = react.useRef(propsLayouts);
const prevLayoutsRef = react.useRef(layouts);
const layout = react.useMemo(() => {
return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
layouts,
breakpoints,
breakpoint,
prevBreakpointRef.current,
cols,
compactor
);
}, [layouts, breakpoints, breakpoint, cols, compactor]);
const setLayoutForBreakpoint = react.useCallback((bp, newLayout) => {
setLayoutsState((prev) => ({
...prev,
[bp]: chunkBJFPTW5Q_js.cloneLayout(newLayout)
}));
}, []);
const setLayouts = react.useCallback((newLayouts) => {
const cloned = {};
for (const bp of Object.keys(newLayouts)) {
const layoutForBp = newLayouts[bp];
if (layoutForBp) {
cloned[bp] = chunkBJFPTW5Q_js.cloneLayout(layoutForBp);
}
}
setLayoutsState(cloned);
}, []);
react.useEffect(() => {
if (prevWidthRef.current === width) return;
prevWidthRef.current = width;
const newBreakpoint = chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
const newCols = chunk2DDROKB2_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
onWidthChange?.(width, [10, 10], newCols, null);
if (newBreakpoint !== breakpoint) {
const newLayout = chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
layouts,
breakpoints,
newBreakpoint,
breakpoint,
newCols,
compactor
);
const updatedLayouts = {
...layouts,
[newBreakpoint]: newLayout
};
setLayoutsState(updatedLayouts);
setBreakpoint(newBreakpoint);
setCols(newCols);
onBreakpointChange?.(newBreakpoint, newCols);
prevBreakpointRef.current = newBreakpoint;
}
}, [
width,
breakpoints,
colsConfig,
breakpoint,
layouts,
compactor,
onBreakpointChange,
onWidthChange
]);
react.useEffect(() => {
if (!fastEquals.deepEqual(propsLayouts, prevPropsLayoutsRef.current)) {
setLayouts(propsLayouts);
prevPropsLayoutsRef.current = propsLayouts;
}
}, [propsLayouts, setLayouts]);
react.useEffect(() => {
if (!fastEquals.deepEqual(layouts, prevLayoutsRef.current)) {
prevLayoutsRef.current = layouts;
onLayoutChange?.(layout, layouts);
}
}, [layout, layouts, onLayoutChange]);
return {
layout,
layouts,
breakpoint,
cols,
setLayoutForBreakpoint,
setLayouts,
sortedBreakpoints
};
}
exports.DEFAULT_BREAKPOINTS = DEFAULT_BREAKPOINTS;
exports.DEFAULT_COLS = DEFAULT_COLS;
exports.useContainerWidth = useContainerWidth;
exports.useGridLayout = useGridLayout;
exports.useResponsiveLayout = useResponsiveLayout;
//# sourceMappingURL=chunk-QGXQSZII.js.map
//# sourceMappingURL=chunk-QGXQSZII.js.map
{"version":3,"sources":["../src/react/hooks/useContainerWidth.ts","../src/react/hooks/useGridLayout.ts","../src/react/hooks/useResponsiveLayout.ts"],"names":["useState","useRef","useCallback","useEffect","verticalCompactor","correctBounds","cloneLayout","deepEqual","getLayoutItem","cloneLayoutItem","moveElement","useMemo","bottom","sortBreakpoints","getBreakpointFromWidth","getColsFromBreakpoint","layout","findOrGenerateResponsiveLayout"],"mappings":";;;;;;;AAsEO,SAAS,iBAAA,CACd,OAAA,GAAoC,EAAC,EACZ;AACzB,EAAA,MAAM,EAAE,kBAAA,GAAqB,KAAA,EAAO,YAAA,GAAe,MAAK,GAAI,OAAA;AAE5D,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAS,YAAY,CAAA;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAIA,cAAA,CAAS,CAAC,kBAAkB,CAAA;AAC1D,EAAA,MAAM,YAAA,GAAeC,aAA8B,IAAI,CAAA;AACvD,EAAA,MAAM,WAAA,GAAcA,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;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-QGXQSZII.js","sourcesContent":["/**\n * useContainerWidth hook\n *\n * Observes container width using ResizeObserver and provides\n * reactive width updates for responsive layouts.\n */\n\nimport {\n useState,\n useEffect,\n useRef,\n useCallback,\n type RefObject\n} from \"react\";\n\nexport interface UseContainerWidthOptions {\n /**\n * If true, delays initial render until width is measured.\n * Useful for SSR or when you need accurate initial measurements.\n */\n measureBeforeMount?: boolean;\n\n /**\n * Initial width to use before measurement.\n * Defaults to 1280.\n */\n initialWidth?: number;\n}\n\nexport interface UseContainerWidthResult {\n /**\n * Current container width in pixels.\n */\n width: number;\n\n /**\n * Whether the container has been measured at least once.\n */\n mounted: boolean;\n\n /**\n * Ref to attach to the container element.\n */\n containerRef: RefObject<HTMLDivElement | null>;\n\n /**\n * Manually trigger a width measurement.\n * Useful when the container size might change without a resize event.\n */\n measureWidth: () => void;\n}\n\n/**\n * Hook to observe and track container width.\n *\n * Replaces the WidthProvider HOC with a more composable approach.\n *\n * @example\n * ```tsx\n * function MyGrid() {\n * const { width, containerRef, mounted } = useContainerWidth();\n *\n * return (\n * <div ref={containerRef}>\n * {mounted && <GridLayout width={width} {...props} />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useContainerWidth(\n options: UseContainerWidthOptions = {}\n): UseContainerWidthResult {\n const { measureBeforeMount = false, initialWidth = 1280 } = options;\n\n const [width, setWidth] = useState(initialWidth);\n const [mounted, setMounted] = useState(!measureBeforeMount);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const measureWidth = useCallback(() => {\n const node = containerRef.current;\n if (node) {\n const newWidth = node.offsetWidth;\n setWidth(newWidth);\n if (!mounted) {\n setMounted(true);\n }\n }\n }, [mounted]);\n\n useEffect(() => {\n const node = containerRef.current;\n if (!node) return;\n\n // Initial measurement\n measureWidth();\n\n // Set up ResizeObserver\n if (typeof ResizeObserver !== \"undefined\") {\n observerRef.current = new ResizeObserver(entries => {\n const entry = entries[0];\n if (entry) {\n // Use contentRect.width for consistent measurements\n const newWidth = entry.contentRect.width;\n setWidth(newWidth);\n }\n });\n\n observerRef.current.observe(node);\n }\n\n return () => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n };\n }, [measureWidth]);\n\n return {\n width,\n mounted,\n containerRef,\n measureWidth\n };\n}\n\nexport default useContainerWidth;\n","/**\n * useGridLayout hook\n *\n * Core hook for managing grid layout state, including drag, resize, and drop operations.\n * This extracts the state management logic from ReactGridLayout into a reusable hook.\n */\n\nimport { useState, useCallback, useMemo, useRef, useEffect } from \"react\";\nimport { deepEqual } from \"fast-equals\";\nimport type {\n Layout,\n LayoutItem,\n DroppingPosition,\n Compactor,\n Mutable\n} from \"../../core/types.js\";\nimport {\n cloneLayout,\n cloneLayoutItem,\n moveElement,\n correctBounds,\n bottom,\n getLayoutItem\n} from \"../../core/layout.js\";\nimport { verticalCompactor } from \"../../core/compactors.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface DragState {\n /** Currently dragging item placeholder */\n activeDrag: LayoutItem | null;\n /** Original item before drag started */\n oldDragItem: LayoutItem | null;\n /** Layout before drag started */\n oldLayout: Layout | null;\n}\n\nexport interface ResizeState {\n /** Whether a resize is in progress */\n resizing: boolean;\n /** Original item before resize started */\n oldResizeItem: LayoutItem | null;\n /** Layout before resize started */\n oldLayout: Layout | null;\n}\n\nexport interface DropState {\n /** DOM node for the dropping placeholder */\n droppingDOMNode: React.ReactElement | null;\n /** Current drop position */\n droppingPosition: DroppingPosition | null;\n}\n\nexport interface UseGridLayoutOptions {\n /** Initial layout */\n layout: Layout;\n /** Number of columns */\n cols: number;\n /** Prevent collisions when moving items */\n preventCollision?: boolean;\n /** Called when layout changes */\n onLayoutChange?: (layout: Layout) => void;\n /** Compactor for layout compaction (default: verticalCompactor) */\n compactor?: Compactor;\n}\n\nexport interface UseGridLayoutResult {\n /** Current layout */\n layout: Layout;\n /** Set layout directly */\n setLayout: (layout: Layout) => void;\n /** Drag state */\n dragState: DragState;\n /** Resize state */\n resizeState: ResizeState;\n /** Drop state */\n dropState: DropState;\n /** Start dragging an item */\n onDragStart: (itemId: string, x: number, y: number) => LayoutItem | null;\n /** Update drag position */\n onDrag: (itemId: string, x: number, y: number) => void;\n /** Stop dragging */\n onDragStop: (itemId: string, x: number, y: number) => void;\n /** Start resizing an item */\n onResizeStart: (itemId: string) => LayoutItem | null;\n /** Update resize dimensions */\n onResize: (\n itemId: string,\n w: number,\n h: number,\n x?: number,\n y?: number\n ) => void;\n /** Stop resizing */\n onResizeStop: (itemId: string, w: number, h: number) => void;\n /** Start dropping (external drag-in) */\n onDropDragOver: (\n droppingItem: LayoutItem,\n position: DroppingPosition\n ) => void;\n /** Update drop position */\n onDropDragLeave: () => void;\n /** Complete drop */\n onDrop: (droppingItem: LayoutItem) => void;\n /** Container height in rows */\n containerHeight: number;\n /** Whether any drag/resize is active */\n isInteracting: boolean;\n /** Get the compactor being used */\n compactor: Compactor;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for managing grid layout state.\n *\n * Handles all layout state including drag, resize, and drop operations.\n * Uses immutable updates and provides callbacks for all interactions.\n *\n * @example\n * ```tsx\n * function MyGrid() {\n * const {\n * layout,\n * onDragStart,\n * onDrag,\n * onDragStop,\n * containerHeight\n * } = useGridLayout({\n * layout: initialLayout,\n * cols: 12\n * });\n *\n * return (\n * <div style={{ height: containerHeight }}>\n * {layout.map(item => (\n * <GridItem\n * key={item.i}\n * {...item}\n * onDragStart={() => onDragStart(item.i, item.x, item.y)}\n * />\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useGridLayout(\n options: UseGridLayoutOptions\n): UseGridLayoutResult {\n const {\n layout: propsLayout,\n cols,\n preventCollision = false,\n onLayoutChange,\n compactor = verticalCompactor\n } = options;\n\n // Track if we're currently dragging to block prop updates\n const isDraggingRef = useRef(false);\n\n // Initialize layout with compaction using the compactor\n const [layout, setLayoutState] = useState<Layout>(() => {\n const corrected = correctBounds(cloneLayout(propsLayout), { cols });\n return compactor.compact(corrected, cols);\n });\n\n // Drag state\n const [dragState, setDragState] = useState<DragState>({\n activeDrag: null,\n oldDragItem: null,\n oldLayout: null\n });\n\n // Resize state\n const [resizeState, setResizeState] = useState<ResizeState>({\n resizing: false,\n oldResizeItem: null,\n oldLayout: null\n });\n\n // Drop state\n const [dropState, setDropState] = useState<DropState>({\n droppingDOMNode: null,\n droppingPosition: null\n });\n\n // Track previous layout for change detection\n const prevLayoutRef = useRef<Layout>(layout);\n\n // Set layout with optional compaction - use compactor.compact() (#2213)\n const setLayout = useCallback(\n (newLayout: Layout) => {\n const corrected = correctBounds(cloneLayout(newLayout), { cols });\n const compacted = compactor.compact(corrected, cols);\n setLayoutState(compacted);\n },\n [cols, compactor]\n );\n\n // Sync layout from props when not dragging\n useEffect(() => {\n if (isDraggingRef.current) return;\n\n if (!deepEqual(propsLayout, prevLayoutRef.current)) {\n setLayout(propsLayout);\n }\n }, [propsLayout, setLayout]);\n\n // Notify layout changes\n useEffect(() => {\n if (!deepEqual(layout, prevLayoutRef.current)) {\n prevLayoutRef.current = layout;\n onLayoutChange?.(layout);\n }\n }, [layout, onLayoutChange]);\n\n // ============================================================================\n // Drag Handlers\n // ============================================================================\n\n const onDragStart = useCallback(\n (itemId: string, x: number, y: number): LayoutItem | null => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return null;\n\n isDraggingRef.current = true;\n\n const placeholder: LayoutItem = {\n ...cloneLayoutItem(item),\n x,\n y,\n static: false,\n moved: false\n };\n\n setDragState({\n activeDrag: placeholder,\n oldDragItem: cloneLayoutItem(item),\n oldLayout: cloneLayout(layout)\n });\n\n return placeholder;\n },\n [layout]\n );\n\n const onDrag = useCallback(\n (itemId: string, x: number, y: number) => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return;\n\n // Update placeholder position\n setDragState(prev => ({\n ...prev,\n activeDrag: prev.activeDrag ? { ...prev.activeDrag, x, y } : null\n }));\n\n // Move element and update layout\n const newLayout = moveElement(\n layout,\n item,\n x,\n y,\n true, // isUserAction\n preventCollision,\n compactor.type,\n cols,\n compactor.allowOverlap\n );\n\n // Compact layout - use compactor.compact() (#2213)\n const compacted = compactor.compact(newLayout, cols);\n\n setLayoutState(compacted);\n },\n [layout, cols, compactor, preventCollision]\n );\n\n const onDragStop = useCallback(\n (itemId: string, x: number, y: number) => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return;\n\n // Final move\n const newLayout = moveElement(\n layout,\n item,\n x,\n y,\n true,\n preventCollision,\n compactor.type,\n cols,\n compactor.allowOverlap\n );\n\n // Compact and finalize - use compactor.compact() (#2213)\n const compacted = compactor.compact(newLayout, cols);\n\n isDraggingRef.current = false;\n\n setDragState({\n activeDrag: null,\n oldDragItem: null,\n oldLayout: null\n });\n\n setLayoutState(compacted);\n },\n [layout, cols, compactor, preventCollision]\n );\n\n // ============================================================================\n // Resize Handlers\n // ============================================================================\n\n const onResizeStart = useCallback(\n (itemId: string): LayoutItem | null => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return null;\n\n setResizeState({\n resizing: true,\n oldResizeItem: cloneLayoutItem(item),\n oldLayout: cloneLayout(layout)\n });\n\n return item;\n },\n [layout]\n );\n\n const onResize = useCallback(\n (itemId: string, w: number, h: number, x?: number, y?: number) => {\n const newLayout = layout.map(item => {\n if (item.i === itemId) {\n const updated: LayoutItem = {\n ...item,\n w,\n h\n };\n if (x !== undefined) (updated as Mutable<LayoutItem>).x = x;\n if (y !== undefined) (updated as Mutable<LayoutItem>).y = y;\n return updated;\n }\n return item;\n });\n\n // Correct bounds and compact - use compactor.compact() (#2213)\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compactor.compact(corrected, cols);\n\n setLayoutState(compacted);\n },\n [layout, cols, compactor]\n );\n\n const onResizeStop = useCallback(\n (itemId: string, w: number, h: number) => {\n // Apply final resize\n onResize(itemId, w, h);\n\n setResizeState({\n resizing: false,\n oldResizeItem: null,\n oldLayout: null\n });\n },\n [onResize]\n );\n\n // ============================================================================\n // Drop Handlers\n // ============================================================================\n\n const onDropDragOver = useCallback(\n (droppingItem: LayoutItem, position: DroppingPosition) => {\n // Check if item already exists in layout\n const existingItem = getLayoutItem(layout, droppingItem.i);\n\n if (!existingItem) {\n // Add dropping item to layout - use compactor.compact() (#2213)\n const newLayout = [...layout, droppingItem];\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compactor.compact(corrected, cols);\n setLayoutState(compacted);\n }\n\n setDropState({\n droppingDOMNode: null, // Will be set by component\n droppingPosition: position\n });\n },\n [layout, cols, compactor]\n );\n\n const onDropDragLeave = useCallback(() => {\n // Remove dropping placeholder from layout\n const newLayout = layout.filter(item => item.i !== \"__dropping-elem__\");\n setLayoutState(newLayout);\n\n setDropState({\n droppingDOMNode: null,\n droppingPosition: null\n });\n }, [layout]);\n\n const onDrop = useCallback(\n (droppingItem: LayoutItem) => {\n // Replace placeholder with actual item\n const newLayout = layout.map(item => {\n if (item.i === \"__dropping-elem__\") {\n return {\n ...item,\n i: droppingItem.i,\n static: false\n };\n }\n return item;\n });\n\n // Use compactor.compact() (#2213)\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compactor.compact(corrected, cols);\n setLayoutState(compacted);\n\n setDropState({\n droppingDOMNode: null,\n droppingPosition: null\n });\n },\n [layout, cols, compactor]\n );\n\n // ============================================================================\n // Computed Values\n // ============================================================================\n\n const containerHeight = useMemo(() => bottom(layout), [layout]);\n\n const isInteracting =\n dragState.activeDrag !== null ||\n resizeState.resizing ||\n dropState.droppingPosition !== null;\n\n return {\n layout,\n setLayout,\n dragState,\n resizeState,\n dropState,\n onDragStart,\n onDrag,\n onDragStop,\n onResizeStart,\n onResize,\n onResizeStop,\n onDropDragOver,\n onDropDragLeave,\n onDrop,\n containerHeight,\n isInteracting,\n compactor\n };\n}\n\nexport default useGridLayout;\n","/**\n * useResponsiveLayout hook\n *\n * Manages responsive breakpoints and layout generation for different screen sizes.\n * Extracts state management from ResponsiveReactGridLayout into a reusable hook.\n */\n\nimport { useState, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { deepEqual } from \"fast-equals\";\nimport type {\n Layout,\n Breakpoint,\n Breakpoints,\n ResponsiveLayouts,\n Compactor\n} from \"../../core/types.js\";\nimport { cloneLayout } from \"../../core/layout.js\";\nimport {\n getBreakpointFromWidth,\n getColsFromBreakpoint,\n findOrGenerateResponsiveLayout,\n sortBreakpoints\n} from \"../../core/responsive.js\";\nimport { verticalCompactor } from \"../../core/compactors.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Default breakpoint names */\nexport type DefaultBreakpoints = \"lg\" | \"md\" | \"sm\" | \"xs\" | \"xxs\";\n\n/** Default breakpoint widths */\nexport const DEFAULT_BREAKPOINTS: Breakpoints<DefaultBreakpoints> = {\n lg: 1200,\n md: 996,\n sm: 768,\n xs: 480,\n xxs: 0\n};\n\n/** Default column counts per breakpoint */\nexport const DEFAULT_COLS: Breakpoints<DefaultBreakpoints> = {\n lg: 12,\n md: 10,\n sm: 6,\n xs: 4,\n xxs: 2\n};\n\nexport interface UseResponsiveLayoutOptions<\n B extends Breakpoint = DefaultBreakpoints\n> {\n /** Current container width */\n width: number;\n /** Breakpoint definitions (name → min-width) */\n breakpoints?: Breakpoints<B>;\n /** Column counts per breakpoint */\n cols?: Breakpoints<B>;\n /** Layouts for each breakpoint */\n layouts?: ResponsiveLayouts<B>;\n /** Compactor for layout compaction (default: verticalCompactor) */\n compactor?: Compactor;\n /** Called when breakpoint changes */\n onBreakpointChange?: (newBreakpoint: B, cols: number) => void;\n /** Called when layout changes */\n onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;\n /** Called when width changes */\n onWidthChange?: (\n width: number,\n margin: readonly [number, number],\n cols: number,\n containerPadding: readonly [number, number] | null\n ) => void;\n}\n\nexport interface UseResponsiveLayoutResult<\n B extends Breakpoint = DefaultBreakpoints\n> {\n /** Current layout for the active breakpoint */\n layout: Layout;\n /** All layouts by breakpoint */\n layouts: ResponsiveLayouts<B>;\n /** Current active breakpoint */\n breakpoint: B;\n /** Column count for the current breakpoint */\n cols: number;\n /** Update layouts for a specific breakpoint */\n setLayoutForBreakpoint: (breakpoint: B, layout: Layout) => void;\n /** Update all layouts */\n setLayouts: (layouts: ResponsiveLayouts<B>) => void;\n /** Sorted array of breakpoint names (smallest to largest) */\n sortedBreakpoints: B[];\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for managing responsive grid layouts.\n *\n * Automatically selects the appropriate layout based on container width\n * and generates layouts for new breakpoints from existing ones.\n *\n * @example\n * ```tsx\n * function MyResponsiveGrid() {\n * const { width, containerRef } = useContainerWidth();\n * const { layout, breakpoint, cols } = useResponsiveLayout({\n * width,\n * layouts: {\n * lg: [...],\n * md: [...],\n * sm: [...]\n * }\n * });\n *\n * return (\n * <div ref={containerRef}>\n * <GridLayout\n * width={width}\n * cols={cols}\n * layout={layout}\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function useResponsiveLayout<B extends Breakpoint = DefaultBreakpoints>(\n options: UseResponsiveLayoutOptions<B>\n): UseResponsiveLayoutResult<B> {\n const {\n width,\n breakpoints = DEFAULT_BREAKPOINTS as unknown as Breakpoints<B>,\n cols: colsConfig = DEFAULT_COLS as unknown as Breakpoints<B>,\n layouts: propsLayouts = {} as ResponsiveLayouts<B>,\n compactor = verticalCompactor,\n onBreakpointChange,\n onLayoutChange,\n onWidthChange\n } = options;\n\n // Sorted breakpoints for consistent ordering\n const sortedBreakpoints = useMemo(\n () => sortBreakpoints(breakpoints),\n [breakpoints]\n );\n\n // Calculate initial breakpoint and cols\n const initialBreakpoint = useMemo(\n () => getBreakpointFromWidth(breakpoints, width),\n // Only calculate on mount, not on width changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const initialCols = useMemo(\n () => getColsFromBreakpoint(initialBreakpoint, colsConfig),\n [initialBreakpoint, colsConfig]\n );\n\n // State\n const [breakpoint, setBreakpoint] = useState<B>(initialBreakpoint);\n const [cols, setCols] = useState<number>(initialCols);\n const [layouts, setLayoutsState] = useState<ResponsiveLayouts<B>>(() => {\n // Clone initial layouts\n const cloned = {} as ResponsiveLayouts<B>;\n for (const bp of sortedBreakpoints) {\n const layout = propsLayouts[bp];\n if (layout) {\n (cloned as Record<B, Layout>)[bp] = cloneLayout(layout);\n }\n }\n return cloned;\n });\n\n // Track previous values for change detection\n const prevWidthRef = useRef(width);\n const prevBreakpointRef = useRef(breakpoint);\n // Separate refs for props vs state to prevent infinite loops (#2202)\n // When using inline objects for layouts prop, we need to compare props to props\n // and state to state, not mix them up.\n const prevPropsLayoutsRef = useRef(propsLayouts);\n const prevLayoutsRef = useRef(layouts);\n\n // Current layout for the active breakpoint - use compactor (#2213)\n const layout = useMemo(() => {\n return findOrGenerateResponsiveLayout(\n layouts,\n breakpoints,\n breakpoint,\n prevBreakpointRef.current,\n cols,\n compactor\n );\n }, [layouts, breakpoints, breakpoint, cols, compactor]);\n\n // Set layout for a specific breakpoint\n const setLayoutForBreakpoint = useCallback((bp: B, newLayout: Layout) => {\n setLayoutsState((prev: ResponsiveLayouts<B>) => ({\n ...prev,\n [bp]: cloneLayout(newLayout)\n }));\n }, []);\n\n // Set all layouts\n const setLayouts = useCallback((newLayouts: ResponsiveLayouts<B>) => {\n const cloned = {} as ResponsiveLayouts<B>;\n for (const bp of Object.keys(newLayouts) as B[]) {\n const layoutForBp = newLayouts[bp];\n if (layoutForBp) {\n (cloned as Record<B, Layout>)[bp] = cloneLayout(layoutForBp);\n }\n }\n setLayoutsState(cloned);\n }, []);\n\n // Handle width changes\n useEffect(() => {\n if (prevWidthRef.current === width) return;\n prevWidthRef.current = width;\n\n // Determine new breakpoint\n const newBreakpoint = getBreakpointFromWidth(breakpoints, width);\n const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);\n\n // Notify width change\n onWidthChange?.(width, [10, 10], newCols, null);\n\n // Check if breakpoint changed\n if (newBreakpoint !== breakpoint) {\n // Generate layout for new breakpoint\n // Use compactor (#2213)\n const newLayout = findOrGenerateResponsiveLayout(\n layouts,\n breakpoints,\n newBreakpoint,\n breakpoint,\n newCols,\n compactor\n );\n\n // Update layouts with the new breakpoint layout\n const updatedLayouts: ResponsiveLayouts<B> = {\n ...layouts,\n [newBreakpoint]: newLayout\n };\n\n setLayoutsState(updatedLayouts);\n setBreakpoint(newBreakpoint);\n setCols(newCols);\n\n // Notify breakpoint change\n onBreakpointChange?.(newBreakpoint, newCols);\n\n prevBreakpointRef.current = newBreakpoint;\n }\n }, [\n width,\n breakpoints,\n colsConfig,\n breakpoint,\n layouts,\n compactor,\n onBreakpointChange,\n onWidthChange\n ]);\n\n // Sync with prop layouts when they change\n useEffect(() => {\n if (!deepEqual(propsLayouts, prevPropsLayoutsRef.current)) {\n setLayouts(propsLayouts);\n prevPropsLayoutsRef.current = propsLayouts;\n }\n }, [propsLayouts, setLayouts]);\n\n // Notify layout changes\n useEffect(() => {\n if (!deepEqual(layouts, prevLayoutsRef.current)) {\n prevLayoutsRef.current = layouts;\n onLayoutChange?.(layout, layouts);\n }\n }, [layout, layouts, onLayoutChange]);\n\n return {\n layout,\n layouts,\n breakpoint,\n cols,\n setLayoutForBreakpoint,\n setLayouts,\n sortedBreakpoints\n };\n}\n\nexport default useResponsiveLayout;\n"]}
import { defaultConstraints, setTransform, setTopLeft, perc, applyPositionConstraints, resizeItemInDirection, applySizeConstraints, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout, getIndentationValue } from './chunk-XYPIYYYQ.mjs';
import { calcXYRaw, calcGridItemWHPx, clamp, calcGridColWidth, calcWHRaw, calcGridItemPosition, bottom, getLayoutItem, cloneLayoutItem, moveElement, withLayoutItem, getAllCollisions, calcXY, cloneLayout, correctBounds } from './chunk-AWM66AWF.mjs';
import React2, { useState, useRef, useMemo, useCallback, useEffect } from 'react';
import { DraggableCore } from 'react-draggable';
import { Resizable } from 'react-resizable';
import clsx from 'clsx';
import { jsx, jsxs } from 'react/jsx-runtime';
import { deepEqual } from 'fast-equals';
function GridItem(props) {
const {
children,
cols,
containerWidth,
margin,
containerPadding,
rowHeight,
maxRows,
isDraggable,
isResizable,
isBounded,
static: isStatic,
useCSSTransforms = true,
usePercentages = false,
transformScale = 1,
positionStrategy,
dragThreshold = 0,
droppingPosition,
className = "",
style,
handle = "",
cancel = "",
x,
y,
w,
h,
minW = 1,
maxW = Infinity,
minH = 1,
maxH = Infinity,
i,
resizeHandles,
resizeHandle,
constraints = defaultConstraints,
layoutItem,
layout = [],
onDragStart: onDragStartProp,
onDrag: onDragProp,
onDragStop: onDragStopProp,
onResizeStart: onResizeStartProp,
onResize: onResizeProp,
onResizeStop: onResizeStopProp
} = props;
const [dragging, setDragging] = useState(false);
const [resizing, setResizing] = useState(false);
const elementRef = useRef(null);
const dragPositionRef = useRef({ left: 0, top: 0 });
const resizePositionRef = useRef({
top: 0,
left: 0,
width: 0,
height: 0
});
const prevDroppingPositionRef = useRef(
void 0
);
const layoutRef = useRef(layout);
layoutRef.current = layout;
const onDragStartRef = useRef(null);
const onDragRef = useRef(null);
const dragPendingRef = useRef(false);
const initialDragClientRef = useRef({ x: 0, y: 0 });
const thresholdExceededRef = useRef(false);
const positionParams = useMemo(
() => ({
cols,
containerPadding,
containerWidth,
margin,
maxRows,
rowHeight
}),
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
);
const constraintContext = useMemo(
() => ({
cols,
maxRows,
containerWidth,
containerHeight: 0,
// Auto-height grids don't have a fixed container height
rowHeight,
margin,
// Use empty layout here - the actual layout will be accessed via layoutRef when needed
// This prevents the context from changing when layout changes, avoiding callback recreation
layout: []
}),
[cols, maxRows, containerWidth, rowHeight, margin]
);
const getConstraintContext = useCallback(
() => ({
...constraintContext,
layout: layoutRef.current
}),
[constraintContext]
);
const effectiveLayoutItem = useMemo(
() => layoutItem ?? {
i,
x,
y,
w,
h,
minW,
maxW,
minH,
maxH
},
[layoutItem, i, x, y, w, h, minW, maxW, minH, maxH]
);
const createStyle = useCallback(
(pos2) => {
if (positionStrategy?.calcStyle) {
return positionStrategy.calcStyle(pos2);
}
if (useCSSTransforms) {
return setTransform(pos2);
}
const styleObj = setTopLeft(pos2);
if (usePercentages) {
return {
...styleObj,
left: perc(pos2.left / containerWidth),
width: perc(pos2.width / containerWidth)
};
}
return styleObj;
},
[positionStrategy, useCSSTransforms, usePercentages, containerWidth]
);
const onDragStart = useCallback(
(e, { node }) => {
if (!onDragStartProp) return;
const { offsetParent } = node;
if (!offsetParent) return;
const parentRect = offsetParent.getBoundingClientRect();
const clientRect = node.getBoundingClientRect();
const cLeft = clientRect.left / transformScale;
const pLeft = parentRect.left / transformScale;
const cTop = clientRect.top / transformScale;
const pTop = parentRect.top / transformScale;
let newPosition;
if (positionStrategy?.calcDragPosition) {
const mouseEvent = e;
newPosition = positionStrategy.calcDragPosition(
mouseEvent.clientX,
mouseEvent.clientY,
mouseEvent.clientX - clientRect.left,
mouseEvent.clientY - clientRect.top
);
} else {
newPosition = {
left: cLeft - pLeft + offsetParent.scrollLeft,
top: cTop - pTop + offsetParent.scrollTop
};
}
dragPositionRef.current = newPosition;
if (dragThreshold > 0) {
const mouseEvent = e;
initialDragClientRef.current = {
x: mouseEvent.clientX,
y: mouseEvent.clientY
};
dragPendingRef.current = true;
thresholdExceededRef.current = false;
setDragging(true);
return;
}
setDragging(true);
const rawPos = calcXYRaw(
positionParams,
newPosition.top,
newPosition.left
);
const { x: newX, y: newY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStartProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStartProp,
transformScale,
positionParams,
positionStrategy,
dragThreshold,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
const onDrag = useCallback(
(e, { node, deltaX, deltaY }) => {
if (!onDragProp || !dragging) return;
const mouseEvent = e;
if (dragPendingRef.current && !thresholdExceededRef.current) {
const dx = mouseEvent.clientX - initialDragClientRef.current.x;
const dy = mouseEvent.clientY - initialDragClientRef.current.y;
const distance = Math.hypot(dx, dy);
if (distance < dragThreshold) {
return;
}
thresholdExceededRef.current = true;
dragPendingRef.current = false;
if (onDragStartProp) {
const rawPos2 = calcXYRaw(
positionParams,
dragPositionRef.current.top,
dragPositionRef.current.left
);
const { x: startX, y: startY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos2.x,
rawPos2.y,
getConstraintContext()
);
onDragStartProp(i, startX, startY, {
e,
node,
newPosition: dragPositionRef.current
});
}
}
let top = dragPositionRef.current.top + deltaY;
let left = dragPositionRef.current.left + deltaX;
if (isBounded) {
const { offsetParent } = node;
if (offsetParent) {
const bottomBoundary = offsetParent.clientHeight - calcGridItemWHPx(h, rowHeight, margin[1]);
top = clamp(top, 0, bottomBoundary);
const colWidth = calcGridColWidth(positionParams);
const rightBoundary = containerWidth - calcGridItemWHPx(w, colWidth, margin[0]);
left = clamp(left, 0, rightBoundary);
}
}
const newPosition = { top, left };
dragPositionRef.current = newPosition;
const rawPos = calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragProp,
onDragStartProp,
dragging,
dragThreshold,
isBounded,
h,
rowHeight,
margin,
positionParams,
containerWidth,
w,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const onDragStop = useCallback(
(e, { node }) => {
if (!onDragStopProp || !dragging) return;
const wasPending = dragPendingRef.current;
dragPendingRef.current = false;
thresholdExceededRef.current = false;
initialDragClientRef.current = { x: 0, y: 0 };
if (wasPending) {
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
return;
}
const { left, top } = dragPositionRef.current;
const newPosition = { top, left };
setDragging(false);
dragPositionRef.current = { left: 0, top: 0 };
const rawPos = calcXYRaw(positionParams, top, left);
const { x: newX, y: newY } = applyPositionConstraints(
constraints,
effectiveLayoutItem,
rawPos.x,
rawPos.y,
getConstraintContext()
);
onDragStopProp(i, newX, newY, {
e,
node,
newPosition
});
},
[
onDragStopProp,
dragging,
positionParams,
constraints,
effectiveLayoutItem,
getConstraintContext,
i
]
);
onDragStartRef.current = onDragStart;
onDragRef.current = onDrag;
const onResizeHandler = useCallback(
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
if (!handler) return;
let updatedSize;
if (node) {
updatedSize = resizeItemInDirection(
resizeHandle2,
position,
size,
containerWidth
);
} else {
updatedSize = {
...size,
top: position.top,
left: position.left
};
}
resizePositionRef.current = updatedSize;
const rawSize = calcWHRaw(
positionParams,
updatedSize.width,
updatedSize.height
);
const { w: newW, h: newH } = applySizeConstraints(
constraints,
effectiveLayoutItem,
rawSize.w,
rawSize.h,
resizeHandle2,
getConstraintContext()
);
handler(i, newW, newH, {
e: e.nativeEvent,
node,
size: updatedSize,
handle: resizeHandle2
});
},
[
onResizeStartProp,
onResizeProp,
onResizeStopProp,
containerWidth,
positionParams,
i,
constraints,
effectiveLayoutItem,
getConstraintContext
]
);
const handleResizeStart = useCallback(
(e, data) => {
setResizing(true);
const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStart");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResize = useCallback(
(e, data) => {
const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResize");
},
[onResizeHandler, positionParams, x, y, w, h]
);
const handleResizeStop = useCallback(
(e, data) => {
setResizing(false);
resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
const pos2 = calcGridItemPosition(positionParams, x, y, w, h);
const typedData = {
...data,
handle: data.handle
};
onResizeHandler(e, typedData, pos2, "onResizeStop");
},
[onResizeHandler, positionParams, x, y, w, h]
);
useEffect(() => {
if (!droppingPosition) return;
const node = elementRef.current;
if (!node) return;
const prevDroppingPosition = prevDroppingPositionRef.current || {
left: 0,
top: 0
};
const shouldDrag = dragging && (droppingPosition.left !== prevDroppingPosition.left || droppingPosition.top !== prevDroppingPosition.top);
if (!dragging) {
const fakeData = {
node,
deltaX: droppingPosition.left,
deltaY: droppingPosition.top,
lastX: 0,
lastY: 0,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragStartRef.current?.(
droppingPosition.e,
fakeData
);
} else if (shouldDrag) {
const deltaX = droppingPosition.left - dragPositionRef.current.left;
const deltaY = droppingPosition.top - dragPositionRef.current.top;
const fakeData = {
node,
deltaX,
deltaY,
lastX: dragPositionRef.current.left,
lastY: dragPositionRef.current.top,
x: droppingPosition.left,
y: droppingPosition.top
};
onDragRef.current?.(
droppingPosition.e,
fakeData
);
}
prevDroppingPositionRef.current = droppingPosition;
}, [droppingPosition, dragging, i]);
const pos = calcGridItemPosition(
positionParams,
x,
y,
w,
h,
dragging ? dragPositionRef.current : null,
resizing ? resizePositionRef.current : null
);
const child = React2.Children.only(children);
const minGridUnit = calcGridItemPosition(positionParams, 0, 0, 1, 1);
const minConstraints = [
minGridUnit.width,
minGridUnit.height
];
const maxConstraints = [Infinity, Infinity];
const childProps = child.props;
const childClassName = childProps["className"];
const childStyle = childProps["style"];
let newChild = React2.cloneElement(child, {
ref: elementRef,
className: clsx("react-grid-item", childClassName, className, {
static: isStatic,
resizing,
"react-draggable": isDraggable,
"react-draggable-dragging": dragging,
dropping: Boolean(droppingPosition),
cssTransforms: useCSSTransforms
}),
style: {
...style,
...childStyle,
...createStyle(pos)
}
});
const resizableHandle = resizeHandle;
newChild = /* @__PURE__ */ jsx(
Resizable,
{
draggableOpts: { disabled: !isResizable },
className: isResizable ? void 0 : "react-resizable-hide",
width: pos.width,
height: pos.height,
minConstraints,
maxConstraints,
onResizeStart: handleResizeStart,
onResize: handleResize,
onResizeStop: handleResizeStop,
transformScale,
resizeHandles,
handle: resizableHandle,
children: newChild
}
);
newChild = /* @__PURE__ */ jsx(
DraggableCore,
{
disabled: !isDraggable,
onStart: onDragStart,
onDrag,
onStop: onDragStop,
handle,
cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
scale: transformScale,
nodeRef: elementRef,
children: newChild
}
);
return newChild;
}
var noop = () => {
};
var layoutClassName = "react-grid-layout";
var isFirefox = false;
try {
isFirefox = /firefox/i.test(navigator.userAgent);
} catch {
}
function childrenEqual(a, b) {
const aArr = React2.Children.toArray(a);
const bArr = React2.Children.toArray(b);
if (aArr.length !== bArr.length) return false;
for (let i = 0; i < aArr.length; i++) {
const aChild = aArr[i];
const bChild = bArr[i];
if (aChild?.key !== bChild?.key) return false;
}
return true;
}
function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
const layout = [];
const childKeys = /* @__PURE__ */ new Set();
React2.Children.forEach(children, (child) => {
if (!React2.isValidElement(child) || child.key === null) return;
const key = String(child.key);
childKeys.add(key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push(cloneLayoutItem(existingItem));
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function GridLayout(props) {
const {
// Required
children,
width,
// Composable config interfaces
gridConfig: gridConfigProp,
dragConfig: dragConfigProp,
resizeConfig: resizeConfigProp,
dropConfig: dropConfigProp,
positionStrategy = defaultPositionStrategy,
compactor: compactorProp,
constraints = defaultConstraints,
// Layout data
layout: propsLayout = [],
droppingItem: droppingItemProp,
// Container props
autoSize = true,
className = "",
style = {},
innerRef,
// Callbacks
onLayoutChange = noop,
onDragStart: onDragStartProp = noop,
onDrag: onDragProp = noop,
onDragStop: onDragStopProp = noop,
onResizeStart: onResizeStartProp = noop,
onResize: onResizeProp = noop,
onResizeStop: onResizeStopProp = noop,
onDrop: onDropProp = noop,
onDropDragOver: onDropDragOverProp = noop
} = props;
const gridConfig = useMemo(
() => ({ ...defaultGridConfig, ...gridConfigProp }),
[gridConfigProp]
);
const dragConfig = useMemo(
() => ({ ...defaultDragConfig, ...dragConfigProp }),
[dragConfigProp]
);
const resizeConfig = useMemo(
() => ({ ...defaultResizeConfig, ...resizeConfigProp }),
[resizeConfigProp]
);
const dropConfig = useMemo(
() => ({ ...defaultDropConfig, ...dropConfigProp }),
[dropConfigProp]
);
const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
const {
enabled: isDraggable,
bounded: isBounded,
handle: draggableHandle,
cancel: draggableCancel,
threshold: dragThreshold
} = dragConfig;
const {
enabled: isResizable,
handles: resizeHandles,
handleComponent: resizeHandle
} = resizeConfig;
const {
enabled: isDroppable,
defaultItem: defaultDropItem,
onDragOver: dropConfigOnDragOver
} = dropConfig;
const compactor = compactorProp ?? getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const preventCollision = compactor.preventCollision ?? false;
const droppingItem = useMemo(
() => droppingItemProp ?? {
i: "__dropping-elem__",
...defaultDropItem
},
[droppingItemProp, defaultDropItem]
);
const useCSSTransforms = positionStrategy.type === "transform";
const transformScale = positionStrategy.scale;
const effectiveContainerPadding = containerPadding ?? margin;
const [mounted, setMounted] = useState(false);
const [layout, setLayout] = useState(
() => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor)
);
const [activeDrag, setActiveDrag] = useState(null);
const [resizing, setResizing] = useState(false);
const [droppingDOMNode, setDroppingDOMNode] = useState(
null
);
const [droppingPosition, setDroppingPosition] = useState();
const oldDragItemRef = useRef(null);
const oldResizeItemRef = useRef(null);
const oldLayoutRef = useRef(null);
const dragEnterCounterRef = useRef(0);
const prevLayoutRef = useRef(layout);
const prevPropsLayoutRef = useRef(propsLayout);
const prevChildrenRef = useRef(children);
const prevCompactTypeRef = useRef(compactType);
const layoutRef = useRef(layout);
layoutRef.current = layout;
useEffect(() => {
setMounted(true);
if (!deepEqual(layout, propsLayout)) {
onLayoutChange(layout);
}
}, []);
useEffect(() => {
if (activeDrag) return;
if (droppingDOMNode) return;
const layoutChanged = !deepEqual(propsLayout, prevPropsLayoutRef.current);
const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
const compactTypeChanged = compactType !== prevCompactTypeRef.current;
if (layoutChanged || childrenChanged || compactTypeChanged) {
const baseLayout = layoutChanged ? propsLayout : layout;
const newLayout = synchronizeLayoutWithChildren(
baseLayout,
children,
cols,
compactor
);
if (!deepEqual(newLayout, layout)) {
setLayout(newLayout);
}
}
prevPropsLayoutRef.current = propsLayout;
prevChildrenRef.current = children;
prevCompactTypeRef.current = compactType;
}, [
propsLayout,
children,
cols,
compactType,
compactor,
activeDrag,
droppingDOMNode,
layout
]);
useEffect(() => {
if (!activeDrag && !deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
const publicLayout = layout.filter((l) => l.i !== droppingItem.i);
onLayoutChange(publicLayout);
}
}, [layout, activeDrag, onLayoutChange, droppingItem.i]);
const containerHeight = useMemo(() => {
if (!autoSize) return void 0;
const nbRow = bottom(layout);
const containerPaddingY = effectiveContainerPadding[1];
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
}, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
const onDragStart = useCallback(
(i, _x, _y, data) => {
const currentLayout = layoutRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
oldDragItemRef.current = cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setActiveDrag(placeholder);
onDragStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onDragStartProp]
);
const onDrag = useCallback(
(i, x, y, data) => {
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i
};
const newLayout = moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
setLayout(compactor.compact(newLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
);
const onDragStop = useCallback(
(i, x, y, data) => {
if (!activeDrag) return;
const currentLayout = layoutRef.current;
const oldDragItem = oldDragItemRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
const newLayout = moveElement(
currentLayout,
l,
x,
y,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
const finalLayout = compactor.compact(newLayout, cols);
onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
const oldLayout = oldLayoutRef.current;
oldDragItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setLayout(finalLayout);
if (oldLayout && !deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[
activeDrag,
preventCollision,
compactType,
cols,
allowOverlap,
compactor,
onDragStopProp,
onLayoutChange
]
);
const onResizeStart = useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const l = getLayoutItem(currentLayout, i);
if (!l) return;
oldResizeItemRef.current = cloneLayoutItem(l);
oldLayoutRef.current = currentLayout;
setResizing(true);
onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
},
[onResizeStartProp]
);
const onResize = useCallback(
(i, w, h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const { handle } = data;
let shouldMoveItem = false;
let newX;
let newY;
const [newLayout, l] = withLayoutItem(currentLayout, i, (item) => {
newX = item.x;
newY = item.y;
if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
if (["sw", "nw", "w"].includes(handle)) {
newX = item.x + (item.w - w);
w = item.x !== newX && newX < 0 ? item.w : w;
newX = newX < 0 ? 0 : newX;
}
if (["ne", "n", "nw"].includes(handle)) {
newY = item.y + (item.h - h);
h = item.y !== newY && newY < 0 ? item.h : h;
newY = newY < 0 ? 0 : newY;
}
shouldMoveItem = true;
}
if (preventCollision && !allowOverlap) {
const collisions = getAllCollisions(currentLayout, {
...item,
w,
h,
x: newX ?? item.x,
y: newY ?? item.y
}).filter((layoutItem) => layoutItem.i !== item.i);
if (collisions.length > 0) {
newY = item.y;
h = item.h;
newX = item.x;
w = item.w;
shouldMoveItem = false;
}
}
item.w = w;
item.h = h;
return item;
});
if (!l) return;
let finalLayout = newLayout;
if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
finalLayout = moveElement(
newLayout,
l,
newX,
newY,
true,
preventCollision,
compactType,
cols,
allowOverlap
);
}
const placeholder = {
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i,
static: true
};
onResizeProp(
finalLayout,
oldResizeItem,
l,
placeholder,
data.e,
data.node
);
setLayout(compactor.compact(finalLayout, cols));
setActiveDrag(placeholder);
},
[preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
);
const onResizeStop = useCallback(
(i, _w, _h, data) => {
const currentLayout = layoutRef.current;
const oldResizeItem = oldResizeItemRef.current;
const l = getLayoutItem(currentLayout, i);
const finalLayout = compactor.compact(currentLayout, cols);
onResizeStopProp(
finalLayout,
oldResizeItem,
l ?? null,
null,
data.e,
data.node
);
const oldLayout = oldLayoutRef.current;
oldResizeItemRef.current = null;
oldLayoutRef.current = null;
setActiveDrag(null);
setResizing(false);
setLayout(finalLayout);
if (oldLayout && !deepEqual(oldLayout, finalLayout)) {
onLayoutChange(finalLayout);
}
},
[cols, compactor, onResizeStopProp, onLayoutChange]
);
const removeDroppingPlaceholder = useCallback(() => {
const currentLayout = layoutRef.current;
const hasDroppingItem = currentLayout.some((l) => l.i === droppingItem.i);
if (!hasDroppingItem) {
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
return;
}
const newLayout = compactor.compact(
currentLayout.filter((l) => l.i !== droppingItem.i),
cols
);
setLayout(newLayout);
setDroppingDOMNode(null);
setActiveDrag(null);
setDroppingPosition(void 0);
}, [droppingItem.i, cols, compactor]);
const handleDragOver = useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
if (isFirefox && !e.nativeEvent.target?.classList.contains(
layoutClassName
)) {
return false;
}
const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
if (rawResult === false) {
if (droppingDOMNode) {
removeDroppingPlaceholder();
}
return false;
}
const {
dragOffsetX = 0,
dragOffsetY = 0,
...onDragOverResult
} = rawResult ?? {};
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
const gridRect = e.currentTarget.getBoundingClientRect();
const positionParams = {
cols,
margin,
maxRows,
rowHeight,
containerWidth: width,
containerPadding: effectiveContainerPadding
};
const actualColWidth = calcGridColWidth(positionParams);
const itemPixelWidth = calcGridItemWHPx(
finalDroppingItem.w,
actualColWidth,
margin[0]
);
const itemPixelHeight = calcGridItemWHPx(
finalDroppingItem.h,
rowHeight,
margin[1]
);
const itemCenterOffsetX = itemPixelWidth / 2;
const itemCenterOffsetY = itemPixelHeight / 2;
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
const clampedGridX = Math.max(0, rawGridX);
const clampedGridY = Math.max(0, rawGridY);
const newDroppingPosition = {
left: clampedGridX / transformScale,
top: clampedGridY / transformScale,
e: e.nativeEvent
};
if (!droppingDOMNode) {
const calculatedPosition = calcXY(
positionParams,
clampedGridY,
clampedGridX,
finalDroppingItem.w,
finalDroppingItem.h
);
setDroppingDOMNode(/* @__PURE__ */ jsx("div", {}, finalDroppingItem.i));
setDroppingPosition(newDroppingPosition);
setLayout([
...layoutRef.current,
{
...finalDroppingItem,
x: calculatedPosition.x,
y: calculatedPosition.y,
static: false,
isDraggable: true
}
]);
} else if (droppingPosition) {
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
if (shouldUpdate) {
setDroppingPosition(newDroppingPosition);
}
}
},
[
droppingDOMNode,
droppingPosition,
droppingItem,
dropConfigOnDragOver,
onDropDragOverProp,
removeDroppingPlaceholder,
transformScale,
cols,
margin,
maxRows,
rowHeight,
width,
effectiveContainerPadding
]
);
const handleDragLeave = useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current--;
if (dragEnterCounterRef.current < 0) {
dragEnterCounterRef.current = 0;
}
if (dragEnterCounterRef.current === 0) {
removeDroppingPlaceholder();
}
},
[removeDroppingPlaceholder]
);
const handleDragEnter = useCallback((e) => {
e.preventDefault();
e.stopPropagation();
dragEnterCounterRef.current++;
}, []);
const handleDrop = useCallback(
(e) => {
e.preventDefault();
e.stopPropagation();
const currentLayout = layoutRef.current;
const item = currentLayout.find((l) => l.i === droppingItem.i);
dragEnterCounterRef.current = 0;
removeDroppingPlaceholder();
onDropProp(currentLayout, item, e.nativeEvent);
},
[droppingItem.i, removeDroppingPlaceholder, onDropProp]
);
const processGridItem = useCallback(
(child, isDroppingItem) => {
if (!child || !child.key) return null;
const l = getLayoutItem(layout, String(child.key));
if (!l) return null;
const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
const resizeHandlesOptions = l.resizeHandles || [...resizeHandles];
const bounded = draggable && isBounded && l.isBounded !== false;
const resizeHandleElement = resizeHandle;
return /* @__PURE__ */ jsx(
GridItem,
{
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
cancel: draggableCancel,
handle: draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable: draggable,
isResizable: resizable,
isBounded: bounded,
useCSSTransforms: useCSSTransforms && mounted,
usePercentages: !mounted,
transformScale,
positionStrategy,
dragThreshold,
w: l.w,
h: l.h,
x: l.x,
y: l.y,
i: l.i,
minH: l.minH,
minW: l.minW,
maxH: l.maxH,
maxW: l.maxW,
static: l.static,
droppingPosition: isDroppingItem ? droppingPosition : void 0,
resizeHandles: resizeHandlesOptions,
resizeHandle: resizeHandleElement,
constraints,
layoutItem: l,
layout,
children: child
},
l.i
);
},
[
layout,
width,
cols,
margin,
effectiveContainerPadding,
maxRows,
rowHeight,
draggableCancel,
draggableHandle,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
isDraggable,
isResizable,
isBounded,
useCSSTransforms,
mounted,
transformScale,
positionStrategy,
dragThreshold,
droppingPosition,
resizeHandles,
resizeHandle,
constraints
]
);
const renderPlaceholder = () => {
if (!activeDrag) return null;
return /* @__PURE__ */ jsx(
GridItem,
{
w: activeDrag.w,
h: activeDrag.h,
x: activeDrag.x,
y: activeDrag.y,
i: activeDrag.i,
className: `react-grid-placeholder ${resizing ? "placeholder-resizing" : ""}`,
containerWidth: width,
cols,
margin,
containerPadding: effectiveContainerPadding,
maxRows,
rowHeight,
isDraggable: false,
isResizable: false,
isBounded: false,
useCSSTransforms,
transformScale,
constraints,
layout,
children: /* @__PURE__ */ jsx("div", {})
}
);
};
const mergedClassName = clsx(layoutClassName, className);
const mergedStyle = {
height: containerHeight,
...style
};
return /* @__PURE__ */ jsxs(
"div",
{
ref: innerRef,
className: mergedClassName,
style: mergedStyle,
onDrop: isDroppable ? handleDrop : void 0,
onDragLeave: isDroppable ? handleDragLeave : void 0,
onDragEnter: isDroppable ? handleDragEnter : void 0,
onDragOver: isDroppable ? handleDragOver : void 0,
children: [
React2.Children.map(children, (child) => {
if (!React2.isValidElement(child)) return null;
return processGridItem(child);
}),
isDroppable && droppingDOMNode && processGridItem(droppingDOMNode, true),
renderPlaceholder()
]
}
);
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
var noop2 = () => {
};
function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor) {
const layout = [];
React2.Children.forEach(children, (child) => {
if (!React2.isValidElement(child) || child.key === null) return;
const key = String(child.key);
const existingItem = initialLayout.find((l) => l.i === key);
if (existingItem) {
layout.push({
...existingItem,
i: key
});
} else {
const childProps = child.props;
const dataGrid = childProps["data-grid"];
if (dataGrid) {
layout.push({
i: key,
x: dataGrid.x ?? 0,
y: dataGrid.y ?? 0,
w: dataGrid.w ?? 1,
h: dataGrid.h ?? 1,
minW: dataGrid.minW,
maxW: dataGrid.maxW,
minH: dataGrid.minH,
maxH: dataGrid.maxH,
static: dataGrid.static,
isDraggable: dataGrid.isDraggable,
isResizable: dataGrid.isResizable,
resizeHandles: dataGrid.resizeHandles,
isBounded: dataGrid.isBounded
});
} else {
layout.push({
i: key,
x: 0,
y: bottom(layout),
w: 1,
h: 1
});
}
}
});
const corrected = correctBounds(layout, { cols });
return compactor.compact(corrected, cols);
}
function ResponsiveGridLayout(props) {
const {
children,
width,
breakpoint: propBreakpoint,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
rowHeight = 150,
maxRows = Infinity,
margin: propMargin = [10, 10],
containerPadding: propContainerPadding = null,
compactor: compactorProp,
onBreakpointChange = noop2,
onLayoutChange = noop2,
onWidthChange = noop2,
...restProps
} = props;
const compactor = compactorProp ?? getCompactor("vertical");
const compactType = compactor.type;
const allowOverlap = compactor.allowOverlap;
const initialBreakpoint = useMemo(() => {
return propBreakpoint ?? getBreakpointFromWidth(breakpoints, width);
}, []);
const initialCols = useMemo(() => {
return getColsFromBreakpoint(initialBreakpoint, colsConfig);
}, [initialBreakpoint, colsConfig]);
const initialLayout = useMemo(() => {
return findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
initialBreakpoint,
initialBreakpoint,
initialCols,
compactType
);
}, []);
const [breakpoint, setBreakpoint] = useState(initialBreakpoint);
const [cols, setCols] = useState(initialCols);
const [layout, setLayout] = useState(initialLayout);
const [layouts, setLayouts] = useState(propsLayouts);
const prevWidthRef = useRef(width);
const prevBreakpointRef = useRef(propBreakpoint);
const prevBreakpointsRef = useRef(breakpoints);
const prevColsRef = useRef(colsConfig);
const prevLayoutsRef = useRef(propsLayouts);
const prevCompactTypeRef = useRef(compactType);
const layoutsRef = useRef(layouts);
useEffect(() => {
layoutsRef.current = layouts;
}, [layouts]);
const derivedLayout = useMemo(() => {
if (!deepEqual(propsLayouts, prevLayoutsRef.current)) {
return findOrGenerateResponsiveLayout(
propsLayouts,
breakpoints,
breakpoint,
breakpoint,
cols,
compactor
);
}
return null;
}, [propsLayouts, breakpoints, breakpoint, cols, compactor]);
const effectiveLayout = derivedLayout ?? layout;
useEffect(() => {
if (derivedLayout !== null) {
setLayout(derivedLayout);
setLayouts(propsLayouts);
layoutsRef.current = propsLayouts;
prevLayoutsRef.current = propsLayouts;
}
}, [derivedLayout, propsLayouts]);
useEffect(() => {
if (compactType !== prevCompactTypeRef.current) {
const newLayout = compactor.compact(cloneLayout(effectiveLayout), cols);
const newLayouts = {
...layoutsRef.current,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
prevCompactTypeRef.current = compactType;
}
}, [
compactType,
compactor,
effectiveLayout,
cols,
allowOverlap,
breakpoint,
onLayoutChange
]);
useEffect(() => {
const widthChanged = width !== prevWidthRef.current;
const breakpointPropChanged = propBreakpoint !== prevBreakpointRef.current;
const breakpointsChanged = !deepEqual(
breakpoints,
prevBreakpointsRef.current
);
const colsChanged = !deepEqual(colsConfig, prevColsRef.current);
if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
const newBreakpoint = propBreakpoint ?? getBreakpointFromWidth(breakpoints, width);
const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);
const lastBreakpoint = breakpoint;
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
const newLayouts = { ...layoutsRef.current };
if (!newLayouts[lastBreakpoint]) {
newLayouts[lastBreakpoint] = cloneLayout(layout);
}
let newLayout = findOrGenerateResponsiveLayout(
newLayouts,
breakpoints,
newBreakpoint,
lastBreakpoint,
newCols,
compactor
);
newLayout = synchronizeLayoutWithChildren2(
newLayout,
children,
newCols,
compactor
);
newLayouts[newBreakpoint] = newLayout;
setBreakpoint(newBreakpoint);
setCols(newCols);
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onBreakpointChange(newBreakpoint, newCols);
onLayoutChange(newLayout, newLayouts);
}
const currentMargin2 = getIndentationValue(
propMargin,
newBreakpoint
);
const currentPadding = propContainerPadding ? getIndentationValue(
propContainerPadding,
newBreakpoint
) : null;
onWidthChange(width, currentMargin2, newCols, currentPadding);
prevWidthRef.current = width;
prevBreakpointRef.current = propBreakpoint;
prevBreakpointsRef.current = breakpoints;
prevColsRef.current = colsConfig;
}
}, [
width,
propBreakpoint,
breakpoints,
colsConfig,
breakpoint,
cols,
layout,
children,
compactor,
compactType,
allowOverlap,
propMargin,
propContainerPadding,
onBreakpointChange,
onLayoutChange,
onWidthChange
]);
const handleLayoutChange = useCallback(
(newLayout) => {
const currentLayouts = layoutsRef.current;
const newLayouts = {
...currentLayouts,
[breakpoint]: newLayout
};
setLayout(newLayout);
setLayouts(newLayouts);
layoutsRef.current = newLayouts;
onLayoutChange(newLayout, newLayouts);
},
[breakpoint, onLayoutChange]
);
const currentMargin = useMemo(() => {
return getIndentationValue(
propMargin,
breakpoint
);
}, [propMargin, breakpoint]);
const currentContainerPadding = useMemo(() => {
if (propContainerPadding === null) return null;
return getIndentationValue(
propContainerPadding,
breakpoint
);
}, [propContainerPadding, breakpoint]);
const gridConfig = useMemo(
() => ({
cols,
rowHeight,
maxRows,
margin: currentMargin,
containerPadding: currentContainerPadding
}),
[cols, rowHeight, maxRows, currentMargin, currentContainerPadding]
);
return /* @__PURE__ */ jsx(
GridLayout,
{
...restProps,
width,
gridConfig,
compactor,
onLayoutChange: handleLayoutChange,
layout: effectiveLayout,
children
}
);
}
export { GridItem, GridLayout, ResponsiveGridLayout };
//# sourceMappingURL=chunk-XM2M6TC6.mjs.map
//# sourceMappingURL=chunk-XM2M6TC6.mjs.map

Sorry, the diff of this file is too big to display

import { getStatics, collides, getFirstCollision, bottom, sortLayoutItemsByRowCol, cloneLayoutItem, sortLayoutItemsByColRow, cloneLayout, correctBounds } from './chunk-AWM66AWF.mjs';
// src/core/constraints.ts
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
var gridBounds = {
name: "gridBounds",
constrainPosition(item, x, y, { cols, maxRows }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
},
constrainSize(item, w, h, handle, { cols, maxRows }) {
const maxW = handle === "w" || handle === "nw" || handle === "sw" ? item.x + item.w : cols - item.x;
const maxH = handle === "n" || handle === "nw" || handle === "ne" ? item.y + item.h : maxRows - item.y;
return {
w: clamp(w, 1, Math.max(1, maxW)),
h: clamp(h, 1, Math.max(1, maxH))
};
}
};
var minMaxSize = {
name: "minMaxSize",
constrainSize(item, w, h) {
return {
w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),
h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)
};
}
};
var containerBounds = {
name: "containerBounds",
constrainPosition(item, x, y, { cols, maxRows, containerHeight, rowHeight, margin }) {
const visibleRows = containerHeight > 0 ? Math.floor((containerHeight + margin[1]) / (rowHeight + margin[1])) : maxRows;
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y: clamp(y, 0, Math.max(0, visibleRows - item.h))
};
}
};
var boundedX = {
name: "boundedX",
constrainPosition(item, x, y, { cols }) {
return {
x: clamp(x, 0, Math.max(0, cols - item.w)),
y
};
}
};
var boundedY = {
name: "boundedY",
constrainPosition(item, x, y, { maxRows }) {
return {
x,
y: clamp(y, 0, Math.max(0, maxRows - item.h))
};
}
};
function aspectRatio(ratio) {
return {
name: `aspectRatio(${ratio})`,
constrainSize(_item, w, _h, _handle, context) {
const { cols, containerWidth, rowHeight, margin } = context;
const colWidth = (containerWidth - margin[0] * (cols - 1)) / cols;
const pixelWidth = colWidth * w + margin[0] * Math.max(0, w - 1);
const pixelHeight = pixelWidth / ratio;
const h = Math.max(
1,
Math.round((pixelHeight + margin[1]) / (rowHeight + margin[1]))
);
return { w, h };
}
};
}
function snapToGrid(stepX, stepY = stepX) {
if (stepX <= 0 || stepY <= 0) {
throw new Error(
`snapToGrid: step values must be positive (got stepX=${stepX}, stepY=${stepY})`
);
}
return {
name: `snapToGrid(${stepX}, ${stepY})`,
constrainPosition(_item, x, y) {
return {
x: Math.round(x / stepX) * stepX,
y: Math.round(y / stepY) * stepY
};
}
};
}
function minSize(minW, minH) {
return {
name: `minSize(${minW}, ${minH})`,
constrainSize(_item, w, h) {
return {
w: Math.max(minW, w),
h: Math.max(minH, h)
};
}
};
}
function maxSize(maxW, maxH) {
return {
name: `maxSize(${maxW}, ${maxH})`,
constrainSize(_item, w, h) {
return {
w: Math.min(maxW, w),
h: Math.min(maxH, h)
};
}
};
}
var defaultConstraints = [gridBounds, minMaxSize];
function applyPositionConstraints(constraints, item, x, y, context) {
let result = { x, y };
for (const constraint of constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(item, result.x, result.y, context);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainPosition) {
result = constraint.constrainPosition(
item,
result.x,
result.y,
context
);
}
}
}
return result;
}
function applySizeConstraints(constraints, item, w, h, handle, context) {
let result = { w, h };
for (const constraint of constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
if (item.constraints) {
for (const constraint of item.constraints) {
if (constraint.constrainSize) {
result = constraint.constrainSize(
item,
result.w,
result.h,
handle,
context
);
}
}
}
return result;
}
// src/core/position.ts
function setTransform({
top,
left,
width,
height
}) {
const translate = `translate(${left}px,${top}px)`;
return {
transform: translate,
WebkitTransform: translate,
MozTransform: translate,
msTransform: translate,
OTransform: translate,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function setTopLeft({
top,
left,
width,
height
}) {
return {
top: `${top}px`,
left: `${left}px`,
width: `${width}px`,
height: `${height}px`,
position: "absolute"
};
}
function perc(num) {
return num * 100 + "%";
}
function constrainWidth(left, currentWidth, newWidth, containerWidth) {
return left + newWidth > containerWidth ? currentWidth : newWidth;
}
function constrainHeight(top, currentHeight, newHeight) {
return top < 0 ? currentHeight : newHeight;
}
function constrainLeft(left) {
return Math.max(0, left);
}
function constrainTop(top) {
return Math.max(0, top);
}
var resizeNorth = (currentSize, newSize, _containerWidth) => {
const { left, height, width } = newSize;
const top = currentSize.top - (height - currentSize.height);
return {
left,
width,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeEast = (currentSize, newSize, containerWidth) => {
const { top, left, height, width } = newSize;
return {
top,
height,
width: constrainWidth(
currentSize.left,
currentSize.width,
width,
containerWidth
),
left: constrainLeft(left)
};
};
var resizeWest = (currentSize, newSize, _containerWidth) => {
const { top, height, width } = newSize;
const left = currentSize.left + currentSize.width - width;
if (left < 0) {
return {
height,
width: currentSize.left + currentSize.width,
top: constrainTop(top),
left: 0
};
}
return {
height,
width,
top: constrainTop(top),
left
};
};
var resizeSouth = (currentSize, newSize, _containerWidth) => {
const { top, left, height, width } = newSize;
return {
width,
left,
height: constrainHeight(top, currentSize.height, height),
top: constrainTop(top)
};
};
var resizeNorthEast = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeNorthWest = (currentSize, newSize, containerWidth) => resizeNorth(
currentSize,
resizeWest(currentSize, newSize));
var resizeSouthEast = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeEast(currentSize, newSize, containerWidth));
var resizeSouthWest = (currentSize, newSize, containerWidth) => resizeSouth(
currentSize,
resizeWest(currentSize, newSize));
var resizeHandlerMap = {
n: resizeNorth,
ne: resizeNorthEast,
e: resizeEast,
se: resizeSouthEast,
s: resizeSouth,
sw: resizeSouthWest,
w: resizeWest,
nw: resizeNorthWest
};
function resizeItemInDirection(direction, currentSize, newSize, containerWidth) {
const handler = resizeHandlerMap[direction];
if (!handler) {
return newSize;
}
return handler(currentSize, { ...currentSize, ...newSize }, containerWidth);
}
var transformStrategy = {
type: "transform",
scale: 1,
calcStyle(pos) {
return setTransform(pos);
}
};
var absoluteStrategy = {
type: "absolute",
scale: 1,
calcStyle(pos) {
return setTopLeft(pos);
}
};
function createScaledStrategy(scale) {
return {
type: "transform",
scale,
calcStyle(pos) {
return setTransform(pos);
},
calcDragPosition(clientX, clientY, offsetX, offsetY) {
return {
left: (clientX - offsetX) / scale,
top: (clientY - offsetY) / scale
};
}
};
}
var defaultPositionStrategy = transformStrategy;
// src/core/types.ts
var defaultGridConfig = {
cols: 12,
rowHeight: 150,
margin: [10, 10],
containerPadding: null,
maxRows: Infinity
};
var defaultDragConfig = {
enabled: true,
bounded: false,
threshold: 3
};
var defaultResizeConfig = {
enabled: true,
handles: ["se"]
};
var defaultDropConfig = {
enabled: false,
defaultItem: { w: 1, h: 1 }
};
// src/core/compactors.ts
function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
const sizeProp = axis === "x" ? "w" : "h";
item[axis] += 1;
const itemIndex = layout.findIndex((l) => l.i === item.i);
const layoutHasStatics = hasStatics ?? getStatics(layout).length > 0;
for (let i = itemIndex + 1; i < layout.length; i++) {
const otherItem = layout[i];
if (otherItem === void 0) continue;
if (otherItem.static) continue;
if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
if (collides(item, otherItem)) {
resolveCompactionCollision(
layout,
otherItem,
moveToCoord + item[sizeProp],
axis,
layoutHasStatics
);
}
}
item[axis] = moveToCoord;
}
function compactItemVertical(compareWith, l, fullLayout, maxY) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
l.y = Math.min(maxY, l.y);
while (l.y > 0 && !getFirstCollision(compareWith, l)) {
l.y--;
}
let collision;
while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y");
}
l.y = Math.max(l.y, 0);
return l;
}
function compactItemHorizontal(compareWith, l, cols, fullLayout) {
l.x = Math.max(l.x, 0);
l.y = Math.max(l.y, 0);
while (l.x > 0 && !getFirstCollision(compareWith, l)) {
l.x--;
}
let collision;
while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
if (l.x + l.w > cols) {
l.x = cols - l.w;
l.y++;
while (l.x > 0 && !getFirstCollision(compareWith, l)) {
l.x--;
}
}
}
l.x = Math.max(l.x, 0);
return l;
}
var verticalCompactor = {
type: "vertical",
allowOverlap: false,
compact(layout, _cols) {
const compareWith = getStatics(layout);
let maxY = bottom(compareWith);
const sorted = sortLayoutItemsByRowCol(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemVertical(compareWith, l, sorted, maxY);
maxY = Math.max(maxY, l.y + l.h);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var horizontalCompactor = {
type: "horizontal",
allowOverlap: false,
compact(layout, cols) {
const compareWith = getStatics(layout);
const sorted = sortLayoutItemsByColRow(layout);
const out = new Array(layout.length);
for (let i = 0; i < sorted.length; i++) {
const sortedItem = sorted[i];
if (sortedItem === void 0) continue;
let l = cloneLayoutItem(sortedItem);
if (!l.static) {
l = compactItemHorizontal(compareWith, l, cols, sorted);
compareWith.push(l);
}
const originalIndex = layout.indexOf(sortedItem);
out[originalIndex] = l;
l.moved = false;
}
return out;
}
};
var noCompactor = {
type: null,
allowOverlap: false,
compact(layout, _cols) {
return cloneLayout(layout);
}
};
var verticalOverlapCompactor = {
...verticalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return cloneLayout(layout);
}
};
var horizontalOverlapCompactor = {
...horizontalCompactor,
allowOverlap: true,
compact(layout, _cols) {
return cloneLayout(layout);
}
};
var noOverlapCompactor = {
...noCompactor,
allowOverlap: true
};
function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
let baseCompactor;
if (allowOverlap) {
if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
else if (compactType === "horizontal")
baseCompactor = horizontalOverlapCompactor;
else baseCompactor = noOverlapCompactor;
} else {
if (compactType === "vertical") baseCompactor = verticalCompactor;
else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
else baseCompactor = noCompactor;
}
if (preventCollision) {
return { ...baseCompactor, preventCollision };
}
return baseCompactor;
}
// src/core/responsive.ts
function sortBreakpoints(breakpoints) {
const keys = Object.keys(breakpoints);
return keys.sort((a, b) => breakpoints[a] - breakpoints[b]);
}
function getBreakpointFromWidth(breakpoints, width) {
const sorted = sortBreakpoints(breakpoints);
let matching = sorted[0];
if (matching === void 0) {
throw new Error("No breakpoints defined");
}
for (let i = 1; i < sorted.length; i++) {
const breakpointName = sorted[i];
if (breakpointName === void 0) continue;
const breakpointWidth = breakpoints[breakpointName];
if (width > breakpointWidth) {
matching = breakpointName;
}
}
return matching;
}
function getColsFromBreakpoint(breakpoint, cols) {
const colCount = cols[breakpoint];
if (colCount === void 0) {
throw new Error(
`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(breakpoint)} is missing!`
);
}
return colCount;
}
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactTypeOrCompactor) {
const existingLayout = layouts[breakpoint];
if (existingLayout) {
return cloneLayout(existingLayout);
}
let layout = layouts[lastBreakpoint];
const breakpointsSorted = sortBreakpoints(breakpoints);
const breakpointsAbove = breakpointsSorted.slice(
breakpointsSorted.indexOf(breakpoint)
);
for (let i = 0; i < breakpointsAbove.length; i++) {
const b = breakpointsAbove[i];
if (b === void 0) continue;
const layoutForBreakpoint = layouts[b];
if (layoutForBreakpoint) {
layout = layoutForBreakpoint;
break;
}
}
const clonedLayout = cloneLayout(layout || []);
const corrected = correctBounds(clonedLayout, { cols });
const compactor = typeof compactTypeOrCompactor === "object" && compactTypeOrCompactor !== null ? compactTypeOrCompactor : getCompactor(compactTypeOrCompactor);
return compactor.compact(corrected, cols);
}
function getIndentationValue(value, breakpoint) {
if (Array.isArray(value)) {
return value;
}
const breakpointMap = value;
const breakpointValue = breakpointMap[breakpoint];
if (breakpointValue !== void 0) {
return breakpointValue;
}
const keys = Object.keys(breakpointMap);
for (const key of keys) {
const v = breakpointMap[key];
if (v !== void 0) {
return v;
}
}
return [10, 10];
}
export { absoluteStrategy, applyPositionConstraints, applySizeConstraints, aspectRatio, boundedX, boundedY, compactItemHorizontal, compactItemVertical, containerBounds, createScaledStrategy, defaultConstraints, defaultDragConfig, defaultDropConfig, defaultGridConfig, defaultPositionStrategy, defaultResizeConfig, findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, getIndentationValue, gridBounds, horizontalCompactor, horizontalOverlapCompactor, maxSize, minMaxSize, minSize, noCompactor, noOverlapCompactor, perc, resizeItemInDirection, resolveCompactionCollision, setTopLeft, setTransform, snapToGrid, sortBreakpoints, transformStrategy, verticalCompactor, verticalOverlapCompactor };
//# sourceMappingURL=chunk-XYPIYYYQ.mjs.map
//# sourceMappingURL=chunk-XYPIYYYQ.mjs.map

Sorry, the diff of this file is too big to display

import { verticalCompactor, sortBreakpoints, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout } from './chunk-XYPIYYYQ.mjs';
import { correctBounds, cloneLayout, getLayoutItem, cloneLayoutItem, moveElement, bottom } from './chunk-AWM66AWF.mjs';
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
import { deepEqual } from 'fast-equals';
function useContainerWidth(options = {}) {
const { measureBeforeMount = false, initialWidth = 1280 } = options;
const [width, setWidth] = useState(initialWidth);
const [mounted, setMounted] = useState(!measureBeforeMount);
const containerRef = useRef(null);
const observerRef = useRef(null);
const measureWidth = useCallback(() => {
const node = containerRef.current;
if (node) {
const newWidth = node.offsetWidth;
setWidth(newWidth);
if (!mounted) {
setMounted(true);
}
}
}, [mounted]);
useEffect(() => {
const node = containerRef.current;
if (!node) return;
measureWidth();
if (typeof ResizeObserver !== "undefined") {
observerRef.current = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry) {
const newWidth = entry.contentRect.width;
setWidth(newWidth);
}
});
observerRef.current.observe(node);
}
return () => {
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
};
}, [measureWidth]);
return {
width,
mounted,
containerRef,
measureWidth
};
}
function useGridLayout(options) {
const {
layout: propsLayout,
cols,
preventCollision = false,
onLayoutChange,
compactor = verticalCompactor
} = options;
const isDraggingRef = useRef(false);
const [layout, setLayoutState] = useState(() => {
const corrected = correctBounds(cloneLayout(propsLayout), { cols });
return compactor.compact(corrected, cols);
});
const [dragState, setDragState] = useState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
const [resizeState, setResizeState] = useState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
const [dropState, setDropState] = useState({
droppingDOMNode: null,
droppingPosition: null
});
const prevLayoutRef = useRef(layout);
const setLayout = useCallback(
(newLayout) => {
const corrected = correctBounds(cloneLayout(newLayout), { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[cols, compactor]
);
useEffect(() => {
if (isDraggingRef.current) return;
if (!deepEqual(propsLayout, prevLayoutRef.current)) {
setLayout(propsLayout);
}
}, [propsLayout, setLayout]);
useEffect(() => {
if (!deepEqual(layout, prevLayoutRef.current)) {
prevLayoutRef.current = layout;
onLayoutChange?.(layout);
}
}, [layout, onLayoutChange]);
const onDragStart = useCallback(
(itemId, x, y) => {
const item = getLayoutItem(layout, itemId);
if (!item) return null;
isDraggingRef.current = true;
const placeholder = {
...cloneLayoutItem(item),
x,
y,
static: false,
moved: false
};
setDragState({
activeDrag: placeholder,
oldDragItem: cloneLayoutItem(item),
oldLayout: cloneLayout(layout)
});
return placeholder;
},
[layout]
);
const onDrag = useCallback(
(itemId, x, y) => {
const item = getLayoutItem(layout, itemId);
if (!item) return;
setDragState((prev) => ({
...prev,
activeDrag: prev.activeDrag ? { ...prev.activeDrag, x, y } : null
}));
const newLayout = moveElement(
layout,
item,
x,
y,
true,
// isUserAction
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onDragStop = useCallback(
(itemId, x, y) => {
const item = getLayoutItem(layout, itemId);
if (!item) return;
const newLayout = moveElement(
layout,
item,
x,
y,
true,
preventCollision,
compactor.type,
cols,
compactor.allowOverlap
);
const compacted = compactor.compact(newLayout, cols);
isDraggingRef.current = false;
setDragState({
activeDrag: null,
oldDragItem: null,
oldLayout: null
});
setLayoutState(compacted);
},
[layout, cols, compactor, preventCollision]
);
const onResizeStart = useCallback(
(itemId) => {
const item = getLayoutItem(layout, itemId);
if (!item) return null;
setResizeState({
resizing: true,
oldResizeItem: cloneLayoutItem(item),
oldLayout: cloneLayout(layout)
});
return item;
},
[layout]
);
const onResize = useCallback(
(itemId, w, h, x, y) => {
const newLayout = layout.map((item) => {
if (item.i === itemId) {
const updated = {
...item,
w,
h
};
if (x !== void 0) updated.x = x;
if (y !== void 0) updated.y = y;
return updated;
}
return item;
});
const corrected = correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
},
[layout, cols, compactor]
);
const onResizeStop = useCallback(
(itemId, w, h) => {
onResize(itemId, w, h);
setResizeState({
resizing: false,
oldResizeItem: null,
oldLayout: null
});
},
[onResize]
);
const onDropDragOver = useCallback(
(droppingItem, position) => {
const existingItem = getLayoutItem(layout, droppingItem.i);
if (!existingItem) {
const newLayout = [...layout, droppingItem];
const corrected = correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
}
setDropState({
droppingDOMNode: null,
// Will be set by component
droppingPosition: position
});
},
[layout, cols, compactor]
);
const onDropDragLeave = useCallback(() => {
const newLayout = layout.filter((item) => item.i !== "__dropping-elem__");
setLayoutState(newLayout);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
}, [layout]);
const onDrop = useCallback(
(droppingItem) => {
const newLayout = layout.map((item) => {
if (item.i === "__dropping-elem__") {
return {
...item,
i: droppingItem.i,
static: false
};
}
return item;
});
const corrected = correctBounds(newLayout, { cols });
const compacted = compactor.compact(corrected, cols);
setLayoutState(compacted);
setDropState({
droppingDOMNode: null,
droppingPosition: null
});
},
[layout, cols, compactor]
);
const containerHeight = useMemo(() => bottom(layout), [layout]);
const isInteracting = dragState.activeDrag !== null || resizeState.resizing || dropState.droppingPosition !== null;
return {
layout,
setLayout,
dragState,
resizeState,
dropState,
onDragStart,
onDrag,
onDragStop,
onResizeStart,
onResize,
onResizeStop,
onDropDragOver,
onDropDragLeave,
onDrop,
containerHeight,
isInteracting,
compactor
};
}
var DEFAULT_BREAKPOINTS = {
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0
};
var DEFAULT_COLS = {
lg: 12,
md: 10,
sm: 6,
xs: 4,
xxs: 2
};
function useResponsiveLayout(options) {
const {
width,
breakpoints = DEFAULT_BREAKPOINTS,
cols: colsConfig = DEFAULT_COLS,
layouts: propsLayouts = {},
compactor = verticalCompactor,
onBreakpointChange,
onLayoutChange,
onWidthChange
} = options;
const sortedBreakpoints = useMemo(
() => sortBreakpoints(breakpoints),
[breakpoints]
);
const initialBreakpoint = useMemo(
() => getBreakpointFromWidth(breakpoints, width),
// Only calculate on mount, not on width changes
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
const initialCols = useMemo(
() => getColsFromBreakpoint(initialBreakpoint, colsConfig),
[initialBreakpoint, colsConfig]
);
const [breakpoint, setBreakpoint] = useState(initialBreakpoint);
const [cols, setCols] = useState(initialCols);
const [layouts, setLayoutsState] = useState(() => {
const cloned = {};
for (const bp of sortedBreakpoints) {
const layout2 = propsLayouts[bp];
if (layout2) {
cloned[bp] = cloneLayout(layout2);
}
}
return cloned;
});
const prevWidthRef = useRef(width);
const prevBreakpointRef = useRef(breakpoint);
const prevPropsLayoutsRef = useRef(propsLayouts);
const prevLayoutsRef = useRef(layouts);
const layout = useMemo(() => {
return findOrGenerateResponsiveLayout(
layouts,
breakpoints,
breakpoint,
prevBreakpointRef.current,
cols,
compactor
);
}, [layouts, breakpoints, breakpoint, cols, compactor]);
const setLayoutForBreakpoint = useCallback((bp, newLayout) => {
setLayoutsState((prev) => ({
...prev,
[bp]: cloneLayout(newLayout)
}));
}, []);
const setLayouts = useCallback((newLayouts) => {
const cloned = {};
for (const bp of Object.keys(newLayouts)) {
const layoutForBp = newLayouts[bp];
if (layoutForBp) {
cloned[bp] = cloneLayout(layoutForBp);
}
}
setLayoutsState(cloned);
}, []);
useEffect(() => {
if (prevWidthRef.current === width) return;
prevWidthRef.current = width;
const newBreakpoint = getBreakpointFromWidth(breakpoints, width);
const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);
onWidthChange?.(width, [10, 10], newCols, null);
if (newBreakpoint !== breakpoint) {
const newLayout = findOrGenerateResponsiveLayout(
layouts,
breakpoints,
newBreakpoint,
breakpoint,
newCols,
compactor
);
const updatedLayouts = {
...layouts,
[newBreakpoint]: newLayout
};
setLayoutsState(updatedLayouts);
setBreakpoint(newBreakpoint);
setCols(newCols);
onBreakpointChange?.(newBreakpoint, newCols);
prevBreakpointRef.current = newBreakpoint;
}
}, [
width,
breakpoints,
colsConfig,
breakpoint,
layouts,
compactor,
onBreakpointChange,
onWidthChange
]);
useEffect(() => {
if (!deepEqual(propsLayouts, prevPropsLayoutsRef.current)) {
setLayouts(propsLayouts);
prevPropsLayoutsRef.current = propsLayouts;
}
}, [propsLayouts, setLayouts]);
useEffect(() => {
if (!deepEqual(layouts, prevLayoutsRef.current)) {
prevLayoutsRef.current = layouts;
onLayoutChange?.(layout, layouts);
}
}, [layout, layouts, onLayoutChange]);
return {
layout,
layouts,
breakpoint,
cols,
setLayoutForBreakpoint,
setLayouts,
sortedBreakpoints
};
}
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout };
//# sourceMappingURL=chunk-YFVX5RDK.mjs.map
//# sourceMappingURL=chunk-YFVX5RDK.mjs.map
{"version":3,"sources":["../src/react/hooks/useContainerWidth.ts","../src/react/hooks/useGridLayout.ts","../src/react/hooks/useResponsiveLayout.ts"],"names":["useRef","useState","useCallback","useEffect","useMemo","layout","deepEqual"],"mappings":";;;;;AAsEO,SAAS,iBAAA,CACd,OAAA,GAAoC,EAAC,EACZ;AACzB,EAAA,MAAM,EAAE,kBAAA,GAAqB,KAAA,EAAO,YAAA,GAAe,MAAK,GAAI,OAAA;AAE5D,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,YAAY,CAAA;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,QAAA,CAAS,CAAC,kBAAkB,CAAA;AAC1D,EAAA,MAAM,YAAA,GAAe,OAA8B,IAAI,CAAA;AACvD,EAAA,MAAM,WAAA,GAAc,OAA8B,IAAI,CAAA;AAEtD,EAAA,MAAM,YAAA,GAAe,YAAY,MAAM;AACrC,IAAA,MAAM,OAAO,YAAA,CAAa,OAAA;AAC1B,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,MAAM,WAAW,IAAA,CAAK,WA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C3B,MAAA,OAAA,CAAQ,OAAO,CAAA;AAGf,MAAA,kBAAA,GAAqB,eAAe,OAAO,CAAA;AAE3C,MAAA,iBAAA,CAAkB,OAAA,GAAU,aAAA;AAAA,IAC9B;AAAA,EACF,CAAA,EAAG;AAAA,IACD,KAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAGD,EAAAA,UAAU,MAAM;AACd,IAAA,IAAI,CAACG,SAAAA,CAAU,YAAA,EAAc,mBAAA,CAAoB,OAAO,CAAA,EAAG;AACzD,MAAA,UAAA,CAAW,YAAY,CAAA;AACvB,MAAA,mBAAA,CAAoB,OAAA,GAAU,YAAA;AAAA,IAChC;AAAA,EACF,CAAA,EAAG,CAAC,YAAA,EAAc,UAAU,CAAC,CAAA;AAG7B,EAAAH,UAAU,MAAM;AACd,IAAA,IAAI,CAACG,SAAAA,CAAU,OAAA,EAAS,cAAA,CAAe,OAAO,CAAA,EAAG;AAC/C,MAAA,cAAA,CAAe,OAAA,GAAU,OAAA;AACzB,MAAA,cAAA,GAAiB,QAAQ,OAAO,CAAA;AAAA,IAClC;AAAA,EACF,CAAA,EAAG,CAAC,MAAA,EAAQ,OAAA,EAAS,cAAc,CAAC,CAAA;AAEpC,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,IAAA;AAAA,IACA,sBAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-YFVX5RDK.mjs","sourcesContent":["/**\n * useContainerWidth hook\n *\n * Observes container width using ResizeObserver and provides\n * reactive width updates for responsive layouts.\n */\n\nimport {\n useState,\n useEffect,\n useRef,\n useCallback,\n type RefObject\n} from \"react\";\n\nexport interface UseContainerWidthOptions {\n /**\n * If true, delays initial render until width is measured.\n * Useful for SSR or when you need accurate initial measurements.\n */\n measureBeforeMount?: boolean;\n\n /**\n * Initial width to use before measurement.\n * Defaults to 1280.\n */\n initialWidth?: number;\n}\n\nexport interface UseContainerWidthResult {\n /**\n * Current container width in pixels.\n */\n width: number;\n\n /**\n * Whether the container has been measured at least once.\n */\n mounted: boolean;\n\n /**\n * Ref to attach to the container element.\n */\n containerRef: RefObject<HTMLDivElement | null>;\n\n /**\n * Manually trigger a width measurement.\n * Useful when the container size might change without a resize event.\n */\n measureWidth: () => void;\n}\n\n/**\n * Hook to observe and track container width.\n *\n * Replaces the WidthProvider HOC with a more composable approach.\n *\n * @example\n * ```tsx\n * function MyGrid() {\n * const { width, containerRef, mounted } = useContainerWidth();\n *\n * return (\n * <div ref={containerRef}>\n * {mounted && <GridLayout width={width} {...props} />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useContainerWidth(\n options: UseContainerWidthOptions = {}\n): UseContainerWidthResult {\n const { measureBeforeMount = false, initialWidth = 1280 } = options;\n\n const [width, setWidth] = useState(initialWidth);\n const [mounted, setMounted] = useState(!measureBeforeMount);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const measureWidth = useCallback(() => {\n const node = containerRef.current;\n if (node) {\n const newWidth = node.offsetWidth;\n setWidth(newWidth);\n if (!mounted) {\n setMounted(true);\n }\n }\n }, [mounted]);\n\n useEffect(() => {\n const node = containerRef.current;\n if (!node) return;\n\n // Initial measurement\n measureWidth();\n\n // Set up ResizeObserver\n if (typeof ResizeObserver !== \"undefined\") {\n observerRef.current = new ResizeObserver(entries => {\n const entry = entries[0];\n if (entry) {\n // Use contentRect.width for consistent measurements\n const newWidth = entry.contentRect.width;\n setWidth(newWidth);\n }\n });\n\n observerRef.current.observe(node);\n }\n\n return () => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n };\n }, [measureWidth]);\n\n return {\n width,\n mounted,\n containerRef,\n measureWidth\n };\n}\n\nexport default useContainerWidth;\n","/**\n * useGridLayout hook\n *\n * Core hook for managing grid layout state, including drag, resize, and drop operations.\n * This extracts the state management logic from ReactGridLayout into a reusable hook.\n */\n\nimport { useState, useCallback, useMemo, useRef, useEffect } from \"react\";\nimport { deepEqual } from \"fast-equals\";\nimport type {\n Layout,\n LayoutItem,\n DroppingPosition,\n Compactor,\n Mutable\n} from \"../../core/types.js\";\nimport {\n cloneLayout,\n cloneLayoutItem,\n moveElement,\n correctBounds,\n bottom,\n getLayoutItem\n} from \"../../core/layout.js\";\nimport { verticalCompactor } from \"../../core/compactors.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface DragState {\n /** Currently dragging item placeholder */\n activeDrag: LayoutItem | null;\n /** Original item before drag started */\n oldDragItem: LayoutItem | null;\n /** Layout before drag started */\n oldLayout: Layout | null;\n}\n\nexport interface ResizeState {\n /** Whether a resize is in progress */\n resizing: boolean;\n /** Original item before resize started */\n oldResizeItem: LayoutItem | null;\n /** Layout before resize started */\n oldLayout: Layout | null;\n}\n\nexport interface DropState {\n /** DOM node for the dropping placeholder */\n droppingDOMNode: React.ReactElement | null;\n /** Current drop position */\n droppingPosition: DroppingPosition | null;\n}\n\nexport interface UseGridLayoutOptions {\n /** Initial layout */\n layout: Layout;\n /** Number of columns */\n cols: number;\n /** Prevent collisions when moving items */\n preventCollision?: boolean;\n /** Called when layout changes */\n onLayoutChange?: (layout: Layout) => void;\n /** Compactor for layout compaction (default: verticalCompactor) */\n compactor?: Compactor;\n}\n\nexport interface UseGridLayoutResult {\n /** Current layout */\n layout: Layout;\n /** Set layout directly */\n setLayout: (layout: Layout) => void;\n /** Drag state */\n dragState: DragState;\n /** Resize state */\n resizeState: ResizeState;\n /** Drop state */\n dropState: DropState;\n /** Start dragging an item */\n onDragStart: (itemId: string, x: number, y: number) => LayoutItem | null;\n /** Update drag position */\n onDrag: (itemId: string, x: number, y: number) => void;\n /** Stop dragging */\n onDragStop: (itemId: string, x: number, y: number) => void;\n /** Start resizing an item */\n onResizeStart: (itemId: string) => LayoutItem | null;\n /** Update resize dimensions */\n onResize: (\n itemId: string,\n w: number,\n h: number,\n x?: number,\n y?: number\n ) => void;\n /** Stop resizing */\n onResizeStop: (itemId: string, w: number, h: number) => void;\n /** Start dropping (external drag-in) */\n onDropDragOver: (\n droppingItem: LayoutItem,\n position: DroppingPosition\n ) => void;\n /** Update drop position */\n onDropDragLeave: () => void;\n /** Complete drop */\n onDrop: (droppingItem: LayoutItem) => void;\n /** Container height in rows */\n containerHeight: number;\n /** Whether any drag/resize is active */\n isInteracting: boolean;\n /** Get the compactor being used */\n compactor: Compactor;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for managing grid layout state.\n *\n * Handles all layout state including drag, resize, and drop operations.\n * Uses immutable updates and provides callbacks for all interactions.\n *\n * @example\n * ```tsx\n * function MyGrid() {\n * const {\n * layout,\n * onDragStart,\n * onDrag,\n * onDragStop,\n * containerHeight\n * } = useGridLayout({\n * layout: initialLayout,\n * cols: 12\n * });\n *\n * return (\n * <div style={{ height: containerHeight }}>\n * {layout.map(item => (\n * <GridItem\n * key={item.i}\n * {...item}\n * onDragStart={() => onDragStart(item.i, item.x, item.y)}\n * />\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useGridLayout(\n options: UseGridLayoutOptions\n): UseGridLayoutResult {\n const {\n layout: propsLayout,\n cols,\n preventCollision = false,\n onLayoutChange,\n compactor = verticalCompactor\n } = options;\n\n // Track if we're currently dragging to block prop updates\n const isDraggingRef = useRef(false);\n\n // Initialize layout with compaction using the compactor\n const [layout, setLayoutState] = useState<Layout>(() => {\n const corrected = correctBounds(cloneLayout(propsLayout), { cols });\n return compactor.compact(corrected, cols);\n });\n\n // Drag state\n const [dragState, setDragState] = useState<DragState>({\n activeDrag: null,\n oldDragItem: null,\n oldLayout: null\n });\n\n // Resize state\n const [resizeState, setResizeState] = useState<ResizeState>({\n resizing: false,\n oldResizeItem: null,\n oldLayout: null\n });\n\n // Drop state\n const [dropState, setDropState] = useState<DropState>({\n droppingDOMNode: null,\n droppingPosition: null\n });\n\n // Track previous layout for change detection\n const prevLayoutRef = useRef<Layout>(layout);\n\n // Set layout with optional compaction - use compactor.compact() (#2213)\n const setLayout = useCallback(\n (newLayout: Layout) => {\n const corrected = correctBounds(cloneLayout(newLayout), { cols });\n const compacted = compactor.compact(corrected, cols);\n setLayoutState(compacted);\n },\n [cols, compactor]\n );\n\n // Sync layout from props when not dragging\n useEffect(() => {\n if (isDraggingRef.current) return;\n\n if (!deepEqual(propsLayout, prevLayoutRef.current)) {\n setLayout(propsLayout);\n }\n }, [propsLayout, setLayout]);\n\n // Notify layout changes\n useEffect(() => {\n if (!deepEqual(layout, prevLayoutRef.current)) {\n prevLayoutRef.current = layout;\n onLayoutChange?.(layout);\n }\n }, [layout, onLayoutChange]);\n\n // ============================================================================\n // Drag Handlers\n // ============================================================================\n\n const onDragStart = useCallback(\n (itemId: string, x: number, y: number): LayoutItem | null => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return null;\n\n isDraggingRef.current = true;\n\n const placeholder: LayoutItem = {\n ...cloneLayoutItem(item),\n x,\n y,\n static: false,\n moved: false\n };\n\n setDragState({\n activeDrag: placeholder,\n oldDragItem: cloneLayoutItem(item),\n oldLayout: cloneLayout(layout)\n });\n\n return placeholder;\n },\n [layout]\n );\n\n const onDrag = useCallback(\n (itemId: string, x: number, y: number) => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return;\n\n // Update placeholder position\n setDragState(prev => ({\n ...prev,\n activeDrag: prev.activeDrag ? { ...prev.activeDrag, x, y } : null\n }));\n\n // Move element and update layout\n const newLayout = moveElement(\n layout,\n item,\n x,\n y,\n true, // isUserAction\n preventCollision,\n compactor.type,\n cols,\n compactor.allowOverlap\n );\n\n // Compact layout - use compactor.compact() (#2213)\n const compacted = compactor.compact(newLayout, cols);\n\n setLayoutState(compacted);\n },\n [layout, cols, compactor, preventCollision]\n );\n\n const onDragStop = useCallback(\n (itemId: string, x: number, y: number) => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return;\n\n // Final move\n const newLayout = moveElement(\n layout,\n item,\n x,\n y,\n true,\n preventCollision,\n compactor.type,\n cols,\n compactor.allowOverlap\n );\n\n // Compact and finalize - use compactor.compact() (#2213)\n const compacted = compactor.compact(newLayout, cols);\n\n isDraggingRef.current = false;\n\n setDragState({\n activeDrag: null,\n oldDragItem: null,\n oldLayout: null\n });\n\n setLayoutState(compacted);\n },\n [layout, cols, compactor, preventCollision]\n );\n\n // ============================================================================\n // Resize Handlers\n // ============================================================================\n\n const onResizeStart = useCallback(\n (itemId: string): LayoutItem | null => {\n const item = getLayoutItem(layout, itemId);\n if (!item) return null;\n\n setResizeState({\n resizing: true,\n oldResizeItem: cloneLayoutItem(item),\n oldLayout: cloneLayout(layout)\n });\n\n return item;\n },\n [layout]\n );\n\n const onResize = useCallback(\n (itemId: string, w: number, h: number, x?: number, y?: number) => {\n const newLayout = layout.map(item => {\n if (item.i === itemId) {\n const updated: LayoutItem = {\n ...item,\n w,\n h\n };\n if (x !== undefined) (updated as Mutable<LayoutItem>).x = x;\n if (y !== undefined) (updated as Mutable<LayoutItem>).y = y;\n return updated;\n }\n return item;\n });\n\n // Correct bounds and compact - use compactor.compact() (#2213)\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compactor.compact(corrected, cols);\n\n setLayoutState(compacted);\n },\n [layout, cols, compactor]\n );\n\n const onResizeStop = useCallback(\n (itemId: string, w: number, h: number) => {\n // Apply final resize\n onResize(itemId, w, h);\n\n setResizeState({\n resizing: false,\n oldResizeItem: null,\n oldLayout: null\n });\n },\n [onResize]\n );\n\n // ============================================================================\n // Drop Handlers\n // ============================================================================\n\n const onDropDragOver = useCallback(\n (droppingItem: LayoutItem, position: DroppingPosition) => {\n // Check if item already exists in layout\n const existingItem = getLayoutItem(layout, droppingItem.i);\n\n if (!existingItem) {\n // Add dropping item to layout - use compactor.compact() (#2213)\n const newLayout = [...layout, droppingItem];\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compactor.compact(corrected, cols);\n setLayoutState(compacted);\n }\n\n setDropState({\n droppingDOMNode: null, // Will be set by component\n droppingPosition: position\n });\n },\n [layout, cols, compactor]\n );\n\n const onDropDragLeave = useCallback(() => {\n // Remove dropping placeholder from layout\n const newLayout = layout.filter(item => item.i !== \"__dropping-elem__\");\n setLayoutState(newLayout);\n\n setDropState({\n droppingDOMNode: null,\n droppingPosition: null\n });\n }, [layout]);\n\n const onDrop = useCallback(\n (droppingItem: LayoutItem) => {\n // Replace placeholder with actual item\n const newLayout = layout.map(item => {\n if (item.i === \"__dropping-elem__\") {\n return {\n ...item,\n i: droppingItem.i,\n static: false\n };\n }\n return item;\n });\n\n // Use compactor.compact() (#2213)\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compactor.compact(corrected, cols);\n setLayoutState(compacted);\n\n setDropState({\n droppingDOMNode: null,\n droppingPosition: null\n });\n },\n [layout, cols, compactor]\n );\n\n // ============================================================================\n // Computed Values\n // ============================================================================\n\n const containerHeight = useMemo(() => bottom(layout), [layout]);\n\n const isInteracting =\n dragState.activeDrag !== null ||\n resizeState.resizing ||\n dropState.droppingPosition !== null;\n\n return {\n layout,\n setLayout,\n dragState,\n resizeState,\n dropState,\n onDragStart,\n onDrag,\n onDragStop,\n onResizeStart,\n onResize,\n onResizeStop,\n onDropDragOver,\n onDropDragLeave,\n onDrop,\n containerHeight,\n isInteracting,\n compactor\n };\n}\n\nexport default useGridLayout;\n","/**\n * useResponsiveLayout hook\n *\n * Manages responsive breakpoints and layout generation for different screen sizes.\n * Extracts state management from ResponsiveReactGridLayout into a reusable hook.\n */\n\nimport { useState, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { deepEqual } from \"fast-equals\";\nimport type {\n Layout,\n Breakpoint,\n Breakpoints,\n ResponsiveLayouts,\n Compactor\n} from \"../../core/types.js\";\nimport { cloneLayout } from \"../../core/layout.js\";\nimport {\n getBreakpointFromWidth,\n getColsFromBreakpoint,\n findOrGenerateResponsiveLayout,\n sortBreakpoints\n} from \"../../core/responsive.js\";\nimport { verticalCompactor } from \"../../core/compactors.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Default breakpoint names */\nexport type DefaultBreakpoints = \"lg\" | \"md\" | \"sm\" | \"xs\" | \"xxs\";\n\n/** Default breakpoint widths */\nexport const DEFAULT_BREAKPOINTS: Breakpoints<DefaultBreakpoints> = {\n lg: 1200,\n md: 996,\n sm: 768,\n xs: 480,\n xxs: 0\n};\n\n/** Default column counts per breakpoint */\nexport const DEFAULT_COLS: Breakpoints<DefaultBreakpoints> = {\n lg: 12,\n md: 10,\n sm: 6,\n xs: 4,\n xxs: 2\n};\n\nexport interface UseResponsiveLayoutOptions<\n B extends Breakpoint = DefaultBreakpoints\n> {\n /** Current container width */\n width: number;\n /** Breakpoint definitions (name → min-width) */\n breakpoints?: Breakpoints<B>;\n /** Column counts per breakpoint */\n cols?: Breakpoints<B>;\n /** Layouts for each breakpoint */\n layouts?: ResponsiveLayouts<B>;\n /** Compactor for layout compaction (default: verticalCompactor) */\n compactor?: Compactor;\n /** Called when breakpoint changes */\n onBreakpointChange?: (newBreakpoint: B, cols: number) => void;\n /** Called when layout changes */\n onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;\n /** Called when width changes */\n onWidthChange?: (\n width: number,\n margin: readonly [number, number],\n cols: number,\n containerPadding: readonly [number, number] | null\n ) => void;\n}\n\nexport interface UseResponsiveLayoutResult<\n B extends Breakpoint = DefaultBreakpoints\n> {\n /** Current layout for the active breakpoint */\n layout: Layout;\n /** All layouts by breakpoint */\n layouts: ResponsiveLayouts<B>;\n /** Current active breakpoint */\n breakpoint: B;\n /** Column count for the current breakpoint */\n cols: number;\n /** Update layouts for a specific breakpoint */\n setLayoutForBreakpoint: (breakpoint: B, layout: Layout) => void;\n /** Update all layouts */\n setLayouts: (layouts: ResponsiveLayouts<B>) => void;\n /** Sorted array of breakpoint names (smallest to largest) */\n sortedBreakpoints: B[];\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for managing responsive grid layouts.\n *\n * Automatically selects the appropriate layout based on container width\n * and generates layouts for new breakpoints from existing ones.\n *\n * @example\n * ```tsx\n * function MyResponsiveGrid() {\n * const { width, containerRef } = useContainerWidth();\n * const { layout, breakpoint, cols } = useResponsiveLayout({\n * width,\n * layouts: {\n * lg: [...],\n * md: [...],\n * sm: [...]\n * }\n * });\n *\n * return (\n * <div ref={containerRef}>\n * <GridLayout\n * width={width}\n * cols={cols}\n * layout={layout}\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function useResponsiveLayout<B extends Breakpoint = DefaultBreakpoints>(\n options: UseResponsiveLayoutOptions<B>\n): UseResponsiveLayoutResult<B> {\n const {\n width,\n breakpoints = DEFAULT_BREAKPOINTS as unknown as Breakpoints<B>,\n cols: colsConfig = DEFAULT_COLS as unknown as Breakpoints<B>,\n layouts: propsLayouts = {} as ResponsiveLayouts<B>,\n compactor = verticalCompactor,\n onBreakpointChange,\n onLayoutChange,\n onWidthChange\n } = options;\n\n // Sorted breakpoints for consistent ordering\n const sortedBreakpoints = useMemo(\n () => sortBreakpoints(breakpoints),\n [breakpoints]\n );\n\n // Calculate initial breakpoint and cols\n const initialBreakpoint = useMemo(\n () => getBreakpointFromWidth(breakpoints, width),\n // Only calculate on mount, not on width changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const initialCols = useMemo(\n () => getColsFromBreakpoint(initialBreakpoint, colsConfig),\n [initialBreakpoint, colsConfig]\n );\n\n // State\n const [breakpoint, setBreakpoint] = useState<B>(initialBreakpoint);\n const [cols, setCols] = useState<number>(initialCols);\n const [layouts, setLayoutsState] = useState<ResponsiveLayouts<B>>(() => {\n // Clone initial layouts\n const cloned = {} as ResponsiveLayouts<B>;\n for (const bp of sortedBreakpoints) {\n const layout = propsLayouts[bp];\n if (layout) {\n (cloned as Record<B, Layout>)[bp] = cloneLayout(layout);\n }\n }\n return cloned;\n });\n\n // Track previous values for change detection\n const prevWidthRef = useRef(width);\n const prevBreakpointRef = useRef(breakpoint);\n // Separate refs for props vs state to prevent infinite loops (#2202)\n // When using inline objects for layouts prop, we need to compare props to props\n // and state to state, not mix them up.\n const prevPropsLayoutsRef = useRef(propsLayouts);\n const prevLayoutsRef = useRef(layouts);\n\n // Current layout for the active breakpoint - use compactor (#2213)\n const layout = useMemo(() => {\n return findOrGenerateResponsiveLayout(\n layouts,\n breakpoints,\n breakpoint,\n prevBreakpointRef.current,\n cols,\n compactor\n );\n }, [layouts, breakpoints, breakpoint, cols, compactor]);\n\n // Set layout for a specific breakpoint\n const setLayoutForBreakpoint = useCallback((bp: B, newLayout: Layout) => {\n setLayoutsState((prev: ResponsiveLayouts<B>) => ({\n ...prev,\n [bp]: cloneLayout(newLayout)\n }));\n }, []);\n\n // Set all layouts\n const setLayouts = useCallback((newLayouts: ResponsiveLayouts<B>) => {\n const cloned = {} as ResponsiveLayouts<B>;\n for (const bp of Object.keys(newLayouts) as B[]) {\n const layoutForBp = newLayouts[bp];\n if (layoutForBp) {\n (cloned as Record<B, Layout>)[bp] = cloneLayout(layoutForBp);\n }\n }\n setLayoutsState(cloned);\n }, []);\n\n // Handle width changes\n useEffect(() => {\n if (prevWidthRef.current === width) return;\n prevWidthRef.current = width;\n\n // Determine new breakpoint\n const newBreakpoint = getBreakpointFromWidth(breakpoints, width);\n const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);\n\n // Notify width change\n onWidthChange?.(width, [10, 10], newCols, null);\n\n // Check if breakpoint changed\n if (newBreakpoint !== breakpoint) {\n // Generate layout for new breakpoint\n // Use compactor (#2213)\n const newLayout = findOrGenerateResponsiveLayout(\n layouts,\n breakpoints,\n newBreakpoint,\n breakpoint,\n newCols,\n compactor\n );\n\n // Update layouts with the new breakpoint layout\n const updatedLayouts: ResponsiveLayouts<B> = {\n ...layouts,\n [newBreakpoint]: newLayout\n };\n\n setLayoutsState(updatedLayouts);\n setBreakpoint(newBreakpoint);\n setCols(newCols);\n\n // Notify breakpoint change\n onBreakpointChange?.(newBreakpoint, newCols);\n\n prevBreakpointRef.current = newBreakpoint;\n }\n }, [\n width,\n breakpoints,\n colsConfig,\n breakpoint,\n layouts,\n compactor,\n onBreakpointChange,\n onWidthChange\n ]);\n\n // Sync with prop layouts when they change\n useEffect(() => {\n if (!deepEqual(propsLayouts, prevPropsLayoutsRef.current)) {\n setLayouts(propsLayouts);\n prevPropsLayoutsRef.current = propsLayouts;\n }\n }, [propsLayouts, setLayouts]);\n\n // Notify layout changes\n useEffect(() => {\n if (!deepEqual(layouts, prevLayoutsRef.current)) {\n prevLayoutsRef.current = layouts;\n onLayoutChange?.(layout, layouts);\n }\n }, [layout, layouts, onLayoutChange]);\n\n return {\n layout,\n layouts,\n breakpoint,\n cols,\n setLayoutForBreakpoint,\n setLayouts,\n sortedBreakpoints\n };\n}\n\nexport default useResponsiveLayout;\n"]}
//# sourceMappingURL=chunk-ZWN22PS2.mjs.map
//# sourceMappingURL=chunk-ZWN22PS2.mjs.map
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-ZWN22PS2.mjs"}
{"version":3,"sources":[],"names":[],"mappings":"","file":"core.js"}
{"version":3,"sources":[],"names":[],"mappings":"","file":"core.mjs"}
{"version":3,"sources":["../src/extras/GridBackground.tsx","../src/extras/fastVerticalCompactor.ts","../src/extras/fastHorizontalCompactor.ts","../src/extras/wrapCompactor.ts"],"names":["useMemo","calcGridCellDimensions","jsx","cloneLayout","t","cloneLayoutItem","originalIndex"],"mappings":";;;;;;AAkFO,SAAS,cAAA,CAAe;AAAA,EAC7B,KAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA,GAAS,CAAC,EAAA,EAAI,EAAE,CAAA;AAAA,EAChB,gBAAA;AAAA,EACA,IAAA,GAAO,EAAA;AAAA,EACP,MAAA;AAAA,EACA,KAAA,GAAQ,SAAA;AAAA,EACR,YAAA,GAAe,CAAA;AAAA,EACf,SAAA;AAAA,EAC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AAM,CAAA;AAAA,EAC3B;AACF","file":"extras.js","sourcesContent":["/**\n * GridBackground component\n *\n * Renders an SVG grid background that aligns with GridLayout cells.\n * Use this to visualize the grid structure behind your layout.\n */\n\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { calcGridCellDimensions } from \"../core/calculate.js\";\nimport type { GridCellConfig } from \"../core/calculate.js\";\n\nexport interface GridBackgroundProps extends GridCellConfig {\n /**\n * Number of rows to display. If \"auto\", calculates based on height.\n * @default 10\n */\n rows?: number | \"auto\";\n\n /**\n * Height of the background in pixels. Used when rows=\"auto\".\n */\n height?: number;\n\n /**\n * Color of the grid cell backgrounds.\n * @default \"#e0e0e0\"\n */\n color?: string;\n\n /**\n * Border radius of grid cells in pixels.\n * @default 4\n */\n borderRadius?: number;\n\n /**\n * Additional CSS class name.\n */\n className?: string;\n\n /**\n * Additional inline styles.\n */\n style?: React.CSSProperties;\n}\n\n/**\n * SVG grid background component.\n *\n * Renders a visual grid that aligns with GridLayout cells. Position this\n * behind your GridLayout using CSS positioning.\n *\n * @example\n * ```tsx\n * import { GridBackground } from 'react-grid-layout/extras';\n *\n * function MyGrid() {\n * const { width, containerRef, mounted } = useContainerWidth();\n *\n * return (\n * <div ref={containerRef} style={{ position: 'relative' }}>\n * {mounted && (\n * <>\n * <GridBackground\n * width={width}\n * cols={12}\n * rowHeight={30}\n * margin={[10, 10]}\n * rows={10}\n * color=\"#f0f0f0\"\n * />\n * <GridLayout width={width} gridConfig={{ cols: 12, rowHeight: 30 }}>\n * {children}\n * </GridLayout>\n * </>\n * )}\n * </div>\n * );\n * }\n * ```\n */\nexport function GridBackground({\n width,\n cols,\n rowHeight,\n margin = [10, 10],\n containerPadding,\n rows = 10,\n height,\n color = \"#e0e0e0\",\n borderRadius = 4,\n className,\n style\n}: GridBackgroundProps): React.ReactElement {\n const dims = useMemo(\n () =>\n calcGridCellDimensions({\n width,\n cols,\n rowHeight,\n margin,\n containerPadding\n }),\n [width, cols, rowHeight, margin, containerPadding]\n );\n\n // Calculate number of rows\n const rowCount = useMemo(() => {\n if (rows !== \"auto\") return rows;\n if (height) {\n // Calculate rows that fit in the given height\n const padding = containerPadding ?? margin;\n return Math.ceil(\n (height - padding[1] * 2 + margin[1]) / (rowHeight + margin[1])\n );\n }\n return 10;\n }, [rows, height, rowHeight, margin, containerPadding]);\n\n // Calculate total height\n const totalHeight = useMemo(() => {\n const padding = containerPadding ?? margin;\n return padding[1] * 2 + rowCount * rowHeight + (rowCount - 1) * margin[1];\n }, [rowCount, rowHeight, margin, containerPadding]);\n\n // Generate cell rectangles\n const cells = useMemo(() => {\n const rects: React.ReactElement[] = [];\n const { cellWidth, cellHeight, offsetX, offsetY, gapX, gapY } = dims;\n\n for (let row = 0; row < rowCount; row++) {\n for (let col = 0; col < cols; col++) {\n const x = offsetX + col * (cellWidth + gapX);\n const y = offsetY + row * (cellHeight + gapY);\n\n rects.push(\n <rect\n key={`${row}-${col}`}\n x={x}\n y={y}\n width={cellWidth}\n height={cellHeight}\n rx={borderRadius}\n ry={borderRadius}\n fill={color}\n />\n );\n }\n }\n\n return rects;\n }, [dims, rowCount, cols, borderRadius, color]);\n\n return (\n <svg\n className={className}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: width,\n height: totalHeight,\n pointerEvents: \"none\",\n ...style\n }}\n aria-hidden=\"true\"\n >\n {cells}\n </svg>\n );\n}\n\nexport default GridBackground;\n","/**\n * Fast Vertical Compactor\n *\n * An optimized vertical compaction algorithm using a \"rising tide\" approach.\n * This algorithm has O(n log n) complexity (dominated by sorting) compared to\n * the default vertical compactor which can have O(n²) complexity due to\n * recursive collision resolution.\n *\n * Best suited for large layouts (200+ items) where compaction performance\n * is critical. For smaller layouts, the difference is negligible.\n *\n * Based on the algorithm from PR #2152 by Morris Brodersen (@morris).\n *\n * @example\n * ```tsx\n * import { fastVerticalCompactor } from 'react-grid-layout/extras';\n *\n * <GridLayout\n * compactor={fastVerticalCompactor}\n * layout={layout}\n * // ...\n * />\n * ```\n */\n\nimport type { Compactor, Layout, LayoutItem, Mutable } from \"../core/types.js\";\nimport { cloneLayout } from \"../core/layout.js\";\n\n/**\n * Check if two layout items collide (overlap).\n */\nfunction collides(l1: LayoutItem, l2: LayoutItem): boolean {\n if (l1.i === l2.i) return false;\n return (\n l1.x < l2.x + l2.w &&\n l1.x + l1.w > l2.x &&\n l1.y < l2.y + l2.h &&\n l1.y + l1.h > l2.y\n );\n}\n\n/**\n * Fast vertical compaction using a \"rising tide\" algorithm.\n *\n * The algorithm works by:\n * 1. Sorting items by (y, x, static) - top-to-bottom, left-to-right\n * 2. Maintaining a \"tide\" array that tracks the highest occupied row per column\n * 3. For each item, moving it up to meet the tide (closing gaps)\n * 4. Checking for collisions with static items and adjusting as needed\n *\n * This avoids recursive collision resolution, making it O(n log n) overall.\n *\n * @param layout - The layout to compact (will be modified in place)\n * @param cols - Number of columns in the grid\n * @param allowOverlap - Whether to allow overlapping items\n */\nfunction compactVerticalFast(\n layout: LayoutItem[],\n cols: number,\n allowOverlap: boolean\n): void {\n const numItems = layout.length;\n\n // Sort items by position: top-to-bottom, left-to-right\n // Static items are sorted first at each position to reduce collision checks\n layout.sort((a, b) => {\n if (a.y < b.y) return -1;\n if (a.y > b.y) return 1;\n if (a.x < b.x) return -1;\n if (a.x > b.x) return 1;\n // Static items sorted first to reduce collision checks\n if (a.static && !b.static) return -1;\n if (!a.static && b.static) return 1;\n return 0;\n });\n\n // \"Rising tide\" - tracks the highest blocked row per column\n const tide: number[] = new Array(cols).fill(0);\n\n // Collect static items for collision checking\n const staticItems = layout.filter(item => item.static);\n const numStatics = staticItems.length;\n let staticOffset = 0;\n\n for (let i = 0; i < numItems; i++) {\n const item = layout[i] as Mutable<LayoutItem>;\n\n // Clamp x2 to grid bounds\n let x2 = item.x + item.w;\n if (x2 > cols) {\n x2 = cols;\n }\n\n if (item.static) {\n // Static items don't move; they become part of the tide\n // and don't need collision checks against themselves\n ++staticOffset;\n } else {\n // Find the minimum gap between the item and the tide\n let minGap = Infinity;\n for (let x = item.x; x < x2; ++x) {\n const tideValue = tide[x] ?? 0;\n const gap = item.y - tideValue;\n if (gap < minGap) {\n minGap = gap;\n }\n }\n\n // Close the gap (move item up to meet the tide)\n if (!allowOverlap || minGap > 0) {\n item.y -= minGap;\n }\n\n // Handle collisions with static items\n for (let j = staticOffset; !allowOverlap && j < numStatics; ++j) {\n const staticItem = staticItems[j];\n if (staticItem === undefined) continue;\n\n // Early exit: if static item is below current item, no more collisions possible\n if (staticItem.y >= item.y + item.h) {\n break;\n }\n\n if (collides(item, staticItem)) {\n // Move current item below the static item\n item.y = staticItem.y + staticItem.h;\n\n if (j > staticOffset) {\n // Item was moved; need to recheck with earlier static items\n // Note: j = staticOffset means after ++j we start at staticOffset + 1,\n // but staticItems[staticOffset] was already checked or is above us\n j = staticOffset;\n }\n }\n }\n\n // Reset moved flag\n item.moved = false;\n }\n\n // Update tide: mark columns as blocked up to item's bottom\n const t = item.y + item.h;\n for (let x = item.x; x < x2; ++x) {\n const currentTide = tide[x] ?? 0;\n if (currentTide < t) {\n tide[x] = t;\n }\n }\n }\n}\n\n/**\n * Fast vertical compactor - optimized for large layouts.\n *\n * Uses a \"rising tide\" algorithm that achieves O(n log n) complexity\n * instead of the potentially O(n²) recursive collision resolution.\n *\n * Best suited for layouts with 200+ items where compaction performance\n * becomes noticeable. For smaller layouts, the standard verticalCompactor\n * works equally well.\n */\nexport const fastVerticalCompactor: Compactor = {\n type: \"vertical\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n // Clone the layout since we modify in place\n const out = cloneLayout(layout) as LayoutItem[];\n compactVerticalFast(out, cols, false);\n return out;\n }\n};\n\n/**\n * Fast vertical compactor that allows overlapping items.\n *\n * Compacts items upward but allows them to overlap each other.\n */\nexport const fastVerticalOverlapCompactor: Compactor = {\n ...fastVerticalCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, cols: number): Layout {\n const out = cloneLayout(layout) as LayoutItem[];\n compactVerticalFast(out, cols, true);\n return out;\n }\n};\n","/**\n * Fast Horizontal Compactor\n *\n * An optimized horizontal compaction algorithm using a \"sweeping tide\" approach.\n * This algorithm has O(n log n) complexity (dominated by sorting) compared to\n * the default horizontal compactor which can have O(n²) complexity due to\n * recursive collision resolution.\n *\n * Best suited for large layouts (200+ items) where compaction performance\n * is critical. For smaller layouts, the difference is negligible.\n *\n * Adapted from the vertical fast compactor algorithm from PR #2152 by Morris Brodersen (@morris).\n *\n * @example\n * ```tsx\n * import { fastHorizontalCompactor } from 'react-grid-layout/extras';\n *\n * <GridLayout\n * compactor={fastHorizontalCompactor}\n * layout={layout}\n * // ...\n * />\n * ```\n */\n\nimport type { Compactor, Layout, LayoutItem, Mutable } from \"../core/types.js\";\nimport { cloneLayout } from \"../core/layout.js\";\n\n/**\n * Ensure the tide array has enough rows.\n */\nfunction ensureTideRows(tide: number[], neededRows: number): void {\n while (tide.length < neededRows) {\n tide.push(0);\n }\n}\n\n/**\n * Find the maximum tide value for a range of rows.\n */\nfunction getMaxTideForItem(tide: number[], y: number, h: number): number {\n let maxTide = 0;\n for (let row = y; row < y + h; row++) {\n const tideValue = tide[row] ?? 0;\n if (tideValue > maxTide) {\n maxTide = tideValue;\n }\n }\n return maxTide;\n}\n\n/**\n * Check if an item can be placed at a given position without colliding with static items.\n */\nfunction canPlaceAt(\n item: LayoutItem,\n x: number,\n y: number,\n staticItems: LayoutItem[],\n cols: number\n): boolean {\n // Check grid bounds\n if (x + item.w > cols) return false;\n\n // Check static collisions\n for (const staticItem of staticItems) {\n if (\n x < staticItem.x + staticItem.w &&\n x + item.w > staticItem.x &&\n y < staticItem.y + staticItem.h &&\n y + item.h > staticItem.y\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Fast horizontal compaction using a \"sweeping tide\" algorithm with row wrapping.\n *\n * The algorithm works by:\n * 1. Sorting items by (y, x, static) - top-to-bottom, left-to-right (like standard compactor)\n * 2. Maintaining a \"tide\" array that tracks the rightmost occupied column per row\n * 3. For each item, finding the leftmost position it can occupy\n * 4. If the item doesn't fit in its current row, wrapping to the next row\n * 5. Checking for collisions with static items and adjusting as needed\n *\n * This avoids recursive collision resolution, making it O(n log n) overall.\n *\n * @param layout - The layout to compact (will be modified in place)\n * @param cols - Number of columns in the grid\n * @param allowOverlap - Whether to allow overlapping items\n */\nfunction compactHorizontalFast(\n layout: LayoutItem[],\n cols: number,\n allowOverlap: boolean\n): void {\n const numItems = layout.length;\n if (numItems === 0) return;\n\n // Sort items by column then row (same as standard horizontal compactor)\n // Static items are sorted first at each position to reduce collision checks\n layout.sort((a, b) => {\n if (a.x !== b.x) return a.x - b.x;\n if (a.y !== b.y) return a.y - b.y;\n if (a.static !== b.static) return a.static ? -1 : 1;\n return 0;\n });\n\n // Calculate max row extent for pre-allocation\n let maxRow = 0;\n for (let i = 0; i < numItems; i++) {\n const item = layout[i];\n if (item !== undefined) {\n const bottom = item.y + item.h;\n if (bottom > maxRow) maxRow = bottom;\n }\n }\n\n // \"Sweeping tide\" - tracks the rightmost blocked column per row\n // Pre-allocate based on max row extent to avoid repeated reallocations\n const tide: number[] = new Array(maxRow).fill(0);\n\n // Collect static items for collision checking\n const staticItems = layout.filter(item => item.static);\n\n // Safety limit for row wrapping (prevents infinite loops)\n // Use a limit relative to layout size (at least 10_000, or 100x the number of items)\n const maxRowLimit = Math.max(10_000, numItems * 100);\n\n for (let i = 0; i < numItems; i++) {\n const item = layout[i] as Mutable<LayoutItem>;\n\n if (item.static) {\n // Static items don't move; they become part of the tide\n ensureTideRows(tide, item.y + item.h);\n const t = item.x + item.w;\n for (let y = item.y; y < item.y + item.h; y++) {\n if ((tide[y] ?? 0) < t) {\n tide[y] = t;\n }\n }\n continue;\n }\n\n // For non-static items, find the best position\n let targetY = item.y;\n let targetX = 0;\n let placed = false;\n\n // Try to place the item, wrapping to lower rows if needed\n while (!placed) {\n ensureTideRows(tide, targetY + item.h);\n\n // Find the maximum tide across the rows this item spans\n const maxTide = getMaxTideForItem(tide, targetY, item.h);\n\n // Try to place at the tide position\n targetX = maxTide;\n\n // Check if item fits within grid bounds\n if (targetX + item.w <= cols) {\n // Check for static item collisions\n if (\n allowOverlap ||\n canPlaceAt(item, targetX, targetY, staticItems, cols)\n ) {\n placed = true;\n } else {\n // Find the rightmost static collision and try past it\n let maxStaticRight = targetX;\n let foundCollision = false;\n for (const staticItem of staticItems) {\n if (\n targetX < staticItem.x + staticItem.w &&\n targetX + item.w > staticItem.x &&\n targetY < staticItem.y + staticItem.h &&\n targetY + item.h > staticItem.y\n ) {\n maxStaticRight = Math.max(\n maxStaticRight,\n staticItem.x + staticItem.w\n );\n foundCollision = true;\n }\n }\n if (foundCollision) {\n targetX = maxStaticRight;\n }\n\n // After moving past static, check if we still fit\n if (foundCollision && targetX + item.w <= cols) {\n // Verify no more collisions at new position\n if (canPlaceAt(item, targetX, targetY, staticItems, cols)) {\n placed = true;\n } else {\n // Can't fit in this row, wrap to next\n targetY++;\n }\n } else if (foundCollision) {\n // Pushed past grid edge, wrap to next row\n targetY++;\n } else {\n // No collision but can't place - shouldn't happen\n placed = true;\n }\n }\n } else {\n // Doesn't fit in this row, wrap to next\n targetY++;\n }\n\n // Safety check to prevent infinite loops\n if (targetY > maxRowLimit) {\n if (typeof console !== \"undefined\" && console.warn) {\n console.warn(\n `Fast horizontal compactor: Item \"${item.i}\" exceeded max row limit (${targetY}). ` +\n `This may indicate a layout that cannot be compacted within grid bounds.`\n );\n }\n // Give up and place at current position\n targetX = 0;\n placed = true;\n }\n }\n\n // Update item position\n item.x = targetX;\n item.y = targetY;\n item.moved = false;\n\n // Update tide: mark rows as blocked up to item's right edge\n ensureTideRows(tide, targetY + item.h);\n const t = targetX + item.w;\n for (let y = targetY; y < targetY + item.h; y++) {\n if ((tide[y] ?? 0) < t) {\n tide[y] = t;\n }\n }\n }\n}\n\n/**\n * Fast horizontal compactor - optimized for large layouts.\n *\n * Uses a \"sweeping tide\" algorithm that achieves O(n log n) complexity\n * instead of the potentially O(n²) recursive collision resolution.\n *\n * Best suited for layouts with 200+ items where compaction performance\n * becomes noticeable. For smaller layouts, the standard horizontalCompactor\n * works equally well.\n */\nexport const fastHorizontalCompactor: Compactor = {\n type: \"horizontal\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n // Clone the layout since we modify in place\n const out = cloneLayout(layout) as LayoutItem[];\n compactHorizontalFast(out, cols, false);\n return out;\n }\n};\n\n/**\n * Fast horizontal compactor that allows overlapping items.\n *\n * Compacts items leftward but allows them to overlap each other.\n */\nexport const fastHorizontalOverlapCompactor: Compactor = {\n ...fastHorizontalCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, cols: number): Layout {\n const out = cloneLayout(layout) as LayoutItem[];\n compactHorizontalFast(out, cols, true);\n return out;\n }\n};\n","/**\n * Wrap Compactor\n *\n * A compaction algorithm that treats grid items like words in a paragraph.\n * Items flow left-to-right, wrapping to the next row when they reach\n * the grid edge.\n *\n * When dragging:\n * - Moving an item earlier in the sequence shifts other items down/right\n * - Moving an item later in the sequence shifts other items up/left\n *\n * This creates a natural reordering behavior similar to drag-and-drop\n * in file managers or card layouts.\n *\n * Based on the algorithm from PR #1773 by John Thomson (@JohnThomson).\n *\n * @example\n * ```tsx\n * import { wrapCompactor } from 'react-grid-layout/extras';\n *\n * <GridLayout\n * compactor={wrapCompactor}\n * layout={layout}\n * // ...\n * />\n * ```\n */\n\nimport type { Compactor, Layout, LayoutItem, Mutable } from \"../core/types.js\";\nimport { cloneLayout, cloneLayoutItem } from \"../core/layout.js\";\n\n/**\n * Sort items in wrap order: left-to-right, top-to-bottom.\n * This is the visual reading order for wrapped content.\n */\nfunction sortByWrapOrder(layout: Layout): LayoutItem[] {\n return [...layout].sort((a, b) => {\n // Primary: top-to-bottom (by row)\n if (a.y !== b.y) return a.y - b.y;\n // Secondary: left-to-right (by column)\n return a.x - b.x;\n });\n}\n\n/**\n * Convert a linear wrap position back to x,y coordinates.\n */\nfunction fromWrapPosition(pos: number, cols: number): { x: number; y: number } {\n return {\n x: pos % cols,\n y: Math.floor(pos / cols)\n };\n}\n\n/**\n * Compact items in wrap order, filling gaps from left-to-right, top-to-bottom.\n * All items are assumed to be 1x1 for wrap mode to work correctly.\n */\nfunction compactWrap(layout: Layout, cols: number): LayoutItem[] {\n if (layout.length === 0) return [];\n\n const sorted = sortByWrapOrder(layout);\n const out: LayoutItem[] = new Array(layout.length);\n const statics = sorted.filter(item => item.static);\n\n // Track which positions are occupied by static items\n const staticPositions = new Set<number>();\n for (const s of statics) {\n // For static items, mark all cells they occupy\n for (let dy = 0; dy < s.h; dy++) {\n for (let dx = 0; dx < s.w; dx++) {\n staticPositions.add((s.y + dy) * cols + (s.x + dx));\n }\n }\n }\n\n let nextPos = 0;\n\n for (let i = 0; i < sorted.length; i++) {\n const sortedItem = sorted[i];\n if (sortedItem === undefined) continue;\n\n const l = cloneLayoutItem(sortedItem);\n\n if (l.static) {\n // Static items stay in place\n const originalIndex = layout.indexOf(sortedItem);\n out[originalIndex] = l;\n l.moved = false;\n continue;\n }\n\n // Find next available position that doesn't conflict with statics\n while (staticPositions.has(nextPos)) {\n nextPos++;\n }\n\n // For items larger than 1x1, we need to check if the full item fits\n const { x, y } = fromWrapPosition(nextPos, cols);\n\n // Check if item would overflow the row\n if (x + l.w > cols) {\n // Move to start of next row\n nextPos = (y + 1) * cols;\n // Skip any static positions on the new row\n while (staticPositions.has(nextPos)) {\n nextPos++;\n }\n }\n\n const newCoords = fromWrapPosition(nextPos, cols);\n (l as Mutable<LayoutItem>).x = newCoords.x;\n (l as Mutable<LayoutItem>).y = newCoords.y;\n\n // Advance past this item\n nextPos += l.w;\n\n const originalIndex = layout.indexOf(sortedItem);\n out[originalIndex] = l;\n l.moved = false;\n }\n\n return out;\n}\n\n/**\n * Wrap compactor - arranges items like words in a paragraph.\n *\n * Items flow left-to-right and wrap to the next row when they\n * reach the grid edge. Dragging an item reorders the sequence,\n * with other items shifting to maintain the flow.\n *\n * Works best with uniformly-sized items (especially 1x1), but\n * handles larger items by ensuring they fit within row bounds.\n */\nexport const wrapCompactor: Compactor = {\n type: \"wrap\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n return compactWrap(layout, cols);\n }\n};\n\n/**\n * Wrap compactor that allows overlapping items.\n */\nexport const wrapOverlapCompactor: Compactor = {\n ...wrapCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, _cols: number): Layout {\n // With overlap allowed, just clone without compacting\n return cloneLayout(layout);\n }\n};\n"]}
{"version":3,"sources":["../src/extras/GridBackground.tsx","../src/extras/fastVerticalCompactor.ts","../src/extras/fastHorizontalCompactor.ts","../src/extras/wrapCompactor.ts"],"names":["t","originalIndex"],"mappings":";;;;AAkFO,SAAS,cAAA,CAAe;AAAA,EAC7B,KAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA,GAAS,CAAC,EAAA,EAAI,EAAE,CAAA;AAAA,EAChB,gBAAA;AAAA,EACA,IAAA,GAAO,EAAA;AAAA,EACP,MAAA;AAAA,EACA,KAAA,GAAQ,SAAA;AAAA,EACR,YAAA,GAAe,CAAA;AAAA,EACf,SAAA;AAAA,EACA;AACF,CAAA,EAA4C;AAC1C,EAAA,MAAM,IAAA,GAAO,OAAA;AAAA,IACX,MACE,sBAAA,CAAuB;AAAA,MACrB,KAAA;AAAA,MACA,IAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,IACH,CAAC,KAAA,EAAO,IAAA,EAAM,SAAA,EAAW,QAAQ,gBAAgB;AAAA,GACnD;AAGA,EAAA,MAAM,QAAA,GAAW,QAAQ,MAAM;AAC7B,IAAA,IAAI,IAAA,KAAS,QAAQ,OAAO,IAAA;AAC5B,IAAA,IAAI,MAAA,EAAQ;AAEV,MAAA,MAAM,UAAU,gBAAA,IAAoB,MAAA;AACpC,MAAA,OAAO,IAAA,CAAK,IAAA;AAAA,QAAA,CACT,MAAA,GAAS,OAAA,CAAQ,CAAC,CAAA,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AAC,CAAA,CAA0B,IAAI,SAAA,CAAU,CAAA;AACzC,IAAC,CAAA,CAA0B,IAAI,SAAA,CAAU,CAAA;AAGzC,IAAA,OAAA,IAAW,CAAA,CAAE,CAAA;AAEb,IAAA,MAAM,aAAA,GAAgB,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAA;AAC/C,IAAA,GAAA,CAAI,aAAa,CAAA,GAAI,CAAA;AACrB,IAAA,CAAA,CAAE,KAAA,GAAQ,KAAA;AAAA,EACZ;AAEA,EAAA,OAAO,GAAA;AACT;AAYO,IAAM,aAAA,GAA2B;AAAA,EACtC,IAAA,EAAM,MAAA;AAAA,EACN,YAAA,EAAc,KAAA;AAAA,EAEd,OAAA,CAAQ,QAAgB,IAAA,EAAsB;AAC5C,IAAA,OAAO,WAAA,CAAY,QAAQ,IAAI,CAAA;AAAA,EACjC;AACF;AAKO,IAAM,oBAAA,GAAkC;AAAA,EAC7C,GAAG,aAAA;AAAA,EACH,YAAA,EAAc,IAAA;AAAA,EAEd,OAAA,CAAQ,QAAgB,KAAA,EAAuB;AAE7C,IAAA,OAAO,YAAY,MAAM,CAAA;AAAA,EAC3B;AACF","file":"extras.mjs","sourcesContent":["/**\n * GridBackground component\n *\n * Renders an SVG grid background that aligns with GridLayout cells.\n * Use this to visualize the grid structure behind your layout.\n */\n\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { calcGridCellDimensions } from \"../core/calculate.js\";\nimport type { GridCellConfig } from \"../core/calculate.js\";\n\nexport interface GridBackgroundProps extends GridCellConfig {\n /**\n * Number of rows to display. If \"auto\", calculates based on height.\n * @default 10\n */\n rows?: number | \"auto\";\n\n /**\n * Height of the background in pixels. Used when rows=\"auto\".\n */\n height?: number;\n\n /**\n * Color of the grid cell backgrounds.\n * @default \"#e0e0e0\"\n */\n color?: string;\n\n /**\n * Border radius of grid cells in pixels.\n * @default 4\n */\n borderRadius?: number;\n\n /**\n * Additional CSS class name.\n */\n className?: string;\n\n /**\n * Additional inline styles.\n */\n style?: React.CSSProperties;\n}\n\n/**\n * SVG grid background component.\n *\n * Renders a visual grid that aligns with GridLayout cells. Position this\n * behind your GridLayout using CSS positioning.\n *\n * @example\n * ```tsx\n * import { GridBackground } from 'react-grid-layout/extras';\n *\n * function MyGrid() {\n * const { width, containerRef, mounted } = useContainerWidth();\n *\n * return (\n * <div ref={containerRef} style={{ position: 'relative' }}>\n * {mounted && (\n * <>\n * <GridBackground\n * width={width}\n * cols={12}\n * rowHeight={30}\n * margin={[10, 10]}\n * rows={10}\n * color=\"#f0f0f0\"\n * />\n * <GridLayout width={width} gridConfig={{ cols: 12, rowHeight: 30 }}>\n * {children}\n * </GridLayout>\n * </>\n * )}\n * </div>\n * );\n * }\n * ```\n */\nexport function GridBackground({\n width,\n cols,\n rowHeight,\n margin = [10, 10],\n containerPadding,\n rows = 10,\n height,\n color = \"#e0e0e0\",\n borderRadius = 4,\n className,\n style\n}: GridBackgroundProps): React.ReactElement {\n const dims = useMemo(\n () =>\n calcGridCellDimensions({\n width,\n cols,\n rowHeight,\n margin,\n containerPadding\n }),\n [width, cols, rowHeight, margin, containerPadding]\n );\n\n // Calculate number of rows\n const rowCount = useMemo(() => {\n if (rows !== \"auto\") return rows;\n if (height) {\n // Calculate rows that fit in the given height\n const padding = containerPadding ?? margin;\n return Math.ceil(\n (height - padding[1] * 2 + margin[1]) / (rowHeight + margin[1])\n );\n }\n return 10;\n }, [rows, height, rowHeight, margin, containerPadding]);\n\n // Calculate total height\n const totalHeight = useMemo(() => {\n const padding = containerPadding ?? margin;\n return padding[1] * 2 + rowCount * rowHeight + (rowCount - 1) * margin[1];\n }, [rowCount, rowHeight, margin, containerPadding]);\n\n // Generate cell rectangles\n const cells = useMemo(() => {\n const rects: React.ReactElement[] = [];\n const { cellWidth, cellHeight, offsetX, offsetY, gapX, gapY } = dims;\n\n for (let row = 0; row < rowCount; row++) {\n for (let col = 0; col < cols; col++) {\n const x = offsetX + col * (cellWidth + gapX);\n const y = offsetY + row * (cellHeight + gapY);\n\n rects.push(\n <rect\n key={`${row}-${col}`}\n x={x}\n y={y}\n width={cellWidth}\n height={cellHeight}\n rx={borderRadius}\n ry={borderRadius}\n fill={color}\n />\n );\n }\n }\n\n return rects;\n }, [dims, rowCount, cols, borderRadius, color]);\n\n return (\n <svg\n className={className}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: width,\n height: totalHeight,\n pointerEvents: \"none\",\n ...style\n }}\n aria-hidden=\"true\"\n >\n {cells}\n </svg>\n );\n}\n\nexport default GridBackground;\n","/**\n * Fast Vertical Compactor\n *\n * An optimized vertical compaction algorithm using a \"rising tide\" approach.\n * This algorithm has O(n log n) complexity (dominated by sorting) compared to\n * the default vertical compactor which can have O(n²) complexity due to\n * recursive collision resolution.\n *\n * Best suited for large layouts (200+ items) where compaction performance\n * is critical. For smaller layouts, the difference is negligible.\n *\n * Based on the algorithm from PR #2152 by Morris Brodersen (@morris).\n *\n * @example\n * ```tsx\n * import { fastVerticalCompactor } from 'react-grid-layout/extras';\n *\n * <GridLayout\n * compactor={fastVerticalCompactor}\n * layout={layout}\n * // ...\n * />\n * ```\n */\n\nimport type { Compactor, Layout, LayoutItem, Mutable } from \"../core/types.js\";\nimport { cloneLayout } from \"../core/layout.js\";\n\n/**\n * Check if two layout items collide (overlap).\n */\nfunction collides(l1: LayoutItem, l2: LayoutItem): boolean {\n if (l1.i === l2.i) return false;\n return (\n l1.x < l2.x + l2.w &&\n l1.x + l1.w > l2.x &&\n l1.y < l2.y + l2.h &&\n l1.y + l1.h > l2.y\n );\n}\n\n/**\n * Fast vertical compaction using a \"rising tide\" algorithm.\n *\n * The algorithm works by:\n * 1. Sorting items by (y, x, static) - top-to-bottom, left-to-right\n * 2. Maintaining a \"tide\" array that tracks the highest occupied row per column\n * 3. For each item, moving it up to meet the tide (closing gaps)\n * 4. Checking for collisions with static items and adjusting as needed\n *\n * This avoids recursive collision resolution, making it O(n log n) overall.\n *\n * @param layout - The layout to compact (will be modified in place)\n * @param cols - Number of columns in the grid\n * @param allowOverlap - Whether to allow overlapping items\n */\nfunction compactVerticalFast(\n layout: LayoutItem[],\n cols: number,\n allowOverlap: boolean\n): void {\n const numItems = layout.length;\n\n // Sort items by position: top-to-bottom, left-to-right\n // Static items are sorted first at each position to reduce collision checks\n layout.sort((a, b) => {\n if (a.y < b.y) return -1;\n if (a.y > b.y) return 1;\n if (a.x < b.x) return -1;\n if (a.x > b.x) return 1;\n // Static items sorted first to reduce collision checks\n if (a.static && !b.static) return -1;\n if (!a.static && b.static) return 1;\n return 0;\n });\n\n // \"Rising tide\" - tracks the highest blocked row per column\n const tide: number[] = new Array(cols).fill(0);\n\n // Collect static items for collision checking\n const staticItems = layout.filter(item => item.static);\n const numStatics = staticItems.length;\n let staticOffset = 0;\n\n for (let i = 0; i < numItems; i++) {\n const item = layout[i] as Mutable<LayoutItem>;\n\n // Clamp x2 to grid bounds\n let x2 = item.x + item.w;\n if (x2 > cols) {\n x2 = cols;\n }\n\n if (item.static) {\n // Static items don't move; they become part of the tide\n // and don't need collision checks against themselves\n ++staticOffset;\n } else {\n // Find the minimum gap between the item and the tide\n let minGap = Infinity;\n for (let x = item.x; x < x2; ++x) {\n const tideValue = tide[x] ?? 0;\n const gap = item.y - tideValue;\n if (gap < minGap) {\n minGap = gap;\n }\n }\n\n // Close the gap (move item up to meet the tide)\n if (!allowOverlap || minGap > 0) {\n item.y -= minGap;\n }\n\n // Handle collisions with static items\n for (let j = staticOffset; !allowOverlap && j < numStatics; ++j) {\n const staticItem = staticItems[j];\n if (staticItem === undefined) continue;\n\n // Early exit: if static item is below current item, no more collisions possible\n if (staticItem.y >= item.y + item.h) {\n break;\n }\n\n if (collides(item, staticItem)) {\n // Move current item below the static item\n item.y = staticItem.y + staticItem.h;\n\n if (j > staticOffset) {\n // Item was moved; need to recheck with earlier static items\n // Note: j = staticOffset means after ++j we start at staticOffset + 1,\n // but staticItems[staticOffset] was already checked or is above us\n j = staticOffset;\n }\n }\n }\n\n // Reset moved flag\n item.moved = false;\n }\n\n // Update tide: mark columns as blocked up to item's bottom\n const t = item.y + item.h;\n for (let x = item.x; x < x2; ++x) {\n const currentTide = tide[x] ?? 0;\n if (currentTide < t) {\n tide[x] = t;\n }\n }\n }\n}\n\n/**\n * Fast vertical compactor - optimized for large layouts.\n *\n * Uses a \"rising tide\" algorithm that achieves O(n log n) complexity\n * instead of the potentially O(n²) recursive collision resolution.\n *\n * Best suited for layouts with 200+ items where compaction performance\n * becomes noticeable. For smaller layouts, the standard verticalCompactor\n * works equally well.\n */\nexport const fastVerticalCompactor: Compactor = {\n type: \"vertical\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n // Clone the layout since we modify in place\n const out = cloneLayout(layout) as LayoutItem[];\n compactVerticalFast(out, cols, false);\n return out;\n }\n};\n\n/**\n * Fast vertical compactor that allows overlapping items.\n *\n * Compacts items upward but allows them to overlap each other.\n */\nexport const fastVerticalOverlapCompactor: Compactor = {\n ...fastVerticalCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, cols: number): Layout {\n const out = cloneLayout(layout) as LayoutItem[];\n compactVerticalFast(out, cols, true);\n return out;\n }\n};\n","/**\n * Fast Horizontal Compactor\n *\n * An optimized horizontal compaction algorithm using a \"sweeping tide\" approach.\n * This algorithm has O(n log n) complexity (dominated by sorting) compared to\n * the default horizontal compactor which can have O(n²) complexity due to\n * recursive collision resolution.\n *\n * Best suited for large layouts (200+ items) where compaction performance\n * is critical. For smaller layouts, the difference is negligible.\n *\n * Adapted from the vertical fast compactor algorithm from PR #2152 by Morris Brodersen (@morris).\n *\n * @example\n * ```tsx\n * import { fastHorizontalCompactor } from 'react-grid-layout/extras';\n *\n * <GridLayout\n * compactor={fastHorizontalCompactor}\n * layout={layout}\n * // ...\n * />\n * ```\n */\n\nimport type { Compactor, Layout, LayoutItem, Mutable } from \"../core/types.js\";\nimport { cloneLayout } from \"../core/layout.js\";\n\n/**\n * Ensure the tide array has enough rows.\n */\nfunction ensureTideRows(tide: number[], neededRows: number): void {\n while (tide.length < neededRows) {\n tide.push(0);\n }\n}\n\n/**\n * Find the maximum tide value for a range of rows.\n */\nfunction getMaxTideForItem(tide: number[], y: number, h: number): number {\n let maxTide = 0;\n for (let row = y; row < y + h; row++) {\n const tideValue = tide[row] ?? 0;\n if (tideValue > maxTide) {\n maxTide = tideValue;\n }\n }\n return maxTide;\n}\n\n/**\n * Check if an item can be placed at a given position without colliding with static items.\n */\nfunction canPlaceAt(\n item: LayoutItem,\n x: number,\n y: number,\n staticItems: LayoutItem[],\n cols: number\n): boolean {\n // Check grid bounds\n if (x + item.w > cols) return false;\n\n // Check static collisions\n for (const staticItem of staticItems) {\n if (\n x < staticItem.x + staticItem.w &&\n x + item.w > staticItem.x &&\n y < staticItem.y + staticItem.h &&\n y + item.h > staticItem.y\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Fast horizontal compaction using a \"sweeping tide\" algorithm with row wrapping.\n *\n * The algorithm works by:\n * 1. Sorting items by (y, x, static) - top-to-bottom, left-to-right (like standard compactor)\n * 2. Maintaining a \"tide\" array that tracks the rightmost occupied column per row\n * 3. For each item, finding the leftmost position it can occupy\n * 4. If the item doesn't fit in its current row, wrapping to the next row\n * 5. Checking for collisions with static items and adjusting as needed\n *\n * This avoids recursive collision resolution, making it O(n log n) overall.\n *\n * @param layout - The layout to compact (will be modified in place)\n * @param cols - Number of columns in the grid\n * @param allowOverlap - Whether to allow overlapping items\n */\nfunction compactHorizontalFast(\n layout: LayoutItem[],\n cols: number,\n allowOverlap: boolean\n): void {\n const numItems = layout.length;\n if (numItems === 0) return;\n\n // Sort items by column then row (same as standard horizontal compactor)\n // Static items are sorted first at each position to reduce collision checks\n layout.sort((a, b) => {\n if (a.x !== b.x) return a.x - b.x;\n if (a.y !== b.y) return a.y - b.y;\n if (a.static !== b.static) return a.static ? -1 : 1;\n return 0;\n });\n\n // Calculate max row extent for pre-allocation\n let maxRow = 0;\n for (let i = 0; i < numItems; i++) {\n const item = layout[i];\n if (item !== undefined) {\n const bottom = item.y + item.h;\n if (bottom > maxRow) maxRow = bottom;\n }\n }\n\n // \"Sweeping tide\" - tracks the rightmost blocked column per row\n // Pre-allocate based on max row extent to avoid repeated reallocations\n const tide: number[] = new Array(maxRow).fill(0);\n\n // Collect static items for collision checking\n const staticItems = layout.filter(item => item.static);\n\n // Safety limit for row wrapping (prevents infinite loops)\n // Use a limit relative to layout size (at least 10_000, or 100x the number of items)\n const maxRowLimit = Math.max(10_000, numItems * 100);\n\n for (let i = 0; i < numItems; i++) {\n const item = layout[i] as Mutable<LayoutItem>;\n\n if (item.static) {\n // Static items don't move; they become part of the tide\n ensureTideRows(tide, item.y + item.h);\n const t = item.x + item.w;\n for (let y = item.y; y < item.y + item.h; y++) {\n if ((tide[y] ?? 0) < t) {\n tide[y] = t;\n }\n }\n continue;\n }\n\n // For non-static items, find the best position\n let targetY = item.y;\n let targetX = 0;\n let placed = false;\n\n // Try to place the item, wrapping to lower rows if needed\n while (!placed) {\n ensureTideRows(tide, targetY + item.h);\n\n // Find the maximum tide across the rows this item spans\n const maxTide = getMaxTideForItem(tide, targetY, item.h);\n\n // Try to place at the tide position\n targetX = maxTide;\n\n // Check if item fits within grid bounds\n if (targetX + item.w <= cols) {\n // Check for static item collisions\n if (\n allowOverlap ||\n canPlaceAt(item, targetX, targetY, staticItems, cols)\n ) {\n placed = true;\n } else {\n // Find the rightmost static collision and try past it\n let maxStaticRight = targetX;\n let foundCollision = false;\n for (const staticItem of staticItems) {\n if (\n targetX < staticItem.x + staticItem.w &&\n targetX + item.w > staticItem.x &&\n targetY < staticItem.y + staticItem.h &&\n targetY + item.h > staticItem.y\n ) {\n maxStaticRight = Math.max(\n maxStaticRight,\n staticItem.x + staticItem.w\n );\n foundCollision = true;\n }\n }\n if (foundCollision) {\n targetX = maxStaticRight;\n }\n\n // After moving past static, check if we still fit\n if (foundCollision && targetX + item.w <= cols) {\n // Verify no more collisions at new position\n if (canPlaceAt(item, targetX, targetY, staticItems, cols)) {\n placed = true;\n } else {\n // Can't fit in this row, wrap to next\n targetY++;\n }\n } else if (foundCollision) {\n // Pushed past grid edge, wrap to next row\n targetY++;\n } else {\n // No collision but can't place - shouldn't happen\n placed = true;\n }\n }\n } else {\n // Doesn't fit in this row, wrap to next\n targetY++;\n }\n\n // Safety check to prevent infinite loops\n if (targetY > maxRowLimit) {\n if (typeof console !== \"undefined\" && console.warn) {\n console.warn(\n `Fast horizontal compactor: Item \"${item.i}\" exceeded max row limit (${targetY}). ` +\n `This may indicate a layout that cannot be compacted within grid bounds.`\n );\n }\n // Give up and place at current position\n targetX = 0;\n placed = true;\n }\n }\n\n // Update item position\n item.x = targetX;\n item.y = targetY;\n item.moved = false;\n\n // Update tide: mark rows as blocked up to item's right edge\n ensureTideRows(tide, targetY + item.h);\n const t = targetX + item.w;\n for (let y = targetY; y < targetY + item.h; y++) {\n if ((tide[y] ?? 0) < t) {\n tide[y] = t;\n }\n }\n }\n}\n\n/**\n * Fast horizontal compactor - optimized for large layouts.\n *\n * Uses a \"sweeping tide\" algorithm that achieves O(n log n) complexity\n * instead of the potentially O(n²) recursive collision resolution.\n *\n * Best suited for layouts with 200+ items where compaction performance\n * becomes noticeable. For smaller layouts, the standard horizontalCompactor\n * works equally well.\n */\nexport const fastHorizontalCompactor: Compactor = {\n type: \"horizontal\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n // Clone the layout since we modify in place\n const out = cloneLayout(layout) as LayoutItem[];\n compactHorizontalFast(out, cols, false);\n return out;\n }\n};\n\n/**\n * Fast horizontal compactor that allows overlapping items.\n *\n * Compacts items leftward but allows them to overlap each other.\n */\nexport const fastHorizontalOverlapCompactor: Compactor = {\n ...fastHorizontalCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, cols: number): Layout {\n const out = cloneLayout(layout) as LayoutItem[];\n compactHorizontalFast(out, cols, true);\n return out;\n }\n};\n","/**\n * Wrap Compactor\n *\n * A compaction algorithm that treats grid items like words in a paragraph.\n * Items flow left-to-right, wrapping to the next row when they reach\n * the grid edge.\n *\n * When dragging:\n * - Moving an item earlier in the sequence shifts other items down/right\n * - Moving an item later in the sequence shifts other items up/left\n *\n * This creates a natural reordering behavior similar to drag-and-drop\n * in file managers or card layouts.\n *\n * Based on the algorithm from PR #1773 by John Thomson (@JohnThomson).\n *\n * @example\n * ```tsx\n * import { wrapCompactor } from 'react-grid-layout/extras';\n *\n * <GridLayout\n * compactor={wrapCompactor}\n * layout={layout}\n * // ...\n * />\n * ```\n */\n\nimport type { Compactor, Layout, LayoutItem, Mutable } from \"../core/types.js\";\nimport { cloneLayout, cloneLayoutItem } from \"../core/layout.js\";\n\n/**\n * Sort items in wrap order: left-to-right, top-to-bottom.\n * This is the visual reading order for wrapped content.\n */\nfunction sortByWrapOrder(layout: Layout): LayoutItem[] {\n return [...layout].sort((a, b) => {\n // Primary: top-to-bottom (by row)\n if (a.y !== b.y) return a.y - b.y;\n // Secondary: left-to-right (by column)\n return a.x - b.x;\n });\n}\n\n/**\n * Convert a linear wrap position back to x,y coordinates.\n */\nfunction fromWrapPosition(pos: number, cols: number): { x: number; y: number } {\n return {\n x: pos % cols,\n y: Math.floor(pos / cols)\n };\n}\n\n/**\n * Compact items in wrap order, filling gaps from left-to-right, top-to-bottom.\n * All items are assumed to be 1x1 for wrap mode to work correctly.\n */\nfunction compactWrap(layout: Layout, cols: number): LayoutItem[] {\n if (layout.length === 0) return [];\n\n const sorted = sortByWrapOrder(layout);\n const out: LayoutItem[] = new Array(layout.length);\n const statics = sorted.filter(item => item.static);\n\n // Track which positions are occupied by static items\n const staticPositions = new Set<number>();\n for (const s of statics) {\n // For static items, mark all cells they occupy\n for (let dy = 0; dy < s.h; dy++) {\n for (let dx = 0; dx < s.w; dx++) {\n staticPositions.add((s.y + dy) * cols + (s.x + dx));\n }\n }\n }\n\n let nextPos = 0;\n\n for (let i = 0; i < sorted.length; i++) {\n const sortedItem = sorted[i];\n if (sortedItem === undefined) continue;\n\n const l = cloneLayoutItem(sortedItem);\n\n if (l.static) {\n // Static items stay in place\n const originalIndex = layout.indexOf(sortedItem);\n out[originalIndex] = l;\n l.moved = false;\n continue;\n }\n\n // Find next available position that doesn't conflict with statics\n while (staticPositions.has(nextPos)) {\n nextPos++;\n }\n\n // For items larger than 1x1, we need to check if the full item fits\n const { x, y } = fromWrapPosition(nextPos, cols);\n\n // Check if item would overflow the row\n if (x + l.w > cols) {\n // Move to start of next row\n nextPos = (y + 1) * cols;\n // Skip any static positions on the new row\n while (staticPositions.has(nextPos)) {\n nextPos++;\n }\n }\n\n const newCoords = fromWrapPosition(nextPos, cols);\n (l as Mutable<LayoutItem>).x = newCoords.x;\n (l as Mutable<LayoutItem>).y = newCoords.y;\n\n // Advance past this item\n nextPos += l.w;\n\n const originalIndex = layout.indexOf(sortedItem);\n out[originalIndex] = l;\n l.moved = false;\n }\n\n return out;\n}\n\n/**\n * Wrap compactor - arranges items like words in a paragraph.\n *\n * Items flow left-to-right and wrap to the next row when they\n * reach the grid edge. Dragging an item reorders the sequence,\n * with other items shifting to maintain the flow.\n *\n * Works best with uniformly-sized items (especially 1x1), but\n * handles larger items by ensuring they fit within row bounds.\n */\nexport const wrapCompactor: Compactor = {\n type: \"wrap\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n return compactWrap(layout, cols);\n }\n};\n\n/**\n * Wrap compactor that allows overlapping items.\n */\nexport const wrapOverlapCompactor: Compactor = {\n ...wrapCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, _cols: number): Layout {\n // With overlap allowed, just clone without compacting\n return cloneLayout(layout);\n }\n};\n"]}
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
{"version":3,"sources":["../src/legacy/ReactGridLayout.tsx","../src/legacy/ResponsiveReactGridLayout.tsx","../src/react/components/WidthProvider.tsx"],"names":["absoluteStrategy","createScaledStrategy","transformStrategy","getCompactor","defaultConstraints","containerBounds","jsx","GridLayout","Respon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MAAA,MAAM,QAAA,GAAW,IAAI,cAAA,CAAe,CAAA,OAAA,KAAW;AAC7C,QAAA,IAAI,OAAA,CAAQ,CAAC,CAAA,EAAG;AACd,UAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,CAAC,CAAA,CAAE,WAAA,CAAY,KAAA;AACxC,UAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,QACnB;AAAA,MACF,CAAC,CAAA;AAED,MAAA,QAAA,CAAS,QAAQ,IAAI,CAAA;AACrB,MAAA,iBAAA,CAAkB,OAAA,GAAU,QAAA;AAE5B,MAAA,OAAO,MAAM;AACX,QAAA,QAAA,CAAS,UAAU,IAAI,CAAA;AACvB,QAAA,QAAA,CAAS,UAAA,EAAW;AAAA,MACtB,CAAA;AAAA,IACF,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAGZ,IAAA,IAAI,kBAAA,IAAsB,CAAC,OAAA,EAAS;AAClC,MAAA,uBACEL,cAAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,SAAA,EAAWM,qBAAA,CAAK,SAAA,EAAW,eAAe,CAAA;AAAA,UAC1C,KAAA;AAAA,UACA,GAAA,EAAK;AAAA;AAAA,OACP;AAAA,IAEJ;AAEA,IAAA,uBACEN,cAAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,QAAA,EAAU,UAAA;AAAA,QACV,SAAA;AAAA,QACA,KAAA;AAAA,QACC,GAAI,IAAA;AAAA,QACL;AAAA;AAAA,KACF;AAAA,EAEJ;AAEA,EAAA,oBAAA,CAAqB,cAAc,CAAA,cAAA,EAAiB,iBAAA,CAAkB,WAAA,IAAe,iBAAA,CAAkB,QAAQ,WAAW,CAAA,CAAA,CAAA;AAE1H,EAAA,OAAO,oBAAA;AACT","file":"legacy.js","sourcesContent":["/**\n * Legacy ReactGridLayout wrapper\n *\n * This component wraps the new TypeScript GridLayout to provide\n * backwards compatibility with the v1 API by converting flat props\n * to the new composable interface format.\n */\n\nimport React from \"react\";\nimport {\n GridLayout,\n type GridLayoutProps\n} from \"../react/components/GridLayout.js\";\nimport type {\n Layout,\n LayoutItem,\n CompactType,\n ResizeHandleAxis,\n GridConfig,\n DragConfig,\n ResizeConfig,\n DropConfig,\n PositionStrategy,\n LayoutConstraint\n} from \"../core/types.js\";\nimport { getCompactor } from \"../core/compactors.js\";\nimport {\n transformStrategy,\n absoluteStrategy,\n createScaledStrategy\n} from \"../core/position.js\";\nimport { defaultConstraints, containerBounds } from \"../core/constraints.js\";\n\n// ============================================================================\n// Legacy Props Interface\n// ============================================================================\n\n/**\n * Legacy props interface for backwards compatibility with v1 API.\n * These flat props are converted to composable interfaces internally.\n */\nexport interface LegacyReactGridLayoutProps {\n // Required\n children: React.ReactNode;\n width: number;\n\n // Grid measurement (→ gridConfig)\n cols?: number;\n rowHeight?: number;\n maxRows?: number;\n margin?: readonly [number, number];\n containerPadding?: readonly [number, number] | null;\n\n // Layout data\n layout?: Layout;\n droppingItem?: LayoutItem;\n\n // Compaction (→ compactor)\n compactType?: CompactType;\n preventCollision?: boolean;\n allowOverlap?: boolean;\n /** @deprecated Use compactType instead */\n verticalCompact?: boolean;\n\n // Drag behavior (→ dragConfig)\n isDraggable?: boolean;\n isBounded?: boolean;\n draggableHandle?: string;\n draggableCancel?: string;\n\n // Resize behavior (→ resizeConfig)\n isResizable?: boolean;\n resizeHandles?: ResizeHandleAxis[];\n resizeHandle?:\n | React.ReactElement\n | ((\n axis: ResizeHandleAxis,\n ref: React.Ref<HTMLElement>\n ) => React.ReactElement);\n\n // Drop behavior (→ dropConfig)\n isDroppable?: boolean;\n\n // Position (→ positionStrategy)\n useCSSTransforms?: boolean;\n transformScale?: number;\n\n // Container props (passed through)\n autoSize?: boolean;\n className?: string;\n style?: React.CSSProperties;\n innerRef?: React.Ref<HTMLDivElement>;\n\n // Callbacks (passed through)\n onLayoutChange?: (layout: Layout) => void;\n onDragStart?: GridLayoutProps[\"onDragStart\"];\n onDrag?: GridLayoutProps[\"onDrag\"];\n onDragStop?: GridLayoutProps[\"onDragStop\"];\n onResizeStart?: GridLayoutProps[\"onResizeStart\"];\n onResize?: GridLayoutProps[\"onResize\"];\n onResizeStop?: GridLayoutProps[\"onResizeStop\"];\n onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;\n onDropDragOver?: (\n e: React.DragEvent\n ) => { w?: number; h?: number } | false | void;\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * ReactGridLayout - Legacy wrapper component\n *\n * Converts v1 flat props to v2 composable interfaces for backwards compatibility.\n */\nfunction ReactGridLayout(props: LegacyReactGridLayoutProps) {\n const {\n // Required\n children,\n width,\n\n // Grid measurement\n cols = 12,\n rowHeight = 150,\n maxRows = Infinity,\n margin = [10, 10],\n containerPadding = null,\n\n // Layout data\n layout,\n droppingItem,\n\n // Compaction\n compactType: compactTypeProp,\n preventCollision = false,\n allowOverlap = false,\n verticalCompact,\n\n // Drag behavior\n isDraggable = true,\n isBounded = false,\n draggableHandle,\n draggableCancel,\n\n // Resize behavior\n isResizable = true,\n resizeHandles = [\"se\"],\n resizeHandle,\n\n // Drop behavior\n isDroppable = false,\n\n // Position\n useCSSTransforms = true,\n transformScale = 1,\n\n // Container props\n autoSize,\n className,\n style,\n innerRef,\n\n // Callbacks\n onLayoutChange,\n onDragStart,\n onDrag,\n onDragStop,\n onResizeStart,\n onResize,\n onResizeStop,\n onDrop,\n onDropDragOver\n } = props;\n\n // Handle deprecated verticalCompact prop\n let compactType: CompactType =\n compactTypeProp === undefined ? \"vertical\" : compactTypeProp;\n if (verticalCompact === false) {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n console.warn(\n \"`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. \" +\n 'Use `compactType`: \"horizontal\" | \"vertical\" | null.'\n );\n }\n compactType = null;\n }\n\n // Convert flat props to composable interfaces\n\n const gridConfig: Partial<GridConfig> = {\n cols,\n rowHeight,\n maxRows,\n margin,\n containerPadding\n };\n\n const dragConfig: Partial<DragConfig> = {\n enabled: isDraggable,\n bounded: isBounded,\n handle: draggableHandle,\n cancel: draggableCancel,\n // Set threshold to 0 for backwards compatibility with v1 API\n // v2 API defaults to 3px threshold (fixes #1341, #1401)\n threshold: 0\n };\n\n const resizeConfig: Partial<ResizeConfig> = {\n enabled: isResizable,\n handles: resizeHandles,\n handleComponent: resizeHandle\n };\n\n const dropConfig: Partial<DropConfig> = {\n enabled: isDroppable\n };\n\n // Build position strategy\n let positionStrategy: PositionStrategy;\n if (!useCSSTransforms) {\n positionStrategy = absoluteStrategy;\n } else if (transformScale !== 1) {\n positionStrategy = createScaledStrategy(transformScale);\n } else {\n positionStrategy = transformStrategy;\n }\n\n // Get compactor from type and options\n const compactor = getCompactor(compactType, allowOverlap, preventCollision);\n\n // Build constraints array based on legacy props\n // When isBounded is true, add containerBounds constraint\n const constraints: LayoutConstraint[] = isBounded\n ? [...defaultConstraints, containerBounds]\n : defaultConstraints;\n\n return (\n <GridLayout\n width={width}\n gridConfig={gridConfig}\n dragConfig={dragConfig}\n resizeConfig={resizeConfig}\n dropConfig={dropConfig}\n positionStrategy={positionStrategy}\n compactor={compactor}\n constraints={constraints}\n layout={layout}\n droppingItem={droppingItem}\n autoSize={autoSize}\n className={className}\n style={style}\n innerRef={innerRef}\n onLayoutChange={onLayoutChange}\n onDragStart={onDragStart}\n onDrag={onDrag}\n onDragStop={onDragStop}\n onResizeStart={onResizeStart}\n onResize={onResize}\n onResizeStop={onResizeStop}\n onDrop={onDrop}\n onDropDragOver={onDropDragOver}\n >\n {children}\n </GridLayout>\n );\n}\n\n// Static properties for backwards compatibility\nReactGridLayout.displayName = \"ReactGridLayout\";\n\nexport default ReactGridLayout;\nexport { ReactGridLayout };\n","/**\n * Legacy ResponsiveReactGridLayout wrapper\n *\n * This component wraps the new TypeScript ResponsiveGridLayout to provide\n * backwards compatibility with the v1 API by converting flat props\n * to the new composable interface format.\n */\n\nimport React from \"react\";\nimport {\n ResponsiveGridLayout,\n type ResponsiveGridLayoutProps\n} from \"../react/components/ResponsiveGridLayout.js\";\nimport type {\n Layout,\n LayoutItem,\n CompactType,\n Breakpoint,\n Breakpoints,\n ResponsiveLayouts,\n ResizeHandleAxis,\n DragConfig,\n ResizeConfig,\n DropConfig,\n PositionStrategy\n} from \"../core/types.js\";\nimport { getCompactor } from \"../core/compactors.js\";\nimport {\n transformStrategy,\n absoluteStrategy,\n createScaledStrategy\n} from \"../core/position.js\";\n\n// ============================================================================\n// Legacy Props Interface\n// ============================================================================\n\n/**\n * Legacy props interface for backwards compatibility with v1 API.\n * These flat props are converted to composable interfaces internally.\n */\nexport interface LegacyResponsiveReactGridLayoutProps<\n B extends Breakpoint = string\n> {\n // Required\n children: React.ReactNode;\n width: number;\n\n // Responsive-specific\n breakpoint?: B;\n breakpoints?: Breakpoints<B>;\n cols?: Breakpoints<B>;\n layouts?: ResponsiveLayouts<B>;\n onBreakpointChange?: (newBreakpoint: B, cols: number) => void;\n onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;\n onWidthChange?: (\n containerWidth: number,\n margin: readonly [number, number],\n cols: number,\n containerPadding: readonly [number, number] | null\n ) => void;\n\n // Grid measurement\n rowHeight?: number;\n maxRows?: number;\n margin?:\n | readonly [number, number]\n | Partial<Record<B, readonly [number, number]>>;\n containerPadding?:\n | readonly [number, number]\n | Partial<Record<B, readonly [number, number] | null>>\n | null;\n\n // Layout data\n droppingItem?: LayoutItem;\n\n // Compaction (→ compactor)\n compactType?: CompactType;\n preventCollision?: boolean;\n allowOverlap?: boolean;\n /** @deprecated Use compactType instead */\n verticalCompact?: boolean;\n\n // Drag behavior (→ dragConfig)\n isDraggable?: boolean;\n isBounded?: boolean;\n draggableHandle?: string;\n draggableCancel?: string;\n\n // Resize behavior (→ resizeConfig)\n isResizable?: boolean;\n resizeHandles?: ResizeHandleAxis[];\n resizeHandle?:\n | React.ReactElement\n | ((\n axis: ResizeHandleAxis,\n ref: React.Ref<HTMLElement>\n ) => React.ReactElement);\n\n // Drop behavior (→ dropConfig)\n isDroppable?: boolean;\n\n // Position (→ positionStrategy)\n useCSSTransforms?: boolean;\n transformScale?: number;\n\n // Container props (passed through)\n autoSize?: boolean;\n className?: string;\n style?: React.CSSProperties;\n innerRef?: React.Ref<HTMLDivElement>;\n\n // Callbacks (passed through)\n onDragStart?: ResponsiveGridLayoutProps<B>[\"onDragStart\"];\n onDrag?: ResponsiveGridLayoutProps<B>[\"onDrag\"];\n onDragStop?: ResponsiveGridLayoutProps<B>[\"onDragStop\"];\n onResizeStart?: ResponsiveGridLayoutProps<B>[\"onResizeStart\"];\n onResize?: ResponsiveGridLayoutProps<B>[\"onResize\"];\n onResizeStop?: ResponsiveGridLayoutProps<B>[\"onResizeStop\"];\n onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;\n onDropDragOver?: (\n e: React.DragEvent\n ) => { w?: number; h?: number } | false | void;\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * ResponsiveReactGridLayout - Legacy wrapper component\n *\n * Converts v1 flat props to v2 composable interfaces for backwards compatibility.\n */\nfunction ResponsiveReactGridLayout<B extends Breakpoint = string>(\n props: LegacyResponsiveReactGridLayoutProps<B>\n) {\n const {\n // Required\n children,\n width,\n\n // Responsive-specific\n breakpoint,\n breakpoints,\n cols,\n layouts,\n onBreakpointChange,\n onLayoutChange,\n onWidthChange,\n\n // Grid measurement\n rowHeight,\n maxRows,\n margin,\n containerPadding,\n\n // Layout data\n droppingItem,\n\n // Compaction\n compactType: compactTypeProp,\n preventCollision = false,\n allowOverlap = false,\n verticalCompact,\n\n // Drag behavior\n isDraggable = true,\n isBounded = false,\n draggableHandle,\n draggableCancel,\n\n // Resize behavior\n isResizable = true,\n resizeHandles = [\"se\"],\n resizeHandle,\n\n // Drop behavior\n isDroppable = false,\n\n // Position\n useCSSTransforms = true,\n transformScale = 1,\n\n // Container props\n autoSize,\n className,\n style,\n innerRef,\n\n // Callbacks\n onDragStart,\n onDrag,\n onDragStop,\n onResizeStart,\n onResize,\n onResizeStop,\n onDrop,\n onDropDragOver\n } = props;\n\n // Handle deprecated verticalCompact prop\n let compactType: CompactType =\n compactTypeProp === undefined ? \"vertical\" : compactTypeProp;\n if (verticalCompact === false) {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n console.warn(\n \"`verticalCompact` on <ResponsiveReactGridLayout> is deprecated and will be removed soon. \" +\n 'Use `compactType`: \"horizontal\" | \"vertical\" | null.'\n );\n }\n compactType = null;\n }\n\n // Convert flat props to composable interfaces\n\n const dragConfig: Partial<DragConfig> = {\n enabled: isDraggable,\n bounded: isBounded,\n handle: draggableHandle,\n cancel: draggableCancel\n };\n\n const resizeConfig: Partial<ResizeConfig> = {\n enabled: isResizable,\n handles: resizeHandles,\n handleComponent: resizeHandle\n };\n\n const dropConfig: Partial<DropConfig> = {\n enabled: isDroppable\n };\n\n // Build position strategy\n let positionStrategy: PositionStrategy;\n if (!useCSSTransforms) {\n positionStrategy = absoluteStrategy;\n } else if (transformScale !== 1) {\n positionStrategy = createScaledStrategy(transformScale);\n } else {\n positionStrategy = transformStrategy;\n }\n\n // Get compactor from type and options\n const compactor = getCompactor(compactType, allowOverlap, preventCollision);\n\n return (\n <ResponsiveGridLayout<B>\n width={width}\n breakpoint={breakpoint}\n breakpoints={breakpoints}\n cols={cols}\n layouts={layouts}\n rowHeight={rowHeight}\n maxRows={maxRows}\n margin={margin}\n containerPadding={containerPadding}\n compactor={compactor}\n dragConfig={dragConfig}\n resizeConfig={resizeConfig}\n dropConfig={dropConfig}\n positionStrategy={positionStrategy}\n droppingItem={droppingItem}\n autoSize={autoSize}\n className={className}\n style={style}\n innerRef={innerRef}\n onBreakpointChange={onBreakpointChange}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n onDragStart={onDragStart}\n onDrag={onDrag}\n onDragStop={onDragStop}\n onResizeStart={onResizeStart}\n onResize={onResize}\n onResizeStop={onResizeStop}\n onDrop={onDrop}\n onDropDragOver={onDropDragOver}\n >\n {children}\n </ResponsiveGridLayout>\n );\n}\n\n// Static properties for backwards compatibility\nResponsiveReactGridLayout.displayName = \"ResponsiveReactGridLayout\";\n\nexport default ResponsiveReactGridLayout;\nexport { ResponsiveReactGridLayout, ResponsiveReactGridLayout as Responsive };\n","/**\n * WidthProvider HOC\n *\n * A Higher-Order Component that provides width measurement to grid layouts.\n * This wraps any component and provides the container width as a prop.\n */\n\nimport React, { useState, useRef, useEffect, type ComponentType } from \"react\";\nimport clsx from \"clsx\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface WidthProviderProps {\n /** If true, will not render children until mounted */\n measureBeforeMount?: boolean;\n /** Additional class name */\n className?: string;\n /** Additional styles */\n style?: React.CSSProperties;\n}\n\ntype WithWidthProps<P> = Omit<P, \"width\"> & WidthProviderProps;\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst layoutClassName = \"react-grid-layout\";\n\n// ============================================================================\n// WidthProvider HOC\n// ============================================================================\n\n/**\n * WidthProvider - HOC that provides container width\n *\n * A simple HOC that provides facility for listening to container resizes.\n * Wraps the provided component and passes down a `width` prop.\n *\n * @example\n * ```tsx\n * import { GridLayout, WidthProvider } from 'react-grid-layout';\n *\n * const GridLayoutWithWidth = WidthProvider(GridLayout);\n *\n * function MyGrid() {\n * return (\n * <GridLayoutWithWidth cols={12} rowHeight={30}>\n * <div key=\"a\">a</div>\n * </GridLayoutWithWidth>\n * );\n * }\n * ```\n */\nexport function WidthProvider<P extends { width: number }>(\n ComposedComponent: ComponentType<P>\n): ComponentType<WithWidthProps<P>> {\n function WidthProviderWrapper(props: WithWidthProps<P>) {\n const { measureBeforeMount = false, className, style, ...rest } = props;\n\n const [width, setWidth] = useState(1280);\n const [mounted, setMounted] = useState(false);\n const elementRef = useRef<HTMLDivElement>(null);\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n // Set mounted state on first render\n useEffect(() => {\n setMounted(true);\n }, []);\n\n // Set up ResizeObserver - re-runs when mounted changes to observe the new element\n // This fixes measureBeforeMount where the ref changes from placeholder to composed component\n useEffect(() => {\n const node = elementRef.current;\n if (!(node instanceof HTMLElement)) return;\n\n const observer = new ResizeObserver(entries => {\n if (entries[0]) {\n const newWidth = entries[0].contentRect.width;\n setWidth(newWidth);\n }\n });\n\n observer.observe(node);\n resizeObserverRef.current = observer;\n\n return () => {\n observer.unobserve(node);\n observer.disconnect();\n };\n }, [mounted]);\n\n // If measureBeforeMount is true and not yet mounted, render placeholder\n if (measureBeforeMount && !mounted) {\n return (\n <div\n className={clsx(className, layoutClassName)}\n style={style}\n ref={elementRef}\n />\n );\n }\n\n return (\n <ComposedComponent\n innerRef={elementRef}\n className={className}\n style={style}\n {...(rest as unknown as P)}\n width={width}\n />\n );\n }\n\n WidthProviderWrapper.displayName = `WidthProvider(${ComposedComponent.displayName || ComposedComponent.name || \"Component\"})`;\n\n return WidthProviderWrapper;\n}\n\nexport default WidthProvider;\n"]}
{"version":3,"sources":["../src/legacy/ReactGridLayout.tsx","../src/legacy/ResponsiveReactGridLayout.tsx","../src/react/components/WidthProvider.tsx"],"names":["jsx"],"mappings":";;;;;;;AAoHA,SAAS,gBAAgB,KAAA,EAAmC;AAC1D,EAAA,MAAM;AAAA;AAAA,IAEJ,QAAA;AAAA,IACA,KAAA;AAAA;AAAA,IAGA,IAAA,GAAO,EAAA;AAAA,IACP,SAAA,GAAY,GAAA;AAAA,IACZ,OAAA,GAAU,QAAA;AAAA,IACV,MAAA,GAAS,CAAC,EAAA,EAAI,EAAE,CAAA;AAAA,IAChB,gBAAA,GAAmB,IAAA;AAAA;AAAA,IAGnB,MAAA;AAAA,IACA,YAAA;AAAA;AAAA,IAGA,WAAA,EAAa,eAAA;AAAA,IACb,gBAAA,GAAmB,KAAA;AAAA,IACnB,YAAA,GAAe,KAAA;AAAA,IACf,eAAA;AAAA;AAAA,IAGA,WAAA,GAAc,IAAA;AAAA,IACd,SAAA,GAAY,KAAA;AAAA,IACZ,eAAA;AAAA,IACA,eAAA;AAAA;AAAA,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A,UACC,SAAA,EAAW,IAAA,CAAK,SAAA,EAAW,eAAe,CAAA;AAAA,UAC1C,KAAA;AAAA,UACA,GAAA,EAAK;AAAA;AAAA,OACP;AAAA,IAEJ;AAEA,IAAA,uBACEA,GAAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,QAAA,EAAU,UAAA;AAAA,QACV,SAAA;AAAA,QACA,KAAA;AAAA,QACC,GAAI,IAAA;AAAA,QACL;AAAA;AAAA,KACF;AAAA,EAEJ;AAEA,EAAA,oBAAA,CAAqB,cAAc,CAAA,cAAA,EAAiB,iBAAA,CAAkB,WAAA,IAAe,iBAAA,CAAkB,QAAQ,WAAW,CAAA,CAAA,CAAA;AAE1H,EAAA,OAAO,oBAAA;AACT","file":"legacy.mjs","sourcesContent":["/**\n * Legacy ReactGridLayout wrapper\n *\n * This component wraps the new TypeScript GridLayout to provide\n * backwards compatibility with the v1 API by converting flat props\n * to the new composable interface format.\n */\n\nimport React from \"react\";\nimport {\n GridLayout,\n type GridLayoutProps\n} from \"../react/components/GridLayout.js\";\nimport type {\n Layout,\n LayoutItem,\n CompactType,\n ResizeHandleAxis,\n GridConfig,\n DragConfig,\n ResizeConfig,\n DropConfig,\n PositionStrategy,\n LayoutConstraint\n} from \"../core/types.js\";\nimport { getCompactor } from \"../core/compactors.js\";\nimport {\n transformStrategy,\n absoluteStrategy,\n createScaledStrategy\n} from \"../core/position.js\";\nimport { defaultConstraints, containerBounds } from \"../core/constraints.js\";\n\n// ============================================================================\n// Legacy Props Interface\n// ============================================================================\n\n/**\n * Legacy props interface for backwards compatibility with v1 API.\n * These flat props are converted to composable interfaces internally.\n */\nexport interface LegacyReactGridLayoutProps {\n // Required\n children: React.ReactNode;\n width: number;\n\n // Grid measurement (→ gridConfig)\n cols?: number;\n rowHeight?: number;\n maxRows?: number;\n margin?: readonly [number, number];\n containerPadding?: readonly [number, number] | null;\n\n // Layout data\n layout?: Layout;\n droppingItem?: LayoutItem;\n\n // Compaction (→ compactor)\n compactType?: CompactType;\n preventCollision?: boolean;\n allowOverlap?: boolean;\n /** @deprecated Use compactType instead */\n verticalCompact?: boolean;\n\n // Drag behavior (→ dragConfig)\n isDraggable?: boolean;\n isBounded?: boolean;\n draggableHandle?: string;\n draggableCancel?: string;\n\n // Resize behavior (→ resizeConfig)\n isResizable?: boolean;\n resizeHandles?: ResizeHandleAxis[];\n resizeHandle?:\n | React.ReactElement\n | ((\n axis: ResizeHandleAxis,\n ref: React.Ref<HTMLElement>\n ) => React.ReactElement);\n\n // Drop behavior (→ dropConfig)\n isDroppable?: boolean;\n\n // Position (→ positionStrategy)\n useCSSTransforms?: boolean;\n transformScale?: number;\n\n // Container props (passed through)\n autoSize?: boolean;\n className?: string;\n style?: React.CSSProperties;\n innerRef?: React.Ref<HTMLDivElement>;\n\n // Callbacks (passed through)\n onLayoutChange?: (layout: Layout) => void;\n onDragStart?: GridLayoutProps[\"onDragStart\"];\n onDrag?: GridLayoutProps[\"onDrag\"];\n onDragStop?: GridLayoutProps[\"onDragStop\"];\n onResizeStart?: GridLayoutProps[\"onResizeStart\"];\n onResize?: GridLayoutProps[\"onResize\"];\n onResizeStop?: GridLayoutProps[\"onResizeStop\"];\n onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;\n onDropDragOver?: (\n e: React.DragEvent\n ) => { w?: number; h?: number } | false | void;\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * ReactGridLayout - Legacy wrapper component\n *\n * Converts v1 flat props to v2 composable interfaces for backwards compatibility.\n */\nfunction ReactGridLayout(props: LegacyReactGridLayoutProps) {\n const {\n // Required\n children,\n width,\n\n // Grid measurement\n cols = 12,\n rowHeight = 150,\n maxRows = Infinity,\n margin = [10, 10],\n containerPadding = null,\n\n // Layout data\n layout,\n droppingItem,\n\n // Compaction\n compactType: compactTypeProp,\n preventCollision = false,\n allowOverlap = false,\n verticalCompact,\n\n // Drag behavior\n isDraggable = true,\n isBounded = false,\n draggableHandle,\n draggableCancel,\n\n // Resize behavior\n isResizable = true,\n resizeHandles = [\"se\"],\n resizeHandle,\n\n // Drop behavior\n isDroppable = false,\n\n // Position\n useCSSTransforms = true,\n transformScale = 1,\n\n // Container props\n autoSize,\n className,\n style,\n innerRef,\n\n // Callbacks\n onLayoutChange,\n onDragStart,\n onDrag,\n onDragStop,\n onResizeStart,\n onResize,\n onResizeStop,\n onDrop,\n onDropDragOver\n } = props;\n\n // Handle deprecated verticalCompact prop\n let compactType: CompactType =\n compactTypeProp === undefined ? \"vertical\" : compactTypeProp;\n if (verticalCompact === false) {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n console.warn(\n \"`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. \" +\n 'Use `compactType`: \"horizontal\" | \"vertical\" | null.'\n );\n }\n compactType = null;\n }\n\n // Convert flat props to composable interfaces\n\n const gridConfig: Partial<GridConfig> = {\n cols,\n rowHeight,\n maxRows,\n margin,\n containerPadding\n };\n\n const dragConfig: Partial<DragConfig> = {\n enabled: isDraggable,\n bounded: isBounded,\n handle: draggableHandle,\n cancel: draggableCancel,\n // Set threshold to 0 for backwards compatibility with v1 API\n // v2 API defaults to 3px threshold (fixes #1341, #1401)\n threshold: 0\n };\n\n const resizeConfig: Partial<ResizeConfig> = {\n enabled: isResizable,\n handles: resizeHandles,\n handleComponent: resizeHandle\n };\n\n const dropConfig: Partial<DropConfig> = {\n enabled: isDroppable\n };\n\n // Build position strategy\n let positionStrategy: PositionStrategy;\n if (!useCSSTransforms) {\n positionStrategy = absoluteStrategy;\n } else if (transformScale !== 1) {\n positionStrategy = createScaledStrategy(transformScale);\n } else {\n positionStrategy = transformStrategy;\n }\n\n // Get compactor from type and options\n const compactor = getCompactor(compactType, allowOverlap, preventCollision);\n\n // Build constraints array based on legacy props\n // When isBounded is true, add containerBounds constraint\n const constraints: LayoutConstraint[] = isBounded\n ? [...defaultConstraints, containerBounds]\n : defaultConstraints;\n\n return (\n <GridLayout\n width={width}\n gridConfig={gridConfig}\n dragConfig={dragConfig}\n resizeConfig={resizeConfig}\n dropConfig={dropConfig}\n positionStrategy={positionStrategy}\n compactor={compactor}\n constraints={constraints}\n layout={layout}\n droppingItem={droppingItem}\n autoSize={autoSize}\n className={className}\n style={style}\n innerRef={innerRef}\n onLayoutChange={onLayoutChange}\n onDragStart={onDragStart}\n onDrag={onDrag}\n onDragStop={onDragStop}\n onResizeStart={onResizeStart}\n onResize={onResize}\n onResizeStop={onResizeStop}\n onDrop={onDrop}\n onDropDragOver={onDropDragOver}\n >\n {children}\n </GridLayout>\n );\n}\n\n// Static properties for backwards compatibility\nReactGridLayout.displayName = \"ReactGridLayout\";\n\nexport default ReactGridLayout;\nexport { ReactGridLayout };\n","/**\n * Legacy ResponsiveReactGridLayout wrapper\n *\n * This component wraps the new TypeScript ResponsiveGridLayout to provide\n * backwards compatibility with the v1 API by converting flat props\n * to the new composable interface format.\n */\n\nimport React from \"react\";\nimport {\n ResponsiveGridLayout,\n type ResponsiveGridLayoutProps\n} from \"../react/components/ResponsiveGridLayout.js\";\nimport type {\n Layout,\n LayoutItem,\n CompactType,\n Breakpoint,\n Breakpoints,\n ResponsiveLayouts,\n ResizeHandleAxis,\n DragConfig,\n ResizeConfig,\n DropConfig,\n PositionStrategy\n} from \"../core/types.js\";\nimport { getCompactor } from \"../core/compactors.js\";\nimport {\n transformStrategy,\n absoluteStrategy,\n createScaledStrategy\n} from \"../core/position.js\";\n\n// ============================================================================\n// Legacy Props Interface\n// ============================================================================\n\n/**\n * Legacy props interface for backwards compatibility with v1 API.\n * These flat props are converted to composable interfaces internally.\n */\nexport interface LegacyResponsiveReactGridLayoutProps<\n B extends Breakpoint = string\n> {\n // Required\n children: React.ReactNode;\n width: number;\n\n // Responsive-specific\n breakpoint?: B;\n breakpoints?: Breakpoints<B>;\n cols?: Breakpoints<B>;\n layouts?: ResponsiveLayouts<B>;\n onBreakpointChange?: (newBreakpoint: B, cols: number) => void;\n onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;\n onWidthChange?: (\n containerWidth: number,\n margin: readonly [number, number],\n cols: number,\n containerPadding: readonly [number, number] | null\n ) => void;\n\n // Grid measurement\n rowHeight?: number;\n maxRows?: number;\n margin?:\n | readonly [number, number]\n | Partial<Record<B, readonly [number, number]>>;\n containerPadding?:\n | readonly [number, number]\n | Partial<Record<B, readonly [number, number] | null>>\n | null;\n\n // Layout data\n droppingItem?: LayoutItem;\n\n // Compaction (→ compactor)\n compactType?: CompactType;\n preventCollision?: boolean;\n allowOverlap?: boolean;\n /** @deprecated Use compactType instead */\n verticalCompact?: boolean;\n\n // Drag behavior (→ dragConfig)\n isDraggable?: boolean;\n isBounded?: boolean;\n draggableHandle?: string;\n draggableCancel?: string;\n\n // Resize behavior (→ resizeConfig)\n isResizable?: boolean;\n resizeHandles?: ResizeHandleAxis[];\n resizeHandle?:\n | React.ReactElement\n | ((\n axis: ResizeHandleAxis,\n ref: React.Ref<HTMLElement>\n ) => React.ReactElement);\n\n // Drop behavior (→ dropConfig)\n isDroppable?: boolean;\n\n // Position (→ positionStrategy)\n useCSSTransforms?: boolean;\n transformScale?: number;\n\n // Container props (passed through)\n autoSize?: boolean;\n className?: string;\n style?: React.CSSProperties;\n innerRef?: React.Ref<HTMLDivElement>;\n\n // Callbacks (passed through)\n onDragStart?: ResponsiveGridLayoutProps<B>[\"onDragStart\"];\n onDrag?: ResponsiveGridLayoutProps<B>[\"onDrag\"];\n onDragStop?: ResponsiveGridLayoutProps<B>[\"onDragStop\"];\n onResizeStart?: ResponsiveGridLayoutProps<B>[\"onResizeStart\"];\n onResize?: ResponsiveGridLayoutProps<B>[\"onResize\"];\n onResizeStop?: ResponsiveGridLayoutProps<B>[\"onResizeStop\"];\n onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;\n onDropDragOver?: (\n e: React.DragEvent\n ) => { w?: number; h?: number } | false | void;\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * ResponsiveReactGridLayout - Legacy wrapper component\n *\n * Converts v1 flat props to v2 composable interfaces for backwards compatibility.\n */\nfunction ResponsiveReactGridLayout<B extends Breakpoint = string>(\n props: LegacyResponsiveReactGridLayoutProps<B>\n) {\n const {\n // Required\n children,\n width,\n\n // Responsive-specific\n breakpoint,\n breakpoints,\n cols,\n layouts,\n onBreakpointChange,\n onLayoutChange,\n onWidthChange,\n\n // Grid measurement\n rowHeight,\n maxRows,\n margin,\n containerPadding,\n\n // Layout data\n droppingItem,\n\n // Compaction\n compactType: compactTypeProp,\n preventCollision = false,\n allowOverlap = false,\n verticalCompact,\n\n // Drag behavior\n isDraggable = true,\n isBounded = false,\n draggableHandle,\n draggableCancel,\n\n // Resize behavior\n isResizable = true,\n resizeHandles = [\"se\"],\n resizeHandle,\n\n // Drop behavior\n isDroppable = false,\n\n // Position\n useCSSTransforms = true,\n transformScale = 1,\n\n // Container props\n autoSize,\n className,\n style,\n innerRef,\n\n // Callbacks\n onDragStart,\n onDrag,\n onDragStop,\n onResizeStart,\n onResize,\n onResizeStop,\n onDrop,\n onDropDragOver\n } = props;\n\n // Handle deprecated verticalCompact prop\n let compactType: CompactType =\n compactTypeProp === undefined ? \"vertical\" : compactTypeProp;\n if (verticalCompact === false) {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n console.warn(\n \"`verticalCompact` on <ResponsiveReactGridLayout> is deprecated and will be removed soon. \" +\n 'Use `compactType`: \"horizontal\" | \"vertical\" | null.'\n );\n }\n compactType = null;\n }\n\n // Convert flat props to composable interfaces\n\n const dragConfig: Partial<DragConfig> = {\n enabled: isDraggable,\n bounded: isBounded,\n handle: draggableHandle,\n cancel: draggableCancel\n };\n\n const resizeConfig: Partial<ResizeConfig> = {\n enabled: isResizable,\n handles: resizeHandles,\n handleComponent: resizeHandle\n };\n\n const dropConfig: Partial<DropConfig> = {\n enabled: isDroppable\n };\n\n // Build position strategy\n let positionStrategy: PositionStrategy;\n if (!useCSSTransforms) {\n positionStrategy = absoluteStrategy;\n } else if (transformScale !== 1) {\n positionStrategy = createScaledStrategy(transformScale);\n } else {\n positionStrategy = transformStrategy;\n }\n\n // Get compactor from type and options\n const compactor = getCompactor(compactType, allowOverlap, preventCollision);\n\n return (\n <ResponsiveGridLayout<B>\n width={width}\n breakpoint={breakpoint}\n breakpoints={breakpoints}\n cols={cols}\n layouts={layouts}\n rowHeight={rowHeight}\n maxRows={maxRows}\n margin={margin}\n containerPadding={containerPadding}\n compactor={compactor}\n dragConfig={dragConfig}\n resizeConfig={resizeConfig}\n dropConfig={dropConfig}\n positionStrategy={positionStrategy}\n droppingItem={droppingItem}\n autoSize={autoSize}\n className={className}\n style={style}\n innerRef={innerRef}\n onBreakpointChange={onBreakpointChange}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n onDragStart={onDragStart}\n onDrag={onDrag}\n onDragStop={onDragStop}\n onResizeStart={onResizeStart}\n onResize={onResize}\n onResizeStop={onResizeStop}\n onDrop={onDrop}\n onDropDragOver={onDropDragOver}\n >\n {children}\n </ResponsiveGridLayout>\n );\n}\n\n// Static properties for backwards compatibility\nResponsiveReactGridLayout.displayName = \"ResponsiveReactGridLayout\";\n\nexport default ResponsiveReactGridLayout;\nexport { ResponsiveReactGridLayout, ResponsiveReactGridLayout as Responsive };\n","/**\n * WidthProvider HOC\n *\n * A Higher-Order Component that provides width measurement to grid layouts.\n * This wraps any component and provides the container width as a prop.\n */\n\nimport React, { useState, useRef, useEffect, type ComponentType } from \"react\";\nimport clsx from \"clsx\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface WidthProviderProps {\n /** If true, will not render children until mounted */\n measureBeforeMount?: boolean;\n /** Additional class name */\n className?: string;\n /** Additional styles */\n style?: React.CSSProperties;\n}\n\ntype WithWidthProps<P> = Omit<P, \"width\"> & WidthProviderProps;\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst layoutClassName = \"react-grid-layout\";\n\n// ============================================================================\n// WidthProvider HOC\n// ============================================================================\n\n/**\n * WidthProvider - HOC that provides container width\n *\n * A simple HOC that provides facility for listening to container resizes.\n * Wraps the provided component and passes down a `width` prop.\n *\n * @example\n * ```tsx\n * import { GridLayout, WidthProvider } from 'react-grid-layout';\n *\n * const GridLayoutWithWidth = WidthProvider(GridLayout);\n *\n * function MyGrid() {\n * return (\n * <GridLayoutWithWidth cols={12} rowHeight={30}>\n * <div key=\"a\">a</div>\n * </GridLayoutWithWidth>\n * );\n * }\n * ```\n */\nexport function WidthProvider<P extends { width: number }>(\n ComposedComponent: ComponentType<P>\n): ComponentType<WithWidthProps<P>> {\n function WidthProviderWrapper(props: WithWidthProps<P>) {\n const { measureBeforeMount = false, className, style, ...rest } = props;\n\n const [width, setWidth] = useState(1280);\n const [mounted, setMounted] = useState(false);\n const elementRef = useRef<HTMLDivElement>(null);\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n // Set mounted state on first render\n useEffect(() => {\n setMounted(true);\n }, []);\n\n // Set up ResizeObserver - re-runs when mounted changes to observe the new element\n // This fixes measureBeforeMount where the ref changes from placeholder to composed component\n useEffect(() => {\n const node = elementRef.current;\n if (!(node instanceof HTMLElement)) return;\n\n const observer = new ResizeObserver(entries => {\n if (entries[0]) {\n const newWidth = entries[0].contentRect.width;\n setWidth(newWidth);\n }\n });\n\n observer.observe(node);\n resizeObserverRef.current = observer;\n\n return () => {\n observer.unobserve(node);\n observer.disconnect();\n };\n }, [mounted]);\n\n // If measureBeforeMount is true and not yet mounted, render placeholder\n if (measureBeforeMount && !mounted) {\n return (\n <div\n className={clsx(className, layoutClassName)}\n style={style}\n ref={elementRef}\n />\n );\n }\n\n return (\n <ComposedComponent\n innerRef={elementRef}\n className={className}\n style={style}\n {...(rest as unknown as P)}\n width={width}\n />\n );\n }\n\n WidthProviderWrapper.displayName = `WidthProvider(${ComposedComponent.displayName || ComposedComponent.name || \"Component\"})`;\n\n return WidthProviderWrapper;\n}\n\nexport default WidthProvider;\n"]}
import { L as Layout, a as LayoutItem, C as CompactType, M as Mutable, c as Compactor, P as Position, d as ResizeHandleAxis, k as PositionStrategy } from './types-BiXsdXr7.mjs';
/**
* Core layout manipulation utilities.
*
* These functions create, modify, and query grid layouts.
* All functions treat layouts as immutable - they return new arrays/objects.
*/
/**
* Get the bottom-most Y coordinate of the layout.
*
* This is the Y position plus height of the lowest item.
*
* @param layout - Layout to measure
* @returns The bottom Y coordinate (0 if layout is empty)
*/
declare function bottom(layout: Layout): number;
/**
* Get a layout item by its ID.
*
* @param layout - Layout to search
* @param id - Item ID to find
* @returns The layout item, or undefined if not found
*/
declare function getLayoutItem(layout: Layout, id: string): LayoutItem | undefined;
/**
* Get all static items from the layout.
*
* Static items cannot be moved or resized by the user.
*
* @param layout - Layout to filter
* @returns Array of static layout items
*/
declare function getStatics(layout: Layout): LayoutItem[];
/**
* Clone a layout item.
*
* Creates a shallow copy with all properties preserved.
* Boolean properties are normalized (undefined becomes false).
*
* @param layoutItem - Item to clone
* @returns A new layout item with the same properties
*/
declare function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem;
/**
* Clone an entire layout.
*
* Creates a new array with cloned items.
*
* @param layout - Layout to clone
* @returns A new layout with cloned items
*/
declare function cloneLayout(layout: Layout): LayoutItem[];
/**
* Replace a layout item in a layout.
*
* Returns a new layout with the item replaced. Other items are not cloned.
*
* @param layout - Layout to modify
* @param layoutItem - New item (matched by `i` property)
* @returns New layout with the item replaced
*/
declare function modifyLayout(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Apply a transformation to a layout item.
*
* Finds the item by key, clones it, applies the callback, and returns
* a new layout with the modified item.
*
* @param layout - Layout to modify
* @param itemKey - Key of the item to modify
* @param cb - Callback that receives the cloned item and returns the modified item
* @returns Tuple of [new layout, modified item or null if not found]
*/
declare function withLayoutItem(layout: Layout, itemKey: string, cb: (item: LayoutItem) => LayoutItem): [LayoutItem[], LayoutItem | null];
/**
* Ensure all layout items fit within the grid bounds.
*
* - Items overflowing right are moved left
* - Items overflowing left are moved to x=0 and clamped to grid width
* - Static items that collide with other statics are moved down
*
* **IMPORTANT**: This function mutates the layout items in place for performance.
* The type signature uses `Mutable<LayoutItem>[]` to make this explicit.
* Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.
*
* @param layout - Layout to correct (items WILL be mutated)
* @param bounds - Grid bounds
* @returns The same layout array (for chaining)
*/
declare function correctBounds(layout: Mutable<LayoutItem>[], bounds: {
cols: number;
}): LayoutItem[];
/**
* Move a layout element to a new position.
*
* Handles collision detection and cascading movements.
* Does not compact the layout - call `compact()` separately.
*
* **Note**: This function mutates the `l` parameter directly for performance.
* The item's x, y, and moved properties will be modified. Callers should
* ideally pass a cloned item if they need to preserve the original.
*
* @param layout - Full layout
* @param l - Item to move (will be mutated)
* @param x - New X position (or undefined to keep current)
* @param y - New Y position (or undefined to keep current)
* @param isUserAction - True if this is a direct user action (affects collision resolution)
* @param preventCollision - True to block movement into occupied space (item snaps back). No effect if allowOverlap is true.
* @param compactType - Compaction type for collision resolution
* @param cols - Number of columns in the grid
* @param allowOverlap - True to allow items to stack on top of each other
* @returns The updated layout
*/
declare function moveElement(layout: Layout, l: LayoutItem, x: number | undefined, y: number | undefined, isUserAction: boolean | undefined, preventCollision: boolean | undefined, compactType: CompactType, cols: number, allowOverlap?: boolean): LayoutItem[];
/**
* Move an item away from a collision.
*
* Attempts to move the item up/left first if there's room,
* otherwise moves it down/right.
*
* @param layout - Full layout
* @param collidesWith - The item being collided with
* @param itemToMove - The item to move away
* @param isUserAction - True if this is a direct user action
* @param compactType - Compaction type
* @param cols - Number of columns
* @returns Updated layout
*/
declare function moveElementAwayFromCollision(layout: Layout, collidesWith: LayoutItem, itemToMove: LayoutItem, isUserAction: boolean | undefined, compactType: CompactType, cols: number): LayoutItem[];
/**
* Validate that a layout has the required properties.
*
* @param layout - Layout to validate
* @param contextName - Name for error messages
* @throws Error if layout is invalid
*/
declare function validateLayout(layout: Layout, contextName?: string): void;
/**
* Compactor implementations.
*
* Compactors are pluggable strategies for removing gaps between grid items.
* Use the Compactor interface to create custom compaction algorithms.
*/
/**
* Resolve a compaction collision by moving items.
*
* Before moving an item to a position, checks if that movement would
* cause collisions and recursively moves those items first.
*
* Useful for implementing custom compactors.
*
* @param layout - Full layout (must be sorted for optimization)
* @param item - Item being moved (will be mutated)
* @param moveToCoord - Target coordinate
* @param axis - Which axis to move on ('x' or 'y')
* @param hasStatics - Whether layout contains static items (disables early break optimization)
*/
declare function resolveCompactionCollision(layout: Layout, item: LayoutItem, moveToCoord: number, axis: "x" | "y", hasStatics?: boolean): void;
/**
* Compact a single item vertically (move up).
*
* Moves the item as far up as possible without colliding.
* Useful for implementing custom vertical compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param fullLayout - Full layout for collision resolution
* @param maxY - Maximum Y to start from
* @returns The compacted item
*/
declare function compactItemVertical(compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number): LayoutItem;
/**
* Compact a single item horizontally (move left).
*
* Moves the item as far left as possible without colliding.
* Wraps to the next row if it overflows.
* Useful for implementing custom horizontal compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param cols - Number of columns in the grid
* @param fullLayout - Full layout for collision resolution
* @returns The compacted item
*/
declare function compactItemHorizontal(compareWith: Layout, l: LayoutItem, cols: number, fullLayout: Layout): LayoutItem;
/**
* Vertical compactor - moves items up to fill gaps.
*
* Items are sorted by row then column, and each item is moved
* as far up as possible without overlapping other items.
*
* This is the default compaction mode for react-grid-layout.
*/
declare const verticalCompactor: Compactor;
/**
* Horizontal compactor - moves items left to fill gaps.
*
* Items are sorted by column then row, and each item is moved
* as far left as possible without overlapping other items.
*/
declare const horizontalCompactor: Compactor;
/**
* No compaction - items stay where placed.
*
* Use this for free-form layouts where items can be placed anywhere.
* Items will not automatically move to fill gaps.
*/
declare const noCompactor: Compactor;
/**
* Vertical compactor that allows overlapping items.
*
* Items compact upward but are allowed to overlap each other.
* Useful for layered layouts or when collision detection is handled externally.
*/
declare const verticalOverlapCompactor: Compactor;
/**
* Horizontal compactor that allows overlapping items.
*/
declare const horizontalOverlapCompactor: Compactor;
/**
* No compaction, with overlapping allowed.
*
* Items stay where placed and can overlap each other.
*/
declare const noOverlapCompactor: Compactor;
/**
* Get a compactor by type.
*
* This is a convenience function for backwards compatibility with the
* string-based compactType API.
*
* Note: For 'wrap' mode, import `wrapCompactor` from 'react-grid-layout/extras'
* and pass it directly to the `compactor` prop. This function returns
* `noCompactor` for 'wrap' type since the wrap compactor is tree-shakeable.
*
* @param compactType - 'vertical', 'horizontal', 'wrap', or null
* @param allowOverlap - Whether to allow overlapping items
* @returns The appropriate Compactor
*/
declare function getCompactor(compactType: CompactType, allowOverlap?: boolean, preventCollision?: boolean): Compactor;
/**
* Position calculation utilities.
*
* These functions convert between grid units and pixel positions,
* and generate CSS styles for grid items.
*/
/**
* Generate CSS transform-based positioning styles.
*
* Using transforms is more performant than top/left positioning
* because it doesn't trigger layout recalculations.
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTransform({ top, left, width, height }: Position): Record<string, string>;
/**
* Generate CSS top/left positioning styles.
*
* Use this when transforms are not suitable (e.g., for printing
* or when transform causes issues with child elements).
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTopLeft({ top, left, width, height }: Position): Record<string, string>;
/**
* Convert a number to a percentage string.
*
* @param num - Number to convert (0-1 range typically)
* @returns Percentage string (e.g., "50%")
*/
declare function perc(num: number): string;
/**
* Resize an item in a specific direction, clamping to container bounds.
*
* This handles the complex logic of resizing from different edges/corners,
* ensuring the item doesn't overflow the container.
*
* @param direction - Which edge/corner is being dragged
* @param currentSize - Current position and size
* @param newSize - Requested new position and size
* @param containerWidth - Width of the container
* @returns Constrained position and size
*/
declare function resizeItemInDirection(direction: ResizeHandleAxis, currentSize: Position, newSize: Position, containerWidth: number): Position;
/**
* CSS transform-based positioning strategy.
*
* Uses CSS transforms for positioning, which is more performant
* as it doesn't trigger layout recalculations.
*
* This is the default strategy.
*/
declare const transformStrategy: PositionStrategy;
/**
* Absolute (top/left) positioning strategy.
*
* Uses CSS top/left for positioning. Use this when CSS transforms
* cause issues (e.g., printing, certain child element positioning).
*/
declare const absoluteStrategy: PositionStrategy;
/**
* Create a scaled transform strategy.
*
* Use this when the grid container is inside a scaled element
* (e.g., `transform: scale(0.5)`). The scale factor adjusts
* drag/resize calculations to account for the parent transform.
*
* @param scale - Scale factor (e.g., 0.5 for half size)
* @returns Position strategy with scaled calculations
*
* @example
* ```tsx
* <div style={{ transform: 'scale(0.5)' }}>
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* </div>
* ```
*/
declare function createScaledStrategy(scale: number): PositionStrategy;
/** Default position strategy (transform-based) */
declare const defaultPositionStrategy: PositionStrategy;
export { absoluteStrategy as A, createScaledStrategy as B, defaultPositionStrategy as C, cloneLayoutItem as a, bottom as b, cloneLayout as c, getCompactor as d, verticalCompactor as e, setTopLeft as f, getLayoutItem as g, horizontalCompactor as h, getStatics as i, modifyLayout as j, correctBounds as k, moveElementAwayFromCollision as l, moveElement as m, noCompactor as n, verticalOverlapCompactor as o, horizontalOverlapCompactor as p, noOverlapCompactor as q, resolveCompactionCollision as r, setTransform as s, compactItemVertical as t, compactItemHorizontal as u, validateLayout as v, withLayoutItem as w, perc as x, resizeItemInDirection as y, transformStrategy as z };
import { L as Layout, a as LayoutItem, C as CompactType, M as Mutable, c as Compactor, P as Position, d as ResizeHandleAxis, k as PositionStrategy } from './types-BiXsdXr7.js';
/**
* Core layout manipulation utilities.
*
* These functions create, modify, and query grid layouts.
* All functions treat layouts as immutable - they return new arrays/objects.
*/
/**
* Get the bottom-most Y coordinate of the layout.
*
* This is the Y position plus height of the lowest item.
*
* @param layout - Layout to measure
* @returns The bottom Y coordinate (0 if layout is empty)
*/
declare function bottom(layout: Layout): number;
/**
* Get a layout item by its ID.
*
* @param layout - Layout to search
* @param id - Item ID to find
* @returns The layout item, or undefined if not found
*/
declare function getLayoutItem(layout: Layout, id: string): LayoutItem | undefined;
/**
* Get all static items from the layout.
*
* Static items cannot be moved or resized by the user.
*
* @param layout - Layout to filter
* @returns Array of static layout items
*/
declare function getStatics(layout: Layout): LayoutItem[];
/**
* Clone a layout item.
*
* Creates a shallow copy with all properties preserved.
* Boolean properties are normalized (undefined becomes false).
*
* @param layoutItem - Item to clone
* @returns A new layout item with the same properties
*/
declare function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem;
/**
* Clone an entire layout.
*
* Creates a new array with cloned items.
*
* @param layout - Layout to clone
* @returns A new layout with cloned items
*/
declare function cloneLayout(layout: Layout): LayoutItem[];
/**
* Replace a layout item in a layout.
*
* Returns a new layout with the item replaced. Other items are not cloned.
*
* @param layout - Layout to modify
* @param layoutItem - New item (matched by `i` property)
* @returns New layout with the item replaced
*/
declare function modifyLayout(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Apply a transformation to a layout item.
*
* Finds the item by key, clones it, applies the callback, and returns
* a new layout with the modified item.
*
* @param layout - Layout to modify
* @param itemKey - Key of the item to modify
* @param cb - Callback that receives the cloned item and returns the modified item
* @returns Tuple of [new layout, modified item or null if not found]
*/
declare function withLayoutItem(layout: Layout, itemKey: string, cb: (item: LayoutItem) => LayoutItem): [LayoutItem[], LayoutItem | null];
/**
* Ensure all layout items fit within the grid bounds.
*
* - Items overflowing right are moved left
* - Items overflowing left are moved to x=0 and clamped to grid width
* - Static items that collide with other statics are moved down
*
* **IMPORTANT**: This function mutates the layout items in place for performance.
* The type signature uses `Mutable<LayoutItem>[]` to make this explicit.
* Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.
*
* @param layout - Layout to correct (items WILL be mutated)
* @param bounds - Grid bounds
* @returns The same layout array (for chaining)
*/
declare function correctBounds(layout: Mutable<LayoutItem>[], bounds: {
cols: number;
}): LayoutItem[];
/**
* Move a layout element to a new position.
*
* Handles collision detection and cascading movements.
* Does not compact the layout - call `compact()` separately.
*
* **Note**: This function mutates the `l` parameter directly for performance.
* The item's x, y, and moved properties will be modified. Callers should
* ideally pass a cloned item if they need to preserve the original.
*
* @param layout - Full layout
* @param l - Item to move (will be mutated)
* @param x - New X position (or undefined to keep current)
* @param y - New Y position (or undefined to keep current)
* @param isUserAction - True if this is a direct user action (affects collision resolution)
* @param preventCollision - True to block movement into occupied space (item snaps back). No effect if allowOverlap is true.
* @param compactType - Compaction type for collision resolution
* @param cols - Number of columns in the grid
* @param allowOverlap - True to allow items to stack on top of each other
* @returns The updated layout
*/
declare function moveElement(layout: Layout, l: LayoutItem, x: number | undefined, y: number | undefined, isUserAction: boolean | undefined, preventCollision: boolean | undefined, compactType: CompactType, cols: number, allowOverlap?: boolean): LayoutItem[];
/**
* Move an item away from a collision.
*
* Attempts to move the item up/left first if there's room,
* otherwise moves it down/right.
*
* @param layout - Full layout
* @param collidesWith - The item being collided with
* @param itemToMove - The item to move away
* @param isUserAction - True if this is a direct user action
* @param compactType - Compaction type
* @param cols - Number of columns
* @returns Updated layout
*/
declare function moveElementAwayFromCollision(layout: Layout, collidesWith: LayoutItem, itemToMove: LayoutItem, isUserAction: boolean | undefined, compactType: CompactType, cols: number): LayoutItem[];
/**
* Validate that a layout has the required properties.
*
* @param layout - Layout to validate
* @param contextName - Name for error messages
* @throws Error if layout is invalid
*/
declare function validateLayout(layout: Layout, contextName?: string): void;
/**
* Compactor implementations.
*
* Compactors are pluggable strategies for removing gaps between grid items.
* Use the Compactor interface to create custom compaction algorithms.
*/
/**
* Resolve a compaction collision by moving items.
*
* Before moving an item to a position, checks if that movement would
* cause collisions and recursively moves those items first.
*
* Useful for implementing custom compactors.
*
* @param layout - Full layout (must be sorted for optimization)
* @param item - Item being moved (will be mutated)
* @param moveToCoord - Target coordinate
* @param axis - Which axis to move on ('x' or 'y')
* @param hasStatics - Whether layout contains static items (disables early break optimization)
*/
declare function resolveCompactionCollision(layout: Layout, item: LayoutItem, moveToCoord: number, axis: "x" | "y", hasStatics?: boolean): void;
/**
* Compact a single item vertically (move up).
*
* Moves the item as far up as possible without colliding.
* Useful for implementing custom vertical compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param fullLayout - Full layout for collision resolution
* @param maxY - Maximum Y to start from
* @returns The compacted item
*/
declare function compactItemVertical(compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number): LayoutItem;
/**
* Compact a single item horizontally (move left).
*
* Moves the item as far left as possible without colliding.
* Wraps to the next row if it overflows.
* Useful for implementing custom horizontal compactors.
*
* @param compareWith - Items to check for collisions
* @param l - Item to compact (will be mutated)
* @param cols - Number of columns in the grid
* @param fullLayout - Full layout for collision resolution
* @returns The compacted item
*/
declare function compactItemHorizontal(compareWith: Layout, l: LayoutItem, cols: number, fullLayout: Layout): LayoutItem;
/**
* Vertical compactor - moves items up to fill gaps.
*
* Items are sorted by row then column, and each item is moved
* as far up as possible without overlapping other items.
*
* This is the default compaction mode for react-grid-layout.
*/
declare const verticalCompactor: Compactor;
/**
* Horizontal compactor - moves items left to fill gaps.
*
* Items are sorted by column then row, and each item is moved
* as far left as possible without overlapping other items.
*/
declare const horizontalCompactor: Compactor;
/**
* No compaction - items stay where placed.
*
* Use this for free-form layouts where items can be placed anywhere.
* Items will not automatically move to fill gaps.
*/
declare const noCompactor: Compactor;
/**
* Vertical compactor that allows overlapping items.
*
* Items compact upward but are allowed to overlap each other.
* Useful for layered layouts or when collision detection is handled externally.
*/
declare const verticalOverlapCompactor: Compactor;
/**
* Horizontal compactor that allows overlapping items.
*/
declare const horizontalOverlapCompactor: Compactor;
/**
* No compaction, with overlapping allowed.
*
* Items stay where placed and can overlap each other.
*/
declare const noOverlapCompactor: Compactor;
/**
* Get a compactor by type.
*
* This is a convenience function for backwards compatibility with the
* string-based compactType API.
*
* Note: For 'wrap' mode, import `wrapCompactor` from 'react-grid-layout/extras'
* and pass it directly to the `compactor` prop. This function returns
* `noCompactor` for 'wrap' type since the wrap compactor is tree-shakeable.
*
* @param compactType - 'vertical', 'horizontal', 'wrap', or null
* @param allowOverlap - Whether to allow overlapping items
* @returns The appropriate Compactor
*/
declare function getCompactor(compactType: CompactType, allowOverlap?: boolean, preventCollision?: boolean): Compactor;
/**
* Position calculation utilities.
*
* These functions convert between grid units and pixel positions,
* and generate CSS styles for grid items.
*/
/**
* Generate CSS transform-based positioning styles.
*
* Using transforms is more performant than top/left positioning
* because it doesn't trigger layout recalculations.
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTransform({ top, left, width, height }: Position): Record<string, string>;
/**
* Generate CSS top/left positioning styles.
*
* Use this when transforms are not suitable (e.g., for printing
* or when transform causes issues with child elements).
*
* @param position - Position in pixels
* @returns CSS style object
*/
declare function setTopLeft({ top, left, width, height }: Position): Record<string, string>;
/**
* Convert a number to a percentage string.
*
* @param num - Number to convert (0-1 range typically)
* @returns Percentage string (e.g., "50%")
*/
declare function perc(num: number): string;
/**
* Resize an item in a specific direction, clamping to container bounds.
*
* This handles the complex logic of resizing from different edges/corners,
* ensuring the item doesn't overflow the container.
*
* @param direction - Which edge/corner is being dragged
* @param currentSize - Current position and size
* @param newSize - Requested new position and size
* @param containerWidth - Width of the container
* @returns Constrained position and size
*/
declare function resizeItemInDirection(direction: ResizeHandleAxis, currentSize: Position, newSize: Position, containerWidth: number): Position;
/**
* CSS transform-based positioning strategy.
*
* Uses CSS transforms for positioning, which is more performant
* as it doesn't trigger layout recalculations.
*
* This is the default strategy.
*/
declare const transformStrategy: PositionStrategy;
/**
* Absolute (top/left) positioning strategy.
*
* Uses CSS top/left for positioning. Use this when CSS transforms
* cause issues (e.g., printing, certain child element positioning).
*/
declare const absoluteStrategy: PositionStrategy;
/**
* Create a scaled transform strategy.
*
* Use this when the grid container is inside a scaled element
* (e.g., `transform: scale(0.5)`). The scale factor adjusts
* drag/resize calculations to account for the parent transform.
*
* @param scale - Scale factor (e.g., 0.5 for half size)
* @returns Position strategy with scaled calculations
*
* @example
* ```tsx
* <div style={{ transform: 'scale(0.5)' }}>
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* </div>
* ```
*/
declare function createScaledStrategy(scale: number): PositionStrategy;
/** Default position strategy (transform-based) */
declare const defaultPositionStrategy: PositionStrategy;
export { absoluteStrategy as A, createScaledStrategy as B, defaultPositionStrategy as C, cloneLayoutItem as a, bottom as b, cloneLayout as c, getCompactor as d, verticalCompactor as e, setTopLeft as f, getLayoutItem as g, horizontalCompactor as h, getStatics as i, modifyLayout as j, correctBounds as k, moveElementAwayFromCollision as l, moveElement as m, noCompactor as n, verticalOverlapCompactor as o, horizontalOverlapCompactor as p, noOverlapCompactor as q, resolveCompactionCollision as r, setTransform as s, compactItemVertical as t, compactItemHorizontal as u, validateLayout as v, withLayoutItem as w, perc as x, resizeItemInDirection as y, transformStrategy as z };
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.js"}
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.mjs"}
import { a as LayoutItem, L as Layout, C as CompactType, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts, c as Compactor } from './types-BiXsdXr7.js';
/**
* Collision detection utilities for grid layouts.
*
* These functions determine if and where layout items overlap.
*/
/**
* Check if two layout items collide (overlap).
*
* Two items collide if their bounding boxes overlap and they are
* not the same item.
*
* @param l1 - First layout item
* @param l2 - Second layout item
* @returns true if the items collide
*/
declare function collides(l1: LayoutItem, l2: LayoutItem): boolean;
/**
* Find the first item in the layout that collides with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns The first colliding item, or undefined if none
*/
declare function getFirstCollision(layout: Layout, layoutItem: LayoutItem): LayoutItem | undefined;
/**
* Find all items in the layout that collide with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns Array of all colliding items (may be empty)
*/
declare function getAllCollisions(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Sorting utilities for grid layouts.
*
* These functions sort layout items for compaction and iteration.
*/
/**
* Sort layout items based on the compaction type.
*
* - Vertical compaction: sort by row (y) then column (x)
* - Horizontal compaction: sort by column (x) then row (y)
* - No compaction (null): return original order
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @param compactType - Type of compaction
* @returns Sorted layout
*/
declare function sortLayoutItems(layout: Layout, compactType: CompactType): LayoutItem[];
/**
* Sort layout items by row ascending, then column ascending.
*
* Items are ordered from top-left to bottom-right, row by row.
* This is the natural reading order for vertical compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByRowCol(layout: Layout): LayoutItem[];
/**
* Sort layout items by column ascending, then row ascending.
*
* Items are ordered from top-left to bottom-right, column by column.
* This is the natural order for horizontal compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByColRow(layout: Layout): LayoutItem[];
/**
* Responsive layout utilities.
*
* Functions for handling responsive breakpoints and layout generation.
*/
/**
* Sort breakpoints by width (ascending).
*
* Returns an array of breakpoint names sorted from smallest to largest.
* E.g., ['xxs', 'xs', 'sm', 'md', 'lg']
*
* @param breakpoints - Map of breakpoint names to widths
* @returns Sorted array of breakpoint names
*/
declare function sortBreakpoints<B extends Breakpoint>(breakpoints: Breakpoints<B>): B[];
/**
* Get the active breakpoint for a given width.
*
* Returns the highest breakpoint that is valid for the width (width > breakpoint).
*
* @param breakpoints - Map of breakpoint names to widths
* @param width - Container width in pixels
* @returns Active breakpoint name
*/
declare function getBreakpointFromWidth<B extends Breakpoint>(breakpoints: Breakpoints<B>, width: number): B;
/**
* Get the column count for a breakpoint.
*
* @param breakpoint - Breakpoint name
* @param cols - Map of breakpoint names to column counts
* @returns Number of columns for the breakpoint
* @throws Error if breakpoint is not defined in cols
*/
declare function getColsFromBreakpoint<B extends Breakpoint>(breakpoint: B, cols: Breakpoints<B>): number;
/**
* Find or generate a layout for a breakpoint.
*
* If a layout exists for the breakpoint, returns a clone.
* Otherwise, generates a new layout from the nearest larger breakpoint.
*
* @param layouts - Existing layouts by breakpoint
* @param breakpoints - Breakpoint definitions
* @param breakpoint - Target breakpoint
* @param lastBreakpoint - Previous breakpoint (for fallback)
* @param cols - Column count for the target breakpoint
* @param compactTypeOrCompactor - Compaction type string (legacy) or Compactor object
* @returns Layout for the breakpoint
*/
declare function findOrGenerateResponsiveLayout<B extends Breakpoint>(layouts: ResponsiveLayouts<B>, breakpoints: Breakpoints<B>, breakpoint: B, lastBreakpoint: B, cols: number, compactTypeOrCompactor: CompactType | Compactor): Layout;
type IndentationValue<B extends Breakpoint> = readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/**
* Get margin or padding value for a breakpoint.
*
* Supports both fixed values ([x, y]) and breakpoint-specific values
* ({ lg: [x, y], md: [x, y], ... }).
*
* @param value - Fixed value or breakpoint-specific map
* @param breakpoint - Current breakpoint
* @returns Margin/padding tuple [x, y]
*/
declare function getIndentationValue<B extends Breakpoint>(value: IndentationValue<B>, breakpoint: B): readonly [number, number];
export { getAllCollisions as a, sortLayoutItemsByRowCol as b, collides as c, sortLayoutItemsByColRow as d, getBreakpointFromWidth as e, getColsFromBreakpoint as f, getFirstCollision as g, findOrGenerateResponsiveLayout as h, sortBreakpoints as i, getIndentationValue as j, sortLayoutItems as s };
import { a as LayoutItem, L as Layout, C as CompactType, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts, c as Compactor } from './types-BiXsdXr7.mjs';
/**
* Collision detection utilities for grid layouts.
*
* These functions determine if and where layout items overlap.
*/
/**
* Check if two layout items collide (overlap).
*
* Two items collide if their bounding boxes overlap and they are
* not the same item.
*
* @param l1 - First layout item
* @param l2 - Second layout item
* @returns true if the items collide
*/
declare function collides(l1: LayoutItem, l2: LayoutItem): boolean;
/**
* Find the first item in the layout that collides with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns The first colliding item, or undefined if none
*/
declare function getFirstCollision(layout: Layout, layoutItem: LayoutItem): LayoutItem | undefined;
/**
* Find all items in the layout that collide with the given item.
*
* @param layout - Layout to search
* @param layoutItem - Item to check for collisions
* @returns Array of all colliding items (may be empty)
*/
declare function getAllCollisions(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
/**
* Sorting utilities for grid layouts.
*
* These functions sort layout items for compaction and iteration.
*/
/**
* Sort layout items based on the compaction type.
*
* - Vertical compaction: sort by row (y) then column (x)
* - Horizontal compaction: sort by column (x) then row (y)
* - No compaction (null): return original order
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @param compactType - Type of compaction
* @returns Sorted layout
*/
declare function sortLayoutItems(layout: Layout, compactType: CompactType): LayoutItem[];
/**
* Sort layout items by row ascending, then column ascending.
*
* Items are ordered from top-left to bottom-right, row by row.
* This is the natural reading order for vertical compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByRowCol(layout: Layout): LayoutItem[];
/**
* Sort layout items by column ascending, then row ascending.
*
* Items are ordered from top-left to bottom-right, column by column.
* This is the natural order for horizontal compaction.
*
* Does not modify the original layout.
*
* @param layout - Layout to sort
* @returns Sorted array of layout items
*/
declare function sortLayoutItemsByColRow(layout: Layout): LayoutItem[];
/**
* Responsive layout utilities.
*
* Functions for handling responsive breakpoints and layout generation.
*/
/**
* Sort breakpoints by width (ascending).
*
* Returns an array of breakpoint names sorted from smallest to largest.
* E.g., ['xxs', 'xs', 'sm', 'md', 'lg']
*
* @param breakpoints - Map of breakpoint names to widths
* @returns Sorted array of breakpoint names
*/
declare function sortBreakpoints<B extends Breakpoint>(breakpoints: Breakpoints<B>): B[];
/**
* Get the active breakpoint for a given width.
*
* Returns the highest breakpoint that is valid for the width (width > breakpoint).
*
* @param breakpoints - Map of breakpoint names to widths
* @param width - Container width in pixels
* @returns Active breakpoint name
*/
declare function getBreakpointFromWidth<B extends Breakpoint>(breakpoints: Breakpoints<B>, width: number): B;
/**
* Get the column count for a breakpoint.
*
* @param breakpoint - Breakpoint name
* @param cols - Map of breakpoint names to column counts
* @returns Number of columns for the breakpoint
* @throws Error if breakpoint is not defined in cols
*/
declare function getColsFromBreakpoint<B extends Breakpoint>(breakpoint: B, cols: Breakpoints<B>): number;
/**
* Find or generate a layout for a breakpoint.
*
* If a layout exists for the breakpoint, returns a clone.
* Otherwise, generates a new layout from the nearest larger breakpoint.
*
* @param layouts - Existing layouts by breakpoint
* @param breakpoints - Breakpoint definitions
* @param breakpoint - Target breakpoint
* @param lastBreakpoint - Previous breakpoint (for fallback)
* @param cols - Column count for the target breakpoint
* @param compactTypeOrCompactor - Compaction type string (legacy) or Compactor object
* @returns Layout for the breakpoint
*/
declare function findOrGenerateResponsiveLayout<B extends Breakpoint>(layouts: ResponsiveLayouts<B>, breakpoints: Breakpoints<B>, breakpoint: B, lastBreakpoint: B, cols: number, compactTypeOrCompactor: CompactType | Compactor): Layout;
type IndentationValue<B extends Breakpoint> = readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/**
* Get margin or padding value for a breakpoint.
*
* Supports both fixed values ([x, y]) and breakpoint-specific values
* ({ lg: [x, y], md: [x, y], ... }).
*
* @param value - Fixed value or breakpoint-specific map
* @param breakpoint - Current breakpoint
* @returns Margin/padding tuple [x, y]
*/
declare function getIndentationValue<B extends Breakpoint>(value: IndentationValue<B>, breakpoint: B): readonly [number, number];
export { getAllCollisions as a, sortLayoutItemsByRowCol as b, collides as c, sortLayoutItemsByColRow as d, getBreakpointFromWidth as e, getColsFromBreakpoint as f, getFirstCollision as g, findOrGenerateResponsiveLayout as h, sortBreakpoints as i, getIndentationValue as j, sortLayoutItems as s };
import React__default, { CSSProperties, DragEvent, ReactElement } from 'react';
import { l as GridConfig, m as DragConfig, n as ResizeConfig, o as DropConfig, k as PositionStrategy, c as Compactor, f as LayoutConstraint, L as Layout, a as LayoutItem, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-BiXsdXr7.mjs';
/**
* GridLayout component
*
* A reactive, fluid grid layout with draggable, resizable components.
*/
type EventCallback = (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null, placeholder: LayoutItem | null, event: Event, element?: HTMLElement) => void;
interface GridLayoutProps {
/** Child elements to render in the grid */
children: React__default.ReactNode;
/** Width of the container in pixels */
width: number;
/**
* Grid measurement configuration.
* @see GridConfig
*/
gridConfig?: Partial<GridConfig>;
/**
* Drag behavior configuration.
* @see DragConfig
*/
dragConfig?: Partial<DragConfig>;
/**
* Resize behavior configuration.
* @see ResizeConfig
*/
resizeConfig?: Partial<ResizeConfig>;
/**
* External drop configuration.
* @see DropConfig
*/
dropConfig?: Partial<DropConfig>;
/**
* CSS positioning strategy.
* Use transformStrategy (default), absoluteStrategy, or createScaledStrategy(scale).
* @see PositionStrategy
*/
positionStrategy?: PositionStrategy;
/**
* Layout compaction strategy.
* Use verticalCompactor (default), horizontalCompactor, or noCompactor.
* @see Compactor
*/
compactor?: Compactor;
/**
* Layout constraints for position and size limiting.
* Applied during drag/resize operations.
* Default: [gridBounds, minMaxSize]
* @see LayoutConstraint
*/
constraints?: LayoutConstraint[];
/** Layout definition */
layout?: Layout;
/** Item to use when dropping from outside */
droppingItem?: LayoutItem;
/** Whether to auto-size the container height */
autoSize?: boolean;
/** Additional class name */
className?: string;
/** Additional styles */
style?: CSSProperties;
/** Ref to the container element */
innerRef?: React__default.Ref<HTMLDivElement>;
/** Called when layout changes */
onLayoutChange?: (layout: Layout) => void;
/** Called when drag starts */
onDragStart?: EventCallback;
/** Called during drag */
onDrag?: EventCallback;
/** Called when drag stops */
onDragStop?: EventCallback;
/** Called when resize starts */
onResizeStart?: EventCallback;
/** Called during resize */
onResize?: EventCallback;
/** Called when resize stops */
onResizeStop?: EventCallback;
/** Called when an item is dropped from outside */
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
/** Called when dragging over the grid */
onDropDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/**
* GridLayout - A reactive, fluid grid layout with draggable, resizable components.
*/
declare function GridLayout(props: GridLayoutProps): ReactElement;
/**
* ResponsiveGridLayout component
*
* A responsive grid layout that automatically adjusts to container width.
*/
interface ResponsiveGridLayoutProps<B extends Breakpoint = string> extends Omit<GridLayoutProps, "gridConfig" | "layout" | "onLayoutChange"> {
/** Current breakpoint (optional, auto-detected from width) */
breakpoint?: B;
/** Breakpoint definitions (name → min-width) */
breakpoints?: Breakpoints<B>;
/** Column counts per breakpoint */
cols?: Breakpoints<B>;
/** Layouts for each breakpoint */
layouts?: ResponsiveLayouts<B>;
/** Row height (default: 150) */
rowHeight?: number;
/** Maximum rows (default: Infinity) */
maxRows?: number;
/** Margin between items - can be fixed or per-breakpoint */
margin?: readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/** Container padding - can be fixed or per-breakpoint */
containerPadding?: readonly [number, number] | Partial<Record<B, readonly [number, number] | null>> | null;
/** Compactor for layout compaction */
compactor?: Compactor;
/** Called when breakpoint changes */
onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
/** Called when layout changes */
onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
/** Called when width changes */
onWidthChange?: (containerWidth: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
}
/**
* ResponsiveGridLayout - A responsive grid layout that adjusts to container width.
*/
declare function ResponsiveGridLayout<B extends Breakpoint = string>(props: ResponsiveGridLayoutProps<B>): ReactElement;
export { type EventCallback as E, GridLayout as G, ResponsiveGridLayout as R, type GridLayoutProps as a, type ResponsiveGridLayoutProps as b };
import React__default, { CSSProperties, DragEvent, ReactElement } from 'react';
import { l as GridConfig, m as DragConfig, n as ResizeConfig, o as DropConfig, k as PositionStrategy, c as Compactor, f as LayoutConstraint, L as Layout, a as LayoutItem, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-BiXsdXr7.js';
/**
* GridLayout component
*
* A reactive, fluid grid layout with draggable, resizable components.
*/
type EventCallback = (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null, placeholder: LayoutItem | null, event: Event, element?: HTMLElement) => void;
interface GridLayoutProps {
/** Child elements to render in the grid */
children: React__default.ReactNode;
/** Width of the container in pixels */
width: number;
/**
* Grid measurement configuration.
* @see GridConfig
*/
gridConfig?: Partial<GridConfig>;
/**
* Drag behavior configuration.
* @see DragConfig
*/
dragConfig?: Partial<DragConfig>;
/**
* Resize behavior configuration.
* @see ResizeConfig
*/
resizeConfig?: Partial<ResizeConfig>;
/**
* External drop configuration.
* @see DropConfig
*/
dropConfig?: Partial<DropConfig>;
/**
* CSS positioning strategy.
* Use transformStrategy (default), absoluteStrategy, or createScaledStrategy(scale).
* @see PositionStrategy
*/
positionStrategy?: PositionStrategy;
/**
* Layout compaction strategy.
* Use verticalCompactor (default), horizontalCompactor, or noCompactor.
* @see Compactor
*/
compactor?: Compactor;
/**
* Layout constraints for position and size limiting.
* Applied during drag/resize operations.
* Default: [gridBounds, minMaxSize]
* @see LayoutConstraint
*/
constraints?: LayoutConstraint[];
/** Layout definition */
layout?: Layout;
/** Item to use when dropping from outside */
droppingItem?: LayoutItem;
/** Whether to auto-size the container height */
autoSize?: boolean;
/** Additional class name */
className?: string;
/** Additional styles */
style?: CSSProperties;
/** Ref to the container element */
innerRef?: React__default.Ref<HTMLDivElement>;
/** Called when layout changes */
onLayoutChange?: (layout: Layout) => void;
/** Called when drag starts */
onDragStart?: EventCallback;
/** Called during drag */
onDrag?: EventCallback;
/** Called when drag stops */
onDragStop?: EventCallback;
/** Called when resize starts */
onResizeStart?: EventCallback;
/** Called during resize */
onResize?: EventCallback;
/** Called when resize stops */
onResizeStop?: EventCallback;
/** Called when an item is dropped from outside */
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
/** Called when dragging over the grid */
onDropDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/**
* GridLayout - A reactive, fluid grid layout with draggable, resizable components.
*/
declare function GridLayout(props: GridLayoutProps): ReactElement;
/**
* ResponsiveGridLayout component
*
* A responsive grid layout that automatically adjusts to container width.
*/
interface ResponsiveGridLayoutProps<B extends Breakpoint = string> extends Omit<GridLayoutProps, "gridConfig" | "layout" | "onLayoutChange"> {
/** Current breakpoint (optional, auto-detected from width) */
breakpoint?: B;
/** Breakpoint definitions (name → min-width) */
breakpoints?: Breakpoints<B>;
/** Column counts per breakpoint */
cols?: Breakpoints<B>;
/** Layouts for each breakpoint */
layouts?: ResponsiveLayouts<B>;
/** Row height (default: 150) */
rowHeight?: number;
/** Maximum rows (default: Infinity) */
maxRows?: number;
/** Margin between items - can be fixed or per-breakpoint */
margin?: readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
/** Container padding - can be fixed or per-breakpoint */
containerPadding?: readonly [number, number] | Partial<Record<B, readonly [number, number] | null>> | null;
/** Compactor for layout compaction */
compactor?: Compactor;
/** Called when breakpoint changes */
onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
/** Called when layout changes */
onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
/** Called when width changes */
onWidthChange?: (containerWidth: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
}
/**
* ResponsiveGridLayout - A responsive grid layout that adjusts to container width.
*/
declare function ResponsiveGridLayout<B extends Breakpoint = string>(props: ResponsiveGridLayoutProps<B>): ReactElement;
export { type EventCallback as E, GridLayout as G, ResponsiveGridLayout as R, type GridLayoutProps as a, type ResponsiveGridLayoutProps as b };
/**
* Core types for react-grid-layout v2
*
* These types are framework-agnostic and define the data structures
* used by the layout algorithms.
*/
/**
* Axis identifiers for resize handles.
* - Cardinal: 'n', 's', 'e', 'w' (north, south, east, west)
* - Diagonal: 'ne', 'nw', 'se', 'sw'
*/
type ResizeHandleAxis = "s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne";
/**
* A single item in the grid layout.
*
* Position (x, y) is in grid units, not pixels.
* Size (w, h) is in grid units.
*/
interface LayoutItem {
/** Unique identifier for this item */
i: string;
/** X position in grid units (0-indexed from left) */
x: number;
/** Y position in grid units (0-indexed from top) */
y: number;
/** Width in grid units */
w: number;
/** Height in grid units */
h: number;
/** Minimum width in grid units */
minW?: number;
/** Minimum height in grid units */
minH?: number;
/** Maximum width in grid units */
maxW?: number;
/** Maximum height in grid units */
maxH?: number;
/**
* If true, item cannot be dragged or resized, and other items
* will move around it during compaction.
*/
static?: boolean;
/**
* If false, item cannot be dragged (but may still be resizable).
* Overrides grid-level isDraggable for this item.
*/
isDraggable?: boolean;
/**
* If false, item cannot be resized (but may still be draggable).
* Overrides grid-level isResizable for this item.
*/
isResizable?: boolean;
/**
* Which resize handles to show for this item.
* Overrides grid-level resizeHandles for this item.
*/
resizeHandles?: ResizeHandleAxis[];
/**
* If true, item is constrained to the grid container bounds.
* Overrides grid-level isBounded for this item.
*/
isBounded?: boolean;
/**
* Internal flag set during drag/resize operations to indicate
* the item has moved from its original position.
* @internal
*/
moved?: boolean;
/**
* Per-item layout constraints.
* Applied in addition to grid-level constraints.
*/
constraints?: LayoutConstraint[];
}
/**
* A layout is a readonly array of layout items.
* Layouts should be treated as immutable.
*/
type Layout = readonly LayoutItem[];
/**
* Pixel position and size of an element.
*/
interface Position {
left: number;
top: number;
width: number;
height: number;
}
/**
* Partial position (just coordinates, no size).
*/
interface PartialPosition {
left: number;
top: number;
}
/**
* Size in pixels.
*/
interface Size {
width: number;
height: number;
}
/**
* Position when dropping an external element onto the grid.
*/
interface DroppingPosition {
left: number;
top: number;
e: Event;
}
/**
* Data provided by react-draggable during drag operations.
*/
interface ReactDraggableCallbackData {
node: HTMLElement;
x?: number;
y?: number;
deltaX: number;
deltaY: number;
lastX?: number;
lastY?: number;
}
/**
* Grid-level drag event data.
*/
interface GridDragEvent {
e: Event;
node: HTMLElement;
newPosition: PartialPosition;
}
/**
* Grid-level resize event data.
*/
interface GridResizeEvent {
e: Event;
node: HTMLElement;
size: Size;
handle: ResizeHandleAxis;
}
/**
* Drag-over event with layer coordinates.
*/
interface DragOverEvent extends MouseEvent {
nativeEvent: Event & {
layerX: number;
layerY: number;
};
}
/**
* Type of compaction to apply to the layout.
* - 'vertical': Items compact upward (default)
* - 'horizontal': Items compact leftward
* - 'wrap': Items arranged in wrapped-paragraph style (like words in text)
* - null: No compaction (free-form positioning)
*/
type CompactType = "horizontal" | "vertical" | "wrap" | null;
/**
* Standard callback signature for layout change events.
*
* @param layout - The current layout after the change
* @param oldItem - The item before the change (null if not applicable)
* @param newItem - The item after the change (null if not applicable)
* @param placeholder - The placeholder item during drag/resize (null at start)
* @param event - The DOM event that triggered the change
* @param element - The DOM element being manipulated (null if not applicable)
*/
type EventCallback = (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null, placeholder: LayoutItem | null, event: Event, element: HTMLElement | null) => void;
/**
* Callback when layout changes for any reason.
*/
type OnLayoutChangeCallback = (layout: Layout) => void;
/**
* Interface for layout compaction strategies.
*
* Implement this interface to create custom compaction algorithms.
*
* @example
* ```typescript
* const myCompactor: Compactor = {
* type: 'vertical',
* allowOverlap: false,
* compact(layout, cols) {
* // Custom compaction logic
* return compactedLayout;
* }
* };
* ```
*/
interface Compactor {
/** Compaction type identifier */
readonly type: CompactType;
/**
* Whether items can overlap (stack on top of each other).
*
* When true:
* - Items can be placed on top of other items
* - Dragging into another item does NOT push it away
* - Compaction is skipped after drag/resize
*/
readonly allowOverlap: boolean;
/**
* Whether to block movement that would cause collision.
*
* When true (and allowOverlap is false):
* - Dragging into another item is blocked (item snaps back)
* - Other items are NOT pushed away
* - Only affects drag/resize, not compaction
*
* Has no effect when allowOverlap is true.
*/
readonly preventCollision?: boolean;
/**
* Compact the layout.
*
* @param layout - The layout to compact
* @param cols - Number of columns in the grid
* @returns The compacted layout
*/
compact(layout: Layout, cols: number): Layout;
}
/**
* Interface for CSS positioning strategies.
*
* Implement this interface to customize how items are positioned in the DOM.
* Built-in strategies: transformStrategy, absoluteStrategy.
*
* @example
* ```typescript
* // Use transform-based positioning (default, better performance)
* <GridLayout positionStrategy={transformStrategy} />
*
* // Use top/left positioning (for environments where transforms cause issues)
* <GridLayout positionStrategy={absoluteStrategy} />
*
* // Use scaled transforms (for scaled containers)
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* ```
*/
interface PositionStrategy {
/** Strategy type identifier */
readonly type: "transform" | "absolute";
/** Scale factor for drag/resize calculations */
readonly scale: number;
/**
* Convert pixel position to CSS style object.
*
* @param pos - Position in pixels
* @returns CSS properties for positioning the element
*/
calcStyle(pos: Position): React.CSSProperties;
/**
* Calculate position during drag operations, accounting for transforms and scale.
*
* This method is optional. When not provided, react-draggable uses its built-in
* parent-relative coordinate calculation. Only override this when you need custom
* coordinate handling, such as for scaled containers.
*
* @param clientX - Mouse client X position
* @param clientY - Mouse client Y position
* @param offsetX - Offset from element origin X
* @param offsetY - Offset from element origin Y
* @returns Adjusted left/top position
*/
calcDragPosition?(clientX: number, clientY: number, offsetX: number, offsetY: number): PartialPosition;
}
/**
* Context provided to constraint functions during drag/resize operations.
*/
interface ConstraintContext {
/** Number of columns in the grid */
cols: number;
/** Maximum number of rows (Infinity if unbounded) */
maxRows: number;
/** Container width in pixels */
containerWidth: number;
/** Container height in pixels (may be 0 if auto-height) */
containerHeight: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] in pixels */
margin: readonly [number, number];
/** Current layout state */
layout: Layout;
}
/**
* Interface for layout constraints.
*
* Implement this interface to create custom position/size constraints.
* Built-in constraints: gridBounds, minMaxSize, containerBounds, boundedX, boundedY.
*
* @example
* ```typescript
* // Grid-level constraints
* <GridLayout constraints={[gridBounds, minMaxSize, aspectRatio(16/9)]} />
*
* // Per-item constraints
* const layout = [
* { i: 'video', x: 0, y: 0, w: 4, h: 2, constraints: [aspectRatio(16/9)] }
* ];
* ```
*/
interface LayoutConstraint {
/** Constraint identifier for debugging */
readonly name: string;
/**
* Constrain position during drag operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being dragged
* @param x - Proposed x position in grid units
* @param y - Proposed y position in grid units
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained x, y position
*/
constrainPosition?(item: LayoutItem, x: number, y: number, context: ConstraintContext): {
x: number;
y: number;
};
/**
* Constrain size during resize operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being resized
* @param w - Proposed width in grid units
* @param h - Proposed height in grid units
* @param handle - Which resize handle is being used
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained w, h size
*/
constrainSize?(item: LayoutItem, w: number, h: number, handle: ResizeHandleAxis, context: ConstraintContext): {
w: number;
h: number;
};
}
/**
* Grid measurement configuration.
* Groups all grid metrics (columns, row height, margins).
*/
interface GridConfig {
/** Number of columns in the grid (default: 12) */
cols: number;
/** Height of a single row in pixels (default: 150) */
rowHeight: number;
/** [horizontal, vertical] margin between items in pixels (default: [10, 10]) */
margin: readonly [number, number];
/** [horizontal, vertical] padding inside the container (default: null, uses margin) */
containerPadding: readonly [number, number] | null;
/** Maximum number of rows (default: Infinity) */
maxRows: number;
}
/** Default grid configuration */
declare const defaultGridConfig: GridConfig;
/**
* Drag behavior configuration.
* Groups all drag-related settings.
*/
interface DragConfig {
/** Whether items can be dragged (default: true) */
enabled: boolean;
/** Whether items are bounded to the container (default: false) */
bounded: boolean;
/** CSS selector for drag handle (e.g., '.drag-handle') */
handle?: string;
/** CSS selector for elements that should not trigger drag */
cancel?: string;
/**
* Minimum pixels to move before drag starts.
* Helps distinguish click from drag (fixes #1341, #1401).
* @default 3
*/
threshold: number;
}
/** Default drag configuration */
declare const defaultDragConfig: DragConfig;
/**
* Resize behavior configuration.
* Groups all resize-related settings.
*/
interface ResizeConfig {
/** Whether items can be resized (default: true) */
enabled: boolean;
/** Which resize handles to show (default: ['se']) */
handles: readonly ResizeHandleAxis[];
/**
* Custom resize handle component.
* Can be a React node or a function that receives the axis.
*/
handleComponent?: React.ReactNode | ((axis: ResizeHandleAxis, ref: React.Ref<HTMLElement>) => React.ReactNode);
}
/** Default resize configuration */
declare const defaultResizeConfig: ResizeConfig;
/**
* Drop configuration (for dropping external elements).
* Groups all drop-related settings.
*/
interface DropConfig {
/** Whether external elements can be dropped on the grid (default: false) */
enabled: boolean;
/** Default size for dropped items (default: { w: 1, h: 1 }) */
defaultItem: {
w: number;
h: number;
};
/**
* Called when dragging over the grid.
* Return dimensions to override defaultItem, or false to reject the drop.
* Can also return dragOffsetX/dragOffsetY to specify cursor offset for centering.
*/
onDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/** Default drop configuration */
declare const defaultDropConfig: DropConfig;
/**
* Breakpoint name (e.g., 'lg', 'md', 'sm', 'xs', 'xxs').
*/
type Breakpoint = string;
/**
* Map of breakpoint name to pixel width.
* Generic type B allows custom breakpoint strings.
*/
type Breakpoints<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to number of columns.
* Generic type B allows custom breakpoint strings.
*/
type BreakpointCols<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to layout.
* Generic type B allows custom breakpoint strings.
*/
type ResponsiveLayouts<B extends Breakpoint = Breakpoint> = Partial<Record<B, Layout>>;
/**
* Callback when breakpoint changes.
*/
type OnBreakpointChangeCallback<B extends Breakpoint = Breakpoint> = (newBreakpoint: B, cols: number) => void;
/**
* Makes all properties in T mutable (removes readonly).
*/
type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
/**
* Deep partial - all properties and nested properties are optional.
*/
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
/**
* Extract the element type from an array type.
*/
type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
export { type ArrayElement as A, type Breakpoint as B, type CompactType as C, type DroppingPosition as D, type EventCallback as E, type GridDragEvent as G, type Layout as L, type Mutable as M, type OnLayoutChangeCallback as O, type Position as P, type ResponsiveLayouts as R, type Size as S, type LayoutItem as a, type Breakpoints as b, type Compactor as c, type ResizeHandleAxis as d, type GridResizeEvent as e, type LayoutConstraint as f, type ConstraintContext as g, type PartialPosition as h, type ReactDraggableCallbackData as i, type DragOverEvent as j, type PositionStrategy as k, type GridConfig as l, type DragConfig as m, type ResizeConfig as n, type DropConfig as o, type BreakpointCols as p, type OnBreakpointChangeCallback as q, type DeepPartial as r, defaultGridConfig as s, defaultDragConfig as t, defaultResizeConfig as u, defaultDropConfig as v };
/**
* Core types for react-grid-layout v2
*
* These types are framework-agnostic and define the data structures
* used by the layout algorithms.
*/
/**
* Axis identifiers for resize handles.
* - Cardinal: 'n', 's', 'e', 'w' (north, south, east, west)
* - Diagonal: 'ne', 'nw', 'se', 'sw'
*/
type ResizeHandleAxis = "s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne";
/**
* A single item in the grid layout.
*
* Position (x, y) is in grid units, not pixels.
* Size (w, h) is in grid units.
*/
interface LayoutItem {
/** Unique identifier for this item */
i: string;
/** X position in grid units (0-indexed from left) */
x: number;
/** Y position in grid units (0-indexed from top) */
y: number;
/** Width in grid units */
w: number;
/** Height in grid units */
h: number;
/** Minimum width in grid units */
minW?: number;
/** Minimum height in grid units */
minH?: number;
/** Maximum width in grid units */
maxW?: number;
/** Maximum height in grid units */
maxH?: number;
/**
* If true, item cannot be dragged or resized, and other items
* will move around it during compaction.
*/
static?: boolean;
/**
* If false, item cannot be dragged (but may still be resizable).
* Overrides grid-level isDraggable for this item.
*/
isDraggable?: boolean;
/**
* If false, item cannot be resized (but may still be draggable).
* Overrides grid-level isResizable for this item.
*/
isResizable?: boolean;
/**
* Which resize handles to show for this item.
* Overrides grid-level resizeHandles for this item.
*/
resizeHandles?: ResizeHandleAxis[];
/**
* If true, item is constrained to the grid container bounds.
* Overrides grid-level isBounded for this item.
*/
isBounded?: boolean;
/**
* Internal flag set during drag/resize operations to indicate
* the item has moved from its original position.
* @internal
*/
moved?: boolean;
/**
* Per-item layout constraints.
* Applied in addition to grid-level constraints.
*/
constraints?: LayoutConstraint[];
}
/**
* A layout is a readonly array of layout items.
* Layouts should be treated as immutable.
*/
type Layout = readonly LayoutItem[];
/**
* Pixel position and size of an element.
*/
interface Position {
left: number;
top: number;
width: number;
height: number;
}
/**
* Partial position (just coordinates, no size).
*/
interface PartialPosition {
left: number;
top: number;
}
/**
* Size in pixels.
*/
interface Size {
width: number;
height: number;
}
/**
* Position when dropping an external element onto the grid.
*/
interface DroppingPosition {
left: number;
top: number;
e: Event;
}
/**
* Data provided by react-draggable during drag operations.
*/
interface ReactDraggableCallbackData {
node: HTMLElement;
x?: number;
y?: number;
deltaX: number;
deltaY: number;
lastX?: number;
lastY?: number;
}
/**
* Grid-level drag event data.
*/
interface GridDragEvent {
e: Event;
node: HTMLElement;
newPosition: PartialPosition;
}
/**
* Grid-level resize event data.
*/
interface GridResizeEvent {
e: Event;
node: HTMLElement;
size: Size;
handle: ResizeHandleAxis;
}
/**
* Drag-over event with layer coordinates.
*/
interface DragOverEvent extends MouseEvent {
nativeEvent: Event & {
layerX: number;
layerY: number;
};
}
/**
* Type of compaction to apply to the layout.
* - 'vertical': Items compact upward (default)
* - 'horizontal': Items compact leftward
* - 'wrap': Items arranged in wrapped-paragraph style (like words in text)
* - null: No compaction (free-form positioning)
*/
type CompactType = "horizontal" | "vertical" | "wrap" | null;
/**
* Standard callback signature for layout change events.
*
* @param layout - The current layout after the change
* @param oldItem - The item before the change (null if not applicable)
* @param newItem - The item after the change (null if not applicable)
* @param placeholder - The placeholder item during drag/resize (null at start)
* @param event - The DOM event that triggered the change
* @param element - The DOM element being manipulated (null if not applicable)
*/
type EventCallback = (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null, placeholder: LayoutItem | null, event: Event, element: HTMLElement | null) => void;
/**
* Callback when layout changes for any reason.
*/
type OnLayoutChangeCallback = (layout: Layout) => void;
/**
* Interface for layout compaction strategies.
*
* Implement this interface to create custom compaction algorithms.
*
* @example
* ```typescript
* const myCompactor: Compactor = {
* type: 'vertical',
* allowOverlap: false,
* compact(layout, cols) {
* // Custom compaction logic
* return compactedLayout;
* }
* };
* ```
*/
interface Compactor {
/** Compaction type identifier */
readonly type: CompactType;
/**
* Whether items can overlap (stack on top of each other).
*
* When true:
* - Items can be placed on top of other items
* - Dragging into another item does NOT push it away
* - Compaction is skipped after drag/resize
*/
readonly allowOverlap: boolean;
/**
* Whether to block movement that would cause collision.
*
* When true (and allowOverlap is false):
* - Dragging into another item is blocked (item snaps back)
* - Other items are NOT pushed away
* - Only affects drag/resize, not compaction
*
* Has no effect when allowOverlap is true.
*/
readonly preventCollision?: boolean;
/**
* Compact the layout.
*
* @param layout - The layout to compact
* @param cols - Number of columns in the grid
* @returns The compacted layout
*/
compact(layout: Layout, cols: number): Layout;
}
/**
* Interface for CSS positioning strategies.
*
* Implement this interface to customize how items are positioned in the DOM.
* Built-in strategies: transformStrategy, absoluteStrategy.
*
* @example
* ```typescript
* // Use transform-based positioning (default, better performance)
* <GridLayout positionStrategy={transformStrategy} />
*
* // Use top/left positioning (for environments where transforms cause issues)
* <GridLayout positionStrategy={absoluteStrategy} />
*
* // Use scaled transforms (for scaled containers)
* <GridLayout positionStrategy={createScaledStrategy(0.5)} />
* ```
*/
interface PositionStrategy {
/** Strategy type identifier */
readonly type: "transform" | "absolute";
/** Scale factor for drag/resize calculations */
readonly scale: number;
/**
* Convert pixel position to CSS style object.
*
* @param pos - Position in pixels
* @returns CSS properties for positioning the element
*/
calcStyle(pos: Position): React.CSSProperties;
/**
* Calculate position during drag operations, accounting for transforms and scale.
*
* This method is optional. When not provided, react-draggable uses its built-in
* parent-relative coordinate calculation. Only override this when you need custom
* coordinate handling, such as for scaled containers.
*
* @param clientX - Mouse client X position
* @param clientY - Mouse client Y position
* @param offsetX - Offset from element origin X
* @param offsetY - Offset from element origin Y
* @returns Adjusted left/top position
*/
calcDragPosition?(clientX: number, clientY: number, offsetX: number, offsetY: number): PartialPosition;
}
/**
* Context provided to constraint functions during drag/resize operations.
*/
interface ConstraintContext {
/** Number of columns in the grid */
cols: number;
/** Maximum number of rows (Infinity if unbounded) */
maxRows: number;
/** Container width in pixels */
containerWidth: number;
/** Container height in pixels (may be 0 if auto-height) */
containerHeight: number;
/** Row height in pixels */
rowHeight: number;
/** Margin between items [x, y] in pixels */
margin: readonly [number, number];
/** Current layout state */
layout: Layout;
}
/**
* Interface for layout constraints.
*
* Implement this interface to create custom position/size constraints.
* Built-in constraints: gridBounds, minMaxSize, containerBounds, boundedX, boundedY.
*
* @example
* ```typescript
* // Grid-level constraints
* <GridLayout constraints={[gridBounds, minMaxSize, aspectRatio(16/9)]} />
*
* // Per-item constraints
* const layout = [
* { i: 'video', x: 0, y: 0, w: 4, h: 2, constraints: [aspectRatio(16/9)] }
* ];
* ```
*/
interface LayoutConstraint {
/** Constraint identifier for debugging */
readonly name: string;
/**
* Constrain position during drag operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being dragged
* @param x - Proposed x position in grid units
* @param y - Proposed y position in grid units
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained x, y position
*/
constrainPosition?(item: LayoutItem, x: number, y: number, context: ConstraintContext): {
x: number;
y: number;
};
/**
* Constrain size during resize operations.
* Called after grid unit conversion, before layout update.
*
* @param item - The item being resized
* @param w - Proposed width in grid units
* @param h - Proposed height in grid units
* @param handle - Which resize handle is being used
* @param context - Grid context (cols, maxRows, etc.)
* @returns Constrained w, h size
*/
constrainSize?(item: LayoutItem, w: number, h: number, handle: ResizeHandleAxis, context: ConstraintContext): {
w: number;
h: number;
};
}
/**
* Grid measurement configuration.
* Groups all grid metrics (columns, row height, margins).
*/
interface GridConfig {
/** Number of columns in the grid (default: 12) */
cols: number;
/** Height of a single row in pixels (default: 150) */
rowHeight: number;
/** [horizontal, vertical] margin between items in pixels (default: [10, 10]) */
margin: readonly [number, number];
/** [horizontal, vertical] padding inside the container (default: null, uses margin) */
containerPadding: readonly [number, number] | null;
/** Maximum number of rows (default: Infinity) */
maxRows: number;
}
/** Default grid configuration */
declare const defaultGridConfig: GridConfig;
/**
* Drag behavior configuration.
* Groups all drag-related settings.
*/
interface DragConfig {
/** Whether items can be dragged (default: true) */
enabled: boolean;
/** Whether items are bounded to the container (default: false) */
bounded: boolean;
/** CSS selector for drag handle (e.g., '.drag-handle') */
handle?: string;
/** CSS selector for elements that should not trigger drag */
cancel?: string;
/**
* Minimum pixels to move before drag starts.
* Helps distinguish click from drag (fixes #1341, #1401).
* @default 3
*/
threshold: number;
}
/** Default drag configuration */
declare const defaultDragConfig: DragConfig;
/**
* Resize behavior configuration.
* Groups all resize-related settings.
*/
interface ResizeConfig {
/** Whether items can be resized (default: true) */
enabled: boolean;
/** Which resize handles to show (default: ['se']) */
handles: readonly ResizeHandleAxis[];
/**
* Custom resize handle component.
* Can be a React node or a function that receives the axis.
*/
handleComponent?: React.ReactNode | ((axis: ResizeHandleAxis, ref: React.Ref<HTMLElement>) => React.ReactNode);
}
/** Default resize configuration */
declare const defaultResizeConfig: ResizeConfig;
/**
* Drop configuration (for dropping external elements).
* Groups all drop-related settings.
*/
interface DropConfig {
/** Whether external elements can be dropped on the grid (default: false) */
enabled: boolean;
/** Default size for dropped items (default: { w: 1, h: 1 }) */
defaultItem: {
w: number;
h: number;
};
/**
* Called when dragging over the grid.
* Return dimensions to override defaultItem, or false to reject the drop.
* Can also return dragOffsetX/dragOffsetY to specify cursor offset for centering.
*/
onDragOver?: (e: DragEvent) => {
w?: number;
h?: number;
dragOffsetX?: number;
dragOffsetY?: number;
} | false | void;
}
/** Default drop configuration */
declare const defaultDropConfig: DropConfig;
/**
* Breakpoint name (e.g., 'lg', 'md', 'sm', 'xs', 'xxs').
*/
type Breakpoint = string;
/**
* Map of breakpoint name to pixel width.
* Generic type B allows custom breakpoint strings.
*/
type Breakpoints<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to number of columns.
* Generic type B allows custom breakpoint strings.
*/
type BreakpointCols<B extends Breakpoint = Breakpoint> = Record<B, number>;
/**
* Map of breakpoint name to layout.
* Generic type B allows custom breakpoint strings.
*/
type ResponsiveLayouts<B extends Breakpoint = Breakpoint> = Partial<Record<B, Layout>>;
/**
* Callback when breakpoint changes.
*/
type OnBreakpointChangeCallback<B extends Breakpoint = Breakpoint> = (newBreakpoint: B, cols: number) => void;
/**
* Makes all properties in T mutable (removes readonly).
*/
type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
/**
* Deep partial - all properties and nested properties are optional.
*/
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
/**
* Extract the element type from an array type.
*/
type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
export { type ArrayElement as A, type Breakpoint as B, type CompactType as C, type DroppingPosition as D, type EventCallback as E, type GridDragEvent as G, type Layout as L, type Mutable as M, type OnLayoutChangeCallback as O, type Position as P, type ResponsiveLayouts as R, type Size as S, type LayoutItem as a, type Breakpoints as b, type Compactor as c, type ResizeHandleAxis as d, type GridResizeEvent as e, type LayoutConstraint as f, type ConstraintContext as g, type PartialPosition as h, type ReactDraggableCallbackData as i, type DragOverEvent as j, type PositionStrategy as k, type GridConfig as l, type DragConfig as m, type ResizeConfig as n, type DropConfig as o, type BreakpointCols as p, type OnBreakpointChangeCallback as q, type DeepPartial as r, defaultGridConfig as s, defaultDragConfig as t, defaultResizeConfig as u, defaultDropConfig as v };