@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.
- package/README.md +35 -14
- package/build/dashboard-grid/grid-item.cjs +232 -295
- package/build/dashboard-grid/grid-item.cjs.map +1 -7
- package/build/dashboard-grid/index.cjs +526 -633
- package/build/dashboard-grid/index.cjs.map +1 -7
- package/build/dashboard-grid/resolve-fill-widths.cjs +159 -203
- package/build/dashboard-grid/resolve-fill-widths.cjs.map +1 -7
- package/build/dashboard-grid/types.cjs +4 -18
- package/build/dashboard-lanes/index.cjs +495 -577
- package/build/dashboard-lanes/index.cjs.map +1 -7
- package/build/dashboard-lanes/lane-placement.cjs +77 -100
- package/build/dashboard-lanes/lane-placement.cjs.map +1 -7
- package/build/dashboard-lanes/lanes-item.cjs +222 -278
- package/build/dashboard-lanes/lanes-item.cjs.map +1 -7
- package/build/dashboard-lanes/types.cjs +4 -18
- package/build/dashboard-lanes/use-lane-placement.cjs +172 -198
- package/build/dashboard-lanes/use-lane-placement.cjs.map +1 -7
- package/build/index.cjs +16 -31
- package/build/shared/array-move-with-pinned.cjs +29 -45
- package/build/shared/array-move-with-pinned.cjs.map +1 -7
- package/build/shared/column-policy.cjs +58 -0
- package/build/shared/column-policy.cjs.map +1 -0
- package/build/shared/drag-overlay-drop-animation.cjs +40 -66
- package/build/shared/drag-overlay-drop-animation.cjs.map +1 -7
- package/build/shared/grid-item-key.cjs +12 -29
- package/build/shared/grid-item-key.cjs.map +1 -7
- package/build/shared/grid-overlay.cjs +163 -164
- package/build/shared/grid-overlay.cjs.map +1 -7
- package/build/shared/item-exit-overlay.cjs +132 -134
- package/build/shared/item-exit-overlay.cjs.map +1 -7
- package/build/shared/resize-handle.cjs +213 -197
- package/build/shared/resize-handle.cjs.map +1 -7
- package/build/shared/resize-snap.cjs +116 -121
- package/build/shared/resize-snap.cjs.map +1 -7
- package/build/shared/types.cjs +4 -18
- package/build/shared/use-item-exit-animation.cjs +96 -143
- package/build/shared/use-item-exit-animation.cjs.map +1 -7
- package/build/shared/use-layout-shift-animation.cjs +121 -150
- package/build/shared/use-layout-shift-animation.cjs.map +1 -7
- package/build/shared/use-span-bounds.cjs +65 -79
- package/build/shared/use-span-bounds.cjs.map +1 -7
- package/build-module/dashboard-grid/grid-item.mjs +209 -265
- package/build-module/dashboard-grid/grid-item.mjs.map +1 -7
- package/build-module/dashboard-grid/index.mjs +502 -623
- package/build-module/dashboard-grid/index.mjs.map +1 -7
- package/build-module/dashboard-grid/resolve-fill-widths.mjs +155 -179
- package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +1 -7
- package/build-module/dashboard-grid/types.mjs +0 -1
- package/build-module/dashboard-lanes/index.mjs +470 -567
- package/build-module/dashboard-lanes/index.mjs.map +1 -7
- package/build-module/dashboard-lanes/lane-placement.mjs +73 -76
- package/build-module/dashboard-lanes/lane-placement.mjs.map +1 -7
- package/build-module/dashboard-lanes/lanes-item.mjs +199 -248
- package/build-module/dashboard-lanes/lanes-item.mjs.map +1 -7
- package/build-module/dashboard-lanes/types.mjs +0 -1
- package/build-module/dashboard-lanes/use-lane-placement.mjs +167 -173
- package/build-module/dashboard-lanes/use-lane-placement.mjs.map +1 -7
- package/build-module/index.mjs +1 -6
- package/build-module/shared/array-move-with-pinned.mjs +25 -21
- package/build-module/shared/array-move-with-pinned.mjs.map +1 -7
- package/build-module/shared/column-policy.mjs +52 -0
- package/build-module/shared/column-policy.mjs.map +1 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs +35 -44
- package/build-module/shared/drag-overlay-drop-animation.mjs.map +1 -7
- package/build-module/shared/grid-item-key.mjs +8 -5
- package/build-module/shared/grid-item-key.mjs.map +1 -7
- package/build-module/shared/grid-overlay.mjs +143 -136
- package/build-module/shared/grid-overlay.mjs.map +1 -7
- package/build-module/shared/item-exit-overlay.mjs +128 -110
- package/build-module/shared/item-exit-overlay.mjs.map +1 -7
- package/build-module/shared/resize-handle.mjs +191 -171
- package/build-module/shared/resize-handle.mjs.map +1 -7
- package/build-module/shared/resize-snap.mjs +108 -93
- package/build-module/shared/resize-snap.mjs.map +1 -7
- package/build-module/shared/types.mjs +0 -1
- package/build-module/shared/use-item-exit-animation.mjs +92 -124
- package/build-module/shared/use-item-exit-animation.mjs.map +1 -7
- package/build-module/shared/use-layout-shift-animation.mjs +114 -123
- package/build-module/shared/use-layout-shift-animation.mjs.map +1 -7
- package/build-module/shared/use-span-bounds.mjs +60 -57
- package/build-module/shared/use-span-bounds.mjs.map +1 -7
- package/build-types/dashboard-grid/index.d.ts.map +1 -1
- package/build-types/dashboard-grid/types.d.ts +9 -5
- package/build-types/dashboard-grid/types.d.ts.map +1 -1
- package/build-types/dashboard-lanes/index.d.ts.map +1 -1
- package/build-types/dashboard-lanes/types.d.ts +9 -5
- package/build-types/dashboard-lanes/types.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/shared/column-policy.d.ts +43 -0
- package/build-types/shared/column-policy.d.ts.map +1 -0
- package/package.json +14 -12
- package/src/dashboard-grid/grid-item.tsx +1 -1
- package/src/dashboard-grid/{grid.module.css → grid.module.scss} +10 -19
- package/src/dashboard-grid/index.tsx +12 -13
- package/src/dashboard-grid/stories/index.story.tsx +129 -50
- package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
- package/src/dashboard-grid/types.ts +9 -5
- package/src/dashboard-lanes/index.tsx +13 -13
- package/src/dashboard-lanes/lanes-item.tsx +1 -1
- package/src/dashboard-lanes/{lanes.module.css → lanes.module.scss} +10 -19
- package/src/dashboard-lanes/stories/index.story.tsx +124 -28
- package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
- package/src/dashboard-lanes/types.ts +9 -5
- package/src/index.ts +1 -0
- package/src/shared/column-policy.ts +100 -0
- package/src/shared/test/column-policy.test.ts +215 -0
- package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
- package/build/dashboard-grid/types.cjs.map +0 -7
- package/build/dashboard-lanes/types.cjs.map +0 -7
- package/build/index.cjs.map +0 -7
- package/build/shared/types.cjs.map +0 -7
- package/build-module/dashboard-grid/types.mjs.map +0 -7
- package/build-module/dashboard-lanes/types.mjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
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" };
|
|
150
|
+
// packages/grid/src/dashboard-grid/grid.module.scss
|
|
151
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("1271e09bea", ".accd954e27a87edd__grid{display:grid;gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));position:relative}._7eb716cb5b0b9243__drag-preview-frame{border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);cursor:grabbing;height:100%;pointer-events:none}._81f4b86c021354df__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame{animation:ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}._81f4b86c021354df__drag-preview-frame__lift{animation:_839f03e3bf8089bd__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter{0%{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}to{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}}@keyframes _839f03e3bf8089bd__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{animation:ca01d09b92c08943__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{animation:a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes ca01d09b92c08943__wp-grid-drag-preview-shadow-exit{0%{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}to{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}}@keyframes a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01)}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){._7eb716cb5b0b9243__drag-preview-frame{box-shadow:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02)}._81f4b86c021354df__drag-preview-frame__lift{transform:none}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting{box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);transition:none}._7eb716cb5b0b9243__drag-preview-frame._19afc579bbe6da9a__is-exiting ._81f4b86c021354df__drag-preview-frame__lift{transition:none}}");
|
|
152
|
+
var grid_module_default = {
|
|
153
|
+
"grid": "accd954e27a87edd__grid",
|
|
154
|
+
"drag-preview-frame": "_7eb716cb5b0b9243__drag-preview-frame",
|
|
155
|
+
"drag-preview-frame__lift": "_81f4b86c021354df__drag-preview-frame__lift",
|
|
156
|
+
"wp-grid-drag-preview-shadow-enter": "ed7af28ad1378ef2__wp-grid-drag-preview-shadow-enter",
|
|
157
|
+
"wp-grid-drag-preview-scale-enter": "_839f03e3bf8089bd__wp-grid-drag-preview-scale-enter",
|
|
158
|
+
"is-exiting": "_19afc579bbe6da9a__is-exiting",
|
|
159
|
+
"wp-grid-drag-preview-shadow-exit": "ca01d09b92c08943__wp-grid-drag-preview-shadow-exit",
|
|
160
|
+
"wp-grid-drag-preview-scale-exit": "a3ecfa00ffa965a5__wp-grid-drag-preview-scale-exit"
|
|
161
|
+
};
|
|
148
162
|
// packages/grid/src/dashboard-grid/index.tsx
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
547
|
+
exports.DashboardGrid = DashboardGrid;
|
|
548
|
+
|
|
549
|
+
//# sourceMappingURL=index.cjs.map
|