@wordpress/grid 0.10.0 → 0.12.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 (116) 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 +526 -633
  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 +495 -577
  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 +14 -12
  93. package/src/dashboard-grid/grid-item.tsx +1 -1
  94. package/src/dashboard-grid/{grid.module.css → grid.module.scss} +10 -19
  95. package/src/dashboard-grid/index.tsx +12 -13
  96. package/src/dashboard-grid/stories/index.story.tsx +129 -50
  97. package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
  98. package/src/dashboard-grid/types.ts +9 -5
  99. package/src/dashboard-lanes/index.tsx +13 -13
  100. package/src/dashboard-lanes/lanes-item.tsx +1 -1
  101. package/src/dashboard-lanes/{lanes.module.css → lanes.module.scss} +10 -19
  102. package/src/dashboard-lanes/stories/index.story.tsx +124 -28
  103. package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
  104. package/src/dashboard-lanes/types.ts +9 -5
  105. package/src/index.ts +1 -0
  106. package/src/shared/column-policy.ts +100 -0
  107. package/src/shared/test/column-policy.test.ts +215 -0
  108. package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
  109. package/build/dashboard-grid/types.cjs.map +0 -7
  110. package/build/dashboard-lanes/types.cjs.map +0 -7
  111. package/build/index.cjs.map +0 -7
  112. package/build/shared/types.cjs.map +0 -7
  113. package/build-module/dashboard-grid/types.mjs.map +0 -7
  114. package/build-module/dashboard-lanes/types.mjs.map +0 -7
  115. package/build-module/index.mjs.map +0 -7
  116. package/build-module/shared/types.mjs.map +0 -7
@@ -1,133 +1,128 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/grid/src/shared/resize-snap.ts
21
- var resize_snap_exports = {};
22
- __export(resize_snap_exports, {
23
- clampResizeDelta: () => clampResizeDelta,
24
- clampSpan: () => clampSpan,
25
- gridSpanToPixelSize: () => gridSpanToPixelSize,
26
- pixelLimitsToSpanBounds: () => pixelLimitsToSpanBounds,
27
- spanBoundsToPixelLimits: () => spanBoundsToPixelLimits
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
28
5
  });
29
- module.exports = __toCommonJS(resize_snap_exports);
6
+ // packages/grid/src/shared/resize-snap.ts
7
+ /**
8
+ * Clamps a resize delta so the tile cannot shrink below the given
9
+ * minimum size, nor grow past the given maximum when one applies.
10
+ *
11
+ * @param delta Cursor offset from the gesture start in pixels.
12
+ * @param initialSize Size captured at gesture start.
13
+ * @param initialSize.width Initial width in pixels.
14
+ * @param initialSize.height Initial height in pixels.
15
+ * @param minSize Minimum tile size in pixels.
16
+ * @param minSize.width Minimum width in pixels.
17
+ * @param minSize.height Minimum height in pixels, when vertical resize applies.
18
+ * @param maxSize Maximum tile size in pixels, when one applies.
19
+ * @param maxSize.width Maximum width in pixels.
20
+ * @param maxSize.height Maximum height in pixels, when vertical resize applies.
21
+ */
30
22
  function clampResizeDelta(delta, initialSize, minSize, maxSize) {
31
- const maxShrinkWidth = initialSize.width - minSize.width;
32
- let width = Math.max(delta.width, -maxShrinkWidth);
33
- if (maxSize?.width !== void 0) {
34
- width = Math.min(width, maxSize.width - initialSize.width);
35
- }
36
- if (minSize.height === void 0) {
37
- return { ...delta, width };
38
- }
39
- const maxShrinkHeight = initialSize.height - minSize.height;
40
- let height = Math.max(delta.height, -maxShrinkHeight);
41
- if (maxSize?.height !== void 0) {
42
- height = Math.min(height, maxSize.height - initialSize.height);
43
- }
44
- return { width, height };
23
+ const maxShrinkWidth = initialSize.width - minSize.width;
24
+ let width = Math.max(delta.width, -maxShrinkWidth);
25
+ if (maxSize?.width !== void 0) width = Math.min(width, maxSize.width - initialSize.width);
26
+ if (minSize.height === void 0) return {
27
+ ...delta,
28
+ width
29
+ };
30
+ const maxShrinkHeight = initialSize.height - minSize.height;
31
+ let height = Math.max(delta.height, -maxShrinkHeight);
32
+ if (maxSize?.height !== void 0) height = Math.min(height, maxSize.height - initialSize.height);
33
+ return {
34
+ width,
35
+ height
36
+ };
45
37
  }
38
+ /**
39
+ * Converts grid spans to pixel width/height for the resize-preview
40
+ * outline, using the same track math the surface uses for placement.
41
+ *
42
+ * @param columnSpan Number of columns the snap target spans.
43
+ * @param rowSpan Number of rows the snap target spans.
44
+ * @param columnWidth Width of one column track in pixels.
45
+ * @param gapPx Gap between tracks in pixels.
46
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
47
+ * are content-sized.
48
+ */
46
49
  function gridSpanToPixelSize(columnSpan, rowSpan, columnWidth, gapPx, rowHeightPx) {
47
- const widthPx = columnSpan * columnWidth + (columnSpan - 1) * gapPx;
48
- const heightPx = rowHeightPx === null ? null : rowSpan * rowHeightPx + (rowSpan - 1) * gapPx;
49
- return { widthPx, heightPx };
50
+ return {
51
+ widthPx: columnSpan * columnWidth + (columnSpan - 1) * gapPx,
52
+ heightPx: rowHeightPx === null ? null : rowSpan * rowHeightPx + (rowSpan - 1) * gapPx
53
+ };
50
54
  }
55
+ /**
56
+ * Converts per-item pixel limits to span bounds with the track math of
57
+ * `gridSpanToPixelSize`. Minimums round up, maximums round down, every
58
+ * bound stays at one track or more, and a minimum wins over a smaller
59
+ * maximum. Width bounds saturate at the column count; height bounds
60
+ * resolve to `1`/`Infinity` when rows are content-sized.
61
+ *
62
+ * @param limits Size limits in pixels.
63
+ * @param columnWidth Width of one column track in pixels.
64
+ * @param gapPx Gap between tracks in pixels.
65
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
66
+ * are content-sized.
67
+ * @param maxColumns Number of column tracks in the surface.
68
+ */
51
69
  function pixelLimitsToSpanBounds(limits, columnWidth, gapPx, rowHeightPx, maxColumns) {
52
- let minWidth = 1;
53
- let maxWidth = maxColumns;
54
- if (columnWidth > 0) {
55
- const columnTrack = columnWidth + gapPx;
56
- if (limits.minWidth) {
57
- minWidth = Math.min(
58
- Math.max(
59
- 1,
60
- Math.ceil((limits.minWidth + gapPx) / columnTrack)
61
- ),
62
- maxColumns
63
- );
64
- }
65
- if (limits.maxWidth) {
66
- maxWidth = Math.min(
67
- Math.max(
68
- 1,
69
- Math.floor((limits.maxWidth + gapPx) / columnTrack)
70
- ),
71
- maxColumns
72
- );
73
- }
74
- }
75
- let minHeight = 1;
76
- let maxHeight = Infinity;
77
- if (rowHeightPx !== null && rowHeightPx > 0) {
78
- const rowTrack = rowHeightPx + gapPx;
79
- if (limits.minHeight) {
80
- minHeight = Math.max(
81
- 1,
82
- Math.ceil((limits.minHeight + gapPx) / rowTrack)
83
- );
84
- }
85
- if (limits.maxHeight) {
86
- maxHeight = Math.max(
87
- 1,
88
- Math.floor((limits.maxHeight + gapPx) / rowTrack)
89
- );
90
- }
91
- }
92
- return {
93
- minWidth,
94
- minHeight,
95
- maxWidth: Math.max(maxWidth, minWidth),
96
- maxHeight: Math.max(maxHeight, minHeight)
97
- };
70
+ let minWidth = 1;
71
+ let maxWidth = maxColumns;
72
+ if (columnWidth > 0) {
73
+ const columnTrack = columnWidth + gapPx;
74
+ if (limits.minWidth) minWidth = Math.min(Math.max(1, Math.ceil((limits.minWidth + gapPx) / columnTrack)), maxColumns);
75
+ if (limits.maxWidth) maxWidth = Math.min(Math.max(1, Math.floor((limits.maxWidth + gapPx) / columnTrack)), maxColumns);
76
+ }
77
+ let minHeight = 1;
78
+ let maxHeight = Infinity;
79
+ if (rowHeightPx !== null && rowHeightPx > 0) {
80
+ const rowTrack = rowHeightPx + gapPx;
81
+ if (limits.minHeight) minHeight = Math.max(1, Math.ceil((limits.minHeight + gapPx) / rowTrack));
82
+ if (limits.maxHeight) maxHeight = Math.max(1, Math.floor((limits.maxHeight + gapPx) / rowTrack));
83
+ }
84
+ return {
85
+ minWidth,
86
+ minHeight,
87
+ maxWidth: Math.max(maxWidth, minWidth),
88
+ maxHeight: Math.max(maxHeight, minHeight)
89
+ };
98
90
  }
91
+ /**
92
+ * Clamps a span to the inclusive `[ min, max ]` range.
93
+ *
94
+ * @param span Span in tracks.
95
+ * @param min Lowest allowed span.
96
+ * @param max Highest allowed span.
97
+ */
99
98
  function clampSpan(span, min, max) {
100
- return Math.min(Math.max(span, min), max);
99
+ return Math.min(Math.max(span, min), max);
101
100
  }
101
+ /**
102
+ * Converts span bounds back to pixel limits for the resize gesture,
103
+ * using the same track math as `gridSpanToPixelSize`.
104
+ *
105
+ * @param bounds Span bounds in whole tracks.
106
+ * @param columnWidth Width of one column track in pixels.
107
+ * @param gapPx Gap between tracks in pixels.
108
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
109
+ * are content-sized.
110
+ */
102
111
  function spanBoundsToPixelLimits(bounds, columnWidth, gapPx, rowHeightPx) {
103
- const min = gridSpanToPixelSize(
104
- bounds.minWidth,
105
- bounds.minHeight,
106
- columnWidth,
107
- gapPx,
108
- rowHeightPx
109
- );
110
- const hasMaxHeight = Number.isFinite(bounds.maxHeight);
111
- const max = gridSpanToPixelSize(
112
- bounds.maxWidth,
113
- hasMaxHeight ? bounds.maxHeight : 1,
114
- columnWidth,
115
- gapPx,
116
- hasMaxHeight ? rowHeightPx : null
117
- );
118
- return {
119
- minWidthPx: min.widthPx,
120
- minHeightPx: min.heightPx,
121
- maxWidthPx: max.widthPx,
122
- maxHeightPx: max.heightPx
123
- };
112
+ const min = gridSpanToPixelSize(bounds.minWidth, bounds.minHeight, columnWidth, gapPx, rowHeightPx);
113
+ const hasMaxHeight = Number.isFinite(bounds.maxHeight);
114
+ const max = gridSpanToPixelSize(bounds.maxWidth, hasMaxHeight ? bounds.maxHeight : 1, columnWidth, gapPx, hasMaxHeight ? rowHeightPx : null);
115
+ return {
116
+ minWidthPx: min.widthPx,
117
+ minHeightPx: min.heightPx,
118
+ maxWidthPx: max.widthPx,
119
+ maxHeightPx: max.heightPx
120
+ };
124
121
  }
125
- // Annotate the CommonJS export names for ESM import in node:
126
- 0 && (module.exports = {
127
- clampResizeDelta,
128
- clampSpan,
129
- gridSpanToPixelSize,
130
- pixelLimitsToSpanBounds,
131
- spanBoundsToPixelLimits
132
- });
133
- //# sourceMappingURL=resize-snap.cjs.map
122
+ exports.clampResizeDelta = clampResizeDelta;
123
+ exports.clampSpan = clampSpan;
124
+ exports.gridSpanToPixelSize = gridSpanToPixelSize;
125
+ exports.pixelLimitsToSpanBounds = pixelLimitsToSpanBounds;
126
+ exports.spanBoundsToPixelLimits = spanBoundsToPixelLimits;
127
+
128
+ //# sourceMappingURL=resize-snap.cjs.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,CAAC,eAAgB;AACtD,MAAK,SAAS,WAAW,QAAY;AACpC,aAAS,KAAK,IAAK,QAAQ,QAAQ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c,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.cjs","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,UAAU,KAAA,GACvB,QAAQ,KAAK,IAAK,OAAO,QAAQ,QAAQ,YAAY,KAAM;CAE5D,IA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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,19 +1,5 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // packages/grid/src/shared/types.ts
17
- var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
19
- //# sourceMappingURL=types.cjs.map
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
@@ -1,148 +1,101 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/grid/src/shared/use-item-exit-animation.ts
21
- var use_item_exit_animation_exports = {};
22
- __export(use_item_exit_animation_exports, {
23
- useItemExitAnimation: () => useItemExitAnimation
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(use_item_exit_animation_exports);
26
- var import_element = require("@wordpress/element");
27
- var EXIT_SAFETY_TIMEOUT_MS = 1e3;
6
+ let _wordpress_element = require("@wordpress/element");
7
+ // packages/grid/src/shared/use-item-exit-animation.ts
8
+ const EXIT_SAFETY_TIMEOUT_MS = 1e3;
28
9
  function prefersReducedMotion() {
29
- return typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
10
+ return typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
30
11
  }
31
- function useItemExitAnimation({
32
- container,
33
- enabled,
34
- layoutKeys,
35
- getPositionsBeforeLastChange,
36
- childrenCacheRef
37
- }) {
38
- const [exitingItems, setExitingItems] = (0, import_element.useState)(
39
- []
40
- );
41
- const prevLayoutKeysRef = (0, import_element.useRef)(/* @__PURE__ */ new Set());
42
- const exitTimeoutsRef = (0, import_element.useRef)(/* @__PURE__ */ new Map());
43
- const clearExitingItem = (0, import_element.useCallback)(
44
- (key) => {
45
- const timeout = exitTimeoutsRef.current.get(key);
46
- if (timeout) {
47
- clearTimeout(timeout);
48
- exitTimeoutsRef.current.delete(key);
49
- }
50
- setExitingItems(
51
- (current) => current.filter((item) => item.key !== key)
52
- );
53
- childrenCacheRef.current.delete(key);
54
- },
55
- [childrenCacheRef]
56
- );
57
- const scheduleExitComplete = (0, import_element.useCallback)(
58
- (key) => {
59
- if (exitTimeoutsRef.current.has(key)) {
60
- return;
61
- }
62
- const timeout = setTimeout(() => {
63
- exitTimeoutsRef.current.delete(key);
64
- clearExitingItem(key);
65
- }, EXIT_SAFETY_TIMEOUT_MS);
66
- exitTimeoutsRef.current.set(key, timeout);
67
- },
68
- [clearExitingItem]
69
- );
70
- (0, import_element.useLayoutEffect)(() => {
71
- if (!enabled || !container) {
72
- prevLayoutKeysRef.current = new Set(layoutKeys);
73
- for (const timeout of exitTimeoutsRef.current.values()) {
74
- clearTimeout(timeout);
75
- }
76
- exitTimeoutsRef.current.clear();
77
- setExitingItems([]);
78
- return;
79
- }
80
- const prevKeys = prevLayoutKeysRef.current;
81
- const removed = [];
82
- for (const key of prevKeys) {
83
- if (!layoutKeys.has(key)) {
84
- removed.push(key);
85
- }
86
- }
87
- prevLayoutKeysRef.current = new Set(layoutKeys);
88
- if (removed.length === 0) {
89
- return;
90
- }
91
- const lastPositions = getPositionsBeforeLastChange();
92
- if (!lastPositions) {
93
- return;
94
- }
95
- const nextExiting = [];
96
- for (const key of removed) {
97
- const position = lastPositions.get(key);
98
- const child = childrenCacheRef.current.get(key);
99
- if (!position || !child) {
100
- continue;
101
- }
102
- nextExiting.push({
103
- key,
104
- rect: position,
105
- child
106
- });
107
- }
108
- if (nextExiting.length === 0) {
109
- return;
110
- }
111
- if (prefersReducedMotion()) {
112
- for (const { key } of nextExiting) {
113
- childrenCacheRef.current.delete(key);
114
- }
115
- return;
116
- }
117
- setExitingItems((current) => [...current, ...nextExiting]);
118
- for (const { key } of nextExiting) {
119
- scheduleExitComplete(key);
120
- }
121
- }, [
122
- container,
123
- enabled,
124
- getPositionsBeforeLastChange,
125
- layoutKeys,
126
- childrenCacheRef,
127
- scheduleExitComplete
128
- ]);
129
- (0, import_element.useLayoutEffect)(() => {
130
- const exitTimeouts = exitTimeoutsRef.current;
131
- return () => {
132
- for (const timeout of exitTimeouts.values()) {
133
- clearTimeout(timeout);
134
- }
135
- exitTimeouts.clear();
136
- };
137
- }, []);
138
- return {
139
- exitingItems,
140
- hasExitingItems: exitingItems.length > 0,
141
- clearExitingItem
142
- };
12
+ /**
13
+ * When `layout` loses keys in edit mode, keeps a short-lived overlay at
14
+ * the removed tile's last position (scale + fade) while siblings FLIP.
15
+ *
16
+ * @param root0 Hook options.
17
+ * @param root0.container Surface root that contains grid tiles.
18
+ * @param root0.enabled When false, exiting state is cleared.
19
+ * @param root0.layoutKeys Keys in the committed `layout` prop.
20
+ * @param root0.getPositionsBeforeLastChange Container-relative rects before the latest layout commit.
21
+ * @param root0.childrenCacheRef Last rendered children keyed by tile id.
22
+ * @return Exiting overlays and a callback to dismiss one by key.
23
+ */
24
+ function useItemExitAnimation({ container, enabled, layoutKeys, getPositionsBeforeLastChange, childrenCacheRef }) {
25
+ const [exitingItems, setExitingItems] = (0, _wordpress_element.useState)([]);
26
+ const prevLayoutKeysRef = (0, _wordpress_element.useRef)(/* @__PURE__ */ new Set());
27
+ const exitTimeoutsRef = (0, _wordpress_element.useRef)(/* @__PURE__ */ new Map());
28
+ const clearExitingItem = (0, _wordpress_element.useCallback)((key) => {
29
+ const timeout = exitTimeoutsRef.current.get(key);
30
+ if (timeout) {
31
+ clearTimeout(timeout);
32
+ exitTimeoutsRef.current.delete(key);
33
+ }
34
+ setExitingItems((current) => current.filter((item) => item.key !== key));
35
+ childrenCacheRef.current.delete(key);
36
+ }, [childrenCacheRef]);
37
+ const scheduleExitComplete = (0, _wordpress_element.useCallback)((key) => {
38
+ if (exitTimeoutsRef.current.has(key)) return;
39
+ const timeout = setTimeout(() => {
40
+ exitTimeoutsRef.current.delete(key);
41
+ clearExitingItem(key);
42
+ }, EXIT_SAFETY_TIMEOUT_MS);
43
+ exitTimeoutsRef.current.set(key, timeout);
44
+ }, [clearExitingItem]);
45
+ (0, _wordpress_element.useLayoutEffect)(() => {
46
+ if (!enabled || !container) {
47
+ prevLayoutKeysRef.current = new Set(layoutKeys);
48
+ for (const timeout of exitTimeoutsRef.current.values()) clearTimeout(timeout);
49
+ exitTimeoutsRef.current.clear();
50
+ setExitingItems([]);
51
+ return;
52
+ }
53
+ const prevKeys = prevLayoutKeysRef.current;
54
+ const removed = [];
55
+ for (const key of prevKeys) if (!layoutKeys.has(key)) removed.push(key);
56
+ prevLayoutKeysRef.current = new Set(layoutKeys);
57
+ if (removed.length === 0) return;
58
+ const lastPositions = getPositionsBeforeLastChange();
59
+ if (!lastPositions) return;
60
+ const nextExiting = [];
61
+ for (const key of removed) {
62
+ const position = lastPositions.get(key);
63
+ const child = childrenCacheRef.current.get(key);
64
+ if (!position || !child) continue;
65
+ nextExiting.push({
66
+ key,
67
+ rect: position,
68
+ child
69
+ });
70
+ }
71
+ if (nextExiting.length === 0) return;
72
+ if (prefersReducedMotion()) {
73
+ for (const { key } of nextExiting) childrenCacheRef.current.delete(key);
74
+ return;
75
+ }
76
+ setExitingItems((current) => [...current, ...nextExiting]);
77
+ for (const { key } of nextExiting) scheduleExitComplete(key);
78
+ }, [
79
+ container,
80
+ enabled,
81
+ getPositionsBeforeLastChange,
82
+ layoutKeys,
83
+ childrenCacheRef,
84
+ scheduleExitComplete
85
+ ]);
86
+ (0, _wordpress_element.useLayoutEffect)(() => {
87
+ const exitTimeouts = exitTimeoutsRef.current;
88
+ return () => {
89
+ for (const timeout of exitTimeouts.values()) clearTimeout(timeout);
90
+ exitTimeouts.clear();
91
+ };
92
+ }, []);
93
+ return {
94
+ exitingItems,
95
+ hasExitingItems: exitingItems.length > 0,
96
+ clearExitingItem
97
+ };
143
98
  }
144
- // Annotate the CommonJS export names for ESM import in node:
145
- 0 && (module.exports = {
146
- useItemExitAnimation
147
- });
148
- //# sourceMappingURL=use-item-exit-animation.cjs.map
99
+ exports.useItemExitAnimation = useItemExitAnimation;
100
+
101
+ //# sourceMappingURL=use-item-exit-animation.cjs.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\tclear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,OAAO,GAAI;AAC9C,qBAAc,OAAQ;AAAA,MACvB;AACA,mBAAa,MAAM;AAAA,IACpB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAO;AAAA,IACN;AAAA,IACA,iBAAiB,aAAa,SAAS;AAAA,IACvC;AAAA,EACD;AACD;",
6
- "names": []
7
- }
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;CAEA,CAAA,GAAA,mBAAA,g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