@wordpress/grid 0.9.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 (120) 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/build-types/shared/drag-overlay-drop-animation.d.ts +2 -2
  93. package/build-types/shared/use-item-exit-animation.d.ts +1 -1
  94. package/build-types/shared/use-item-exit-animation.d.ts.map +1 -1
  95. package/package.json +13 -14
  96. package/src/dashboard-grid/grid-item.tsx +1 -1
  97. package/src/dashboard-grid/index.tsx +11 -12
  98. package/src/dashboard-grid/stories/index.story.tsx +129 -50
  99. package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
  100. package/src/dashboard-grid/types.ts +9 -5
  101. package/src/dashboard-lanes/index.tsx +11 -11
  102. package/src/dashboard-lanes/lanes-item.tsx +1 -1
  103. package/src/dashboard-lanes/stories/index.story.tsx +124 -28
  104. package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
  105. package/src/dashboard-lanes/types.ts +9 -5
  106. package/src/index.ts +1 -0
  107. package/src/shared/column-policy.ts +100 -0
  108. package/src/shared/drag-overlay-drop-animation.ts +2 -2
  109. package/src/shared/test/column-policy.test.ts +215 -0
  110. package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
  111. package/src/shared/use-item-exit-animation.ts +1 -3
  112. package/CHANGELOG.md +0 -93
  113. package/build/dashboard-grid/types.cjs.map +0 -7
  114. package/build/dashboard-lanes/types.cjs.map +0 -7
  115. package/build/index.cjs.map +0 -7
  116. package/build/shared/types.cjs.map +0 -7
  117. package/build-module/dashboard-grid/types.mjs.map +0 -7
  118. package/build-module/dashboard-lanes/types.mjs.map +0 -7
  119. package/build-module/index.mjs.map +0 -7
  120. package/build-module/shared/types.mjs.map +0 -7
@@ -1,656 +1,549 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
13
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/grid/src/dashboard-grid/index.tsx
31
- var dashboard_grid_exports = {};
32
- __export(dashboard_grid_exports, {
33
- DashboardGrid: () => DashboardGrid
34
- });
35
- module.exports = __toCommonJS(dashboard_grid_exports);
36
- var import_core = require("@dnd-kit/core");
37
- var import_sortable = require("@dnd-kit/sortable");
38
- var import_clsx = __toESM(require("clsx"));
39
- var import_compose = require("@wordpress/compose");
40
- var import_element = require("@wordpress/element");
41
- var import_grid_item = require("./grid-item.cjs");
42
- var import_array_move_with_pinned = require("../shared/array-move-with-pinned.cjs");
43
- var import_grid_overlay = require("../shared/grid-overlay.cjs");
44
- var import_resize_snap = require("../shared/resize-snap.cjs");
45
- var import_use_span_bounds = require("../shared/use-span-bounds.cjs");
46
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _dnd_kit_core = require("@dnd-kit/core");
28
+ let _dnd_kit_sortable = require("@dnd-kit/sortable");
29
+ let clsx = require("clsx");
30
+ clsx = __toESM(clsx);
31
+ let _wordpress_compose = require("@wordpress/compose");
32
+ let _wordpress_element = require("@wordpress/element");
33
+ let __grid_item_tsx = require("./grid-item.cjs");
34
+ let ___shared_array_move_with_pinned_ts = require("../shared/array-move-with-pinned.cjs");
35
+ let ___shared_column_policy_ts = require("../shared/column-policy.cjs");
36
+ let ___shared_grid_overlay_tsx = require("../shared/grid-overlay.cjs");
37
+ let ___shared_resize_snap_ts = require("../shared/resize-snap.cjs");
38
+ let ___shared_use_span_bounds_ts = require("../shared/use-span-bounds.cjs");
39
+ let ___shared_item_exit_overlay_tsx = require("../shared/item-exit-overlay.cjs");
40
+ let ___shared_use_layout_shift_animation_ts = require("../shared/use-layout-shift-animation.cjs");
41
+ let ___shared_use_item_exit_animation_ts = require("../shared/use-item-exit-animation.cjs");
42
+ let __resolve_fill_widths_ts = require("./resolve-fill-widths.cjs");
43
+ let ___shared_drag_overlay_drop_animation_ts = require("../shared/drag-overlay-drop-animation.cjs");
44
+ let react_jsx_runtime = require("react/jsx-runtime");
47
45
  // packages/style-runtime/src/index.ts
48
- var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
46
+ const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
47
+ /**
48
+ * Returns the shared style runtime registry.
49
+ *
50
+ * The registry is stored on `globalThis` so separately bundled copies of this
51
+ * package can coordinate through the same document and style maps.
52
+ *
53
+ * @return The shared runtime registry.
54
+ */
49
55
  function getRuntime() {
50
- const globalScope = globalThis;
51
- if (globalScope.__wpStyleRuntime) {
52
- return globalScope.__wpStyleRuntime;
53
- }
54
- globalScope.__wpStyleRuntime = {
55
- documents: /* @__PURE__ */ new Map(),
56
- styles: /* @__PURE__ */ new Map(),
57
- injectedStyles: /* @__PURE__ */ new WeakMap()
58
- };
59
- if (typeof document !== "undefined") {
60
- registerDocument(document);
61
- }
62
- return globalScope.__wpStyleRuntime;
56
+ const globalScope = globalThis;
57
+ if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
58
+ globalScope.__wpStyleRuntime = {
59
+ documents: /* @__PURE__ */ new Map(),
60
+ styles: /* @__PURE__ */ new Map(),
61
+ injectedStyles: /* @__PURE__ */ new WeakMap()
62
+ };
63
+ if (typeof document !== "undefined") registerDocument(document);
64
+ return globalScope.__wpStyleRuntime;
63
65
  }
66
+ /**
67
+ * Checks whether a document already contains a style tag for a hash.
68
+ *
69
+ * @param targetDocument Document to inspect.
70
+ * @param hash Stable hash for the transformed CSS.
71
+ *
72
+ * @return Whether the style hash already exists in the document.
73
+ */
64
74
  function documentContainsStyleHash(targetDocument, hash) {
65
- if (!targetDocument.head) {
66
- return false;
67
- }
68
- for (const style of targetDocument.head.querySelectorAll(
69
- `style[${STYLE_HASH_ATTRIBUTE}]`
70
- )) {
71
- if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
72
- return true;
73
- }
74
- }
75
- return false;
75
+ if (!targetDocument.head) return false;
76
+ for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
77
+ return false;
76
78
  }
79
+ /**
80
+ * Injects a registered style into a document, unless that document already
81
+ * contains a style tag for the same hash.
82
+ *
83
+ * @param targetDocument Document to inject the style into.
84
+ * @param hash Stable hash for the transformed CSS.
85
+ * @param css CSS text to inject.
86
+ */
77
87
  function injectStyle(targetDocument, hash, css) {
78
- if (!targetDocument.head) {
79
- return;
80
- }
81
- const runtime = getRuntime();
82
- let injectedStyles = runtime.injectedStyles.get(targetDocument);
83
- if (!injectedStyles) {
84
- injectedStyles = /* @__PURE__ */ new Set();
85
- runtime.injectedStyles.set(targetDocument, injectedStyles);
86
- }
87
- if (injectedStyles.has(hash)) {
88
- return;
89
- }
90
- if (documentContainsStyleHash(targetDocument, hash)) {
91
- injectedStyles.add(hash);
92
- return;
93
- }
94
- const style = targetDocument.createElement("style");
95
- style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
96
- style.appendChild(targetDocument.createTextNode(css));
97
- targetDocument.head.appendChild(style);
98
- injectedStyles.add(hash);
88
+ if (!targetDocument.head) return;
89
+ const runtime = getRuntime();
90
+ let injectedStyles = runtime.injectedStyles.get(targetDocument);
91
+ if (!injectedStyles) {
92
+ injectedStyles = /* @__PURE__ */ new Set();
93
+ runtime.injectedStyles.set(targetDocument, injectedStyles);
94
+ }
95
+ if (injectedStyles.has(hash)) return;
96
+ if (documentContainsStyleHash(targetDocument, hash)) {
97
+ injectedStyles.add(hash);
98
+ return;
99
+ }
100
+ const style = targetDocument.createElement("style");
101
+ style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
102
+ style.appendChild(targetDocument.createTextNode(css));
103
+ targetDocument.head.appendChild(style);
104
+ injectedStyles.add(hash);
99
105
  }
106
+ /**
107
+ * Registers a document as a style injection target.
108
+ *
109
+ * Existing registered styles are replayed into the document immediately.
110
+ * Documents are reference-counted so multiple providers can safely register the
111
+ * same document without one cleanup removing it while another registration is
112
+ * still active.
113
+ *
114
+ * @param targetDocument Document to receive registered styles.
115
+ * @return Cleanup function that unregisters this document registration.
116
+ */
100
117
  function registerDocument(targetDocument) {
101
- const runtime = getRuntime();
102
- runtime.documents.set(
103
- targetDocument,
104
- (runtime.documents.get(targetDocument) ?? 0) + 1
105
- );
106
- for (const [hash, css] of runtime.styles) {
107
- injectStyle(targetDocument, hash, css);
108
- }
109
- return () => {
110
- const count = runtime.documents.get(targetDocument);
111
- if (count === void 0) {
112
- return;
113
- }
114
- if (count <= 1) {
115
- runtime.documents.delete(targetDocument);
116
- return;
117
- }
118
- runtime.documents.set(targetDocument, count - 1);
119
- };
118
+ const runtime = getRuntime();
119
+ runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
120
+ for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
121
+ return () => {
122
+ const count = runtime.documents.get(targetDocument);
123
+ if (count === void 0) return;
124
+ if (count <= 1) {
125
+ runtime.documents.delete(targetDocument);
126
+ return;
127
+ }
128
+ runtime.documents.set(targetDocument, count - 1);
129
+ };
120
130
  }
131
+ /**
132
+ * Registers a style and injects it into all registered documents.
133
+ *
134
+ * The hash is used as the deduplication key, so calling this repeatedly with
135
+ * the same hash will not add duplicate style tags to a document.
136
+ * Registered styles are retained for the lifetime of the page so they can be
137
+ * replayed into documents that are registered later.
138
+ *
139
+ * @param hash Stable hash for the transformed CSS.
140
+ * @param css CSS text to inject.
141
+ */
121
142
  function registerStyle(hash, css) {
122
- const runtime = getRuntime();
123
- runtime.styles.set(hash, css);
124
- for (const targetDocument of runtime.documents.keys()) {
125
- injectStyle(targetDocument, hash, css);
126
- }
143
+ const runtime = getRuntime();
144
+ runtime.styles.set(hash, css);
145
+ for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
127
146
  }
128
-
129
147
  // packages/grid/src/shared/layout-shift-animation.module.css
130
- if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
131
- registerStyle("9e5573e51f", "._2db63116caa90ae9__layout-animating [data-wp-grid-item-key]{transition:transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1))}@media (prefers-reduced-motion:reduce){._2db63116caa90ae9__layout-animating [data-wp-grid-item-key]{transition:none}}");
132
- }
133
- var layout_shift_animation_default = { "layout-animating": "_2db63116caa90ae9__layout-animating" };
134
-
135
- // packages/grid/src/dashboard-grid/index.tsx
136
- var import_item_exit_overlay = require("../shared/item-exit-overlay.cjs");
137
- var import_use_layout_shift_animation = require("../shared/use-layout-shift-animation.cjs");
138
- var import_use_item_exit_animation = require("../shared/use-item-exit-animation.cjs");
139
- var import_resolve_fill_widths = require("./resolve-fill-widths.cjs");
140
- var import_drag_overlay_drop_animation = require("../shared/drag-overlay-drop-animation.cjs");
141
-
148
+ if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("5d10111ab0", ".c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1))}@media (prefers-reduced-motion:reduce){.c68bb75eb6bf717a__layout-animating [data-wp-grid-item-key]{transition:none}}");
149
+ var layout_shift_animation_module_default = { "layout-animating": "c68bb75eb6bf717a__layout-animating" };
142
150
  // packages/grid/src/dashboard-grid/grid.module.css
143
- if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
144
- registerStyle("9b45a626c9", "._960c435c33759f46__grid{display:grid;gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));position:relative}._48e8cd4225dcb813__drag-preview-frame{--_wp-grid-elevation-xs:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);--_wp-grid-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:var(--_wp-grid-elevation-md);cursor:grabbing;height:100%;pointer-events:none}._4b471bf24f891d2d__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){._48e8cd4225dcb813__drag-preview-frame{animation:_08fdf90ef86c4706__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}._4b471bf24f891d2d__drag-preview-frame__lift{animation:_8aaeb335436989f9__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes _08fdf90ef86c4706__wp-grid-drag-preview-shadow-enter{0%{box-shadow:var(--_wp-grid-elevation-xs)}to{box-shadow:var(--_wp-grid-elevation-md)}}@keyframes _8aaeb335436989f9__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){._48e8cd4225dcb813__drag-preview-frame.cf64ad2b878ad478__is-exiting{animation:a7ead84bfd25ff8a__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}._48e8cd4225dcb813__drag-preview-frame.cf64ad2b878ad478__is-exiting ._4b471bf24f891d2d__drag-preview-frame__lift{animation:_234ccad5c20d49f8__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes a7ead84bfd25ff8a__wp-grid-drag-preview-shadow-exit{0%{box-shadow:var(--_wp-grid-elevation-md)}to{box-shadow:var(--_wp-grid-elevation-xs)}}@keyframes _234ccad5c20d49f8__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}._48e8cd4225dcb813__drag-preview-frame.cf64ad2b878ad478__is-exiting{box-shadow:var(--_wp-grid-elevation-xs)}._48e8cd4225dcb813__drag-preview-frame.cf64ad2b878ad478__is-exiting ._4b471bf24f891d2d__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){._48e8cd4225dcb813__drag-preview-frame{box-shadow:var(--_wp-grid-elevation-md)}._4b471bf24f891d2d__drag-preview-frame__lift{transform:none}._48e8cd4225dcb813__drag-preview-frame.cf64ad2b878ad478__is-exiting{box-shadow:var(--_wp-grid-elevation-xs);transition:none}._48e8cd4225dcb813__drag-preview-frame.cf64ad2b878ad478__is-exiting ._4b471bf24f891d2d__drag-preview-frame__lift{transition:none}}");
145
- }
146
- var grid_default = { "grid": "_960c435c33759f46__grid", "drag-preview-frame": "_48e8cd4225dcb813__drag-preview-frame", "drag-preview-frame__lift": "_4b471bf24f891d2d__drag-preview-frame__lift", "wp-grid-drag-preview-shadow-enter": "_08fdf90ef86c4706__wp-grid-drag-preview-shadow-enter", "wp-grid-drag-preview-scale-enter": "_8aaeb335436989f9__wp-grid-drag-preview-scale-enter", "is-exiting": "cf64ad2b878ad478__is-exiting", "wp-grid-drag-preview-shadow-exit": "a7ead84bfd25ff8a__wp-grid-drag-preview-shadow-exit", "wp-grid-drag-preview-scale-exit": "_234ccad5c20d49f8__wp-grid-drag-preview-scale-exit" };
147
-
151
+ if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("38b90762ee", "._21f1954f75f72766__grid{display:grid;gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));position:relative}.e464fb19a38466c5__drag-preview-frame{--_wp-grid-elevation-xs:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);--_wp-grid-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:var(--_wp-grid-elevation-md);cursor:grabbing;height:100%;pointer-events:none}.da244be067f8f335__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){.e464fb19a38466c5__drag-preview-frame{animation:_1c00dcb154fe518d__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}.da244be067f8f335__drag-preview-frame__lift{animation:ef2aa0b981f2c744__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes _1c00dcb154fe518d__wp-grid-drag-preview-shadow-enter{0%{box-shadow:var(--_wp-grid-elevation-xs)}to{box-shadow:var(--_wp-grid-elevation-md)}}@keyframes ef2aa0b981f2c744__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting{animation:f1ccc9200b4579c4__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting .da244be067f8f335__drag-preview-frame__lift{animation:c84abadc2143eb8a__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes f1ccc9200b4579c4__wp-grid-drag-preview-shadow-exit{0%{box-shadow:var(--_wp-grid-elevation-md)}to{box-shadow:var(--_wp-grid-elevation-xs)}}@keyframes c84abadc2143eb8a__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting{box-shadow:var(--_wp-grid-elevation-xs)}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting .da244be067f8f335__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){.e464fb19a38466c5__drag-preview-frame{box-shadow:var(--_wp-grid-elevation-md)}.da244be067f8f335__drag-preview-frame__lift{transform:none}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting{box-shadow:var(--_wp-grid-elevation-xs);transition:none}.e464fb19a38466c5__drag-preview-frame._4a025da98b54c1dc__is-exiting .da244be067f8f335__drag-preview-frame__lift{transition:none}}");
152
+ var grid_module_default = {
153
+ "grid": "_21f1954f75f72766__grid",
154
+ "drag-preview-frame": "e464fb19a38466c5__drag-preview-frame",
155
+ "drag-preview-frame__lift": "da244be067f8f335__drag-preview-frame__lift",
156
+ "wp-grid-drag-preview-shadow-enter": "_1c00dcb154fe518d__wp-grid-drag-preview-shadow-enter",
157
+ "wp-grid-drag-preview-scale-enter": "ef2aa0b981f2c744__wp-grid-drag-preview-scale-enter",
158
+ "is-exiting": "_4a025da98b54c1dc__is-exiting",
159
+ "wp-grid-drag-preview-shadow-exit": "f1ccc9200b4579c4__wp-grid-drag-preview-shadow-exit",
160
+ "wp-grid-drag-preview-scale-exit": "c84abadc2143eb8a__wp-grid-drag-preview-scale-exit"
161
+ };
148
162
  // packages/grid/src/dashboard-grid/index.tsx
149
- var import_jsx_runtime = require("react/jsx-runtime");
150
- var dashboardDragDropAnimation = (0, import_drag_overlay_drop_animation.createDashboardDragDropAnimation)(
151
- grid_default["drag-preview-frame"],
152
- grid_default["is-exiting"]
153
- );
154
- var FALLBACK_GAP_PX = 24;
155
- var DEFAULT_COLUMNS = 6;
156
- var NO_SORT_STRATEGY = () => null;
157
- var DashboardGrid = (0, import_element.forwardRef)(
158
- function UnforwardedDashboardGrid(props, ref) {
159
- const {
160
- layout,
161
- columns,
162
- children,
163
- className,
164
- style,
165
- rowHeight = "auto",
166
- minColumnWidth,
167
- itemLimits,
168
- editMode = false,
169
- onChangeLayout,
170
- onPreviewLayout,
171
- renderResizeHandle,
172
- renderDragPreview,
173
- renderGridOverlay,
174
- ...divProps
175
- } = props;
176
- const [temporaryLayout, setTemporaryLayout] = (0, import_element.useState)();
177
- const [activeId, setActiveId] = (0, import_element.useState)(null);
178
- const [isResizing, setIsResizing] = (0, import_element.useState)(false);
179
- const [resizeSnapPreview, setResizeSnapPreview] = (0, import_element.useState)(null);
180
- const latestLayoutRef = (0, import_element.useRef)(
181
- void 0
182
- );
183
- const lastReorderCursorRef = (0, import_element.useRef)(null);
184
- const resizeBaselineRef = (0, import_element.useRef)(null);
185
- const captureLayoutSnapshotRef = (0, import_element.useRef)(() => {
186
- });
187
- const childrenCacheRef = (0, import_element.useRef)(
188
- /* @__PURE__ */ new Map()
189
- );
190
- const [gridRoot, setGridRoot] = (0, import_element.useState)(
191
- null
192
- );
193
- const [containerWidth, setContainerWidth] = (0, import_element.useState)(0);
194
- const [containerHeight, setContainerHeight] = (0, import_element.useState)(0);
195
- const [gapPx, setGapPx] = (0, import_element.useState)(FALLBACK_GAP_PX);
196
- const resizeObserverRef = (0, import_compose.useResizeObserver)(
197
- ([{ contentRect }]) => {
198
- setContainerWidth(contentRect.width);
199
- setContainerHeight(contentRect.height);
200
- }
201
- );
202
- const mergedGridRef = (0, import_compose.useMergeRefs)([
203
- setGridRoot,
204
- resizeObserverRef,
205
- ref
206
- ]);
207
- (0, import_element.useLayoutEffect)(() => {
208
- if (!gridRoot) {
209
- return;
210
- }
211
- const { width, height } = gridRoot.getBoundingClientRect();
212
- if (width > 0) {
213
- setContainerWidth(width);
214
- }
215
- if (height > 0) {
216
- setContainerHeight(height);
217
- }
218
- const parsed = Number.parseFloat(
219
- window.getComputedStyle(gridRoot).columnGap
220
- );
221
- if (Number.isFinite(parsed) && parsed > 0) {
222
- setGapPx(parsed);
223
- }
224
- }, [gridRoot]);
225
- const effectiveColumns = (0, import_element.useMemo)(() => {
226
- if (!minColumnWidth) {
227
- return columns ?? DEFAULT_COLUMNS;
228
- }
229
- const totalWidthPerColumn = minColumnWidth + gapPx;
230
- const maxFit = Math.max(
231
- 1,
232
- Math.floor((containerWidth + gapPx) / totalWidthPerColumn)
233
- );
234
- return columns !== void 0 ? Math.min(columns, maxFit) : maxFit;
235
- }, [minColumnWidth, gapPx, containerWidth, columns]);
236
- const columnWidth = (containerWidth - (effectiveColumns - 1) * gapPx) / effectiveColumns;
237
- const minResizeWidthPx = (0, import_resize_snap.gridSpanToPixelSize)(
238
- 1,
239
- 1,
240
- columnWidth,
241
- gapPx,
242
- null
243
- ).widthPx;
244
- const rowHeightPx = typeof rowHeight === "number" ? rowHeight : null;
245
- const minResizeHeightPx = rowHeightPx === null ? void 0 : (0, import_resize_snap.gridSpanToPixelSize)(1, 1, columnWidth, gapPx, rowHeightPx).heightPx ?? void 0;
246
- const spanBoundsByKey = (0, import_use_span_bounds.useSpanBounds)(
247
- itemLimits,
248
- columnWidth,
249
- gapPx,
250
- rowHeightPx,
251
- effectiveColumns
252
- );
253
- const resizeLimitsByKey = (0, import_use_span_bounds.useResizePixelLimits)(
254
- spanBoundsByKey,
255
- columnWidth,
256
- gapPx,
257
- rowHeightPx
258
- );
259
- const sourceLayout = temporaryLayout ?? layout;
260
- const activeLayout = (0, import_element.useMemo)(() => {
261
- if (spanBoundsByKey.size === 0) {
262
- return sourceLayout;
263
- }
264
- let changed = false;
265
- const bounded = sourceLayout.map((item) => {
266
- const bounds = spanBoundsByKey.get(item.key);
267
- if (!bounds) {
268
- return item;
269
- }
270
- const width = typeof item.width === "number" ? (0, import_resize_snap.clampSpan)(
271
- item.width,
272
- bounds.minWidth,
273
- bounds.maxWidth
274
- ) : item.width;
275
- const height = (0, import_resize_snap.clampSpan)(
276
- item.height ?? 1,
277
- bounds.minHeight,
278
- bounds.maxHeight
279
- );
280
- if (width === item.width && height === (item.height ?? 1)) {
281
- return item;
282
- }
283
- changed = true;
284
- return { ...item, width, height };
285
- });
286
- return changed ? bounded : sourceLayout;
287
- }, [sourceLayout, spanBoundsByKey]);
288
- const layoutMap = (0, import_element.useMemo)(() => {
289
- const map = /* @__PURE__ */ new Map();
290
- activeLayout.forEach((item) => map.set(item.key, item));
291
- return map;
292
- }, [activeLayout]);
293
- const layoutKeys = (0, import_element.useMemo)(
294
- () => new Set(layout.map((item) => item.key)),
295
- [layout]
296
- );
297
- const sortedItems = (0, import_element.useMemo)(
298
- () => activeLayout.map((item, index) => ({ item, index })).sort(
299
- (a, b) => (a.item.order ?? a.index) - (b.item.order ?? b.index)
300
- ).map(({ item }) => item.key),
301
- [activeLayout]
302
- );
303
- const items = sortedItems;
304
- const resolvedItemMap = (0, import_element.useMemo)(() => {
305
- const fillWidths = (0, import_resolve_fill_widths.resolveFillWidths)(
306
- items,
307
- layoutMap,
308
- effectiveColumns,
309
- spanBoundsByKey
310
- );
311
- if (fillWidths.size === 0) {
312
- return layoutMap;
313
- }
314
- const map = /* @__PURE__ */ new Map();
315
- for (const [key, item] of layoutMap) {
316
- const fillW = fillWidths.get(key);
317
- map.set(
318
- key,
319
- fillW !== void 0 ? { ...item, width: fillW } : item
320
- );
321
- }
322
- return map;
323
- }, [items, layoutMap, effectiveColumns, spanBoundsByKey]);
324
- const [childrenMap, actionableAreaMap, remaining, renderedByKey] = (0, import_element.useMemo)(() => {
325
- const childMap = /* @__PURE__ */ new Map();
326
- const actionableMap = /* @__PURE__ */ new Map();
327
- const rest = [];
328
- const byKey = /* @__PURE__ */ new Map();
329
- import_element.Children.forEach(children, (child) => {
330
- if (!(0, import_element.isValidElement)(child)) {
331
- rest.push(child);
332
- return;
333
- }
334
- const key = child.key?.toString();
335
- if (!key) {
336
- rest.push(child);
337
- return;
338
- }
339
- const typedChild = child;
340
- const { actionableArea } = typedChild.props;
341
- const stripped = actionableArea !== void 0 ? (0, import_element.cloneElement)(typedChild, {
342
- actionableArea: void 0
343
- }) : child;
344
- byKey.set(key, stripped);
345
- if (layoutKeys.has(key)) {
346
- if (actionableArea !== void 0) {
347
- actionableMap.set(key, actionableArea);
348
- }
349
- childMap.set(key, stripped);
350
- } else {
351
- rest.push(child);
352
- }
353
- });
354
- return [childMap, actionableMap, rest, byKey];
355
- }, [children, layoutKeys]);
356
- (0, import_element.useLayoutEffect)(() => {
357
- for (const [key, child] of renderedByKey) {
358
- childrenCacheRef.current.set(key, child);
359
- }
360
- }, [renderedByKey]);
361
- const sensors = (0, import_core.useSensors)(
362
- (0, import_core.useSensor)(import_core.PointerSensor),
363
- (0, import_core.useSensor)(import_core.KeyboardSensor, {
364
- coordinateGetter: import_sortable.sortableKeyboardCoordinates
365
- })
366
- );
367
- const handleDragStart = (0, import_compose.useEvent)((event) => {
368
- setActiveId(String(event.active.id));
369
- lastReorderCursorRef.current = null;
370
- });
371
- const handleDragCancel = (0, import_compose.useEvent)(() => {
372
- setActiveId(null);
373
- latestLayoutRef.current = void 0;
374
- lastReorderCursorRef.current = null;
375
- resizeBaselineRef.current = null;
376
- setIsResizing(false);
377
- setResizeSnapPreview(null);
378
- setTemporaryLayout(void 0);
379
- });
380
- const handleDragMove = (0, import_compose.useEvent)((event) => {
381
- const { active, over } = event;
382
- if (!over || active.id === over.id) {
383
- return;
384
- }
385
- const activeRect = active.rect.current.translated;
386
- if (!activeRect) {
387
- return;
388
- }
389
- const activeCenterX = activeRect.left + activeRect.width / 2;
390
- const activeCenterY = activeRect.top + activeRect.height / 2;
391
- const lastCursor = lastReorderCursorRef.current;
392
- if (lastCursor) {
393
- const dx = activeCenterX - lastCursor.x;
394
- const dy = activeCenterY - lastCursor.y;
395
- if (dx * dx + dy * dy < 100) {
396
- return;
397
- }
398
- }
399
- const overCenterX = over.rect.left + over.rect.width / 2;
400
- const insertAfter = activeCenterX > overCenterX;
401
- const currentIndex = items.indexOf(String(active.id));
402
- const overIndex = items.indexOf(String(over.id));
403
- let newIndex;
404
- if (insertAfter) {
405
- newIndex = currentIndex > overIndex ? overIndex + 1 : overIndex;
406
- } else {
407
- newIndex = currentIndex > overIndex ? overIndex : overIndex - 1;
408
- }
409
- newIndex = Math.max(0, Math.min(newIndex, items.length - 1));
410
- if (newIndex === currentIndex) {
411
- return;
412
- }
413
- const updatedItems = (0, import_array_move_with_pinned.arrayMoveWithPinned)(
414
- items,
415
- currentIndex,
416
- newIndex,
417
- (key) => layoutMap.get(key)?.draggable === false
418
- );
419
- if (updatedItems.every((key, index) => key === items[index])) {
420
- return;
421
- }
422
- const updatedLayout = (latestLayoutRef.current ?? layout).map(
423
- (item) => ({
424
- ...item,
425
- order: updatedItems.indexOf(item.key)
426
- })
427
- );
428
- lastReorderCursorRef.current = {
429
- x: activeCenterX,
430
- y: activeCenterY
431
- };
432
- latestLayoutRef.current = updatedLayout;
433
- captureLayoutSnapshotRef.current();
434
- setTemporaryLayout(updatedLayout);
435
- onPreviewLayout?.(updatedLayout);
436
- });
437
- const persistTemporaryLayout = (0, import_compose.useEvent)(() => {
438
- const latest = latestLayoutRef.current;
439
- latestLayoutRef.current = void 0;
440
- resizeBaselineRef.current = null;
441
- setIsResizing(false);
442
- setResizeSnapPreview(null);
443
- if (!onChangeLayout || !latest) {
444
- setTemporaryLayout(void 0);
445
- return;
446
- }
447
- onChangeLayout(latest);
448
- setTemporaryLayout(void 0);
449
- });
450
- const handleResize = (0, import_compose.useEvent)((id, delta) => {
451
- if (!editMode) {
452
- return;
453
- }
454
- if (!isResizing) {
455
- setIsResizing(true);
456
- }
457
- const relativeDelta = {
458
- width: Math.round(delta.width / (columnWidth + gapPx)),
459
- height: rowHeight === "auto" ? 0 : Math.round(delta.height / (rowHeight + gapPx))
460
- };
461
- const bounds = spanBoundsByKey.get(id);
462
- if (!resizeBaselineRef.current) {
463
- const baseItem = layoutMap.get(id);
464
- const resolvedItem = resolvedItemMap.get(id);
465
- let baseWidth;
466
- if (baseItem?.width === "full") {
467
- baseWidth = bounds?.maxWidth ?? effectiveColumns;
468
- } else if (baseItem?.width === "fill") {
469
- baseWidth = typeof resolvedItem?.width === "number" ? resolvedItem.width : 1;
470
- } else {
471
- baseWidth = baseItem?.width ?? 1;
472
- }
473
- resizeBaselineRef.current = {
474
- width: baseWidth,
475
- height: baseItem?.height ?? 1
476
- };
477
- }
478
- const baseline = resizeBaselineRef.current;
479
- const newWidth = (0, import_resize_snap.clampSpan)(
480
- baseline.width + relativeDelta.width,
481
- bounds?.minWidth ?? 1,
482
- bounds?.maxWidth ?? effectiveColumns
483
- );
484
- const newHeight = (0, import_resize_snap.clampSpan)(
485
- baseline.height + relativeDelta.height,
486
- bounds?.minHeight ?? 1,
487
- bounds?.maxHeight ?? Infinity
488
- );
489
- setResizeSnapPreview({
490
- id,
491
- snap: (0, import_resize_snap.gridSpanToPixelSize)(
492
- newWidth,
493
- newHeight,
494
- columnWidth,
495
- gapPx,
496
- rowHeightPx
497
- )
498
- });
499
- const pendingItem = latestLayoutRef.current?.find(
500
- (item) => item.key === id
501
- );
502
- const currentItem = pendingItem ?? layoutMap.get(id);
503
- if (currentItem && currentItem.width === newWidth && (currentItem.height ?? 1) === newHeight) {
504
- return;
505
- }
506
- const updatedLayout = (latestLayoutRef.current ?? layout).map(
507
- (item) => item.key === id ? { ...item, width: newWidth, height: newHeight } : item
508
- );
509
- latestLayoutRef.current = updatedLayout;
510
- captureLayoutSnapshotRef.current();
511
- setTemporaryLayout(updatedLayout);
512
- onPreviewLayout?.(updatedLayout);
513
- });
514
- const activeClone = activeId ? childrenMap.get(activeId) : null;
515
- const DragPreview = renderDragPreview;
516
- const dragOverlayContent = activeId && activeClone ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: grid_default["drag-preview-frame"], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: grid_default["drag-preview-frame__lift"], children: DragPreview ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragPreview, { itemId: activeId, children: activeClone }) : activeClone }) }) : null;
517
- const Overlay = renderGridOverlay ?? import_grid_overlay.GridOverlay;
518
- const overlayRowHeight = typeof rowHeight === "number" ? rowHeight : void 0;
519
- const overlayRows = (0, import_element.useMemo)(() => {
520
- if (overlayRowHeight === void 0 || containerHeight <= 0) {
521
- return void 0;
522
- }
523
- const rowTile = overlayRowHeight + gapPx;
524
- return Math.max(
525
- 1,
526
- Math.floor((containerHeight + gapPx) / rowTile)
527
- );
528
- }, [overlayRowHeight, containerHeight, gapPx]);
529
- const gridOverlay = (0, import_element.useMemo)(
530
- () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
531
- Overlay,
532
- {
533
- columns: effectiveColumns,
534
- rowHeight: overlayRowHeight,
535
- rows: overlayRows,
536
- isActive: editMode
537
- }
538
- ),
539
- [
540
- Overlay,
541
- editMode,
542
- effectiveColumns,
543
- overlayRowHeight,
544
- overlayRows
545
- ]
546
- );
547
- const layoutFingerprint = (0, import_element.useMemo)(
548
- () => (0, import_use_layout_shift_animation.getLayoutFingerprint)([...resolvedItemMap.values()]),
549
- [resolvedItemMap]
550
- );
551
- const excludeLayoutAnimationKey = activeId ?? (isResizing ? resizeSnapPreview?.id : null);
552
- const { captureLayoutSnapshot, getPositionsBeforeLastChange } = (0, import_use_layout_shift_animation.useLayoutShiftAnimation)({
553
- container: gridRoot,
554
- enabled: editMode,
555
- layoutFingerprint,
556
- excludeItemKey: excludeLayoutAnimationKey
557
- });
558
- const { exitingItems, clearExitingItem } = (0, import_use_item_exit_animation.useItemExitAnimation)({
559
- container: gridRoot,
560
- enabled: editMode,
561
- layoutKeys,
562
- getPositionsBeforeLastChange,
563
- childrenCacheRef
564
- });
565
- const layoutAnimating = editMode;
566
- (0, import_element.useLayoutEffect)(() => {
567
- captureLayoutSnapshotRef.current = captureLayoutSnapshot;
568
- }, [captureLayoutSnapshot]);
569
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
570
- import_core.DndContext,
571
- {
572
- sensors,
573
- onDragStart: handleDragStart,
574
- onDragCancel: handleDragCancel,
575
- onDragMove: handleDragMove,
576
- onDragEnd: () => {
577
- persistTemporaryLayout();
578
- lastReorderCursorRef.current = null;
579
- setActiveId(null);
580
- },
581
- children: [
582
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sortable.SortableContext, { items, strategy: NO_SORT_STRATEGY, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
583
- "div",
584
- {
585
- ...divProps,
586
- ref: mergedGridRef,
587
- className: (0, import_clsx.default)(
588
- grid_default.grid,
589
- layoutAnimating && layout_shift_animation_default["layout-animating"],
590
- className
591
- ),
592
- "data-wp-grid-dragging": activeId || void 0,
593
- "data-wp-grid-resizing": isResizing || void 0,
594
- style: {
595
- ...style,
596
- gridTemplateColumns: `repeat(${effectiveColumns}, minmax(0, 1fr))`,
597
- gridAutoRows: rowHeight
598
- },
599
- children: [
600
- gridOverlay,
601
- items.map((id) => {
602
- const limitsPx = resizeLimitsByKey.get(id);
603
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
604
- import_grid_item.GridItem,
605
- {
606
- item: resolvedItemMap.get(
607
- id
608
- ),
609
- maxColumns: spanBoundsByKey.get(id)?.maxWidth ?? effectiveColumns,
610
- disabled: !editMode,
611
- draggable: layoutMap.get(id)?.draggable !== false,
612
- resizable: layoutMap.get(id)?.resizable !== false,
613
- verticalResizable: rowHeight !== "auto",
614
- interacting: activeId !== null || isResizing,
615
- dragging: activeId !== null,
616
- onResize: handleResize,
617
- onResizeEnd: persistTemporaryLayout,
618
- resizeSnapPreview: resizeSnapPreview?.id === id ? resizeSnapPreview.snap : null,
619
- minResizeWidthPx: limitsPx?.minWidthPx ?? minResizeWidthPx,
620
- minResizeHeightPx: limitsPx?.minHeightPx ?? minResizeHeightPx,
621
- maxResizeWidthPx: limitsPx?.maxWidthPx,
622
- maxResizeHeightPx: limitsPx?.maxHeightPx ?? void 0,
623
- actionableArea: actionableAreaMap.get(
624
- id
625
- ),
626
- renderResizeHandle,
627
- children: childrenMap.get(id)
628
- },
629
- id
630
- );
631
- }),
632
- remaining,
633
- exitingItems.map(({ key, rect, child }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
634
- import_item_exit_overlay.ItemExitOverlay,
635
- {
636
- itemKey: key,
637
- rect,
638
- onAnimationEnd: () => clearExitingItem(key),
639
- children: child
640
- },
641
- `exiting-${key}`
642
- ))
643
- ]
644
- }
645
- ) }),
646
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.DragOverlay, { dropAnimation: dashboardDragDropAnimation, children: dragOverlayContent })
647
- ]
648
- }
649
- );
650
- }
651
- );
652
- // Annotate the CommonJS export names for ESM import in node:
653
- 0 && (module.exports = {
654
- DashboardGrid
163
+ const dashboardDragDropAnimation = (0, ___shared_drag_overlay_drop_animation_ts.createDashboardDragDropAnimation)(grid_module_default["drag-preview-frame"], grid_module_default["is-exiting"]);
164
+ const FALLBACK_GAP_PX = 24;
165
+ const DEFAULT_COLUMNS = 6;
166
+ const NO_SORT_STRATEGY = () => null;
167
+ /**
168
+ * 2D packed dashboard grid with drag-to-reorder and resize handles.
169
+ * Supports fixed-column and responsive modes, `number | 'fill' | 'full'`
170
+ * widths, and multi-row tiles.
171
+ *
172
+ * Each child's `key` must match an entry in the `layout` array;
173
+ * children without a match render at the end of the grid without
174
+ * explicit placement and fall through CSS Grid's auto-flow.
175
+ *
176
+ * @example
177
+ * ```jsx
178
+ * const layout = [
179
+ * { key: 'a', width: 2 },
180
+ * { key: 'b', width: 'fill' },
181
+ * { key: 'c', width: 'full' },
182
+ * ];
183
+ *
184
+ * <DashboardGrid
185
+ * layout={ layout }
186
+ * columns={ 6 }
187
+ * editMode
188
+ * onChangeLayout={ setLayout }
189
+ * >
190
+ * <div key="a">A</div>
191
+ * <div key="b">B</div>
192
+ * <div key="c">C</div>
193
+ * </DashboardGrid>
194
+ * ```
195
+ *
196
+ * @param props Component props.
197
+ * @param ref Forwarded to the grid's root `<div>`.
198
+ */
199
+ const DashboardGrid = (0, _wordpress_element.forwardRef)(function UnforwardedDashboardGrid(props, ref) {
200
+ const { layout, columns, children, className, style, rowHeight = "auto", minColumnWidth, itemLimits, editMode = false, onChangeLayout, onPreviewLayout, renderResizeHandle, renderDragPreview, renderGridOverlay, ...divProps } = props;
201
+ const [temporaryLayout, setTemporaryLayout] = (0, _wordpress_element.useState)();
202
+ const [activeId, setActiveId] = (0, _wordpress_element.useState)(null);
203
+ const [isResizing, setIsResizing] = (0, _wordpress_element.useState)(false);
204
+ const [resizeSnapPreview, setResizeSnapPreview] = (0, _wordpress_element.useState)(null);
205
+ const latestLayoutRef = (0, _wordpress_element.useRef)(void 0);
206
+ const lastReorderCursorRef = (0, _wordpress_element.useRef)(null);
207
+ const resizeBaselineRef = (0, _wordpress_element.useRef)(null);
208
+ const captureLayoutSnapshotRef = (0, _wordpress_element.useRef)(() => {});
209
+ const childrenCacheRef = (0, _wordpress_element.useRef)(/* @__PURE__ */ new Map());
210
+ const [gridRoot, setGridRoot] = (0, _wordpress_element.useState)(null);
211
+ const [containerWidth, setContainerWidth] = (0, _wordpress_element.useState)(0);
212
+ const [containerHeight, setContainerHeight] = (0, _wordpress_element.useState)(0);
213
+ const [gapPx, setGapPx] = (0, _wordpress_element.useState)(FALLBACK_GAP_PX);
214
+ const resizeObserverRef = (0, _wordpress_compose.useResizeObserver)(([{ contentRect }]) => {
215
+ setContainerWidth(contentRect.width);
216
+ setContainerHeight(contentRect.height);
217
+ });
218
+ const mergedGridRef = (0, _wordpress_compose.useMergeRefs)([
219
+ setGridRoot,
220
+ resizeObserverRef,
221
+ ref
222
+ ]);
223
+ (0, _wordpress_element.useLayoutEffect)(() => {
224
+ if (!gridRoot) return;
225
+ const { width, height } = gridRoot.getBoundingClientRect();
226
+ if (width > 0) setContainerWidth(width);
227
+ if (height > 0) setContainerHeight(height);
228
+ const parsed = Number.parseFloat(window.getComputedStyle(gridRoot).columnGap);
229
+ if (Number.isFinite(parsed) && parsed > 0) setGapPx(parsed);
230
+ }, [gridRoot]);
231
+ const effectiveColumns = (0, _wordpress_element.useMemo)(() => (0, ___shared_column_policy_ts.resolveColumnCount)({
232
+ columns,
233
+ minColumnWidth
234
+ }, containerWidth, gapPx, DEFAULT_COLUMNS), [
235
+ minColumnWidth,
236
+ gapPx,
237
+ containerWidth,
238
+ columns
239
+ ]);
240
+ const columnWidth = (containerWidth - (effectiveColumns - 1) * gapPx) / effectiveColumns;
241
+ const minResizeWidthPx = (0, ___shared_resize_snap_ts.gridSpanToPixelSize)(1, 1, columnWidth, gapPx, null).widthPx;
242
+ const rowHeightPx = typeof rowHeight === "number" ? rowHeight : null;
243
+ const minResizeHeightPx = rowHeightPx === null ? void 0 : (0, ___shared_resize_snap_ts.gridSpanToPixelSize)(1, 1, columnWidth, gapPx, rowHeightPx).heightPx ?? void 0;
244
+ const spanBoundsByKey = (0, ___shared_use_span_bounds_ts.useSpanBounds)(itemLimits, columnWidth, gapPx, rowHeightPx, effectiveColumns);
245
+ const resizeLimitsByKey = (0, ___shared_use_span_bounds_ts.useResizePixelLimits)(spanBoundsByKey, columnWidth, gapPx, rowHeightPx);
246
+ const sourceLayout = temporaryLayout ?? layout;
247
+ const activeLayout = (0, _wordpress_element.useMemo)(() => {
248
+ if (spanBoundsByKey.size === 0) return sourceLayout;
249
+ let changed = false;
250
+ const bounded = sourceLayout.map((item) => {
251
+ const bounds = spanBoundsByKey.get(item.key);
252
+ if (!bounds) return item;
253
+ const width = typeof item.width === "number" ? (0, ___shared_resize_snap_ts.clampSpan)(item.width, bounds.minWidth, bounds.maxWidth) : item.width;
254
+ const height = (0, ___shared_resize_snap_ts.clampSpan)(item.height ?? 1, bounds.minHeight, bounds.maxHeight);
255
+ if (width === item.width && height === (item.height ?? 1)) return item;
256
+ changed = true;
257
+ return {
258
+ ...item,
259
+ width,
260
+ height
261
+ };
262
+ });
263
+ return changed ? bounded : sourceLayout;
264
+ }, [sourceLayout, spanBoundsByKey]);
265
+ const layoutMap = (0, _wordpress_element.useMemo)(() => {
266
+ const map = /* @__PURE__ */ new Map();
267
+ activeLayout.forEach((item) => map.set(item.key, item));
268
+ return map;
269
+ }, [activeLayout]);
270
+ const layoutKeys = (0, _wordpress_element.useMemo)(() => new Set(layout.map((item) => item.key)), [layout]);
271
+ const items = (0, _wordpress_element.useMemo)(() => activeLayout.map((item, index) => ({
272
+ item,
273
+ index
274
+ })).sort((a, b) => (a.item.order ?? a.index) - (b.item.order ?? b.index)).map(({ item }) => item.key), [activeLayout]);
275
+ const resolvedItemMap = (0, _wordpress_element.useMemo)(() => {
276
+ const fillWidths = (0, __resolve_fill_widths_ts.resolveFillWidths)(items, layoutMap, effectiveColumns, spanBoundsByKey);
277
+ if (fillWidths.size === 0) return layoutMap;
278
+ const map = /* @__PURE__ */ new Map();
279
+ for (const [key, item] of layoutMap) {
280
+ const fillW = fillWidths.get(key);
281
+ map.set(key, fillW !== void 0 ? {
282
+ ...item,
283
+ width: fillW
284
+ } : item);
285
+ }
286
+ return map;
287
+ }, [
288
+ items,
289
+ layoutMap,
290
+ effectiveColumns,
291
+ spanBoundsByKey
292
+ ]);
293
+ const [childrenMap, actionableAreaMap, remaining, renderedByKey] = (0, _wordpress_element.useMemo)(() => {
294
+ const childMap = /* @__PURE__ */ new Map();
295
+ const actionableMap = /* @__PURE__ */ new Map();
296
+ const rest = [];
297
+ const byKey = /* @__PURE__ */ new Map();
298
+ _wordpress_element.Children.forEach(children, (child) => {
299
+ if (!(0, _wordpress_element.isValidElement)(child)) {
300
+ rest.push(child);
301
+ return;
302
+ }
303
+ const key = child.key?.toString();
304
+ if (!key) {
305
+ rest.push(child);
306
+ return;
307
+ }
308
+ const typedChild = child;
309
+ const { actionableArea } = typedChild.props;
310
+ const stripped = actionableArea !== void 0 ? (0, _wordpress_element.cloneElement)(typedChild, { actionableArea: void 0 }) : child;
311
+ byKey.set(key, stripped);
312
+ if (layoutKeys.has(key)) {
313
+ if (actionableArea !== void 0) actionableMap.set(key, actionableArea);
314
+ childMap.set(key, stripped);
315
+ } else rest.push(child);
316
+ });
317
+ return [
318
+ childMap,
319
+ actionableMap,
320
+ rest,
321
+ byKey
322
+ ];
323
+ }, [children, layoutKeys]);
324
+ (0, _wordpress_element.useLayoutEffect)(() => {
325
+ for (const [key, child] of renderedByKey) childrenCacheRef.current.set(key, child);
326
+ }, [renderedByKey]);
327
+ const sensors = (0, _dnd_kit_core.useSensors)((0, _dnd_kit_core.useSensor)(_dnd_kit_core.PointerSensor), (0, _dnd_kit_core.useSensor)(_dnd_kit_core.KeyboardSensor, { coordinateGetter: _dnd_kit_sortable.sortableKeyboardCoordinates }));
328
+ const handleDragStart = (0, _wordpress_compose.useEvent)((event) => {
329
+ setActiveId(String(event.active.id));
330
+ lastReorderCursorRef.current = null;
331
+ });
332
+ const handleDragCancel = (0, _wordpress_compose.useEvent)(() => {
333
+ setActiveId(null);
334
+ latestLayoutRef.current = void 0;
335
+ lastReorderCursorRef.current = null;
336
+ resizeBaselineRef.current = null;
337
+ setIsResizing(false);
338
+ setResizeSnapPreview(null);
339
+ setTemporaryLayout(void 0);
340
+ });
341
+ const handleDragMove = (0, _wordpress_compose.useEvent)((event) => {
342
+ const { active, over } = event;
343
+ if (!over || active.id === over.id) return;
344
+ const activeRect = active.rect.current.translated;
345
+ if (!activeRect) return;
346
+ const activeCenterX = activeRect.left + activeRect.width / 2;
347
+ const activeCenterY = activeRect.top + activeRect.height / 2;
348
+ const lastCursor = lastReorderCursorRef.current;
349
+ if (lastCursor) {
350
+ const dx = activeCenterX - lastCursor.x;
351
+ const dy = activeCenterY - lastCursor.y;
352
+ if (dx * dx + dy * dy < 100) return;
353
+ }
354
+ const insertAfter = activeCenterX > over.rect.left + over.rect.width / 2;
355
+ const currentIndex = items.indexOf(String(active.id));
356
+ const overIndex = items.indexOf(String(over.id));
357
+ let newIndex;
358
+ if (insertAfter) newIndex = currentIndex > overIndex ? overIndex + 1 : overIndex;
359
+ else newIndex = currentIndex > overIndex ? overIndex : overIndex - 1;
360
+ newIndex = Math.max(0, Math.min(newIndex, items.length - 1));
361
+ if (newIndex === currentIndex) return;
362
+ const updatedItems = (0, ___shared_array_move_with_pinned_ts.arrayMoveWithPinned)(items, currentIndex, newIndex, (key) => layoutMap.get(key)?.draggable === false);
363
+ if (updatedItems.every((key, index) => key === items[index])) return;
364
+ const updatedLayout = (latestLayoutRef.current ?? layout).map((item) => ({
365
+ ...item,
366
+ order: updatedItems.indexOf(item.key)
367
+ }));
368
+ lastReorderCursorRef.current = {
369
+ x: activeCenterX,
370
+ y: activeCenterY
371
+ };
372
+ latestLayoutRef.current = updatedLayout;
373
+ captureLayoutSnapshotRef.current();
374
+ setTemporaryLayout(updatedLayout);
375
+ onPreviewLayout?.(updatedLayout);
376
+ });
377
+ const persistTemporaryLayout = (0, _wordpress_compose.useEvent)(() => {
378
+ const latest = latestLayoutRef.current;
379
+ latestLayoutRef.current = void 0;
380
+ resizeBaselineRef.current = null;
381
+ setIsResizing(false);
382
+ setResizeSnapPreview(null);
383
+ if (!onChangeLayout || !latest) {
384
+ setTemporaryLayout(void 0);
385
+ return;
386
+ }
387
+ onChangeLayout(latest);
388
+ setTemporaryLayout(void 0);
389
+ });
390
+ const handleResize = (0, _wordpress_compose.useEvent)((id, delta) => {
391
+ if (!editMode) return;
392
+ if (!isResizing) setIsResizing(true);
393
+ const relativeDelta = {
394
+ width: Math.round(delta.width / (columnWidth + gapPx)),
395
+ height: rowHeight === "auto" ? 0 : Math.round(delta.height / (rowHeight + gapPx))
396
+ };
397
+ const bounds = spanBoundsByKey.get(id);
398
+ if (!resizeBaselineRef.current) {
399
+ const baseItem = layoutMap.get(id);
400
+ const resolvedItem = resolvedItemMap.get(id);
401
+ let baseWidth;
402
+ if (baseItem?.width === "full") baseWidth = bounds?.maxWidth ?? effectiveColumns;
403
+ else if (baseItem?.width === "fill") baseWidth = typeof resolvedItem?.width === "number" ? resolvedItem.width : 1;
404
+ else baseWidth = baseItem?.width ?? 1;
405
+ resizeBaselineRef.current = {
406
+ width: baseWidth,
407
+ height: baseItem?.height ?? 1
408
+ };
409
+ }
410
+ const baseline = resizeBaselineRef.current;
411
+ const newWidth = (0, ___shared_resize_snap_ts.clampSpan)(baseline.width + relativeDelta.width, bounds?.minWidth ?? 1, bounds?.maxWidth ?? effectiveColumns);
412
+ const newHeight = (0, ___shared_resize_snap_ts.clampSpan)(baseline.height + relativeDelta.height, bounds?.minHeight ?? 1, bounds?.maxHeight ?? Infinity);
413
+ setResizeSnapPreview({
414
+ id,
415
+ snap: (0, ___shared_resize_snap_ts.gridSpanToPixelSize)(newWidth, newHeight, columnWidth, gapPx, rowHeightPx)
416
+ });
417
+ const currentItem = latestLayoutRef.current?.find((item) => item.key === id) ?? layoutMap.get(id);
418
+ if (currentItem && currentItem.width === newWidth && (currentItem.height ?? 1) === newHeight) return;
419
+ const updatedLayout = (latestLayoutRef.current ?? layout).map((item) => item.key === id ? {
420
+ ...item,
421
+ width: newWidth,
422
+ height: newHeight
423
+ } : item);
424
+ latestLayoutRef.current = updatedLayout;
425
+ captureLayoutSnapshotRef.current();
426
+ setTemporaryLayout(updatedLayout);
427
+ onPreviewLayout?.(updatedLayout);
428
+ });
429
+ const activeClone = activeId ? childrenMap.get(activeId) : null;
430
+ const DragPreview = renderDragPreview;
431
+ const dragOverlayContent = activeId && activeClone ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
432
+ className: grid_module_default["drag-preview-frame"],
433
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
434
+ className: grid_module_default["drag-preview-frame__lift"],
435
+ children: DragPreview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DragPreview, {
436
+ itemId: activeId,
437
+ children: activeClone
438
+ }) : activeClone
439
+ })
440
+ }) : null;
441
+ const Overlay = renderGridOverlay ?? ___shared_grid_overlay_tsx.GridOverlay;
442
+ const overlayRowHeight = typeof rowHeight === "number" ? rowHeight : void 0;
443
+ const overlayRows = (0, _wordpress_element.useMemo)(() => {
444
+ if (overlayRowHeight === void 0 || containerHeight <= 0) return;
445
+ const rowTile = overlayRowHeight + gapPx;
446
+ return Math.max(1, Math.floor((containerHeight + gapPx) / rowTile));
447
+ }, [
448
+ overlayRowHeight,
449
+ containerHeight,
450
+ gapPx
451
+ ]);
452
+ const gridOverlay = (0, _wordpress_element.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Overlay, {
453
+ columns: effectiveColumns,
454
+ rowHeight: overlayRowHeight,
455
+ rows: overlayRows,
456
+ isActive: editMode
457
+ }), [
458
+ Overlay,
459
+ editMode,
460
+ effectiveColumns,
461
+ overlayRowHeight,
462
+ overlayRows
463
+ ]);
464
+ const layoutFingerprint = (0, _wordpress_element.useMemo)(() => (0, ___shared_use_layout_shift_animation_ts.getLayoutFingerprint)([...resolvedItemMap.values()]), [resolvedItemMap]);
465
+ const excludeLayoutAnimationKey = activeId ?? (isResizing ? resizeSnapPreview?.id : null);
466
+ const { captureLayoutSnapshot, getPositionsBeforeLastChange } = (0, ___shared_use_layout_shift_animation_ts.useLayoutShiftAnimation)({
467
+ container: gridRoot,
468
+ enabled: editMode,
469
+ layoutFingerprint,
470
+ excludeItemKey: excludeLayoutAnimationKey
471
+ });
472
+ const { exitingItems, clearExitingItem } = (0, ___shared_use_item_exit_animation_ts.useItemExitAnimation)({
473
+ container: gridRoot,
474
+ enabled: editMode,
475
+ layoutKeys,
476
+ getPositionsBeforeLastChange,
477
+ childrenCacheRef
478
+ });
479
+ const layoutAnimating = editMode;
480
+ (0, _wordpress_element.useLayoutEffect)(() => {
481
+ captureLayoutSnapshotRef.current = captureLayoutSnapshot;
482
+ }, [captureLayoutSnapshot]);
483
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_dnd_kit_core.DndContext, {
484
+ sensors,
485
+ onDragStart: handleDragStart,
486
+ onDragCancel: handleDragCancel,
487
+ onDragMove: handleDragMove,
488
+ onDragEnd: () => {
489
+ persistTemporaryLayout();
490
+ lastReorderCursorRef.current = null;
491
+ setActiveId(null);
492
+ },
493
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_dnd_kit_sortable.SortableContext, {
494
+ items,
495
+ strategy: NO_SORT_STRATEGY,
496
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
497
+ ...divProps,
498
+ ref: mergedGridRef,
499
+ className: (0, clsx.default)(grid_module_default.grid, layoutAnimating && layout_shift_animation_module_default["layout-animating"], className),
500
+ "data-wp-grid-dragging": activeId || void 0,
501
+ "data-wp-grid-resizing": isResizing || void 0,
502
+ style: {
503
+ ...style,
504
+ gridTemplateColumns: `repeat(${effectiveColumns}, minmax(0, 1fr))`,
505
+ gridAutoRows: rowHeight
506
+ },
507
+ children: [
508
+ gridOverlay,
509
+ items.map((id) => {
510
+ const limitsPx = resizeLimitsByKey.get(id);
511
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__grid_item_tsx.GridItem, {
512
+ item: resolvedItemMap.get(id),
513
+ maxColumns: spanBoundsByKey.get(id)?.maxWidth ?? effectiveColumns,
514
+ disabled: !editMode,
515
+ draggable: layoutMap.get(id)?.draggable !== false,
516
+ resizable: layoutMap.get(id)?.resizable !== false,
517
+ verticalResizable: rowHeight !== "auto",
518
+ interacting: activeId !== null || isResizing,
519
+ dragging: activeId !== null,
520
+ onResize: handleResize,
521
+ onResizeEnd: persistTemporaryLayout,
522
+ resizeSnapPreview: resizeSnapPreview?.id === id ? resizeSnapPreview.snap : null,
523
+ minResizeWidthPx: limitsPx?.minWidthPx ?? minResizeWidthPx,
524
+ minResizeHeightPx: limitsPx?.minHeightPx ?? minResizeHeightPx,
525
+ maxResizeWidthPx: limitsPx?.maxWidthPx,
526
+ maxResizeHeightPx: limitsPx?.maxHeightPx ?? void 0,
527
+ actionableArea: actionableAreaMap.get(id),
528
+ renderResizeHandle,
529
+ children: childrenMap.get(id)
530
+ }, id);
531
+ }),
532
+ remaining,
533
+ exitingItems.map(({ key, rect, child }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___shared_item_exit_overlay_tsx.ItemExitOverlay, {
534
+ itemKey: key,
535
+ rect,
536
+ onAnimationEnd: () => clearExitingItem(key),
537
+ children: child
538
+ }, `exiting-${key}`))
539
+ ]
540
+ })
541
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_dnd_kit_core.DragOverlay, {
542
+ dropAnimation: dashboardDragDropAnimation,
543
+ children: dragOverlayContent
544
+ })]
545
+ });
655
546
  });
656
- //# sourceMappingURL=index.cjs.map
547
+ exports.DashboardGrid = DashboardGrid;
548
+
549
+ //# sourceMappingURL=index.cjs.map