react-grid-layout 1.5.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +1074 -432
  2. package/css/styles.css +6 -4
  3. package/dist/ResponsiveGridLayout-CH4s0tKj.d.ts +124 -0
  4. package/dist/ResponsiveGridLayout-D6lFRE3f.d.mts +124 -0
  5. package/dist/calculate-CwYDW8na.d.mts +168 -0
  6. package/dist/calculate-mgLpNJ5O.d.ts +168 -0
  7. package/dist/chunk-2KUHNJXF.mjs +90 -0
  8. package/dist/chunk-2KUHNJXF.mjs.map +1 -0
  9. package/dist/chunk-3WO4SAYB.js +868 -0
  10. package/dist/chunk-3WO4SAYB.js.map +1 -0
  11. package/dist/chunk-4HNUMWQK.mjs +822 -0
  12. package/dist/chunk-4HNUMWQK.mjs.map +1 -0
  13. package/dist/chunk-BFTKGAP3.js +1309 -0
  14. package/dist/chunk-BFTKGAP3.js.map +1 -0
  15. package/dist/chunk-F6NQPYKT.js +98 -0
  16. package/dist/chunk-F6NQPYKT.js.map +1 -0
  17. package/dist/chunk-H5KMDLY3.js +434 -0
  18. package/dist/chunk-H5KMDLY3.js.map +1 -0
  19. package/dist/chunk-PBQSHIID.js +4 -0
  20. package/dist/chunk-PBQSHIID.js.map +1 -0
  21. package/dist/chunk-R35HZZTA.mjs +1300 -0
  22. package/dist/chunk-R35HZZTA.mjs.map +1 -0
  23. package/dist/chunk-ZCXE6SR5.mjs +428 -0
  24. package/dist/chunk-ZCXE6SR5.mjs.map +1 -0
  25. package/dist/chunk-ZWN22PS2.mjs +3 -0
  26. package/dist/chunk-ZWN22PS2.mjs.map +1 -0
  27. package/dist/core.d.mts +33 -0
  28. package/dist/core.d.ts +33 -0
  29. package/dist/core.js +218 -0
  30. package/dist/core.js.map +1 -0
  31. package/dist/core.mjs +5 -0
  32. package/dist/core.mjs.map +1 -0
  33. package/dist/extras.d.mts +78 -0
  34. package/dist/extras.d.ts +78 -0
  35. package/dist/extras.js +91 -0
  36. package/dist/extras.js.map +1 -0
  37. package/dist/extras.mjs +89 -0
  38. package/dist/extras.mjs.map +1 -0
  39. package/dist/index.d.mts +7 -0
  40. package/dist/index.d.ts +7 -0
  41. package/dist/index.js +154 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/index.mjs +7 -0
  44. package/dist/index.mjs.map +1 -0
  45. package/dist/legacy.d.mts +163 -0
  46. package/dist/legacy.d.ts +163 -0
  47. package/dist/legacy.js +319 -0
  48. package/dist/legacy.js.map +1 -0
  49. package/dist/legacy.mjs +307 -0
  50. package/dist/legacy.mjs.map +1 -0
  51. package/dist/position-BmN1z36J.d.mts +319 -0
  52. package/dist/position-Dk2b4ZMS.d.ts +319 -0
  53. package/dist/react.d.mts +351 -0
  54. package/dist/react.d.ts +351 -0
  55. package/dist/react.js +96 -0
  56. package/dist/react.js.map +1 -0
  57. package/dist/react.mjs +7 -0
  58. package/dist/react.mjs.map +1 -0
  59. package/dist/responsive-C4L1ESlm.d.ts +145 -0
  60. package/dist/responsive-CJxefsYw.d.mts +145 -0
  61. package/dist/types-Cxf4nHNr.d.mts +375 -0
  62. package/dist/types-Cxf4nHNr.d.ts +375 -0
  63. package/index-dev.js +8 -0
  64. package/package.json +132 -40
  65. package/.babelrc.js +0 -22
  66. package/.browserslistrc +0 -3
  67. package/.eslintignore +0 -4
  68. package/.flowconfig +0 -20
  69. package/.prettierignore +0 -4
  70. package/.prettierrc +0 -17
  71. package/CHANGELOG.md +0 -985
  72. package/build/GridItem.js +0 -638
  73. package/build/ReactGridLayout.js +0 -741
  74. package/build/ReactGridLayoutPropTypes.js +0 -210
  75. package/build/ResponsiveReactGridLayout.js +0 -297
  76. package/build/calculateUtils.js +0 -165
  77. package/build/components/WidthProvider.js +0 -115
  78. package/build/fastRGLPropsEqual.js +0 -5
  79. package/build/responsiveUtils.js +0 -101
  80. package/build/utils.js +0 -842
  81. package/dist/react-grid-layout.min.js +0 -2
  82. package/dist/react-grid-layout.min.js.map +0 -1
  83. package/index.js.flow +0 -8
  84. package/ip_fetcher +0 -0
  85. package/ip_fetcher.c +0 -47
  86. package/lib/GridItem.jsx +0 -689
  87. package/lib/ReactGridLayout.jsx +0 -855
  88. package/lib/ReactGridLayoutPropTypes.js +0 -241
  89. package/lib/ResponsiveReactGridLayout.jsx +0 -349
  90. package/lib/calculateUtils.js +0 -169
  91. package/lib/components/WidthProvider.jsx +0 -110
  92. package/lib/fastRGLPropsEqual.js +0 -46
  93. package/lib/responsiveUtils.js +0 -118
  94. package/lib/utils.js +0 -995
  95. package/yarn-error.log +0 -7780
@@ -0,0 +1,319 @@
1
+ import { L as Layout, a as LayoutItem, C as CompactType, M as Mutable, c as Compactor, P as Position, d as ResizeHandleAxis, i as PositionStrategy } from './types-Cxf4nHNr.js';
2
+
3
+ /**
4
+ * Core layout manipulation utilities.
5
+ *
6
+ * These functions create, modify, and query grid layouts.
7
+ * All functions treat layouts as immutable - they return new arrays/objects.
8
+ */
9
+
10
+ /**
11
+ * Get the bottom-most Y coordinate of the layout.
12
+ *
13
+ * This is the Y position plus height of the lowest item.
14
+ *
15
+ * @param layout - Layout to measure
16
+ * @returns The bottom Y coordinate (0 if layout is empty)
17
+ */
18
+ declare function bottom(layout: Layout): number;
19
+ /**
20
+ * Get a layout item by its ID.
21
+ *
22
+ * @param layout - Layout to search
23
+ * @param id - Item ID to find
24
+ * @returns The layout item, or undefined if not found
25
+ */
26
+ declare function getLayoutItem(layout: Layout, id: string): LayoutItem | undefined;
27
+ /**
28
+ * Get all static items from the layout.
29
+ *
30
+ * Static items cannot be moved or resized by the user.
31
+ *
32
+ * @param layout - Layout to filter
33
+ * @returns Array of static layout items
34
+ */
35
+ declare function getStatics(layout: Layout): LayoutItem[];
36
+ /**
37
+ * Clone a layout item.
38
+ *
39
+ * Creates a shallow copy with all properties preserved.
40
+ * Boolean properties are normalized (undefined becomes false).
41
+ *
42
+ * @param layoutItem - Item to clone
43
+ * @returns A new layout item with the same properties
44
+ */
45
+ declare function cloneLayoutItem(layoutItem: LayoutItem): LayoutItem;
46
+ /**
47
+ * Clone an entire layout.
48
+ *
49
+ * Creates a new array with cloned items.
50
+ *
51
+ * @param layout - Layout to clone
52
+ * @returns A new layout with cloned items
53
+ */
54
+ declare function cloneLayout(layout: Layout): LayoutItem[];
55
+ /**
56
+ * Replace a layout item in a layout.
57
+ *
58
+ * Returns a new layout with the item replaced. Other items are not cloned.
59
+ *
60
+ * @param layout - Layout to modify
61
+ * @param layoutItem - New item (matched by `i` property)
62
+ * @returns New layout with the item replaced
63
+ */
64
+ declare function modifyLayout(layout: Layout, layoutItem: LayoutItem): LayoutItem[];
65
+ /**
66
+ * Apply a transformation to a layout item.
67
+ *
68
+ * Finds the item by key, clones it, applies the callback, and returns
69
+ * a new layout with the modified item.
70
+ *
71
+ * @param layout - Layout to modify
72
+ * @param itemKey - Key of the item to modify
73
+ * @param cb - Callback that receives the cloned item and returns the modified item
74
+ * @returns Tuple of [new layout, modified item or null if not found]
75
+ */
76
+ declare function withLayoutItem(layout: Layout, itemKey: string, cb: (item: LayoutItem) => LayoutItem): [LayoutItem[], LayoutItem | null];
77
+ /**
78
+ * Ensure all layout items fit within the grid bounds.
79
+ *
80
+ * - Items overflowing right are moved left
81
+ * - Items overflowing left are moved to x=0 and clamped to grid width
82
+ * - Static items that collide with other statics are moved down
83
+ *
84
+ * **IMPORTANT**: This function mutates the layout items in place for performance.
85
+ * The type signature uses `Mutable<LayoutItem>[]` to make this explicit.
86
+ * Clone the layout first (e.g., with `cloneLayout()`) if you need immutability.
87
+ *
88
+ * @param layout - Layout to correct (items WILL be mutated)
89
+ * @param bounds - Grid bounds
90
+ * @returns The same layout array (for chaining)
91
+ */
92
+ declare function correctBounds(layout: Mutable<LayoutItem>[], bounds: {
93
+ cols: number;
94
+ }): LayoutItem[];
95
+ /**
96
+ * Move a layout element to a new position.
97
+ *
98
+ * Handles collision detection and cascading movements.
99
+ * Does not compact the layout - call `compact()` separately.
100
+ *
101
+ * **Note**: This function mutates the `l` parameter directly for performance.
102
+ * The item's x, y, and moved properties will be modified. Callers should
103
+ * ideally pass a cloned item if they need to preserve the original.
104
+ *
105
+ * @param layout - Full layout
106
+ * @param l - Item to move (will be mutated)
107
+ * @param x - New X position (or undefined to keep current)
108
+ * @param y - New Y position (or undefined to keep current)
109
+ * @param isUserAction - True if this is a direct user action (affects collision resolution)
110
+ * @param preventCollision - True to prevent movement if it causes collision
111
+ * @param compactType - Compaction type for collision resolution
112
+ * @param cols - Number of columns in the grid
113
+ * @param allowOverlap - True to allow items to overlap
114
+ * @returns The updated layout
115
+ */
116
+ 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[];
117
+ /**
118
+ * Move an item away from a collision.
119
+ *
120
+ * Attempts to move the item up/left first if there's room,
121
+ * otherwise moves it down/right.
122
+ *
123
+ * @param layout - Full layout
124
+ * @param collidesWith - The item being collided with
125
+ * @param itemToMove - The item to move away
126
+ * @param isUserAction - True if this is a direct user action
127
+ * @param compactType - Compaction type
128
+ * @param cols - Number of columns
129
+ * @returns Updated layout
130
+ */
131
+ declare function moveElementAwayFromCollision(layout: Layout, collidesWith: LayoutItem, itemToMove: LayoutItem, isUserAction: boolean | undefined, compactType: CompactType, cols: number): LayoutItem[];
132
+ /**
133
+ * Validate that a layout has the required properties.
134
+ *
135
+ * @param layout - Layout to validate
136
+ * @param contextName - Name for error messages
137
+ * @throws Error if layout is invalid
138
+ */
139
+ declare function validateLayout(layout: Layout, contextName?: string): void;
140
+
141
+ /**
142
+ * Compactor implementations.
143
+ *
144
+ * Compactors are pluggable strategies for removing gaps between grid items.
145
+ * Use the Compactor interface to create custom compaction algorithms.
146
+ */
147
+
148
+ /**
149
+ * Resolve a compaction collision by moving items.
150
+ *
151
+ * Before moving an item to a position, checks if that movement would
152
+ * cause collisions and recursively moves those items first.
153
+ *
154
+ * Useful for implementing custom compactors.
155
+ *
156
+ * @param layout - Full layout (must be sorted for optimization)
157
+ * @param item - Item being moved (will be mutated)
158
+ * @param moveToCoord - Target coordinate
159
+ * @param axis - Which axis to move on ('x' or 'y')
160
+ */
161
+ declare function resolveCompactionCollision(layout: Layout, item: LayoutItem, moveToCoord: number, axis: "x" | "y"): void;
162
+ /**
163
+ * Compact a single item vertically (move up).
164
+ *
165
+ * Moves the item as far up as possible without colliding.
166
+ * Useful for implementing custom vertical compactors.
167
+ *
168
+ * @param compareWith - Items to check for collisions
169
+ * @param l - Item to compact (will be mutated)
170
+ * @param fullLayout - Full layout for collision resolution
171
+ * @param maxY - Maximum Y to start from
172
+ * @returns The compacted item
173
+ */
174
+ declare function compactItemVertical(compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number): LayoutItem;
175
+ /**
176
+ * Compact a single item horizontally (move left).
177
+ *
178
+ * Moves the item as far left as possible without colliding.
179
+ * Wraps to the next row if it overflows.
180
+ * Useful for implementing custom horizontal compactors.
181
+ *
182
+ * @param compareWith - Items to check for collisions
183
+ * @param l - Item to compact (will be mutated)
184
+ * @param cols - Number of columns in the grid
185
+ * @param fullLayout - Full layout for collision resolution
186
+ * @returns The compacted item
187
+ */
188
+ declare function compactItemHorizontal(compareWith: Layout, l: LayoutItem, cols: number, fullLayout: Layout): LayoutItem;
189
+ /**
190
+ * Vertical compactor - moves items up to fill gaps.
191
+ *
192
+ * Items are sorted by row then column, and each item is moved
193
+ * as far up as possible without overlapping other items.
194
+ *
195
+ * This is the default compaction mode for react-grid-layout.
196
+ */
197
+ declare const verticalCompactor: Compactor;
198
+ /**
199
+ * Horizontal compactor - moves items left to fill gaps.
200
+ *
201
+ * Items are sorted by column then row, and each item is moved
202
+ * as far left as possible without overlapping other items.
203
+ */
204
+ declare const horizontalCompactor: Compactor;
205
+ /**
206
+ * No compaction - items stay where placed.
207
+ *
208
+ * Use this for free-form layouts where items can be placed anywhere.
209
+ * Items will not automatically move to fill gaps.
210
+ */
211
+ declare const noCompactor: Compactor;
212
+ /**
213
+ * Vertical compactor that allows overlapping items.
214
+ *
215
+ * Items compact upward but are allowed to overlap each other.
216
+ * Useful for layered layouts or when collision detection is handled externally.
217
+ */
218
+ declare const verticalOverlapCompactor: Compactor;
219
+ /**
220
+ * Horizontal compactor that allows overlapping items.
221
+ */
222
+ declare const horizontalOverlapCompactor: Compactor;
223
+ /**
224
+ * Get a compactor by type.
225
+ *
226
+ * This is a convenience function for backwards compatibility with the
227
+ * string-based compactType API.
228
+ *
229
+ * @param compactType - 'vertical', 'horizontal', or null
230
+ * @param allowOverlap - Whether to allow overlapping items
231
+ * @returns The appropriate Compactor
232
+ */
233
+ declare function getCompactor(compactType: "vertical" | "horizontal" | null, allowOverlap?: boolean, preventCollision?: boolean): Compactor;
234
+
235
+ /**
236
+ * Position calculation utilities.
237
+ *
238
+ * These functions convert between grid units and pixel positions,
239
+ * and generate CSS styles for grid items.
240
+ */
241
+
242
+ /**
243
+ * Generate CSS transform-based positioning styles.
244
+ *
245
+ * Using transforms is more performant than top/left positioning
246
+ * because it doesn't trigger layout recalculations.
247
+ *
248
+ * @param position - Position in pixels
249
+ * @returns CSS style object
250
+ */
251
+ declare function setTransform({ top, left, width, height }: Position): Record<string, string>;
252
+ /**
253
+ * Generate CSS top/left positioning styles.
254
+ *
255
+ * Use this when transforms are not suitable (e.g., for printing
256
+ * or when transform causes issues with child elements).
257
+ *
258
+ * @param position - Position in pixels
259
+ * @returns CSS style object
260
+ */
261
+ declare function setTopLeft({ top, left, width, height }: Position): Record<string, string>;
262
+ /**
263
+ * Convert a number to a percentage string.
264
+ *
265
+ * @param num - Number to convert (0-1 range typically)
266
+ * @returns Percentage string (e.g., "50%")
267
+ */
268
+ declare function perc(num: number): string;
269
+ /**
270
+ * Resize an item in a specific direction, clamping to container bounds.
271
+ *
272
+ * This handles the complex logic of resizing from different edges/corners,
273
+ * ensuring the item doesn't overflow the container.
274
+ *
275
+ * @param direction - Which edge/corner is being dragged
276
+ * @param currentSize - Current position and size
277
+ * @param newSize - Requested new position and size
278
+ * @param containerWidth - Width of the container
279
+ * @returns Constrained position and size
280
+ */
281
+ declare function resizeItemInDirection(direction: ResizeHandleAxis, currentSize: Position, newSize: Position, containerWidth: number): Position;
282
+ /**
283
+ * CSS transform-based positioning strategy.
284
+ *
285
+ * Uses CSS transforms for positioning, which is more performant
286
+ * as it doesn't trigger layout recalculations.
287
+ *
288
+ * This is the default strategy.
289
+ */
290
+ declare const transformStrategy: PositionStrategy;
291
+ /**
292
+ * Absolute (top/left) positioning strategy.
293
+ *
294
+ * Uses CSS top/left for positioning. Use this when CSS transforms
295
+ * cause issues (e.g., printing, certain child element positioning).
296
+ */
297
+ declare const absoluteStrategy: PositionStrategy;
298
+ /**
299
+ * Create a scaled transform strategy.
300
+ *
301
+ * Use this when the grid container is inside a scaled element
302
+ * (e.g., `transform: scale(0.5)`). The scale factor adjusts
303
+ * drag/resize calculations to account for the parent transform.
304
+ *
305
+ * @param scale - Scale factor (e.g., 0.5 for half size)
306
+ * @returns Position strategy with scaled calculations
307
+ *
308
+ * @example
309
+ * ```tsx
310
+ * <div style={{ transform: 'scale(0.5)' }}>
311
+ * <GridLayout positionStrategy={createScaledStrategy(0.5)} />
312
+ * </div>
313
+ * ```
314
+ */
315
+ declare function createScaledStrategy(scale: number): PositionStrategy;
316
+ /** Default position strategy (transform-based) */
317
+ declare const defaultPositionStrategy: PositionStrategy;
318
+
319
+ export { createScaledStrategy as A, defaultPositionStrategy as B, 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, compactItemVertical as q, resolveCompactionCollision as r, setTransform as s, compactItemHorizontal as t, perc as u, validateLayout as v, withLayoutItem as w, resizeItemInDirection as x, transformStrategy as y, absoluteStrategy as z };
@@ -0,0 +1,351 @@
1
+ import React__default, { ReactElement, CSSProperties, RefObject } from 'react';
2
+ import { D as DroppingPosition, d as ResizeHandleAxis, G as GridDragEvent, e as GridResizeEvent, L as Layout, C as CompactType, a as LayoutItem, c as Compactor, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-Cxf4nHNr.mjs';
3
+ export { P as Position } from './types-Cxf4nHNr.mjs';
4
+ export { E as EventCallback, G as GridLayout, a as GridLayoutProps, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-D6lFRE3f.mjs';
5
+ 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-BmN1z36J.mjs';
6
+ export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-CwYDW8na.mjs';
7
+
8
+ /**
9
+ * GridItem component
10
+ *
11
+ * An individual item within a grid layout. Handles dragging and resizing.
12
+ */
13
+
14
+ type GridItemCallback<Data extends GridDragEvent | GridResizeEvent> = (i: string, w: number, h: number, data: Data) => void;
15
+ type ResizeHandle = ReactElement | ((resizeHandleAxis: ResizeHandleAxis, ref: React__default.Ref<HTMLElement>) => ReactElement);
16
+ interface GridItemProps {
17
+ /** Child element to render */
18
+ children: ReactElement;
19
+ /** Number of columns in the grid */
20
+ cols: number;
21
+ /** Width of the container in pixels */
22
+ containerWidth: number;
23
+ /** Margin between items [x, y] */
24
+ margin: readonly [number, number];
25
+ /** Padding inside the container [x, y] */
26
+ containerPadding: readonly [number, number];
27
+ /** Height of each row in pixels */
28
+ rowHeight: number;
29
+ /** Maximum number of rows */
30
+ maxRows: number;
31
+ /** Whether the item can be dragged */
32
+ isDraggable: boolean;
33
+ /** Whether the item can be resized */
34
+ isResizable: boolean;
35
+ /** Whether the item is bounded within the container */
36
+ isBounded: boolean;
37
+ /** Whether the item is static (can't be moved/resized) */
38
+ static?: boolean;
39
+ /** Use CSS transforms instead of top/left */
40
+ useCSSTransforms?: boolean;
41
+ /** Use percentage widths for server rendering */
42
+ usePercentages?: boolean;
43
+ /** Scale factor for transforms */
44
+ transformScale?: number;
45
+ /** Current position of a dropping element */
46
+ droppingPosition?: DroppingPosition;
47
+ /** Additional class name */
48
+ className?: string;
49
+ /** Additional styles */
50
+ style?: CSSProperties;
51
+ /** CSS selector for draggable handle */
52
+ handle?: string;
53
+ /** CSS selector for cancel handle */
54
+ cancel?: string;
55
+ /** X position in grid units */
56
+ x: number;
57
+ /** Y position in grid units */
58
+ y: number;
59
+ /** Width in grid units */
60
+ w: number;
61
+ /** Height in grid units */
62
+ h: number;
63
+ /** Minimum width in grid units */
64
+ minW?: number;
65
+ /** Maximum width in grid units */
66
+ maxW?: number;
67
+ /** Minimum height in grid units */
68
+ minH?: number;
69
+ /** Maximum height in grid units */
70
+ maxH?: number;
71
+ /** Unique identifier */
72
+ i: string;
73
+ /** Which resize handles to show */
74
+ resizeHandles?: ResizeHandleAxis[];
75
+ /** Custom resize handle */
76
+ resizeHandle?: ResizeHandle;
77
+ /** Called when drag starts */
78
+ onDragStart?: GridItemCallback<GridDragEvent>;
79
+ /** Called during drag */
80
+ onDrag?: GridItemCallback<GridDragEvent>;
81
+ /** Called when drag stops */
82
+ onDragStop?: GridItemCallback<GridDragEvent>;
83
+ /** Called when resize starts */
84
+ onResizeStart?: GridItemCallback<GridResizeEvent>;
85
+ /** Called during resize */
86
+ onResize?: GridItemCallback<GridResizeEvent>;
87
+ /** Called when resize stops */
88
+ onResizeStop?: GridItemCallback<GridResizeEvent>;
89
+ }
90
+ /**
91
+ * GridItem - An individual item within a grid layout.
92
+ *
93
+ * Wraps a child element with drag and resize functionality.
94
+ */
95
+ declare function GridItem(props: GridItemProps): ReactElement;
96
+
97
+ /**
98
+ * useContainerWidth hook
99
+ *
100
+ * Observes container width using ResizeObserver and provides
101
+ * reactive width updates for responsive layouts.
102
+ */
103
+
104
+ interface UseContainerWidthOptions {
105
+ /**
106
+ * If true, delays initial render until width is measured.
107
+ * Useful for SSR or when you need accurate initial measurements.
108
+ */
109
+ measureBeforeMount?: boolean;
110
+ /**
111
+ * Initial width to use before measurement.
112
+ * Defaults to 1280.
113
+ */
114
+ initialWidth?: number;
115
+ }
116
+ interface UseContainerWidthResult {
117
+ /**
118
+ * Current container width in pixels.
119
+ */
120
+ width: number;
121
+ /**
122
+ * Whether the container has been measured at least once.
123
+ */
124
+ mounted: boolean;
125
+ /**
126
+ * Ref to attach to the container element.
127
+ */
128
+ containerRef: RefObject<HTMLDivElement | null>;
129
+ /**
130
+ * Manually trigger a width measurement.
131
+ * Useful when the container size might change without a resize event.
132
+ */
133
+ measureWidth: () => void;
134
+ }
135
+ /**
136
+ * Hook to observe and track container width.
137
+ *
138
+ * Replaces the WidthProvider HOC with a more composable approach.
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * function MyGrid() {
143
+ * const { width, containerRef, mounted } = useContainerWidth();
144
+ *
145
+ * return (
146
+ * <div ref={containerRef}>
147
+ * {mounted && <GridLayout width={width} {...props} />}
148
+ * </div>
149
+ * );
150
+ * }
151
+ * ```
152
+ */
153
+ declare function useContainerWidth(options?: UseContainerWidthOptions): UseContainerWidthResult;
154
+
155
+ /**
156
+ * useGridLayout hook
157
+ *
158
+ * Core hook for managing grid layout state, including drag, resize, and drop operations.
159
+ * This extracts the state management logic from ReactGridLayout into a reusable hook.
160
+ */
161
+
162
+ interface DragState {
163
+ /** Currently dragging item placeholder */
164
+ activeDrag: LayoutItem | null;
165
+ /** Original item before drag started */
166
+ oldDragItem: LayoutItem | null;
167
+ /** Layout before drag started */
168
+ oldLayout: Layout | null;
169
+ }
170
+ interface ResizeState {
171
+ /** Whether a resize is in progress */
172
+ resizing: boolean;
173
+ /** Original item before resize started */
174
+ oldResizeItem: LayoutItem | null;
175
+ /** Layout before resize started */
176
+ oldLayout: Layout | null;
177
+ }
178
+ interface DropState {
179
+ /** DOM node for the dropping placeholder */
180
+ droppingDOMNode: React.ReactElement | null;
181
+ /** Current drop position */
182
+ droppingPosition: DroppingPosition | null;
183
+ }
184
+ interface UseGridLayoutOptions {
185
+ /** Initial layout */
186
+ layout: Layout;
187
+ /** Number of columns */
188
+ cols: number;
189
+ /** Compaction type: 'vertical', 'horizontal', or null */
190
+ compactType?: CompactType;
191
+ /** Allow items to overlap */
192
+ allowOverlap?: boolean;
193
+ /** Prevent collisions when moving items */
194
+ preventCollision?: boolean;
195
+ /** Called when layout changes */
196
+ onLayoutChange?: (layout: Layout) => void;
197
+ }
198
+ interface UseGridLayoutResult {
199
+ /** Current layout */
200
+ layout: Layout;
201
+ /** Set layout directly */
202
+ setLayout: (layout: Layout) => void;
203
+ /** Drag state */
204
+ dragState: DragState;
205
+ /** Resize state */
206
+ resizeState: ResizeState;
207
+ /** Drop state */
208
+ dropState: DropState;
209
+ /** Start dragging an item */
210
+ onDragStart: (itemId: string, x: number, y: number) => LayoutItem | null;
211
+ /** Update drag position */
212
+ onDrag: (itemId: string, x: number, y: number) => void;
213
+ /** Stop dragging */
214
+ onDragStop: (itemId: string, x: number, y: number) => void;
215
+ /** Start resizing an item */
216
+ onResizeStart: (itemId: string) => LayoutItem | null;
217
+ /** Update resize dimensions */
218
+ onResize: (itemId: string, w: number, h: number, x?: number, y?: number) => void;
219
+ /** Stop resizing */
220
+ onResizeStop: (itemId: string, w: number, h: number) => void;
221
+ /** Start dropping (external drag-in) */
222
+ onDropDragOver: (droppingItem: LayoutItem, position: DroppingPosition) => void;
223
+ /** Update drop position */
224
+ onDropDragLeave: () => void;
225
+ /** Complete drop */
226
+ onDrop: (droppingItem: LayoutItem) => void;
227
+ /** Container height in rows */
228
+ containerHeight: number;
229
+ /** Whether any drag/resize is active */
230
+ isInteracting: boolean;
231
+ /** Get the compactor being used */
232
+ compactor: Compactor;
233
+ }
234
+ /**
235
+ * Hook for managing grid layout state.
236
+ *
237
+ * Handles all layout state including drag, resize, and drop operations.
238
+ * Uses immutable updates and provides callbacks for all interactions.
239
+ *
240
+ * @example
241
+ * ```tsx
242
+ * function MyGrid() {
243
+ * const {
244
+ * layout,
245
+ * onDragStart,
246
+ * onDrag,
247
+ * onDragStop,
248
+ * containerHeight
249
+ * } = useGridLayout({
250
+ * layout: initialLayout,
251
+ * cols: 12,
252
+ * compactType: 'vertical'
253
+ * });
254
+ *
255
+ * return (
256
+ * <div style={{ height: containerHeight }}>
257
+ * {layout.map(item => (
258
+ * <GridItem
259
+ * key={item.i}
260
+ * {...item}
261
+ * onDragStart={() => onDragStart(item.i, item.x, item.y)}
262
+ * />
263
+ * ))}
264
+ * </div>
265
+ * );
266
+ * }
267
+ * ```
268
+ */
269
+ declare function useGridLayout(options: UseGridLayoutOptions): UseGridLayoutResult;
270
+
271
+ /**
272
+ * useResponsiveLayout hook
273
+ *
274
+ * Manages responsive breakpoints and layout generation for different screen sizes.
275
+ * Extracts state management from ResponsiveReactGridLayout into a reusable hook.
276
+ */
277
+
278
+ /** Default breakpoint names */
279
+ type DefaultBreakpoints = "lg" | "md" | "sm" | "xs" | "xxs";
280
+ /** Default breakpoint widths */
281
+ declare const DEFAULT_BREAKPOINTS: Breakpoints<DefaultBreakpoints>;
282
+ /** Default column counts per breakpoint */
283
+ declare const DEFAULT_COLS: Breakpoints<DefaultBreakpoints>;
284
+ interface UseResponsiveLayoutOptions<B extends Breakpoint = DefaultBreakpoints> {
285
+ /** Current container width */
286
+ width: number;
287
+ /** Breakpoint definitions (name → min-width) */
288
+ breakpoints?: Breakpoints<B>;
289
+ /** Column counts per breakpoint */
290
+ cols?: Breakpoints<B>;
291
+ /** Layouts for each breakpoint */
292
+ layouts?: ResponsiveLayouts<B>;
293
+ /** Compaction type */
294
+ compactType?: CompactType;
295
+ /** Called when breakpoint changes */
296
+ onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
297
+ /** Called when layout changes */
298
+ onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
299
+ /** Called when width changes */
300
+ onWidthChange?: (width: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
301
+ }
302
+ interface UseResponsiveLayoutResult<B extends Breakpoint = DefaultBreakpoints> {
303
+ /** Current layout for the active breakpoint */
304
+ layout: Layout;
305
+ /** All layouts by breakpoint */
306
+ layouts: ResponsiveLayouts<B>;
307
+ /** Current active breakpoint */
308
+ breakpoint: B;
309
+ /** Column count for the current breakpoint */
310
+ cols: number;
311
+ /** Update layouts for a specific breakpoint */
312
+ setLayoutForBreakpoint: (breakpoint: B, layout: Layout) => void;
313
+ /** Update all layouts */
314
+ setLayouts: (layouts: ResponsiveLayouts<B>) => void;
315
+ /** Sorted array of breakpoint names (smallest to largest) */
316
+ sortedBreakpoints: B[];
317
+ }
318
+ /**
319
+ * Hook for managing responsive grid layouts.
320
+ *
321
+ * Automatically selects the appropriate layout based on container width
322
+ * and generates layouts for new breakpoints from existing ones.
323
+ *
324
+ * @example
325
+ * ```tsx
326
+ * function MyResponsiveGrid() {
327
+ * const { width, containerRef } = useContainerWidth();
328
+ * const { layout, breakpoint, cols } = useResponsiveLayout({
329
+ * width,
330
+ * layouts: {
331
+ * lg: [...],
332
+ * md: [...],
333
+ * sm: [...]
334
+ * }
335
+ * });
336
+ *
337
+ * return (
338
+ * <div ref={containerRef}>
339
+ * <GridLayout
340
+ * width={width}
341
+ * cols={cols}
342
+ * layout={layout}
343
+ * />
344
+ * </div>
345
+ * );
346
+ * }
347
+ * ```
348
+ */
349
+ declare function useResponsiveLayout<B extends Breakpoint = DefaultBreakpoints>(options: UseResponsiveLayoutOptions<B>): UseResponsiveLayoutResult<B>;
350
+
351
+ export { Breakpoint, Breakpoints, CompactType, Compactor, DEFAULT_BREAKPOINTS, DEFAULT_COLS, type DefaultBreakpoints, type DragState, type DropState, DroppingPosition, GridDragEvent, GridItem, type GridItemCallback, type GridItemProps, GridResizeEvent, Layout, LayoutItem, type ResizeHandle, ResizeHandleAxis, type ResizeState, ResponsiveLayouts, type UseContainerWidthOptions, type UseContainerWidthResult, type UseGridLayoutOptions, type UseGridLayoutResult, type UseResponsiveLayoutOptions, type UseResponsiveLayoutResult, useContainerWidth, useGridLayout, useResponsiveLayout };