@wordpress/grid 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +35 -14
  2. package/build/dashboard-grid/grid-item.cjs +232 -295
  3. package/build/dashboard-grid/grid-item.cjs.map +1 -7
  4. package/build/dashboard-grid/index.cjs +525 -632
  5. package/build/dashboard-grid/index.cjs.map +1 -7
  6. package/build/dashboard-grid/resolve-fill-widths.cjs +159 -203
  7. package/build/dashboard-grid/resolve-fill-widths.cjs.map +1 -7
  8. package/build/dashboard-grid/types.cjs +4 -18
  9. package/build/dashboard-lanes/index.cjs +494 -576
  10. package/build/dashboard-lanes/index.cjs.map +1 -7
  11. package/build/dashboard-lanes/lane-placement.cjs +77 -100
  12. package/build/dashboard-lanes/lane-placement.cjs.map +1 -7
  13. package/build/dashboard-lanes/lanes-item.cjs +222 -278
  14. package/build/dashboard-lanes/lanes-item.cjs.map +1 -7
  15. package/build/dashboard-lanes/types.cjs +4 -18
  16. package/build/dashboard-lanes/use-lane-placement.cjs +172 -198
  17. package/build/dashboard-lanes/use-lane-placement.cjs.map +1 -7
  18. package/build/index.cjs +16 -31
  19. package/build/shared/array-move-with-pinned.cjs +29 -45
  20. package/build/shared/array-move-with-pinned.cjs.map +1 -7
  21. package/build/shared/column-policy.cjs +58 -0
  22. package/build/shared/column-policy.cjs.map +1 -0
  23. package/build/shared/drag-overlay-drop-animation.cjs +40 -66
  24. package/build/shared/drag-overlay-drop-animation.cjs.map +1 -7
  25. package/build/shared/grid-item-key.cjs +12 -29
  26. package/build/shared/grid-item-key.cjs.map +1 -7
  27. package/build/shared/grid-overlay.cjs +163 -164
  28. package/build/shared/grid-overlay.cjs.map +1 -7
  29. package/build/shared/item-exit-overlay.cjs +132 -134
  30. package/build/shared/item-exit-overlay.cjs.map +1 -7
  31. package/build/shared/resize-handle.cjs +213 -197
  32. package/build/shared/resize-handle.cjs.map +1 -7
  33. package/build/shared/resize-snap.cjs +116 -121
  34. package/build/shared/resize-snap.cjs.map +1 -7
  35. package/build/shared/types.cjs +4 -18
  36. package/build/shared/use-item-exit-animation.cjs +96 -143
  37. package/build/shared/use-item-exit-animation.cjs.map +1 -7
  38. package/build/shared/use-layout-shift-animation.cjs +121 -150
  39. package/build/shared/use-layout-shift-animation.cjs.map +1 -7
  40. package/build/shared/use-span-bounds.cjs +65 -79
  41. package/build/shared/use-span-bounds.cjs.map +1 -7
  42. package/build-module/dashboard-grid/grid-item.mjs +209 -265
  43. package/build-module/dashboard-grid/grid-item.mjs.map +1 -7
  44. package/build-module/dashboard-grid/index.mjs +502 -623
  45. package/build-module/dashboard-grid/index.mjs.map +1 -7
  46. package/build-module/dashboard-grid/resolve-fill-widths.mjs +155 -179
  47. package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +1 -7
  48. package/build-module/dashboard-grid/types.mjs +0 -1
  49. package/build-module/dashboard-lanes/index.mjs +470 -567
  50. package/build-module/dashboard-lanes/index.mjs.map +1 -7
  51. package/build-module/dashboard-lanes/lane-placement.mjs +73 -76
  52. package/build-module/dashboard-lanes/lane-placement.mjs.map +1 -7
  53. package/build-module/dashboard-lanes/lanes-item.mjs +199 -248
  54. package/build-module/dashboard-lanes/lanes-item.mjs.map +1 -7
  55. package/build-module/dashboard-lanes/types.mjs +0 -1
  56. package/build-module/dashboard-lanes/use-lane-placement.mjs +167 -173
  57. package/build-module/dashboard-lanes/use-lane-placement.mjs.map +1 -7
  58. package/build-module/index.mjs +1 -6
  59. package/build-module/shared/array-move-with-pinned.mjs +25 -21
  60. package/build-module/shared/array-move-with-pinned.mjs.map +1 -7
  61. package/build-module/shared/column-policy.mjs +52 -0
  62. package/build-module/shared/column-policy.mjs.map +1 -0
  63. package/build-module/shared/drag-overlay-drop-animation.mjs +35 -44
  64. package/build-module/shared/drag-overlay-drop-animation.mjs.map +1 -7
  65. package/build-module/shared/grid-item-key.mjs +8 -5
  66. package/build-module/shared/grid-item-key.mjs.map +1 -7
  67. package/build-module/shared/grid-overlay.mjs +143 -136
  68. package/build-module/shared/grid-overlay.mjs.map +1 -7
  69. package/build-module/shared/item-exit-overlay.mjs +128 -110
  70. package/build-module/shared/item-exit-overlay.mjs.map +1 -7
  71. package/build-module/shared/resize-handle.mjs +191 -171
  72. package/build-module/shared/resize-handle.mjs.map +1 -7
  73. package/build-module/shared/resize-snap.mjs +108 -93
  74. package/build-module/shared/resize-snap.mjs.map +1 -7
  75. package/build-module/shared/types.mjs +0 -1
  76. package/build-module/shared/use-item-exit-animation.mjs +92 -124
  77. package/build-module/shared/use-item-exit-animation.mjs.map +1 -7
  78. package/build-module/shared/use-layout-shift-animation.mjs +114 -123
  79. package/build-module/shared/use-layout-shift-animation.mjs.map +1 -7
  80. package/build-module/shared/use-span-bounds.mjs +60 -57
  81. package/build-module/shared/use-span-bounds.mjs.map +1 -7
  82. package/build-types/dashboard-grid/index.d.ts.map +1 -1
  83. package/build-types/dashboard-grid/types.d.ts +9 -5
  84. package/build-types/dashboard-grid/types.d.ts.map +1 -1
  85. package/build-types/dashboard-lanes/index.d.ts.map +1 -1
  86. package/build-types/dashboard-lanes/types.d.ts +9 -5
  87. package/build-types/dashboard-lanes/types.d.ts.map +1 -1
  88. package/build-types/index.d.ts +1 -0
  89. package/build-types/index.d.ts.map +1 -1
  90. package/build-types/shared/column-policy.d.ts +43 -0
  91. package/build-types/shared/column-policy.d.ts.map +1 -0
  92. package/package.json +11 -11
  93. package/src/dashboard-grid/grid-item.tsx +1 -1
  94. package/src/dashboard-grid/index.tsx +11 -12
  95. package/src/dashboard-grid/stories/index.story.tsx +129 -50
  96. package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
  97. package/src/dashboard-grid/types.ts +9 -5
  98. package/src/dashboard-lanes/index.tsx +11 -11
  99. package/src/dashboard-lanes/lanes-item.tsx +1 -1
  100. package/src/dashboard-lanes/stories/index.story.tsx +124 -28
  101. package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
  102. package/src/dashboard-lanes/types.ts +9 -5
  103. package/src/index.ts +1 -0
  104. package/src/shared/column-policy.ts +100 -0
  105. package/src/shared/test/column-policy.test.ts +215 -0
  106. package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
  107. package/build/dashboard-grid/types.cjs.map +0 -7
  108. package/build/dashboard-lanes/types.cjs.map +0 -7
  109. package/build/index.cjs.map +0 -7
  110. package/build/shared/types.cjs.map +0 -7
  111. package/build-module/dashboard-grid/types.mjs.map +0 -7
  112. package/build-module/dashboard-lanes/types.mjs.map +0 -7
  113. package/build-module/index.mjs.map +0 -7
  114. package/build-module/shared/types.mjs.map +0 -7
@@ -1,104 +1,119 @@
1
1
  // packages/grid/src/shared/resize-snap.ts
2
+ /**
3
+ * Clamps a resize delta so the tile cannot shrink below the given
4
+ * minimum size, nor grow past the given maximum when one applies.
5
+ *
6
+ * @param delta Cursor offset from the gesture start in pixels.
7
+ * @param initialSize Size captured at gesture start.
8
+ * @param initialSize.width Initial width in pixels.
9
+ * @param initialSize.height Initial height in pixels.
10
+ * @param minSize Minimum tile size in pixels.
11
+ * @param minSize.width Minimum width in pixels.
12
+ * @param minSize.height Minimum height in pixels, when vertical resize applies.
13
+ * @param maxSize Maximum tile size in pixels, when one applies.
14
+ * @param maxSize.width Maximum width in pixels.
15
+ * @param maxSize.height Maximum height in pixels, when vertical resize applies.
16
+ */
2
17
  function clampResizeDelta(delta, initialSize, minSize, maxSize) {
3
- const maxShrinkWidth = initialSize.width - minSize.width;
4
- let width = Math.max(delta.width, -maxShrinkWidth);
5
- if (maxSize?.width !== void 0) {
6
- width = Math.min(width, maxSize.width - initialSize.width);
7
- }
8
- if (minSize.height === void 0) {
9
- return { ...delta, width };
10
- }
11
- const maxShrinkHeight = initialSize.height - minSize.height;
12
- let height = Math.max(delta.height, -maxShrinkHeight);
13
- if (maxSize?.height !== void 0) {
14
- height = Math.min(height, maxSize.height - initialSize.height);
15
- }
16
- return { width, height };
18
+ const maxShrinkWidth = initialSize.width - minSize.width;
19
+ let width = Math.max(delta.width, -maxShrinkWidth);
20
+ if (maxSize?.width !== void 0) width = Math.min(width, maxSize.width - initialSize.width);
21
+ if (minSize.height === void 0) return {
22
+ ...delta,
23
+ width
24
+ };
25
+ const maxShrinkHeight = initialSize.height - minSize.height;
26
+ let height = Math.max(delta.height, -maxShrinkHeight);
27
+ if (maxSize?.height !== void 0) height = Math.min(height, maxSize.height - initialSize.height);
28
+ return {
29
+ width,
30
+ height
31
+ };
17
32
  }
33
+ /**
34
+ * Converts grid spans to pixel width/height for the resize-preview
35
+ * outline, using the same track math the surface uses for placement.
36
+ *
37
+ * @param columnSpan Number of columns the snap target spans.
38
+ * @param rowSpan Number of rows the snap target spans.
39
+ * @param columnWidth Width of one column track in pixels.
40
+ * @param gapPx Gap between tracks in pixels.
41
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
42
+ * are content-sized.
43
+ */
18
44
  function gridSpanToPixelSize(columnSpan, rowSpan, columnWidth, gapPx, rowHeightPx) {
19
- const widthPx = columnSpan * columnWidth + (columnSpan - 1) * gapPx;
20
- const heightPx = rowHeightPx === null ? null : rowSpan * rowHeightPx + (rowSpan - 1) * gapPx;
21
- return { widthPx, heightPx };
45
+ return {
46
+ widthPx: columnSpan * columnWidth + (columnSpan - 1) * gapPx,
47
+ heightPx: rowHeightPx === null ? null : rowSpan * rowHeightPx + (rowSpan - 1) * gapPx
48
+ };
22
49
  }
50
+ /**
51
+ * Converts per-item pixel limits to span bounds with the track math of
52
+ * `gridSpanToPixelSize`. Minimums round up, maximums round down, every
53
+ * bound stays at one track or more, and a minimum wins over a smaller
54
+ * maximum. Width bounds saturate at the column count; height bounds
55
+ * resolve to `1`/`Infinity` when rows are content-sized.
56
+ *
57
+ * @param limits Size limits in pixels.
58
+ * @param columnWidth Width of one column track in pixels.
59
+ * @param gapPx Gap between tracks in pixels.
60
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
61
+ * are content-sized.
62
+ * @param maxColumns Number of column tracks in the surface.
63
+ */
23
64
  function pixelLimitsToSpanBounds(limits, columnWidth, gapPx, rowHeightPx, maxColumns) {
24
- let minWidth = 1;
25
- let maxWidth = maxColumns;
26
- if (columnWidth > 0) {
27
- const columnTrack = columnWidth + gapPx;
28
- if (limits.minWidth) {
29
- minWidth = Math.min(
30
- Math.max(
31
- 1,
32
- Math.ceil((limits.minWidth + gapPx) / columnTrack)
33
- ),
34
- maxColumns
35
- );
36
- }
37
- if (limits.maxWidth) {
38
- maxWidth = Math.min(
39
- Math.max(
40
- 1,
41
- Math.floor((limits.maxWidth + gapPx) / columnTrack)
42
- ),
43
- maxColumns
44
- );
45
- }
46
- }
47
- let minHeight = 1;
48
- let maxHeight = Infinity;
49
- if (rowHeightPx !== null && rowHeightPx > 0) {
50
- const rowTrack = rowHeightPx + gapPx;
51
- if (limits.minHeight) {
52
- minHeight = Math.max(
53
- 1,
54
- Math.ceil((limits.minHeight + gapPx) / rowTrack)
55
- );
56
- }
57
- if (limits.maxHeight) {
58
- maxHeight = Math.max(
59
- 1,
60
- Math.floor((limits.maxHeight + gapPx) / rowTrack)
61
- );
62
- }
63
- }
64
- return {
65
- minWidth,
66
- minHeight,
67
- maxWidth: Math.max(maxWidth, minWidth),
68
- maxHeight: Math.max(maxHeight, minHeight)
69
- };
65
+ let minWidth = 1;
66
+ let maxWidth = maxColumns;
67
+ if (columnWidth > 0) {
68
+ const columnTrack = columnWidth + gapPx;
69
+ if (limits.minWidth) minWidth = Math.min(Math.max(1, Math.ceil((limits.minWidth + gapPx) / columnTrack)), maxColumns);
70
+ if (limits.maxWidth) maxWidth = Math.min(Math.max(1, Math.floor((limits.maxWidth + gapPx) / columnTrack)), maxColumns);
71
+ }
72
+ let minHeight = 1;
73
+ let maxHeight = Infinity;
74
+ if (rowHeightPx !== null && rowHeightPx > 0) {
75
+ const rowTrack = rowHeightPx + gapPx;
76
+ if (limits.minHeight) minHeight = Math.max(1, Math.ceil((limits.minHeight + gapPx) / rowTrack));
77
+ if (limits.maxHeight) maxHeight = Math.max(1, Math.floor((limits.maxHeight + gapPx) / rowTrack));
78
+ }
79
+ return {
80
+ minWidth,
81
+ minHeight,
82
+ maxWidth: Math.max(maxWidth, minWidth),
83
+ maxHeight: Math.max(maxHeight, minHeight)
84
+ };
70
85
  }
86
+ /**
87
+ * Clamps a span to the inclusive `[ min, max ]` range.
88
+ *
89
+ * @param span Span in tracks.
90
+ * @param min Lowest allowed span.
91
+ * @param max Highest allowed span.
92
+ */
71
93
  function clampSpan(span, min, max) {
72
- return Math.min(Math.max(span, min), max);
94
+ return Math.min(Math.max(span, min), max);
73
95
  }
96
+ /**
97
+ * Converts span bounds back to pixel limits for the resize gesture,
98
+ * using the same track math as `gridSpanToPixelSize`.
99
+ *
100
+ * @param bounds Span bounds in whole tracks.
101
+ * @param columnWidth Width of one column track in pixels.
102
+ * @param gapPx Gap between tracks in pixels.
103
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
104
+ * are content-sized.
105
+ */
74
106
  function spanBoundsToPixelLimits(bounds, columnWidth, gapPx, rowHeightPx) {
75
- const min = gridSpanToPixelSize(
76
- bounds.minWidth,
77
- bounds.minHeight,
78
- columnWidth,
79
- gapPx,
80
- rowHeightPx
81
- );
82
- const hasMaxHeight = Number.isFinite(bounds.maxHeight);
83
- const max = gridSpanToPixelSize(
84
- bounds.maxWidth,
85
- hasMaxHeight ? bounds.maxHeight : 1,
86
- columnWidth,
87
- gapPx,
88
- hasMaxHeight ? rowHeightPx : null
89
- );
90
- return {
91
- minWidthPx: min.widthPx,
92
- minHeightPx: min.heightPx,
93
- maxWidthPx: max.widthPx,
94
- maxHeightPx: max.heightPx
95
- };
107
+ const min = gridSpanToPixelSize(bounds.minWidth, bounds.minHeight, columnWidth, gapPx, rowHeightPx);
108
+ const hasMaxHeight = Number.isFinite(bounds.maxHeight);
109
+ const max = gridSpanToPixelSize(bounds.maxWidth, hasMaxHeight ? bounds.maxHeight : 1, columnWidth, gapPx, hasMaxHeight ? rowHeightPx : null);
110
+ return {
111
+ minWidthPx: min.widthPx,
112
+ minHeightPx: min.heightPx,
113
+ maxWidthPx: max.widthPx,
114
+ maxHeightPx: max.heightPx
115
+ };
96
116
  }
97
- export {
98
- clampResizeDelta,
99
- clampSpan,
100
- gridSpanToPixelSize,
101
- pixelLimitsToSpanBounds,
102
- spanBoundsToPixelLimits
103
- };
104
- //# sourceMappingURL=resize-snap.mjs.map
117
+ export { clampResizeDelta, clampSpan, gridSpanToPixelSize, pixelLimitsToSpanBounds, spanBoundsToPixelLimits };
118
+
119
+ //# sourceMappingURL=resize-snap.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/shared/resize-snap.ts"],
4
- "sourcesContent": ["import type { GridItemLimits, ResizeDelta } from './types';\n\n/**\n * Pixel dimensions for the snapped resize preview outline.\n */\nexport type ResizeSnapSize = {\n\twidthPx: number;\n\t/** When `null`, the preview spans the item's content height (lanes). */\n\theightPx: number | null;\n};\n\n/**\n * Clamps a resize delta so the tile cannot shrink below the given\n * minimum size, nor grow past the given maximum when one applies.\n *\n * @param delta Cursor offset from the gesture start in pixels.\n * @param initialSize Size captured at gesture start.\n * @param initialSize.width Initial width in pixels.\n * @param initialSize.height Initial height in pixels.\n * @param minSize Minimum tile size in pixels.\n * @param minSize.width Minimum width in pixels.\n * @param minSize.height Minimum height in pixels, when vertical resize applies.\n * @param maxSize Maximum tile size in pixels, when one applies.\n * @param maxSize.width Maximum width in pixels.\n * @param maxSize.height Maximum height in pixels, when vertical resize applies.\n */\nexport function clampResizeDelta(\n\tdelta: ResizeDelta,\n\tinitialSize: { width: number; height: number },\n\tminSize: { width: number; height?: number },\n\tmaxSize?: { width?: number; height?: number }\n): ResizeDelta {\n\tconst maxShrinkWidth = initialSize.width - minSize.width;\n\tlet width = Math.max( delta.width, -maxShrinkWidth );\n\tif ( maxSize?.width !== undefined ) {\n\t\twidth = Math.min( width, maxSize.width - initialSize.width );\n\t}\n\tif ( minSize.height === undefined ) {\n\t\treturn { ...delta, width };\n\t}\n\tconst maxShrinkHeight = initialSize.height - minSize.height;\n\tlet height = Math.max( delta.height, -maxShrinkHeight );\n\tif ( maxSize?.height !== undefined ) {\n\t\theight = Math.min( height, maxSize.height - initialSize.height );\n\t}\n\treturn { width, height };\n}\n\n/**\n * Converts grid spans to pixel width/height for the resize-preview\n * outline, using the same track math the surface uses for placement.\n *\n * @param columnSpan Number of columns the snap target spans.\n * @param rowSpan Number of rows the snap target spans.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n */\nexport function gridSpanToPixelSize(\n\tcolumnSpan: number,\n\trowSpan: number,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null\n): ResizeSnapSize {\n\tconst widthPx = columnSpan * columnWidth + ( columnSpan - 1 ) * gapPx;\n\tconst heightPx =\n\t\trowHeightPx === null\n\t\t\t? null\n\t\t\t: rowSpan * rowHeightPx + ( rowSpan - 1 ) * gapPx;\n\treturn { widthPx, heightPx };\n}\n\n/**\n * Span bounds derived from per-item pixel limits, in whole tracks.\n * Maximums are concrete: an undeclared width maximum resolves to the\n * column count, an undeclared or inapplicable height maximum to\n * `Infinity`.\n */\nexport type SpanBounds = {\n\tminWidth: number;\n\tminHeight: number;\n\tmaxWidth: number;\n\tmaxHeight: number;\n};\n\n/**\n * Converts per-item pixel limits to span bounds with the track math of\n * `gridSpanToPixelSize`. Minimums round up, maximums round down, every\n * bound stays at one track or more, and a minimum wins over a smaller\n * maximum. Width bounds saturate at the column count; height bounds\n * resolve to `1`/`Infinity` when rows are content-sized.\n *\n * @param limits Size limits in pixels.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n * @param maxColumns Number of column tracks in the surface.\n */\nexport function pixelLimitsToSpanBounds(\n\tlimits: GridItemLimits,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null,\n\tmaxColumns: number\n): SpanBounds {\n\tlet minWidth = 1;\n\tlet maxWidth = maxColumns;\n\tif ( columnWidth > 0 ) {\n\t\tconst columnTrack = columnWidth + gapPx;\n\t\tif ( limits.minWidth ) {\n\t\t\tminWidth = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.ceil( ( limits.minWidth + gapPx ) / columnTrack )\n\t\t\t\t),\n\t\t\t\tmaxColumns\n\t\t\t);\n\t\t}\n\t\tif ( limits.maxWidth ) {\n\t\t\tmaxWidth = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.floor( ( limits.maxWidth + gapPx ) / columnTrack )\n\t\t\t\t),\n\t\t\t\tmaxColumns\n\t\t\t);\n\t\t}\n\t}\n\n\tlet minHeight = 1;\n\tlet maxHeight = Infinity;\n\tif ( rowHeightPx !== null && rowHeightPx > 0 ) {\n\t\tconst rowTrack = rowHeightPx + gapPx;\n\t\tif ( limits.minHeight ) {\n\t\t\tminHeight = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.ceil( ( limits.minHeight + gapPx ) / rowTrack )\n\t\t\t);\n\t\t}\n\t\tif ( limits.maxHeight ) {\n\t\t\tmaxHeight = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.floor( ( limits.maxHeight + gapPx ) / rowTrack )\n\t\t\t);\n\t\t}\n\t}\n\n\treturn {\n\t\tminWidth,\n\t\tminHeight,\n\t\tmaxWidth: Math.max( maxWidth, minWidth ),\n\t\tmaxHeight: Math.max( maxHeight, minHeight ),\n\t};\n}\n\n/**\n * Clamps a span to the inclusive `[ min, max ]` range.\n *\n * @param span Span in tracks.\n * @param min Lowest allowed span.\n * @param max Highest allowed span.\n */\nexport function clampSpan( span: number, min: number, max: number ): number {\n\treturn Math.min( Math.max( span, min ), max );\n}\n\n/**\n * Pixel limits for the resize gesture, derived from span bounds.\n * Heights are `null` when rows are content-sized or the height\n * bound is open.\n */\nexport type ResizePixelLimits = {\n\tminWidthPx: number;\n\tminHeightPx: number | null;\n\tmaxWidthPx: number;\n\tmaxHeightPx: number | null;\n};\n\n/**\n * Converts span bounds back to pixel limits for the resize gesture,\n * using the same track math as `gridSpanToPixelSize`.\n *\n * @param bounds Span bounds in whole tracks.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n */\nexport function spanBoundsToPixelLimits(\n\tbounds: SpanBounds,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null\n): ResizePixelLimits {\n\tconst min = gridSpanToPixelSize(\n\t\tbounds.minWidth,\n\t\tbounds.minHeight,\n\t\tcolumnWidth,\n\t\tgapPx,\n\t\trowHeightPx\n\t);\n\tconst hasMaxHeight = Number.isFinite( bounds.maxHeight );\n\tconst max = gridSpanToPixelSize(\n\t\tbounds.maxWidth,\n\t\thasMaxHeight ? bounds.maxHeight : 1,\n\t\tcolumnWidth,\n\t\tgapPx,\n\t\thasMaxHeight ? rowHeightPx : null\n\t);\n\treturn {\n\t\tminWidthPx: min.widthPx,\n\t\tminHeightPx: min.heightPx,\n\t\tmaxWidthPx: max.widthPx,\n\t\tmaxHeightPx: max.heightPx,\n\t};\n}\n"],
5
- "mappings": ";AA0BO,SAAS,iBACf,OACA,aACA,SACA,SACc;AACd,QAAM,iBAAiB,YAAY,QAAQ,QAAQ;AACnD,MAAI,QAAQ,KAAK,IAAK,MAAM,OAAO,CAAC,cAAe;AACnD,MAAK,SAAS,UAAU,QAAY;AACnC,YAAQ,KAAK,IAAK,OAAO,QAAQ,QAAQ,YAAY,KAAM;AAAA,EAC5D;AACA,MAAK,QAAQ,WAAW,QAAY;AACnC,WAAO,EAAE,GAAG,OAAO,MAAM;AAAA,EAC1B;AACA,QAAM,kBAAkB,YAAY,SAAS,QAAQ;AACrD,MAAI,SAAS,KAAK,IAAK,MAAM,QAAQ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S;AAAA,IACvC,WAAW,KAAK,IAAK,WAAW,SAAU;AAAA,EAC3C;AACD;AASO,SAAS,UAAW,MAAc,KAAa,KAAsB;AAC3E,SAAO,KAAK,IAAK,KAAK,IAAK,MAAM,GAAI,GAAG,GAAI;AAC7C;AAwBO,SAAS,wBACf,QACA,aACA,OACA,aACoB;AACpB,QAAM,MAAM;AAAA,IACX,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,eAAe,OAAO,SAAU,OAAO,SAAU;AACvD,QAAM,MAAM;AAAA,IACX,OAAO;AAAA,IACP,eAAe,OAAO,YAAY;AAAA,IAClC;AAAA,IACA;AAAA,IACA,eAAe,cAAc;AAAA,EAC9B;AACA,SAAO;AAAA,IACN,YAAY,IAAI;AAAA,IAChB,aAAa,IAAI;AAAA,IACjB,YAAY,IAAI;AAAA,IAChB,aAAa,IAAI;AAAA,EAClB;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"resize-snap.mjs","names":[],"sources":["../../src/shared/resize-snap.ts"],"sourcesContent":["import type { GridItemLimits, ResizeDelta } from './types';\n\n/**\n * Pixel dimensions for the snapped resize preview outline.\n */\nexport type ResizeSnapSize = {\n\twidthPx: number;\n\t/** When `null`, the preview spans the item's content height (lanes). */\n\theightPx: number | null;\n};\n\n/**\n * Clamps a resize delta so the tile cannot shrink below the given\n * minimum size, nor grow past the given maximum when one applies.\n *\n * @param delta Cursor offset from the gesture start in pixels.\n * @param initialSize Size captured at gesture start.\n * @param initialSize.width Initial width in pixels.\n * @param initialSize.height Initial height in pixels.\n * @param minSize Minimum tile size in pixels.\n * @param minSize.width Minimum width in pixels.\n * @param minSize.height Minimum height in pixels, when vertical resize applies.\n * @param maxSize Maximum tile size in pixels, when one applies.\n * @param maxSize.width Maximum width in pixels.\n * @param maxSize.height Maximum height in pixels, when vertical resize applies.\n */\nexport function clampResizeDelta(\n\tdelta: ResizeDelta,\n\tinitialSize: { width: number; height: number },\n\tminSize: { width: number; height?: number },\n\tmaxSize?: { width?: number; height?: number }\n): ResizeDelta {\n\tconst maxShrinkWidth = initialSize.width - minSize.width;\n\tlet width = Math.max( delta.width, -maxShrinkWidth );\n\tif ( maxSize?.width !== undefined ) {\n\t\twidth = Math.min( width, maxSize.width - initialSize.width );\n\t}\n\tif ( minSize.height === undefined ) {\n\t\treturn { ...delta, width };\n\t}\n\tconst maxShrinkHeight = initialSize.height - minSize.height;\n\tlet height = Math.max( delta.height, -maxShrinkHeight );\n\tif ( maxSize?.height !== undefined ) {\n\t\theight = Math.min( height, maxSize.height - initialSize.height );\n\t}\n\treturn { width, height };\n}\n\n/**\n * Converts grid spans to pixel width/height for the resize-preview\n * outline, using the same track math the surface uses for placement.\n *\n * @param columnSpan Number of columns the snap target spans.\n * @param rowSpan Number of rows the snap target spans.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n */\nexport function gridSpanToPixelSize(\n\tcolumnSpan: number,\n\trowSpan: number,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null\n): ResizeSnapSize {\n\tconst widthPx = columnSpan * columnWidth + ( columnSpan - 1 ) * gapPx;\n\tconst heightPx =\n\t\trowHeightPx === null\n\t\t\t? null\n\t\t\t: rowSpan * rowHeightPx + ( rowSpan - 1 ) * gapPx;\n\treturn { widthPx, heightPx };\n}\n\n/**\n * Span bounds derived from per-item pixel limits, in whole tracks.\n * Maximums are concrete: an undeclared width maximum resolves to the\n * column count, an undeclared or inapplicable height maximum to\n * `Infinity`.\n */\nexport type SpanBounds = {\n\tminWidth: number;\n\tminHeight: number;\n\tmaxWidth: number;\n\tmaxHeight: number;\n};\n\n/**\n * Converts per-item pixel limits to span bounds with the track math of\n * `gridSpanToPixelSize`. Minimums round up, maximums round down, every\n * bound stays at one track or more, and a minimum wins over a smaller\n * maximum. Width bounds saturate at the column count; height bounds\n * resolve to `1`/`Infinity` when rows are content-sized.\n *\n * @param limits Size limits in pixels.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n * @param maxColumns Number of column tracks in the surface.\n */\nexport function pixelLimitsToSpanBounds(\n\tlimits: GridItemLimits,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null,\n\tmaxColumns: number\n): SpanBounds {\n\tlet minWidth = 1;\n\tlet maxWidth = maxColumns;\n\tif ( columnWidth > 0 ) {\n\t\tconst columnTrack = columnWidth + gapPx;\n\t\tif ( limits.minWidth ) {\n\t\t\tminWidth = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.ceil( ( limits.minWidth + gapPx ) / columnTrack )\n\t\t\t\t),\n\t\t\t\tmaxColumns\n\t\t\t);\n\t\t}\n\t\tif ( limits.maxWidth ) {\n\t\t\tmaxWidth = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.floor( ( limits.maxWidth + gapPx ) / columnTrack )\n\t\t\t\t),\n\t\t\t\tmaxColumns\n\t\t\t);\n\t\t}\n\t}\n\n\tlet minHeight = 1;\n\tlet maxHeight = Infinity;\n\tif ( rowHeightPx !== null && rowHeightPx > 0 ) {\n\t\tconst rowTrack = rowHeightPx + gapPx;\n\t\tif ( limits.minHeight ) {\n\t\t\tminHeight = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.ceil( ( limits.minHeight + gapPx ) / rowTrack )\n\t\t\t);\n\t\t}\n\t\tif ( limits.maxHeight ) {\n\t\t\tmaxHeight = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.floor( ( limits.maxHeight + gapPx ) / rowTrack )\n\t\t\t);\n\t\t}\n\t}\n\n\treturn {\n\t\tminWidth,\n\t\tminHeight,\n\t\tmaxWidth: Math.max( maxWidth, minWidth ),\n\t\tmaxHeight: Math.max( maxHeight, minHeight ),\n\t};\n}\n\n/**\n * Clamps a span to the inclusive `[ min, max ]` range.\n *\n * @param span Span in tracks.\n * @param min Lowest allowed span.\n * @param max Highest allowed span.\n */\nexport function clampSpan( span: number, min: number, max: number ): number {\n\treturn Math.min( Math.max( span, min ), max );\n}\n\n/**\n * Pixel limits for the resize gesture, derived from span bounds.\n * Heights are `null` when rows are content-sized or the height\n * bound is open.\n */\nexport type ResizePixelLimits = {\n\tminWidthPx: number;\n\tminHeightPx: number | null;\n\tmaxWidthPx: number;\n\tmaxHeightPx: number | null;\n};\n\n/**\n * Converts span bounds back to pixel limits for the resize gesture,\n * using the same track math as `gridSpanToPixelSize`.\n *\n * @param bounds Span bounds in whole tracks.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n */\nexport function spanBoundsToPixelLimits(\n\tbounds: SpanBounds,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null\n): ResizePixelLimits {\n\tconst min = gridSpanToPixelSize(\n\t\tbounds.minWidth,\n\t\tbounds.minHeight,\n\t\tcolumnWidth,\n\t\tgapPx,\n\t\trowHeightPx\n\t);\n\tconst hasMaxHeight = Number.isFinite( bounds.maxHeight );\n\tconst max = gridSpanToPixelSize(\n\t\tbounds.maxWidth,\n\t\thasMaxHeight ? bounds.maxHeight : 1,\n\t\tcolumnWidth,\n\t\tgapPx,\n\t\thasMaxHeight ? rowHeightPx : null\n\t);\n\treturn {\n\t\tminWidthPx: min.widthPx,\n\t\tminHeightPx: min.heightPx,\n\t\tmaxWidthPx: max.widthPx,\n\t\tmaxHeightPx: max.heightPx,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,SAAgB,iBACf,OACA,aACA,SACA,SACc;CACd,MAAM,iBAAiB,YAAY,QAAQ,QAAQ;CACnD,IAAI,QAAQ,KAAK,IAAK,MAAM,OAAO,CAAC,cAAe;CACnD,IAAK,SAAS,UA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U,QAAS;EACvC,WAAW,KAAK,IAAK,WAAW,SAAU;CAC3C;AACD;;;;;;;;AASA,SAAgB,UAAW,MAAc,KAAa,KAAsB;CAC3E,OAAO,KAAK,IAAK,KAAK,IAAK,MAAM,GAAI,GAAG,GAAI;AAC7C;;;;;;;;;;;AAwBA,SAAgB,wBACf,QACA,aACA,OACA,aACoB;CACpB,MAAM,MAAM,oBACX,OAAO,UACP,OAAO,WACP,aACA,OACA,WACD;CACA,MAAM,eAAe,OAAO,SAAU,OAAO,SAAU;CACvD,MAAM,MAAM,oBACX,OAAO,UACP,eAAe,OAAO,YAAY,GAClC,aACA,OACA,eAAe,cAAc,IAC9B;CACA,OAAO;EACN,YAAY,IAAI;EAChB,aAAa,IAAI;EACjB,YAAY,IAAI;EAChB,aAAa,IAAI;CAClB;AACD"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.mjs.map
@@ -1,128 +1,96 @@
1
+ import { useCallback, useLayoutEffect, useRef, useState } from "@wordpress/element";
1
2
  // packages/grid/src/shared/use-item-exit-animation.ts
2
- import {
3
- useCallback,
4
- useLayoutEffect,
5
- useRef,
6
- useState
7
- } from "@wordpress/element";
8
- var EXIT_SAFETY_TIMEOUT_MS = 1e3;
3
+ const EXIT_SAFETY_TIMEOUT_MS = 1e3;
9
4
  function prefersReducedMotion() {
10
- return typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
5
+ return typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
11
6
  }
12
- function useItemExitAnimation({
13
- container,
14
- enabled,
15
- layoutKeys,
16
- getPositionsBeforeLastChange,
17
- childrenCacheRef
18
- }) {
19
- const [exitingItems, setExitingItems] = useState(
20
- []
21
- );
22
- const prevLayoutKeysRef = useRef(/* @__PURE__ */ new Set());
23
- const exitTimeoutsRef = useRef(/* @__PURE__ */ new Map());
24
- const clearExitingItem = useCallback(
25
- (key) => {
26
- const timeout = exitTimeoutsRef.current.get(key);
27
- if (timeout) {
28
- clearTimeout(timeout);
29
- exitTimeoutsRef.current.delete(key);
30
- }
31
- setExitingItems(
32
- (current) => current.filter((item) => item.key !== key)
33
- );
34
- childrenCacheRef.current.delete(key);
35
- },
36
- [childrenCacheRef]
37
- );
38
- const scheduleExitComplete = useCallback(
39
- (key) => {
40
- if (exitTimeoutsRef.current.has(key)) {
41
- return;
42
- }
43
- const timeout = setTimeout(() => {
44
- exitTimeoutsRef.current.delete(key);
45
- clearExitingItem(key);
46
- }, EXIT_SAFETY_TIMEOUT_MS);
47
- exitTimeoutsRef.current.set(key, timeout);
48
- },
49
- [clearExitingItem]
50
- );
51
- useLayoutEffect(() => {
52
- if (!enabled || !container) {
53
- prevLayoutKeysRef.current = new Set(layoutKeys);
54
- for (const timeout of exitTimeoutsRef.current.values()) {
55
- clearTimeout(timeout);
56
- }
57
- exitTimeoutsRef.current.clear();
58
- setExitingItems([]);
59
- return;
60
- }
61
- const prevKeys = prevLayoutKeysRef.current;
62
- const removed = [];
63
- for (const key of prevKeys) {
64
- if (!layoutKeys.has(key)) {
65
- removed.push(key);
66
- }
67
- }
68
- prevLayoutKeysRef.current = new Set(layoutKeys);
69
- if (removed.length === 0) {
70
- return;
71
- }
72
- const lastPositions = getPositionsBeforeLastChange();
73
- if (!lastPositions) {
74
- return;
75
- }
76
- const nextExiting = [];
77
- for (const key of removed) {
78
- const position = lastPositions.get(key);
79
- const child = childrenCacheRef.current.get(key);
80
- if (!position || !child) {
81
- continue;
82
- }
83
- nextExiting.push({
84
- key,
85
- rect: position,
86
- child
87
- });
88
- }
89
- if (nextExiting.length === 0) {
90
- return;
91
- }
92
- if (prefersReducedMotion()) {
93
- for (const { key } of nextExiting) {
94
- childrenCacheRef.current.delete(key);
95
- }
96
- return;
97
- }
98
- setExitingItems((current) => [...current, ...nextExiting]);
99
- for (const { key } of nextExiting) {
100
- scheduleExitComplete(key);
101
- }
102
- }, [
103
- container,
104
- enabled,
105
- getPositionsBeforeLastChange,
106
- layoutKeys,
107
- childrenCacheRef,
108
- scheduleExitComplete
109
- ]);
110
- useLayoutEffect(() => {
111
- const exitTimeouts = exitTimeoutsRef.current;
112
- return () => {
113
- for (const timeout of exitTimeouts.values()) {
114
- clearTimeout(timeout);
115
- }
116
- exitTimeouts.clear();
117
- };
118
- }, []);
119
- return {
120
- exitingItems,
121
- hasExitingItems: exitingItems.length > 0,
122
- clearExitingItem
123
- };
7
+ /**
8
+ * When `layout` loses keys in edit mode, keeps a short-lived overlay at
9
+ * the removed tile's last position (scale + fade) while siblings FLIP.
10
+ *
11
+ * @param root0 Hook options.
12
+ * @param root0.container Surface root that contains grid tiles.
13
+ * @param root0.enabled When false, exiting state is cleared.
14
+ * @param root0.layoutKeys Keys in the committed `layout` prop.
15
+ * @param root0.getPositionsBeforeLastChange Container-relative rects before the latest layout commit.
16
+ * @param root0.childrenCacheRef Last rendered children keyed by tile id.
17
+ * @return Exiting overlays and a callback to dismiss one by key.
18
+ */
19
+ function useItemExitAnimation({ container, enabled, layoutKeys, getPositionsBeforeLastChange, childrenCacheRef }) {
20
+ const [exitingItems, setExitingItems] = useState([]);
21
+ const prevLayoutKeysRef = useRef(/* @__PURE__ */ new Set());
22
+ const exitTimeoutsRef = useRef(/* @__PURE__ */ new Map());
23
+ const clearExitingItem = useCallback((key) => {
24
+ const timeout = exitTimeoutsRef.current.get(key);
25
+ if (timeout) {
26
+ clearTimeout(timeout);
27
+ exitTimeoutsRef.current.delete(key);
28
+ }
29
+ setExitingItems((current) => current.filter((item) => item.key !== key));
30
+ childrenCacheRef.current.delete(key);
31
+ }, [childrenCacheRef]);
32
+ const scheduleExitComplete = useCallback((key) => {
33
+ if (exitTimeoutsRef.current.has(key)) return;
34
+ const timeout = setTimeout(() => {
35
+ exitTimeoutsRef.current.delete(key);
36
+ clearExitingItem(key);
37
+ }, EXIT_SAFETY_TIMEOUT_MS);
38
+ exitTimeoutsRef.current.set(key, timeout);
39
+ }, [clearExitingItem]);
40
+ useLayoutEffect(() => {
41
+ if (!enabled || !container) {
42
+ prevLayoutKeysRef.current = new Set(layoutKeys);
43
+ for (const timeout of exitTimeoutsRef.current.values()) clearTimeout(timeout);
44
+ exitTimeoutsRef.current.clear();
45
+ setExitingItems([]);
46
+ return;
47
+ }
48
+ const prevKeys = prevLayoutKeysRef.current;
49
+ const removed = [];
50
+ for (const key of prevKeys) if (!layoutKeys.has(key)) removed.push(key);
51
+ prevLayoutKeysRef.current = new Set(layoutKeys);
52
+ if (removed.length === 0) return;
53
+ const lastPositions = getPositionsBeforeLastChange();
54
+ if (!lastPositions) return;
55
+ const nextExiting = [];
56
+ for (const key of removed) {
57
+ const position = lastPositions.get(key);
58
+ const child = childrenCacheRef.current.get(key);
59
+ if (!position || !child) continue;
60
+ nextExiting.push({
61
+ key,
62
+ rect: position,
63
+ child
64
+ });
65
+ }
66
+ if (nextExiting.length === 0) return;
67
+ if (prefersReducedMotion()) {
68
+ for (const { key } of nextExiting) childrenCacheRef.current.delete(key);
69
+ return;
70
+ }
71
+ setExitingItems((current) => [...current, ...nextExiting]);
72
+ for (const { key } of nextExiting) scheduleExitComplete(key);
73
+ }, [
74
+ container,
75
+ enabled,
76
+ getPositionsBeforeLastChange,
77
+ layoutKeys,
78
+ childrenCacheRef,
79
+ scheduleExitComplete
80
+ ]);
81
+ useLayoutEffect(() => {
82
+ const exitTimeouts = exitTimeoutsRef.current;
83
+ return () => {
84
+ for (const timeout of exitTimeouts.values()) clearTimeout(timeout);
85
+ exitTimeouts.clear();
86
+ };
87
+ }, []);
88
+ return {
89
+ exitingItems,
90
+ hasExitingItems: exitingItems.length > 0,
91
+ clearExitingItem
92
+ };
124
93
  }
125
- export {
126
- useItemExitAnimation
127
- };
128
- //# sourceMappingURL=use-item-exit-animation.mjs.map
94
+ export { useItemExitAnimation };
95
+
96
+ //# sourceMappingURL=use-item-exit-animation.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/shared/use-item-exit-animation.ts"],
4
- "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"],
5
- "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AASP,IAAM,yBAAyB;AAyB/B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AAA,IACA,iBAAiB,aAAa,SAAS;AAAA,IACvC;AAAA,EACD;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"use-item-exit-animation.mjs","names":[],"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\texiting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