react-grid-layout 2.2.1 → 2.2.3

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 (63) hide show
  1. package/dist/{ResponsiveGridLayout-MbDNfJ8M.d.ts → ResponsiveGridLayout-BjVraYMQ.d.mts} +2 -3
  2. package/dist/{ResponsiveGridLayout-DqK__izz.d.mts → ResponsiveGridLayout-BrhkSyZk.d.ts} +2 -3
  3. package/dist/{calculate-FbCWy8x1.d.mts → calculate-DH4EVtn1.d.mts} +2 -2
  4. package/dist/{calculate-9RxGrt-U.d.ts → calculate-rP3DHexe.d.ts} +2 -2
  5. package/dist/{chunk-2DDROKB2.js → chunk-55DQUWLA.js} +21 -23
  6. package/dist/{chunk-AWM66AWF.mjs → chunk-76RTO6EO.mjs} +0 -2
  7. package/dist/{chunk-QGXQSZII.js → chunk-7MZZ6T4J.js} +49 -35
  8. package/dist/{chunk-BJFPTW5Q.js → chunk-A5WIFECI.js} +0 -2
  9. package/dist/{chunk-3CEWSUXL.js → chunk-BPZQUJ7Y.js} +101 -84
  10. package/dist/{chunk-XYPIYYYQ.mjs → chunk-KDANGDDL.mjs} +1 -3
  11. package/dist/chunk-O3KX3VYW.mjs +1 -0
  12. package/dist/{chunk-YFVX5RDK.mjs → chunk-PZLKKWSX.mjs} +19 -5
  13. package/dist/{chunk-AZ6K3JIJ.mjs → chunk-WGL5FSZH.mjs} +34 -17
  14. package/dist/chunk-ZJHF4QM5.js +2 -0
  15. package/dist/core.d.mts +5 -5
  16. package/dist/core.d.ts +5 -5
  17. package/dist/core.js +68 -70
  18. package/dist/core.mjs +3 -5
  19. package/dist/extras.d.mts +2 -2
  20. package/dist/extras.d.ts +2 -2
  21. package/dist/extras.js +8 -10
  22. package/dist/extras.mjs +1 -3
  23. package/dist/index.d.mts +5 -5
  24. package/dist/index.d.ts +5 -5
  25. package/dist/index.js +40 -42
  26. package/dist/index.mjs +5 -7
  27. package/dist/legacy.d.mts +2 -2
  28. package/dist/legacy.d.ts +2 -2
  29. package/dist/legacy.js +25 -17
  30. package/dist/legacy.mjs +14 -6
  31. package/dist/{position-CetgOHhD.d.mts → position-BV-g3Ezg.d.mts} +2 -2
  32. package/dist/{position-DhZqWO1-.d.ts → position-CSgQSjwQ.d.ts} +2 -2
  33. package/dist/react.d.mts +5 -5
  34. package/dist/react.d.ts +5 -5
  35. package/dist/react.js +26 -28
  36. package/dist/react.mjs +5 -7
  37. package/dist/{responsive-T0N0GmBB.d.mts → responsive-BrTV_0tK.d.mts} +2 -2
  38. package/dist/{responsive-DLRtE8v8.d.ts → responsive-C_YtBQYq.d.ts} +2 -2
  39. package/dist/{types-BiXsdXr7.d.mts → types-jd8MiKM1.d.mts} +1 -1
  40. package/dist/{types-BiXsdXr7.d.ts → types-jd8MiKM1.d.ts} +1 -1
  41. package/package.json +22 -22
  42. package/dist/chunk-2DDROKB2.js.map +0 -1
  43. package/dist/chunk-3CEWSUXL.js.map +0 -1
  44. package/dist/chunk-AWM66AWF.mjs.map +0 -1
  45. package/dist/chunk-AZ6K3JIJ.mjs.map +0 -1
  46. package/dist/chunk-BJFPTW5Q.js.map +0 -1
  47. package/dist/chunk-PBQSHIID.js +0 -4
  48. package/dist/chunk-PBQSHIID.js.map +0 -1
  49. package/dist/chunk-QGXQSZII.js.map +0 -1
  50. package/dist/chunk-XYPIYYYQ.mjs.map +0 -1
  51. package/dist/chunk-YFVX5RDK.mjs.map +0 -1
  52. package/dist/chunk-ZWN22PS2.mjs +0 -3
  53. package/dist/chunk-ZWN22PS2.mjs.map +0 -1
  54. package/dist/core.js.map +0 -1
  55. package/dist/core.mjs.map +0 -1
  56. package/dist/extras.js.map +0 -1
  57. package/dist/extras.mjs.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/index.mjs.map +0 -1
  60. package/dist/legacy.js.map +0 -1
  61. package/dist/legacy.mjs.map +0 -1
  62. package/dist/react.js.map +0 -1
  63. package/dist/react.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"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,aAA8B,IAAI,CAAA;AAEtD,EAAA,MAAM,YAAA,GAAeC,kBAAY,MAAM;AACrC,IAAA,MAAM,OAAO,YAAA,CAAa,OAAA;AAC1B,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,MAAM,WAAW,IAAA,CAAK,WAAA;AACtB,MAAA,QAAA,CAAS,QAAQ,CAAA;AACjB,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,UAAA,CAAW,IAAI,CAAA;AAAA,MACjB;AAAA,IACF;AAAA,EACF,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAO,YAAA,CAAa,OAAA;AAC1B,IAAA,IAAI,CAAC,IAAA,EAAM;AAGX,IAAA,YAAA,EAAa;AAGb,IAAA,IAAI,OAAO,mBAAmB,WAAA,EAAa;AACzC,MAAA,WAAA,CAAY,OAAA,GAAU,IAAI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AAAd,gBAAU,MAAM;AACd,IAAA,IAAI,CAACI,oBAAAA,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,EAAAJ,gBAAU,MAAM;AACd,IAAA,IAAI,CAACI,oBAAAA,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-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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/constraints.ts","../src/core/position.ts","../src/core/types.ts","../src/core/compactors.ts","../src/core/responsive.ts"],"names":[],"mappings":";;;AAqBA,SAAS,KAAA,CAAM,KAAA,EAAe,GAAA,EAAa,GAAA,EAAqB;AAC9D,EAAA,OAAO,KAAK,GAAA,CAAI,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;AAYO,IAAM,UAAA,GAA+B;AAAA,EAC1C,IAAA,EAAM,YAAA;AAAA,EAEN,kBACE,IAAA,EACA,CAAA,EACA,GACA,EAAE,IAAA,EAAM,SAAQ,EACU;AAC1B,IAAA,OAAO;AAAA,MACL,CAAA,EAAG,KAAA,CAAM,CAAA,EAAG,CAAA,EAAG,IAAA,CAAK,IAAI,CAAA,EAAG,IAAA,GAAO,IAAA,CAAK,CAAC,CAAC,CAAA;AAAA,MACzC,CAAA,EAAG,KAAA,CAAM,CAAA,EAAG,CAAA,EAAG,IAAA,CAAK,IAAI,CAAA,EAAG,OAAA,GAAU,IAAA,CAAK,CAAC,CAAC;AAAA,KAC9C;AAAA,EACF,CAAA;AAAA,EAEA,aAAA,CACE,MACA,CAAA,EACA,CAAA,EACA,QACA,EAAE,IAAA,EAAM,SAAQ,EACU;AAG1B,IAAA,MAAM,IAAA,GACJ,MAAA,KAAW,GAAA,IAAO,MAAA,KAAW,IAAA,IAAQ,MAAA,KAAW,IAAA,GAC5C,IAAA,CAAK,CAAA,GAAI,IAAA,CAAK,CAAA,GACd,IAAA,GAAO,IAAA,CA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,sBAAsB,CAAA;AACzC,EAAA,OAAO,SAAA,CAAU,OAAA,CAAQ,SAAA,EAAW,IAAI,CAAA;AAC1C;AAoBO,SAAS,mBAAA,CACd,OACA,UAAA,EAC2B;AAE3B,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,KAAA;AAAA,EACT;AAGA,EAAA,MAAM,aAAA,GAAgB,KAAA;AACtB,EAAA,MAAM,eAAA,GAAkB,cAAc,UAAU,CAAA;AAChD,EAAA,IAAI,oBAAoB,MAAA,EAAW;AACjC,IAAA,OAAO,eAAA;AAAA,EACT;AAGA,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,aAAa,CAAA;AACtC,EAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,IAAA,MAAM,CAAA,GAAI,cAAc,GAAG,CAAA;AAC3B,IAAA,IAAI,MAAM,MAAA,EAAW;AACnB,MAAA,OAAO,CAAA;AAAA,IACT;AAAA,EACF;AAGA,EAAA,OAAO,CAAC,IAAI,EAAE,CAAA;AAChB","file":"chunk-XYPIYYYQ.mjs","sourcesContent":["/**\n * Pluggable layout constraints for react-grid-layout v2\n *\n * Constraints control position and size limits during drag/resize operations.\n * They are composable, tree-shakeable, and can be applied at grid or item level.\n */\n\nimport type {\n LayoutItem,\n LayoutConstraint,\n ConstraintContext,\n ResizeHandleAxis\n} from \"./types.js\";\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Clamp a value between min and max bounds.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\n// ============================================================================\n// Built-in Constraints\n// ============================================================================\n\n/**\n * Grid boundary constraint.\n *\n * Ensures items stay within the grid bounds (0 to cols-w for x, 0 to maxRows-h for y).\n * This is the default position constraint.\n */\nexport const gridBounds: LayoutConstraint = {\n name: \"gridBounds\",\n\n constrainPosition(\n item: LayoutItem,\n x: number,\n y: number,\n { cols, maxRows }: ConstraintContext\n ): { x: number; y: number } {\n return {\n x: clamp(x, 0, Math.max(0, cols - item.w)),\n y: clamp(y, 0, Math.max(0, maxRows - item.h))\n };\n },\n\n constrainSize(\n item: LayoutItem,\n w: number,\n h: number,\n handle: ResizeHandleAxis,\n { cols, maxRows }: ConstraintContext\n ): { w: number; h: number } {\n // For west-side resizes (w, nw, sw), max width is limited by the right edge position\n // because the item expands leftward (x decreases as w increases)\n const maxW =\n handle === \"w\" || handle === \"nw\" || handle === \"sw\"\n ? item.x + item.w // right edge = x + w, can expand left to x=0\n : cols - item.x; // can expand right to cols\n\n // For north-side resizes (n, nw, ne), max height is limited by the bottom edge position\n // because the item expands upward (y decreases as h increases)\n const maxH =\n handle === \"n\" || handle === \"nw\" || handle === \"ne\"\n ? item.y + item.h // bottom edge = y + h, can expand up to y=0\n : maxRows - item.y; // can expand down to maxRows\n\n return {\n w: clamp(w, 1, Math.max(1, maxW)),\n h: clamp(h, 1, Math.max(1, maxH))\n };\n }\n};\n\n/**\n * Min/max size constraint.\n *\n * Enforces per-item minW/maxW/minH/maxH properties.\n * This is applied by default after gridBounds.\n */\nexport const minMaxSize: LayoutConstraint = {\n name: \"minMaxSize\",\n\n constrainSize(\n item: LayoutItem,\n w: number,\n h: number\n ): { w: number; h: number } {\n return {\n w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),\n h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)\n };\n }\n};\n\n/**\n * Container bounds constraint.\n *\n * Constrains items to stay within the visible container.\n * Use this as a replacement for the legacy `isBounded` prop.\n *\n * Unlike gridBounds which uses maxRows (which may be Infinity),\n * this constraint calculates visible rows from the actual container height.\n * Falls back to maxRows if containerHeight is 0 (auto-height grids).\n */\nexport const containerBounds: LayoutConstraint = {\n name: \"containerBounds\",\n\n constrainPosition(\n item: LayoutItem,\n x: number,\n y: number,\n { cols, maxRows, containerHeight, rowHeight, margin }: ConstraintContext\n ): { x: number; y: number } {\n // Calculate visible rows from container height\n // Formula: containerHeight = rows * rowHeight + (rows - 1) * margin\n // Solving: rows = (containerHeight + margin) / (rowHeight + margin)\n const visibleRows =\n containerHeight > 0\n ? Math.floor((containerHeight + margin[1]) / (rowHeight + margin[1]))\n : maxRows;\n\n return {\n x: clamp(x, 0, Math.max(0, cols - item.w)),\n y: clamp(y, 0, Math.max(0, visibleRows - item.h))\n };\n }\n};\n\n/**\n * Bounded X constraint.\n *\n * Only constrains horizontal position (x-axis).\n * Items can move freely in the vertical direction.\n */\nexport const boundedX: LayoutConstraint = {\n name: \"boundedX\",\n\n constrainPosition(\n item: LayoutItem,\n x: number,\n y: number,\n { cols }: ConstraintContext\n ): { x: number; y: number } {\n return {\n x: clamp(x, 0, Math.max(0, cols - item.w)),\n y\n };\n }\n};\n\n/**\n * Bounded Y constraint.\n *\n * Only constrains vertical position (y-axis).\n * Items can move freely in the horizontal direction.\n */\nexport const boundedY: LayoutConstraint = {\n name: \"boundedY\",\n\n constrainPosition(\n item: LayoutItem,\n x: number,\n y: number,\n { maxRows }: ConstraintContext\n ): { x: number; y: number } {\n return {\n x,\n y: clamp(y, 0, Math.max(0, maxRows - item.h))\n };\n }\n};\n\n// ============================================================================\n// Constraint Factories\n// ============================================================================\n\n/**\n * Create an aspect ratio constraint.\n *\n * Maintains a fixed width-to-height ratio **in pixels** during resize operations.\n * Accounts for the different pixel sizes of grid columns vs rows.\n *\n * @param ratio - Width-to-height ratio (e.g., 16/9 for widescreen, 1 for square)\n * @returns A constraint that enforces the aspect ratio\n *\n * @example\n * ```typescript\n * // 16:9 aspect ratio (actual pixel proportions)\n * const layout = [\n * { i: 'video', x: 0, y: 0, w: 4, h: 2, constraints: [aspectRatio(16/9)] }\n * ];\n *\n * // Square items (in pixels, not grid units)\n * <GridLayout constraints={[gridBounds, minMaxSize, aspectRatio(1)]} />\n * ```\n */\nexport function aspectRatio(ratio: number): LayoutConstraint {\n return {\n name: `aspectRatio(${ratio})`,\n\n constrainSize(\n _item: LayoutItem,\n w: number,\n _h: number,\n _handle: ResizeHandleAxis,\n context: ConstraintContext\n ): { w: number; h: number } {\n const { cols, containerWidth, rowHeight, margin } = context;\n // Calculate column width in pixels\n // colWidth = (containerWidth - margin[0] * (cols - 1)) / cols\n // Note: simplified formula assumes no container padding\n const colWidth = (containerWidth - margin[0] * (cols - 1)) / cols;\n\n // Calculate pixel width of the item\n // pixelWidth = colWidth * w + margin[0] * (w - 1)\n const pixelWidth = colWidth * w + margin[0] * Math.max(0, w - 1);\n\n // Calculate required pixel height for aspect ratio\n const pixelHeight = pixelWidth / ratio;\n\n // Convert pixel height back to grid units\n // pixelHeight = rowHeight * h + margin[1] * (h - 1)\n // Solving for h:\n // pixelHeight = h * (rowHeight + margin[1]) - margin[1]\n // h = (pixelHeight + margin[1]) / (rowHeight + margin[1])\n const h = Math.max(\n 1,\n Math.round((pixelHeight + margin[1]) / (rowHeight + margin[1]))\n );\n\n return { w, h };\n }\n };\n}\n\n/**\n * Create a snap-to-grid constraint.\n *\n * Snaps positions to multiples of the specified step values.\n * Useful for aligning items to a coarser grid.\n *\n * @param stepX - Horizontal snap step in grid units\n * @param stepY - Vertical snap step in grid units (defaults to stepX)\n * @returns A constraint that snaps positions to the grid\n *\n * @example\n * ```typescript\n * // Snap to every 2 grid units\n * <GridLayout constraints={[snapToGrid(2), gridBounds]} />\n *\n * // Different horizontal and vertical snap\n * <GridLayout constraints={[snapToGrid(2, 3), gridBounds]} />\n * ```\n */\nexport function snapToGrid(\n stepX: number,\n stepY: number = stepX\n): LayoutConstraint {\n // Validate step values to prevent division by zero or invalid snapping\n if (stepX <= 0 || stepY <= 0) {\n throw new Error(\n `snapToGrid: step values must be positive (got stepX=${stepX}, stepY=${stepY})`\n );\n }\n\n return {\n name: `snapToGrid(${stepX}, ${stepY})`,\n\n constrainPosition(\n _item: LayoutItem,\n x: number,\n y: number\n ): { x: number; y: number } {\n return {\n x: Math.round(x / stepX) * stepX,\n y: Math.round(y / stepY) * stepY\n };\n }\n };\n}\n\n/**\n * Create a minimum size constraint.\n *\n * Sets minimum width and height for all items using this constraint.\n * Useful for grid-wide minimums without setting minW/minH on each item.\n *\n * @param minW - Minimum width in grid units\n * @param minH - Minimum height in grid units\n * @returns A constraint that enforces minimum size\n */\nexport function minSize(minW: number, minH: number): LayoutConstraint {\n return {\n name: `minSize(${minW}, ${minH})`,\n\n constrainSize(\n _item: LayoutItem,\n w: number,\n h: number\n ): { w: number; h: number } {\n return {\n w: Math.max(minW, w),\n h: Math.max(minH, h)\n };\n }\n };\n}\n\n/**\n * Create a maximum size constraint.\n *\n * Sets maximum width and height for all items using this constraint.\n * Useful for grid-wide maximums without setting maxW/maxH on each item.\n *\n * @param maxW - Maximum width in grid units\n * @param maxH - Maximum height in grid units\n * @returns A constraint that enforces maximum size\n */\nexport function maxSize(maxW: number, maxH: number): LayoutConstraint {\n return {\n name: `maxSize(${maxW}, ${maxH})`,\n\n constrainSize(\n _item: LayoutItem,\n w: number,\n h: number\n ): { w: number; h: number } {\n return {\n w: Math.min(maxW, w),\n h: Math.min(maxH, h)\n };\n }\n };\n}\n\n// ============================================================================\n// Default Constraints\n// ============================================================================\n\n/**\n * Default constraints applied when none are specified.\n *\n * Includes:\n * - gridBounds: Keep items within the grid\n * - minMaxSize: Respect per-item min/max constraints\n */\nexport const defaultConstraints: LayoutConstraint[] = [gridBounds, minMaxSize];\n\n// ============================================================================\n// Constraint Application Functions\n// ============================================================================\n\n/**\n * Apply position constraints to a proposed position.\n *\n * Constraints are applied in array order, allowing composition.\n * Grid-level constraints are applied first, then per-item constraints.\n *\n * @param constraints - Array of constraints to apply\n * @param item - The layout item being positioned\n * @param x - Proposed x position\n * @param y - Proposed y position\n * @param context - Grid context (cols, maxRows, etc.)\n * @returns Constrained position\n */\nexport function applyPositionConstraints(\n constraints: LayoutConstraint[],\n item: LayoutItem,\n x: number,\n y: number,\n context: ConstraintContext\n): { x: number; y: number } {\n let result = { x, y };\n\n // Apply grid-level constraints\n for (const constraint of constraints) {\n if (constraint.constrainPosition) {\n result = constraint.constrainPosition(item, result.x, result.y, context);\n }\n }\n\n // Apply per-item constraints\n if (item.constraints) {\n for (const constraint of item.constraints) {\n if (constraint.constrainPosition) {\n result = constraint.constrainPosition(\n item,\n result.x,\n result.y,\n context\n );\n }\n }\n }\n\n return result;\n}\n\n/**\n * Apply size constraints to a proposed size.\n *\n * Constraints are applied in array order, allowing composition.\n * Grid-level constraints are applied first, then per-item constraints.\n *\n * @param constraints - Array of constraints to apply\n * @param item - The layout item being resized\n * @param w - Proposed width\n * @param h - Proposed height\n * @param handle - Which resize handle is being used\n * @param context - Grid context (cols, maxRows, etc.)\n * @returns Constrained size\n */\nexport function applySizeConstraints(\n constraints: LayoutConstraint[],\n item: LayoutItem,\n w: number,\n h: number,\n handle: ResizeHandleAxis,\n context: ConstraintContext\n): { w: number; h: number } {\n let result = { w, h };\n\n // Apply grid-level constraints\n for (const constraint of constraints) {\n if (constraint.constrainSize) {\n result = constraint.constrainSize(\n item,\n result.w,\n result.h,\n handle,\n context\n );\n }\n }\n\n // Apply per-item constraints\n if (item.constraints) {\n for (const constraint of item.constraints) {\n if (constraint.constrainSize) {\n result = constraint.constrainSize(\n item,\n result.w,\n result.h,\n handle,\n context\n );\n }\n }\n }\n\n return result;\n}\n","/**\n * Position calculation utilities.\n *\n * These functions convert between grid units and pixel positions,\n * and generate CSS styles for grid items.\n */\n\nimport type {\n Position,\n PartialPosition,\n ResizeHandleAxis,\n PositionStrategy\n} from \"./types.js\";\n\n// ============================================================================\n// CSS Style Generation\n// ============================================================================\n\n/**\n * Generate CSS transform-based positioning styles.\n *\n * Using transforms is more performant than top/left positioning\n * because it doesn't trigger layout recalculations.\n *\n * @param position - Position in pixels\n * @returns CSS style object\n */\nexport function setTransform({\n top,\n left,\n width,\n height\n}: Position): Record<string, string> {\n const translate = `translate(${left}px,${top}px)`;\n return {\n transform: translate,\n WebkitTransform: translate,\n MozTransform: translate,\n msTransform: translate,\n OTransform: translate,\n width: `${width}px`,\n height: `${height}px`,\n position: \"absolute\"\n };\n}\n\n/**\n * Generate CSS top/left positioning styles.\n *\n * Use this when transforms are not suitable (e.g., for printing\n * or when transform causes issues with child elements).\n *\n * @param position - Position in pixels\n * @returns CSS style object\n */\nexport function setTopLeft({\n top,\n left,\n width,\n height\n}: Position): Record<string, string> {\n return {\n top: `${top}px`,\n left: `${left}px`,\n width: `${width}px`,\n height: `${height}px`,\n position: \"absolute\"\n };\n}\n\n/**\n * Convert a number to a percentage string.\n *\n * @param num - Number to convert (0-1 range typically)\n * @returns Percentage string (e.g., \"50%\")\n */\nexport function perc(num: number): string {\n return num * 100 + \"%\";\n}\n\n// ============================================================================\n// Resize Direction Handling\n// ============================================================================\n\n/**\n * Constrain width to not overflow container.\n */\nfunction constrainWidth(\n left: number,\n currentWidth: number,\n newWidth: number,\n containerWidth: number\n): number {\n return left + newWidth > containerWidth ? currentWidth : newWidth;\n}\n\n/**\n * Constrain height to not go above container (negative top).\n */\nfunction constrainHeight(\n top: number,\n currentHeight: number,\n newHeight: number\n): number {\n return top < 0 ? currentHeight : newHeight;\n}\n\n/**\n * Constrain left to not be negative.\n */\nfunction constrainLeft(left: number): number {\n return Math.max(0, left);\n}\n\n/**\n * Constrain top to not be negative.\n */\nfunction constrainTop(top: number): number {\n return Math.max(0, top);\n}\n\n// Direction handlers\ntype ResizeHandler = (\n currentSize: Position,\n newSize: Position,\n containerWidth: number\n) => Position;\n\nconst resizeNorth: ResizeHandler = (currentSize, newSize, _containerWidth) => {\n const { left, height, width } = newSize;\n const top = currentSize.top - (height - currentSize.height);\n\n return {\n left,\n width,\n height: constrainHeight(top, currentSize.height, height),\n top: constrainTop(top)\n };\n};\n\nconst resizeEast: ResizeHandler = (currentSize, newSize, containerWidth) => {\n const { top, left, height, width } = newSize;\n return {\n top,\n height,\n width: constrainWidth(\n currentSize.left,\n currentSize.width,\n width,\n containerWidth\n ),\n left: constrainLeft(left)\n };\n};\n\nconst resizeWest: ResizeHandler = (currentSize, newSize, _containerWidth) => {\n const { top, height, width } = newSize;\n const left = currentSize.left + currentSize.width - width;\n\n if (left < 0) {\n return {\n height,\n width: currentSize.left + currentSize.width,\n top: constrainTop(top),\n left: 0\n };\n }\n\n return {\n height,\n width,\n top: constrainTop(top),\n left\n };\n};\n\nconst resizeSouth: ResizeHandler = (currentSize, newSize, _containerWidth) => {\n const { top, left, height, width } = newSize;\n return {\n width,\n left,\n height: constrainHeight(top, currentSize.height, height),\n top: constrainTop(top)\n };\n};\n\n// Compound directions (corners)\nconst resizeNorthEast: ResizeHandler = (currentSize, newSize, containerWidth) =>\n resizeNorth(\n currentSize,\n resizeEast(currentSize, newSize, containerWidth),\n containerWidth\n );\n\nconst resizeNorthWest: ResizeHandler = (currentSize, newSize, containerWidth) =>\n resizeNorth(\n currentSize,\n resizeWest(currentSize, newSize, containerWidth),\n containerWidth\n );\n\nconst resizeSouthEast: ResizeHandler = (currentSize, newSize, containerWidth) =>\n resizeSouth(\n currentSize,\n resizeEast(currentSize, newSize, containerWidth),\n containerWidth\n );\n\nconst resizeSouthWest: ResizeHandler = (currentSize, newSize, containerWidth) =>\n resizeSouth(\n currentSize,\n resizeWest(currentSize, newSize, containerWidth),\n containerWidth\n );\n\nconst resizeHandlerMap: Record<ResizeHandleAxis, ResizeHandler> = {\n n: resizeNorth,\n ne: resizeNorthEast,\n e: resizeEast,\n se: resizeSouthEast,\n s: resizeSouth,\n sw: resizeSouthWest,\n w: resizeWest,\n nw: resizeNorthWest\n};\n\n/**\n * Resize an item in a specific direction, clamping to container bounds.\n *\n * This handles the complex logic of resizing from different edges/corners,\n * ensuring the item doesn't overflow the container.\n *\n * @param direction - Which edge/corner is being dragged\n * @param currentSize - Current position and size\n * @param newSize - Requested new position and size\n * @param containerWidth - Width of the container\n * @returns Constrained position and size\n */\nexport function resizeItemInDirection(\n direction: ResizeHandleAxis,\n currentSize: Position,\n newSize: Position,\n containerWidth: number\n): Position {\n const handler = resizeHandlerMap[direction];\n\n // Fallback if direction not found (shouldn't happen with proper types)\n if (!handler) {\n return newSize;\n }\n\n return handler(currentSize, { ...currentSize, ...newSize }, containerWidth);\n}\n\n// ============================================================================\n// Position Strategies (v2 Composable Interface)\n// ============================================================================\n\n/**\n * CSS transform-based positioning strategy.\n *\n * Uses CSS transforms for positioning, which is more performant\n * as it doesn't trigger layout recalculations.\n *\n * This is the default strategy.\n */\nexport const transformStrategy: PositionStrategy = {\n type: \"transform\",\n scale: 1,\n\n calcStyle(pos: Position): React.CSSProperties {\n return setTransform(pos) as React.CSSProperties;\n }\n};\n\n/**\n * Absolute (top/left) positioning strategy.\n *\n * Uses CSS top/left for positioning. Use this when CSS transforms\n * cause issues (e.g., printing, certain child element positioning).\n */\nexport const absoluteStrategy: PositionStrategy = {\n type: \"absolute\",\n scale: 1,\n\n calcStyle(pos: Position): React.CSSProperties {\n return setTopLeft(pos) as React.CSSProperties;\n }\n};\n\n/**\n * Create a scaled transform strategy.\n *\n * Use this when the grid container is inside a scaled element\n * (e.g., `transform: scale(0.5)`). The scale factor adjusts\n * drag/resize calculations to account for the parent transform.\n *\n * @param scale - Scale factor (e.g., 0.5 for half size)\n * @returns Position strategy with scaled calculations\n *\n * @example\n * ```tsx\n * <div style={{ transform: 'scale(0.5)' }}>\n * <GridLayout positionStrategy={createScaledStrategy(0.5)} />\n * </div>\n * ```\n */\nexport function createScaledStrategy(scale: number): PositionStrategy {\n return {\n type: \"transform\",\n scale,\n\n calcStyle(pos: Position): React.CSSProperties {\n return setTransform(pos) as React.CSSProperties;\n },\n\n calcDragPosition(\n clientX: number,\n clientY: number,\n offsetX: number,\n offsetY: number\n ): PartialPosition {\n return {\n left: (clientX - offsetX) / scale,\n top: (clientY - offsetY) / scale\n };\n }\n };\n}\n\n/** Default position strategy (transform-based) */\nexport const defaultPositionStrategy = transformStrategy;\n","/**\n * Core types for react-grid-layout v2\n *\n * These types are framework-agnostic and define the data structures\n * used by the layout algorithms.\n */\n\n// ============================================================================\n// Resize Handle Types\n// ============================================================================\n\n/**\n * Axis identifiers for resize handles.\n * - Cardinal: 'n', 's', 'e', 'w' (north, south, east, west)\n * - Diagonal: 'ne', 'nw', 'se', 'sw'\n */\nexport type ResizeHandleAxis =\n | \"s\"\n | \"w\"\n | \"e\"\n | \"n\"\n | \"sw\"\n | \"nw\"\n | \"se\"\n | \"ne\";\n\n// ============================================================================\n// Layout Item Types\n// ============================================================================\n\n/**\n * A single item in the grid layout.\n *\n * Position (x, y) is in grid units, not pixels.\n * Size (w, h) is in grid units.\n */\nexport interface LayoutItem {\n /** Unique identifier for this item */\n i: string;\n\n /** X position in grid units (0-indexed from left) */\n x: number;\n\n /** Y position in grid units (0-indexed from top) */\n y: number;\n\n /** Width in grid units */\n w: number;\n\n /** Height in grid units */\n h: number;\n\n /** Minimum width in grid units */\n minW?: number;\n\n /** Minimum height in grid units */\n minH?: number;\n\n /** Maximum width in grid units */\n maxW?: number;\n\n /** Maximum height in grid units */\n maxH?: number;\n\n /**\n * If true, item cannot be dragged or resized, and other items\n * will move around it during compaction.\n */\n static?: boolean;\n\n /**\n * If false, item cannot be dragged (but may still be resizable).\n * Overrides grid-level isDraggable for this item.\n */\n isDraggable?: boolean;\n\n /**\n * If false, item cannot be resized (but may still be draggable).\n * Overrides grid-level isResizable for this item.\n */\n isResizable?: boolean;\n\n /**\n * Which resize handles to show for this item.\n * Overrides grid-level resizeHandles for this item.\n */\n resizeHandles?: ResizeHandleAxis[];\n\n /**\n * If true, item is constrained to the grid container bounds.\n * Overrides grid-level isBounded for this item.\n */\n isBounded?: boolean;\n\n /**\n * Internal flag set during drag/resize operations to indicate\n * the item has moved from its original position.\n * @internal\n */\n moved?: boolean;\n\n /**\n * Per-item layout constraints.\n * Applied in addition to grid-level constraints.\n */\n constraints?: LayoutConstraint[];\n}\n\n/**\n * A layout is a readonly array of layout items.\n * Layouts should be treated as immutable.\n */\nexport type Layout = readonly LayoutItem[];\n\n// ============================================================================\n// Position & Size Types\n// ============================================================================\n\n/**\n * Pixel position and size of an element.\n */\nexport interface Position {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/**\n * Partial position (just coordinates, no size).\n */\nexport interface PartialPosition {\n left: number;\n top: number;\n}\n\n/**\n * Size in pixels.\n */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/**\n * Position when dropping an external element onto the grid.\n */\nexport interface DroppingPosition {\n left: number;\n top: number;\n e: Event;\n}\n\n// ============================================================================\n// Event Types\n// ============================================================================\n\n/**\n * Data provided by react-draggable during drag operations.\n */\nexport interface ReactDraggableCallbackData {\n node: HTMLElement;\n x?: number;\n y?: number;\n deltaX: number;\n deltaY: number;\n lastX?: number;\n lastY?: number;\n}\n\n/**\n * Grid-level drag event data.\n */\nexport interface GridDragEvent {\n e: Event;\n node: HTMLElement;\n newPosition: PartialPosition;\n}\n\n/**\n * Grid-level resize event data.\n */\nexport interface GridResizeEvent {\n e: Event;\n node: HTMLElement;\n size: Size;\n handle: ResizeHandleAxis;\n}\n\n/**\n * Drag-over event with layer coordinates.\n */\nexport interface DragOverEvent extends MouseEvent {\n nativeEvent: Event & {\n layerX: number;\n layerY: number;\n };\n}\n\n// ============================================================================\n// Compaction Types\n// ============================================================================\n\n/**\n * Type of compaction to apply to the layout.\n * - 'vertical': Items compact upward (default)\n * - 'horizontal': Items compact leftward\n * - 'wrap': Items arranged in wrapped-paragraph style (like words in text)\n * - null: No compaction (free-form positioning)\n */\nexport type CompactType = \"horizontal\" | \"vertical\" | \"wrap\" | null;\n\n// ============================================================================\n// Callback Types\n// ============================================================================\n\n/**\n * Standard callback signature for layout change events.\n *\n * @param layout - The current layout after the change\n * @param oldItem - The item before the change (null if not applicable)\n * @param newItem - The item after the change (null if not applicable)\n * @param placeholder - The placeholder item during drag/resize (null at start)\n * @param event - The DOM event that triggered the change\n * @param element - The DOM element being manipulated (null if not applicable)\n */\nexport type EventCallback = (\n layout: Layout,\n oldItem: LayoutItem | null,\n newItem: LayoutItem | null,\n placeholder: LayoutItem | null,\n event: Event,\n element: HTMLElement | null\n) => void;\n\n/**\n * Callback when layout changes for any reason.\n */\nexport type OnLayoutChangeCallback = (layout: Layout) => void;\n\n// ============================================================================\n// Composable Interfaces (v2 API)\n// ============================================================================\n\n/**\n * Interface for layout compaction strategies.\n *\n * Implement this interface to create custom compaction algorithms.\n *\n * @example\n * ```typescript\n * const myCompactor: Compactor = {\n * type: 'vertical',\n * allowOverlap: false,\n * compact(layout, cols) {\n * // Custom compaction logic\n * return compactedLayout;\n * }\n * };\n * ```\n */\nexport interface Compactor {\n /** Compaction type identifier */\n readonly type: CompactType;\n\n /**\n * Whether items can overlap (stack on top of each other).\n *\n * When true:\n * - Items can be placed on top of other items\n * - Dragging into another item does NOT push it away\n * - Compaction is skipped after drag/resize\n */\n readonly allowOverlap: boolean;\n\n /**\n * Whether to block movement that would cause collision.\n *\n * When true (and allowOverlap is false):\n * - Dragging into another item is blocked (item snaps back)\n * - Other items are NOT pushed away\n * - Only affects drag/resize, not compaction\n *\n * Has no effect when allowOverlap is true.\n */\n readonly preventCollision?: boolean;\n\n /**\n * Compact the layout.\n *\n * @param layout - The layout to compact\n * @param cols - Number of columns in the grid\n * @returns The compacted layout\n */\n compact(layout: Layout, cols: number): Layout;\n}\n\n/**\n * Interface for CSS positioning strategies.\n *\n * Implement this interface to customize how items are positioned in the DOM.\n * Built-in strategies: transformStrategy, absoluteStrategy.\n *\n * @example\n * ```typescript\n * // Use transform-based positioning (default, better performance)\n * <GridLayout positionStrategy={transformStrategy} />\n *\n * // Use top/left positioning (for environments where transforms cause issues)\n * <GridLayout positionStrategy={absoluteStrategy} />\n *\n * // Use scaled transforms (for scaled containers)\n * <GridLayout positionStrategy={createScaledStrategy(0.5)} />\n * ```\n */\nexport interface PositionStrategy {\n /** Strategy type identifier */\n readonly type: \"transform\" | \"absolute\";\n\n /** Scale factor for drag/resize calculations */\n readonly scale: number;\n\n /**\n * Convert pixel position to CSS style object.\n *\n * @param pos - Position in pixels\n * @returns CSS properties for positioning the element\n */\n calcStyle(pos: Position): React.CSSProperties;\n\n /**\n * Calculate position during drag operations, accounting for transforms and scale.\n *\n * This method is optional. When not provided, react-draggable uses its built-in\n * parent-relative coordinate calculation. Only override this when you need custom\n * coordinate handling, such as for scaled containers.\n *\n * @param clientX - Mouse client X position\n * @param clientY - Mouse client Y position\n * @param offsetX - Offset from element origin X\n * @param offsetY - Offset from element origin Y\n * @returns Adjusted left/top position\n */\n calcDragPosition?(\n clientX: number,\n clientY: number,\n offsetX: number,\n offsetY: number\n ): PartialPosition;\n}\n\n// ============================================================================\n// Layout Constraint Types\n// ============================================================================\n\n/**\n * Context provided to constraint functions during drag/resize operations.\n */\nexport interface ConstraintContext {\n /** Number of columns in the grid */\n cols: number;\n\n /** Maximum number of rows (Infinity if unbounded) */\n maxRows: number;\n\n /** Container width in pixels */\n containerWidth: number;\n\n /** Container height in pixels (may be 0 if auto-height) */\n containerHeight: number;\n\n /** Row height in pixels */\n rowHeight: number;\n\n /** Margin between items [x, y] in pixels */\n margin: readonly [number, number];\n\n /** Current layout state */\n layout: Layout;\n}\n\n/**\n * Interface for layout constraints.\n *\n * Implement this interface to create custom position/size constraints.\n * Built-in constraints: gridBounds, minMaxSize, containerBounds, boundedX, boundedY.\n *\n * @example\n * ```typescript\n * // Grid-level constraints\n * <GridLayout constraints={[gridBounds, minMaxSize, aspectRatio(16/9)]} />\n *\n * // Per-item constraints\n * const layout = [\n * { i: 'video', x: 0, y: 0, w: 4, h: 2, constraints: [aspectRatio(16/9)] }\n * ];\n * ```\n */\nexport interface LayoutConstraint {\n /** Constraint identifier for debugging */\n readonly name: string;\n\n /**\n * Constrain position during drag operations.\n * Called after grid unit conversion, before layout update.\n *\n * @param item - The item being dragged\n * @param x - Proposed x position in grid units\n * @param y - Proposed y position in grid units\n * @param context - Grid context (cols, maxRows, etc.)\n * @returns Constrained x, y position\n */\n constrainPosition?(\n item: LayoutItem,\n x: number,\n y: number,\n context: ConstraintContext\n ): { x: number; y: number };\n\n /**\n * Constrain size during resize operations.\n * Called after grid unit conversion, before layout update.\n *\n * @param item - The item being resized\n * @param w - Proposed width in grid units\n * @param h - Proposed height in grid units\n * @param handle - Which resize handle is being used\n * @param context - Grid context (cols, maxRows, etc.)\n * @returns Constrained w, h size\n */\n constrainSize?(\n item: LayoutItem,\n w: number,\n h: number,\n handle: ResizeHandleAxis,\n context: ConstraintContext\n ): { w: number; h: number };\n}\n\n// ============================================================================\n// Grid Configuration Types (v2 Composable Interfaces)\n// ============================================================================\n\n/**\n * Grid measurement configuration.\n * Groups all grid metrics (columns, row height, margins).\n */\nexport interface GridConfig {\n /** Number of columns in the grid (default: 12) */\n cols: number;\n\n /** Height of a single row in pixels (default: 150) */\n rowHeight: number;\n\n /** [horizontal, vertical] margin between items in pixels (default: [10, 10]) */\n margin: readonly [number, number];\n\n /** [horizontal, vertical] padding inside the container (default: null, uses margin) */\n containerPadding: readonly [number, number] | null;\n\n /** Maximum number of rows (default: Infinity) */\n maxRows: number;\n}\n\n/** Default grid configuration */\nexport const defaultGridConfig: GridConfig = {\n cols: 12,\n rowHeight: 150,\n margin: [10, 10],\n containerPadding: null,\n maxRows: Infinity\n};\n\n/**\n * Drag behavior configuration.\n * Groups all drag-related settings.\n */\nexport interface DragConfig {\n /** Whether items can be dragged (default: true) */\n enabled: boolean;\n\n /** Whether items are bounded to the container (default: false) */\n bounded: boolean;\n\n /** CSS selector for drag handle (e.g., '.drag-handle') */\n handle?: string;\n\n /** CSS selector for elements that should not trigger drag */\n cancel?: string;\n\n /**\n * Minimum pixels to move before drag starts.\n * Helps distinguish click from drag (fixes #1341, #1401).\n * @default 3\n */\n threshold: number;\n}\n\n/** Default drag configuration */\nexport const defaultDragConfig: DragConfig = {\n enabled: true,\n bounded: false,\n threshold: 3\n};\n\n/**\n * Resize behavior configuration.\n * Groups all resize-related settings.\n */\nexport interface ResizeConfig {\n /** Whether items can be resized (default: true) */\n enabled: boolean;\n\n /** Which resize handles to show (default: ['se']) */\n handles: readonly ResizeHandleAxis[];\n\n /**\n * Custom resize handle component.\n * Can be a React node or a function that receives the axis.\n */\n handleComponent?:\n | React.ReactNode\n | ((\n axis: ResizeHandleAxis,\n ref: React.Ref<HTMLElement>\n ) => React.ReactNode);\n}\n\n/** Default resize configuration */\nexport const defaultResizeConfig: ResizeConfig = {\n enabled: true,\n handles: [\"se\"]\n};\n\n/**\n * Drop configuration (for dropping external elements).\n * Groups all drop-related settings.\n */\nexport interface DropConfig {\n /** Whether external elements can be dropped on the grid (default: false) */\n enabled: boolean;\n\n /** Default size for dropped items (default: { w: 1, h: 1 }) */\n defaultItem: { w: number; h: number };\n\n /**\n * Called when dragging over the grid.\n * Return dimensions to override defaultItem, or false to reject the drop.\n * Can also return dragOffsetX/dragOffsetY to specify cursor offset for centering.\n */\n onDragOver?: (\n e: DragEvent\n ) =>\n | { w?: number; h?: number; dragOffsetX?: number; dragOffsetY?: number }\n | false\n | void;\n}\n\n/** Default drop configuration */\nexport const defaultDropConfig: DropConfig = {\n enabled: false,\n defaultItem: { w: 1, h: 1 }\n};\n\n// ============================================================================\n// Responsive Types\n// ============================================================================\n\n/**\n * Breakpoint name (e.g., 'lg', 'md', 'sm', 'xs', 'xxs').\n */\nexport type Breakpoint = string;\n\n/**\n * Map of breakpoint name to pixel width.\n * Generic type B allows custom breakpoint strings.\n */\nexport type Breakpoints<B extends Breakpoint = Breakpoint> = Record<B, number>;\n\n/**\n * Map of breakpoint name to number of columns.\n * Generic type B allows custom breakpoint strings.\n */\nexport type BreakpointCols<B extends Breakpoint = Breakpoint> = Record<\n B,\n number\n>;\n\n/**\n * Map of breakpoint name to layout.\n * Generic type B allows custom breakpoint strings.\n */\nexport type ResponsiveLayouts<B extends Breakpoint = Breakpoint> = Partial<\n Record<B, Layout>\n>;\n\n/**\n * Callback when breakpoint changes.\n */\nexport type OnBreakpointChangeCallback<B extends Breakpoint = Breakpoint> = (\n newBreakpoint: B,\n cols: number\n) => void;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\n/**\n * Makes all properties in T mutable (removes readonly).\n */\nexport type Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * Deep partial - all properties and nested properties are optional.\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\n/**\n * Extract the element type from an array type.\n */\nexport type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;\n","/**\n * Compactor implementations.\n *\n * Compactors are pluggable strategies for removing gaps between grid items.\n * Use the Compactor interface to create custom compaction algorithms.\n */\n\nimport type {\n Compactor,\n CompactType,\n Layout,\n LayoutItem,\n Mutable\n} from \"./types.js\";\nimport { getFirstCollision } from \"./collision.js\";\nimport { sortLayoutItemsByRowCol, sortLayoutItemsByColRow } from \"./sort.js\";\nimport { bottom, cloneLayoutItem, getStatics, cloneLayout } from \"./layout.js\";\nimport { collides } from \"./collision.js\";\n\n// ============================================================================\n// Helpers for Custom Compactors\n// ============================================================================\n\n/**\n * Resolve a compaction collision by moving items.\n *\n * Before moving an item to a position, checks if that movement would\n * cause collisions and recursively moves those items first.\n *\n * Useful for implementing custom compactors.\n *\n * @param layout - Full layout (must be sorted for optimization)\n * @param item - Item being moved (will be mutated)\n * @param moveToCoord - Target coordinate\n * @param axis - Which axis to move on ('x' or 'y')\n * @param hasStatics - Whether layout contains static items (disables early break optimization)\n */\nexport function resolveCompactionCollision(\n layout: Layout,\n item: LayoutItem,\n moveToCoord: number,\n axis: \"x\" | \"y\",\n hasStatics?: boolean\n): void {\n const sizeProp = axis === \"x\" ? \"w\" : \"h\";\n\n // Temporarily increment position to check for collisions\n (item as Mutable<LayoutItem>)[axis] += 1;\n\n const itemIndex = layout.findIndex(l => l.i === item.i);\n\n // Calculate hasStatics once if not provided (for backwards compat)\n const layoutHasStatics = hasStatics ?? getStatics(layout).length > 0;\n\n for (let i = itemIndex + 1; i < layout.length; i++) {\n const otherItem = layout[i];\n if (otherItem === undefined) continue;\n if (otherItem.static) continue;\n // Optimization: break early if past this element, but only if no statics\n // are present. Static items can be scattered throughout the layout,\n // so we can't assume sort order guarantees no more collisions.\n if (!layoutHasStatics && otherItem.y > item.y + item.h) break;\n\n if (collides(item, otherItem)) {\n resolveCompactionCollision(\n layout,\n otherItem,\n moveToCoord + item[sizeProp],\n axis,\n layoutHasStatics\n );\n }\n }\n\n (item as Mutable<LayoutItem>)[axis] = moveToCoord;\n}\n\n/**\n * Compact a single item vertically (move up).\n *\n * Moves the item as far up as possible without colliding.\n * Useful for implementing custom vertical compactors.\n *\n * @param compareWith - Items to check for collisions\n * @param l - Item to compact (will be mutated)\n * @param fullLayout - Full layout for collision resolution\n * @param maxY - Maximum Y to start from\n * @returns The compacted item\n */\nexport function compactItemVertical(\n compareWith: Layout,\n l: LayoutItem,\n fullLayout: Layout,\n maxY: number\n): LayoutItem {\n // Correct negative positions first\n (l as Mutable<LayoutItem>).x = Math.max(l.x, 0);\n (l as Mutable<LayoutItem>).y = Math.max(l.y, 0);\n\n // Limit Y to the current bottom\n (l as Mutable<LayoutItem>).y = Math.min(maxY, l.y);\n\n // Move up as far as possible\n while (l.y > 0 && !getFirstCollision(compareWith, l)) {\n (l as Mutable<LayoutItem>).y--;\n }\n\n // Resolve collisions by moving down\n let collision: LayoutItem | undefined;\n while ((collision = getFirstCollision(compareWith, l)) !== undefined) {\n resolveCompactionCollision(fullLayout, l, collision.y + collision.h, \"y\");\n }\n\n (l as Mutable<LayoutItem>).y = Math.max(l.y, 0);\n return l;\n}\n\n/**\n * Compact a single item horizontally (move left).\n *\n * Moves the item as far left as possible without colliding.\n * Wraps to the next row if it overflows.\n * Useful for implementing custom horizontal compactors.\n *\n * @param compareWith - Items to check for collisions\n * @param l - Item to compact (will be mutated)\n * @param cols - Number of columns in the grid\n * @param fullLayout - Full layout for collision resolution\n * @returns The compacted item\n */\nexport function compactItemHorizontal(\n compareWith: Layout,\n l: LayoutItem,\n cols: number,\n fullLayout: Layout\n): LayoutItem {\n // Correct negative positions first\n (l as Mutable<LayoutItem>).x = Math.max(l.x, 0);\n (l as Mutable<LayoutItem>).y = Math.max(l.y, 0);\n\n // Move left as far as possible\n while (l.x > 0 && !getFirstCollision(compareWith, l)) {\n (l as Mutable<LayoutItem>).x--;\n }\n\n // Resolve collisions\n let collision: LayoutItem | undefined;\n while ((collision = getFirstCollision(compareWith, l)) !== undefined) {\n resolveCompactionCollision(fullLayout, l, collision.x + collision.w, \"x\");\n\n // Horizontal overflow: wrap to next row\n if (l.x + l.w > cols) {\n (l as Mutable<LayoutItem>).x = cols - l.w;\n (l as Mutable<LayoutItem>).y++;\n\n while (l.x > 0 && !getFirstCollision(compareWith, l)) {\n (l as Mutable<LayoutItem>).x--;\n }\n }\n }\n\n (l as Mutable<LayoutItem>).x = Math.max(l.x, 0);\n return l;\n}\n\n// ============================================================================\n// Vertical Compactor\n// ============================================================================\n\n/**\n * Vertical compactor - moves items up to fill gaps.\n *\n * Items are sorted by row then column, and each item is moved\n * as far up as possible without overlapping other items.\n *\n * This is the default compaction mode for react-grid-layout.\n */\nexport const verticalCompactor: Compactor = {\n type: \"vertical\",\n allowOverlap: false,\n\n compact(layout: Layout, _cols: number): Layout {\n const compareWith = getStatics(layout);\n let maxY = bottom(compareWith);\n const sorted = sortLayoutItemsByRowCol(layout);\n const out: LayoutItem[] = new Array(layout.length);\n\n for (let i = 0; i < sorted.length; i++) {\n const sortedItem = sorted[i];\n if (sortedItem === undefined) continue;\n\n let l = cloneLayoutItem(sortedItem);\n\n if (!l.static) {\n l = compactItemVertical(compareWith, l, sorted, maxY);\n maxY = Math.max(maxY, l.y + l.h);\n compareWith.push(l);\n }\n\n const originalIndex = layout.indexOf(sortedItem);\n out[originalIndex] = l;\n l.moved = false;\n }\n\n return out;\n }\n};\n\n// ============================================================================\n// Horizontal Compactor\n// ============================================================================\n\n/**\n * Horizontal compactor - moves items left to fill gaps.\n *\n * Items are sorted by column then row, and each item is moved\n * as far left as possible without overlapping other items.\n */\nexport const horizontalCompactor: Compactor = {\n type: \"horizontal\",\n allowOverlap: false,\n\n compact(layout: Layout, cols: number): Layout {\n const compareWith = getStatics(layout);\n const sorted = sortLayoutItemsByColRow(layout);\n const out: LayoutItem[] = new Array(layout.length);\n\n for (let i = 0; i < sorted.length; i++) {\n const sortedItem = sorted[i];\n if (sortedItem === undefined) continue;\n\n let l = cloneLayoutItem(sortedItem);\n\n if (!l.static) {\n l = compactItemHorizontal(compareWith, l, cols, sorted);\n compareWith.push(l);\n }\n\n const originalIndex = layout.indexOf(sortedItem);\n out[originalIndex] = l;\n l.moved = false;\n }\n\n return out;\n }\n};\n\n// ============================================================================\n// No Compaction\n// ============================================================================\n\n/**\n * No compaction - items stay where placed.\n *\n * Use this for free-form layouts where items can be placed anywhere.\n * Items will not automatically move to fill gaps.\n */\nexport const noCompactor: Compactor = {\n type: null,\n allowOverlap: false,\n\n compact(layout: Layout, _cols: number): Layout {\n // No compaction - just clone to maintain immutability\n return cloneLayout(layout);\n }\n};\n\n// ============================================================================\n// Overlap-Allowing Variants\n// ============================================================================\n\n/**\n * Vertical compactor that allows overlapping items.\n *\n * Items compact upward but are allowed to overlap each other.\n * Useful for layered layouts or when collision detection is handled externally.\n */\nexport const verticalOverlapCompactor: Compactor = {\n ...verticalCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, _cols: number): Layout {\n // With overlap allowed, just clone without moving\n return cloneLayout(layout);\n }\n};\n\n/**\n * Horizontal compactor that allows overlapping items.\n */\nexport const horizontalOverlapCompactor: Compactor = {\n ...horizontalCompactor,\n allowOverlap: true,\n\n compact(layout: Layout, _cols: number): Layout {\n return cloneLayout(layout);\n }\n};\n\n/**\n * No compaction, with overlapping allowed.\n *\n * Items stay where placed and can overlap each other.\n */\nexport const noOverlapCompactor: Compactor = {\n ...noCompactor,\n allowOverlap: true\n};\n\n// ============================================================================\n// Factory Function\n// ============================================================================\n\n/**\n * Get a compactor by type.\n *\n * This is a convenience function for backwards compatibility with the\n * string-based compactType API.\n *\n * Note: For 'wrap' mode, import `wrapCompactor` from 'react-grid-layout/extras'\n * and pass it directly to the `compactor` prop. This function returns\n * `noCompactor` for 'wrap' type since the wrap compactor is tree-shakeable.\n *\n * @param compactType - 'vertical', 'horizontal', 'wrap', or null\n * @param allowOverlap - Whether to allow overlapping items\n * @returns The appropriate Compactor\n */\nexport function getCompactor(\n compactType: CompactType,\n allowOverlap: boolean = false,\n preventCollision: boolean = false\n): Compactor {\n let baseCompactor: Compactor;\n\n if (allowOverlap) {\n if (compactType === \"vertical\") baseCompactor = verticalOverlapCompactor;\n else if (compactType === \"horizontal\")\n baseCompactor = horizontalOverlapCompactor;\n else baseCompactor = noOverlapCompactor;\n } else {\n if (compactType === \"vertical\") baseCompactor = verticalCompactor;\n else if (compactType === \"horizontal\") baseCompactor = horizontalCompactor;\n // For 'wrap' and null, use noCompactor\n // Users wanting wrap mode should import wrapCompactor from extras\n else baseCompactor = noCompactor;\n }\n\n // Return with preventCollision if specified\n if (preventCollision) {\n return { ...baseCompactor, preventCollision };\n }\n return baseCompactor;\n}\n","/**\n * Responsive layout utilities.\n *\n * Functions for handling responsive breakpoints and layout generation.\n */\n\nimport type {\n Breakpoint,\n Breakpoints,\n Compactor,\n CompactType,\n Layout,\n ResponsiveLayouts\n} from \"./types.js\";\nimport { cloneLayout, correctBounds } from \"./layout.js\";\nimport { getCompactor } from \"./compactors.js\";\n\n// ============================================================================\n// Breakpoint Utilities\n// ============================================================================\n\n/**\n * Sort breakpoints by width (ascending).\n *\n * Returns an array of breakpoint names sorted from smallest to largest.\n * E.g., ['xxs', 'xs', 'sm', 'md', 'lg']\n *\n * @param breakpoints - Map of breakpoint names to widths\n * @returns Sorted array of breakpoint names\n */\nexport function sortBreakpoints<B extends Breakpoint>(\n breakpoints: Breakpoints<B>\n): B[] {\n const keys = Object.keys(breakpoints) as B[];\n return keys.sort((a, b) => breakpoints[a] - breakpoints[b]);\n}\n\n/**\n * Get the active breakpoint for a given width.\n *\n * Returns the highest breakpoint that is valid for the width (width > breakpoint).\n *\n * @param breakpoints - Map of breakpoint names to widths\n * @param width - Container width in pixels\n * @returns Active breakpoint name\n */\nexport function getBreakpointFromWidth<B extends Breakpoint>(\n breakpoints: Breakpoints<B>,\n width: number\n): B {\n const sorted = sortBreakpoints(breakpoints);\n let matching = sorted[0];\n\n if (matching === undefined) {\n throw new Error(\"No breakpoints defined\");\n }\n\n for (let i = 1; i < sorted.length; i++) {\n const breakpointName = sorted[i];\n if (breakpointName === undefined) continue;\n\n const breakpointWidth = breakpoints[breakpointName];\n if (width > breakpointWidth) {\n matching = breakpointName;\n }\n }\n\n return matching;\n}\n\n/**\n * Get the column count for a breakpoint.\n *\n * @param breakpoint - Breakpoint name\n * @param cols - Map of breakpoint names to column counts\n * @returns Number of columns for the breakpoint\n * @throws Error if breakpoint is not defined in cols\n */\nexport function getColsFromBreakpoint<B extends Breakpoint>(\n breakpoint: B,\n cols: Breakpoints<B>\n): number {\n const colCount = cols[breakpoint];\n if (colCount === undefined) {\n throw new Error(\n `ResponsiveReactGridLayout: \\`cols\\` entry for breakpoint ${String(breakpoint)} is missing!`\n );\n }\n return colCount;\n}\n\n// ============================================================================\n// Layout Generation\n// ============================================================================\n\n/**\n * Find or generate a layout for a breakpoint.\n *\n * If a layout exists for the breakpoint, returns a clone.\n * Otherwise, generates a new layout from the nearest larger breakpoint.\n *\n * @param layouts - Existing layouts by breakpoint\n * @param breakpoints - Breakpoint definitions\n * @param breakpoint - Target breakpoint\n * @param lastBreakpoint - Previous breakpoint (for fallback)\n * @param cols - Column count for the target breakpoint\n * @param compactTypeOrCompactor - Compaction type string (legacy) or Compactor object\n * @returns Layout for the breakpoint\n */\nexport function findOrGenerateResponsiveLayout<B extends Breakpoint>(\n layouts: ResponsiveLayouts<B>,\n breakpoints: Breakpoints<B>,\n breakpoint: B,\n lastBreakpoint: B,\n cols: number,\n compactTypeOrCompactor: CompactType | Compactor\n): Layout {\n // If it already exists, just return it\n const existingLayout = layouts[breakpoint];\n if (existingLayout) {\n return cloneLayout(existingLayout);\n }\n\n // Find or generate the next layout\n let layout = layouts[lastBreakpoint];\n\n // Look for layouts at larger breakpoints\n const breakpointsSorted = sortBreakpoints(breakpoints);\n const breakpointsAbove = breakpointsSorted.slice(\n breakpointsSorted.indexOf(breakpoint)\n );\n\n for (let i = 0; i < breakpointsAbove.length; i++) {\n const b = breakpointsAbove[i];\n if (b === undefined) continue;\n\n const layoutForBreakpoint = layouts[b];\n if (layoutForBreakpoint) {\n layout = layoutForBreakpoint;\n break;\n }\n }\n\n // Clone layout so we don't modify existing items\n const clonedLayout = cloneLayout(layout || []);\n\n // Correct bounds and compact - use compactor.compact() (#2213)\n // Handle both legacy compactType string and new Compactor object\n const corrected = correctBounds(clonedLayout, { cols });\n const compactor: Compactor =\n typeof compactTypeOrCompactor === \"object\" &&\n compactTypeOrCompactor !== null\n ? compactTypeOrCompactor\n : getCompactor(compactTypeOrCompactor);\n return compactor.compact(corrected, cols);\n}\n\n// ============================================================================\n// Margin/Padding Helpers\n// ============================================================================\n\ntype IndentationValue<B extends Breakpoint> =\n | readonly [number, number]\n | Partial<Record<B, readonly [number, number]>>;\n\n/**\n * Get margin or padding value for a breakpoint.\n *\n * Supports both fixed values ([x, y]) and breakpoint-specific values\n * ({ lg: [x, y], md: [x, y], ... }).\n *\n * @param value - Fixed value or breakpoint-specific map\n * @param breakpoint - Current breakpoint\n * @returns Margin/padding tuple [x, y]\n */\nexport function getIndentationValue<B extends Breakpoint>(\n value: IndentationValue<B>,\n breakpoint: B\n): readonly [number, number] {\n // If it's a tuple (array), return it directly\n if (Array.isArray(value)) {\n return value as readonly [number, number];\n }\n\n // It's a breakpoint map - find the value\n const breakpointMap = value as Partial<Record<B, readonly [number, number]>>;\n const breakpointValue = breakpointMap[breakpoint];\n if (breakpointValue !== undefined) {\n return breakpointValue;\n }\n\n // Fallback to first defined value\n const keys = Object.keys(breakpointMap) as B[];\n for (const key of keys) {\n const v = breakpointMap[key];\n if (v !== undefined) {\n return v;\n }\n }\n\n // Default fallback\n return [10, 10];\n}\n"]}
@@ -1 +0,0 @@
1
- {"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,WAAA;AACtB,MAAA,QAAA,CAAS,QAAQ,CAAA;AACjB,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,UAAA,CAAW,IAAI,CAAA;AAAA,MACjB;AAAA,IACF;AAAA,EACF,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAO,YAAA,CAAa,OAAA;AAC1B,IAAA,IAAI,CAAC,IAAA,EAAM;AAGX,IAAA,YAAA,EAAa;AAGb,IAAA,IAAI,OAAO,mBAAmB,WAAA,EAAa;AACzC,MAAA,WAAA,CAAY,OAAA,GAAU,IAAI,cAAA,CAAe,CAAA,OAAA,KAAW;AAClD,QAAA,MAAM,KAAA,GAAQ,QAAQ,CAAC,CAAA;AACvB,QAAA,IAAI,KAAA,EAAO;AAET,UAAA,MAAM,QAAA,GAAW,MAAM,WAAA,CAAY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,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"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-ZWN22PS2.mjs.map
3
- //# sourceMappingURL=chunk-ZWN22PS2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-ZWN22PS2.mjs"}
package/dist/core.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"core.js"}
package/dist/core.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"core.mjs"}
@@ -1 +0,0 @@
1
- {"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,EACA;AACF,CAAA,EAA4C;AAC1C,EAAA,MAAM,IAAA,GAAOA,aAAA;AAAA,IACX,MACEC,uCAAA,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,GAAWD,cAAQ,MAAM;AAC7B,IAAA,IAAI,IAAA,KAAS,QAAQ,OAAO,IAAA;AAC5B,IAAA,IAAI,MAAA,EAAQ;AAEV,MAAA,M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,CAAA,EAAG;AACnC,QAAA,OAAA,EAAA;AAAA,MACF;AAAA,IACF;AAEA,IAAA,MAAM,SAAA,GAAY,gBAAA,CAAiB,OAAA,EAAS,IAAI,CAAA;AAChD,IAAC,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,OAAOH,6BAAY,MAAM,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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/extras/GridBackground.tsx","../src/extras/fastVerticalCompactor.ts","../src/extras/fastHorizontalCompactor.ts","../src/extras/wr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AAA;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"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}