react-panel-layout 0.2.0 → 0.4.1
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/dist/FloatingPanelFrame-BeP9z8EI.js +98 -0
- package/dist/FloatingPanelFrame-BeP9z8EI.js.map +1 -0
- package/dist/FloatingPanelFrame-Cu50Y9xg.cjs +2 -0
- package/dist/FloatingPanelFrame-Cu50Y9xg.cjs.map +1 -0
- package/dist/GridLayout-CwuQEP7k.cjs +2 -0
- package/dist/GridLayout-CwuQEP7k.cjs.map +1 -0
- package/dist/GridLayout-DZCV1X-3.js +1338 -0
- package/dist/GridLayout-DZCV1X-3.js.map +1 -0
- package/dist/components/paneling/FloatingPanelFrame.d.ts +2 -2
- package/dist/components/window/Drawer.d.ts +0 -3
- package/dist/config.cjs +1 -1
- package/dist/config.js +1 -1
- package/dist/constants/styles.d.ts +92 -86
- package/dist/floating.cjs +1 -1
- package/dist/floating.cjs.map +1 -1
- package/dist/floating.js +7 -64
- package/dist/floating.js.map +1 -1
- package/dist/hooks/useTransitionState.d.ts +21 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -6
- package/dist/modules/window/useDrawerState.d.ts +3 -2
- package/dist/types.d.ts +21 -0
- package/package.json +2 -1
- package/dist/GridLayout-CmzKfbPP.js +0 -1295
- package/dist/GridLayout-CmzKfbPP.js.map +0 -1
- package/dist/GridLayout-Dx3Qofl0.cjs +0 -2
- package/dist/GridLayout-Dx3Qofl0.cjs.map +0 -1
- package/dist/styles-BMEhL6I0.cjs +0 -2
- package/dist/styles-BMEhL6I0.cjs.map +0 -1
- package/dist/styles-BnvLfp6e.js +0 -49
- package/dist/styles-BnvLfp6e.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GridLayout-CmzKfbPP.js","sources":["../src/hooks/useIntersectionObserver.tsx","../src/components/window/Drawer.tsx","../src/hooks/useEffectEvent.ts","../src/modules/window/useDrawerState.ts","../src/components/window/DrawerLayers.tsx","../src/modules/grid/GridLayoutContext.tsx","../src/PanelSystemContext.tsx","../src/modules/grid/LayerInstanceContext.tsx","../src/components/window/PopupLayerPortal.tsx","../src/components/grid/GridLayerResizeHandles.tsx","../src/components/grid/GridLayerList.tsx","../src/hooks/useDocumentPointerEvents.ts","../src/modules/resizer/useResizeDrag.ts","../src/hooks/useElementComponentWrapper.tsx","../src/components/resizer/ResizeHandle.tsx","../src/components/grid/GridTrackResizeHandle.tsx","../src/modules/grid/useGridPlacements.ts","../src/hooks/useIsomorphicLayoutEffect.ts","../src/modules/grid/useGridTracks.ts","../src/utils/math.ts","../src/modules/grid/useLayerInteractions.tsx","../src/components/grid/GridLayout.tsx"],"sourcesContent":["/**\n * @file Shared useIntersectionObserver hook with cached observer instances.\n */\nimport * as React from \"react\";\n\nconst createIdGenerator = () => {\n const map = new Map<object, number>();\n return (ref: object | null | undefined) => {\n if (!ref) {\n return undefined;\n }\n const existing = map.get(ref);\n if (existing !== undefined) {\n return existing;\n }\n const nextId = map.size;\n map.set(ref, nextId);\n return nextId;\n };\n};\n\nconst getId = createIdGenerator();\ntype Unobserve = () => void;\ntype Callback = (entry: IntersectionObserverEntry) => void;\ntype SharedObserver = {\n observe: (target: Element, callback: Callback) => Unobserve;\n};\nconst observerCache = new Map<string, SharedObserver>();\nconst getSharedObserver = (options: IntersectionObserverInit) => {\n const observerKey = `ovs-threshold:${options.threshold}-rootMargin:${options.rootMargin}-root:${getId(options.root)}`;\n\n if (observerCache.has(observerKey)) {\n return observerCache.get(observerKey)!;\n }\n const observer = new (class {\n #callbackMap = new Map<Element, Callback>();\n #intersectionObserver = new IntersectionObserver((entries) => {\n entries.forEach((entry) => {\n const callback = this.#callbackMap.get(entry.target);\n if (callback) {\n callback(entry);\n }\n });\n }, options);\n observe(target: Element, callback: Callback) {\n this.#callbackMap.set(target, callback);\n this.#intersectionObserver.observe(target);\n return () => {\n this.#callbackMap.delete(target);\n this.#intersectionObserver.unobserve(target);\n };\n }\n })();\n observerCache.set(observerKey, observer);\n\n return observer;\n};\nconst voidClientRect = Object.freeze({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n}) as DOMRectReadOnly;\n/**\n * Observe intersection changes for a given element reference using shared observers.\n *\n * @param ref - Ref holding the element to observe.\n * @param options - Intersection observer configuration.\n * @returns Latest intersection entry snapshot with sensible defaults.\n */\nexport function useIntersectionObserver<T extends HTMLElement>(\n ref: React.RefObject<T | null>,\n { threshold = 0, rootMargin = \"0px\", root = null }: IntersectionObserverInit,\n): {\n readonly boundingClientRect: DOMRectReadOnly;\n readonly intersectionRatio: number;\n readonly intersectionRect: DOMRectReadOnly;\n readonly isIntersecting: boolean;\n readonly rootBounds: DOMRectReadOnly | null;\n readonly target: Element | null;\n readonly time: DOMHighResTimeStamp;\n} {\n const [intersection, setIntersection] = React.useState<IntersectionObserverEntry | null>(null);\n\n React.useEffect(() => {\n const target = ref.current;\n if (!target) {\n return;\n }\n\n const observer = getSharedObserver({\n threshold,\n rootMargin,\n root,\n });\n\n return observer.observe(target, (entry) => {\n setIntersection({\n isIntersecting: entry.isIntersecting,\n boundingClientRect: entry.boundingClientRect,\n intersectionRatio: entry.intersectionRatio,\n intersectionRect: entry.intersectionRect,\n rootBounds: entry.rootBounds,\n target: entry.target,\n time: entry.time,\n });\n });\n }, [ref, threshold, rootMargin, root]);\n\n return React.useMemo(() => {\n return {\n isIntersecting: intersection?.isIntersecting ?? false,\n boundingClientRect: intersection?.boundingClientRect ?? voidClientRect,\n intersectionRatio: intersection?.intersectionRatio ?? 0,\n intersectionRect: intersection?.intersectionRect ?? voidClientRect,\n rootBounds: intersection?.rootBounds ?? null,\n target: intersection?.target ?? ref.current,\n time: intersection?.time ?? 0,\n };\n }, [intersection, ref]);\n}\n","/**\n * @file Drawer component\n *\n * Mobile-friendly slide-in panel with backdrop support.\n */\nimport * as React from \"react\";\nimport type { DrawerBehavior, WindowPosition } from \"../../types\";\nimport {\n DRAWER_HEADER_PADDING_Y,\n DRAWER_HEADER_PADDING_X,\n DRAWER_HEADER_GAP,\n DRAWER_CONTENT_PADDING,\n DRAWER_CLOSE_BUTTON_FONT_SIZE,\n DRAWER_SURFACE_COLOR,\n DRAWER_BORDER_COLOR,\n DRAWER_SHADOW,\n} from \"../../constants/styles\";\n\nconst drawerBackdropStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(0, 0, 0, 0.5)\",\n};\n\nconst drawerBaseStyle: React.CSSProperties = {\n position: \"fixed\",\n background: DRAWER_SURFACE_COLOR,\n boxShadow: DRAWER_SHADOW,\n willChange: \"transform\",\n};\n\nconst drawerPlacementStyles: Record<string, React.CSSProperties> = {\n left: {\n top: 0,\n bottom: 0,\n left: 0,\n transform: \"translateX(-100%)\",\n },\n right: {\n top: 0,\n bottom: 0,\n right: 0,\n transform: \"translateX(100%)\",\n },\n top: {\n top: 0,\n left: 0,\n right: 0,\n transform: \"translateY(-100%)\",\n },\n bottom: {\n bottom: 0,\n left: 0,\n right: 0,\n transform: \"translateY(100%)\",\n },\n};\n\nconst drawerHeaderStyle: React.CSSProperties = {\n display: \"flex\",\n alignItems: \"center\",\n padding: `${DRAWER_HEADER_PADDING_Y} ${DRAWER_HEADER_PADDING_X}`,\n gap: DRAWER_HEADER_GAP,\n borderBottom: `1px solid ${DRAWER_BORDER_COLOR}`,\n};\n\nconst drawerHeaderTitleStyle: React.CSSProperties = {\n fontWeight: 600,\n};\n\nconst drawerHeaderCloseButtonStyle: React.CSSProperties = {\n marginLeft: \"auto\",\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n fontSize: DRAWER_CLOSE_BUTTON_FONT_SIZE,\n};\n\nconst drawerContentStyle: React.CSSProperties = {\n padding: DRAWER_CONTENT_PADDING,\n};\n\nexport type DrawerProps = {\n id: string;\n config: DrawerBehavior;\n isOpen: boolean;\n onClose: () => void;\n children: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n zIndex?: number;\n width?: string | number;\n height?: string | number;\n position?: WindowPosition;\n backdropStyle?: React.CSSProperties;\n};\n\ntype DrawerBackdropProps = { style?: React.CSSProperties; dismissible: boolean; onClose: () => void };\n\nconst DrawerBackdrop: React.FC<DrawerBackdropProps> = React.memo(({ style, dismissible, onClose }) => {\n const handleClick = dismissible ? onClose : undefined;\n const combinedStyle = React.useMemo(() => ({ ...drawerBackdropStyle, ...style }), [style]);\n return <div style={combinedStyle} onClick={handleClick} />;\n});\n\ntype DrawerHeaderProps = {\n header: DrawerBehavior[\"header\"];\n dismissible: boolean;\n onClose: () => void;\n};\n\nconst DrawerHeader: React.FC<DrawerHeaderProps> = React.memo(({ header, dismissible, onClose }) => {\n if (!header) {\n return null;\n }\n\n const showCloseButton = header.showCloseButton ?? true;\n\n const renderTitle = () => {\n if (!header.title) {\n return null;\n }\n return <div style={drawerHeaderTitleStyle}>{header.title}</div>;\n };\n\n const renderCloseButton = () => {\n if (!showCloseButton || !dismissible) {\n return null;\n }\n return (\n <button style={drawerHeaderCloseButtonStyle} onClick={onClose} aria-label=\"Close drawer\" type=\"button\">\n ×\n </button>\n );\n };\n\n return (\n <div style={drawerHeaderStyle}>\n {renderTitle()}\n {renderCloseButton()}\n </div>\n );\n});\n\nexport const Drawer: React.FC<DrawerProps> = ({\n id,\n config,\n isOpen,\n onClose,\n children,\n className,\n style: styleProp,\n zIndex,\n width,\n height,\n position,\n backdropStyle,\n}) => {\n const { dismissible = true, header } = config;\n\n const resolvePlacement = React.useCallback((pos?: WindowPosition): \"left\" | \"right\" | \"top\" | \"bottom\" => {\n if (!pos) {\n return \"right\";\n }\n if (pos.left !== undefined) {\n return \"left\";\n }\n if (pos.right !== undefined) {\n return \"right\";\n }\n if (pos.top !== undefined) {\n return \"top\";\n }\n if (pos.bottom !== undefined) {\n return \"bottom\";\n }\n return \"right\";\n }, []);\n\n const placement = resolvePlacement(position);\n\n const drawerStyle = React.useMemo((): React.CSSProperties => {\n const style: React.CSSProperties = {\n ...drawerBaseStyle,\n ...drawerPlacementStyles[placement],\n ...styleProp,\n };\n\n if (zIndex !== undefined) {\n style.zIndex = zIndex;\n }\n\n if (width !== undefined) {\n style.width = typeof width === \"number\" ? `${width}px` : width;\n }\n if (height !== undefined) {\n style.height = typeof height === \"number\" ? `${height}px` : height;\n }\n\n return style;\n }, [styleProp, zIndex, width, height, placement]);\n\n const contentFinalStyle = header ? drawerContentStyle : undefined;\n\n const renderHeader = () => {\n if (!header) {\n return null;\n }\n return <DrawerHeader header={header} dismissible={dismissible} onClose={onClose} />;\n };\n\n const renderBackdrop = () => {\n if (!backdropStyle) {\n return null;\n }\n return (\n <React.Activity mode={isOpen ? \"visible\" : \"hidden\"}>\n <DrawerBackdrop style={backdropStyle} dismissible={dismissible} onClose={onClose} />\n </React.Activity>\n );\n };\n\n return (\n <>\n {renderBackdrop()}\n <React.Activity mode={isOpen ? \"visible\" : \"hidden\"}>\n <div\n className={className}\n data-layer-id={id}\n data-placement={placement}\n style={drawerStyle}\n role=\"dialog\"\n aria-modal={dismissible ? true : undefined}\n aria-hidden={isOpen ? undefined : true}\n aria-label={header?.title ?? \"Drawer\"}\n >\n {renderHeader()}\n <div style={contentFinalStyle}>{children}</div>\n </div>\n </React.Activity>\n </>\n );\n};\n","/**\n * @file useEffectEvent hook - Stable event handler for Effects\n *\n * This hook allows you to extract event handlers from Effects without causing them to re-run.\n * The returned function is stable and can be safely used in effect dependencies.\n *\n * @see https://react.dev/learn/separating-events-from-effects#declaring-an-effect-event\n */\nimport * as React from \"react\";\n\n/**\n * Extract event handlers from Effects to avoid unnecessary re-runs\n *\n * @example\n * ```tsx\n * function Component({ onEvent }) {\n * const onEventHandler = useEffectEvent(onEvent);\n *\n * React.useEffect(() => {\n * // onEventHandler is stable, but always calls the latest onEvent\n * const cleanup = subscribe(onEventHandler);\n * return cleanup;\n * }, []); // No need to include onEvent in dependencies\n * }\n * ```\n */\nexport function useEffectEvent<Args extends unknown[], Return>(\n fn: ((...args: Args) => Return) | undefined,\n): (...args: Args) => Return | undefined {\n const ref = React.useRef<typeof fn>(fn);\n ref.current = fn;\n\n return React.useCallback((...args: Args): Return | undefined => {\n const currentFn = ref.current;\n if (currentFn) {\n return currentFn(...args);\n }\n return undefined;\n }, []);\n}\n","/**\n * @file Hook for managing drawer state (controlled/uncontrolled)\n */\nimport * as React from \"react\";\nimport { useEffectEvent } from \"../../hooks/useEffectEvent\";\nimport type { LayerDefinition } from \"../../types\";\n\nexport const useDrawerState = (layers: LayerDefinition[]) => {\n const [drawerStates, setDrawerStates] = React.useState<Record<string, boolean>>(() => {\n const initial: Record<string, boolean> = {};\n layers.forEach((layer) => {\n if (layer.drawer) {\n initial[layer.id] = layer.drawer.defaultOpen ?? false;\n }\n });\n return initial;\n });\n\n const layerMap = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => {\n map.set(layer.id, layer);\n });\n return map;\n }, [layers]);\n\n const notifyStateChange = useEffectEvent((layerId: string, newState: boolean) => {\n const layer = layerMap.get(layerId);\n layer?.drawer?.onStateChange?.(newState);\n });\n\n const state = React.useCallback(\n (layerId: string): boolean => {\n const layer = layerMap.get(layerId);\n if (!layer?.drawer) {\n return false;\n }\n if (layer.drawer.open !== undefined) {\n return layer.drawer.open;\n }\n return drawerStates[layerId] ?? false;\n },\n [layerMap, drawerStates],\n );\n\n const open = React.useCallback(\n (layerId: string) => {\n const layer = layerMap.get(layerId);\n if (!layer?.drawer) {\n return;\n }\n if (layer.drawer.open !== undefined) {\n notifyStateChange(layerId, true);\n return;\n }\n setDrawerStates((prev) => {\n if (prev[layerId]) {\n return prev;\n }\n notifyStateChange(layerId, true);\n return { ...prev, [layerId]: true };\n });\n },\n [layerMap, notifyStateChange],\n );\n\n const close = React.useCallback(\n (layerId: string) => {\n const layer = layerMap.get(layerId);\n if (!layer?.drawer) {\n return;\n }\n if (layer.drawer.open !== undefined) {\n notifyStateChange(layerId, false);\n return;\n }\n setDrawerStates((prev) => {\n if (!prev[layerId]) {\n return prev;\n }\n notifyStateChange(layerId, false);\n return { ...prev, [layerId]: false };\n });\n },\n [layerMap, notifyStateChange],\n );\n\n return {\n state,\n open,\n close,\n };\n};\n","/**\n * @file DrawerLayers component\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\nimport { Drawer } from \"./Drawer\";\nimport { useDrawerState } from \"../../modules/window/useDrawerState\";\n\nexport type DrawerLayersProps = {\n layers: LayerDefinition[];\n};\n\nexport const DrawerLayers: React.FC<DrawerLayersProps> = ({ layers }) => {\n const drawer = useDrawerState(layers);\n\n const drawerLayers = React.useMemo(() => layers.filter((layer) => layer.drawer), [layers]);\n\n const closeHandlers = React.useMemo(() => {\n const handlers = new Map<string, () => void>();\n drawerLayers.forEach((layer) => {\n handlers.set(layer.id, () => drawer.close(layer.id));\n });\n return handlers;\n }, [drawerLayers, drawer.close]);\n\n return (\n <>\n {drawerLayers.map((layer) => {\n if (!layer.drawer) {\n return null;\n }\n\n const isOpen = drawer.state(layer.id);\n const onClose = closeHandlers.get(layer.id);\n\n if (!onClose) {\n return null;\n }\n\n return (\n <Drawer\n key={layer.id}\n id={layer.id}\n config={layer.drawer}\n isOpen={isOpen}\n onClose={onClose}\n style={layer.style}\n zIndex={layer.zIndex}\n width={layer.width}\n height={layer.height}\n position={layer.position}\n backdropStyle={layer.backdropStyle}\n >\n {layer.component}\n </Drawer>\n );\n })}\n </>\n );\n};\n","/**\n * @file Context provider for grid layer rendering helpers.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\n\nexport type GridLayerHandleProps = React.HTMLAttributes<HTMLElement> & {\n \"data-drag-handle\": \"true\";\n};\n\nexport type ResizeHandleConfig =\n | {\n key: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n variant: \"corner\";\n horizontal: \"left\" | \"right\";\n vertical: \"top\" | \"bottom\";\n }\n | {\n key: \"left\" | \"right\" | \"top\" | \"bottom\";\n variant: \"edge\";\n horizontal?: \"left\" | \"right\";\n vertical?: \"top\" | \"bottom\";\n };\n\nexport type GridLayerRenderState = {\n style: React.CSSProperties;\n isResizable: boolean;\n isResizing: boolean;\n onResizeHandlePointerDown: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => void;\n};\n\nexport type GridLayoutContextValue = {\n handleLayerPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;\n getLayerRenderState: (layer: LayerDefinition) => GridLayerRenderState;\n getLayerHandleProps: (layerId: string) => GridLayerHandleProps;\n};\n\nconst GridLayoutContext = React.createContext<GridLayoutContextValue | null>(null);\n\nexport const GridLayoutProvider: React.FC<\n React.PropsWithChildren<{ value: GridLayoutContextValue }>\n> = ({ value, children }) => {\n return <GridLayoutContext.Provider value={value}>{children}</GridLayoutContext.Provider>;\n};\n\nexport const useGridLayoutContext = (): GridLayoutContextValue => {\n const context = React.useContext(GridLayoutContext);\n if (!context) {\n throw new Error(\"useGridLayoutContext must be used within a GridLayoutProvider.\");\n }\n return context;\n};\n","/**\n * @file PanelSystemContext\n *\n * Core provider for panel definitions and registry. Grid-specific layout and\n * interactions are composed by UI layers (e.g., GridLayout) on top of this.\n */\nimport * as React from \"react\";\nimport type { PanelLayoutConfig, LayerDefinition } from \"./types\";\n\nexport type PanelSystemContextValue = {\n config: PanelLayoutConfig;\n style?: React.CSSProperties;\n layers: {\n /** Raw panel definitions (no grid normalization). */\n defs: LayerDefinition[];\n /** Fast lookup map by id for consumers. */\n layerById: Map<string, LayerDefinition>;\n };\n};\n\nconst PanelSystemContext = React.createContext<PanelSystemContextValue | null>(null);\n\nexport const usePanelSystem = (): PanelSystemContextValue => {\n const ctx = React.useContext(PanelSystemContext);\n if (!ctx) {\n throw new Error(\"usePanelSystem must be used within a PanelSystemProvider.\");\n }\n return ctx;\n};\n\nexport type PanelSystemProviderProps = React.PropsWithChildren<{\n config: PanelLayoutConfig;\n layers: LayerDefinition[];\n style?: React.CSSProperties;\n}>;\n\nexport const PanelSystemProvider: React.FC<PanelSystemProviderProps> = ({ config, layers, style, children }) => {\n const layerById = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => {\n map.set(layer.id, layer);\n });\n return map;\n }, [layers]);\n\n const value = React.useMemo<PanelSystemContextValue>(\n () => ({\n config,\n style,\n layers: {\n defs: layers,\n layerById,\n },\n }),\n [config, style, layers, layerById],\n );\n\n return <PanelSystemContext.Provider value={value}>{children}</PanelSystemContext.Provider>;\n};\n","/**\n * @file Context exposing the current grid layer id and helpers to child components.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\nimport { usePanelSystem } from \"../../PanelSystemContext\";\nimport { useGridLayoutContext, type GridLayerHandleProps } from \"./GridLayoutContext\";\n\ntype LayerInstanceContextValue = {\n layerId: string;\n};\n\nconst LayerInstanceContext = React.createContext<LayerInstanceContextValue | null>(null);\n\nexport type LayerInstanceProviderProps = React.PropsWithChildren<LayerInstanceContextValue>;\n\nexport const LayerInstanceProvider: React.FC<LayerInstanceProviderProps> = ({ layerId, children }) => {\n const value = React.useMemo(() => ({ layerId }), [layerId]);\n return <LayerInstanceContext.Provider value={value}>{children}</LayerInstanceContext.Provider>;\n};\n\nexport const useLayerInstance = (): LayerInstanceContextValue => {\n const value = React.useContext(LayerInstanceContext);\n if (!value) {\n throw new Error(\"useLayerInstance must be used within a LayerInstanceProvider.\");\n }\n return value;\n};\n\n/**\n * Convenience: read the current layer definition from the core registry.\n */\nexport const useCurrentLayerDefinition = (): LayerDefinition => {\n const { layerId } = useLayerInstance();\n const { layers } = usePanelSystem();\n const def = layers.layerById.get(layerId);\n if (!def) {\n throw new Error(`Layer definition not found for id: ${layerId}`);\n }\n return def;\n};\n\n/**\n * Convenience: get drag handle props, pre-bound to the current layer.\n */\nexport const useCurrentLayerHandleProps = (): GridLayerHandleProps => {\n const { layerId } = useLayerInstance();\n const { getLayerHandleProps } = useGridLayoutContext();\n return React.useMemo(() => getLayerHandleProps(layerId), [getLayerHandleProps, layerId]);\n};\n\n/**\n * Compatibility helper for existing code using useLayerDragHandle.\n * Prefer useCurrentLayerHandleProps for direct access.\n */\nexport const useLayerDragHandleProps = useCurrentLayerHandleProps;\n","/**\n * @file Renders floating layers inside a dedicated browser popup window.\n */\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { LayerDefinition, PopupWindowOptions, WindowPosition, WindowBounds } from \"../../types\";\nimport { LayerInstanceProvider } from \"../../modules/grid/LayerInstanceContext\";\n\nconst ensureNumericOffset = (value: number | string | undefined, key: keyof WindowPosition, layerId: string): number => {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n throw new Error(`Popup layer \"${layerId}\" requires a numeric \"${key}\" value.`);\n};\n\nconst resolvePopupAnchor = (position: WindowPosition | undefined, layerId: string): { left: number; top: number } => {\n if (!position) {\n throw new Error(`Popup layer \"${layerId}\" must define position (left/top).`);\n }\n return {\n left: ensureNumericOffset(position.left, \"left\", layerId),\n top: ensureNumericOffset(position.top, \"top\", layerId),\n };\n};\n\nconst numericFeature = (value: number): string => {\n return `${Math.round(value)}`;\n};\n\nconst booleanFeature = (value: boolean | undefined): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n return value ? \"yes\" : \"no\";\n};\n\nconst buildWindowFeatures = (\n layerId: string,\n position: WindowPosition | undefined,\n width: number | string | undefined,\n height: number | string | undefined,\n options: PopupWindowOptions | undefined,\n): string => {\n const features: Record<string, string> = {};\n const anchor = resolvePopupAnchor(position, layerId);\n\n if (typeof width !== \"number\" || typeof height !== \"number\") {\n throw new Error(`Popup layer \"${layerId}\" requires numeric width/height.`);\n }\n features.width = numericFeature(width);\n features.height = numericFeature(height);\n features.left = numericFeature(anchor.left);\n features.top = numericFeature(anchor.top);\n\n const overrides = options?.features;\n if (overrides) {\n const toolbar = booleanFeature(overrides.toolbar);\n const menubar = booleanFeature(overrides.menubar);\n const location = booleanFeature(overrides.location);\n const status = booleanFeature(overrides.status);\n const resizable = booleanFeature(overrides.resizable);\n const scrollbars = booleanFeature(overrides.scrollbars);\n\n if (toolbar !== undefined) {\n features.toolbar = toolbar;\n }\n if (menubar !== undefined) {\n features.menubar = menubar;\n }\n if (location !== undefined) {\n features.location = location;\n }\n if (status !== undefined) {\n features.status = status;\n }\n if (resizable !== undefined) {\n features.resizable = resizable;\n }\n if (scrollbars !== undefined) {\n features.scrollbars = scrollbars;\n }\n }\n\n return Object.entries(features)\n .map(([key, value]) => `${key}=${value}`)\n .join(\",\");\n};\n\nconst applyBoundsToWindow = (\n popupWindow: Window,\n layerId: string,\n position: WindowPosition | undefined,\n width: number | string | undefined,\n height: number | string | undefined,\n) => {\n const anchor = resolvePopupAnchor(position, layerId);\n if (typeof width !== \"number\" || typeof height !== \"number\") {\n throw new Error(`Popup layer \"${layerId}\" requires numeric width/height.`);\n }\n popupWindow.moveTo(Math.round(anchor.left), Math.round(anchor.top));\n popupWindow.resizeTo(Math.round(width), Math.round(height));\n};\n\ntype PopupLayerPortalProps = {\n layer: LayerDefinition;\n};\n\nexport const PopupLayerPortal: React.FC<PopupLayerPortalProps> = ({ layer }) => {\n const floating = layer.floating;\n if (!floating) {\n throw new Error(`Layer \"${layer.id}\" is missing floating configuration required for popup mode.`);\n }\n const mode = floating.mode ?? \"embedded\";\n if (mode !== \"popup\") {\n throw new Error(`PopupLayerPortal received layer \"${layer.id}\" that is not configured for popup mode.`);\n }\n\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const popupWindowRef = React.useRef<Window | null>(null);\n const [isMounted, setIsMounted] = React.useState(false);\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const features = buildWindowFeatures(layer.id, layer.position, layer.width, layer.height, floating.popup);\n const windowName = floating.popup?.name ?? layer.id;\n const createdWindow = resolvePopupWindow(\n windowName,\n features,\n {\n position: layer.position,\n size: { width: layer.width as number, height: layer.height as number },\n },\n floating.popup,\n );\n\n if (!createdWindow) {\n throw new Error(`Failed to open popup window for layer \"${layer.id}\".`);\n }\n\n const openedWindow = createdWindow;\n\n popupWindowRef.current = openedWindow;\n\n if (floating.popup?.focus !== false) {\n openedWindow.focus();\n }\n\n if (!openedWindow.document.title) {\n openedWindow.document.title = layer.id;\n }\n openedWindow.document.body.innerHTML = \"\";\n const mountNode = openedWindow.document.createElement(\"div\");\n mountNode.dataset.layerId = layer.id;\n openedWindow.document.body.appendChild(mountNode);\n containerRef.current = mountNode;\n setIsMounted(true);\n\n applyBoundsToWindow(openedWindow, layer.id, layer.position, layer.width, layer.height);\n\n const handleBeforeUnload = () => {\n popupWindowRef.current = null;\n containerRef.current = null;\n setIsMounted(false);\n };\n openedWindow.addEventListener(\"beforeunload\", handleBeforeUnload);\n\n return () => {\n openedWindow.removeEventListener(\"beforeunload\", handleBeforeUnload);\n if (floating.popup?.closeOnUnmount !== false) {\n openedWindow.close();\n }\n popupWindowRef.current = null;\n containerRef.current = null;\n setIsMounted(false);\n };\n }, [\n floating.popup?.closeOnUnmount,\n floating.popup?.features?.location,\n floating.popup?.features?.menubar,\n floating.popup?.features?.resizable,\n floating.popup?.features?.scrollbars,\n floating.popup?.features?.status,\n floating.popup?.features?.toolbar,\n floating.popup?.focus,\n floating.popup?.name,\n layer.id,\n ]);\n\n React.useEffect(() => {\n const popupWindow = popupWindowRef.current;\n if (!popupWindow) {\n return;\n }\n applyBoundsToWindow(popupWindow, layer.id, layer.position, layer.width, layer.height);\n }, [layer.position?.left, layer.position?.top, layer.height, layer.width, layer.id]);\n\n if (!isMounted || !containerRef.current) {\n return null;\n }\n\n return createPortal(<LayerInstanceProvider layerId={layer.id}>{layer.component}</LayerInstanceProvider>, containerRef.current);\n};\n\nconst resolvePopupWindow = (\n windowName: string,\n features: string,\n bounds: WindowBounds,\n options: PopupWindowOptions | undefined,\n): Window | null => {\n const customFactory = options?.createWindow;\n if (customFactory) {\n return customFactory({ name: windowName, features, bounds });\n }\n return window.open(\"\", windowName, features);\n};\n","/**\n * @file Presentational resize handles for floating layers (corner + edge).\n */\nimport * as React from \"react\";\nimport { GRID_LAYER_CORNER_HIT_SIZE, GRID_LAYER_EDGE_HIT_THICKNESS } from \"../../constants/styles\";\n\nconst resizeHandleBaseStyle: React.CSSProperties = {\n position: \"absolute\",\n pointerEvents: \"auto\",\n boxSizing: \"border-box\",\n background: \"transparent\",\n border: \"none\",\n};\n\nconst cornerHandleStyle: React.CSSProperties = {\n ...resizeHandleBaseStyle,\n width: GRID_LAYER_CORNER_HIT_SIZE,\n height: GRID_LAYER_CORNER_HIT_SIZE,\n zIndex: 2,\n};\n\nconst edgeHandleStyle: React.CSSProperties = {\n ...resizeHandleBaseStyle,\n zIndex: 1,\n};\n\nconst cornerPositions: Record<string, React.CSSProperties> = {\n \"top-left\": {\n top: 0,\n left: 0,\n transform: \"translate(-50%, -50%)\",\n cursor: \"nwse-resize\",\n },\n \"top-right\": {\n top: 0,\n right: 0,\n transform: \"translate(50%, -50%)\",\n cursor: \"nesw-resize\",\n },\n \"bottom-left\": {\n bottom: 0,\n left: 0,\n transform: \"translate(-50%, 50%)\",\n cursor: \"nesw-resize\",\n },\n \"bottom-right\": {\n bottom: 0,\n right: 0,\n transform: \"translate(50%, 50%)\",\n cursor: \"nwse-resize\",\n },\n};\n\nconst edgePositions: Record<string, React.CSSProperties> = {\n left: {\n top: GRID_LAYER_CORNER_HIT_SIZE,\n bottom: GRID_LAYER_CORNER_HIT_SIZE,\n left: 0,\n width: GRID_LAYER_EDGE_HIT_THICKNESS,\n transform: \"translateX(-50%)\",\n cursor: \"ew-resize\",\n },\n right: {\n top: GRID_LAYER_CORNER_HIT_SIZE,\n bottom: GRID_LAYER_CORNER_HIT_SIZE,\n right: 0,\n width: GRID_LAYER_EDGE_HIT_THICKNESS,\n transform: \"translateX(50%)\",\n cursor: \"ew-resize\",\n },\n top: {\n left: GRID_LAYER_CORNER_HIT_SIZE,\n right: GRID_LAYER_CORNER_HIT_SIZE,\n top: 0,\n height: GRID_LAYER_EDGE_HIT_THICKNESS,\n transform: \"translateY(-50%)\",\n cursor: \"ns-resize\",\n },\n bottom: {\n left: GRID_LAYER_CORNER_HIT_SIZE,\n right: GRID_LAYER_CORNER_HIT_SIZE,\n bottom: 0,\n height: GRID_LAYER_EDGE_HIT_THICKNESS,\n transform: \"translateY(50%)\",\n cursor: \"ns-resize\",\n },\n};\n\nexport type HorizontalEdge = \"left\" | \"right\";\nexport type VerticalEdge = \"top\" | \"bottom\";\n\nexport type ResizeHandleConfig =\n | {\n key: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n variant: \"corner\";\n horizontal: HorizontalEdge;\n vertical: VerticalEdge;\n }\n | {\n key: \"left\" | \"right\" | \"top\" | \"bottom\";\n variant: \"edge\";\n horizontal?: HorizontalEdge;\n vertical?: VerticalEdge;\n };\n\nconst RESIZE_HANDLE_CONFIGS: ReadonlyArray<ResizeHandleConfig> = [\n { key: \"top-left\", variant: \"corner\", horizontal: \"left\", vertical: \"top\" },\n { key: \"top-right\", variant: \"corner\", horizontal: \"right\", vertical: \"top\" },\n { key: \"bottom-left\", variant: \"corner\", horizontal: \"left\", vertical: \"bottom\" },\n { key: \"bottom-right\", variant: \"corner\", horizontal: \"right\", vertical: \"bottom\" },\n { key: \"left\", variant: \"edge\", horizontal: \"left\" },\n { key: \"right\", variant: \"edge\", horizontal: \"right\" },\n { key: \"top\", variant: \"edge\", vertical: \"top\" },\n { key: \"bottom\", variant: \"edge\", vertical: \"bottom\" },\n];\n\nexport type GridLayerResizeHandlesProps = {\n layerId: string;\n onPointerDown: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => void;\n};\n\nexport const GridLayerResizeHandles: React.FC<GridLayerResizeHandlesProps> = ({ layerId, onPointerDown }) => {\n return (\n <>\n {RESIZE_HANDLE_CONFIGS.map((config) => {\n const baseStyle = config.variant === \"corner\" ? cornerHandleStyle : edgeHandleStyle;\n const positionStyle = config.variant === \"corner\" ? cornerPositions[config.key] : edgePositions[config.key];\n const combinedStyle = { ...baseStyle, ...positionStyle };\n const datasetProps =\n config.variant === \"corner\" ? { \"data-resize-corner\": config.key } : { \"data-resize-edge\": config.key };\n return (\n <div\n key={config.key}\n role=\"presentation\"\n aria-hidden=\"true\"\n style={combinedStyle}\n {...datasetProps}\n data-layer-id={layerId}\n onPointerDown={(event) => onPointerDown(config, event)}\n />\n );\n })}\n </>\n );\n};\n","/**\n * @file Layer list rendering inside the grid layout.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\nimport { useGridLayoutContext } from \"../../modules/grid/GridLayoutContext\";\nimport { LayerInstanceProvider } from \"../../modules/grid/LayerInstanceContext\";\nimport { PopupLayerPortal } from \"../window/PopupLayerPortal\";\nimport { GridLayerResizeHandles } from \"./GridLayerResizeHandles\";\nimport type { ResizeHandleConfig } from \"../../modules/grid/GridLayoutContext\";\n\ntype GridLayerListProps = {\n layers: LayerDefinition[];\n};\n\ntype ResizeHandleRenderRequest = {\n layerId: string;\n onPointerDown: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => void;\n};\n\nexport const GridLayerList: React.FC<GridLayerListProps> = ({ layers }) => {\n const { handleLayerPointerDown, getLayerRenderState } = useGridLayoutContext();\n\n const renderResizeHandles = React.useCallback((requests: ResizeHandleRenderRequest[]): React.ReactNode => {\n if (requests.length === 0) {\n return null;\n }\n return requests.map((request) => (\n <GridLayerResizeHandles key={request.layerId} layerId={request.layerId} onPointerDown={request.onPointerDown} />\n ));\n }, []);\n\n return (\n <>\n {layers.map((layer) => {\n const floatingMode = layer.floating?.mode ?? \"embedded\";\n if (layer.floating && floatingMode === \"popup\") {\n return <PopupLayerPortal key={layer.id} layer={layer} />;\n }\n\n const { style, isResizable, isResizing, onResizeHandlePointerDown } = getLayerRenderState(layer);\n const gridPlacementStyle: React.CSSProperties = {};\n if (layer.gridArea) {\n gridPlacementStyle.gridArea = layer.gridArea;\n }\n if (layer.gridRow) {\n gridPlacementStyle.gridRow = layer.gridRow;\n }\n if (layer.gridColumn) {\n gridPlacementStyle.gridColumn = layer.gridColumn;\n }\n\n const buildCombinedStyle = (): React.CSSProperties => {\n if (isResizable) {\n return { ...style, ...gridPlacementStyle, position: \"relative\" as const };\n }\n return { ...style, ...gridPlacementStyle };\n };\n const combinedStyle = buildCombinedStyle();\n\n const buildResizeHandleRequests = (): ResizeHandleRenderRequest[] => {\n if (!isResizable) {\n return [];\n }\n return [\n {\n layerId: layer.id,\n onPointerDown: onResizeHandlePointerDown,\n },\n ];\n };\n const resizeHandles = renderResizeHandles(buildResizeHandleRequests());\n\n return (\n <div\n key={layer.id}\n data-layer-id={layer.id}\n data-draggable={Boolean(layer.floating?.draggable)}\n data-resizable={isResizable}\n data-resizing={isResizing}\n style={combinedStyle}\n onPointerDown={handleLayerPointerDown}\n >\n <LayerInstanceProvider layerId={layer.id}>{layer.component}</LayerInstanceProvider>\n {resizeHandles}\n </div>\n );\n })}\n </>\n );\n};\n","/**\n * @file Hooks for managing document-level pointer events with proper cleanup\n */\nimport * as React from \"react\";\nimport { useEffectEvent } from \"./useEffectEvent\";\n\nexport type UseDocumentPointerEventsOptions = {\n onMove?: (e: PointerEvent) => void;\n onUp?: (e: PointerEvent) => void;\n onCancel?: (e: PointerEvent) => void;\n};\n\n/**\n * Custom hook for managing document-level pointer events with proper cleanup\n * This pattern is commonly used for drag operations that need to continue\n * even when the pointer moves outside the original element\n */\nexport function useDocumentPointerEvents(enabled: boolean, handlers: UseDocumentPointerEventsOptions) {\n const handleMoveEvent = useEffectEvent(handlers.onMove);\n const handleUpEvent = useEffectEvent(handlers.onUp);\n const handleCancelEvent = useEffectEvent(handlers.onCancel);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n if (handlers.onMove) {\n document.addEventListener(\"pointermove\", handleMoveEvent, { passive: false });\n }\n if (handlers.onUp) {\n document.addEventListener(\"pointerup\", handleUpEvent);\n }\n if (handlers.onCancel) {\n document.addEventListener(\"pointercancel\", handleCancelEvent);\n }\n\n // Cleanup function\n return () => {\n if (handlers.onMove) {\n document.removeEventListener(\"pointermove\", handleMoveEvent);\n }\n if (handlers.onUp) {\n document.removeEventListener(\"pointerup\", handleUpEvent);\n }\n if (handlers.onCancel) {\n document.removeEventListener(\"pointercancel\", handleCancelEvent);\n }\n };\n }, [enabled, handlers.onMove, handlers.onUp, handlers.onCancel, handleMoveEvent, handleUpEvent, handleCancelEvent]);\n}\n\n/**\n * Hook for capturing pointer during drag operations\n * This ensures that pointer events are delivered to the capturing element\n * even when the pointer moves outside its boundaries\n */\nexport function usePointerCapture(elementRef: React.RefObject<HTMLElement | null>, enabled: boolean, pointerId?: number) {\n React.useEffect(() => {\n const element = elementRef.current;\n if (!enabled || !element || pointerId === undefined) {\n return;\n }\n\n // Capture pointer\n element.setPointerCapture(pointerId);\n\n // Release capture on cleanup\n return () => {\n if (element.hasPointerCapture && element.hasPointerCapture(pointerId)) {\n element.releasePointerCapture(pointerId);\n }\n };\n }, [elementRef, enabled, pointerId]);\n}\n\n/**\n * Hook for preventing default pointer events during operations\n * Useful for preventing text selection, context menus, etc. during drag operations\n */\nexport function usePreventPointerDefaults(\n elementRef: React.RefObject<HTMLElement | null>,\n enabled: boolean,\n events: string[] = [\"pointerdown\", \"pointermove\", \"pointerup\"],\n) {\n React.useEffect(() => {\n const element = elementRef.current;\n if (!enabled || !element) {\n return;\n }\n\n const preventDefault = (e: Event) => {\n e.preventDefault();\n };\n\n // Add listeners\n events.forEach((eventType) => {\n element.addEventListener(eventType, preventDefault, { passive: false });\n });\n\n // Cleanup\n return () => {\n events.forEach((eventType) => {\n element.removeEventListener(eventType, preventDefault);\n });\n };\n }, [elementRef, enabled, events]);\n}\n\n/**\n * Hook that combines multiple pointer event patterns for drag operations\n */\nexport function useDragPointerEvents(\n elementRef: React.RefObject<HTMLElement | null>,\n enabled: boolean,\n options: {\n onMove?: (e: PointerEvent) => void;\n onUp?: (e: PointerEvent) => void;\n onCancel?: (e: PointerEvent) => void;\n pointerId?: number;\n capturePointer?: boolean;\n preventDefaults?: boolean;\n },\n) {\n const { onMove, onUp, onCancel, pointerId, capturePointer = true, preventDefaults = true } = options;\n\n // Document-level event handlers\n useDocumentPointerEvents(enabled, { onMove, onUp, onCancel });\n\n // Pointer capture\n const shouldCapturePointer = enabled ? capturePointer : false;\n usePointerCapture(elementRef, shouldCapturePointer, pointerId);\n\n // Prevent defaults\n const shouldPreventDefaults = enabled ? preventDefaults : false;\n usePreventPointerDefaults(elementRef, shouldPreventDefaults);\n}\n","/**\n * @file Shared logic for draggable resize handles.\n */\nimport * as React from \"react\";\nimport { useDragPointerEvents } from \"../../hooks/useDocumentPointerEvents\";\nimport { useEffectEvent } from \"../../hooks/useEffectEvent\";\n\nexport type ResizeDragAxis = \"x\" | \"y\";\n\nexport type UseResizeDragOptions = {\n /** Axis along which the drag should compute deltas */\n axis: ResizeDragAxis;\n /** Callback invoked with the delta value when dragging */\n onResize?: (delta: number) => void;\n};\n\nexport type UseResizeDragResult<TElement extends HTMLElement> = {\n /** Ref to attach to the draggable element */\n ref: React.RefObject<TElement | null>;\n /** Pointer down handler to initiate dragging */\n onPointerDown: (event: React.PointerEvent<TElement>) => void;\n /** Whether a drag interaction is currently active */\n isDragging: boolean;\n};\n\n/**\n * Provides unified pointer handling for resize-capable UI elements.\n *\n * @param options - Configuration for the drag interaction.\n * @returns Handlers and state for wiring into a draggable element.\n */\nexport const useResizeDrag = <TElement extends HTMLElement = HTMLElement>(\n options: UseResizeDragOptions,\n): UseResizeDragResult<TElement> => {\n const elementRef = React.useRef<TElement | null>(null);\n const pointerIdRef = React.useRef<number | null>(null);\n const previousCoordinateRef = React.useRef<number>(0);\n const [isDragging, setIsDragging] = React.useState(false);\n\n const emitResize = useEffectEvent((delta: number) => {\n options.onResize?.(delta);\n });\n\n const getCoordinate = React.useCallback(\n (event: PointerEvent | React.PointerEvent) => {\n return options.axis === \"x\" ? event.clientX : event.clientY;\n },\n [options.axis],\n );\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<TElement>) => {\n event.preventDefault();\n elementRef.current = event.currentTarget;\n pointerIdRef.current = event.pointerId;\n previousCoordinateRef.current = getCoordinate(event);\n setIsDragging(true);\n },\n [getCoordinate],\n );\n\n const handlePointerMove = React.useCallback(\n (event: PointerEvent) => {\n const coordinate = getCoordinate(event);\n const delta = coordinate - previousCoordinateRef.current;\n if (delta === 0) {\n return;\n }\n previousCoordinateRef.current = coordinate;\n emitResize(delta);\n },\n [getCoordinate, emitResize],\n );\n\n const handlePointerUp = React.useCallback(() => {\n setIsDragging(false);\n pointerIdRef.current = null;\n }, []);\n\n useDragPointerEvents(elementRef as React.RefObject<HTMLElement | null>, isDragging, {\n onMove: handlePointerMove,\n onUp: handlePointerUp,\n pointerId: pointerIdRef.current ?? undefined,\n capturePointer: true,\n preventDefaults: false,\n });\n\n return {\n ref: elementRef,\n onPointerDown: handlePointerDown,\n isDragging,\n };\n};\n\n","/**\n * @file Hook for building wrapper components that accept either an element or a component override.\n */\nimport * as React from \"react\";\n\ntype WrapperProps = React.HTMLAttributes<HTMLDivElement>;\n\ntype CloneableProps = WrapperProps & {\n ref?: React.Ref<HTMLDivElement>;\n};\n\ntype UseElementComponentWrapperOptions = {\n element?: React.ReactElement<WrapperProps>;\n component?: React.ComponentType<WrapperProps & { ref?: React.Ref<HTMLDivElement> }>;\n};\n\ntype WrapperComponent = React.ForwardRefExoticComponent<\n React.PropsWithChildren<WrapperProps> & React.RefAttributes<HTMLDivElement>\n>;\n\nconst createWrapperComponent = ({\n element,\n component: Component,\n}: UseElementComponentWrapperOptions): WrapperComponent =>\n React.forwardRef<HTMLDivElement, React.PropsWithChildren<WrapperProps>>(({ children, ...rest }, forwardedRef) => {\n if (element) {\n return React.cloneElement(\n element,\n { ...rest, ref: forwardedRef } as CloneableProps,\n children ?? element.props.children\n );\n }\n if (Component) {\n return (\n <Component {...rest} ref={forwardedRef}>\n {children}\n </Component>\n );\n }\n return (\n <div {...rest} ref={forwardedRef}>\n {children}\n </div>\n );\n });\n\n/**\n * Memoizes a wrapper component that can render either a provided element, a provided component, or a default tag.\n * @returns Wrapper component honoring the overrides.\n */\nexport function useElementComponentWrapper({\n element,\n component,\n}: UseElementComponentWrapperOptions): WrapperComponent {\n return React.useMemo(\n () =>\n createWrapperComponent({\n element,\n component,\n }),\n [component, element]\n );\n}\n","/**\n * @file Resize handle component\n */\nimport * as React from \"react\";\nimport { useResizeDrag } from \"../../modules/resizer/useResizeDrag\";\nimport {\n RESIZE_HANDLE_THICKNESS,\n RESIZE_HANDLE_Z_INDEX,\n COLOR_RESIZE_HANDLE_IDLE,\n COLOR_RESIZE_HANDLE_ACTIVE,\n COLOR_RESIZE_HANDLE_HOVER,\n} from \"../../constants/styles\";\nimport { useElementComponentWrapper } from \"../../hooks/useElementComponentWrapper\";\n\ntype ResizeHandleDirection = \"horizontal\" | \"vertical\";\n\nexport type ResizeHandleProps = {\n /** Direction of resize */\n direction: ResizeHandleDirection;\n /** Callback when resize occurs */\n onResize?: (delta: number) => void;\n /** Custom component for the handle */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the handle */\n element?: React.ReactElement<React.HTMLAttributes<HTMLDivElement>>;\n /** Optional children rendered inside the handle */\n children?: React.ReactNode;\n};\n\nconst baseResizeHandleStyle: React.CSSProperties = {\n position: \"absolute\",\n zIndex: RESIZE_HANDLE_Z_INDEX,\n};\n\nconst sizeStylesByDirection: Record<ResizeHandleDirection, React.CSSProperties> = {\n vertical: {\n width: RESIZE_HANDLE_THICKNESS,\n height: \"100%\",\n top: 0,\n cursor: \"col-resize\",\n },\n horizontal: {\n width: \"100%\",\n height: RESIZE_HANDLE_THICKNESS,\n left: 0,\n cursor: \"row-resize\",\n },\n};\n\ntype ResizeHandleVisualState = \"idle\" | \"hovered\" | \"dragging\";\n\nconst backgroundByVisualState: Record<ResizeHandleVisualState, string> = {\n idle: COLOR_RESIZE_HANDLE_IDLE,\n hovered: COLOR_RESIZE_HANDLE_HOVER,\n dragging: COLOR_RESIZE_HANDLE_ACTIVE,\n};\n\n/**\n * ResizeHandle - Draggable handle for resizing grid areas\n */\nexport const ResizeHandle: React.FC<ResizeHandleProps> = ({\n direction,\n onResize,\n component: Component,\n element,\n children,\n}) => {\n const axis = direction === \"vertical\" ? \"x\" : \"y\";\n const { ref, isDragging, onPointerDown } = useResizeDrag<HTMLDivElement>({ axis, onResize });\n const [isHovered, setIsHovered] = React.useState(false);\n const handlePointerEnter = React.useCallback(() => {\n setIsHovered(true);\n }, []);\n const handlePointerLeave = React.useCallback(() => {\n setIsHovered(false);\n }, []);\n\n const Wrapper = useElementComponentWrapper({\n element,\n component: Component,\n });\n const visualState: ResizeHandleVisualState = React.useMemo(() => {\n if (isDragging) {\n return \"dragging\";\n }\n if (isHovered) {\n return \"hovered\";\n }\n return \"idle\";\n }, [isDragging, isHovered]);\n\n const style = React.useMemo(() => {\n return {\n ...baseResizeHandleStyle,\n ...sizeStylesByDirection[direction],\n backgroundColor: backgroundByVisualState[visualState],\n touchAction: \"none\",\n };\n }, [direction, visualState]);\n\n return (\n <Wrapper\n ref={ref}\n style={style}\n role=\"separator\"\n aria-orientation={direction}\n aria-hidden={undefined}\n data-resize-handle=\"true\"\n data-direction={direction}\n data-is-dragging={isDragging ? \"true\" : undefined}\n onPointerDown={onPointerDown}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {children}\n </Wrapper>\n );\n};\n","/**\n * @file Internal renderer for grid resize handles.\n */\nimport * as React from \"react\";\nimport { ResizeHandle } from \"../resizer/ResizeHandle\";\nimport { GRID_HANDLE_THICKNESS } from \"../../constants/styles\";\n\ntype TrackDirection = \"row\" | \"col\";\n\ntype GridTrackResizeHandleProps = {\n direction: TrackDirection;\n trackIndex: number;\n align: \"start\" | \"end\";\n gap: number;\n span: { start: number; end: number };\n onResize: (direction: TrackDirection, index: number, delta: number) => void;\n};\n\nconst resizeHandleWrapperBaseStyle: React.CSSProperties = {\n position: \"absolute\",\n pointerEvents: \"auto\",\n};\n\nexport const GridTrackResizeHandle: React.FC<GridTrackResizeHandleProps> = ({\n direction,\n trackIndex,\n align,\n gap,\n span,\n onResize,\n}) => {\n const resizeDirection = direction === \"col\" ? \"vertical\" : \"horizontal\";\n\n const handleResize = React.useCallback(\n (delta: number) => {\n onResize(direction, trackIndex, delta);\n },\n [direction, trackIndex, onResize],\n );\n\n const placementStyle = React.useMemo<React.CSSProperties>(() => {\n if (direction === \"col\") {\n return {\n gridColumn: `${trackIndex + 1} / ${trackIndex + 2}`,\n gridRow: `${span.start} / ${span.end}`,\n };\n }\n return {\n gridRow: `${trackIndex + 1} / ${trackIndex + 2}`,\n gridColumn: `${span.start} / ${span.end}`,\n };\n }, [direction, trackIndex, span]);\n\n const wrapperStyle = React.useMemo<React.CSSProperties>(() => {\n const halfGap = Math.max(0, gap) / 2;\n const offset = halfGap + GRID_HANDLE_THICKNESS / 2;\n\n if (direction === \"col\") {\n return {\n ...resizeHandleWrapperBaseStyle,\n width: GRID_HANDLE_THICKNESS,\n height: \"100%\",\n top: 0,\n bottom: 0,\n ...(align === \"start\" ? { left: -offset } : { right: -offset }),\n };\n }\n\n return {\n ...resizeHandleWrapperBaseStyle,\n width: \"100%\",\n height: GRID_HANDLE_THICKNESS,\n left: 0,\n right: 0,\n ...(align === \"start\" ? { top: -offset } : { bottom: -offset }),\n };\n }, [align, direction, gap]);\n\n return (\n <div data-resizable=\"true\" style={{ ...placementStyle, position: \"relative\", pointerEvents: \"none\" }}>\n <div data-direction={resizeDirection} data-align={align} data-handle=\"true\" style={wrapperStyle}>\n <ResizeHandle direction={resizeDirection} onResize={handleResize} />\n </div>\n </div>\n );\n};\n","/**\n * @file Hooks for deriving grid placements and layer collections.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition, PanelLayoutConfig } from \"../../types\";\n\ntype GridPlacement = {\n gridArea: string;\n gridRow: string;\n gridColumn: string;\n};\n\nconst computeGridPlacements = (areas: PanelLayoutConfig[\"areas\"]): Map<string, GridPlacement> => {\n type Bounds = {\n rowStart: number;\n rowEnd: number;\n colStart: number;\n colEnd: number;\n };\n\n const boundsByArea = new Map<string, Bounds>();\n\n areas.forEach((row, rowIndex) => {\n row.forEach((area, colIndex) => {\n if (!area || area === \".\") {\n return;\n }\n\n const existing = boundsByArea.get(area);\n if (existing) {\n const nextBounds: Bounds = {\n rowStart: Math.min(existing.rowStart, rowIndex),\n rowEnd: Math.max(existing.rowEnd, rowIndex),\n colStart: Math.min(existing.colStart, colIndex),\n colEnd: Math.max(existing.colEnd, colIndex),\n };\n\n boundsByArea.set(area, nextBounds);\n return;\n }\n\n const initialBounds: Bounds = {\n rowStart: rowIndex,\n rowEnd: rowIndex,\n colStart: colIndex,\n colEnd: colIndex,\n };\n\n boundsByArea.set(area, initialBounds);\n });\n });\n\n const placements = new Map<string, GridPlacement>();\n boundsByArea.forEach((bounds, area) => {\n const rowStart = bounds.rowStart + 1;\n const rowEnd = bounds.rowEnd + 2;\n const colStart = bounds.colStart + 1;\n const colEnd = bounds.colEnd + 2;\n\n const placement: GridPlacement = {\n gridArea: area,\n gridRow: `${rowStart} / ${rowEnd}`,\n gridColumn: `${colStart} / ${colEnd}`,\n };\n\n placements.set(area, placement);\n });\n\n return placements;\n};\n\nconst normalizeLayerForGrid = (\n layer: LayerDefinition,\n placements: Map<string, GridPlacement>,\n): LayerDefinition => {\n const mode = layer.positionMode ?? \"grid\";\n if (mode !== \"grid\") {\n return layer;\n }\n\n const placementKey = layer.gridArea ?? layer.id;\n const placement = placements.get(placementKey);\n\n if (!placement) {\n return layer;\n }\n\n const needsGridArea = !layer.gridArea;\n const needsRow = !layer.gridRow;\n const needsColumn = !layer.gridColumn;\n\n if (!needsGridArea && !needsRow && !needsColumn) {\n return layer;\n }\n\n return {\n ...layer,\n gridArea: needsGridArea ? placement.gridArea : layer.gridArea,\n gridRow: needsRow ? placement.gridRow : layer.gridRow,\n gridColumn: needsColumn ? placement.gridColumn : layer.gridColumn,\n };\n};\n\nexport const useGridPlacements = (\n config: PanelLayoutConfig,\n layers: LayerDefinition[],\n): {\n normalizedLayers: LayerDefinition[];\n visibleLayers: LayerDefinition[];\n regularLayers: LayerDefinition[];\n layerById: Map<string, LayerDefinition>;\n} => {\n const placements = React.useMemo(() => computeGridPlacements(config.areas), [config.areas]);\n\n const normalizedLayers = React.useMemo(() => {\n return layers.map((layer) => normalizeLayerForGrid(layer, placements));\n }, [layers, placements]);\n\n const visibleLayers = React.useMemo(\n () => normalizedLayers.filter((layer) => layer.visible !== false),\n [normalizedLayers],\n );\n\n const regularLayers = React.useMemo(\n () => visibleLayers.filter((layer) => !layer.drawer),\n [visibleLayers],\n );\n\n const layerById = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n normalizedLayers.forEach((layer) => {\n map.set(layer.id, layer);\n });\n return map;\n }, [normalizedLayers]);\n\n return {\n normalizedLayers,\n visibleLayers,\n regularLayers,\n layerById,\n };\n};\n","/**\n * @file useIsomorphicLayoutEffect - SSR-safe version of useLayoutEffect\n *\n * Uses useLayoutEffect on the client and useEffect on the server to avoid warnings\n * during server-side rendering (e.g., with Next.js)\n */\nimport * as React from \"react\";\n\n/**\n * Check if we're running in a browser environment\n */\nconst isBrowser = typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\n/**\n * SSR-safe version of useLayoutEffect\n *\n * - Client: Uses useLayoutEffect for synchronous layout updates\n * - Server: Uses useEffect to avoid SSR warnings\n *\n * @example\n * ```tsx\n * useIsomorphicLayoutEffect(() => {\n * // This runs synchronously after DOM mutations on the client\n * // but safely falls back to useEffect on the server\n * measureElement();\n * }, [deps]);\n * ```\n */\nexport const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useEffect;\n","/**\n * @file Track sizing and resize handle hooks for the grid layout.\n */\nimport * as React from \"react\";\nimport { useIsomorphicLayoutEffect } from \"../../hooks/useIsomorphicLayoutEffect\";\nimport type { GridTrack, PanelLayoutConfig } from \"../../types\";\n\nexport type TrackHandleConfig = {\n trackIndex: number;\n align: \"start\" | \"end\";\n span: { start: number; end: number };\n};\n\ntype ParsedGap = {\n rowGap: number;\n columnGap: number;\n};\n\n// Inline track template utilities (previously in helpers)\ntype TrackDirection = \"row\" | \"col\";\n\nconst createTrackKey = (direction: TrackDirection, index: number): string => {\n return `${direction}-${index}`;\n};\n\nconst getTrackSize = (\n track: GridTrack,\n trackSizes: Record<string, number>,\n direction: TrackDirection,\n index: number,\n): string => {\n const key = createTrackKey(direction, index);\n const currentSize = trackSizes[key];\n if (currentSize !== undefined) {\n return `${currentSize}px`;\n }\n return track.size;\n};\n\nconst buildTrackTemplateString = (\n tracks: GridTrack[],\n trackSizes: Record<string, number>,\n direction: TrackDirection,\n): string => {\n return tracks.map((track, index) => getTrackSize(track, trackSizes, direction, index)).join(\" \");\n};\n\nconst extractInitialTrackSizes = (tracks: GridTrack[], direction: TrackDirection): Record<string, number> => {\n return tracks.reduce<Record<string, number>>((acc, track, index) => {\n if (track.resizable && track.size.endsWith(\"px\")) {\n acc[createTrackKey(direction, index)] = parseInt(track.size, 10);\n }\n return acc;\n }, {});\n};\n\n// Inline resize utils\nconst applyConstraints = (size: number, minSize?: number, maxSize?: number): number => {\n const withMinConstraint = minSize !== undefined ? Math.max(size, minSize) : size;\n const withMaxConstraint = maxSize !== undefined ? Math.min(withMinConstraint, maxSize) : withMinConstraint;\n return withMaxConstraint;\n};\n\nconst calculateNewTrackSize = (currentSize: number, delta: number, track: GridTrack): number => {\n const newSize = currentSize + delta;\n return applyConstraints(newSize, track.minSize, track.maxSize);\n};\n\nconst createTrackSizeUpdater = (\n direction: TrackDirection,\n index: number,\n currentSize: number,\n delta: number,\n track: GridTrack,\n) => {\n const key = createTrackKey(direction, index);\n return (prev: Record<string, number>): Record<string, number> => {\n const newSize = calculateNewTrackSize(currentSize, delta, track);\n return { ...prev, [key]: newSize };\n };\n};\n\n/**\n * Computes the valid row span for a column boundary.\n * Returns the contiguous range of rows where the adjacent areas differ.\n */\nconst computeColumnBoundarySpan = (\n areas: string[][],\n boundaryIndex: number,\n): { start: number; end: number } => {\n const rowCount = areas.length;\n\n // Find rows where left and right areas differ at this boundary\n const validRows: number[] = [];\n for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n const row = areas[rowIndex];\n const leftArea = row[boundaryIndex];\n const rightArea = row[boundaryIndex + 1];\n if (leftArea !== rightArea) {\n validRows.push(rowIndex);\n }\n }\n\n if (validRows.length === 0) {\n // Fallback: full span if no valid rows found (shouldn't happen for resizable columns)\n return { start: 1, end: rowCount + 1 };\n }\n\n // Convert to 1-indexed grid lines\n const minRow = Math.min(...validRows);\n const maxRow = Math.max(...validRows);\n return { start: minRow + 1, end: maxRow + 2 };\n};\n\n/**\n * Computes the valid column span for a row boundary.\n * Returns the contiguous range of columns where the adjacent areas differ.\n */\nconst computeRowBoundarySpan = (\n areas: string[][],\n boundaryIndex: number,\n): { start: number; end: number } => {\n const topRow = areas[boundaryIndex];\n const bottomRow = areas[boundaryIndex + 1];\n const colCount = topRow?.length ?? 0;\n\n // Find columns where top and bottom areas differ at this boundary\n const validCols: number[] = [];\n for (let colIndex = 0; colIndex < colCount; colIndex++) {\n const topArea = topRow?.[colIndex];\n const bottomArea = bottomRow?.[colIndex];\n if (topArea !== bottomArea) {\n validCols.push(colIndex);\n }\n }\n\n if (validCols.length === 0) {\n // Fallback: full span if no valid columns found\n return { start: 1, end: colCount + 1 };\n }\n\n // Convert to 1-indexed grid lines\n const minCol = Math.min(...validCols);\n const maxCol = Math.max(...validCols);\n return { start: minCol + 1, end: maxCol + 2 };\n};\n\nconst computeColumnResizeHandles = (\n tracks: GridTrack[],\n areas: string[][],\n): TrackHandleConfig[] => {\n if (tracks.length === 0) {\n return [];\n }\n\n const rowCount = areas.length;\n\n if (tracks.length === 1) {\n const onlyTrack = tracks[0];\n if (onlyTrack?.resizable) {\n const fullSpan = { start: 1, end: rowCount + 1 };\n return [{ trackIndex: 0, align: \"end\", span: fullSpan }];\n }\n return [];\n }\n\n const handles: TrackHandleConfig[] = [];\n\n const boundaryIndexes = Array.from({ length: tracks.length - 1 }, (_, index) => index);\n boundaryIndexes.forEach((boundaryIndex) => {\n const leftTrack = tracks[boundaryIndex];\n const rightTrack = tracks[boundaryIndex + 1];\n\n if (rightTrack?.resizable) {\n const span = computeColumnBoundarySpan(areas, boundaryIndex);\n handles.push({ trackIndex: boundaryIndex + 1, align: \"start\", span });\n return;\n }\n\n if (leftTrack?.resizable) {\n const span = computeColumnBoundarySpan(areas, boundaryIndex);\n handles.push({ trackIndex: boundaryIndex, align: \"end\", span });\n }\n });\n\n return handles;\n};\n\nconst computeRowResizeHandles = (\n tracks: GridTrack[],\n areas: string[][],\n): TrackHandleConfig[] => {\n if (tracks.length === 0) {\n return [];\n }\n\n const colCount = areas[0]?.length ?? 0;\n\n if (tracks.length === 1) {\n const onlyTrack = tracks[0];\n if (onlyTrack?.resizable) {\n const fullSpan = { start: 1, end: colCount + 1 };\n return [{ trackIndex: 0, align: \"end\", span: fullSpan }];\n }\n return [];\n }\n\n const handles: TrackHandleConfig[] = [];\n\n const boundaryIndexes = Array.from({ length: tracks.length - 1 }, (_, index) => index);\n boundaryIndexes.forEach((boundaryIndex) => {\n const topTrack = tracks[boundaryIndex];\n const bottomTrack = tracks[boundaryIndex + 1];\n\n if (bottomTrack?.resizable) {\n const span = computeRowBoundarySpan(areas, boundaryIndex);\n handles.push({ trackIndex: boundaryIndex + 1, align: \"start\", span });\n return;\n }\n\n if (topTrack?.resizable) {\n const span = computeRowBoundarySpan(areas, boundaryIndex);\n handles.push({ trackIndex: boundaryIndex, align: \"end\", span });\n }\n });\n\n return handles;\n};\n\nconst parseGap = (gapValue?: string): ParsedGap => {\n if (!gapValue) {\n return { rowGap: 0, columnGap: 0 };\n }\n\n const tokens = gapValue\n .split(/\\s+/)\n .map((token) => token.trim())\n .filter(Boolean);\n\n const parseToken = (token: string): number => {\n const match = token.match(/^(-?\\d+(?:\\.\\d+)?)px$/);\n if (!match) {\n return 0;\n }\n return Number.parseFloat(match[1]);\n };\n\n if (tokens.length === 1) {\n const parsed = parseToken(tokens[0]);\n return { rowGap: parsed, columnGap: parsed };\n }\n\n return {\n rowGap: parseToken(tokens[0]),\n columnGap: parseToken(tokens[1]),\n };\n};\n\nconst getGapStyle = (gap?: string): React.CSSProperties => {\n return gap !== undefined ? { gap } : {};\n};\n\nconst resolveCurrentTrackSize = (\n trackSizes: Record<string, number>,\n track: GridTrack,\n direction: TrackDirection,\n trackIndex: number,\n): number => {\n const key = createTrackKey(direction, trackIndex);\n const storedSize = trackSizes[key];\n\n if (storedSize !== undefined) {\n return storedSize;\n }\n\n if (track.size.endsWith(\"px\")) {\n return Number.parseInt(track.size, 10);\n }\n\n return 300;\n};\n\nexport const useGridTracks = (\n config: PanelLayoutConfig,\n styleProp?: React.CSSProperties,\n): {\n columnHandles: TrackHandleConfig[];\n rowHandles: TrackHandleConfig[];\n gapSizes: ParsedGap;\n gridStyle: React.CSSProperties;\n handleResize: (direction: TrackDirection, trackIndex: number, delta: number) => void;\n} => {\n const [trackSizes, setTrackSizes] = React.useState<Record<string, number>>(() => ({\n ...extractInitialTrackSizes(config.columns, \"col\"),\n ...extractInitialTrackSizes(config.rows, \"row\"),\n }));\n\n useIsomorphicLayoutEffect(() => {\n const nextSizes = {\n ...extractInitialTrackSizes(config.columns, \"col\"),\n ...extractInitialTrackSizes(config.rows, \"row\"),\n };\n\n setTrackSizes((prev) => {\n const allKeys = new Set([...Object.keys(prev), ...Object.keys(nextSizes)]);\n const hasChanges = Array.from(allKeys).some((key) => {\n return prev[key] !== nextSizes[key];\n });\n\n return hasChanges ? nextSizes : prev;\n });\n }, [config.columns, config.rows]);\n\n const areasString = React.useMemo(() => {\n return config.areas.map((row) => `\"${row.join(\" \")}\"`).join(\" \");\n }, [config.areas]);\n\n const gapSizes = React.useMemo(() => parseGap(config.gap), [config.gap]);\n const columnHandles = React.useMemo(\n () => computeColumnResizeHandles(config.columns, config.areas),\n [config.columns, config.areas],\n );\n const rowHandles = React.useMemo(\n () => computeRowResizeHandles(config.rows, config.areas),\n [config.rows, config.areas],\n );\n\n const gridStyle = React.useMemo((): React.CSSProperties => {\n return {\n ...config.style,\n ...styleProp,\n gridTemplateAreas: areasString,\n gridTemplateRows: buildTrackTemplateString(config.rows, trackSizes, \"row\"),\n gridTemplateColumns: buildTrackTemplateString(config.columns, trackSizes, \"col\"),\n ...getGapStyle(config.gap),\n };\n }, [areasString, config.columns, config.gap, config.rows, config.style, styleProp, trackSizes]);\n\n const handleResize = React.useCallback(\n (direction: TrackDirection, trackIndex: number, delta: number) => {\n const tracks = direction === \"row\" ? config.rows : config.columns;\n const track = tracks[trackIndex];\n if (!track || !track.resizable) {\n return;\n }\n\n const currentSize = resolveCurrentTrackSize(trackSizes, track, direction, trackIndex);\n setTrackSizes(createTrackSizeUpdater(direction, trackIndex, currentSize, delta, track));\n },\n [config.columns, config.rows, trackSizes],\n );\n\n return {\n columnHandles,\n rowHandles,\n gapSizes,\n gridStyle,\n handleResize,\n };\n};\n","/**\n * @file Primitive math helpers shared across modules.\n */\n\nexport const clampNumber = (\n value: number,\n min: number = Number.NEGATIVE_INFINITY,\n max: number = Number.POSITIVE_INFINITY,\n): number => {\n return Math.min(Math.max(value, min), max);\n};\n\nexport const toFiniteNumberOr = (value: number | undefined, fallback: number): number => {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n return fallback;\n }\n return value;\n};\n","/**\n * @file Drag and resize interaction management for floating grid layers.\n */\nimport * as React from \"react\";\nimport { useDocumentPointerEvents } from \"../../hooks/useDocumentPointerEvents\";\nimport { useEffectEvent } from \"../../hooks/useEffectEvent\";\nimport { useIsomorphicLayoutEffect } from \"../../hooks/useIsomorphicLayoutEffect\";\nimport type { LayerDefinition, WindowPosition, WindowSize } from \"../../types\";\nimport { clampNumber } from \"../../utils/math\";\n// Inline style computation previously in layerStyles to keep hook-local logic\nimport type { CSSProperties } from \"react\";\nimport type { GridLayerHandleProps, GridLayoutContextValue, ResizeHandleConfig } from \"./GridLayoutContext\";\n// UI components should not be imported here; expose pointer handlers instead.\n\ntype LayerSize = {\n width: number;\n height: number;\n};\n\ntype DragState = {\n pointerStartX: number;\n pointerStartY: number;\n initialTranslationX: number;\n initialTranslationY: number;\n baseLeft: number;\n baseTop: number;\n layerId: string;\n pointerId: number;\n target: HTMLElement;\n};\n\ntype HorizontalEdge = \"left\" | \"right\";\ntype VerticalEdge = \"top\" | \"bottom\";\n\ntype ResizeState = {\n layerId: string;\n pointerId: number;\n horizontalEdge?: HorizontalEdge;\n verticalEdge?: VerticalEdge;\n startX: number;\n startY: number;\n startWidth: number;\n startHeight: number;\n startPosition: { x: number; y: number };\n baseLeft: number;\n baseTop: number;\n minWidth?: number;\n maxWidth?: number;\n minHeight?: number;\n maxHeight?: number;\n target: HTMLElement;\n};\n\n// ------------------------------------------------------------------------------------------\n// Inline layer style computation (was layerStyles.ts)\n// ------------------------------------------------------------------------------------------\nconst resolvePositionMode = (layer: LayerDefinition): LayerDefinition[\"positionMode\"] => {\n if (layer.positionMode) {\n return layer.positionMode;\n }\n if (layer.floating) {\n const floatingMode = layer.floating.mode ?? \"embedded\";\n return floatingMode === \"embedded\" ? \"absolute\" : \"relative\";\n }\n return \"grid\";\n};\n\nconst getPositionModeStyle = (mode: LayerDefinition[\"positionMode\"]): CSSProperties => {\n return { position: mode === \"grid\" ? \"relative\" : mode };\n};\n\nconst getGridAreaStyle = (layer: LayerDefinition, mode: LayerDefinition[\"positionMode\"]): CSSProperties => {\n if (mode !== \"grid\") {\n return {};\n }\n return {\n gridArea: layer.gridArea,\n gridRow: layer.gridRow,\n gridColumn: layer.gridColumn,\n };\n};\n\nconst getAbsolutePositionStyle = (position?: WindowPosition | LayerDefinition[\"position\"]): CSSProperties => {\n if (!position) {\n return {};\n }\n\n return {\n top: position.top,\n right: position.right,\n bottom: position.bottom,\n left: position.left,\n };\n};\n\nconst getZIndexStyle = (zIndex?: number): CSSProperties => {\n return zIndex !== undefined ? { zIndex } : {};\n};\n\nconst getDimensionsStyle = (width?: number | string, height?: number | string): CSSProperties => {\n return {\n width,\n height,\n };\n};\n\nconst getPointerEventsStyle = (layer: LayerDefinition, mode: LayerDefinition[\"positionMode\"]): CSSProperties => {\n if (layer.pointerEvents !== undefined) {\n if (typeof layer.pointerEvents === \"boolean\") {\n return { pointerEvents: layer.pointerEvents ? \"auto\" : \"none\" };\n }\n return { pointerEvents: layer.pointerEvents };\n }\n\n if (mode === \"absolute\" || mode === \"fixed\") {\n return { pointerEvents: \"auto\" };\n }\n\n return {};\n};\n\nconst resolveEffectivePosition = (\n layer: LayerDefinition,\n): WindowPosition | LayerDefinition[\"position\"] | undefined => {\n return layer.position;\n};\n\nconst resolveEffectiveSize = (\n layer: LayerDefinition,\n): {\n width?: number | string;\n height?: number | string;\n} => {\n return {\n width: layer.width,\n height: layer.height,\n };\n};\n\nconst resolveEffectiveZIndex = (layer: LayerDefinition): number | undefined => {\n return layer.zIndex;\n};\n\nconst buildLayerStyleObject = (layer: LayerDefinition): CSSProperties => {\n const resolvedMode = resolvePositionMode(layer);\n const effectivePosition = resolveEffectivePosition(layer);\n const effectiveSize = resolveEffectiveSize(layer);\n const effectiveZIndex = resolveEffectiveZIndex(layer);\n\n return {\n ...layer.style,\n ...getPositionModeStyle(resolvedMode),\n ...getGridAreaStyle(layer, resolvedMode),\n ...getAbsolutePositionStyle(effectivePosition),\n ...getZIndexStyle(effectiveZIndex),\n ...getDimensionsStyle(effectiveSize.width, effectiveSize.height),\n ...getPointerEventsStyle(layer, resolvedMode),\n };\n};\n\nconst resolveFloatingMode = (layer: LayerDefinition): \"embedded\" | \"popup\" | null => {\n const floating = layer.floating;\n if (!floating) {\n return null;\n }\n const mode = floating.mode ?? \"embedded\";\n return mode;\n};\n\nconst getEmbeddedFloatingConfig = (layer: LayerDefinition) => {\n const mode = resolveFloatingMode(layer);\n if (mode !== \"embedded\") {\n return null;\n }\n return layer.floating ?? null;\n};\n\nconst isInteractiveElement = (target: EventTarget | null): target is HTMLElement => {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n return [\"INPUT\", \"TEXTAREA\", \"SELECT\", \"BUTTON\"].includes(target.tagName);\n};\n\n\nconst clampDimension = (value: number, min?: number, max?: number): number => {\n const resolvedMin = min ?? Number.NEGATIVE_INFINITY;\n const resolvedMax = max ?? Number.POSITIVE_INFINITY;\n return clampNumber(value, resolvedMin, resolvedMax);\n};\n\nconst ensureNumericOffset = (value: number | string | undefined, key: keyof WindowPosition, layerId: string): number => {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n throw new Error(\n `Floating layer \"${layerId}\" must provide a numeric \"${key}\" value when draggable mode is enabled.`,\n );\n};\n\nconst resolveDragAnchor = (layer: LayerDefinition): { left: number; top: number } => {\n const floating = getEmbeddedFloatingConfig(layer);\n if (!floating) {\n throw new Error(`Floating layer \"${layer.id}\" is missing floating configuration required for dragging.`);\n }\n const position = layer.position;\n if (!position) {\n throw new Error(`Floating layer \"${layer.id}\" must define position with left and top values.`);\n }\n return {\n left: ensureNumericOffset(position.left, \"left\", layer.id),\n top: ensureNumericOffset(position.top, \"top\", layer.id),\n };\n};\n\nconst resolveFloatingConstraints = (\n layer: LayerDefinition,\n): { minWidth?: number; maxWidth?: number; minHeight?: number; maxHeight?: number } => {\n const floating = getEmbeddedFloatingConfig(layer);\n if (!floating) {\n return {};\n }\n return floating.constraints ?? {};\n};\n\nconst resolveHorizontalSizeCandidate = (\n edge: HorizontalEdge | undefined,\n startSize: number,\n delta: number,\n): number => {\n if (!edge) {\n return startSize;\n }\n return edge === \"left\" ? startSize - delta : startSize + delta;\n};\n\nconst resolveVerticalSizeCandidate = (edge: VerticalEdge | undefined, startSize: number, delta: number): number => {\n if (!edge) {\n return startSize;\n }\n return edge === \"top\" ? startSize - delta : startSize + delta;\n};\n\nconst resolveHorizontalPosition = (\n edge: HorizontalEdge | undefined,\n startPosition: number,\n delta: number,\n): number => {\n if (!edge || edge === \"right\") {\n return startPosition;\n }\n return startPosition + delta;\n};\n\nconst resolveVerticalPosition = (\n edge: VerticalEdge | undefined,\n startPosition: number,\n delta: number,\n): number => {\n if (!edge || edge === \"bottom\") {\n return startPosition;\n }\n return startPosition + delta;\n};\n\nconst findLayerElementById = (element: HTMLElement | null, layerId: string): HTMLElement | null => {\n if (!element) {\n return null;\n }\n if (element.dataset.layerId === layerId) {\n return element;\n }\n return findLayerElementById(element.parentElement, layerId);\n};\n\nconst findAncestor = (\n element: HTMLElement | null,\n predicate: (node: HTMLElement) => boolean,\n stopPredicate?: (node: HTMLElement) => boolean,\n): HTMLElement | null => {\n if (!element) {\n return null;\n }\n if (stopPredicate?.(element)) {\n return null;\n }\n if (predicate(element)) {\n return element;\n }\n return findAncestor(element.parentElement, predicate, stopPredicate);\n};\n\nconst findDragHandleElement = (target: EventTarget | null): HTMLElement | null => {\n if (!(target instanceof HTMLElement)) {\n return null;\n }\n\n return findAncestor(\n target,\n (node) => node.dataset.dragHandle === \"true\",\n (node) => node.dataset.dragIgnore === \"true\",\n );\n};\n\nconst isResizeControl = (target: EventTarget | null): boolean => {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n\n return (\n findAncestor(\n target,\n (node) => node.dataset.resizeCorner !== undefined || node.dataset.resizeEdge !== undefined,\n ) !== null\n );\n};\n\nconst shouldRenderFloatingResize = (layer: LayerDefinition): boolean => {\n const floating = getEmbeddedFloatingConfig(layer);\n if (!floating) {\n return false;\n }\n return floating.resizable === true;\n};\n\nconst getLayerSizeFromDefinition = (layer: LayerDefinition): LayerSize | null => {\n const floating = getEmbeddedFloatingConfig(layer);\n if (!floating) {\n return null;\n }\n const size = getNumericLayerSize(layer);\n if (!size) {\n throw new Error(`Floating layer \"${layer.id}\" must define width and height when resizable or draggable.`);\n }\n return {\n width: size.width,\n height: size.height,\n };\n};\n\n// No-op placeholder: rendering is handled in component layer\n\nconst computeResizableLayerSizes = (\n layers: LayerDefinition[],\n previousSizes: Record<string, LayerSize>,\n activeResizeLayerId: string | null,\n): { sizes: Record<string, LayerSize>; changed: boolean } => {\n const nextSizes = layers\n .filter(shouldRenderFloatingResize)\n .reduce<Record<string, LayerSize>>((accumulator, layer) => {\n if (activeResizeLayerId === layer.id) {\n const existing = previousSizes[layer.id];\n if (existing) {\n accumulator[layer.id] = existing;\n return accumulator;\n }\n }\n\n const parsedSize = getLayerSizeFromDefinition(layer);\n if (!parsedSize) {\n return accumulator;\n }\n\n accumulator[layer.id] = parsedSize;\n return accumulator;\n }, {});\n\n const previousKeys = Object.keys(previousSizes);\n const nextKeys = Object.keys(nextSizes);\n\n const keysChangedByLength = previousKeys.length !== nextKeys.length;\n const keysChangedByMissing = previousKeys.some((key) => {\n return !Object.prototype.hasOwnProperty.call(nextSizes, key);\n });\n const keysChanged = keysChangedByLength ? true : keysChangedByMissing;\n\n const sizeChanged = nextKeys.some((key) => {\n const previous = previousSizes[key];\n const next = nextSizes[key];\n if (!previous || !next) {\n return true;\n }\n return previous.width !== next.width || previous.height !== next.height;\n });\n\n const changed = keysChanged ? true : sizeChanged;\n\n return {\n sizes: nextSizes,\n changed,\n };\n};\n\ntype UseLayerInteractionsArgs = {\n layers: LayerDefinition[];\n layerById: Map<string, LayerDefinition>;\n};\n\nexport const useLayerInteractions = ({\n layers,\n layerById,\n}: UseLayerInteractionsArgs): {\n providerValue: GridLayoutContextValue;\n draggingLayerId: string | null;\n resizingLayerId: string | null;\n} => {\n const [draggingLayerId, setDraggingLayerId] = React.useState<string | null>(null);\n const [resizingLayerId, setResizingLayerId] = React.useState<string | null>(null);\n\n const [layerPositions, setLayerPositions] = React.useState<Record<string, { x: number; y: number }>>({});\n const [layerSizes, setLayerSizes] = React.useState<Record<string, LayerSize>>({});\n\n const dragStartRef = React.useRef<DragState | null>(null);\n const resizeStartRef = React.useRef<ResizeState | null>(null);\n\n const notifyFloatingMove = useEffectEvent((layerId: string, position: WindowPosition) => {\n const layer = layerById.get(layerId);\n const floating = layer?.floating;\n floating?.onMove?.(position);\n });\n\n const notifyFloatingResize = useEffectEvent((layerId: string, size: WindowSize) => {\n const layer = layerById.get(layerId);\n const floating = layer?.floating;\n floating?.onResize?.(size);\n });\n\n useIsomorphicLayoutEffect(() => {\n const { sizes, changed } = computeResizableLayerSizes(layers, layerSizes, resizingLayerId);\n if (!changed) {\n return;\n }\n setLayerSizes(sizes);\n }, [layers, resizingLayerId]);\n\n const beginLayerDrag = React.useCallback(\n (layerId: string, layer: LayerDefinition, target: HTMLElement, event: React.PointerEvent) => {\n const anchor = resolveDragAnchor(layer);\n const translation = layerPositions[layerId] ?? { x: 0, y: 0 };\n const dragState: DragState = {\n pointerStartX: event.clientX,\n pointerStartY: event.clientY,\n initialTranslationX: translation.x,\n initialTranslationY: translation.y,\n baseLeft: anchor.left,\n baseTop: anchor.top,\n layerId,\n pointerId: event.pointerId,\n target: target as HTMLElement,\n };\n\n if (dragState.target.setPointerCapture) {\n try {\n dragState.target.setPointerCapture(dragState.pointerId);\n } catch {\n // Ignore pointer capture errors\n }\n }\n\n dragStartRef.current = dragState;\n setDraggingLayerId(layerId);\n },\n [layerPositions],\n );\n\n const handleLayerPointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n const target = event.target;\n const dragHandle = findDragHandleElement(target);\n if (!dragHandle) {\n return;\n }\n\n const layerId = dragHandle.closest('[data-layer-id]')?.getAttribute(\"data-layer-id\");\n if (!layerId) {\n return;\n }\n const layer = layerById.get(layerId);\n if (!layer) {\n return;\n }\n const floating = getEmbeddedFloatingConfig(layer);\n if (!floating || floating.draggable !== true) {\n return;\n }\n\n if (isInteractiveElement(event.target)) {\n return;\n }\n\n if (isResizeControl(event.target)) {\n return;\n }\n\n if (dragHandle) {\n const layerElement = findLayerElementById(dragHandle as HTMLElement, layerId);\n if (!layerElement) {\n return;\n }\n beginLayerDrag(layerId, layer, layerElement, event);\n return;\n }\n },\n [beginLayerDrag, layerById],\n );\n\n const handleDragHandlePointerDown = React.useCallback(\n (layerId: string, event: React.PointerEvent<HTMLElement>) => {\n const layer = layerById.get(layerId);\n const floating = layer ? getEmbeddedFloatingConfig(layer) : null;\n if (!layer || !floating || floating.draggable !== true) {\n return;\n }\n\n if (isInteractiveElement(event.target)) {\n return;\n }\n\n if (isResizeControl(event.target)) {\n return;\n }\n\n const layerElement = findLayerElementById(event.currentTarget as HTMLElement, layerId);\n if (!layerElement) {\n return;\n }\n\n beginLayerDrag(layerId, layer, layerElement, event);\n },\n [beginLayerDrag, layerById],\n );\n\n const handleResizePointerDown = React.useCallback(\n (layerId: string, config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => {\n const layer = layerById.get(layerId);\n if (!layer || !shouldRenderFloatingResize(layer)) {\n return;\n }\n\n const sizeEntry = layerSizes[layerId] ?? getLayerSizeFromDefinition(layer);\n if (!sizeEntry) {\n return;\n }\n\n const baseAnchor = resolveDragAnchor(layer);\n const constraints = resolveFloatingConstraints(layer);\n\n const initialPosition = layerPositions[layerId] ?? { x: 0, y: 0 };\n\n event.stopPropagation();\n event.preventDefault();\n\n if (event.currentTarget.setPointerCapture) {\n try {\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {\n // Pointer capture may be unsupported; ignore gracefully.\n }\n }\n\n resizeStartRef.current = {\n layerId,\n pointerId: event.pointerId,\n horizontalEdge: config.horizontal,\n verticalEdge: config.vertical,\n startX: event.clientX,\n startY: event.clientY,\n startWidth: sizeEntry.width,\n startHeight: sizeEntry.height,\n startPosition: initialPosition,\n baseLeft: baseAnchor.left,\n baseTop: baseAnchor.top,\n minWidth: constraints.minWidth,\n maxWidth: constraints.maxWidth,\n minHeight: constraints.minHeight,\n maxHeight: constraints.maxHeight,\n target: event.currentTarget,\n };\n\n setResizingLayerId(layerId);\n },\n [layerById, layerPositions, layerSizes],\n );\n\n const handleDragPointerMove = React.useCallback(\n (event: PointerEvent) => {\n const dragStart = dragStartRef.current;\n if (!dragStart) {\n return;\n }\n\n const deltaX = event.clientX - dragStart.pointerStartX;\n const deltaY = event.clientY - dragStart.pointerStartY;\n const newPos = {\n x: dragStart.initialTranslationX + deltaX,\n y: dragStart.initialTranslationY + deltaY,\n };\n\n setLayerPositions((prev) => ({ ...prev, [dragStart.layerId]: newPos }));\n notifyFloatingMove(dragStart.layerId, {\n left: dragStart.baseLeft + newPos.x,\n top: dragStart.baseTop + newPos.y,\n });\n },\n [notifyFloatingMove],\n );\n\n const handleResizePointerMove = React.useCallback(\n (event: PointerEvent) => {\n const resizeStart = resizeStartRef.current;\n if (!resizeStart || resizeStart.pointerId !== event.pointerId) {\n return;\n }\n\n const layer = layerById.get(resizeStart.layerId);\n if (!layer) {\n return;\n }\n\n const deltaX = event.clientX - resizeStart.startX;\n const deltaY = event.clientY - resizeStart.startY;\n\n const widthCandidate = resolveHorizontalSizeCandidate(resizeStart.horizontalEdge, resizeStart.startWidth, deltaX);\n const heightCandidate = resolveVerticalSizeCandidate(resizeStart.verticalEdge, resizeStart.startHeight, deltaY);\n\n const nextWidth = clampDimension(widthCandidate, resizeStart.minWidth, resizeStart.maxWidth);\n const nextHeight = clampDimension(heightCandidate, resizeStart.minHeight, resizeStart.maxHeight);\n\n const widthDelta = resizeStart.startWidth - nextWidth;\n const heightDelta = resizeStart.startHeight - nextHeight;\n\n const nextPositionX = resolveHorizontalPosition(\n resizeStart.horizontalEdge,\n resizeStart.startPosition.x,\n widthDelta,\n );\n const nextPositionY = resolveVerticalPosition(resizeStart.verticalEdge, resizeStart.startPosition.y, heightDelta);\n\n const currentSize = layerSizes[resizeStart.layerId];\n const nextSize: WindowSize = { width: nextWidth, height: nextHeight };\n const sizeChanged =\n !currentSize || currentSize.width !== nextWidth || currentSize.height !== nextHeight;\n if (sizeChanged) {\n setLayerSizes((prev) => ({\n ...prev,\n [resizeStart.layerId]: nextSize,\n }));\n notifyFloatingResize(resizeStart.layerId, nextSize);\n }\n\n const currentPosition = layerPositions[resizeStart.layerId] ?? { x: 0, y: 0 };\n const nextPosition = { x: nextPositionX, y: nextPositionY };\n const positionChanged =\n currentPosition.x !== nextPosition.x || currentPosition.y !== nextPosition.y;\n if (positionChanged) {\n setLayerPositions((prev) => ({\n ...prev,\n [resizeStart.layerId]: nextPosition,\n }));\n notifyFloatingMove(resizeStart.layerId, {\n left: resizeStart.baseLeft + nextPosition.x,\n top: resizeStart.baseTop + nextPosition.y,\n });\n }\n },\n [layerById, layerPositions, layerSizes, notifyFloatingMove, notifyFloatingResize],\n );\n\n const finishDrag = React.useCallback((event: PointerEvent) => {\n const dragStart = dragStartRef.current;\n if (dragStart) {\n if (dragStart.pointerId === event.pointerId && dragStart.target.releasePointerCapture) {\n try {\n dragStart.target.releasePointerCapture(dragStart.pointerId);\n } catch {\n // Ignore release errors (e.g., already released).\n }\n }\n dragStartRef.current = null;\n }\n setDraggingLayerId(null);\n }, []);\n\n const finishResize = React.useCallback((event: PointerEvent) => {\n const resizeStart = resizeStartRef.current;\n if (resizeStart) {\n if (resizeStart.pointerId === event.pointerId && resizeStart.target.releasePointerCapture) {\n try {\n resizeStart.target.releasePointerCapture(resizeStart.pointerId);\n } catch {\n // Ignore pointer capture release errors.\n }\n }\n resizeStartRef.current = null;\n }\n setResizingLayerId(null);\n }, []);\n\n useDocumentPointerEvents(draggingLayerId !== null, {\n onMove: handleDragPointerMove,\n onUp: finishDrag,\n onCancel: finishDrag,\n });\n\n useDocumentPointerEvents(resizingLayerId !== null, {\n onMove: handleResizePointerMove,\n onUp: finishResize,\n onCancel: finishResize,\n });\n\n const buildDraggableLayerStyle = React.useCallback(\n (layer: LayerDefinition): React.CSSProperties => {\n const baseStyle = buildLayerStyleObject(layer);\n\n const floating = getEmbeddedFloatingConfig(layer);\n if (!floating || floating.draggable !== true) {\n return baseStyle;\n }\n\n const position = layerPositions[layer.id];\n const isDragging = draggingLayerId === layer.id;\n const isResizing = resizingLayerId === layer.id;\n const transformStyle = position ? { transform: `translate(${position.x}px, ${position.y}px)` } : {};\n const storedSize = layerSizes[layer.id];\n const fallbackSize = shouldRenderFloatingResize(layer) ? getLayerSizeFromDefinition(layer) : null;\n const sizeRecord = storedSize ?? fallbackSize;\n const sizeStyle = sizeRecord ? { width: `${sizeRecord.width}px`, height: `${sizeRecord.height}px` } : {};\n const cursorStyle = isDragging || isResizing ? { cursor: \"grabbing\" } : {};\n\n return {\n ...baseStyle,\n ...sizeStyle,\n ...transformStyle,\n ...cursorStyle,\n };\n },\n [draggingLayerId, layerPositions, layerSizes, resizingLayerId],\n );\n\n const getResizeHandleState = React.useCallback(\n (layer: LayerDefinition): { isResizable: boolean; onPointerDown?: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => void } => {\n const canResize = shouldRenderFloatingResize(layer);\n if (!canResize) {\n return { isResizable: false };\n }\n\n const storedLayerSize = layerSizes[layer.id];\n const fallbackLayerSize = getLayerSizeFromDefinition(layer);\n const sizeForHandle = storedLayerSize ?? fallbackLayerSize;\n const show = sizeForHandle !== null;\n if (!show) {\n return { isResizable: false };\n }\n\n const onPointerDown = (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => {\n handleResizePointerDown(layer.id, config, event);\n };\n\n return { isResizable: true, onPointerDown };\n },\n [handleResizePointerDown, layerSizes],\n );\n\n const getLayerRenderState = React.useCallback(\n (layer: LayerDefinition) => {\n const { isResizable, onPointerDown } = getResizeHandleState(layer);\n const style = buildDraggableLayerStyle(layer);\n const isResizing = resizingLayerId === layer.id;\n\n return {\n style,\n isResizable,\n isResizing,\n onResizeHandlePointerDown: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => {\n if (onPointerDown) {\n onPointerDown(config, event);\n }\n },\n };\n },\n [buildDraggableLayerStyle, getResizeHandleState, resizingLayerId],\n );\n\n const getLayerHandleProps = React.useCallback(\n (layerId: string): GridLayerHandleProps => {\n return {\n \"data-drag-handle\": \"true\",\n role: \"button\",\n \"aria-roledescription\": \"Drag handle\",\n \"aria-label\": \"Drag layer\",\n onPointerDown: (event: React.PointerEvent<HTMLElement>) => {\n handleDragHandlePointerDown(layerId, event);\n },\n };\n },\n [handleDragHandlePointerDown],\n );\n\n const providerValue = React.useMemo<GridLayoutContextValue>(\n () => ({\n handleLayerPointerDown,\n getLayerRenderState,\n getLayerHandleProps,\n }),\n [getLayerHandleProps, getLayerRenderState, handleLayerPointerDown],\n );\n\n return {\n providerValue,\n draggingLayerId,\n resizingLayerId,\n };\n};\n\n/* Debug note: Reviewed GridLayout.module.css and LayerInstanceContext to keep drag handle integration consistent. */\nconst getNumericLayerSize = (layer: LayerDefinition): LayerSize | undefined => {\n if (typeof layer.width === \"number\" && typeof layer.height === \"number\") {\n return { width: layer.width, height: layer.height };\n }\n return undefined;\n};\n","/**\n * @file Top-level grid layout component that consumes PanelSystemContext core.\n */\nimport * as React from \"react\";\nimport { useIntersectionObserver } from \"../../hooks/useIntersectionObserver\";\nimport type { LayerDefinition, PanelLayoutConfig } from \"../../types\";\nimport { DrawerLayers } from \"../window/DrawerLayers\";\nimport { GridLayerList } from \"./GridLayerList\";\nimport { GridTrackResizeHandle } from \"./GridTrackResizeHandle\";\nimport { PanelSystemProvider, usePanelSystem } from \"../../PanelSystemContext\";\nimport { useGridPlacements } from \"../../modules/grid/useGridPlacements\";\nimport { useGridTracks } from \"../../modules/grid/useGridTracks\";\nimport { useLayerInteractions } from \"../../modules/grid/useLayerInteractions\";\nimport { GridLayoutProvider } from \"../../modules/grid/GridLayoutContext\";\n\nconst gridLayoutBaseStyle: React.CSSProperties = {\n display: \"grid\",\n width: \"100%\",\n height: \"100%\",\n overflow: \"hidden\",\n};\n\nconst gridLayoutDraggingStyle: React.CSSProperties = {\n touchAction: \"none\",\n WebkitTouchCallout: \"none\",\n WebkitUserSelect: \"none\",\n userSelect: \"none\",\n};\n\nexport type GridLayoutProps = {\n config: PanelLayoutConfig;\n layers: LayerDefinition[];\n style?: React.CSSProperties;\n};\n\nexport const GridLayout: React.FC<GridLayoutProps> = ({ config, layers, style: styleProp }) => {\n const gridRef = React.useRef<HTMLDivElement | null>(null);\n const { isIntersecting } = useIntersectionObserver(gridRef, { threshold: 0 });\n\n return (\n <PanelSystemProvider config={config} layers={layers} style={styleProp}>\n <GridLayoutInner gridRef={gridRef} isIntersecting={isIntersecting} />\n </PanelSystemProvider>\n );\n};\n\nconst GridLayoutInner: React.FC<{\n gridRef: React.RefObject<HTMLDivElement | null>;\n isIntersecting: boolean;\n}> = ({ gridRef, isIntersecting }) => {\n const { config, style, layers } = usePanelSystem();\n const { normalizedLayers, visibleLayers, regularLayers, layerById } = useGridPlacements(config, layers.defs);\n const { columnHandles, rowHandles, gapSizes, gridStyle, handleResize } = useGridTracks(config, style);\n const { providerValue, draggingLayerId, resizingLayerId } = useLayerInteractions({\n layers: normalizedLayers,\n layerById,\n });\n\n const isDraggingOrResizing = draggingLayerId ? true : Boolean(resizingLayerId);\n const combinedStyle = React.useMemo(() => {\n return {\n ...gridLayoutBaseStyle,\n ...gridStyle,\n ...(isDraggingOrResizing ? gridLayoutDraggingStyle : {}),\n };\n }, [gridStyle, isDraggingOrResizing]);\n\n return (\n <>\n <div\n ref={gridRef}\n style={combinedStyle}\n data-dragging={Boolean(draggingLayerId)}\n data-resizing={Boolean(resizingLayerId)}\n data-visible={isIntersecting}\n >\n <GridLayoutProvider value={providerValue}>\n <GridLayerList layers={regularLayers} />\n </GridLayoutProvider>\n\n {columnHandles.map(({ trackIndex, align, span }) => (\n <GridTrackResizeHandle\n key={`col-${trackIndex}:${align}`}\n direction=\"col\"\n trackIndex={trackIndex}\n align={align}\n gap={gapSizes.columnGap}\n span={span}\n onResize={handleResize}\n />\n ))}\n\n {rowHandles.map(({ trackIndex, align, span }) => (\n <GridTrackResizeHandle\n key={`row-${trackIndex}:${align}`}\n direction=\"row\"\n trackIndex={trackIndex}\n align={align}\n gap={gapSizes.rowGap}\n span={span}\n onResize={handleResize}\n />\n ))}\n </div>\n\n <DrawerLayers layers={visibleLayers} />\n </>\n );\n};\n\n/* Debug note: Refactored to consume PanelSystemContext core for consistent separation. */\n"],"names":["createIdGenerator","map","ref","existing","nextId","getId","observerCache","getSharedObserver","options","observerKey","observer","#callbackMap","#intersectionObserver","entries","entry","callback","target","voidClientRect","useIntersectionObserver","threshold","rootMargin","root","intersection","setIntersection","React","drawerBackdropStyle","drawerBaseStyle","DRAWER_SURFACE_COLOR","DRAWER_SHADOW","drawerPlacementStyles","drawerHeaderStyle","DRAWER_HEADER_PADDING_Y","DRAWER_HEADER_PADDING_X","DRAWER_HEADER_GAP","DRAWER_BORDER_COLOR","drawerHeaderTitleStyle","drawerHeaderCloseButtonStyle","DRAWER_CLOSE_BUTTON_FONT_SIZE","drawerContentStyle","DRAWER_CONTENT_PADDING","DrawerBackdrop","style","dismissible","onClose","handleClick","combinedStyle","jsx","DrawerHeader","header","showCloseButton","renderTitle","renderCloseButton","jsxs","Drawer","id","config","isOpen","children","className","styleProp","zIndex","width","height","position","backdropStyle","placement","pos","drawerStyle","contentFinalStyle","renderHeader","Fragment","useEffectEvent","fn","args","currentFn","useDrawerState","layers","drawerStates","setDrawerStates","initial","layer","layerMap","notifyStateChange","layerId","newState","state","open","prev","close","DrawerLayers","drawer","drawerLayers","closeHandlers","handlers","GridLayoutContext","GridLayoutProvider","value","useGridLayoutContext","context","PanelSystemContext","usePanelSystem","ctx","PanelSystemProvider","layerById","LayerInstanceContext","LayerInstanceProvider","useLayerInstance","ensureNumericOffset","key","resolvePopupAnchor","numericFeature","booleanFeature","buildWindowFeatures","features","anchor","overrides","toolbar","menubar","location","status","resizable","scrollbars","applyBoundsToWindow","popupWindow","PopupLayerPortal","floating","containerRef","popupWindowRef","isMounted","setIsMounted","windowName","createdWindow","resolvePopupWindow","openedWindow","mountNode","handleBeforeUnload","createPortal","bounds","customFactory","resizeHandleBaseStyle","cornerHandleStyle","GRID_LAYER_CORNER_HIT_SIZE","edgeHandleStyle","cornerPositions","edgePositions","GRID_LAYER_EDGE_HIT_THICKNESS","RESIZE_HANDLE_CONFIGS","GridLayerResizeHandles","onPointerDown","baseStyle","positionStyle","datasetProps","event","GridLayerList","handleLayerPointerDown","getLayerRenderState","renderResizeHandles","requests","request","floatingMode","isResizable","isResizing","onResizeHandlePointerDown","gridPlacementStyle","resizeHandles","useDocumentPointerEvents","enabled","handleMoveEvent","handleUpEvent","handleCancelEvent","usePointerCapture","elementRef","pointerId","element","usePreventPointerDefaults","events","preventDefault","e","eventType","useDragPointerEvents","onMove","onUp","onCancel","capturePointer","preventDefaults","useResizeDrag","pointerIdRef","previousCoordinateRef","isDragging","setIsDragging","emitResize","delta","getCoordinate","handlePointerDown","handlePointerMove","coordinate","handlePointerUp","createWrapperComponent","Component","rest","forwardedRef","useElementComponentWrapper","component","baseResizeHandleStyle","RESIZE_HANDLE_Z_INDEX","sizeStylesByDirection","RESIZE_HANDLE_THICKNESS","backgroundByVisualState","COLOR_RESIZE_HANDLE_IDLE","COLOR_RESIZE_HANDLE_HOVER","COLOR_RESIZE_HANDLE_ACTIVE","ResizeHandle","direction","onResize","axis","isHovered","setIsHovered","handlePointerEnter","handlePointerLeave","Wrapper","visualState","resizeHandleWrapperBaseStyle","GridTrackResizeHandle","trackIndex","align","gap","span","resizeDirection","handleResize","placementStyle","wrapperStyle","offset","GRID_HANDLE_THICKNESS","computeGridPlacements","areas","boundsByArea","row","rowIndex","area","colIndex","nextBounds","initialBounds","placements","rowStart","rowEnd","colStart","colEnd","normalizeLayerForGrid","placementKey","needsGridArea","needsRow","needsColumn","useGridPlacements","normalizedLayers","visibleLayers","regularLayers","isBrowser","useIsomorphicLayoutEffect","createTrackKey","index","getTrackSize","track","trackSizes","currentSize","buildTrackTemplateString","tracks","extractInitialTrackSizes","acc","applyConstraints","size","minSize","maxSize","withMinConstraint","calculateNewTrackSize","newSize","createTrackSizeUpdater","computeColumnBoundarySpan","boundaryIndex","rowCount","validRows","leftArea","rightArea","minRow","maxRow","computeRowBoundarySpan","topRow","bottomRow","colCount","validCols","topArea","bottomArea","minCol","maxCol","computeColumnResizeHandles","handles","_","leftTrack","computeRowResizeHandles","topTrack","parseGap","gapValue","tokens","token","parseToken","match","parsed","getGapStyle","resolveCurrentTrackSize","storedSize","useGridTracks","setTrackSizes","nextSizes","allKeys","areasString","gapSizes","columnHandles","rowHandles","gridStyle","clampNumber","min","max","toFiniteNumberOr","fallback","resolvePositionMode","getPositionModeStyle","mode","getGridAreaStyle","getAbsolutePositionStyle","getZIndexStyle","getDimensionsStyle","getPointerEventsStyle","resolveEffectivePosition","resolveEffectiveSize","resolveEffectiveZIndex","buildLayerStyleObject","resolvedMode","effectivePosition","effectiveSize","effectiveZIndex","resolveFloatingMode","getEmbeddedFloatingConfig","isInteractiveElement","clampDimension","resolvedMin","resolvedMax","resolveDragAnchor","resolveFloatingConstraints","resolveHorizontalSizeCandidate","edge","startSize","resolveVerticalSizeCandidate","resolveHorizontalPosition","startPosition","resolveVerticalPosition","findLayerElementById","findAncestor","predicate","stopPredicate","findDragHandleElement","node","isResizeControl","shouldRenderFloatingResize","getLayerSizeFromDefinition","getNumericLayerSize","computeResizableLayerSizes","previousSizes","activeResizeLayerId","accumulator","parsedSize","previousKeys","nextKeys","keysChangedByLength","keysChangedByMissing","keysChanged","sizeChanged","previous","next","useLayerInteractions","draggingLayerId","setDraggingLayerId","resizingLayerId","setResizingLayerId","layerPositions","setLayerPositions","layerSizes","setLayerSizes","dragStartRef","resizeStartRef","notifyFloatingMove","notifyFloatingResize","sizes","changed","beginLayerDrag","translation","dragState","dragHandle","layerElement","handleDragHandlePointerDown","handleResizePointerDown","sizeEntry","baseAnchor","constraints","initialPosition","handleDragPointerMove","dragStart","deltaX","deltaY","newPos","handleResizePointerMove","resizeStart","widthCandidate","heightCandidate","nextWidth","nextHeight","widthDelta","heightDelta","nextPositionX","nextPositionY","nextSize","currentPosition","nextPosition","finishDrag","finishResize","buildDraggableLayerStyle","transformStyle","fallbackSize","sizeRecord","sizeStyle","getResizeHandleState","storedLayerSize","fallbackLayerSize","getLayerHandleProps","gridLayoutBaseStyle","gridLayoutDraggingStyle","GridLayout","gridRef","isIntersecting","GridLayoutInner","providerValue","isDraggingOrResizing"],"mappings":";;;;AAKA,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AAAkB,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAlB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK+X;AAAA,QACL,OAAOtY;AAAA,QACP,iBAAe,EAAQ6U;AAAA,QACvB,iBAAe,EAAQE;AAAA,QACvB,gBAAcwD;AAAA,QAEd,UAAA;AAAA,UAAA,gBAAAtY,EAACiD,MAAmB,OAAOuV,GACzB,4BAAC7R,IAAA,EAAc,QAAQsG,GAAe,EAAA,CACxC;AAAA,UAEC4D,EAAc,IAAI,CAAC,EAAE,YAAA5F,GAAY,OAAAC,GAAO,MAAAE,QACvC,gBAAApL;AAAA,YAACgL;AAAA,YAAA;AAAA,cAEC,WAAU;AAAA,cACV,YAAAC;AAAA,cACA,OAAAC;AAAA,cACA,KAAK0F,EAAS;AAAA,cACd,MAAAxF;AAAA,cACA,UAAUE;AAAA,YAAA;AAAA,YANL,OAAOL,CAAU,IAAIC,CAAK;AAAA,UAAA,CAQlC;AAAA,UAEA4F,EAAW,IAAI,CAAC,EAAE,YAAA7F,GAAY,OAAAC,GAAO,MAAAE,QACpC,gBAAApL;AAAA,YAACgL;AAAA,YAAA;AAAA,cAEC,WAAU;AAAA,cACV,YAAAC;AAAA,cACA,OAAAC;AAAA,cACA,KAAK0F,EAAS;AAAA,cACd,MAAAxF;AAAA,cACA,UAAUE;AAAA,YAAA;AAAA,YANL,OAAOL,CAAU,IAAIC,CAAK;AAAA,UAAA,CAQlC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAGH,gBAAAlL,EAAC2C,IAAA,EAAa,QAAQqK,EAAA,CAAe;AAAA,EAAA,GACvC;AAEJ;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const h=require("react/jsx-runtime"),Mt=require("react"),E=require("./styles-BMEhL6I0.cjs"),Tt=require("react-dom");function Ht(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const a=Ht(Mt),At=()=>{const t=new Map;return e=>{if(!e)return;const n=t.get(e);if(n!==void 0)return n;const o=t.size;return t.set(e,o),o}},kt=At(),X=new Map,Nt=t=>{const e=`ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${kt(t.root)}`;if(X.has(e))return X.get(e);const n=new class{#t=new Map;#e=new IntersectionObserver(o=>{o.forEach(r=>{const s=this.#t.get(r.target);s&&s(r)})},t);observe(o,r){return this.#t.set(o,r),this.#e.observe(o),()=>{this.#t.delete(o),this.#e.unobserve(o)}}};return X.set(e,n),n},st=Object.freeze({x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0});function Gt(t,{threshold:e=0,rootMargin:n="0px",root:o=null}){const[r,s]=a.useState(null);return a.useEffect(()=>{const c=t.current;return c?Nt({threshold:e,rootMargin:n,root:o}).observe(c,i=>{s({isIntersecting:i.isIntersecting,boundingClientRect:i.boundingClientRect,intersectionRatio:i.intersectionRatio,intersectionRect:i.intersectionRect,rootBounds:i.rootBounds,target:i.target,time:i.time})}):void 0},[t,e,n,o]),a.useMemo(()=>({isIntersecting:r?.isIntersecting??!1,boundingClientRect:r?.boundingClientRect??st,intersectionRatio:r?.intersectionRatio??0,intersectionRect:r?.intersectionRect??st,rootBounds:r?.rootBounds??null,target:r?.target??t.current,time:r?.time??0}),[r,t])}const jt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.5)"},Ot={position:"fixed",background:E.DRAWER_SURFACE_COLOR,boxShadow:E.DRAWER_SHADOW,willChange:"transform"},$t={left:{top:0,bottom:0,left:0,transform:"translateX(-100%)"},right:{top:0,bottom:0,right:0,transform:"translateX(100%)"},top:{top:0,left:0,right:0,transform:"translateY(-100%)"},bottom:{bottom:0,left:0,right:0,transform:"translateY(100%)"}},Ft={display:"flex",alignItems:"center",padding:`${E.DRAWER_HEADER_PADDING_Y} ${E.DRAWER_HEADER_PADDING_X}`,gap:E.DRAWER_HEADER_GAP,borderBottom:`1px solid ${E.DRAWER_BORDER_COLOR}`},Yt={fontWeight:600},Wt={marginLeft:"auto",border:"none",background:"transparent",cursor:"pointer",fontSize:E.DRAWER_CLOSE_BUTTON_FONT_SIZE},Bt={padding:E.DRAWER_CONTENT_PADDING},Zt=a.memo(({style:t,dismissible:e,onClose:n})=>{const o=e?n:void 0,r=a.useMemo(()=>({...jt,...t}),[t]);return h.jsx("div",{style:r,onClick:o})}),Xt=a.memo(({header:t,dismissible:e,onClose:n})=>{if(!t)return null;const o=t.showCloseButton??!0,r=()=>t.title?h.jsx("div",{style:Yt,children:t.title}):null,s=()=>!o||!e?null:h.jsx("button",{style:Wt,onClick:n,"aria-label":"Close drawer",type:"button",children:"×"});return h.jsxs("div",{style:Ft,children:[r(),s()]})}),bt=({id:t,config:e,isOpen:n,onClose:o,children:r,className:s,style:c,zIndex:u,width:i,height:f,position:d,backdropStyle:p})=>{const{dismissible:m=!0,header:v}=e,x=a.useCallback(C=>C?C.left!==void 0?"left":C.right!==void 0?"right":C.top!==void 0?"top":C.bottom!==void 0?"bottom":"right":"right",[])(d),_=a.useMemo(()=>{const C={...Ot,...$t[x],...c};return u!==void 0&&(C.zIndex=u),i!==void 0&&(C.width=typeof i=="number"?`${i}px`:i),f!==void 0&&(C.height=typeof f=="number"?`${f}px`:f),C},[c,u,i,f,x]),y=v?Bt:void 0,k=()=>v?h.jsx(Xt,{header:v,dismissible:m,onClose:o}):null,I=()=>p?h.jsx(a.Activity,{mode:n?"visible":"hidden",children:h.jsx(Zt,{style:p,dismissible:m,onClose:o})}):null;return h.jsxs(h.Fragment,{children:[I(),h.jsx(a.Activity,{mode:n?"visible":"hidden",children:h.jsxs("div",{className:s,"data-layer-id":t,"data-placement":x,style:_,role:"dialog","aria-modal":m?!0:void 0,"aria-hidden":n?void 0:!0,"aria-label":v?.title??"Drawer",children:[k(),h.jsx("div",{style:y,children:r})]})})]})};function P(t){const e=a.useRef(t);return e.current=t,a.useCallback((...n)=>{const o=e.current;if(o)return o(...n)},[])}const Ut=t=>{const[e,n]=a.useState(()=>{const i={};return t.forEach(f=>{f.drawer&&(i[f.id]=f.drawer.defaultOpen??!1)}),i}),o=a.useMemo(()=>{const i=new Map;return t.forEach(f=>{i.set(f.id,f)}),i},[t]),r=P((i,f)=>{o.get(i)?.drawer?.onStateChange?.(f)}),s=a.useCallback(i=>{const f=o.get(i);return f?.drawer?f.drawer.open!==void 0?f.drawer.open:e[i]??!1:!1},[o,e]),c=a.useCallback(i=>{const f=o.get(i);if(f?.drawer){if(f.drawer.open!==void 0){r(i,!0);return}n(d=>d[i]?d:(r(i,!0),{...d,[i]:!0}))}},[o,r]),u=a.useCallback(i=>{const f=o.get(i);if(f?.drawer){if(f.drawer.open!==void 0){r(i,!1);return}n(d=>d[i]?(r(i,!1),{...d,[i]:!1}):d)}},[o,r]);return{state:s,open:c,close:u}},Et=({layers:t})=>{const e=Ut(t),n=a.useMemo(()=>t.filter(r=>r.drawer),[t]),o=a.useMemo(()=>{const r=new Map;return n.forEach(s=>{r.set(s.id,()=>e.close(s.id))}),r},[n,e.close]);return h.jsx(h.Fragment,{children:n.map(r=>{if(!r.drawer)return null;const s=e.state(r.id),c=o.get(r.id);return c?h.jsx(bt,{id:r.id,config:r.drawer,isOpen:s,onClose:c,style:r.style,zIndex:r.zIndex,width:r.width,height:r.height,position:r.position,backdropStyle:r.backdropStyle,children:r.component},r.id):null})})},vt=a.createContext(null),Kt=({value:t,children:e})=>h.jsx(vt.Provider,{value:t,children:e}),Rt=()=>{const t=a.useContext(vt);if(!t)throw new Error("useGridLayoutContext must be used within a GridLayoutProvider.");return t},St=a.createContext(null),Vt=()=>{const t=a.useContext(St);if(!t)throw new Error("usePanelSystem must be used within a PanelSystemProvider.");return t},qt=({config:t,layers:e,style:n,children:o})=>{const r=a.useMemo(()=>{const c=new Map;return e.forEach(u=>{c.set(u.id,u)}),c},[e]),s=a.useMemo(()=>({config:t,style:n,layers:{defs:e,layerById:r}}),[t,n,e,r]);return h.jsx(St.Provider,{value:s,children:o})},Ct=a.createContext(null),zt=({layerId:t,children:e})=>{const n=a.useMemo(()=>({layerId:t}),[t]);return h.jsx(Ct.Provider,{value:n,children:e})},Jt=()=>{const t=a.useContext(Ct);if(!t)throw new Error("useLayerInstance must be used within a LayerInstanceProvider.");return t},it=(t,e,n)=>{if(typeof t=="number"&&Number.isFinite(t))return t;throw new Error(`Popup layer "${n}" requires a numeric "${e}" value.`)},Dt=(t,e)=>{if(!t)throw new Error(`Popup layer "${e}" must define position (left/top).`);return{left:it(t.left,"left",e),top:it(t.top,"top",e)}},j=t=>`${Math.round(t)}`,A=t=>{if(t!==void 0)return t?"yes":"no"},Qt=(t,e,n,o,r)=>{const s={},c=Dt(e,t);if(typeof n!="number"||typeof o!="number")throw new Error(`Popup layer "${t}" requires numeric width/height.`);s.width=j(n),s.height=j(o),s.left=j(c.left),s.top=j(c.top);const u=r?.features;if(u){const i=A(u.toolbar),f=A(u.menubar),d=A(u.location),p=A(u.status),m=A(u.resizable),v=A(u.scrollbars);i!==void 0&&(s.toolbar=i),f!==void 0&&(s.menubar=f),d!==void 0&&(s.location=d),p!==void 0&&(s.status=p),m!==void 0&&(s.resizable=m),v!==void 0&&(s.scrollbars=v)}return Object.entries(s).map(([i,f])=>`${i}=${f}`).join(",")},at=(t,e,n,o,r)=>{const s=Dt(n,e);if(typeof o!="number"||typeof r!="number")throw new Error(`Popup layer "${e}" requires numeric width/height.`);t.moveTo(Math.round(s.left),Math.round(s.top)),t.resizeTo(Math.round(o),Math.round(r))},te=({layer:t})=>{const e=t.floating;if(!e)throw new Error(`Layer "${t.id}" is missing floating configuration required for popup mode.`);if((e.mode??"embedded")!=="popup")throw new Error(`PopupLayerPortal received layer "${t.id}" that is not configured for popup mode.`);const o=a.useRef(null),r=a.useRef(null),[s,c]=a.useState(!1);return a.useEffect(()=>{if(typeof window>"u")return;const u=Qt(t.id,t.position,t.width,t.height,e.popup),i=e.popup?.name??t.id,f=ee(i,u,{position:t.position,size:{width:t.width,height:t.height}},e.popup);if(!f)throw new Error(`Failed to open popup window for layer "${t.id}".`);const d=f;r.current=d,e.popup?.focus!==!1&&d.focus(),d.document.title||(d.document.title=t.id),d.document.body.innerHTML="";const p=d.document.createElement("div");p.dataset.layerId=t.id,d.document.body.appendChild(p),o.current=p,c(!0),at(d,t.id,t.position,t.width,t.height);const m=()=>{r.current=null,o.current=null,c(!1)};return d.addEventListener("beforeunload",m),()=>{d.removeEventListener("beforeunload",m),e.popup?.closeOnUnmount!==!1&&d.close(),r.current=null,o.current=null,c(!1)}},[e.popup?.closeOnUnmount,e.popup?.features?.location,e.popup?.features?.menubar,e.popup?.features?.resizable,e.popup?.features?.scrollbars,e.popup?.features?.status,e.popup?.features?.toolbar,e.popup?.focus,e.popup?.name,t.id]),a.useEffect(()=>{const u=r.current;u&&at(u,t.id,t.position,t.width,t.height)},[t.position?.left,t.position?.top,t.height,t.width,t.id]),!s||!o.current?null:Tt.createPortal(h.jsx(zt,{layerId:t.id,children:t.component}),o.current)},ee=(t,e,n,o)=>{const r=o?.createWindow;return r?r({name:t,features:e,bounds:n}):window.open("",t,e)},xt={position:"absolute",pointerEvents:"auto",boxSizing:"border-box",background:"transparent",border:"none"},ne={...xt,width:E.GRID_LAYER_CORNER_HIT_SIZE,height:E.GRID_LAYER_CORNER_HIT_SIZE,zIndex:2},re={...xt,zIndex:1},oe={"top-left":{top:0,left:0,transform:"translate(-50%, -50%)",cursor:"nwse-resize"},"top-right":{top:0,right:0,transform:"translate(50%, -50%)",cursor:"nesw-resize"},"bottom-left":{bottom:0,left:0,transform:"translate(-50%, 50%)",cursor:"nesw-resize"},"bottom-right":{bottom:0,right:0,transform:"translate(50%, 50%)",cursor:"nwse-resize"}},se={left:{top:E.GRID_LAYER_CORNER_HIT_SIZE,bottom:E.GRID_LAYER_CORNER_HIT_SIZE,left:0,width:E.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(-50%)",cursor:"ew-resize"},right:{top:E.GRID_LAYER_CORNER_HIT_SIZE,bottom:E.GRID_LAYER_CORNER_HIT_SIZE,right:0,width:E.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(50%)",cursor:"ew-resize"},top:{left:E.GRID_LAYER_CORNER_HIT_SIZE,right:E.GRID_LAYER_CORNER_HIT_SIZE,top:0,height:E.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(-50%)",cursor:"ns-resize"},bottom:{left:E.GRID_LAYER_CORNER_HIT_SIZE,right:E.GRID_LAYER_CORNER_HIT_SIZE,bottom:0,height:E.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(50%)",cursor:"ns-resize"}},ie=[{key:"top-left",variant:"corner",horizontal:"left",vertical:"top"},{key:"top-right",variant:"corner",horizontal:"right",vertical:"top"},{key:"bottom-left",variant:"corner",horizontal:"left",vertical:"bottom"},{key:"bottom-right",variant:"corner",horizontal:"right",vertical:"bottom"},{key:"left",variant:"edge",horizontal:"left"},{key:"right",variant:"edge",horizontal:"right"},{key:"top",variant:"edge",vertical:"top"},{key:"bottom",variant:"edge",vertical:"bottom"}],ae=({layerId:t,onPointerDown:e})=>h.jsx(h.Fragment,{children:ie.map(n=>{const o=n.variant==="corner"?ne:re,r=n.variant==="corner"?oe[n.key]:se[n.key],s={...o,...r},c=n.variant==="corner"?{"data-resize-corner":n.key}:{"data-resize-edge":n.key};return h.jsx("div",{role:"presentation","aria-hidden":"true",style:s,...c,"data-layer-id":t,onPointerDown:u=>e(n,u)},n.key)})}),ce=({layers:t})=>{const{handleLayerPointerDown:e,getLayerRenderState:n}=Rt(),o=a.useCallback(r=>r.length===0?null:r.map(s=>h.jsx(ae,{layerId:s.layerId,onPointerDown:s.onPointerDown},s.layerId)),[]);return h.jsx(h.Fragment,{children:t.map(r=>{const s=r.floating?.mode??"embedded";if(r.floating&&s==="popup")return h.jsx(te,{layer:r},r.id);const{style:c,isResizable:u,isResizing:i,onResizeHandlePointerDown:f}=n(r),d={};r.gridArea&&(d.gridArea=r.gridArea),r.gridRow&&(d.gridRow=r.gridRow),r.gridColumn&&(d.gridColumn=r.gridColumn);const m=u?{...c,...d,position:"relative"}:{...c,...d},S=o(u?[{layerId:r.id,onPointerDown:f}]:[]);return h.jsxs("div",{"data-layer-id":r.id,"data-draggable":!!r.floating?.draggable,"data-resizable":u,"data-resizing":i,style:m,onPointerDown:e,children:[h.jsx(zt,{layerId:r.id,children:r.component}),S]},r.id)})})};function U(t,e){const n=P(e.onMove),o=P(e.onUp),r=P(e.onCancel);a.useEffect(()=>{if(t)return e.onMove&&document.addEventListener("pointermove",n,{passive:!1}),e.onUp&&document.addEventListener("pointerup",o),e.onCancel&&document.addEventListener("pointercancel",r),()=>{e.onMove&&document.removeEventListener("pointermove",n),e.onUp&&document.removeEventListener("pointerup",o),e.onCancel&&document.removeEventListener("pointercancel",r)}},[t,e.onMove,e.onUp,e.onCancel,n,o,r])}function ue(t,e,n){a.useEffect(()=>{const o=t.current;if(!(!e||!o||n===void 0))return o.setPointerCapture(n),()=>{o.hasPointerCapture&&o.hasPointerCapture(n)&&o.releasePointerCapture(n)}},[t,e,n])}function le(t,e,n=["pointerdown","pointermove","pointerup"]){a.useEffect(()=>{const o=t.current;if(!e||!o)return;const r=s=>{s.preventDefault()};return n.forEach(s=>{o.addEventListener(s,r,{passive:!1})}),()=>{n.forEach(s=>{o.removeEventListener(s,r)})}},[t,e,n])}function de(t,e,n){const{onMove:o,onUp:r,onCancel:s,pointerId:c,capturePointer:u=!0,preventDefaults:i=!0}=n;U(e,{onMove:o,onUp:r,onCancel:s}),ue(t,e?u:!1,c),le(t,e?i:!1)}const It=t=>{const e=a.useRef(null),n=a.useRef(null),o=a.useRef(0),[r,s]=a.useState(!1),c=P(p=>{t.onResize?.(p)}),u=a.useCallback(p=>t.axis==="x"?p.clientX:p.clientY,[t.axis]),i=a.useCallback(p=>{p.preventDefault(),e.current=p.currentTarget,n.current=p.pointerId,o.current=u(p),s(!0)},[u]),f=a.useCallback(p=>{const m=u(p),v=m-o.current;v!==0&&(o.current=m,c(v))},[u,c]),d=a.useCallback(()=>{s(!1),n.current=null},[]);return de(e,r,{onMove:f,onUp:d,pointerId:n.current??void 0,capturePointer:!0,preventDefaults:!1}),{ref:e,onPointerDown:i,isDragging:r}},fe=({element:t,component:e})=>a.forwardRef(({children:n,...o},r)=>t?a.cloneElement(t,{...o,ref:r},n??t.props.children):e?h.jsx(e,{...o,ref:r,children:n}):h.jsx("div",{...o,ref:r,children:n}));function Lt({element:t,component:e}){return a.useMemo(()=>fe({element:t,component:e}),[e,t])}const pe={position:"absolute",zIndex:E.RESIZE_HANDLE_Z_INDEX},ge={vertical:{width:E.RESIZE_HANDLE_THICKNESS,height:"100%",top:0,cursor:"col-resize"},horizontal:{width:"100%",height:E.RESIZE_HANDLE_THICKNESS,left:0,cursor:"row-resize"}},he={idle:E.COLOR_RESIZE_HANDLE_IDLE,hovered:E.COLOR_RESIZE_HANDLE_HOVER,dragging:E.COLOR_RESIZE_HANDLE_ACTIVE},Pt=({direction:t,onResize:e,component:n,element:o,children:r})=>{const s=t==="vertical"?"x":"y",{ref:c,isDragging:u,onPointerDown:i}=It({axis:s,onResize:e}),[f,d]=a.useState(!1),p=a.useCallback(()=>{d(!0)},[]),m=a.useCallback(()=>{d(!1)},[]),v=Lt({element:o,component:n}),S=a.useMemo(()=>u?"dragging":f?"hovered":"idle",[u,f]),x=a.useMemo(()=>({...pe,...ge[t],backgroundColor:he[S],touchAction:"none"}),[t,S]);return h.jsx(v,{ref:c,style:x,role:"separator","aria-orientation":t,"aria-hidden":void 0,"data-resize-handle":"true","data-direction":t,"data-is-dragging":u?"true":void 0,onPointerDown:i,onPointerEnter:p,onPointerLeave:m,children:r})},ct={position:"absolute",pointerEvents:"auto"},ut=({direction:t,trackIndex:e,align:n,gap:o,span:r,onResize:s})=>{const c=t==="col"?"vertical":"horizontal",u=a.useCallback(d=>{s(t,e,d)},[t,e,s]),i=a.useMemo(()=>t==="col"?{gridColumn:`${e+1} / ${e+2}`,gridRow:`${r.start} / ${r.end}`}:{gridRow:`${e+1} / ${e+2}`,gridColumn:`${r.start} / ${r.end}`},[t,e,r]),f=a.useMemo(()=>{const p=Math.max(0,o)/2+E.GRID_HANDLE_THICKNESS/2;return t==="col"?{...ct,width:E.GRID_HANDLE_THICKNESS,height:"100%",top:0,bottom:0,...n==="start"?{left:-p}:{right:-p}}:{...ct,width:"100%",height:E.GRID_HANDLE_THICKNESS,left:0,right:0,...n==="start"?{top:-p}:{bottom:-p}}},[n,t,o]);return h.jsx("div",{"data-resizable":"true",style:{...i,position:"relative",pointerEvents:"none"},children:h.jsx("div",{"data-direction":c,"data-align":n,"data-handle":"true",style:f,children:h.jsx(Pt,{direction:c,onResize:u})})})},me=t=>{const e=new Map;t.forEach((o,r)=>{o.forEach((s,c)=>{if(!s||s===".")return;const u=e.get(s);if(u){const f={rowStart:Math.min(u.rowStart,r),rowEnd:Math.max(u.rowEnd,r),colStart:Math.min(u.colStart,c),colEnd:Math.max(u.colEnd,c)};e.set(s,f);return}const i={rowStart:r,rowEnd:r,colStart:c,colEnd:c};e.set(s,i)})});const n=new Map;return e.forEach((o,r)=>{const s=o.rowStart+1,c=o.rowEnd+2,u=o.colStart+1,i=o.colEnd+2,f={gridArea:r,gridRow:`${s} / ${c}`,gridColumn:`${u} / ${i}`};n.set(r,f)}),n},we=(t,e)=>{if((t.positionMode??"grid")!=="grid")return t;const o=t.gridArea??t.id,r=e.get(o);if(!r)return t;const s=!t.gridArea,c=!t.gridRow,u=!t.gridColumn;return!s&&!c&&!u?t:{...t,gridArea:s?r.gridArea:t.gridArea,gridRow:c?r.gridRow:t.gridRow,gridColumn:u?r.gridColumn:t.gridColumn}},be=(t,e)=>{const n=a.useMemo(()=>me(t.areas),[t.areas]),o=a.useMemo(()=>e.map(u=>we(u,n)),[e,n]),r=a.useMemo(()=>o.filter(u=>u.visible!==!1),[o]),s=a.useMemo(()=>r.filter(u=>!u.drawer),[r]),c=a.useMemo(()=>{const u=new Map;return o.forEach(i=>{u.set(i.id,i)}),u},[o]);return{normalizedLayers:o,visibleLayers:r,regularLayers:s,layerById:c}},Ee=typeof window<"u"&&typeof window.document<"u",V=Ee?a.useLayoutEffect:a.useEffect,Y=(t,e)=>`${t}-${e}`,ve=(t,e,n,o)=>{const r=Y(n,o),s=e[r];return s!==void 0?`${s}px`:t.size},lt=(t,e,n)=>t.map((o,r)=>ve(o,e,n,r)).join(" "),O=(t,e)=>t.reduce((n,o,r)=>(o.resizable&&o.size.endsWith("px")&&(n[Y(e,r)]=parseInt(o.size,10)),n),{}),Re=(t,e,n)=>{const o=e!==void 0?Math.max(t,e):t;return n!==void 0?Math.min(o,n):o},Se=(t,e,n)=>{const o=t+e;return Re(o,n.minSize,n.maxSize)},Ce=(t,e,n,o,r)=>{const s=Y(t,e);return c=>{const u=Se(n,o,r);return{...c,[s]:u}}},dt=(t,e)=>{const n=t.length,o=[];for(let c=0;c<n;c++){const u=t[c],i=u[e],f=u[e+1];i!==f&&o.push(c)}if(o.length===0)return{start:1,end:n+1};const r=Math.min(...o),s=Math.max(...o);return{start:r+1,end:s+2}},ft=(t,e)=>{const n=t[e],o=t[e+1],r=n?.length??0,s=[];for(let i=0;i<r;i++){const f=n?.[i],d=o?.[i];f!==d&&s.push(i)}if(s.length===0)return{start:1,end:r+1};const c=Math.min(...s),u=Math.max(...s);return{start:c+1,end:u+2}},ze=(t,e)=>{if(t.length===0)return[];const n=e.length;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const o=[];return Array.from({length:t.length-1},(s,c)=>c).forEach(s=>{const c=t[s];if(t[s+1]?.resizable){const i=dt(e,s);o.push({trackIndex:s+1,align:"start",span:i});return}if(c?.resizable){const i=dt(e,s);o.push({trackIndex:s,align:"end",span:i})}}),o},De=(t,e)=>{if(t.length===0)return[];const n=e[0]?.length??0;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const o=[];return Array.from({length:t.length-1},(s,c)=>c).forEach(s=>{const c=t[s];if(t[s+1]?.resizable){const i=ft(e,s);o.push({trackIndex:s+1,align:"start",span:i});return}if(c?.resizable){const i=ft(e,s);o.push({trackIndex:s,align:"end",span:i})}}),o},xe=t=>{if(!t)return{rowGap:0,columnGap:0};const e=t.split(/\s+/).map(o=>o.trim()).filter(Boolean),n=o=>{const r=o.match(/^(-?\d+(?:\.\d+)?)px$/);return r?Number.parseFloat(r[1]):0};if(e.length===1){const o=n(e[0]);return{rowGap:o,columnGap:o}}return{rowGap:n(e[0]),columnGap:n(e[1])}},Ie=t=>t!==void 0?{gap:t}:{},Le=(t,e,n,o)=>{const r=Y(n,o),s=t[r];return s!==void 0?s:e.size.endsWith("px")?Number.parseInt(e.size,10):300},Pe=(t,e)=>{const[n,o]=a.useState(()=>({...O(t.columns,"col"),...O(t.rows,"row")}));V(()=>{const d={...O(t.columns,"col"),...O(t.rows,"row")};o(p=>{const m=new Set([...Object.keys(p),...Object.keys(d)]);return Array.from(m).some(S=>p[S]!==d[S])?d:p})},[t.columns,t.rows]);const r=a.useMemo(()=>t.areas.map(d=>`"${d.join(" ")}"`).join(" "),[t.areas]),s=a.useMemo(()=>xe(t.gap),[t.gap]),c=a.useMemo(()=>ze(t.columns,t.areas),[t.columns,t.areas]),u=a.useMemo(()=>De(t.rows,t.areas),[t.rows,t.areas]),i=a.useMemo(()=>({...t.style,...e,gridTemplateAreas:r,gridTemplateRows:lt(t.rows,n,"row"),gridTemplateColumns:lt(t.columns,n,"col"),...Ie(t.gap)}),[r,t.columns,t.gap,t.rows,t.style,e,n]),f=a.useCallback((d,p,m)=>{const S=(d==="row"?t.rows:t.columns)[p];if(!S||!S.resizable)return;const x=Le(n,S,d,p);o(Ce(d,p,x,m,S))},[t.columns,t.rows,n]);return{columnHandles:c,rowHandles:u,gapSizes:s,gridStyle:i,handleResize:f}},_t=(t,e=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY)=>Math.min(Math.max(t,e),n),_e=(t,e)=>typeof t!="number"||!Number.isFinite(t)?e:t,ye=t=>t.positionMode?t.positionMode:t.floating?(t.floating.mode??"embedded")==="embedded"?"absolute":"relative":"grid",Me=t=>({position:t==="grid"?"relative":t}),Te=(t,e)=>e!=="grid"?{}:{gridArea:t.gridArea,gridRow:t.gridRow,gridColumn:t.gridColumn},He=t=>t?{top:t.top,right:t.right,bottom:t.bottom,left:t.left}:{},Ae=t=>t!==void 0?{zIndex:t}:{},ke=(t,e)=>({width:t,height:e}),Ne=(t,e)=>t.pointerEvents!==void 0?typeof t.pointerEvents=="boolean"?{pointerEvents:t.pointerEvents?"auto":"none"}:{pointerEvents:t.pointerEvents}:e==="absolute"||e==="fixed"?{pointerEvents:"auto"}:{},Ge=t=>t.position,je=t=>({width:t.width,height:t.height}),Oe=t=>t.zIndex,$e=t=>{const e=ye(t),n=Ge(t),o=je(t),r=Oe(t);return{...t.style,...Me(e),...Te(t,e),...He(n),...Ae(r),...ke(o.width,o.height),...Ne(t,e)}},Fe=t=>{const e=t.floating;return e?e.mode??"embedded":null},T=t=>Fe(t)!=="embedded"?null:t.floating??null,pt=t=>t instanceof HTMLElement?["INPUT","TEXTAREA","SELECT","BUTTON"].includes(t.tagName):!1,gt=(t,e,n)=>{const o=e??Number.NEGATIVE_INFINITY,r=n??Number.POSITIVE_INFINITY;return _t(t,o,r)},ht=(t,e,n)=>{if(typeof t=="number"&&Number.isFinite(t))return t;throw new Error(`Floating layer "${n}" must provide a numeric "${e}" value when draggable mode is enabled.`)},mt=t=>{if(!T(t))throw new Error(`Floating layer "${t.id}" is missing floating configuration required for dragging.`);const n=t.position;if(!n)throw new Error(`Floating layer "${t.id}" must define position with left and top values.`);return{left:ht(n.left,"left",t.id),top:ht(n.top,"top",t.id)}},Ye=t=>{const e=T(t);return e?e.constraints??{}:{}},We=(t,e,n)=>t?t==="left"?e-n:e+n:e,Be=(t,e,n)=>t?t==="top"?e-n:e+n:e,Ze=(t,e,n)=>!t||t==="right"?e:e+n,Xe=(t,e,n)=>!t||t==="bottom"?e:e+n,K=(t,e)=>t?t.dataset.layerId===e?t:K(t.parentElement,e):null,q=(t,e,n)=>!t||n?.(t)?null:e(t)?t:q(t.parentElement,e,n),Ue=t=>t instanceof HTMLElement?q(t,e=>e.dataset.dragHandle==="true",e=>e.dataset.dragIgnore==="true"):null,wt=t=>t instanceof HTMLElement?q(t,e=>e.dataset.resizeCorner!==void 0||e.dataset.resizeEdge!==void 0)!==null:!1,$=t=>{const e=T(t);return e?e.resizable===!0:!1},F=t=>{if(!T(t))return null;const n=qe(t);if(!n)throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);return{width:n.width,height:n.height}},Ke=(t,e,n)=>{const o=t.filter($).reduce((p,m)=>{if(n===m.id){const S=e[m.id];if(S)return p[m.id]=S,p}const v=F(m);return v&&(p[m.id]=v),p},{}),r=Object.keys(e),s=Object.keys(o),c=r.length!==s.length,u=r.some(p=>!Object.prototype.hasOwnProperty.call(o,p)),i=c?!0:u,f=s.some(p=>{const m=e[p],v=o[p];return!m||!v?!0:m.width!==v.width||m.height!==v.height});return{sizes:o,changed:i?!0:f}},Ve=({layers:t,layerById:e})=>{const[n,o]=a.useState(null),[r,s]=a.useState(null),[c,u]=a.useState({}),[i,f]=a.useState({}),d=a.useRef(null),p=a.useRef(null),m=P((g,l)=>{e.get(g)?.floating?.onMove?.(l)}),v=P((g,l)=>{e.get(g)?.floating?.onResize?.(l)});V(()=>{const{sizes:g,changed:l}=Ke(t,i,r);l&&f(g)},[t,r]);const S=a.useCallback((g,l,w,b)=>{const R=mt(l),D=c[g]??{x:0,y:0},z={pointerStartX:b.clientX,pointerStartY:b.clientY,initialTranslationX:D.x,initialTranslationY:D.y,baseLeft:R.left,baseTop:R.top,layerId:g,pointerId:b.pointerId,target:w};if(z.target.setPointerCapture)try{z.target.setPointerCapture(z.pointerId)}catch{}d.current=z,o(g)},[c]),x=a.useCallback(g=>{const l=g.target,w=Ue(l);if(!w)return;const b=w.closest("[data-layer-id]")?.getAttribute("data-layer-id");if(!b)return;const R=e.get(b);if(!R)return;const D=T(R);if(!(!D||D.draggable!==!0)&&!pt(g.target)&&!wt(g.target)&&w){const z=K(w,b);if(!z)return;S(b,R,z,g);return}},[S,e]),_=a.useCallback((g,l)=>{const w=e.get(g),b=w?T(w):null;if(!w||!b||b.draggable!==!0||pt(l.target)||wt(l.target))return;const R=K(l.currentTarget,g);R&&S(g,w,R,l)},[S,e]),y=a.useCallback((g,l,w)=>{const b=e.get(g);if(!b||!$(b))return;const R=i[g]??F(b);if(!R)return;const D=mt(b),z=Ye(b),L=c[g]??{x:0,y:0};if(w.stopPropagation(),w.preventDefault(),w.currentTarget.setPointerCapture)try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}p.current={layerId:g,pointerId:w.pointerId,horizontalEdge:l.horizontal,verticalEdge:l.vertical,startX:w.clientX,startY:w.clientY,startWidth:R.width,startHeight:R.height,startPosition:L,baseLeft:D.left,baseTop:D.top,minWidth:z.minWidth,maxWidth:z.maxWidth,minHeight:z.minHeight,maxHeight:z.maxHeight,target:w.currentTarget},s(g)},[e,c,i]),k=a.useCallback(g=>{const l=d.current;if(!l)return;const w=g.clientX-l.pointerStartX,b=g.clientY-l.pointerStartY,R={x:l.initialTranslationX+w,y:l.initialTranslationY+b};u(D=>({...D,[l.layerId]:R})),m(l.layerId,{left:l.baseLeft+R.x,top:l.baseTop+R.y})},[m]),I=a.useCallback(g=>{const l=p.current;if(!l||l.pointerId!==g.pointerId||!e.get(l.layerId))return;const b=g.clientX-l.startX,R=g.clientY-l.startY,D=We(l.horizontalEdge,l.startWidth,b),z=Be(l.verticalEdge,l.startHeight,R),L=gt(D,l.minWidth,l.maxWidth),M=gt(z,l.minHeight,l.maxHeight),N=l.startWidth-L,W=l.startHeight-M,nt=Ze(l.horizontalEdge,l.startPosition.x,N),yt=Xe(l.verticalEdge,l.startPosition.y,W),B=i[l.layerId],rt={width:L,height:M};(!B||B.width!==L||B.height!==M)&&(f(Z=>({...Z,[l.layerId]:rt})),v(l.layerId,rt));const ot=c[l.layerId]??{x:0,y:0},G={x:nt,y:yt};(ot.x!==G.x||ot.y!==G.y)&&(u(Z=>({...Z,[l.layerId]:G})),m(l.layerId,{left:l.baseLeft+G.x,top:l.baseTop+G.y}))},[e,c,i,m,v]),C=a.useCallback(g=>{const l=d.current;if(l){if(l.pointerId===g.pointerId&&l.target.releasePointerCapture)try{l.target.releasePointerCapture(l.pointerId)}catch{}d.current=null}o(null)},[]),H=a.useCallback(g=>{const l=p.current;if(l){if(l.pointerId===g.pointerId&&l.target.releasePointerCapture)try{l.target.releasePointerCapture(l.pointerId)}catch{}p.current=null}s(null)},[]);U(n!==null,{onMove:k,onUp:C,onCancel:C}),U(r!==null,{onMove:I,onUp:H,onCancel:H});const J=a.useCallback(g=>{const l=$e(g),w=T(g);if(!w||w.draggable!==!0)return l;const b=c[g.id],R=n===g.id,D=r===g.id,z=b?{transform:`translate(${b.x}px, ${b.y}px)`}:{},L=i[g.id],M=$(g)?F(g):null,N=L??M,W=N?{width:`${N.width}px`,height:`${N.height}px`}:{};return{...l,...W,...z,...R||D?{cursor:"grabbing"}:{}}},[n,c,i,r]),Q=a.useCallback(g=>{if(!$(g))return{isResizable:!1};const w=i[g.id],b=F(g);return(w??b)!==null?{isResizable:!0,onPointerDown:(L,M)=>{y(g.id,L,M)}}:{isResizable:!1}},[y,i]),tt=a.useCallback(g=>{const{isResizable:l,onPointerDown:w}=Q(g),b=J(g),R=r===g.id;return{style:b,isResizable:l,isResizing:R,onResizeHandlePointerDown:(D,z)=>{w&&w(D,z)}}},[J,Q,r]),et=a.useCallback(g=>({"data-drag-handle":"true",role:"button","aria-roledescription":"Drag handle","aria-label":"Drag layer",onPointerDown:l=>{_(g,l)}}),[_]);return{providerValue:a.useMemo(()=>({handleLayerPointerDown:x,getLayerRenderState:tt,getLayerHandleProps:et}),[et,tt,x]),draggingLayerId:n,resizingLayerId:r}},qe=t=>{if(typeof t.width=="number"&&typeof t.height=="number")return{width:t.width,height:t.height}},Je={display:"grid",width:"100%",height:"100%",overflow:"hidden"},Qe={touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"},tn=({config:t,layers:e,style:n})=>{const o=a.useRef(null),{isIntersecting:r}=Gt(o,{threshold:0});return h.jsx(qt,{config:t,layers:e,style:n,children:h.jsx(en,{gridRef:o,isIntersecting:r})})},en=({gridRef:t,isIntersecting:e})=>{const{config:n,style:o,layers:r}=Vt(),{normalizedLayers:s,visibleLayers:c,regularLayers:u,layerById:i}=be(n,r.defs),{columnHandles:f,rowHandles:d,gapSizes:p,gridStyle:m,handleResize:v}=Pe(n,o),{providerValue:S,draggingLayerId:x,resizingLayerId:_}=Ve({layers:s,layerById:i}),y=x?!0:!!_,k=a.useMemo(()=>({...Je,...m,...y?Qe:{}}),[m,y]);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{ref:t,style:k,"data-dragging":!!x,"data-resizing":!!_,"data-visible":e,children:[h.jsx(Kt,{value:S,children:h.jsx(ce,{layers:u})}),f.map(({trackIndex:I,align:C,span:H})=>h.jsx(ut,{direction:"col",trackIndex:I,align:C,gap:p.columnGap,span:H,onResize:v},`col-${I}:${C}`)),d.map(({trackIndex:I,align:C,span:H})=>h.jsx(ut,{direction:"row",trackIndex:I,align:C,gap:p.rowGap,span:H,onResize:v},`row-${I}:${C}`))]}),h.jsx(Et,{layers:c})]})};exports.Drawer=bt;exports.DrawerLayers=Et;exports.GridLayout=tn;exports.ResizeHandle=Pt;exports.clampNumber=_t;exports.toFiniteNumberOr=_e;exports.useEffectEvent=P;exports.useElementComponentWrapper=Lt;exports.useGridLayoutContext=Rt;exports.useIsomorphicLayoutEffect=V;exports.useLayerInstance=Jt;exports.useResizeDrag=It;
|
|
2
|
-
//# sourceMappingURL=GridLayout-Dx3Qofl0.cjs.map
|