react-grid-layout 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -25
- package/css/styles.css +0 -1
- package/dist/{ResponsiveGridLayout-D6lFRE3f.d.mts → ResponsiveGridLayout-BkHF9YHa.d.mts} +10 -1
- package/dist/{ResponsiveGridLayout-CH4s0tKj.d.ts → ResponsiveGridLayout-CLn16-X3.d.ts} +10 -1
- package/dist/{calculate-CwYDW8na.d.mts → calculate-DsVTldEE.d.ts} +30 -2
- package/dist/{calculate-mgLpNJ5O.d.ts → calculate-DwbL1D06.d.mts} +30 -2
- package/dist/{chunk-4HNUMWQK.mjs → chunk-2O3ZME4Q.mjs} +178 -297
- package/dist/chunk-2O3ZME4Q.mjs.map +1 -0
- package/dist/chunk-526JND3R.mjs +3 -0
- package/dist/{chunk-ZWN22PS2.mjs.map → chunk-526JND3R.mjs.map} +1 -1
- package/dist/chunk-7ELO5FRW.js +4 -0
- package/dist/{chunk-PBQSHIID.js.map → chunk-7ELO5FRW.js.map} +1 -1
- package/dist/chunk-AWM66AWF.mjs +422 -0
- package/dist/chunk-AWM66AWF.mjs.map +1 -0
- package/dist/chunk-BJFPTW5Q.js +449 -0
- package/dist/chunk-BJFPTW5Q.js.map +1 -0
- package/dist/{chunk-3WO4SAYB.js → chunk-FN6MIZ24.js} +221 -345
- package/dist/chunk-FN6MIZ24.js.map +1 -0
- package/dist/{chunk-H5KMDLY3.js → chunk-GPZBANOK.js} +40 -39
- package/dist/chunk-GPZBANOK.js.map +1 -0
- package/dist/{chunk-ZCXE6SR5.mjs → chunk-LWF5EYMO.mjs} +4 -3
- package/dist/chunk-LWF5EYMO.mjs.map +1 -0
- package/dist/{chunk-R35HZZTA.mjs → chunk-MXXN7GUE.mjs} +170 -62
- package/dist/chunk-MXXN7GUE.mjs.map +1 -0
- package/dist/{chunk-BFTKGAP3.js → chunk-QRW3ND4U.js} +230 -122
- package/dist/chunk-QRW3ND4U.js.map +1 -0
- package/dist/core.d.mts +159 -6
- package/dist/core.d.ts +159 -6
- package/dist/core.js +141 -85
- package/dist/core.mjs +3 -3
- package/dist/extras.d.mts +133 -3
- package/dist/extras.d.ts +133 -3
- package/dist/extras.js +373 -2
- package/dist/extras.js.map +1 -1
- package/dist/extras.mjs +367 -2
- package/dist/extras.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +64 -64
- package/dist/index.mjs +5 -5
- package/dist/legacy.d.mts +2 -2
- package/dist/legacy.d.ts +2 -2
- package/dist/legacy.js +26 -25
- package/dist/legacy.js.map +1 -1
- package/dist/legacy.mjs +16 -15
- package/dist/legacy.mjs.map +1 -1
- package/dist/{position-Dk2b4ZMS.d.ts → position-C8a5g6bb.d.mts} +11 -6
- package/dist/{position-BmN1z36J.d.mts → position-H8tBL91b.d.ts} +11 -6
- package/dist/react.d.mts +11 -5
- package/dist/react.d.ts +11 -5
- package/dist/react.js +38 -38
- package/dist/react.mjs +5 -5
- package/dist/{responsive-CJxefsYw.d.mts → responsive-BB5d98xz.d.mts} +1 -1
- package/dist/{responsive-C4L1ESlm.d.ts → responsive-BXI-GCXG.d.ts} +1 -1
- package/dist/{types-Cxf4nHNr.d.mts → types-CokovIMH.d.mts} +98 -4
- package/dist/{types-Cxf4nHNr.d.ts → types-CokovIMH.d.ts} +98 -4
- package/index-dev.js +16 -0
- package/package.json +2 -1
- package/dist/chunk-2KUHNJXF.mjs +0 -90
- package/dist/chunk-2KUHNJXF.mjs.map +0 -1
- package/dist/chunk-3WO4SAYB.js.map +0 -1
- package/dist/chunk-4HNUMWQK.mjs.map +0 -1
- package/dist/chunk-BFTKGAP3.js.map +0 -1
- package/dist/chunk-F6NQPYKT.js +0 -98
- package/dist/chunk-F6NQPYKT.js.map +0 -1
- package/dist/chunk-H5KMDLY3.js.map +0 -1
- package/dist/chunk-PBQSHIID.js +0 -4
- package/dist/chunk-R35HZZTA.mjs.map +0 -1
- package/dist/chunk-ZCXE6SR5.mjs.map +0 -1
- package/dist/chunk-ZWN22PS2.mjs +0 -3
|
@@ -0,0 +1 @@
|
|
|
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,K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,WAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAGD,EAAAA,UAAU,MAAM;AACd,IAAA,IAAI,CAACG,SAAAA,CAAU,YAAA,EAAc,cAAA,CAAe,OAAO,CAAA,EAAG;AACpD,MAAA,UAAA,CAAW,YAAY,CAAA;AACvB,MAAA,cAAA,CAAe,OAAA,GAAU,YAAA;AAAA,IAC3B;AAAA,EACF,CAAA,EAAG,CAAC,YAAA,EAAc,UAAU,CAAC,CAAA;AAG7B,EAAAH,UAAU,MAAM;AACd,IAAA,IAAI,CAACG,SAAAA,CAAU,OAAA,EAAS,cAAA,CAAe,OAAO,CAAA,EAAG;AAC/C,MAAA,cAAA,CAAe,OAAA,GAAU,OAAA;AACzB,MAAA,cAAA,GAAiB,QAAQ,OAAO,CAAA;AAAA,IAClC;AAAA,EACF,CAAA,EAAG,CAAC,MAAA,EAAQ,OAAA,EAAS,cAAc,CAAC,CAAA;AAEpC,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,IAAA;AAAA,IACA,sBAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-LWF5EYMO.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 CompactType,\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 { compact } from \"../../core/compact-compat.js\";\nimport { getCompactor } 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 /** Compaction type: 'vertical', 'horizontal', or null */\n compactType?: CompactType;\n /** Allow items to overlap */\n allowOverlap?: boolean;\n /** Prevent collisions when moving items */\n preventCollision?: boolean;\n /** Called when layout changes */\n onLayoutChange?: (layout: Layout) => void;\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 * compactType: 'vertical'\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 compactType = \"vertical\",\n allowOverlap = false,\n preventCollision = false,\n onLayoutChange\n } = options;\n\n // Get the appropriate compactor\n const compactor = useMemo(\n () => getCompactor(compactType, allowOverlap),\n [compactType, allowOverlap]\n );\n\n // Track if we're currently dragging to block prop updates\n const isDraggingRef = useRef(false);\n\n // Initialize layout with compaction\n const [layout, setLayoutState] = useState<Layout>(() => {\n const corrected = correctBounds(cloneLayout(propsLayout), { cols });\n return compact(corrected, compactType, cols, allowOverlap);\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\n const setLayout = useCallback(\n (newLayout: Layout) => {\n const corrected = correctBounds(cloneLayout(newLayout), { cols });\n const compacted = compact(corrected, compactType, cols, allowOverlap);\n setLayoutState(compacted);\n },\n [cols, compactType, allowOverlap]\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 compactType,\n cols,\n allowOverlap\n );\n\n // Compact layout\n const compacted = allowOverlap\n ? newLayout\n : compact(newLayout, compactType, cols);\n\n setLayoutState(compacted);\n },\n [layout, cols, compactType, preventCollision, allowOverlap]\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 compactType,\n cols,\n allowOverlap\n );\n\n // Compact and finalize\n const compacted = compact(newLayout, compactType, cols, allowOverlap);\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, compactType, preventCollision, allowOverlap]\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\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compact(corrected, compactType, cols, allowOverlap);\n\n setLayoutState(compacted);\n },\n [layout, cols, compactType, allowOverlap]\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\n const newLayout = [...layout, droppingItem];\n const corrected = correctBounds(newLayout, { cols });\n const compacted = compact(corrected, compactType, cols, allowOverlap);\n setLayoutState(compacted);\n }\n\n setDropState({\n droppingDOMNode: null, // Will be set by component\n droppingPosition: position\n });\n },\n [layout, cols, compactType, allowOverlap]\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 const corrected = correctBounds(newLayout, { cols });\n const compacted = compact(corrected, compactType, cols, allowOverlap);\n setLayoutState(compacted);\n\n setDropState({\n droppingDOMNode: null,\n droppingPosition: null\n });\n },\n [layout, cols, compactType, allowOverlap]\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 CompactType\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\";\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 /** Compaction type */\n compactType?: CompactType;\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 compactType = \"vertical\",\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 const prevLayoutsRef = useRef(layouts);\n\n // Current layout for the active breakpoint\n const layout = useMemo(() => {\n return findOrGenerateResponsiveLayout(\n layouts,\n breakpoints,\n breakpoint,\n prevBreakpointRef.current,\n cols,\n compactType\n );\n }, [layouts, breakpoints, breakpoint, cols, compactType]);\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 const newLayout = findOrGenerateResponsiveLayout(\n layouts,\n breakpoints,\n newBreakpoint,\n breakpoint,\n newCols,\n compactType\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 compactType,\n onBreakpointChange,\n onWidthChange\n ]);\n\n // Sync with prop layouts when they change\n useEffect(() => {\n if (!deepEqual(propsLayouts, prevLayoutsRef.current)) {\n setLayouts(propsLayouts);\n prevLayoutsRef.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,5 +1,5 @@
|
|
|
1
|
-
import { setTransform, setTopLeft, perc, resizeItemInDirection, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor,
|
|
2
|
-
import {
|
|
1
|
+
import { defaultConstraints, setTransform, setTopLeft, perc, applyPositionConstraints, resizeItemInDirection, applySizeConstraints, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor, compact, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout, getIndentationValue } from './chunk-2O3ZME4Q.mjs';
|
|
2
|
+
import { calcXYRaw, calcGridItemWHPx, clamp, calcGridColWidth, calcWHRaw, calcGridItemPosition, bottom, getLayoutItem, cloneLayoutItem, moveElement, withLayoutItem, getAllCollisions, calcXY, cloneLayout, correctBounds } from './chunk-AWM66AWF.mjs';
|
|
3
3
|
import React2, { useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
4
4
|
import { DraggableCore } from 'react-draggable';
|
|
5
5
|
import { Resizable } from 'react-resizable';
|
|
@@ -39,6 +39,9 @@ function GridItem(props) {
|
|
|
39
39
|
i,
|
|
40
40
|
resizeHandles,
|
|
41
41
|
resizeHandle,
|
|
42
|
+
constraints = defaultConstraints,
|
|
43
|
+
layoutItem,
|
|
44
|
+
layout = [],
|
|
42
45
|
onDragStart: onDragStartProp,
|
|
43
46
|
onDrag: onDragProp,
|
|
44
47
|
onDragStop: onDragStopProp,
|
|
@@ -70,6 +73,33 @@ function GridItem(props) {
|
|
|
70
73
|
}),
|
|
71
74
|
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
|
|
72
75
|
);
|
|
76
|
+
const constraintContext = useMemo(
|
|
77
|
+
() => ({
|
|
78
|
+
cols,
|
|
79
|
+
maxRows,
|
|
80
|
+
containerWidth,
|
|
81
|
+
containerHeight: 0,
|
|
82
|
+
// Auto-height grids don't have a fixed container height
|
|
83
|
+
rowHeight,
|
|
84
|
+
margin,
|
|
85
|
+
layout
|
|
86
|
+
}),
|
|
87
|
+
[cols, maxRows, containerWidth, rowHeight, margin, layout]
|
|
88
|
+
);
|
|
89
|
+
const effectiveLayoutItem = useMemo(
|
|
90
|
+
() => layoutItem ?? {
|
|
91
|
+
i,
|
|
92
|
+
x,
|
|
93
|
+
y,
|
|
94
|
+
w,
|
|
95
|
+
h,
|
|
96
|
+
minW,
|
|
97
|
+
maxW,
|
|
98
|
+
minH,
|
|
99
|
+
maxH
|
|
100
|
+
},
|
|
101
|
+
[layoutItem, i, x, y, w, h, minW, maxW, minH, maxH]
|
|
102
|
+
);
|
|
73
103
|
const createStyle = useCallback(
|
|
74
104
|
(pos2) => {
|
|
75
105
|
if (useCSSTransforms) {
|
|
@@ -104,12 +134,17 @@ function GridItem(props) {
|
|
|
104
134
|
};
|
|
105
135
|
dragPositionRef.current = newPosition;
|
|
106
136
|
setDragging(true);
|
|
107
|
-
const
|
|
137
|
+
const rawPos = calcXYRaw(
|
|
108
138
|
positionParams,
|
|
109
139
|
newPosition.top,
|
|
110
|
-
newPosition.left
|
|
111
|
-
|
|
112
|
-
|
|
140
|
+
newPosition.left
|
|
141
|
+
);
|
|
142
|
+
const { x: newX, y: newY } = applyPositionConstraints(
|
|
143
|
+
constraints,
|
|
144
|
+
effectiveLayoutItem,
|
|
145
|
+
rawPos.x,
|
|
146
|
+
rawPos.y,
|
|
147
|
+
constraintContext
|
|
113
148
|
);
|
|
114
149
|
onDragStartProp(i, newX, newY, {
|
|
115
150
|
e,
|
|
@@ -117,7 +152,15 @@ function GridItem(props) {
|
|
|
117
152
|
newPosition
|
|
118
153
|
});
|
|
119
154
|
},
|
|
120
|
-
[
|
|
155
|
+
[
|
|
156
|
+
onDragStartProp,
|
|
157
|
+
transformScale,
|
|
158
|
+
positionParams,
|
|
159
|
+
constraints,
|
|
160
|
+
effectiveLayoutItem,
|
|
161
|
+
constraintContext,
|
|
162
|
+
i
|
|
163
|
+
]
|
|
121
164
|
);
|
|
122
165
|
const onDrag = useCallback(
|
|
123
166
|
(e, { node, deltaX, deltaY }) => {
|
|
@@ -136,7 +179,14 @@ function GridItem(props) {
|
|
|
136
179
|
}
|
|
137
180
|
const newPosition = { top, left };
|
|
138
181
|
dragPositionRef.current = newPosition;
|
|
139
|
-
const
|
|
182
|
+
const rawPos = calcXYRaw(positionParams, top, left);
|
|
183
|
+
const { x: newX, y: newY } = applyPositionConstraints(
|
|
184
|
+
constraints,
|
|
185
|
+
effectiveLayoutItem,
|
|
186
|
+
rawPos.x,
|
|
187
|
+
rawPos.y,
|
|
188
|
+
constraintContext
|
|
189
|
+
);
|
|
140
190
|
onDragProp(i, newX, newY, {
|
|
141
191
|
e,
|
|
142
192
|
node,
|
|
@@ -153,7 +203,10 @@ function GridItem(props) {
|
|
|
153
203
|
positionParams,
|
|
154
204
|
containerWidth,
|
|
155
205
|
w,
|
|
156
|
-
i
|
|
206
|
+
i,
|
|
207
|
+
constraints,
|
|
208
|
+
effectiveLayoutItem,
|
|
209
|
+
constraintContext
|
|
157
210
|
]
|
|
158
211
|
);
|
|
159
212
|
const onDragStop = useCallback(
|
|
@@ -163,14 +216,29 @@ function GridItem(props) {
|
|
|
163
216
|
const newPosition = { top, left };
|
|
164
217
|
setDragging(false);
|
|
165
218
|
dragPositionRef.current = { left: 0, top: 0 };
|
|
166
|
-
const
|
|
219
|
+
const rawPos = calcXYRaw(positionParams, top, left);
|
|
220
|
+
const { x: newX, y: newY } = applyPositionConstraints(
|
|
221
|
+
constraints,
|
|
222
|
+
effectiveLayoutItem,
|
|
223
|
+
rawPos.x,
|
|
224
|
+
rawPos.y,
|
|
225
|
+
constraintContext
|
|
226
|
+
);
|
|
167
227
|
onDragStopProp(i, newX, newY, {
|
|
168
228
|
e,
|
|
169
229
|
node,
|
|
170
230
|
newPosition
|
|
171
231
|
});
|
|
172
232
|
},
|
|
173
|
-
[
|
|
233
|
+
[
|
|
234
|
+
onDragStopProp,
|
|
235
|
+
dragging,
|
|
236
|
+
positionParams,
|
|
237
|
+
constraints,
|
|
238
|
+
effectiveLayoutItem,
|
|
239
|
+
constraintContext,
|
|
240
|
+
i
|
|
241
|
+
]
|
|
174
242
|
);
|
|
175
243
|
const onResizeHandler = useCallback(
|
|
176
244
|
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
|
|
@@ -192,16 +260,19 @@ function GridItem(props) {
|
|
|
192
260
|
};
|
|
193
261
|
}
|
|
194
262
|
resizePositionRef.current = updatedSize;
|
|
195
|
-
|
|
263
|
+
const rawSize = calcWHRaw(
|
|
196
264
|
positionParams,
|
|
197
265
|
updatedSize.width,
|
|
198
|
-
updatedSize.height
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
266
|
+
updatedSize.height
|
|
267
|
+
);
|
|
268
|
+
const { w: newW, h: newH } = applySizeConstraints(
|
|
269
|
+
constraints,
|
|
270
|
+
effectiveLayoutItem,
|
|
271
|
+
rawSize.w,
|
|
272
|
+
rawSize.h,
|
|
273
|
+
resizeHandle2,
|
|
274
|
+
constraintContext
|
|
202
275
|
);
|
|
203
|
-
newW = clamp(newW, Math.max(minW, 1), maxW);
|
|
204
|
-
newH = clamp(newH, minH, maxH);
|
|
205
276
|
handler(i, newW, newH, {
|
|
206
277
|
e: e.nativeEvent,
|
|
207
278
|
node,
|
|
@@ -217,11 +288,10 @@ function GridItem(props) {
|
|
|
217
288
|
positionParams,
|
|
218
289
|
x,
|
|
219
290
|
y,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
i
|
|
291
|
+
i,
|
|
292
|
+
constraints,
|
|
293
|
+
effectiveLayoutItem,
|
|
294
|
+
constraintContext
|
|
225
295
|
]
|
|
226
296
|
);
|
|
227
297
|
const handleResizeStart = useCallback(
|
|
@@ -306,14 +376,12 @@ function GridItem(props) {
|
|
|
306
376
|
resizing ? resizePositionRef.current : null
|
|
307
377
|
);
|
|
308
378
|
const child = React2.Children.only(children);
|
|
309
|
-
const
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const maxConstraints = [
|
|
314
|
-
Math.min(maxes.width, maxWidth),
|
|
315
|
-
Math.min(maxes.height, Infinity)
|
|
379
|
+
const minGridUnit = calcGridItemPosition(positionParams, 0, 0, 1, 1);
|
|
380
|
+
const minConstraints = [
|
|
381
|
+
minGridUnit.width,
|
|
382
|
+
minGridUnit.height
|
|
316
383
|
];
|
|
384
|
+
const maxConstraints = [Infinity, Infinity];
|
|
317
385
|
const childProps = child.props;
|
|
318
386
|
const childClassName = childProps["className"];
|
|
319
387
|
const childStyle = childProps["style"];
|
|
@@ -443,6 +511,7 @@ function GridLayout(props) {
|
|
|
443
511
|
dropConfig: dropConfigProp,
|
|
444
512
|
positionStrategy = defaultPositionStrategy,
|
|
445
513
|
compactor: compactorProp,
|
|
514
|
+
constraints = defaultConstraints,
|
|
446
515
|
// Layout data
|
|
447
516
|
layout: propsLayout = [],
|
|
448
517
|
droppingItem: droppingItemProp,
|
|
@@ -801,35 +870,55 @@ function GridLayout(props) {
|
|
|
801
870
|
)) {
|
|
802
871
|
return false;
|
|
803
872
|
}
|
|
804
|
-
const
|
|
805
|
-
if (
|
|
873
|
+
const rawResult = onDropDragOverProp(e);
|
|
874
|
+
if (rawResult === false) {
|
|
806
875
|
if (droppingDOMNode) {
|
|
807
876
|
removeDroppingPlaceholder();
|
|
808
877
|
}
|
|
809
878
|
return false;
|
|
810
879
|
}
|
|
880
|
+
const {
|
|
881
|
+
dragOffsetX = 0,
|
|
882
|
+
dragOffsetY = 0,
|
|
883
|
+
...onDragOverResult
|
|
884
|
+
} = rawResult ?? {};
|
|
811
885
|
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
|
|
812
886
|
const gridRect = e.currentTarget.getBoundingClientRect();
|
|
813
|
-
const
|
|
814
|
-
|
|
887
|
+
const positionParams = {
|
|
888
|
+
cols,
|
|
889
|
+
margin,
|
|
890
|
+
maxRows,
|
|
891
|
+
rowHeight,
|
|
892
|
+
containerWidth: width,
|
|
893
|
+
containerPadding: effectiveContainerPadding
|
|
894
|
+
};
|
|
895
|
+
const actualColWidth = calcGridColWidth(positionParams);
|
|
896
|
+
const itemPixelWidth = calcGridItemWHPx(
|
|
897
|
+
finalDroppingItem.w,
|
|
898
|
+
actualColWidth,
|
|
899
|
+
margin[0]
|
|
900
|
+
);
|
|
901
|
+
const itemPixelHeight = calcGridItemWHPx(
|
|
902
|
+
finalDroppingItem.h,
|
|
903
|
+
rowHeight,
|
|
904
|
+
margin[1]
|
|
905
|
+
);
|
|
906
|
+
const itemCenterOffsetX = itemPixelWidth / 2;
|
|
907
|
+
const itemCenterOffsetY = itemPixelHeight / 2;
|
|
908
|
+
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
|
|
909
|
+
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
|
|
910
|
+
const clampedGridX = Math.max(0, rawGridX);
|
|
911
|
+
const clampedGridY = Math.max(0, rawGridY);
|
|
815
912
|
const newDroppingPosition = {
|
|
816
|
-
left:
|
|
817
|
-
top:
|
|
913
|
+
left: clampedGridX / transformScale,
|
|
914
|
+
top: clampedGridY / transformScale,
|
|
818
915
|
e: e.nativeEvent
|
|
819
916
|
};
|
|
820
917
|
if (!droppingDOMNode) {
|
|
821
|
-
const positionParams = {
|
|
822
|
-
cols,
|
|
823
|
-
margin,
|
|
824
|
-
maxRows,
|
|
825
|
-
rowHeight,
|
|
826
|
-
containerWidth: width,
|
|
827
|
-
containerPadding: effectiveContainerPadding
|
|
828
|
-
};
|
|
829
918
|
const calculatedPosition = calcXY(
|
|
830
919
|
positionParams,
|
|
831
|
-
|
|
832
|
-
|
|
920
|
+
clampedGridY,
|
|
921
|
+
clampedGridX,
|
|
833
922
|
finalDroppingItem.w,
|
|
834
923
|
finalDroppingItem.h
|
|
835
924
|
);
|
|
@@ -846,7 +935,7 @@ function GridLayout(props) {
|
|
|
846
935
|
}
|
|
847
936
|
]);
|
|
848
937
|
} else if (droppingPosition) {
|
|
849
|
-
const shouldUpdate = droppingPosition.left !==
|
|
938
|
+
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
|
|
850
939
|
if (shouldUpdate) {
|
|
851
940
|
setDroppingPosition(newDroppingPosition);
|
|
852
941
|
}
|
|
@@ -941,6 +1030,9 @@ function GridLayout(props) {
|
|
|
941
1030
|
droppingPosition: isDroppingItem ? droppingPosition : void 0,
|
|
942
1031
|
resizeHandles: resizeHandlesOptions,
|
|
943
1032
|
resizeHandle: resizeHandleElement,
|
|
1033
|
+
constraints,
|
|
1034
|
+
layoutItem: l,
|
|
1035
|
+
layout,
|
|
944
1036
|
children: child
|
|
945
1037
|
},
|
|
946
1038
|
l.i
|
|
@@ -970,7 +1062,8 @@ function GridLayout(props) {
|
|
|
970
1062
|
transformScale,
|
|
971
1063
|
droppingPosition,
|
|
972
1064
|
resizeHandles,
|
|
973
|
-
resizeHandle
|
|
1065
|
+
resizeHandle,
|
|
1066
|
+
constraints
|
|
974
1067
|
]
|
|
975
1068
|
);
|
|
976
1069
|
const renderPlaceholder = () => {
|
|
@@ -995,6 +1088,8 @@ function GridLayout(props) {
|
|
|
995
1088
|
isBounded: false,
|
|
996
1089
|
useCSSTransforms,
|
|
997
1090
|
transformScale,
|
|
1091
|
+
constraints,
|
|
1092
|
+
layout,
|
|
998
1093
|
children: /* @__PURE__ */ jsx("div", {})
|
|
999
1094
|
}
|
|
1000
1095
|
);
|
|
@@ -1133,9 +1228,13 @@ function ResponsiveGridLayout(props) {
|
|
|
1133
1228
|
const prevColsRef = useRef(colsConfig);
|
|
1134
1229
|
const prevLayoutsRef = useRef(propsLayouts);
|
|
1135
1230
|
const prevCompactTypeRef = useRef(compactType);
|
|
1231
|
+
const layoutsRef = useRef(layouts);
|
|
1136
1232
|
useEffect(() => {
|
|
1233
|
+
layoutsRef.current = layouts;
|
|
1234
|
+
}, [layouts]);
|
|
1235
|
+
const derivedLayout = useMemo(() => {
|
|
1137
1236
|
if (!deepEqual(propsLayouts, prevLayoutsRef.current)) {
|
|
1138
|
-
|
|
1237
|
+
return findOrGenerateResponsiveLayout(
|
|
1139
1238
|
propsLayouts,
|
|
1140
1239
|
breakpoints,
|
|
1141
1240
|
breakpoint,
|
|
@@ -1143,34 +1242,41 @@ function ResponsiveGridLayout(props) {
|
|
|
1143
1242
|
cols,
|
|
1144
1243
|
compactType
|
|
1145
1244
|
);
|
|
1146
|
-
|
|
1245
|
+
}
|
|
1246
|
+
return null;
|
|
1247
|
+
}, [propsLayouts, breakpoints, breakpoint, cols, compactType]);
|
|
1248
|
+
const effectiveLayout = derivedLayout ?? layout;
|
|
1249
|
+
useEffect(() => {
|
|
1250
|
+
if (derivedLayout !== null) {
|
|
1251
|
+
setLayout(derivedLayout);
|
|
1147
1252
|
setLayouts(propsLayouts);
|
|
1253
|
+
layoutsRef.current = propsLayouts;
|
|
1148
1254
|
prevLayoutsRef.current = propsLayouts;
|
|
1149
1255
|
}
|
|
1150
|
-
}, [
|
|
1256
|
+
}, [derivedLayout, propsLayouts]);
|
|
1151
1257
|
useEffect(() => {
|
|
1152
1258
|
if (compactType !== prevCompactTypeRef.current) {
|
|
1153
1259
|
const newLayout = compact(
|
|
1154
|
-
cloneLayout(
|
|
1260
|
+
cloneLayout(effectiveLayout),
|
|
1155
1261
|
compactType,
|
|
1156
1262
|
cols,
|
|
1157
1263
|
allowOverlap
|
|
1158
1264
|
);
|
|
1159
1265
|
const newLayouts = {
|
|
1160
|
-
...
|
|
1266
|
+
...layoutsRef.current,
|
|
1161
1267
|
[breakpoint]: newLayout
|
|
1162
1268
|
};
|
|
1163
1269
|
setLayout(newLayout);
|
|
1164
1270
|
setLayouts(newLayouts);
|
|
1271
|
+
layoutsRef.current = newLayouts;
|
|
1165
1272
|
onLayoutChange(newLayout, newLayouts);
|
|
1166
1273
|
prevCompactTypeRef.current = compactType;
|
|
1167
1274
|
}
|
|
1168
1275
|
}, [
|
|
1169
1276
|
compactType,
|
|
1170
|
-
|
|
1277
|
+
effectiveLayout,
|
|
1171
1278
|
cols,
|
|
1172
1279
|
allowOverlap,
|
|
1173
|
-
layouts,
|
|
1174
1280
|
breakpoint,
|
|
1175
1281
|
onLayoutChange
|
|
1176
1282
|
]);
|
|
@@ -1187,7 +1293,7 @@ function ResponsiveGridLayout(props) {
|
|
|
1187
1293
|
const newCols = getColsFromBreakpoint(newBreakpoint, colsConfig);
|
|
1188
1294
|
const lastBreakpoint = breakpoint;
|
|
1189
1295
|
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
|
|
1190
|
-
const newLayouts = { ...
|
|
1296
|
+
const newLayouts = { ...layoutsRef.current };
|
|
1191
1297
|
if (!newLayouts[lastBreakpoint]) {
|
|
1192
1298
|
newLayouts[lastBreakpoint] = cloneLayout(layout);
|
|
1193
1299
|
}
|
|
@@ -1211,6 +1317,7 @@ function ResponsiveGridLayout(props) {
|
|
|
1211
1317
|
setCols(newCols);
|
|
1212
1318
|
setLayout(newLayout);
|
|
1213
1319
|
setLayouts(newLayouts);
|
|
1320
|
+
layoutsRef.current = newLayouts;
|
|
1214
1321
|
onBreakpointChange(newBreakpoint, newCols);
|
|
1215
1322
|
onLayoutChange(newLayout, newLayouts);
|
|
1216
1323
|
}
|
|
@@ -1236,7 +1343,6 @@ function ResponsiveGridLayout(props) {
|
|
|
1236
1343
|
breakpoint,
|
|
1237
1344
|
cols,
|
|
1238
1345
|
layout,
|
|
1239
|
-
layouts,
|
|
1240
1346
|
children,
|
|
1241
1347
|
compactType,
|
|
1242
1348
|
allowOverlap,
|
|
@@ -1248,15 +1354,17 @@ function ResponsiveGridLayout(props) {
|
|
|
1248
1354
|
]);
|
|
1249
1355
|
const handleLayoutChange = useCallback(
|
|
1250
1356
|
(newLayout) => {
|
|
1357
|
+
const currentLayouts = layoutsRef.current;
|
|
1251
1358
|
const newLayouts = {
|
|
1252
|
-
...
|
|
1359
|
+
...currentLayouts,
|
|
1253
1360
|
[breakpoint]: newLayout
|
|
1254
1361
|
};
|
|
1255
1362
|
setLayout(newLayout);
|
|
1256
1363
|
setLayouts(newLayouts);
|
|
1364
|
+
layoutsRef.current = newLayouts;
|
|
1257
1365
|
onLayoutChange(newLayout, newLayouts);
|
|
1258
1366
|
},
|
|
1259
|
-
[
|
|
1367
|
+
[breakpoint, onLayoutChange]
|
|
1260
1368
|
);
|
|
1261
1369
|
const currentMargin = useMemo(() => {
|
|
1262
1370
|
return getIndentationValue(
|
|
@@ -1289,12 +1397,12 @@ function ResponsiveGridLayout(props) {
|
|
|
1289
1397
|
gridConfig,
|
|
1290
1398
|
compactor,
|
|
1291
1399
|
onLayoutChange: handleLayoutChange,
|
|
1292
|
-
layout,
|
|
1400
|
+
layout: effectiveLayout,
|
|
1293
1401
|
children
|
|
1294
1402
|
}
|
|
1295
1403
|
);
|
|
1296
1404
|
}
|
|
1297
1405
|
|
|
1298
1406
|
export { GridItem, GridLayout, ResponsiveGridLayout };
|
|
1299
|
-
//# sourceMappingURL=chunk-
|
|
1300
|
-
//# sourceMappingURL=chunk-
|
|
1407
|
+
//# sourceMappingURL=chunk-MXXN7GUE.mjs.map
|
|
1408
|
+
//# sourceMappingURL=chunk-MXXN7GUE.mjs.map
|