@wordpress/grid 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dashboard-grid/grid-item.cjs +10 -8
- package/build/dashboard-grid/grid-item.cjs.map +1 -1
- package/build/dashboard-grid/index.cjs +20 -18
- package/build/dashboard-grid/index.cjs.map +1 -1
- package/build/dashboard-lanes/index.cjs +19 -17
- package/build/dashboard-lanes/index.cjs.map +1 -1
- package/build/dashboard-lanes/lane-placement.cjs +1 -1
- package/build/dashboard-lanes/lanes-item.cjs +10 -8
- package/build/dashboard-lanes/lanes-item.cjs.map +1 -1
- package/build/dashboard-lanes/use-lane-placement.cjs.map +1 -1
- package/build/shared/grid-overlay.cjs +16 -14
- package/build/shared/grid-overlay.cjs.map +1 -1
- package/build/shared/resize-handle.cjs +9 -7
- package/build/shared/resize-handle.cjs.map +1 -1
- package/build/shared/resize-snap.cjs +1 -1
- package/build/shared/use-item-exit-animation.cjs.map +1 -1
- package/build/shared/use-layout-shift-animation.cjs.map +1 -1
- package/build-module/dashboard-grid/index.mjs +11 -11
- package/build-module/dashboard-grid/index.mjs.map +1 -1
- package/build-module/dashboard-lanes/index.mjs +10 -10
- package/build-module/dashboard-lanes/index.mjs.map +1 -1
- package/build-module/dashboard-lanes/lane-placement.mjs +1 -1
- package/build-module/shared/grid-overlay.mjs +7 -7
- package/build-module/shared/grid-overlay.mjs.map +1 -1
- package/build-module/shared/resize-snap.mjs +1 -1
- package/build-module/shared/use-layout-shift-animation.mjs.map +1 -1
- package/package.json +14 -12
- package/src/dashboard-grid/{grid.module.css → grid.module.scss} +10 -19
- package/src/dashboard-grid/index.tsx +1 -1
- package/src/dashboard-lanes/index.tsx +2 -2
- package/src/dashboard-lanes/{lanes.module.css → lanes.module.scss} +10 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize-handle.cjs","names":["useDraggable","useRef","useCallback","useMergeRefs","RenderResizeHandle","styles","useThrottle","DndContext"],"sources":["../../../style-runtime/src/index.ts","../../src/shared/resize-handle.module.css","../../src/shared/resize-handle.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"a268367938\", \".ec44a4f547abd05b__resize-handle-slot{opacity:1}@media (prefers-reduced-motion:no-preference){.ec44a4f547abd05b__resize-handle-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-dragging] .ec44a4f547abd05b__resize-handle-slot,[data-wp-grid-resizing] .ec44a4f547abd05b__resize-handle-slot{opacity:0;pointer-events:none}[data-wp-grid-resizing]\\n[data-wp-grid-item-resizing]\\n.ec44a4f547abd05b__resize-handle-slot{opacity:1;pointer-events:auto}.ce3becd091879c6c__resize-handle{border-block-end:12px solid var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-inline-start:12px solid transparent;bottom:0;cursor:nwse-resize;height:0;inset-inline-end:0;position:absolute;width:0;z-index:1}.a498ea47859f08fc__is-horizontal-only{align-items:center;background:transparent;border-style:none;bottom:auto;cursor:ew-resize;display:flex;height:40px;justify-content:center;top:50%;transform:translateY(-50%);width:16px}.a498ea47859f08fc__is-horizontal-only:before{background-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-radius:2px;content:\\\"\\\";height:24px;width:4px}@media (forced-colors:active){.a498ea47859f08fc__is-horizontal-only:before{background-color:Highlight}}\");\n}\nexport default {\"resize-handle-slot\":\"ec44a4f547abd05b__resize-handle-slot\",\"resize-handle\":\"ce3becd091879c6c__resize-handle\",\"is-horizontal-only\":\"a498ea47859f08fc__is-horizontal-only\"};\n","import { DndContext, useDraggable } from '@dnd-kit/core';\nimport type { DragMoveEvent } from '@dnd-kit/core';\nimport clsx from 'clsx';\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMergeRefs, useThrottle } from '@wordpress/compose';\nimport type { ResizeDelta, ResizeHandleProps } from './types';\nimport styles from './resize-handle.module.css';\n\n/**\n * Sets `document.documentElement.style.cursor` for the duration of a drag\n * and restores it on cleanup. Lives outside the component so cursor writes\n * are not analyzed as mutating values derived from refs in the component\n * body (react-hooks/immutability).\n *\n * @param getDocument Returns the document whose root element should receive\n * the cursor (handle owner, or global `document`).\n * @param cursor CSS cursor value while active.\n * @return Cleanup that restores the previous cursor.\n */\nfunction lockDocumentCursorWhileActive(\n\tgetDocument: () => Document,\n\tcursor: string\n): () => void {\n\tconst root = getDocument().documentElement;\n\tconst previous = root.style.cursor;\n\troot.style.cursor = cursor;\n\treturn () => {\n\t\troot.style.cursor = previous;\n\t};\n}\n\nfunction ResizeHandle( {\n\titemId,\n\tverticalResizable = true,\n\trenderResizeHandle,\n}: ResizeHandleProps ) {\n\tconst { attributes, listeners, setNodeRef, isDragging } = useDraggable( {\n\t\tid: 'draggable',\n\t\tdata: { itemId },\n\t} );\n\n\t// Snapshot owner document on mount/update via ref callback so the\n\t// cursor-lock effect can resolve the correct document in an iframe.\n\tconst ownerDocumentRef = useRef< Document | null >( null );\n\tconst setOwnerDocumentRef = useCallback( ( node: HTMLElement | null ) => {\n\t\townerDocumentRef.current = node?.ownerDocument ?? null;\n\t}, [] );\n\tconst mergedRef = useMergeRefs( [ setOwnerDocumentRef, setNodeRef ] );\n\n\t// Lock the document cursor while the gesture is active. Without\n\t// this, the OS pointer reverts to the default arrow as soon as it\n\t// leaves the handle's hit area, even though the resize is still\n\t// in progress.\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\treturn;\n\t\t}\n\t\tconst cursor = verticalResizable ? 'nwse-resize' : 'ew-resize';\n\t\treturn lockDocumentCursorWhileActive(\n\t\t\t() => ownerDocumentRef.current ?? document,\n\t\t\tcursor\n\t\t);\n\t}, [ isDragging, verticalResizable ] );\n\n\tif ( renderResizeHandle ) {\n\t\tconst RenderResizeHandle = renderResizeHandle;\n\t\treturn (\n\t\t\t<RenderResizeHandle\n\t\t\t\tref={ mergedRef }\n\t\t\t\tlisteners={ listeners }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tverticalResizable={ verticalResizable }\n\t\t\t\tisResizing={ isDragging }\n\t\t\t\titemId={ itemId }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ mergedRef }\n\t\t\tclassName={ clsx(\n\t\t\t\tstyles[ 'resize-handle' ],\n\t\t\t\t! verticalResizable && styles[ 'is-horizontal-only' ]\n\t\t\t) }\n\t\t\t{ ...listeners }\n\t\t\t{ ...attributes }\n\t\t/>\n\t);\n}\n\n/**\n * Renders a corner resize handle inside an isolated `<DndContext>`.\n * Reports the cursor offset since the gesture started (in pixels)\n * via `onResize`, throttled to one animation frame so the grid\n * commit loop runs at most once per paint.\n *\n * Auto-scroll is enabled with a tight trigger zone and a low\n * acceleration so a resize gesture near the viewport edge scrolls\n * the page only when the user deliberately pushes against the very\n * edge, and even then at a pace the user can interrupt by releasing.\n * Default tuning would otherwise produce a runaway loop where the\n * page scrolls fast, dnd-kit's document-coordinate `delta` inflates\n * with the scroll, and the tile keeps growing without further user\n * input.\n *\n * @param props Component props.\n */\nexport default function ResizeHandleWrapper( props: ResizeHandleProps ) {\n\tconst throttleDelay = 16;\n\tconst throttledResize = useThrottle( ( delta: ResizeDelta ) => {\n\t\tif ( props.onResize ) {\n\t\t\tprops.onResize( delta );\n\t\t}\n\t}, throttleDelay );\n\n\t// `event.delta` is the cursor offset from the gesture start —\n\t// not from the handle's current position — so it stays stable\n\t// even when the tile (and therefore the handle) jumps a column.\n\t// The grid's resize logic snapshots the start width and adds\n\t// `delta`, so the two must share the same frame of reference.\n\tconst handleDragMove = ( event: DragMoveEvent ) => {\n\t\tif ( event.active.id !== 'draggable' ) {\n\t\t\treturn;\n\t\t}\n\t\tthrottledResize( {\n\t\t\twidth: event.delta.x,\n\t\t\theight: event.delta.y,\n\t\t} );\n\t};\n\n\tconst handleDragEnd = () => {\n\t\tif ( props.onResizeEnd ) {\n\t\t\tprops.onResizeEnd();\n\t\t}\n\t};\n\n\treturn (\n\t\t<DndContext\n\t\t\tautoScroll={ {\n\t\t\t\tthreshold: { x: 0.005, y: 0.005 },\n\t\t\t\tacceleration: 1,\n\t\t\t} }\n\t\t\tonDragMove={ handleDragMove }\n\t\t\tonDragEnd={ handleDragEnd }\n\t\t>\n\t\t\t<div className={ styles[ 'resize-handle-slot' ] }>\n\t\t\t\t<ResizeHandle { ...props } />\n\t\t\t</div>\n\t\t</DndContext>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;;;;;;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;CAC3E,IAAK,CAAE,eAAe,MACrB;CAGD,MAAM,UAAU,WAAW;CAC3B,IAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;C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ED,gBAAiB;GAChB,OAAO,MAAM,MAAM;GACnB,QAAQ,MAAM,MAAM;EACrB,CAAE;CACH;CAEA,MAAM,sBAAsB;EAC3B,IAAK,MAAM,aACV,MAAM,YAAY;CAEpB;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,YAAD;EACC,YAAa;GACZ,WAAW;IAAE,GAAG;IAAO,GAAG;GAAM;GAChC,cAAc;EACf;EACA,YAAa;EACb,WAAY;EAEZ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAYF,6BAAQ;GACxB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD,EAAc,GAAK,MAAS,CAAA;EACxB,CAAA;CACM,CAAA;AAEd"}
|
|
1
|
+
{"version":3,"file":"resize-handle.cjs","names":["useDraggable","useRef","useCallback","useMergeRefs","useEffect","RenderResizeHandle","clsx","styles","useThrottle","DndContext"],"sources":["../../../style-runtime/src/index.ts","../../src/shared/resize-handle.module.css","../../src/shared/resize-handle.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"a268367938\", \".ec44a4f547abd05b__resize-handle-slot{opacity:1}@media (prefers-reduced-motion:no-preference){.ec44a4f547abd05b__resize-handle-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-dragging] .ec44a4f547abd05b__resize-handle-slot,[data-wp-grid-resizing] .ec44a4f547abd05b__resize-handle-slot{opacity:0;pointer-events:none}[data-wp-grid-resizing]\\n[data-wp-grid-item-resizing]\\n.ec44a4f547abd05b__resize-handle-slot{opacity:1;pointer-events:auto}.ce3becd091879c6c__resize-handle{border-block-end:12px solid var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-inline-start:12px solid transparent;bottom:0;cursor:nwse-resize;height:0;inset-inline-end:0;position:absolute;width:0;z-index:1}.a498ea47859f08fc__is-horizontal-only{align-items:center;background:transparent;border-style:none;bottom:auto;cursor:ew-resize;display:flex;height:40px;justify-content:center;top:50%;transform:translateY(-50%);width:16px}.a498ea47859f08fc__is-horizontal-only:before{background-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-radius:2px;content:\\\"\\\";height:24px;width:4px}@media (forced-colors:active){.a498ea47859f08fc__is-horizontal-only:before{background-color:Highlight}}\");\n}\nexport default {\"resize-handle-slot\":\"ec44a4f547abd05b__resize-handle-slot\",\"resize-handle\":\"ce3becd091879c6c__resize-handle\",\"is-horizontal-only\":\"a498ea47859f08fc__is-horizontal-only\"};\n","import { DndContext, useDraggable } from '@dnd-kit/core';\nimport type { DragMoveEvent } from '@dnd-kit/core';\nimport clsx from 'clsx';\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMergeRefs, useThrottle } from '@wordpress/compose';\nimport type { ResizeDelta, ResizeHandleProps } from './types';\nimport styles from './resize-handle.module.css';\n\n/**\n * Sets `document.documentElement.style.cursor` for the duration of a drag\n * and restores it on cleanup. Lives outside the component so cursor writes\n * are not analyzed as mutating values derived from refs in the component\n * body (react-hooks/immutability).\n *\n * @param getDocument Returns the document whose root element should receive\n * the cursor (handle owner, or global `document`).\n * @param cursor CSS cursor value while active.\n * @return Cleanup that restores the previous cursor.\n */\nfunction lockDocumentCursorWhileActive(\n\tgetDocument: () => Document,\n\tcursor: string\n): () => void {\n\tconst root = getDocument().documentElement;\n\tconst previous = root.style.cursor;\n\troot.style.cursor = cursor;\n\treturn () => {\n\t\troot.style.cursor = previous;\n\t};\n}\n\nfunction ResizeHandle( {\n\titemId,\n\tverticalResizable = true,\n\trenderResizeHandle,\n}: ResizeHandleProps ) {\n\tconst { attributes, listeners, setNodeRef, isDragging } = useDraggable( {\n\t\tid: 'draggable',\n\t\tdata: { itemId },\n\t} );\n\n\t// Snapshot owner document on mount/update via ref callback so the\n\t// cursor-lock effect can resolve the correct document in an iframe.\n\tconst ownerDocumentRef = useRef< Document | null >( null );\n\tconst setOwnerDocumentRef = useCallback( ( node: HTMLElement | null ) => {\n\t\townerDocumentRef.current = node?.ownerDocument ?? null;\n\t}, [] );\n\tconst mergedRef = useMergeRefs( [ setOwnerDocumentRef, setNodeRef ] );\n\n\t// Lock the document cursor while the gesture is active. Without\n\t// this, the OS pointer reverts to the default arrow as soon as it\n\t// leaves the handle's hit area, even though the resize is still\n\t// in progress.\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\treturn;\n\t\t}\n\t\tconst cursor = verticalResizable ? 'nwse-resize' : 'ew-resize';\n\t\treturn lockDocumentCursorWhileActive(\n\t\t\t() => ownerDocumentRef.current ?? document,\n\t\t\tcursor\n\t\t);\n\t}, [ isDragging, verticalResizable ] );\n\n\tif ( renderResizeHandle ) {\n\t\tconst RenderResizeHandle = renderResizeHandle;\n\t\treturn (\n\t\t\t<RenderResizeHandle\n\t\t\t\tref={ mergedRef }\n\t\t\t\tlisteners={ listeners }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tverticalResizable={ verticalResizable }\n\t\t\t\tisResizing={ isDragging }\n\t\t\t\titemId={ itemId }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ mergedRef }\n\t\t\tclassName={ clsx(\n\t\t\t\tstyles[ 'resize-handle' ],\n\t\t\t\t! verticalResizable && styles[ 'is-horizontal-only' ]\n\t\t\t) }\n\t\t\t{ ...listeners }\n\t\t\t{ ...attributes }\n\t\t/>\n\t);\n}\n\n/**\n * Renders a corner resize handle inside an isolated `<DndContext>`.\n * Reports the cursor offset since the gesture started (in pixels)\n * via `onResize`, throttled to one animation frame so the grid\n * commit loop runs at most once per paint.\n *\n * Auto-scroll is enabled with a tight trigger zone and a low\n * acceleration so a resize gesture near the viewport edge scrolls\n * the page only when the user deliberately pushes against the very\n * edge, and even then at a pace the user can interrupt by releasing.\n * Default tuning would otherwise produce a runaway loop where the\n * page scrolls fast, dnd-kit's document-coordinate `delta` inflates\n * with the scroll, and the tile keeps growing without further user\n * input.\n *\n * @param props Component props.\n */\nexport default function ResizeHandleWrapper( props: ResizeHandleProps ) {\n\tconst throttleDelay = 16;\n\tconst throttledResize = useThrottle( ( delta: ResizeDelta ) => {\n\t\tif ( props.onResize ) {\n\t\t\tprops.onResize( delta );\n\t\t}\n\t}, throttleDelay );\n\n\t// `event.delta` is the cursor offset from the gesture start —\n\t// not from the handle's current position — so it stays stable\n\t// even when the tile (and therefore the handle) jumps a column.\n\t// The grid's resize logic snapshots the start width and adds\n\t// `delta`, so the two must share the same frame of reference.\n\tconst handleDragMove = ( event: DragMoveEvent ) => {\n\t\tif ( event.active.id !== 'draggable' ) {\n\t\t\treturn;\n\t\t}\n\t\tthrottledResize( {\n\t\t\twidth: event.delta.x,\n\t\t\theight: event.delta.y,\n\t\t} );\n\t};\n\n\tconst handleDragEnd = () => {\n\t\tif ( props.onResizeEnd ) {\n\t\t\tprops.onResizeEnd();\n\t\t}\n\t};\n\n\treturn (\n\t\t<DndContext\n\t\t\tautoScroll={ {\n\t\t\t\tthreshold: { x: 0.005, y: 0.005 },\n\t\t\t\tacceleration: 1,\n\t\t\t} }\n\t\t\tonDragMove={ handleDragMove }\n\t\t\tonDragEnd={ handleDragEnd }\n\t\t>\n\t\t\t<div className={ styles[ 'resize-handle-slot' ] }>\n\t\t\t\t<ResizeHandle { ...props } />\n\t\t\t</div>\n\t\t</DndContext>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,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CACD,GAAG,CAAE,YAAY,iBAAkB,CAAE;CAErC,IAAK,oBAEJ,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAD;EACC,KAAM;EACM;EACC;EACO;EACpB,YAAa;EACJ;CACT,CAAA;CAIH,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,KAAM;EACN,YAAA,GAAYC,KAAAA,QAAAA,CACXC,6BAAQ,kBACR,CAAE,qBAAqBA,6BAAQ,qBAChC;EACA,GAAK;EACL,GAAK;CACL,CAAA;AAEH;;;;;;;;;;;;;;;;;;AAmBA,SAAwB,oBAAqB,OAA2B;CAEvE,MAAM,mBAAA,GAAkBC,mBAAAA,YAAAA,EAAe,UAAwB;EAC9D,IAAK,MAAM,UACV,MAAM,SAAU,KAAM;CAExB,GAAG,EAAc;CAOjB,MAAM,kBAAmB,UAA0B;EAClD,IAAK,MAAM,OAAO,OAAO,aACxB;EAED,gBAAiB;GAChB,OAAO,MAAM,MAAM;GACnB,QAAQ,MAAM,MAAM;EACrB,CAAE;CACH;CAEA,MAAM,sBAAsB;EAC3B,IAAK,MAAM,aACV,MAAM,YAAY;CAEpB;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,YAAD;EACC,YAAa;GACZ,WAAW;IAAE,GAAG;IAAO,GAAG;GAAM;GAChC,cAAc;EACf;EACA,YAAa;EACb,WAAY;EAEZ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAYF,6BAAQ;GACxB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD,EAAc,GAAK,MAAS,CAAA;EACxB,CAAA;CACM,CAAA;AAEd"}
|
|
@@ -75,7 +75,7 @@ function pixelLimitsToSpanBounds(limits, columnWidth, gapPx, rowHeightPx, maxCol
|
|
|
75
75
|
if (limits.maxWidth) maxWidth = Math.min(Math.max(1, Math.floor((limits.maxWidth + gapPx) / columnTrack)), maxColumns);
|
|
76
76
|
}
|
|
77
77
|
let minHeight = 1;
|
|
78
|
-
let maxHeight =
|
|
78
|
+
let maxHeight = 1e400;
|
|
79
79
|
if (rowHeightPx !== null && rowHeightPx > 0) {
|
|
80
80
|
const rowTrack = rowHeightPx + gapPx;
|
|
81
81
|
if (limits.minHeight) minHeight = Math.max(1, Math.ceil((limits.minHeight + gapPx) / rowTrack));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-item-exit-animation.cjs","names":["useState","useRef","useCallback"],"sources":["../../src/shared/use-item-exit-animation.ts"],"sourcesContent":["import {\n\tuseCallback,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport type { ItemExitOverlayRect } from './item-exit-overlay';\nimport type { RectSnapshot } from './use-layout-shift-animation';\n\n/*\n * Last-resort cleanup if `animationend` never fires (the overlay's\n * `onAnimationEnd` is the primary path). Kept well above the motion\n * token durations so the timeout can never clip the exit animation.\n */\nconst EXIT_SAFETY_TIMEOUT_MS = 1000;\n\nexport type ExitingGridItem = {\n\tkey: string;\n\trect: ItemExitOverlayRect;\n\tchild: React.ReactElement;\n};\n\ntype UseItemExitAnimationOptions = {\n\tcontainer: HTMLElement | null;\n\tenabled: boolean;\n\tlayoutKeys: ReadonlySet< string >;\n\tgetPositionsBeforeLastChange: () => ReadonlyMap<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null;\n\tchildrenCacheRef: React.RefObject< Map< string, React.ReactElement > >;\n};\n\ntype UseItemExitAnimationResult = {\n\texitingItems: ExitingGridItem[];\n\thasExitingItems: boolean;\n\tclearExitingItem: ( key: string ) => void;\n};\n\nfunction prefersReducedMotion(): boolean {\n\treturn (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches\n\t);\n}\n\n/**\n * When `layout` loses keys in edit mode, keeps a short-lived overlay at\n * the removed tile's last position (scale + fade) while siblings FLIP.\n *\n * @param root0 Hook options.\n * @param root0.container Surface root that contains grid tiles.\n * @param root0.enabled When false, exiting state is cleared.\n * @param root0.layoutKeys Keys in the committed `layout` prop.\n * @param root0.getPositionsBeforeLastChange Container-relative rects before the latest layout commit.\n * @param root0.childrenCacheRef Last rendered children keyed by tile id.\n * @return Exiting overlays and a callback to dismiss one by key.\n */\nexport function useItemExitAnimation( {\n\tcontainer,\n\tenabled,\n\tlayoutKeys,\n\tgetPositionsBeforeLastChange,\n\tchildrenCacheRef,\n}: UseItemExitAnimationOptions ): UseItemExitAnimationResult {\n\tconst [ exitingItems, setExitingItems ] = useState< ExitingGridItem[] >(\n\t\t[]\n\t);\n\tconst prevLayoutKeysRef = useRef< Set< string > >( new Set() );\n\tconst exitTimeoutsRef = useRef<\n\t\tMap< string, ReturnType< typeof setTimeout > >\n\t>( new Map() );\n\n\tconst clearExitingItem = useCallback(\n\t\t( key: string ) => {\n\t\t\tconst timeout = exitTimeoutsRef.current.get( key );\n\t\t\tif ( timeout ) {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t\texitTimeoutsRef.current.delete( key );\n\t\t\t}\n\t\t\tsetExitingItems( ( current ) =>\n\t\t\t\tcurrent.filter( ( item ) => item.key !== key )\n\t\t\t);\n\t\t\tchildrenCacheRef.current.delete( key );\n\t\t},\n\t\t[ childrenCacheRef ]\n\t);\n\n\tconst scheduleExitComplete = useCallback(\n\t\t( key: string ) => {\n\t\t\tif ( exitTimeoutsRef.current.has( key ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\texitTimeoutsRef.current.delete( key );\n\t\t\t\tclearExitingItem( key );\n\t\t\t}, EXIT_SAFETY_TIMEOUT_MS );\n\t\t\texitTimeoutsRef.current.set( key, timeout );\n\t\t},\n\t\t[ clearExitingItem ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! enabled || ! container ) {\n\t\t\tprevLayoutKeysRef.current = new Set( layoutKeys );\n\t\t\tfor ( const timeout of exitTimeoutsRef.current.values() ) {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t}\n\t\t\texitTimeoutsRef.current.clear();\n\t\t\tsetExitingItems( [] );\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevKeys = prevLayoutKeysRef.current;\n\t\tconst removed: string[] = [];\n\t\tfor ( const key of prevKeys ) {\n\t\t\tif ( ! layoutKeys.has( key ) ) {\n\t\t\t\tremoved.push( key );\n\t\t\t}\n\t\t}\n\t\tprevLayoutKeysRef.current = new Set( layoutKeys );\n\n\t\tif ( removed.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lastPositions = getPositionsBeforeLastChange();\n\t\tif ( ! lastPositions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextExiting: ExitingGridItem[] = [];\n\t\tfor ( const key of removed ) {\n\t\t\tconst position = lastPositions.get( key );\n\t\t\tconst child = childrenCacheRef.current.get( key );\n\t\t\tif ( ! position || ! child ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnextExiting.push( {\n\t\t\t\tkey,\n\t\t\t\trect: position,\n\t\t\t\tchild,\n\t\t\t} );\n\t\t}\n\n\t\tif ( nextExiting.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion() ) {\n\t\t\t// Siblings snap into place via the layout-shift hook; skip the\n\t\t\t// exit ghost (and its synchronous mount) entirely.\n\t\t\tfor ( const { key } of nextExiting ) {\n\t\t\t\tchildrenCacheRef.current.delete( key );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// A state update inside a layout effect is flushed before paint,\n\t\t// so the ghost mounts in the same frame the tile is removed.\n\t\tsetExitingItems( ( current ) => [ ...current, ...nextExiting ] );\n\n\t\tfor ( const { key } of nextExiting ) {\n\t\t\tscheduleExitComplete( key );\n\t\t}\n\t}, [\n\t\tcontainer,\n\t\tenabled,\n\t\tgetPositionsBeforeLastChange,\n\t\tlayoutKeys,\n\t\tchildrenCacheRef,\n\t\tscheduleExitComplete,\n\t] );\n\n\tuseLayoutEffect( () => {\n\t\tconst exitTimeouts = exitTimeoutsRef.current;\n\t\treturn () => {\n\t\t\tfor ( const timeout of exitTimeouts.values() ) {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t}\n\t\t\texitTimeouts.clear();\n\t\t};\n\t}, [] );\n\n\treturn {\n\t\texitingItems,\n\t\thasExitingItems: exitingItems.length > 0,\n\t\tclearExitingItem,\n\t};\n}\n"],"mappings":";;;;;;;AAcA,MAAM,yBAAyB;AAyB/B,SAAS,uBAAgC;CACxC,OACC,OAAO,WAAW,eAClB,OAAO,WAAY,kCAAmC,CAAC,CAAC;AAE1D;;;;;;;;;;;;;AAcA,SAAgB,qBAAsB,EACrC,WACA,SACA,YACA,8BACA,oBAC4D;CAC5D,MAAM,CAAE,cAAc,oBAAA,GAAoBA,mBAAAA,SAAAA,CACzC,CAAC,CACF;CACA,MAAM,qBAAA,GAAoBC,mBAAAA,OAAAA,iBAAyB,IAAI,IAAI,CAAE;CAC7D,MAAM,mBAAA,GAAkBA,mBAAAA,OAAAA,iBAErB,IAAI,IAAI,CAAE;CAEb,MAAM,oBAAA,GAAmBC,mBAAAA,YAAAA,EACtB,QAAiB;EAClB,MAAM,UAAU,gBAAgB,QAAQ,IAAK,GAAI;EACjD,IAAK,SAAU;GACd,aAAc,OAAQ;GACtB,gBAAgB,QAAQ,OAAQ,GAAI;EACrC;EACA,iBAAmB,YAClB,QAAQ,QAAU,SAAU,KAAK,QAAQ,GAAI,CAC9C;EACA,iBAAiB,QAAQ,OAAQ,GAAI;CACtC,GACA,CAAE,gBAAiB,CACpB;CAEA,MAAM,wBAAA,GAAuBA,mBAAAA,YAAAA,EAC1B,QAAiB;EAClB,IAAK,gBAAgB,QAAQ,IAAK,GAAI,GACrC;EAED,MAAM,UAAU,iBAAkB;GACjC,gBAAgB,QAAQ,OAAQ,GAAI;GACpC,iBAAkB,GAAI;EACvB,GAAG,sBAAuB;EAC1B,gBAAgB,QAAQ,IAAK,KAAK,OAAQ;CAC3C,GACA,CAAE,gBAAiB,CACpB;
|
|
1
|
+
{"version":3,"file":"use-item-exit-animation.cjs","names":["useState","useRef","useCallback","useLayoutEffect"],"sources":["../../src/shared/use-item-exit-animation.ts"],"sourcesContent":["import {\n\tuseCallback,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport type { ItemExitOverlayRect } from './item-exit-overlay';\nimport type { RectSnapshot } from './use-layout-shift-animation';\n\n/*\n * Last-resort cleanup if `animationend` never fires (the overlay's\n * `onAnimationEnd` is the primary path). Kept well above the motion\n * token durations so the timeout can never clip the exit animation.\n */\nconst EXIT_SAFETY_TIMEOUT_MS = 1000;\n\nexport type ExitingGridItem = {\n\tkey: string;\n\trect: ItemExitOverlayRect;\n\tchild: React.ReactElement;\n};\n\ntype UseItemExitAnimationOptions = {\n\tcontainer: HTMLElement | null;\n\tenabled: boolean;\n\tlayoutKeys: ReadonlySet< string >;\n\tgetPositionsBeforeLastChange: () => ReadonlyMap<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null;\n\tchildrenCacheRef: React.RefObject< Map< string, React.ReactElement > >;\n};\n\ntype UseItemExitAnimationResult = {\n\texitingItems: ExitingGridItem[];\n\thasExitingItems: boolean;\n\tclearExitingItem: ( key: string ) => void;\n};\n\nfunction prefersReducedMotion(): boolean {\n\treturn (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches\n\t);\n}\n\n/**\n * When `layout` loses keys in edit mode, keeps a short-lived overlay at\n * the removed tile's last position (scale + fade) while siblings FLIP.\n *\n * @param root0 Hook options.\n * @param root0.container Surface root that contains grid tiles.\n * @param root0.enabled When false, exiting state is cleared.\n * @param root0.layoutKeys Keys in the committed `layout` prop.\n * @param root0.getPositionsBeforeLastChange Container-relative rects before the latest layout commit.\n * @param root0.childrenCacheRef Last rendered children keyed by tile id.\n * @return Exiting overlays and a callback to dismiss one by key.\n */\nexport function useItemExitAnimation( {\n\tcontainer,\n\tenabled,\n\tlayoutKeys,\n\tgetPositionsBeforeLastChange,\n\tchildrenCacheRef,\n}: UseItemExitAnimationOptions ): UseItemExitAnimationResult {\n\tconst [ exitingItems, setExitingItems ] = useState< ExitingGridItem[] >(\n\t\t[]\n\t);\n\tconst prevLayoutKeysRef = useRef< Set< string > >( new Set() );\n\tconst exitTimeoutsRef = useRef<\n\t\tMap< string, ReturnType< typeof setTimeout > >\n\t>( new Map() );\n\n\tconst clearExitingItem = useCallback(\n\t\t( key: string ) => {\n\t\t\tconst timeout = exitTimeoutsRef.current.get( key );\n\t\t\tif ( timeout ) {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t\texitTimeoutsRef.current.delete( key );\n\t\t\t}\n\t\t\tsetExitingItems( ( current ) =>\n\t\t\t\tcurrent.filter( ( item ) => item.key !== key )\n\t\t\t);\n\t\t\tchildrenCacheRef.current.delete( key );\n\t\t},\n\t\t[ childrenCacheRef ]\n\t);\n\n\tconst scheduleExitComplete = useCallback(\n\t\t( key: string ) => {\n\t\t\tif ( exitTimeoutsRef.current.has( key ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\texitTimeoutsRef.current.delete( key );\n\t\t\t\tclearExitingItem( key );\n\t\t\t}, EXIT_SAFETY_TIMEOUT_MS );\n\t\t\texitTimeoutsRef.current.set( key, timeout );\n\t\t},\n\t\t[ clearExitingItem ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! enabled || ! container ) {\n\t\t\tprevLayoutKeysRef.current = new Set( layoutKeys );\n\t\t\tfor ( const timeout of exitTimeoutsRef.current.values() ) {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t}\n\t\t\texitTimeoutsRef.current.clear();\n\t\t\tsetExitingItems( [] );\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevKeys = prevLayoutKeysRef.current;\n\t\tconst removed: string[] = [];\n\t\tfor ( const key of prevKeys ) {\n\t\t\tif ( ! layoutKeys.has( key ) ) {\n\t\t\t\tremoved.push( key );\n\t\t\t}\n\t\t}\n\t\tprevLayoutKeysRef.current = new Set( layoutKeys );\n\n\t\tif ( removed.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lastPositions = getPositionsBeforeLastChange();\n\t\tif ( ! lastPositions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextExiting: ExitingGridItem[] = [];\n\t\tfor ( const key of removed ) {\n\t\t\tconst position = lastPositions.get( key );\n\t\t\tconst child = childrenCacheRef.current.get( key );\n\t\t\tif ( ! position || ! child ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnextExiting.push( {\n\t\t\t\tkey,\n\t\t\t\trect: position,\n\t\t\t\tchild,\n\t\t\t} );\n\t\t}\n\n\t\tif ( nextExiting.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion() ) {\n\t\t\t// Siblings snap into place via the layout-shift hook; skip the\n\t\t\t// exit ghost (and its synchronous mount) entirely.\n\t\t\tfor ( const { key } of nextExiting ) {\n\t\t\t\tchildrenCacheRef.current.delete( key );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// A state update inside a layout effect is flushed before paint,\n\t\t// so the ghost mounts in the same frame the tile is removed.\n\t\tsetExitingItems( ( current ) => [ ...current, ...nextExiting ] );\n\n\t\tfor ( const { key } of nextExiting ) {\n\t\t\tscheduleExitComplete( key );\n\t\t}\n\t}, [\n\t\tcontainer,\n\t\tenabled,\n\t\tgetPositionsBeforeLastChange,\n\t\tlayoutKeys,\n\t\tchildrenCacheRef,\n\t\tscheduleExitComplete,\n\t] );\n\n\tuseLayoutEffect( () => {\n\t\tconst exitTimeouts = exitTimeoutsRef.current;\n\t\treturn () => {\n\t\t\tfor ( const timeout of exitTimeouts.values() ) {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t}\n\t\t\texitTimeouts.clear();\n\t\t};\n\t}, [] );\n\n\treturn {\n\t\texitingItems,\n\t\thasExitingItems: exitingItems.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AgB,QAAQ,MAAM;GAC9B,gBAAiB,CAAC,CAAE;GACpB;EACD;EAEA,MAAM,WAAW,kBAAkB;EACnC,MAAM,UAAoB,CAAC;EAC3B,KAAM,MAAM,OAAO,UAClB,IAAK,CAAE,WAAW,IAAK,GAAI,GAC1B,QAAQ,KAAM,GAAI;EAGpB,kBAAkB,UAAU,IAAI,IAAK,UAAW;EAEhD,IAAK,QAAQ,WAAW,GACvB;EAGD,MAAM,gBAAgB,6BAA6B;EACnD,IAAK,CAAE,eACN;EAGD,MAAM,cAAiC,CAAC;EACxC,KAAM,MAAM,OAAO,SAAU;GAC5B,MAAM,WAAW,cAAc,IAAK,GAAI;GACxC,MAAM,QAAQ,iBAAiB,QAAQ,IAAK,GAAI;GAChD,IAAK,CAAE,YAAY,CAAE,OACpB;GAED,YAAY,KAAM;IACjB;IACA,MAAM;IACN;GACD,CAAE;EACH;EAEA,IAAK,YAAY,WAAW,GAC3B;EAGD,IAAK,qBAAqB,GAAI;GAG7B,KAAM,MAAM,EAAE,SAAS,aACtB,iBAAiB,QAAQ,OAAQ,GAAI;GAEtC;EACD;EAIA,iBAAmB,YAAa,CAAE,GAAG,SAAS,GAAG,WAAY,CAAE;EAE/D,KAAM,MAAM,EAAE,SAAS,aACtB,qBAAsB,GAAI;CAE5B,GAAG;EACF;EACA;EACA;EACA;EACA;EACA;CACD,CAAE;CAEFA,CAAAA,GAAAA,mBAAAA,gBAAAA,OAAuB;EACtB,MAAM,eAAe,gBAAgB;EACrC,aAAa;GACZ,KAAM,MAAM,WAAW,aAAa,OAAO,GAC1C,aAAc,OAAQ;GAEvB,aAAa,MAAM;EACpB;CACD,GAAG,CAAC,CAAE;CAEN,OAAO;EACN;EACA,iBAAiB,aAAa,SAAS;EACvC;CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-layout-shift-animation.cjs","names":["GRID_ITEM_DATA_KEY","useRef","useCallback"],"sources":["../../src/shared/use-layout-shift-animation.ts"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef } from '@wordpress/element';\nimport { GRID_ITEM_DATA_KEY } from './grid-item-key';\n\n/* `left`/`top` are relative to the grid container, not the viewport. */\nexport type RectSnapshot = {\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n};\n\ntype UseLayoutShiftAnimationOptions = {\n\t/**\n\t * Surface root that contains grid tiles.\n\t */\n\tcontainer: HTMLElement | null;\n\n\t/**\n\t * When false, snapshots are cleared and no transforms run.\n\t */\n\tenabled: boolean;\n\n\t/**\n\t * Serialized layout/placement state. The hook runs FLIP when this\n\t * value changes while `enabled` is true.\n\t */\n\tlayoutFingerprint: string;\n\n\t/**\n\t * Item key to skip (the tile being dragged or resized).\n\t */\n\texcludeItemKey?: string | null;\n};\n\ntype UseLayoutShiftAnimationResult = {\n\t/**\n\t * Capture tile positions synchronously **before** a layout update\n\t * (call immediately before `setTemporaryLayout` / similar).\n\t */\n\tcaptureLayoutSnapshot: () => void;\n\n\t/**\n\t * Container-relative rects from the last committed paint (settled, no\n\t * FLIP invert transforms).\n\t */\n\tgetLastPositions: () => ReadonlyMap< string, RectSnapshot > | null;\n\n\t/**\n\t * Tile positions immediately before the latest layout commit. Used\n\t * by item-exit animation when keys drop out of `layout`.\n\t */\n\tgetPositionsBeforeLastChange: () => ReadonlyMap<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null;\n};\n\nfunction queryGridItems( container: HTMLElement ): HTMLElement[] {\n\treturn Array.from(\n\t\tcontainer.querySelectorAll< HTMLElement >(\n\t\t\t`[${ GRID_ITEM_DATA_KEY }]:not([data-wp-grid-item-exiting])`\n\t\t)\n\t);\n}\n\nfunction readItemKey( element: HTMLElement ): string | null {\n\treturn element.getAttribute( GRID_ITEM_DATA_KEY );\n}\n\nfunction snapshotPositions(\n\tcontainer: HTMLElement\n): Map< string, RectSnapshot > {\n\t// Measure relative to the container so positions stay valid even if the\n\t// page scroll shifts between capture and use (e.g. the document reflowing\n\t// shorter after a tile is removed).\n\tconst base = container.getBoundingClientRect();\n\tconst positions = new Map< string, RectSnapshot >();\n\tfor ( const element of queryGridItems( container ) ) {\n\t\tconst key = readItemKey( element );\n\t\tif ( ! key ) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst { left, top, width, height } = element.getBoundingClientRect();\n\t\tpositions.set( key, {\n\t\t\tleft: left - base.left,\n\t\t\ttop: top - base.top,\n\t\t\twidth,\n\t\t\theight,\n\t\t} );\n\t}\n\treturn positions;\n}\n\nfunction clearLayoutShiftStyles( element: HTMLElement ): void {\n\telement.style.removeProperty( 'transform' );\n\telement.style.removeProperty( 'transition' );\n}\n\nfunction playLayoutShift(\n\telement: HTMLElement,\n\tdeltaX: number,\n\tdeltaY: number\n): void {\n\tif ( deltaX === 0 && deltaY === 0 ) {\n\t\treturn;\n\t}\n\n\t// Invert: show the tile where it was before the layout change.\n\telement.style.transition = 'none';\n\telement.style.transform = `translate(${ deltaX }px, ${ deltaY }px)`;\n\tvoid element.offsetHeight;\n\n\t// Play on the next frame so the inverted transform paints before\n\t// the transition back to the committed grid position.\n\trequestAnimationFrame( () => {\n\t\telement.style.removeProperty( 'transition' );\n\t\telement.style.transform = '';\n\n\t\tconst onTransitionEnd = ( event: TransitionEvent ) => {\n\t\t\tif ( event.propertyName !== 'transform' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telement.removeEventListener( 'transitionend', onTransitionEnd );\n\t\t\tclearLayoutShiftStyles( element );\n\t\t};\n\t\telement.addEventListener( 'transitionend', onTransitionEnd );\n\t} );\n}\n\n/**\n * Animates sibling tiles when grid layout reflows during drag or resize\n * using a FLIP transform (see `layout-shift-animation.module.css`).\n *\n * @param root0 Hook options.\n * @param root0.container Surface root that contains grid tiles.\n * @param root0.enabled When false, snapshots are cleared and no transforms run.\n * @param root0.layoutFingerprint Serialized layout/placement state.\n * @param root0.excludeItemKey Item key to skip (the tile being dragged or resized).\n * @return Snapshot capture callback for use before layout updates.\n */\nexport function useLayoutShiftAnimation( {\n\tcontainer,\n\tenabled,\n\tlayoutFingerprint,\n\texcludeItemKey = null,\n}: UseLayoutShiftAnimationOptions ): UseLayoutShiftAnimationResult {\n\tconst snapshotBeforeChangeRef = useRef< Map<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null >( null );\n\tconst lastRenderedPositionsRef = useRef< Map<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null >( null );\n\tconst positionsBeforeLastChangeRef = useRef< Map<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null >( null );\n\n\tconst captureLayoutSnapshot = useCallback( () => {\n\t\tif ( container ) {\n\t\t\tsnapshotBeforeChangeRef.current = snapshotPositions( container );\n\t\t}\n\t}, [ container ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! container || ! enabled ) {\n\t\t\tsnapshotBeforeChangeRef.current = null;\n\t\t\tlastRenderedPositionsRef.current = null;\n\t\t\tpositionsBeforeLastChangeRef.current = null;\n\t\t\tif ( container ) {\n\t\t\t\tfor ( const element of queryGridItems( container ) ) {\n\t\t\t\t\tclearLayoutShiftStyles( element );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( const element of queryGridItems( container ) ) {\n\t\t\tclearLayoutShiftStyles( element );\n\t\t}\n\n\t\tconst previous =\n\t\t\tsnapshotBeforeChangeRef.current ?? lastRenderedPositionsRef.current;\n\t\tsnapshotBeforeChangeRef.current = null;\n\n\t\tpositionsBeforeLastChangeRef.current = previous\n\t\t\t? new Map( previous )\n\t\t\t: null;\n\n\t\t// Record settled grid positions for the next FLIP. Must run before\n\t\t// invert transforms — measuring after `playLayoutShift` would bake\n\t\t// translate offsets into the baseline and skew the next animation.\n\t\tlastRenderedPositionsRef.current = snapshotPositions( container );\n\n\t\tif ( previous ) {\n\t\t\tconst base = container.getBoundingClientRect();\n\t\t\tfor ( const element of queryGridItems( container ) ) {\n\t\t\t\tconst key = readItemKey( element );\n\t\t\t\tif ( ! key || key === excludeItemKey ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst old = previous.get( key );\n\t\t\t\tif ( ! old ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst { left, top } = element.getBoundingClientRect();\n\t\t\t\tconst deltaX = old.left - ( left - base.left );\n\t\t\t\tconst deltaY = old.top - ( top - base.top );\n\t\t\t\tplayLayoutShift( element, deltaX, deltaY );\n\t\t\t}\n\t\t}\n\t}, [ container, enabled, layoutFingerprint, excludeItemKey ] );\n\n\tconst getLastPositions = useCallback( () => {\n\t\treturn lastRenderedPositionsRef.current;\n\t}, [] );\n\n\tconst getPositionsBeforeLastChange = useCallback( () => {\n\t\treturn positionsBeforeLastChangeRef.current;\n\t}, [] );\n\n\treturn {\n\t\tcaptureLayoutSnapshot,\n\t\tgetLastPositions,\n\t\tgetPositionsBeforeLastChange,\n\t};\n}\n\n/**\n * Stable fingerprint for {@link useLayoutShiftAnimation}. Width/height\n * values may be numbers or layout keywords (`'fill'`, `'full'`).\n *\n * @param layout Layout items to serialize.\n * @return Fingerprint string.\n */\nexport function getLayoutFingerprint(\n\tlayout: ReadonlyArray< {\n\t\tkey: string;\n\t\twidth?: number | string;\n\t\theight?: number;\n\t\torder?: number;\n\t\tlane?: number;\n\t} >\n): string {\n\treturn layout\n\t\t.map(\n\t\t\t( item ) =>\n\t\t\t\t`${ item.key }:${ String( item.width ?? '' ) }:${\n\t\t\t\t\titem.height ?? 1\n\t\t\t\t}:${ item.order ?? '' }:${ item.lane ?? '' }`\n\t\t)\n\t\t.join( '|' );\n}\n\n/**\n * Placement fingerprint for lanes polyfill / explicit grid positions.\n *\n * @param itemStyles Per-item inline placement styles.\n * @return Fingerprint string.\n */\nexport function getPlacementFingerprint(\n\titemStyles: Map< string, React.CSSProperties >\n): string {\n\treturn [ ...itemStyles.entries() ]\n\t\t.sort( ( [ a ], [ b ] ) => a.localeCompare( b ) )\n\t\t.map( ( [ key, style ] ) => {\n\t\t\tconst column = style.gridColumn ?? '';\n\t\t\tconst columnStart = style.gridColumnStart ?? '';\n\t\t\tconst rowStart = style.gridRowStart ?? '';\n\t\t\tconst rowEnd = style.gridRowEnd ?? '';\n\t\t\treturn `${ key }:${ String( column ) }:${ String(\n\t\t\t\tcolumnStart\n\t\t\t) }:${ String( rowStart ) }:${ String( rowEnd ) }`;\n\t\t} )\n\t\t.join( '|' );\n}\n"],"mappings":";;;;;;;;AAyDA,SAAS,eAAgB,WAAwC;CAChE,OAAO,MAAM,KACZ,UAAU,iBACT,IAAKA,mBAAAA,mBAAoB,mCAC1B,CACD;AACD;AAEA,SAAS,YAAa,SAAsC;CAC3D,OAAO,QAAQ,aAAcA,mBAAAA,kBAAmB;AACjD;AAEA,SAAS,kBACR,WAC8B;CAI9B,MAAM,OAAO,UAAU,sBAAsB;CAC7C,MAAM,4BAAY,IAAI,IAA4B;CAClD,KAAM,MAAM,WAAW,eAAgB,SAAU,GAAI;EACpD,MAAM,MAAM,YAAa,OAAQ;EACjC,IAAK,CAAE,KACN;EAED,MAAM,EAAE,MAAM,KAAK,OAAO,WAAW,QAAQ,sBAAsB;EACnE,UAAU,IAAK,KAAK;GACnB,MAAM,OAAO,KAAK;GAClB,KAAK,MAAM,KAAK;GAChB;GACA;EACD,CAAE;CACH;CACA,OAAO;AACR;AAEA,SAAS,uBAAwB,SAA6B;CAC7D,QAAQ,MAAM,eAAgB,WAAY;CAC1C,QAAQ,MAAM,eAAgB,YAAa;AAC5C;AAEA,SAAS,gBACR,SACA,QACA,QACO;CACP,IAAK,WAAW,KAAK,WAAW,GAC/B;CAID,QAAQ,MAAM,aAAa;CAC3B,QAAQ,MAAM,YAAY,aAAc,OAAQ,MAAO,OAAQ;CAC/D,QAAa;CAIb,4BAA6B;EAC5B,QAAQ,MAAM,eAAgB,YAAa;EAC3C,QAAQ,MAAM,YAAY;EAE1B,MAAM,mBAAoB,UAA4B;GACrD,IAAK,MAAM,iBAAiB,aAC3B;GAED,QAAQ,oBAAqB,iBAAiB,eAAgB;GAC9D,uBAAwB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CACD,GAAG;EAAE;EAAW;EAAS;EAAmB;CAAe,CAAE;CAU7D,OAAO;EACN;EACA,mBAAA,GAVwBA,mBAAAA,YAAAA,OAAmB;GAC3C,OAAO,yBAAyB;EACjC,GAAG,CAAC,CAQY;EACf,+BAAA,GAPoCA,mBAAAA,YAAAA,OAAmB;GACvD,OAAO,6BAA6B;EACrC,GAAG,CAAC,CAKwB;CAC5B;AACD;;;;;;;;AASA,SAAgB,qBACf,QAOS;CACT,OAAO,OACL,KACE,SACD,GAAI,KAAK,IAAK,GAAI,OAAQ,KAAK,SAAS,EAAG,EAAG,GAC7C,KAAK,UAAU,EACf,GAAI,KAAK,SAAS,GAAI,GAAI,KAAK,QAAQ,IAC1C,CAAC,CACA,KAAM,GAAI;AACb;;;;;;;AAQA,SAAgB,wBACf,YACS;CACT,OAAO,CAAE,GAAG,WAAW,QAAQ,CAAE,CAAC,CAChC,MAAQ,CAAE,IAAK,CAAE,OAAS,EAAE,cAAe,CAAE,CAAE,CAAC,CAChD,KAAO,CAAE,KAAK,WAAa;EAC3B,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,cAAc,MAAM,mBAAmB;EAC7C,MAAM,WAAW,MAAM,gBAAgB;EACvC,MAAM,SAAS,MAAM,cAAc;EACnC,OAAO,GAAI,IAAK,GAAI,OAAQ,MAAO,EAAG,GAAI,OACzC,WACD,EAAG,GAAI,OAAQ,QAAS,EAAG,GAAI,OAAQ,MAAO;CAC/C,CAAE,CAAC,CACF,KAAM,GAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"use-layout-shift-animation.cjs","names":["GRID_ITEM_DATA_KEY","useRef","useCallback","useLayoutEffect"],"sources":["../../src/shared/use-layout-shift-animation.ts"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef } from '@wordpress/element';\nimport { GRID_ITEM_DATA_KEY } from './grid-item-key';\n\n/* `left`/`top` are relative to the grid container, not the viewport. */\nexport type RectSnapshot = {\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n};\n\ntype UseLayoutShiftAnimationOptions = {\n\t/**\n\t * Surface root that contains grid tiles.\n\t */\n\tcontainer: HTMLElement | null;\n\n\t/**\n\t * When false, snapshots are cleared and no transforms run.\n\t */\n\tenabled: boolean;\n\n\t/**\n\t * Serialized layout/placement state. The hook runs FLIP when this\n\t * value changes while `enabled` is true.\n\t */\n\tlayoutFingerprint: string;\n\n\t/**\n\t * Item key to skip (the tile being dragged or resized).\n\t */\n\texcludeItemKey?: string | null;\n};\n\ntype UseLayoutShiftAnimationResult = {\n\t/**\n\t * Capture tile positions synchronously **before** a layout update\n\t * (call immediately before `setTemporaryLayout` / similar).\n\t */\n\tcaptureLayoutSnapshot: () => void;\n\n\t/**\n\t * Container-relative rects from the last committed paint (settled, no\n\t * FLIP invert transforms).\n\t */\n\tgetLastPositions: () => ReadonlyMap< string, RectSnapshot > | null;\n\n\t/**\n\t * Tile positions immediately before the latest layout commit. Used\n\t * by item-exit animation when keys drop out of `layout`.\n\t */\n\tgetPositionsBeforeLastChange: () => ReadonlyMap<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null;\n};\n\nfunction queryGridItems( container: HTMLElement ): HTMLElement[] {\n\treturn Array.from(\n\t\tcontainer.querySelectorAll< HTMLElement >(\n\t\t\t`[${ GRID_ITEM_DATA_KEY }]:not([data-wp-grid-item-exiting])`\n\t\t)\n\t);\n}\n\nfunction readItemKey( element: HTMLElement ): string | null {\n\treturn element.getAttribute( GRID_ITEM_DATA_KEY );\n}\n\nfunction snapshotPositions(\n\tcontainer: HTMLElement\n): Map< string, RectSnapshot > {\n\t// Measure relative to the container so positions stay valid even if the\n\t// page scroll shifts between capture and use (e.g. the document reflowing\n\t// shorter after a tile is removed).\n\tconst base = container.getBoundingClientRect();\n\tconst positions = new Map< string, RectSnapshot >();\n\tfor ( const element of queryGridItems( container ) ) {\n\t\tconst key = readItemKey( element );\n\t\tif ( ! key ) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst { left, top, width, height } = element.getBoundingClientRect();\n\t\tpositions.set( key, {\n\t\t\tleft: left - base.left,\n\t\t\ttop: top - base.top,\n\t\t\twidth,\n\t\t\theight,\n\t\t} );\n\t}\n\treturn positions;\n}\n\nfunction clearLayoutShiftStyles( element: HTMLElement ): void {\n\telement.style.removeProperty( 'transform' );\n\telement.style.removeProperty( 'transition' );\n}\n\nfunction playLayoutShift(\n\telement: HTMLElement,\n\tdeltaX: number,\n\tdeltaY: number\n): void {\n\tif ( deltaX === 0 && deltaY === 0 ) {\n\t\treturn;\n\t}\n\n\t// Invert: show the tile where it was before the layout change.\n\telement.style.transition = 'none';\n\telement.style.transform = `translate(${ deltaX }px, ${ deltaY }px)`;\n\tvoid element.offsetHeight;\n\n\t// Play on the next frame so the inverted transform paints before\n\t// the transition back to the committed grid position.\n\trequestAnimationFrame( () => {\n\t\telement.style.removeProperty( 'transition' );\n\t\telement.style.transform = '';\n\n\t\tconst onTransitionEnd = ( event: TransitionEvent ) => {\n\t\t\tif ( event.propertyName !== 'transform' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telement.removeEventListener( 'transitionend', onTransitionEnd );\n\t\t\tclearLayoutShiftStyles( element );\n\t\t};\n\t\telement.addEventListener( 'transitionend', onTransitionEnd );\n\t} );\n}\n\n/**\n * Animates sibling tiles when grid layout reflows during drag or resize\n * using a FLIP transform (see `layout-shift-animation.module.css`).\n *\n * @param root0 Hook options.\n * @param root0.container Surface root that contains grid tiles.\n * @param root0.enabled When false, snapshots are cleared and no transforms run.\n * @param root0.layoutFingerprint Serialized layout/placement state.\n * @param root0.excludeItemKey Item key to skip (the tile being dragged or resized).\n * @return Snapshot capture callback for use before layout updates.\n */\nexport function useLayoutShiftAnimation( {\n\tcontainer,\n\tenabled,\n\tlayoutFingerprint,\n\texcludeItemKey = null,\n}: UseLayoutShiftAnimationOptions ): UseLayoutShiftAnimationResult {\n\tconst snapshotBeforeChangeRef = useRef< Map<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null >( null );\n\tconst lastRenderedPositionsRef = useRef< Map<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null >( null );\n\tconst positionsBeforeLastChangeRef = useRef< Map<\n\t\tstring,\n\t\tRectSnapshot\n\t> | null >( null );\n\n\tconst captureLayoutSnapshot = useCallback( () => {\n\t\tif ( container ) {\n\t\t\tsnapshotBeforeChangeRef.current = snapshotPositions( container );\n\t\t}\n\t}, [ container ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! container || ! enabled ) {\n\t\t\tsnapshotBeforeChangeRef.current = null;\n\t\t\tlastRenderedPositionsRef.current = null;\n\t\t\tpositionsBeforeLastChangeRef.current = null;\n\t\t\tif ( container ) {\n\t\t\t\tfor ( const element of queryGridItems( container ) ) {\n\t\t\t\t\tclearLayoutShiftStyles( element );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( const element of queryGridItems( container ) ) {\n\t\t\tclearLayoutShiftStyles( element );\n\t\t}\n\n\t\tconst previous =\n\t\t\tsnapshotBeforeChangeRef.current ?? lastRenderedPositionsRef.current;\n\t\tsnapshotBeforeChangeRef.current = null;\n\n\t\tpositionsBeforeLastChangeRef.current = previous\n\t\t\t? new Map( previous )\n\t\t\t: null;\n\n\t\t// Record settled grid positions for the next FLIP. Must run before\n\t\t// invert transforms — measuring after `playLayoutShift` would bake\n\t\t// translate offsets into the baseline and skew the next animation.\n\t\tlastRenderedPositionsRef.current = snapshotPositions( container );\n\n\t\tif ( previous ) {\n\t\t\tconst base = container.getBoundingClientRect();\n\t\t\tfor ( const element of queryGridItems( container ) ) {\n\t\t\t\tconst key = readItemKey( element );\n\t\t\t\tif ( ! key || key === excludeItemKey ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst old = previous.get( key );\n\t\t\t\tif ( ! old ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst { left, top } = element.getBoundingClientRect();\n\t\t\t\tconst deltaX = old.left - ( left - base.left );\n\t\t\t\tconst deltaY = old.top - ( top - base.top );\n\t\t\t\tplayLayoutShift( element, deltaX, deltaY );\n\t\t\t}\n\t\t}\n\t}, [ container, enabled, layoutFingerprint, excludeItemKey ] );\n\n\tconst getLastPositions = useCallback( () => {\n\t\treturn lastRenderedPositionsRef.current;\n\t}, [] );\n\n\tconst getPositionsBeforeLastChange = useCallback( () => {\n\t\treturn positionsBeforeLastChangeRef.current;\n\t}, [] );\n\n\treturn {\n\t\tcaptureLayoutSnapshot,\n\t\tgetLastPositions,\n\t\tgetPositionsBeforeLastChange,\n\t};\n}\n\n/**\n * Stable fingerprint for {@link useLayoutShiftAnimation}. Width/height\n * values may be numbers or layout keywords (`'fill'`, `'full'`).\n *\n * @param layout Layout items to serialize.\n * @return Fingerprint string.\n */\nexport function getLayoutFingerprint(\n\tlayout: ReadonlyArray< {\n\t\tkey: string;\n\t\twidth?: number | string;\n\t\theight?: number;\n\t\torder?: number;\n\t\tlane?: number;\n\t} >\n): string {\n\treturn layout\n\t\t.map(\n\t\t\t( item ) =>\n\t\t\t\t`${ item.key }:${ String( item.width ?? '' ) }:${\n\t\t\t\t\titem.height ?? 1\n\t\t\t\t}:${ item.order ?? '' }:${ item.lane ?? '' }`\n\t\t)\n\t\t.join( '|' );\n}\n\n/**\n * Placement fingerprint for lanes polyfill / explicit grid positions.\n *\n * @param itemStyles Per-item inline placement styles.\n * @return Fingerprint string.\n */\nexport function getPlacementFingerprint(\n\titemStyles: Map< string, React.CSSProperties >\n): string {\n\treturn [ ...itemStyles.entries() ]\n\t\t.sort( ( [ a ], [ b ] ) => a.localeCompare( b ) )\n\t\t.map( ( [ key, style ] ) => {\n\t\t\tconst column = style.gridColumn ?? '';\n\t\t\tconst columnStart = style.gridColumnStart ?? '';\n\t\t\tconst rowStart = style.gridRowStart ?? '';\n\t\t\tconst rowEnd = style.gridRowEnd ?? '';\n\t\t\treturn `${ key }:${ String( column ) }:${ String(\n\t\t\t\tcolumnStart\n\t\t\t) }:${ String( rowStart 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AA,GAPoCA,mBAAAA,YAAAA,OAAmB;GACvD,OAAO,6BAA6B;EACrC,GAAG,CAAC,CAKwB;CAC5B;AACD;;;;;;;;AASA,SAAgB,qBACf,QAOS;CACT,OAAO,OACL,KACE,SACD,GAAI,KAAK,IAAK,GAAI,OAAQ,KAAK,SAAS,EAAG,EAAG,GAC7C,KAAK,UAAU,EACf,GAAI,KAAK,SAAS,GAAI,GAAI,KAAK,QAAQ,IAC1C,CAAC,CACA,KAAM,GAAI;AACb;;;;;;;AAQA,SAAgB,wBACf,YACS;CACT,OAAO,CAAE,GAAG,WAAW,QAAQ,CAAE,CAAC,CAChC,MAAQ,CAAE,IAAK,CAAE,OAAS,EAAE,cAAe,CAAE,CAAE,CAAC,CAChD,KAAO,CAAE,KAAK,WAAa;EAC3B,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,cAAc,MAAM,mBAAmB;EAC7C,MAAM,WAAW,MAAM,gBAAgB;EACvC,MAAM,SAAS,MAAM,cAAc;EACnC,OAAO,GAAI,IAAK,GAAI,OAAQ,MAAO,EAAG,GAAI,OACzC,WACD,EAAG,GAAI,OAAQ,QAAS,EAAG,GAAI,OAAQ,MAAO;CAC/C,CAAE,CAAC,CACF,KAAM,GAAI;AACb"}
|
|
@@ -120,17 +120,17 @@ function registerStyle(hash, css) {
|
|
|
120
120
|
// packages/grid/src/shared/layout-shift-animation.module.css
|
|
121
121
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("5d10111ab0", ".c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1))}@media (prefers-reduced-motion:reduce){.c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:none}}");
|
|
122
122
|
var layout_shift_animation_module_default = { "layout-animating": "c68bb75eb6bf717a__layout-animating" };
|
|
123
|
-
// packages/grid/src/dashboard-grid/grid.module.
|
|
124
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("
|
|
123
|
+
// packages/grid/src/dashboard-grid/grid.module.scss
|
|
124
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("1271e09bea", ".accd954e27a87edd__grid{display:grid;gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));position:relative}._7eb716cb5b0b9243__drag-preview-frame{border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);cursor:grabbing;height:100%;pointer-events:none}._81f4b86c021354df__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame{animation:ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}._81f4b86c021354df__drag-preview-frame__lift{animation:_839f03e3bf8089bd__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter{0%{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}to{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}}@keyframes _839f03e3bf8089bd__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{animation:ca01d09b92c08943__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{animation:a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes ca01d09b92c08943__wp-grid-drag-preview-shadow-exit{0%{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}to{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}}@keyframes a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}._81f4b86c021354df__drag-preview-frame__lift{transform:none}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);transition:none}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{transition:none}}");
|
|
125
125
|
var grid_module_default = {
|
|
126
|
-
"grid": "
|
|
127
|
-
"drag-preview-frame": "
|
|
128
|
-
"drag-preview-frame__lift": "
|
|
129
|
-
"wp-grid-drag-preview-shadow-enter": "
|
|
130
|
-
"wp-grid-drag-preview-scale-enter": "
|
|
131
|
-
"is-exiting": "
|
|
132
|
-
"wp-grid-drag-preview-shadow-exit": "
|
|
133
|
-
"wp-grid-drag-preview-scale-exit": "
|
|
126
|
+
"grid": "accd954e27a87edd__grid",
|
|
127
|
+
"drag-preview-frame": "_7eb716cb5b0b9243__drag-preview-frame",
|
|
128
|
+
"drag-preview-frame__lift": "_81f4b86c021354df__drag-preview-frame__lift",
|
|
129
|
+
"wp-grid-drag-preview-shadow-enter": "ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter",
|
|
130
|
+
"wp-grid-drag-preview-scale-enter": "_839f03e3bf8089bd__wp-grid-drag-preview-scale-enter",
|
|
131
|
+
"is-exiting": "_19afc579bbe6da9a__is-exiting",
|
|
132
|
+
"wp-grid-drag-preview-shadow-exit": "ca01d09b92c08943__wp-grid-drag-preview-shadow-exit",
|
|
133
|
+
"wp-grid-drag-preview-scale-exit": "a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit"
|
|
134
134
|
};
|
|
135
135
|
// packages/grid/src/dashboard-grid/index.tsx
|
|
136
136
|
const dashboardDragDropAnimation = createDashboardDragDropAnimation(grid_module_default["drag-preview-frame"], grid_module_default["is-exiting"]);
|
|
@@ -382,7 +382,7 @@ const DashboardGrid = forwardRef(function UnforwardedDashboardGrid(props, ref) {
|
|
|
382
382
|
}
|
|
383
383
|
const baseline = resizeBaselineRef.current;
|
|
384
384
|
const newWidth = clampSpan(baseline.width + relativeDelta.width, bounds?.minWidth ?? 1, bounds?.maxWidth ?? effectiveColumns);
|
|
385
|
-
const newHeight = clampSpan(baseline.height + relativeDelta.height, bounds?.minHeight ?? 1, bounds?.maxHeight ??
|
|
385
|
+
const newHeight = clampSpan(baseline.height + relativeDelta.height, bounds?.minHeight ?? 1, bounds?.maxHeight ?? 1e400);
|
|
386
386
|
setResizeSnapPreview({
|
|
387
387
|
id,
|
|
388
388
|
snap: gridSpanToPixelSize(newWidth, newHeight, columnWidth, gapPx, rowHeightPx)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["styles","layoutAnimationStyles"],"sources":["../../../style-runtime/src/index.ts","../../src/shared/layout-shift-animation.module.css","../../src/dashboard-grid/grid.module.css","../../src/dashboard-grid/index.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"5d10111ab0\", \".c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1))}@media (prefers-reduced-motion:reduce){.c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:none}}\");\n}\nexport default {\"layout-animating\":\"c68bb75eb6bf717a__layout-animating\"};\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"38b90762ee\", \"._21f1954f75f72766__grid{display:grid;gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));position:relative}.e464fb19a38466c5__drag-preview-frame{--_wp-grid-elevation-xs:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);--_wp-grid-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:var(--_wp-grid-elevation-md);cursor:grabbing;height:100%;pointer-events:none}.da244be067f8f335__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){.e464fb19a38466c5__drag-preview-frame{animation:_1c00dcb154fe518d__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}.da244be067f8f335__drag-preview-frame__lift{animation:ef2aa0b981f2c744__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes _1c00dcb154fe518d__wp-grid-drag-preview-shadow-enter{0%{box-shadow:var(--_wp-grid-elevation-xs)}to{box-shadow:var(--_wp-grid-elevation-md)}}@keyframes ef2aa0b981f2c744__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting{animation:f1ccc9200b4579c4__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting .da244be067f8f335__drag-preview-frame__lift{animation:c84abadc2143eb8a__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes f1ccc9200b4579c4__wp-grid-drag-preview-shadow-exit{0%{box-shadow:var(--_wp-grid-elevation-md)}to{box-shadow:var(--_wp-grid-elevation-xs)}}@keyframes c84abadc2143eb8a__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting{box-shadow:var(--_wp-grid-elevation-xs)}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting .da244be067f8f335__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){.e464fb19a38466c5__drag-preview-frame{box-shadow:var(--_wp-grid-elevation-md)}.da244be067f8f335__drag-preview-frame__lift{transform:none}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting{box-shadow:var(--_wp-grid-elevation-xs);transition:none}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting .da244be067f8f335__drag-preview-frame__lift{transition:none}}\");\n}\nexport default {\"grid\":\"_21f1954f75f72766__grid\",\"drag-preview-frame\":\"e464fb19a38466c5__drag-preview-frame\",\"drag-preview-frame__lift\":\"da244be067f8f335__drag-preview-frame__lift\",\"wp-grid-drag-preview-shadow-enter\":\"_1c00dcb154fe518d__wp-grid-drag-preview-shadow-enter\",\"wp-grid-drag-preview-scale-enter\":\"ef2aa0b981f2c744__wp-grid-drag-preview-scale-enter\",\"is-exiting\":\"_4a025da98b54c1dc__is-exiting\",\"wp-grid-drag-preview-shadow-exit\":\"f1ccc9200b4579c4__wp-grid-drag-preview-shadow-exit\",\"wp-grid-drag-preview-scale-exit\":\"c84abadc2143eb8a__wp-grid-drag-preview-scale-exit\"};\n","import {\n\tDndContext,\n\tDragOverlay,\n\tKeyboardSensor,\n\tPointerSensor,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core';\nimport {\n\tSortableContext,\n\tsortableKeyboardCoordinates,\n} from '@dnd-kit/sortable';\nimport type { DragMoveEvent, DragStartEvent } from '@dnd-kit/core';\nimport clsx from 'clsx';\nimport { useResizeObserver, useEvent, useMergeRefs } from '@wordpress/compose';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tChildren,\n\tcloneElement,\n\tisValidElement,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { GridItem } from './grid-item';\nimport { arrayMoveWithPinned } from '../shared/array-move-with-pinned';\nimport { resolveColumnCount } from '../shared/column-policy';\nimport { GridOverlay } from '../shared/grid-overlay';\nimport { clampSpan, gridSpanToPixelSize } from '../shared/resize-snap';\nimport { useResizePixelLimits, useSpanBounds } from '../shared/use-span-bounds';\nimport layoutAnimationStyles from '../shared/layout-shift-animation.module.css';\nimport { ItemExitOverlay } from '../shared/item-exit-overlay';\nimport {\n\tgetLayoutFingerprint,\n\tuseLayoutShiftAnimation,\n} from '../shared/use-layout-shift-animation';\nimport { useItemExitAnimation } from '../shared/use-item-exit-animation';\nimport { resolveFillWidths } from './resolve-fill-widths';\nimport type { DashboardGridLayoutItem, DashboardGridProps } from './types';\nimport type { ResizeSnapSize } from '../shared/resize-snap';\nimport type { ResizeDelta } from '../shared/types';\nimport { createDashboardDragDropAnimation } from '../shared/drag-overlay-drop-animation';\nimport styles from './grid.module.css';\n\nconst dashboardDragDropAnimation = createDashboardDragDropAnimation(\n\tstyles[ 'drag-preview-frame' ],\n\tstyles[ 'is-exiting' ]\n);\n\n// Fallback gap in pixels for math that runs before the computed gap\n// can be read from the DOM. Matches the `'xl'` step the surface\n// resolves to in CSS (`--wpds-dimension-gap-xl`); the next layout\n// effect overwrites this with the actual computed value.\nconst FALLBACK_GAP_PX = 24;\n\n// Default column cap when no explicit `columns` or `minColumnWidth` is\n// supplied. Layered semantics: `columns` acts as a cap and\n// `minColumnWidth` as a per-tile floor; if neither is set we still\n// need a finite count to render against.\nconst DEFAULT_COLUMNS = 6;\n\n// Reorder is driven by `temporaryLayout` + CSS Grid, not by dnd-kit\n// transforms. Hoist the no-op strategy outside the component so its\n// reference is stable across renders — passing a fresh `() => null`\n// to `<SortableContext>` updates its context value and triggers all\n// `useSortable` subscribers to re-render every frame.\nconst NO_SORT_STRATEGY = () => null;\n\n/**\n * 2D packed dashboard grid with drag-to-reorder and resize handles.\n * Supports fixed-column and responsive modes, `number | 'fill' | 'full'`\n * widths, and multi-row tiles.\n *\n * Each child's `key` must match an entry in the `layout` array;\n * children without a match render at the end of the grid without\n * explicit placement and fall through CSS Grid's auto-flow.\n *\n * @example\n * ```jsx\n * const layout = [\n * { key: 'a', width: 2 },\n * { key: 'b', width: 'fill' },\n * { key: 'c', width: 'full' },\n * ];\n *\n * <DashboardGrid\n * layout={ layout }\n * columns={ 6 }\n * editMode\n * onChangeLayout={ setLayout }\n * >\n * <div key=\"a\">A</div>\n * <div key=\"b\">B</div>\n * <div key=\"c\">C</div>\n * </DashboardGrid>\n * ```\n *\n * @param props Component props.\n * @param ref Forwarded to the grid's root `<div>`.\n */\nexport const DashboardGrid = forwardRef< HTMLDivElement, DashboardGridProps >(\n\tfunction UnforwardedDashboardGrid( props, ref ) {\n\t\tconst {\n\t\t\tlayout,\n\t\t\tcolumns,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tstyle,\n\t\t\trowHeight = 'auto',\n\t\t\tminColumnWidth,\n\t\t\titemLimits,\n\t\t\teditMode = false,\n\t\t\tonChangeLayout,\n\t\t\tonPreviewLayout,\n\t\t\trenderResizeHandle,\n\t\t\trenderDragPreview,\n\t\t\trenderGridOverlay,\n\t\t\t...divProps\n\t\t} = props;\n\t\t// Preview layout applied during drag/resize before committing.\n\t\tconst [ temporaryLayout, setTemporaryLayout ] = useState<\n\t\t\tDashboardGridLayoutItem[] | undefined\n\t\t>();\n\t\t// Drives `<DragOverlay>` content while a drag is in progress.\n\t\tconst [ activeId, setActiveId ] = useState< string | null >( null );\n\t\t// True while any tile is being resized. Combined with `activeId`,\n\t\t// it drives the grid-wide `inert` flag on actionable areas so\n\t\t// hovering over another tile's buttons can't steal the gesture.\n\t\tconst [ isResizing, setIsResizing ] = useState( false );\n\t\t// Snapped span in pixels for the resize-preview outline on the\n\t\t// active tile. The tile content follows the cursor continuously;\n\t\t// this preview shows the grid size that will commit on release.\n\t\tconst [ resizeSnapPreview, setResizeSnapPreview ] = useState< {\n\t\t\tid: string;\n\t\t\tsnap: ResizeSnapSize;\n\t\t} | null >( null );\n\t\t// Mirror of `temporaryLayout` read synchronously on drag end —\n\t\t// the state update from `handleDragMove` may still be batched.\n\t\tconst latestLayoutRef = useRef< DashboardGridLayoutItem[] | undefined >(\n\t\t\tundefined\n\t\t);\n\t\t// Cursor center at the last applied reorder. Used to skip the\n\t\t// cascade of re-measured `onDragMove` events after a layout\n\t\t// change, when the cursor has not actually moved.\n\t\tconst lastReorderCursorRef = useRef< {\n\t\t\tx: number;\n\t\t\ty: number;\n\t\t} | null >( null );\n\t\t// Width/height snapshot at the start of a resize session. The\n\t\t// resize handle reports `delta` absolute from the gesture start,\n\t\t// so the baseline must stay frozen — reading from the already\n\t\t// mutated `activeLayout` would compound the delta each frame.\n\t\tconst resizeBaselineRef = useRef< {\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t} | null >( null );\n\t\tconst captureLayoutSnapshotRef = useRef< () => void >( () => {} );\n\t\tconst childrenCacheRef = useRef< Map< string, React.ReactElement > >(\n\t\t\tnew Map()\n\t\t);\n\n\t\tconst [ gridRoot, setGridRoot ] = useState< HTMLDivElement | null >(\n\t\t\tnull\n\t\t);\n\t\tconst [ containerWidth, setContainerWidth ] = useState( 0 );\n\t\tconst [ containerHeight, setContainerHeight ] = useState( 0 );\n\t\tconst [ gapPx, setGapPx ] = useState( FALLBACK_GAP_PX );\n\t\tconst resizeObserverRef = useResizeObserver(\n\t\t\t( [ { contentRect } ] ) => {\n\t\t\t\tsetContainerWidth( contentRect.width );\n\t\t\t\tsetContainerHeight( contentRect.height );\n\t\t\t}\n\t\t);\n\t\tconst mergedGridRef = useMergeRefs( [\n\t\t\tsetGridRoot,\n\t\t\tresizeObserverRef,\n\t\t\tref,\n\t\t] );\n\n\t\t// Measure before paint to avoid a single-column flash in\n\t\t// responsive mode; `useResizeObserver` delivers async. The\n\t\t// computed `column-gap` is read from the resolved CSS so the\n\t\t// math tracks the design-system token under any density.\n\t\tuseLayoutEffect( () => {\n\t\t\tif ( ! gridRoot ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { width, height } = gridRoot.getBoundingClientRect();\n\t\t\tif ( width > 0 ) {\n\t\t\t\tsetContainerWidth( width );\n\t\t\t}\n\t\t\tif ( height > 0 ) {\n\t\t\t\tsetContainerHeight( height );\n\t\t\t}\n\t\t\tconst parsed = Number.parseFloat(\n\t\t\t\twindow.getComputedStyle( gridRoot ).columnGap\n\t\t\t);\n\t\t\tif ( Number.isFinite( parsed ) && parsed > 0 ) {\n\t\t\t\tsetGapPx( parsed );\n\t\t\t}\n\t\t}, [ gridRoot ] );\n\t\tconst effectiveColumns = useMemo(\n\t\t\t() =>\n\t\t\t\tresolveColumnCount(\n\t\t\t\t\t{ columns, minColumnWidth },\n\t\t\t\t\tcontainerWidth,\n\t\t\t\t\tgapPx,\n\t\t\t\t\tDEFAULT_COLUMNS\n\t\t\t\t),\n\t\t\t[ minColumnWidth, gapPx, containerWidth, columns ]\n\t\t);\n\t\tconst columnWidth =\n\t\t\t( containerWidth - ( effectiveColumns - 1 ) * gapPx ) /\n\t\t\teffectiveColumns;\n\t\tconst minResizeWidthPx = gridSpanToPixelSize(\n\t\t\t1,\n\t\t\t1,\n\t\t\tcolumnWidth,\n\t\t\tgapPx,\n\t\t\tnull\n\t\t).widthPx;\n\t\tconst rowHeightPx = typeof rowHeight === 'number' ? rowHeight : null;\n\t\tconst minResizeHeightPx =\n\t\t\trowHeightPx === null\n\t\t\t\t? undefined\n\t\t\t\t: ( gridSpanToPixelSize( 1, 1, columnWidth, gapPx, rowHeightPx )\n\t\t\t\t\t\t.heightPx ?? undefined );\n\n\t\tconst spanBoundsByKey = useSpanBounds(\n\t\t\titemLimits,\n\t\t\tcolumnWidth,\n\t\t\tgapPx,\n\t\t\trowHeightPx,\n\t\t\teffectiveColumns\n\t\t);\n\t\tconst resizeLimitsByKey = useResizePixelLimits(\n\t\t\tspanBoundsByKey,\n\t\t\tcolumnWidth,\n\t\t\tgapPx,\n\t\t\trowHeightPx\n\t\t);\n\n\t\t// Stored and in-gesture layouts may sit outside an item's limits;\n\t\t// render them bounded while the data stays untouched. Gestures\n\t\t// commit from the stored `layout`, never from this bounded view,\n\t\t// so a bounded span cannot reach `onChangeLayout`. Keeps the\n\t\t// source identity when no item needs bounding.\n\t\tconst sourceLayout = temporaryLayout ?? layout;\n\t\tconst activeLayout = useMemo( () => {\n\t\t\tif ( spanBoundsByKey.size === 0 ) {\n\t\t\t\treturn sourceLayout;\n\t\t\t}\n\t\t\tlet changed = false;\n\t\t\tconst bounded = sourceLayout.map( ( item ) => {\n\t\t\t\tconst bounds = spanBoundsByKey.get( item.key );\n\t\t\t\tif ( ! bounds ) {\n\t\t\t\t\treturn item;\n\t\t\t\t}\n\t\t\t\tconst width =\n\t\t\t\t\ttypeof item.width === 'number'\n\t\t\t\t\t\t? clampSpan(\n\t\t\t\t\t\t\t\titem.width,\n\t\t\t\t\t\t\t\tbounds.minWidth,\n\t\t\t\t\t\t\t\tbounds.maxWidth\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: item.width;\n\t\t\t\tconst height = clampSpan(\n\t\t\t\t\titem.height ?? 1,\n\t\t\t\t\tbounds.minHeight,\n\t\t\t\t\tbounds.maxHeight\n\t\t\t\t);\n\t\t\t\tif ( width === item.width && height === ( item.height ?? 1 ) ) {\n\t\t\t\t\treturn item;\n\t\t\t\t}\n\t\t\t\tchanged = true;\n\t\t\t\treturn { ...item, width, height };\n\t\t\t} );\n\t\t\treturn changed ? bounded : sourceLayout;\n\t\t}, [ sourceLayout, spanBoundsByKey ] );\n\n\t\tconst layoutMap = useMemo( () => {\n\t\t\tconst map = new Map< string, DashboardGridLayoutItem >();\n\t\t\tactiveLayout.forEach( ( item ) => map.set( item.key, item ) );\n\t\t\treturn map;\n\t\t}, [ activeLayout ] );\n\n\t\t// Stable-identity key set, preserved across renders whenever the\n\t\t// *contents* of the key set are unchanged — even if the consumer\n\t\t// passes a fresh `layout` array reference (common when `layout`\n\t\t// is derived inline from state). Without this, downstream memos\n\t\t// would invalidate on every parent re-render and the children\n\t\t// walk skip during gestures wouldn't hold.\n\t\tconst layoutKeys = useMemo(\n\t\t\t() => new Set( layout.map( ( item ) => item.key ) ),\n\t\t\t[ layout ]\n\t\t);\n\n\t\t// Sorted item keys, identity-stable when the resulting sequence is\n\t\t// unchanged. Avoids producing a fresh `items` array on every parent\n\t\t// re-render so `<SortableContext>` doesn't update its context value\n\t\t// and notify every `useSortable` subscriber unnecessarily.\n\t\tconst sortedItems = useMemo(\n\t\t\t() =>\n\t\t\t\tactiveLayout\n\t\t\t\t\t.map( ( item, index ) => ( { item, index } ) )\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t( a, b ) =>\n\t\t\t\t\t\t\t( a.item.order ?? a.index ) -\n\t\t\t\t\t\t\t( b.item.order ?? b.index )\n\t\t\t\t\t)\n\t\t\t\t\t.map( ( { item } ) => item.key ),\n\t\t\t[ activeLayout ]\n\t\t);\n\t\tconst items = sortedItems;\n\n\t\t// Resolve `width: 'fill'` items to concrete column spans; the\n\t\t// resolver plans the row around each fill's span bounds.\n\t\tconst resolvedItemMap = useMemo( () => {\n\t\t\tconst fillWidths = resolveFillWidths(\n\t\t\t\titems,\n\t\t\t\tlayoutMap,\n\t\t\t\teffectiveColumns,\n\t\t\t\tspanBoundsByKey\n\t\t\t);\n\t\t\tif ( fillWidths.size === 0 ) {\n\t\t\t\treturn layoutMap;\n\t\t\t}\n\t\t\tconst map = new Map< string, DashboardGridLayoutItem >();\n\t\t\tfor ( const [ key, item ] of layoutMap ) {\n\t\t\t\tconst fillW = fillWidths.get( key );\n\t\t\t\tmap.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tfillW !== undefined ? { ...item, width: fillW } : item\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn map;\n\t\t}, [ items, layoutMap, effectiveColumns, spanBoundsByKey ] );\n\n\t\tconst [ childrenMap, actionableAreaMap, remaining, renderedByKey ] =\n\t\t\tuseMemo( () => {\n\t\t\t\tconst childMap = new Map< string, React.ReactElement >();\n\t\t\t\tconst actionableMap = new Map< string, React.ReactNode >();\n\t\t\t\tconst rest: React.ReactNode[] = [];\n\t\t\t\tconst byKey = new Map< string, React.ReactElement >();\n\n\t\t\t\tChildren.forEach( children, ( child ) => {\n\t\t\t\t\tif ( ! isValidElement( child ) ) {\n\t\t\t\t\t\trest.push( child );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst key = child.key?.toString();\n\t\t\t\t\tif ( ! key ) {\n\t\t\t\t\t\trest.push( child );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Strip `actionableArea` so it does not leak to the DOM;\n\t\t\t\t\t// the grid lifts it to a slot separately.\n\t\t\t\t\tconst typedChild = child as React.ReactElement< {\n\t\t\t\t\t\tactionableArea?: React.ReactNode;\n\t\t\t\t\t} >;\n\t\t\t\t\tconst { actionableArea } = typedChild.props;\n\t\t\t\t\tconst stripped =\n\t\t\t\t\t\tactionableArea !== undefined\n\t\t\t\t\t\t\t? cloneElement( typedChild, {\n\t\t\t\t\t\t\t\t\tactionableArea: undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t: child;\n\n\t\t\t\t\tbyKey.set( key, stripped );\n\n\t\t\t\t\tif ( layoutKeys.has( key ) ) {\n\t\t\t\t\t\tif ( actionableArea !== undefined ) {\n\t\t\t\t\t\t\tactionableMap.set( key, actionableArea );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchildMap.set( key, stripped );\n\t\t\t\t\t} else {\n\t\t\t\t\t\trest.push( child );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn [ childMap, actionableMap, rest, byKey ];\n\t\t\t}, [ children, layoutKeys ] );\n\n\t\t// Persist the latest rendered children so a removed tile's content\n\t\t// is still available for its exit overlay. Filled from an effect so a\n\t\t// discarded render never writes to the cache.\n\t\tuseLayoutEffect( () => {\n\t\t\tfor ( const [ key, child ] of renderedByKey ) {\n\t\t\t\tchildrenCacheRef.current.set( key, child );\n\t\t\t}\n\t\t}, [ renderedByKey ] );\n\n\t\tconst sensors = useSensors(\n\t\t\tuseSensor( PointerSensor ),\n\t\t\tuseSensor( KeyboardSensor, {\n\t\t\t\tcoordinateGetter: sortableKeyboardCoordinates,\n\t\t\t} )\n\t\t);\n\n\t\tconst handleDragStart = useEvent( ( event: DragStartEvent ) => {\n\t\t\tsetActiveId( String( event.active.id ) );\n\t\t\tlastReorderCursorRef.current = null;\n\t\t} );\n\n\t\tconst handleDragCancel = useEvent( () => {\n\t\t\tsetActiveId( null );\n\t\t\tlatestLayoutRef.current = undefined;\n\t\t\tlastReorderCursorRef.current = null;\n\t\t\tresizeBaselineRef.current = null;\n\t\t\tsetIsResizing( false );\n\t\t\tsetResizeSnapPreview( null );\n\t\t\tsetTemporaryLayout( undefined );\n\t\t} );\n\n\t\t// Re-evaluate the insertion slot on every pointer move, not\n\t\t// just when `over.id` changes — otherwise a \"swap back\" with\n\t\t// the cursor still on the same tile would never fire.\n\t\tconst handleDragMove = useEvent( ( event: DragMoveEvent ) => {\n\t\t\tconst { active, over } = event;\n\t\t\tif ( ! over || active.id === over.id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst activeRect = active.rect.current.translated;\n\t\t\tif ( ! activeRect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst activeCenterX = activeRect.left + activeRect.width / 2;\n\t\t\tconst activeCenterY = activeRect.top + activeRect.height / 2;\n\n\t\t\t// Skip re-measured events after a layout change: require\n\t\t\t// meaningful cursor movement between reorders.\n\t\t\tconst lastCursor = lastReorderCursorRef.current;\n\t\t\tif ( lastCursor ) {\n\t\t\t\tconst dx = activeCenterX - lastCursor.x;\n\t\t\t\tconst dy = activeCenterY - lastCursor.y;\n\t\t\t\tif ( dx * dx + dy * dy < 100 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst overCenterX = over.rect.left + over.rect.width / 2;\n\t\t\tconst insertAfter = activeCenterX > overCenterX;\n\n\t\t\tconst currentIndex = items.indexOf( String( active.id ) );\n\t\t\tconst overIndex = items.indexOf( String( over.id ) );\n\t\t\tlet newIndex: number;\n\t\t\tif ( insertAfter ) {\n\t\t\t\tnewIndex = currentIndex > overIndex ? overIndex + 1 : overIndex;\n\t\t\t} else {\n\t\t\t\tnewIndex = currentIndex > overIndex ? overIndex : overIndex - 1;\n\t\t\t}\n\t\t\tnewIndex = Math.max( 0, Math.min( newIndex, items.length - 1 ) );\n\n\t\t\tif ( newIndex === currentIndex ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Non-draggable items are pinned: they hold their index while\n\t\t\t// the others reorder around them.\n\t\t\tconst updatedItems = arrayMoveWithPinned(\n\t\t\t\titems,\n\t\t\t\tcurrentIndex,\n\t\t\t\tnewIndex,\n\t\t\t\t( key ) => layoutMap.get( key )?.draggable === false\n\t\t\t);\n\t\t\tif (\n\t\t\t\tupdatedItems.every( ( key, index ) => key === items[ index ] )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Commit from the stored layout (or the pending commit), not\n\t\t\t// the bounded view, so untouched tiles keep their stored spans.\n\t\t\tconst updatedLayout = ( latestLayoutRef.current ?? layout ).map(\n\t\t\t\t( item ) => ( {\n\t\t\t\t\t...item,\n\t\t\t\t\torder: updatedItems.indexOf( item.key ),\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tlastReorderCursorRef.current = {\n\t\t\t\tx: activeCenterX,\n\t\t\t\ty: activeCenterY,\n\t\t\t};\n\t\t\tlatestLayoutRef.current = updatedLayout;\n\t\t\tcaptureLayoutSnapshotRef.current();\n\t\t\tsetTemporaryLayout( updatedLayout );\n\t\t\tonPreviewLayout?.( updatedLayout );\n\t\t} );\n\n\t\t// Commit the latest temporary layout and clear local state.\n\t\t// Reads from the ref to bypass React's state batching.\n\t\tconst persistTemporaryLayout = useEvent( () => {\n\t\t\tconst latest = latestLayoutRef.current;\n\t\t\tlatestLayoutRef.current = undefined;\n\t\t\tresizeBaselineRef.current = null;\n\t\t\tsetIsResizing( false );\n\t\t\tsetResizeSnapPreview( null );\n\t\t\tif ( ! onChangeLayout || ! latest ) {\n\t\t\t\tsetTemporaryLayout( undefined );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tonChangeLayout( latest );\n\t\t\tsetTemporaryLayout( undefined );\n\t\t} );\n\n\t\tconst handleResize = useEvent( ( id: string, delta: ResizeDelta ) => {\n\t\t\tif ( ! editMode ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! isResizing ) {\n\t\t\t\tsetIsResizing( true );\n\t\t\t}\n\n\t\t\tconst relativeDelta = {\n\t\t\t\twidth: Math.round( delta.width / ( columnWidth + gapPx ) ),\n\t\t\t\theight:\n\t\t\t\t\trowHeight === 'auto'\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: Math.round( delta.height / ( rowHeight + gapPx ) ),\n\t\t\t};\n\n\t\t\t// Snapshot the baseline once at gesture start. The handle's\n\t\t\t// `delta` is absolute from the gesture start, so summing it\n\t\t\t// with the live (already mutated) `activeLayout` width would\n\t\t\t// compound and oscillate — and stepping back through the\n\t\t\t// zero-delta zone would never restore the original size.\n\t\t\tconst bounds = spanBoundsByKey.get( id );\n\t\t\tif ( ! resizeBaselineRef.current ) {\n\t\t\t\tconst baseItem = layoutMap.get( id );\n\t\t\t\tconst resolvedItem = resolvedItemMap.get( id );\n\t\t\t\t// `'fill'`/`'full'` resize from the rendered span\n\t\t\t\t// and convert to a numeric width.\n\t\t\t\tlet baseWidth: number;\n\t\t\t\tif ( baseItem?.width === 'full' ) {\n\t\t\t\t\tbaseWidth = bounds?.maxWidth ?? effectiveColumns;\n\t\t\t\t} else if ( baseItem?.width === 'fill' ) {\n\t\t\t\t\tbaseWidth =\n\t\t\t\t\t\ttypeof resolvedItem?.width === 'number'\n\t\t\t\t\t\t\t? resolvedItem.width\n\t\t\t\t\t\t\t: 1;\n\t\t\t\t} else {\n\t\t\t\t\tbaseWidth = baseItem?.width ?? 1;\n\t\t\t\t}\n\t\t\t\tresizeBaselineRef.current = {\n\t\t\t\t\twidth: baseWidth,\n\t\t\t\t\theight: baseItem?.height ?? 1,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst baseline = resizeBaselineRef.current;\n\t\t\tconst newWidth = clampSpan(\n\t\t\t\tbaseline.width + relativeDelta.width,\n\t\t\t\tbounds?.minWidth ?? 1,\n\t\t\t\tbounds?.maxWidth ?? effectiveColumns\n\t\t\t);\n\t\t\tconst newHeight = clampSpan(\n\t\t\t\tbaseline.height + relativeDelta.height,\n\t\t\t\tbounds?.minHeight ?? 1,\n\t\t\t\tbounds?.maxHeight ?? Infinity\n\t\t\t);\n\n\t\t\tsetResizeSnapPreview( {\n\t\t\t\tid,\n\t\t\t\tsnap: gridSpanToPixelSize(\n\t\t\t\t\tnewWidth,\n\t\t\t\t\tnewHeight,\n\t\t\t\t\tcolumnWidth,\n\t\t\t\t\tgapPx,\n\t\t\t\t\trowHeightPx\n\t\t\t\t),\n\t\t\t} );\n\n\t\t\t// Bail when the snapped size matches the layout already\n\t\t\t// staged for commit. The tile still tracks the cursor\n\t\t\t// continuously; only the preview outline and pending commit\n\t\t\t// need updating when the snap target changes.\n\t\t\tconst pendingItem = latestLayoutRef.current?.find(\n\t\t\t\t( item ) => item.key === id\n\t\t\t);\n\t\t\tconst currentItem = pendingItem ?? layoutMap.get( id );\n\t\t\tif (\n\t\t\t\tcurrentItem &&\n\t\t\t\tcurrentItem.width === newWidth &&\n\t\t\t\t( currentItem.height ?? 1 ) === newHeight\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Commit from the stored layout (or the pending commit), not\n\t\t\t// the bounded view: the resized tile takes its new span and\n\t\t\t// every other tile keeps its stored one.\n\t\t\tconst updatedLayout = ( latestLayoutRef.current ?? layout ).map(\n\t\t\t\t( item ) =>\n\t\t\t\t\titem.key === id\n\t\t\t\t\t\t? { ...item, width: newWidth, height: newHeight }\n\t\t\t\t\t\t: item\n\t\t\t);\n\n\t\t\tlatestLayoutRef.current = updatedLayout;\n\t\t\tcaptureLayoutSnapshotRef.current();\n\t\t\tsetTemporaryLayout( updatedLayout );\n\t\t\tonPreviewLayout?.( updatedLayout );\n\t\t} );\n\n\t\t// Drag-overlay clone composition: the surface always wraps with a\n\t\t// thin functional frame (lift, cursor, pointer pass-through). When\n\t\t// `renderDragPreview` is supplied, the consumer's wrapper sits\n\t\t// inside the frame around the cloned children; otherwise the\n\t\t// cloned children render directly so any persistent chrome on\n\t\t// them carries through unchanged.\n\t\tconst activeClone = activeId ? childrenMap.get( activeId ) : null;\n\t\tconst DragPreview = renderDragPreview;\n\t\tconst dragOverlayContent =\n\t\t\tactiveId && activeClone ? (\n\t\t\t\t<div className={ styles[ 'drag-preview-frame' ] }>\n\t\t\t\t\t<div className={ styles[ 'drag-preview-frame__lift' ] }>\n\t\t\t\t\t\t{ DragPreview ? (\n\t\t\t\t\t\t\t<DragPreview itemId={ activeId }>\n\t\t\t\t\t\t\t\t{ activeClone }\n\t\t\t\t\t\t\t</DragPreview>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tactiveClone\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null;\n\n\t\t// Edit-mode background. Rendered unconditionally so it can\n\t\t// cross-fade on edit-mode toggles (`isActive` drives the\n\t\t// transition); memoized so drag/resize re-renders skip it while\n\t\t// inputs are stable. A numeric `rowHeight` adds row markers;\n\t\t// `'auto'` collapses to `undefined` and omits them.\n\t\tconst Overlay = renderGridOverlay ?? GridOverlay;\n\t\tconst overlayRowHeight =\n\t\t\ttypeof rowHeight === 'number' ? rowHeight : undefined;\n\t\tconst overlayRows = useMemo( () => {\n\t\t\tif ( overlayRowHeight === undefined || containerHeight <= 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst rowTile = overlayRowHeight + gapPx;\n\t\t\treturn Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.floor( ( containerHeight + gapPx ) / rowTile )\n\t\t\t);\n\t\t}, [ overlayRowHeight, containerHeight, gapPx ] );\n\t\tconst gridOverlay = useMemo(\n\t\t\t() => (\n\t\t\t\t<Overlay\n\t\t\t\t\tcolumns={ effectiveColumns }\n\t\t\t\t\trowHeight={ overlayRowHeight }\n\t\t\t\t\trows={ overlayRows }\n\t\t\t\t\tisActive={ editMode }\n\t\t\t\t/>\n\t\t\t),\n\t\t\t[\n\t\t\t\tOverlay,\n\t\t\t\teditMode,\n\t\t\t\teffectiveColumns,\n\t\t\t\toverlayRowHeight,\n\t\t\t\toverlayRows,\n\t\t\t]\n\t\t);\n\n\t\tconst layoutFingerprint = useMemo(\n\t\t\t() => getLayoutFingerprint( [ ...resolvedItemMap.values() ] ),\n\t\t\t[ resolvedItemMap ]\n\t\t);\n\t\tconst excludeLayoutAnimationKey =\n\t\t\tactiveId ?? ( isResizing ? resizeSnapPreview?.id : null );\n\t\tconst { captureLayoutSnapshot, getPositionsBeforeLastChange } =\n\t\t\tuseLayoutShiftAnimation( {\n\t\t\t\tcontainer: gridRoot,\n\t\t\t\tenabled: editMode,\n\t\t\t\tlayoutFingerprint,\n\t\t\t\texcludeItemKey: excludeLayoutAnimationKey,\n\t\t\t} );\n\t\tconst { exitingItems, clearExitingItem } = useItemExitAnimation( {\n\t\t\tcontainer: gridRoot,\n\t\t\tenabled: editMode,\n\t\t\tlayoutKeys,\n\t\t\tgetPositionsBeforeLastChange,\n\t\t\tchildrenCacheRef,\n\t\t} );\n\t\t// Transform transitions on tiles for FLIP (drag, resize, removal).\n\t\tconst layoutAnimating = editMode;\n\t\tuseLayoutEffect( () => {\n\t\t\tcaptureLayoutSnapshotRef.current = captureLayoutSnapshot;\n\t\t}, [ captureLayoutSnapshot ] );\n\n\t\treturn (\n\t\t\t<DndContext\n\t\t\t\tsensors={ sensors }\n\t\t\t\tonDragStart={ handleDragStart }\n\t\t\t\tonDragCancel={ handleDragCancel }\n\t\t\t\tonDragMove={ handleDragMove }\n\t\t\t\tonDragEnd={ () => {\n\t\t\t\t\tpersistTemporaryLayout();\n\t\t\t\t\tlastReorderCursorRef.current = null;\n\t\t\t\t\tsetActiveId( null );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ /* No-op strategy: reorder comes from `temporaryLayout`\n\t\t\t\t + CSS Grid, not dnd-kit transforms. */ }\n\t\t\t\t<SortableContext items={ items } strategy={ NO_SORT_STRATEGY }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...divProps }\n\t\t\t\t\t\tref={ mergedGridRef }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\tstyles.grid,\n\t\t\t\t\t\t\tlayoutAnimating &&\n\t\t\t\t\t\t\t\tlayoutAnimationStyles[ 'layout-animating' ],\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdata-wp-grid-dragging={ activeId || undefined }\n\t\t\t\t\t\tdata-wp-grid-resizing={ isResizing || undefined }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tgridTemplateColumns: `repeat(${ effectiveColumns }, minmax(0, 1fr))`,\n\t\t\t\t\t\t\tgridAutoRows: rowHeight,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ gridOverlay }\n\t\t\t\t\t\t{ items.map( ( id ) => {\n\t\t\t\t\t\t\tconst limitsPx = resizeLimitsByKey.get( id );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<GridItem\n\t\t\t\t\t\t\t\t\tkey={ id }\n\t\t\t\t\t\t\t\t\titem={\n\t\t\t\t\t\t\t\t\t\tresolvedItemMap.get(\n\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t) as DashboardGridLayoutItem\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmaxColumns={\n\t\t\t\t\t\t\t\t\t\tspanBoundsByKey.get( id )?.maxWidth ??\n\t\t\t\t\t\t\t\t\t\teffectiveColumns\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdisabled={ ! editMode }\n\t\t\t\t\t\t\t\t\tdraggable={\n\t\t\t\t\t\t\t\t\t\tlayoutMap.get( id )?.draggable !== false\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tresizable={\n\t\t\t\t\t\t\t\t\t\tlayoutMap.get( id )?.resizable !== false\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tverticalResizable={ rowHeight !== 'auto' }\n\t\t\t\t\t\t\t\t\tinteracting={\n\t\t\t\t\t\t\t\t\t\tactiveId !== null || isResizing\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdragging={ activeId !== null }\n\t\t\t\t\t\t\t\t\tonResize={ handleResize }\n\t\t\t\t\t\t\t\t\tonResizeEnd={ persistTemporaryLayout }\n\t\t\t\t\t\t\t\t\tresizeSnapPreview={\n\t\t\t\t\t\t\t\t\t\tresizeSnapPreview?.id === id\n\t\t\t\t\t\t\t\t\t\t\t? resizeSnapPreview.snap\n\t\t\t\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tminResizeWidthPx={\n\t\t\t\t\t\t\t\t\t\tlimitsPx?.minWidthPx ?? minResizeWidthPx\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tminResizeHeightPx={\n\t\t\t\t\t\t\t\t\t\tlimitsPx?.minHeightPx ??\n\t\t\t\t\t\t\t\t\t\tminResizeHeightPx\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmaxResizeWidthPx={ limitsPx?.maxWidthPx }\n\t\t\t\t\t\t\t\t\tmaxResizeHeightPx={\n\t\t\t\t\t\t\t\t\t\tlimitsPx?.maxHeightPx ?? undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tactionableArea={ actionableAreaMap.get(\n\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\trenderResizeHandle={ renderResizeHandle }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ childrenMap.get( id ) }\n\t\t\t\t\t\t\t\t</GridItem>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t{ remaining }\n\t\t\t\t\t\t{ exitingItems.map( ( { key, rect, child } ) => (\n\t\t\t\t\t\t\t<ItemExitOverlay\n\t\t\t\t\t\t\t\tkey={ `exiting-${ key }` }\n\t\t\t\t\t\t\t\titemKey={ key }\n\t\t\t\t\t\t\t\trect={ rect }\n\t\t\t\t\t\t\t\tonAnimationEnd={ () => clearExitingItem( key ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ child }\n\t\t\t\t\t\t\t</ItemExitOverlay>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</SortableContext>\n\t\t\t\t<DragOverlay dropAnimation={ dashboardDragDropAnimation }>\n\t\t\t\t\t{ dragOverlayContent }\n\t\t\t\t</DragOverlay>\n\t\t\t</DndContext>\n\t\t);\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,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eACV;OAED,kBAAmB,UAAU;OAC7B,mBACC,UAAU,eAAe,KAAA;OAE1B,gBAAiB,kBAAkB,IAClC,EACD;OACqB;OAEnB,UAAA,YAAY,IAAK,EAAG;MACb,GA9CH,EA8CG;KAEZ,CAAE;KACA;KACA,aAAa,KAAO,EAAE,KAAK,MAAM,YAClC,oBAAC,iBAAD;MAEC,SAAU;MACH;MACP,sBAAuB,iBAAkB,GAAI;MAE3C,UAAA;KACc,GANV,WAAY,KAMF,CAChB;IACE;;EACW,CAAA,GACjB,oBAAC,aAAD;GAAa,eAAgB;GAC1B,UAAA;EACU,CAAA,CACF;;AAEd,CACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["styles","layoutAnimationStyles"],"sources":["../../../style-runtime/src/index.ts","../../src/shared/layout-shift-animation.module.css","../../src/dashboard-grid/grid.module.scss","../../src/dashboard-grid/index.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"5d10111ab0\", \".c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1))}@media (prefers-reduced-motion:reduce){.c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:none}}\");\n}\nexport default {\"layout-animating\":\"c68bb75eb6bf717a__layout-animating\"};\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"1271e09bea\", \".accd954e27a87edd__grid{display:grid;gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));position:relative}._7eb716cb5b0b9243__drag-preview-frame{border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);cursor:grabbing;height:100%;pointer-events:none}._81f4b86c021354df__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame{animation:ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}._81f4b86c021354df__drag-preview-frame__lift{animation:_839f03e3bf8089bd__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter{0%{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}to{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}}@keyframes _839f03e3bf8089bd__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{animation:ca01d09b92c08943__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{animation:a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes ca01d09b92c08943__wp-grid-drag-preview-shadow-exit{0%{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}to{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}}@keyframes a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}._81f4b86c021354df__drag-preview-frame__lift{transform:none}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);transition:none}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{transition:none}}\");\n}\nexport default {\"grid\":\"accd954e27a87edd__grid\",\"drag-preview-frame\":\"_7eb716cb5b0b9243__drag-preview-frame\",\"drag-preview-frame__lift\":\"_81f4b86c021354df__drag-preview-frame__lift\",\"wp-grid-drag-preview-shadow-enter\":\"ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter\",\"wp-grid-drag-preview-scale-enter\":\"_839f03e3bf8089bd__wp-grid-drag-preview-scale-enter\",\"is-exiting\":\"_19afc579bbe6da9a__is-exiting\",\"wp-grid-drag-preview-shadow-exit\":\"ca01d09b92c08943__wp-grid-drag-preview-shadow-exit\",\"wp-grid-drag-preview-scale-exit\":\"a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit\"};\n","import {\n\tDndContext,\n\tDragOverlay,\n\tKeyboardSensor,\n\tPointerSensor,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core';\nimport {\n\tSortableContext,\n\tsortableKeyboardCoordinates,\n} from '@dnd-kit/sortable';\nimport type { DragMoveEvent, DragStartEvent } from '@dnd-kit/core';\nimport clsx from 'clsx';\nimport { useResizeObserver, useEvent, useMergeRefs } from '@wordpress/compose';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tChildren,\n\tcloneElement,\n\tisValidElement,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { GridItem } from './grid-item';\nimport { arrayMoveWithPinned } from '../shared/array-move-with-pinned';\nimport { resolveColumnCount } from '../shared/column-policy';\nimport { GridOverlay } from '../shared/grid-overlay';\nimport { clampSpan, gridSpanToPixelSize } from '../shared/resize-snap';\nimport { useResizePixelLimits, useSpanBounds } from '../shared/use-span-bounds';\nimport layoutAnimationStyles from '../shared/layout-shift-animation.module.css';\nimport { ItemExitOverlay } from '../shared/item-exit-overlay';\nimport {\n\tgetLayoutFingerprint,\n\tuseLayoutShiftAnimation,\n} from '../shared/use-layout-shift-animation';\nimport { useItemExitAnimation } from '../shared/use-item-exit-animation';\nimport { resolveFillWidths } from './resolve-fill-widths';\nimport type { DashboardGridLayoutItem, DashboardGridProps } from './types';\nimport type { ResizeSnapSize } from '../shared/resize-snap';\nimport type { ResizeDelta } from '../shared/types';\nimport { createDashboardDragDropAnimation } from '../shared/drag-overlay-drop-animation';\nimport styles from './grid.module.scss';\n\nconst dashboardDragDropAnimation = createDashboardDragDropAnimation(\n\tstyles[ 'drag-preview-frame' ],\n\tstyles[ 'is-exiting' ]\n);\n\n// Fallback gap in pixels for math that runs before the computed gap\n// can be read from the DOM. Matches the `'xl'` step the surface\n// resolves to in CSS (`--wpds-dimension-gap-xl`); the next layout\n// effect overwrites this with the actual computed value.\nconst FALLBACK_GAP_PX = 24;\n\n// Default column cap when no explicit `columns` or `minColumnWidth` is\n// supplied. Layered semantics: `columns` acts as a cap and\n// `minColumnWidth` as a per-tile floor; if neither is set we still\n// need a finite count to render against.\nconst DEFAULT_COLUMNS = 6;\n\n// Reorder is driven by `temporaryLayout` + CSS Grid, not by dnd-kit\n// transforms. Hoist the no-op strategy outside the component so its\n// reference is stable across renders — passing a fresh `() => null`\n// to `<SortableContext>` updates its context value and triggers all\n// `useSortable` subscribers to re-render every frame.\nconst NO_SORT_STRATEGY = () => null;\n\n/**\n * 2D packed dashboard grid with drag-to-reorder and resize handles.\n * Supports fixed-column and responsive modes, `number | 'fill' | 'full'`\n * widths, and multi-row tiles.\n *\n * Each child's `key` must match an entry in the `layout` array;\n * children without a match render at the end of the grid without\n * explicit placement and fall through CSS Grid's auto-flow.\n *\n * @example\n * ```jsx\n * const layout = [\n * { key: 'a', width: 2 },\n * { key: 'b', width: 'fill' },\n * { key: 'c', width: 'full' },\n * ];\n *\n * <DashboardGrid\n * layout={ layout }\n * columns={ 6 }\n * editMode\n * onChangeLayout={ setLayout }\n * >\n * <div key=\"a\">A</div>\n * <div key=\"b\">B</div>\n * <div key=\"c\">C</div>\n * </DashboardGrid>\n * ```\n *\n * @param props Component props.\n * @param ref Forwarded to the grid's root `<div>`.\n */\nexport const DashboardGrid = forwardRef< HTMLDivElement, DashboardGridProps >(\n\tfunction UnforwardedDashboardGrid( props, ref ) {\n\t\tconst {\n\t\t\tlayout,\n\t\t\tcolumns,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tstyle,\n\t\t\trowHeight = 'auto',\n\t\t\tminColumnWidth,\n\t\t\titemLimits,\n\t\t\teditMode = false,\n\t\t\tonChangeLayout,\n\t\t\tonPreviewLayout,\n\t\t\trenderResizeHandle,\n\t\t\trenderDragPreview,\n\t\t\trenderGridOverlay,\n\t\t\t...divProps\n\t\t} = props;\n\t\t// Preview layout applied during drag/resize before committing.\n\t\tconst [ temporaryLayout, setTemporaryLayout ] = useState<\n\t\t\tDashboardGridLayoutItem[] | undefined\n\t\t>();\n\t\t// Drives `<DragOverlay>` content while a drag is in progress.\n\t\tconst [ activeId, setActiveId ] = useState< string | null >( null );\n\t\t// True while any tile is being resized. Combined with `activeId`,\n\t\t// it drives the grid-wide `inert` flag on actionable areas so\n\t\t// hovering over another tile's buttons can't steal the gesture.\n\t\tconst [ isResizing, setIsResizing ] = useState( false );\n\t\t// Snapped span in pixels for the resize-preview outline on the\n\t\t// active tile. The tile content follows the cursor continuously;\n\t\t// this preview shows the grid size that will commit on release.\n\t\tconst [ resizeSnapPreview, setResizeSnapPreview ] = useState< {\n\t\t\tid: string;\n\t\t\tsnap: ResizeSnapSize;\n\t\t} | null >( null );\n\t\t// Mirror of `temporaryLayout` read synchronously on drag end —\n\t\t// the state update from `handleDragMove` may still be batched.\n\t\tconst latestLayoutRef = useRef< DashboardGridLayoutItem[] | undefined >(\n\t\t\tundefined\n\t\t);\n\t\t// Cursor center at the last applied reorder. Used to skip the\n\t\t// cascade of re-measured `onDragMove` events after a layout\n\t\t// change, when the cursor has not actually moved.\n\t\tconst lastReorderCursorRef = useRef< {\n\t\t\tx: number;\n\t\t\ty: number;\n\t\t} | null >( null );\n\t\t// Width/height snapshot at the start of a resize session. The\n\t\t// resize handle reports `delta` absolute from the gesture start,\n\t\t// so the baseline must stay frozen — reading from the already\n\t\t// mutated `activeLayout` would compound the delta each frame.\n\t\tconst resizeBaselineRef = useRef< {\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t} | null >( null );\n\t\tconst captureLayoutSnapshotRef = useRef< () => void >( () => {} );\n\t\tconst childrenCacheRef = useRef< Map< string, React.ReactElement > >(\n\t\t\tnew Map()\n\t\t);\n\n\t\tconst [ gridRoot, setGridRoot ] = useState< HTMLDivElement | null >(\n\t\t\tnull\n\t\t);\n\t\tconst [ containerWidth, setContainerWidth ] = useState( 0 );\n\t\tconst [ containerHeight, setContainerHeight ] = useState( 0 );\n\t\tconst [ gapPx, setGapPx ] = useState( FALLBACK_GAP_PX );\n\t\tconst resizeObserverRef = useResizeObserver(\n\t\t\t( [ { contentRect } ] ) => {\n\t\t\t\tsetContainerWidth( contentRect.width );\n\t\t\t\tsetContainerHeight( contentRect.height );\n\t\t\t}\n\t\t);\n\t\tconst mergedGridRef = useMergeRefs( [\n\t\t\tsetGridRoot,\n\t\t\tresizeObserverRef,\n\t\t\tref,\n\t\t] );\n\n\t\t// Measure before paint to avoid a single-column flash in\n\t\t// responsive mode; `useResizeObserver` delivers async. The\n\t\t// computed `column-gap` is read from the resolved CSS so the\n\t\t// math tracks the design-system token under any density.\n\t\tuseLayoutEffect( () => {\n\t\t\tif ( ! gridRoot ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { width, height } = gridRoot.getBoundingClientRect();\n\t\t\tif ( width > 0 ) {\n\t\t\t\tsetContainerWidth( width );\n\t\t\t}\n\t\t\tif ( height > 0 ) {\n\t\t\t\tsetContainerHeight( height );\n\t\t\t}\n\t\t\tconst parsed = Number.parseFloat(\n\t\t\t\twindow.getComputedStyle( gridRoot ).columnGap\n\t\t\t);\n\t\t\tif ( Number.isFinite( parsed ) && parsed > 0 ) {\n\t\t\t\tsetGapPx( parsed );\n\t\t\t}\n\t\t}, [ gridRoot ] );\n\t\tconst effectiveColumns = useMemo(\n\t\t\t() =>\n\t\t\t\tresolveColumnCount(\n\t\t\t\t\t{ columns, minColumnWidth },\n\t\t\t\t\tcontainerWidth,\n\t\t\t\t\tgapPx,\n\t\t\t\t\tDEFAULT_COLUMNS\n\t\t\t\t),\n\t\t\t[ minColumnWidth, gapPx, containerWidth, columns ]\n\t\t);\n\t\tconst columnWidth =\n\t\t\t( containerWidth - ( effectiveColumns - 1 ) * gapPx ) /\n\t\t\teffectiveColumns;\n\t\tconst minResizeWidthPx = gridSpanToPixelSize(\n\t\t\t1,\n\t\t\t1,\n\t\t\tcolumnWidth,\n\t\t\tgapPx,\n\t\t\tnull\n\t\t).widthPx;\n\t\tconst rowHeightPx = typeof rowHeight === 'number' ? rowHeight : null;\n\t\tconst minResizeHeightPx =\n\t\t\trowHeightPx === null\n\t\t\t\t? undefined\n\t\t\t\t: ( gridSpanToPixelSize( 1, 1, columnWidth, gapPx, rowHeightPx )\n\t\t\t\t\t\t.heightPx ?? undefined );\n\n\t\tconst spanBoundsByKey = useSpanBounds(\n\t\t\titemLimits,\n\t\t\tcolumnWidth,\n\t\t\tgapPx,\n\t\t\trowHeightPx,\n\t\t\teffectiveColumns\n\t\t);\n\t\tconst resizeLimitsByKey = useResizePixelLimits(\n\t\t\tspanBoundsByKey,\n\t\t\tcolumnWidth,\n\t\t\tgapPx,\n\t\t\trowHeightPx\n\t\t);\n\n\t\t// Stored and in-gesture layouts may sit outside an item's limits;\n\t\t// render them bounded while the data stays untouched. Gestures\n\t\t// commit from the stored `layout`, never from this bounded view,\n\t\t// so a bounded span cannot reach `onChangeLayout`. Keeps the\n\t\t// source identity when no item needs bounding.\n\t\tconst sourceLayout = temporaryLayout ?? layout;\n\t\tconst activeLayout = useMemo( () => {\n\t\t\tif ( spanBoundsByKey.size === 0 ) {\n\t\t\t\treturn sourceLayout;\n\t\t\t}\n\t\t\tlet changed = false;\n\t\t\tconst bounded = sourceLayout.map( ( item ) => {\n\t\t\t\tconst bounds = spanBoundsByKey.get( item.key );\n\t\t\t\tif ( ! bounds ) {\n\t\t\t\t\treturn item;\n\t\t\t\t}\n\t\t\t\tconst width =\n\t\t\t\t\ttypeof item.width === 'number'\n\t\t\t\t\t\t? clampSpan(\n\t\t\t\t\t\t\t\titem.width,\n\t\t\t\t\t\t\t\tbounds.minWidth,\n\t\t\t\t\t\t\t\tbounds.maxWidth\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: item.width;\n\t\t\t\tconst height = clampSpan(\n\t\t\t\t\titem.height ?? 1,\n\t\t\t\t\tbounds.minHeight,\n\t\t\t\t\tbounds.maxHeight\n\t\t\t\t);\n\t\t\t\tif ( width === item.width && height === ( item.height ?? 1 ) ) {\n\t\t\t\t\treturn item;\n\t\t\t\t}\n\t\t\t\tchanged = true;\n\t\t\t\treturn { ...item, width, height };\n\t\t\t} );\n\t\t\treturn changed ? bounded : sourceLayout;\n\t\t}, [ sourceLayout, spanBoundsByKey ] );\n\n\t\tconst layoutMap = useMemo( () => {\n\t\t\tconst map = new Map< string, DashboardGridLayoutItem >();\n\t\t\tactiveLayout.forEach( ( item ) => map.set( item.key, item ) );\n\t\t\treturn map;\n\t\t}, [ activeLayout ] );\n\n\t\t// Stable-identity key set, preserved across renders whenever the\n\t\t// *contents* of the key set are unchanged — even if the consumer\n\t\t// passes a fresh `layout` array reference (common when `layout`\n\t\t// is derived inline from state). Without this, downstream memos\n\t\t// would invalidate on every parent re-render and the children\n\t\t// walk skip during gestures wouldn't hold.\n\t\tconst layoutKeys = useMemo(\n\t\t\t() => new Set( layout.map( ( item ) => item.key ) ),\n\t\t\t[ layout ]\n\t\t);\n\n\t\t// Sorted item keys, identity-stable when the resulting sequence is\n\t\t// unchanged. Avoids producing a fresh `items` array on every parent\n\t\t// re-render so `<SortableContext>` doesn't update its context value\n\t\t// and notify every `useSortable` subscriber unnecessarily.\n\t\tconst sortedItems = useMemo(\n\t\t\t() =>\n\t\t\t\tactiveLayout\n\t\t\t\t\t.map( ( item, index ) => ( { item, index } ) )\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t( a, b ) =>\n\t\t\t\t\t\t\t( a.item.order ?? a.index ) -\n\t\t\t\t\t\t\t( b.item.order ?? b.index )\n\t\t\t\t\t)\n\t\t\t\t\t.map( ( { item } ) => item.key ),\n\t\t\t[ activeLayout ]\n\t\t);\n\t\tconst items = sortedItems;\n\n\t\t// Resolve `width: 'fill'` items to concrete column spans; the\n\t\t// resolver plans the row around each fill's span bounds.\n\t\tconst resolvedItemMap = useMemo( () => {\n\t\t\tconst fillWidths = resolveFillWidths(\n\t\t\t\titems,\n\t\t\t\tlayoutMap,\n\t\t\t\teffectiveColumns,\n\t\t\t\tspanBoundsByKey\n\t\t\t);\n\t\t\tif ( fillWidths.size === 0 ) {\n\t\t\t\treturn layoutMap;\n\t\t\t}\n\t\t\tconst map = new Map< string, DashboardGridLayoutItem >();\n\t\t\tfor ( const [ key, item ] of layoutMap ) {\n\t\t\t\tconst fillW = fillWidths.get( key );\n\t\t\t\tmap.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tfillW !== undefined ? { ...item, width: fillW } : item\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn map;\n\t\t}, [ items, layoutMap, effectiveColumns, spanBoundsByKey ] );\n\n\t\tconst [ childrenMap, actionableAreaMap, remaining, renderedByKey ] =\n\t\t\tuseMemo( () => {\n\t\t\t\tconst childMap = new Map< string, React.ReactElement >();\n\t\t\t\tconst actionableMap = new Map< string, React.ReactNode >();\n\t\t\t\tconst rest: React.ReactNode[] = [];\n\t\t\t\tconst byKey = new Map< string, React.ReactElement >();\n\n\t\t\t\tChildren.forEach( children, ( child ) => {\n\t\t\t\t\tif ( ! isValidElement( child ) ) {\n\t\t\t\t\t\trest.push( child );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst key = child.key?.toString();\n\t\t\t\t\tif ( ! key ) {\n\t\t\t\t\t\trest.push( child );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Strip `actionableArea` so it does not leak to the DOM;\n\t\t\t\t\t// the grid lifts it to a slot separately.\n\t\t\t\t\tconst typedChild = child as React.ReactElement< {\n\t\t\t\t\t\tactionableArea?: React.ReactNode;\n\t\t\t\t\t} >;\n\t\t\t\t\tconst { actionableArea } = typedChild.props;\n\t\t\t\t\tconst stripped =\n\t\t\t\t\t\tactionableArea !== undefined\n\t\t\t\t\t\t\t? cloneElement( typedChild, {\n\t\t\t\t\t\t\t\t\tactionableArea: undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t: child;\n\n\t\t\t\t\tbyKey.set( key, stripped );\n\n\t\t\t\t\tif ( layoutKeys.has( key ) ) {\n\t\t\t\t\t\tif ( actionableArea !== undefined ) {\n\t\t\t\t\t\t\tactionableMap.set( key, actionableArea );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchildMap.set( key, stripped );\n\t\t\t\t\t} else {\n\t\t\t\t\t\trest.push( child );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn [ childMap, actionableMap, rest, byKey ];\n\t\t\t}, [ children, layoutKeys ] );\n\n\t\t// Persist the latest rendered children so a removed tile's content\n\t\t// is still available for its exit overlay. Filled from an effect so a\n\t\t// discarded render never writes to the cache.\n\t\tuseLayoutEffect( () => {\n\t\t\tfor ( const [ key, child ] of renderedByKey ) {\n\t\t\t\tchildrenCacheRef.current.set( key, child );\n\t\t\t}\n\t\t}, [ renderedByKey ] );\n\n\t\tconst sensors = useSensors(\n\t\t\tuseSensor( PointerSensor ),\n\t\t\tuseSensor( KeyboardSensor, {\n\t\t\t\tcoordinateGetter: sortableKeyboardCoordinates,\n\t\t\t} )\n\t\t);\n\n\t\tconst handleDragStart = useEvent( ( event: DragStartEvent ) => {\n\t\t\tsetActiveId( String( event.active.id ) );\n\t\t\tlastReorderCursorRef.current = null;\n\t\t} );\n\n\t\tconst handleDragCancel = useEvent( () => {\n\t\t\tsetActiveId( null );\n\t\t\tlatestLayoutRef.current = undefined;\n\t\t\tlastReorderCursorRef.current = null;\n\t\t\tresizeBaselineRef.current = null;\n\t\t\tsetIsResizing( false );\n\t\t\tsetResizeSnapPreview( null );\n\t\t\tsetTemporaryLayout( undefined );\n\t\t} );\n\n\t\t// Re-evaluate the insertion slot on every pointer move, not\n\t\t// just when `over.id` changes — otherwise a \"swap back\" with\n\t\t// the cursor still on the same tile would never fire.\n\t\tconst handleDragMove = useEvent( ( event: DragMoveEvent ) => {\n\t\t\tconst { active, over } = event;\n\t\t\tif ( ! over || active.id === over.id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst activeRect = active.rect.current.translated;\n\t\t\tif ( ! activeRect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst activeCenterX = activeRect.left + activeRect.width / 2;\n\t\t\tconst activeCenterY = activeRect.top + activeRect.height / 2;\n\n\t\t\t// Skip re-measured events after a layout change: require\n\t\t\t// meaningful cursor movement between reorders.\n\t\t\tconst lastCursor = lastReorderCursorRef.current;\n\t\t\tif ( lastCursor ) {\n\t\t\t\tconst dx = activeCenterX - lastCursor.x;\n\t\t\t\tconst dy = activeCenterY - lastCursor.y;\n\t\t\t\tif ( dx * dx + dy * dy < 100 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst overCenterX = over.rect.left + over.rect.width / 2;\n\t\t\tconst insertAfter = activeCenterX > overCenterX;\n\n\t\t\tconst currentIndex = items.indexOf( String( active.id ) );\n\t\t\tconst overIndex = items.indexOf( String( over.id ) );\n\t\t\tlet newIndex: number;\n\t\t\tif ( insertAfter ) {\n\t\t\t\tnewIndex = currentIndex > overIndex ? overIndex + 1 : overIndex;\n\t\t\t} else {\n\t\t\t\tnewIndex = currentIndex > overIndex ? overIndex : overIndex - 1;\n\t\t\t}\n\t\t\tnewIndex = Math.max( 0, Math.min( newIndex, items.length - 1 ) );\n\n\t\t\tif ( newIndex === currentIndex ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Non-draggable items are pinned: they hold their index while\n\t\t\t// the others reorder around them.\n\t\t\tconst updatedItems = arrayMoveWithPinned(\n\t\t\t\titems,\n\t\t\t\tcurrentIndex,\n\t\t\t\tnewIndex,\n\t\t\t\t( key ) => layoutMap.get( key )?.draggable === false\n\t\t\t);\n\t\t\tif (\n\t\t\t\tupdatedItems.every( ( key, index ) => key === items[ index ] )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Commit from the stored layout (or the pending commit), not\n\t\t\t// the bounded view, so untouched tiles keep their stored spans.\n\t\t\tconst updatedLayout = ( latestLayoutRef.current ?? layout ).map(\n\t\t\t\t( item ) => ( {\n\t\t\t\t\t...item,\n\t\t\t\t\torder: updatedItems.indexOf( item.key ),\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tlastReorderCursorRef.current = {\n\t\t\t\tx: activeCenterX,\n\t\t\t\ty: activeCenterY,\n\t\t\t};\n\t\t\tlatestLayoutRef.current = updatedLayout;\n\t\t\tcaptureLayoutSnapshotRef.current();\n\t\t\tsetTemporaryLayout( updatedLayout );\n\t\t\tonPreviewLayout?.( updatedLayout );\n\t\t} );\n\n\t\t// Commit the latest temporary layout and clear local state.\n\t\t// Reads from the ref to bypass React's state batching.\n\t\tconst persistTemporaryLayout = useEvent( () => {\n\t\t\tconst latest = latestLayoutRef.current;\n\t\t\tlatestLayoutRef.current = undefined;\n\t\t\tresizeBaselineRef.current = null;\n\t\t\tsetIsResizing( false );\n\t\t\tsetResizeSnapPreview( null );\n\t\t\tif ( ! onChangeLayout || ! latest ) {\n\t\t\t\tsetTemporaryLayout( undefined );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tonChangeLayout( latest );\n\t\t\tsetTemporaryLayout( undefined );\n\t\t} );\n\n\t\tconst handleResize = useEvent( ( id: string, delta: ResizeDelta ) => {\n\t\t\tif ( ! editMode ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! isResizing ) {\n\t\t\t\tsetIsResizing( true );\n\t\t\t}\n\n\t\t\tconst relativeDelta = {\n\t\t\t\twidth: Math.round( delta.width / ( columnWidth + gapPx ) ),\n\t\t\t\theight:\n\t\t\t\t\trowHeight === 'auto'\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: Math.round( delta.height / ( rowHeight + gapPx ) ),\n\t\t\t};\n\n\t\t\t// Snapshot the baseline once at gesture start. The handle's\n\t\t\t// `delta` is absolute from the gesture start, so summing it\n\t\t\t// with the live (already mutated) `activeLayout` width would\n\t\t\t// compound and oscillate — and stepping back through the\n\t\t\t// zero-delta zone would never restore the original size.\n\t\t\tconst bounds = spanBoundsByKey.get( id );\n\t\t\tif ( ! resizeBaselineRef.current ) {\n\t\t\t\tconst baseItem = layoutMap.get( id );\n\t\t\t\tconst resolvedItem = resolvedItemMap.get( id );\n\t\t\t\t// `'fill'`/`'full'` resize from the rendered span\n\t\t\t\t// and convert to a numeric width.\n\t\t\t\tlet baseWidth: number;\n\t\t\t\tif ( baseItem?.width === 'full' ) {\n\t\t\t\t\tbaseWidth = bounds?.maxWidth ?? effectiveColumns;\n\t\t\t\t} else if ( baseItem?.width === 'fill' ) {\n\t\t\t\t\tbaseWidth =\n\t\t\t\t\t\ttypeof resolvedItem?.width === 'number'\n\t\t\t\t\t\t\t? resolvedItem.width\n\t\t\t\t\t\t\t: 1;\n\t\t\t\t} else {\n\t\t\t\t\tbaseWidth = baseItem?.width ?? 1;\n\t\t\t\t}\n\t\t\t\tresizeBaselineRef.current = {\n\t\t\t\t\twidth: baseWidth,\n\t\t\t\t\theight: baseItem?.height ?? 1,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst baseline = resizeBaselineRef.current;\n\t\t\tconst newWidth = clampSpan(\n\t\t\t\tbaseline.width + relativeDelta.width,\n\t\t\t\tbounds?.minWidth ?? 1,\n\t\t\t\tbounds?.maxWidth ?? effectiveColumns\n\t\t\t);\n\t\t\tconst newHeight = clampSpan(\n\t\t\t\tbaseline.height + relativeDelta.height,\n\t\t\t\tbounds?.minHeight ?? 1,\n\t\t\t\tbounds?.maxHeight ?? Infinity\n\t\t\t);\n\n\t\t\tsetResizeSnapPreview( {\n\t\t\t\tid,\n\t\t\t\tsnap: gridSpanToPixelSize(\n\t\t\t\t\tnewWidth,\n\t\t\t\t\tnewHeight,\n\t\t\t\t\tcolumnWidth,\n\t\t\t\t\tgapPx,\n\t\t\t\t\trowHeightPx\n\t\t\t\t),\n\t\t\t} );\n\n\t\t\t// Bail when the snapped size matches the layout already\n\t\t\t// staged for commit. The tile still tracks the cursor\n\t\t\t// continuously; only the preview outline and pending commit\n\t\t\t// need updating when the snap target changes.\n\t\t\tconst pendingItem = latestLayoutRef.current?.find(\n\t\t\t\t( item ) => item.key === id\n\t\t\t);\n\t\t\tconst currentItem = pendingItem ?? layoutMap.get( id );\n\t\t\tif (\n\t\t\t\tcurrentItem &&\n\t\t\t\tcurrentItem.width === newWidth &&\n\t\t\t\t( currentItem.height ?? 1 ) === newHeight\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Commit from the stored layout (or the pending commit), not\n\t\t\t// the bounded view: the resized tile takes its new span and\n\t\t\t// every other tile keeps its stored one.\n\t\t\tconst updatedLayout = ( latestLayoutRef.current ?? layout ).map(\n\t\t\t\t( item ) =>\n\t\t\t\t\titem.key === id\n\t\t\t\t\t\t? { ...item, width: newWidth, height: newHeight }\n\t\t\t\t\t\t: item\n\t\t\t);\n\n\t\t\tlatestLayoutRef.current = updatedLayout;\n\t\t\tcaptureLayoutSnapshotRef.current();\n\t\t\tsetTemporaryLayout( updatedLayout );\n\t\t\tonPreviewLayout?.( updatedLayout );\n\t\t} );\n\n\t\t// Drag-overlay clone composition: the surface always wraps with a\n\t\t// thin functional frame (lift, cursor, pointer pass-through). When\n\t\t// `renderDragPreview` is supplied, the consumer's wrapper sits\n\t\t// inside the frame around the cloned children; otherwise the\n\t\t// cloned children render directly so any persistent chrome on\n\t\t// them carries through unchanged.\n\t\tconst activeClone = activeId ? childrenMap.get( activeId ) : null;\n\t\tconst DragPreview = renderDragPreview;\n\t\tconst dragOverlayContent =\n\t\t\tactiveId && activeClone ? (\n\t\t\t\t<div className={ styles[ 'drag-preview-frame' ] }>\n\t\t\t\t\t<div className={ styles[ 'drag-preview-frame__lift' ] }>\n\t\t\t\t\t\t{ DragPreview ? (\n\t\t\t\t\t\t\t<DragPreview itemId={ activeId }>\n\t\t\t\t\t\t\t\t{ activeClone }\n\t\t\t\t\t\t\t</DragPreview>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tactiveClone\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null;\n\n\t\t// Edit-mode background. Rendered unconditionally so it can\n\t\t// cross-fade on edit-mode toggles (`isActive` drives the\n\t\t// transition); memoized so drag/resize re-renders skip it while\n\t\t// inputs are stable. A numeric `rowHeight` adds row markers;\n\t\t// `'auto'` collapses to `undefined` and omits them.\n\t\tconst Overlay = renderGridOverlay ?? GridOverlay;\n\t\tconst overlayRowHeight =\n\t\t\ttypeof rowHeight === 'number' ? rowHeight : undefined;\n\t\tconst overlayRows = useMemo( () => {\n\t\t\tif ( overlayRowHeight === undefined || containerHeight <= 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst rowTile = overlayRowHeight + gapPx;\n\t\t\treturn Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.floor( ( containerHeight + gapPx ) / rowTile )\n\t\t\t);\n\t\t}, [ overlayRowHeight, containerHeight, gapPx ] );\n\t\tconst gridOverlay = useMemo(\n\t\t\t() => (\n\t\t\t\t<Overlay\n\t\t\t\t\tcolumns={ effectiveColumns }\n\t\t\t\t\trowHeight={ overlayRowHeight }\n\t\t\t\t\trows={ overlayRows }\n\t\t\t\t\tisActive={ editMode }\n\t\t\t\t/>\n\t\t\t),\n\t\t\t[\n\t\t\t\tOverlay,\n\t\t\t\teditMode,\n\t\t\t\teffectiveColumns,\n\t\t\t\toverlayRowHeight,\n\t\t\t\toverlayRows,\n\t\t\t]\n\t\t);\n\n\t\tconst layoutFingerprint = useMemo(\n\t\t\t() => getLayoutFingerprint( [ ...resolvedItemMap.values() ] ),\n\t\t\t[ resolvedItemMap ]\n\t\t);\n\t\tconst excludeLayoutAnimationKey =\n\t\t\tactiveId ?? ( isResizing ? resizeSnapPreview?.id : null );\n\t\tconst { captureLayoutSnapshot, getPositionsBeforeLastChange } =\n\t\t\tuseLayoutShiftAnimation( {\n\t\t\t\tcontainer: gridRoot,\n\t\t\t\tenabled: editMode,\n\t\t\t\tlayoutFingerprint,\n\t\t\t\texcludeItemKey: excludeLayoutAnimationKey,\n\t\t\t} );\n\t\tconst { exitingItems, clearExitingItem } = useItemExitAnimation( {\n\t\t\tcontainer: gridRoot,\n\t\t\tenabled: editMode,\n\t\t\tlayoutKeys,\n\t\t\tgetPositionsBeforeLastChange,\n\t\t\tchildrenCacheRef,\n\t\t} );\n\t\t// Transform transitions on tiles for FLIP (drag, resize, removal).\n\t\tconst layoutAnimating = editMode;\n\t\tuseLayoutEffect( () => {\n\t\t\tcaptureLayoutSnapshotRef.current = captureLayoutSnapshot;\n\t\t}, [ captureLayoutSnapshot ] );\n\n\t\treturn (\n\t\t\t<DndContext\n\t\t\t\tsensors={ sensors }\n\t\t\t\tonDragStart={ handleDragStart }\n\t\t\t\tonDragCancel={ handleDragCancel }\n\t\t\t\tonDragMove={ handleDragMove }\n\t\t\t\tonDragEnd={ () => {\n\t\t\t\t\tpersistTemporaryLayout();\n\t\t\t\t\tlastReorderCursorRef.current = null;\n\t\t\t\t\tsetActiveId( null );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ /* No-op strategy: reorder comes from `temporaryLayout`\n\t\t\t\t + CSS Grid, not dnd-kit transforms. */ }\n\t\t\t\t<SortableContext items={ items } strategy={ NO_SORT_STRATEGY }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...divProps }\n\t\t\t\t\t\tref={ mergedGridRef }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\tstyles.grid,\n\t\t\t\t\t\t\tlayoutAnimating &&\n\t\t\t\t\t\t\t\tlayoutAnimationStyles[ 'layout-animating' ],\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdata-wp-grid-dragging={ activeId || undefined }\n\t\t\t\t\t\tdata-wp-grid-resizing={ isResizing || undefined }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tgridTemplateColumns: `repeat(${ effectiveColumns }, minmax(0, 1fr))`,\n\t\t\t\t\t\t\tgridAutoRows: rowHeight,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ gridOverlay }\n\t\t\t\t\t\t{ items.map( ( id ) => {\n\t\t\t\t\t\t\tconst limitsPx = resizeLimitsByKey.get( id );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<GridItem\n\t\t\t\t\t\t\t\t\tkey={ id }\n\t\t\t\t\t\t\t\t\titem={\n\t\t\t\t\t\t\t\t\t\tresolvedItemMap.get(\n\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t) as DashboardGridLayoutItem\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmaxColumns={\n\t\t\t\t\t\t\t\t\t\tspanBoundsByKey.get( id )?.maxWidth ??\n\t\t\t\t\t\t\t\t\t\teffectiveColumns\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdisabled={ ! editMode }\n\t\t\t\t\t\t\t\t\tdraggable={\n\t\t\t\t\t\t\t\t\t\tlayoutMap.get( id )?.draggable !== false\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tresizable={\n\t\t\t\t\t\t\t\t\t\tlayoutMap.get( id )?.resizable !== false\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tverticalResizable={ rowHeight !== 'auto' }\n\t\t\t\t\t\t\t\t\tinteracting={\n\t\t\t\t\t\t\t\t\t\tactiveId !== null || isResizing\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdragging={ activeId !== null }\n\t\t\t\t\t\t\t\t\tonResize={ handleResize }\n\t\t\t\t\t\t\t\t\tonResizeEnd={ persistTemporaryLayout }\n\t\t\t\t\t\t\t\t\tresizeSnapPreview={\n\t\t\t\t\t\t\t\t\t\tresizeSnapPreview?.id === id\n\t\t\t\t\t\t\t\t\t\t\t? resizeSnapPreview.snap\n\t\t\t\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tminResizeWidthPx={\n\t\t\t\t\t\t\t\t\t\tlimitsPx?.minWidthPx ?? minResizeWidthPx\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tminResizeHeightPx={\n\t\t\t\t\t\t\t\t\t\tlimitsPx?.minHeightPx ??\n\t\t\t\t\t\t\t\t\t\tminResizeHeightPx\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmaxResizeWidthPx={ limitsPx?.maxWidthPx }\n\t\t\t\t\t\t\t\t\tmaxResizeHeightPx={\n\t\t\t\t\t\t\t\t\t\tlimitsPx?.maxHeightPx ?? undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tactionableArea={ actionableAreaMap.get(\n\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\trenderResizeHandle={ renderResizeHandle }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ childrenMap.get( id ) }\n\t\t\t\t\t\t\t\t</GridItem>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t{ remaining }\n\t\t\t\t\t\t{ exitingItems.map( ( { key, rect, child } ) => (\n\t\t\t\t\t\t\t<ItemExitOverlay\n\t\t\t\t\t\t\t\tkey={ `exiting-${ key }` }\n\t\t\t\t\t\t\t\titemKey={ key }\n\t\t\t\t\t\t\t\trect={ rect }\n\t\t\t\t\t\t\t\tonAnimationEnd={ () => clearExitingItem( key ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ child }\n\t\t\t\t\t\t\t</ItemExitOverlay>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</SortableContext>\n\t\t\t\t<DragOverlay dropAnimation={ dashboardDragDropAnimation }>\n\t\t\t\t\t{ dragOverlayContent }\n\t\t\t\t</DragOverlay>\n\t\t\t</DndContext>\n\t\t);\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;;;;;;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;CAC3E,IAAK,CAAE,eAAe,MACrB;CAGD,MAAM,UAAU,WAAW;CAC3B,IAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;CAEhE,IAAK,CAAE,gBAAiB;EACvB,iCAAiB,IAAI,IAAI;EACzB,QAAQ,eAAe,IAAK,gBAAgB,cAAe;CAC5D;CAEA,IAAK,eAAe,IAAK,IAAK,GAC7B;CAMD,IAAK,0BAA2B,gBAAgB,IAAK,GAAI;EACxD,eAAe,IAAK,IAAK;EACzB;CACD;CAEA,MAAM,QAAQ,eAAe,cAAe,OAAQ;CACpD,MAAM,aA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c,KAAA;IACtC,OAAQ;KACP,GAAG;KACH,qBAAqB,UAAW,iBAAkB;KAClD,cAAc;IACf;IAfD,UAAA;KAiBG;KACA,MAAM,KAAO,OAAQ;MACtB,MAAM,WAAW,kBAAkB,IAAK,EAAG;MAC3C,OACC,oBAAC,UAAD;OAEC,MACC,gBAAgB,IACf,EACD;OAED,YACC,gBAAgB,IAAK,EAAG,CAAC,EAAE,YAC3B;OAED,UAAW,CAAE;OACb,WACC,UAAU,IAAK,EAAG,CAAC,EAAE,cAAc;OAEpC,WACC,UAAU,IAAK,EAAG,CAAC,EAAE,cAAc;OAEpC,mBAAoB,cAAc;OAClC,aACC,aAAa,QAAQ;OAEtB,UAAW,aAAa;OACxB,UAAW;OACX,aAAc;OACd,mBACC,mBAAmB,OAAO,KACvB,kBAAkB,OAClB;OAEJ,kBACC,UAAU,cAAc;OAEzB,mBACC,UAAU,eACV;OAED,kBAAmB,UAAU;OAC7B,mBACC,UAAU,eAAe,KAAA;OAE1B,gBAAiB,kBAAkB,IAClC,EACD;OACqB;OAEnB,UAAA,YAAY,IAAK,EAAG;MACb,GA9CH,EA8CG;KAEZ,CAAE;KACA;KACA,aAAa,KAAO,EAAE,KAAK,MAAM,YAClC,oBAAC,iBAAD;MAEC,SAAU;MACH;MACP,sBAAuB,iBAAkB,GAAI;MAE3C,UAAA;KACc,GANV,WAAY,KAMF,CAChB;IACE;;EACW,CAAA,GACjB,oBAAC,aAAD;GAAa,eAAgB;GAC1B,UAAA;EACU,CAAA,CACF;;AAEd,CACD"}
|
|
@@ -120,17 +120,17 @@ function registerStyle(hash, css) {
|
|
|
120
120
|
// packages/grid/src/shared/layout-shift-animation.module.css
|
|
121
121
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("5d10111ab0", ".c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1))}@media (prefers-reduced-motion:reduce){.c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:none}}");
|
|
122
122
|
var layout_shift_animation_module_default = { "layout-animating": "c68bb75eb6bf717a__layout-animating" };
|
|
123
|
-
// packages/grid/src/dashboard-lanes/lanes.module.
|
|
124
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("
|
|
123
|
+
// packages/grid/src/dashboard-lanes/lanes.module.scss
|
|
124
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("25b095c2e7", "._23779dfdf51c5e50__lanes{column-gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));display:grid-lanes;position:relative;row-gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px))}@supports not (display:grid-lanes){._23779dfdf51c5e50__lanes{display:grid;grid-auto-flow:dense;grid-auto-rows:var(--wp-grid-lane-row-unit,4px);row-gap:0}}.d7e03cc9b910fc7e__drag-preview-frame{border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);cursor:grabbing;height:100%;pointer-events:none}._4425b9a6fa30579d__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){.d7e03cc9b910fc7e__drag-preview-frame{animation:ff9e5dccc1f34f49__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}._4425b9a6fa30579d__drag-preview-frame__lift{animation:_2592bed08e4f30e4__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes ff9e5dccc1f34f49__wp-grid-drag-preview-shadow-enter{0%{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}to{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}}@keyframes _2592bed08e4f30e4__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){.d7e03cc9b910fc7e__drag-preview-frame._6348e3778fd237bf__is-exiting{animation:_4eb7799009ff2eea__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}.d7e03cc9b910fc7e__drag-preview-frame._6348e3778fd237bf__is-exiting ._4425b9a6fa30579d__drag-preview-frame__lift{animation:_58b3144e745d3a6e__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _4eb7799009ff2eea__wp-grid-drag-preview-shadow-exit{0%{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}to{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}}@keyframes _58b3144e745d3a6e__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}.d7e03cc9b910fc7e__drag-preview-frame._6348e3778fd237bf__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}.d7e03cc9b910fc7e__drag-preview-frame._6348e3778fd237bf__is-exiting ._4425b9a6fa30579d__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){.d7e03cc9b910fc7e__drag-preview-frame{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}._4425b9a6fa30579d__drag-preview-frame__lift{transform:none}.d7e03cc9b910fc7e__drag-preview-frame._6348e3778fd237bf__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);transition:none}.d7e03cc9b910fc7e__drag-preview-frame._6348e3778fd237bf__is-exiting ._4425b9a6fa30579d__drag-preview-frame__lift{transition:none}}");
|
|
125
125
|
var lanes_module_default = {
|
|
126
|
-
"lanes": "
|
|
127
|
-
"drag-preview-frame": "
|
|
128
|
-
"drag-preview-frame__lift": "
|
|
129
|
-
"wp-grid-drag-preview-shadow-enter": "
|
|
130
|
-
"wp-grid-drag-preview-scale-enter": "
|
|
131
|
-
"is-exiting": "
|
|
132
|
-
"wp-grid-drag-preview-shadow-exit": "
|
|
133
|
-
"wp-grid-drag-preview-scale-exit": "
|
|
126
|
+
"lanes": "_23779dfdf51c5e50__lanes",
|
|
127
|
+
"drag-preview-frame": "d7e03cc9b910fc7e__drag-preview-frame",
|
|
128
|
+
"drag-preview-frame__lift": "_4425b9a6fa30579d__drag-preview-frame__lift",
|
|
129
|
+
"wp-grid-drag-preview-shadow-enter": "ff9e5dccc1f34f49__wp-grid-drag-preview-shadow-enter",
|
|
130
|
+
"wp-grid-drag-preview-scale-enter": "_2592bed08e4f30e4__wp-grid-drag-preview-scale-enter",
|
|
131
|
+
"is-exiting": "_6348e3778fd237bf__is-exiting",
|
|
132
|
+
"wp-grid-drag-preview-shadow-exit": "_4eb7799009ff2eea__wp-grid-drag-preview-shadow-exit",
|
|
133
|
+
"wp-grid-drag-preview-scale-exit": "_58b3144e745d3a6e__wp-grid-drag-preview-scale-exit"
|
|
134
134
|
};
|
|
135
135
|
// packages/grid/src/dashboard-lanes/index.tsx
|
|
136
136
|
const dashboardDragDropAnimation = createDashboardDragDropAnimation(lanes_module_default["drag-preview-frame"], lanes_module_default["is-exiting"]);
|