@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.
- 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 +525 -632
- 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 +494 -576
- 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/build-types/shared/drag-overlay-drop-animation.d.ts +2 -2
- package/build-types/shared/use-item-exit-animation.d.ts +1 -1
- package/build-types/shared/use-item-exit-animation.d.ts.map +1 -1
- package/package.json +13 -14
- package/src/dashboard-grid/grid-item.tsx +1 -1
- package/src/dashboard-grid/index.tsx +11 -12
- 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 +11 -11
- package/src/dashboard-lanes/lanes-item.tsx +1 -1
- 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/drag-overlay-drop-animation.ts +2 -2
- package/src/shared/test/column-policy.test.ts +215 -0
- package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
- package/src/shared/use-item-exit-animation.ts +1 -3
- package/CHANGELOG.md +0 -93
- 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,600 +1,518 @@
|
|
|
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_use_lane_placement = require("./use-lane-placement.cjs");
|
|
43
|
-
var import_array_move_with_pinned = require("../shared/array-move-with-pinned.cjs");
|
|
44
|
-
var import_grid_overlay = require("../shared/grid-overlay.cjs");
|
|
45
|
-
var import_resize_snap = require("../shared/resize-snap.cjs");
|
|
46
|
-
var import_use_span_bounds = require("../shared/use-span-bounds.cjs");
|
|
47
|
-
|
|
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 __lanes_item_tsx = require("./lanes-item.cjs");
|
|
34
|
+
let __use_lane_placement_ts = require("./use-lane-placement.cjs");
|
|
35
|
+
let ___shared_array_move_with_pinned_ts = require("../shared/array-move-with-pinned.cjs");
|
|
36
|
+
let ___shared_column_policy_ts = require("../shared/column-policy.cjs");
|
|
37
|
+
let ___shared_grid_overlay_tsx = require("../shared/grid-overlay.cjs");
|
|
38
|
+
let ___shared_resize_snap_ts = require("../shared/resize-snap.cjs");
|
|
39
|
+
let ___shared_use_span_bounds_ts = require("../shared/use-span-bounds.cjs");
|
|
40
|
+
let ___shared_item_exit_overlay_tsx = require("../shared/item-exit-overlay.cjs");
|
|
41
|
+
let ___shared_use_layout_shift_animation_ts = require("../shared/use-layout-shift-animation.cjs");
|
|
42
|
+
let ___shared_use_item_exit_animation_ts = require("../shared/use-item-exit-animation.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");
|
|
48
45
|
// packages/style-runtime/src/index.ts
|
|
49
|
-
|
|
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
|
+
*/
|
|
50
55
|
function getRuntime() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (typeof document !== "undefined") {
|
|
61
|
-
registerDocument(document);
|
|
62
|
-
}
|
|
63
|
-
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;
|
|
64
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
|
+
*/
|
|
65
74
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
70
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
71
|
-
)) {
|
|
72
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
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;
|
|
77
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
|
+
*/
|
|
78
87
|
function injectStyle(targetDocument, hash, css) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
97
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
98
|
-
targetDocument.head.appendChild(style);
|
|
99
|
-
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);
|
|
100
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
|
+
*/
|
|
101
117
|
function registerDocument(targetDocument) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
if (count <= 1) {
|
|
116
|
-
runtime.documents.delete(targetDocument);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
120
|
-
};
|
|
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
|
+
};
|
|
121
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
|
+
*/
|
|
122
142
|
function registerStyle(hash, css) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
injectStyle(targetDocument, hash, css);
|
|
127
|
-
}
|
|
143
|
+
const runtime = getRuntime();
|
|
144
|
+
runtime.styles.set(hash, css);
|
|
145
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
128
146
|
}
|
|
129
|
-
|
|
130
147
|
// packages/grid/src/shared/layout-shift-animation.module.css
|
|
131
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
var layout_shift_animation_default = { "layout-animating": "_2db63116caa90ae9__layout-animating" };
|
|
135
|
-
|
|
136
|
-
// packages/grid/src/dashboard-lanes/index.tsx
|
|
137
|
-
var import_item_exit_overlay = require("../shared/item-exit-overlay.cjs");
|
|
138
|
-
var import_use_layout_shift_animation = require("../shared/use-layout-shift-animation.cjs");
|
|
139
|
-
var import_use_item_exit_animation = require("../shared/use-item-exit-animation.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-lanes/lanes.module.css
|
|
143
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("6b5b6b8d59", "._279d14c775dbbe7a__lanes{column-gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));display:grid-lanes;position:relative;row-gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px))}@supports not (display:grid-lanes){._279d14c775dbbe7a__lanes{display:grid;grid-auto-flow:dense;grid-auto-rows:var(--wp-grid-lane-row-unit,4px);row-gap:0}}.cf1a25111e009cff__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}._1670330318f73437__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){.cf1a25111e009cff__drag-preview-frame{animation:c44ad0dc1d6b976a__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}._1670330318f73437__drag-preview-frame__lift{animation:dba9b43a556bb015__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 c44ad0dc1d6b976a__wp-grid-drag-preview-shadow-enter{0%{box-shadow:var(--_wp-grid-elevation-xs)}to{box-shadow:var(--_wp-grid-elevation-md)}}@keyframes dba9b43a556bb015__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){.cf1a25111e009cff__drag-preview-frame._44fd9c611b434255__is-exiting{animation:_5f907efa9ff8caac__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}.cf1a25111e009cff__drag-preview-frame._44fd9c611b434255__is-exiting ._1670330318f73437__drag-preview-frame__lift{animation:a91293ba67737ef7__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 _5f907efa9ff8caac__wp-grid-drag-preview-shadow-exit{0%{box-shadow:var(--_wp-grid-elevation-md)}to{box-shadow:var(--_wp-grid-elevation-xs)}}@keyframes a91293ba67737ef7__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}.cf1a25111e009cff__drag-preview-frame._44fd9c611b434255__is-exiting{box-shadow:var(--_wp-grid-elevation-xs)}.cf1a25111e009cff__drag-preview-frame._44fd9c611b434255__is-exiting ._1670330318f73437__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){.cf1a25111e009cff__drag-preview-frame{box-shadow:var(--_wp-grid-elevation-md)}._1670330318f73437__drag-preview-frame__lift{transform:none}.cf1a25111e009cff__drag-preview-frame._44fd9c611b434255__is-exiting{box-shadow:var(--_wp-grid-elevation-xs);transition:none}.cf1a25111e009cff__drag-preview-frame._44fd9c611b434255__is-exiting ._1670330318f73437__drag-preview-frame__lift{transition:none}}");
|
|
152
|
+
var lanes_module_default = {
|
|
153
|
+
"lanes": "_279d14c775dbbe7a__lanes",
|
|
154
|
+
"drag-preview-frame": "cf1a25111e009cff__drag-preview-frame",
|
|
155
|
+
"drag-preview-frame__lift": "_1670330318f73437__drag-preview-frame__lift",
|
|
156
|
+
"wp-grid-drag-preview-shadow-enter": "c44ad0dc1d6b976a__wp-grid-drag-preview-shadow-enter",
|
|
157
|
+
"wp-grid-drag-preview-scale-enter": "dba9b43a556bb015__wp-grid-drag-preview-scale-enter",
|
|
158
|
+
"is-exiting": "_44fd9c611b434255__is-exiting",
|
|
159
|
+
"wp-grid-drag-preview-shadow-exit": "_5f907efa9ff8caac__wp-grid-drag-preview-shadow-exit",
|
|
160
|
+
"wp-grid-drag-preview-scale-exit": "a91293ba67737ef7__wp-grid-drag-preview-scale-exit"
|
|
161
|
+
};
|
|
148
162
|
// packages/grid/src/dashboard-lanes/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
|
-
}, [captureLayoutSnapshot]);
|
|
502
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
503
|
-
import_core.DndContext,
|
|
504
|
-
{
|
|
505
|
-
sensors,
|
|
506
|
-
onDragStart: handleDragStart,
|
|
507
|
-
onDragCancel: handleDragCancel,
|
|
508
|
-
onDragMove: handleDragMove,
|
|
509
|
-
onDragEnd: () => {
|
|
510
|
-
persistTemporaryLayout();
|
|
511
|
-
lastReorderCursorRef.current = null;
|
|
512
|
-
setActiveId(null);
|
|
513
|
-
},
|
|
514
|
-
children: [
|
|
515
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sortable.SortableContext, { items, strategy: NO_SORT_STRATEGY, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
516
|
-
"div",
|
|
517
|
-
{
|
|
518
|
-
...divProps,
|
|
519
|
-
ref: mergedRootRef,
|
|
520
|
-
className: (0, import_clsx.default)(
|
|
521
|
-
lanes_default.lanes,
|
|
522
|
-
layoutAnimating && layout_shift_animation_default["layout-animating"],
|
|
523
|
-
className
|
|
524
|
-
),
|
|
525
|
-
"data-wp-grid-dragging": activeId || void 0,
|
|
526
|
-
"data-wp-grid-resizing": isResizing || void 0,
|
|
527
|
-
style: {
|
|
528
|
-
...style,
|
|
529
|
-
gridTemplateColumns: `repeat(${effectiveColumns}, minmax(0, 1fr))`,
|
|
530
|
-
// `column-gap` and `row-gap` are set in
|
|
531
|
-
// `lanes.module.css` from the
|
|
532
|
-
// design-system gap token, with an
|
|
533
|
-
// `@supports` block that zeroes `row-gap`
|
|
534
|
-
// in polyfill mode (the skyline already
|
|
535
|
-
// encodes vertical spacing in each tile's
|
|
536
|
-
// `top`). Driving the toggle from CSS
|
|
537
|
-
// keeps SSR and client output identical
|
|
538
|
-
// regardless of native support.
|
|
539
|
-
"--wp-grid-lane-row-unit": `${Math.max(
|
|
540
|
-
1,
|
|
541
|
-
rowUnit
|
|
542
|
-
)}px`
|
|
543
|
-
},
|
|
544
|
-
children: [
|
|
545
|
-
gridOverlay,
|
|
546
|
-
items.map((id) => {
|
|
547
|
-
const child = childrenMap.get(id);
|
|
548
|
-
if (!child) {
|
|
549
|
-
return null;
|
|
550
|
-
}
|
|
551
|
-
const limitsPx = resizeLimitsByKey.get(id);
|
|
552
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
553
|
-
import_lanes_item.LanesItem,
|
|
554
|
-
{
|
|
555
|
-
itemKey: id,
|
|
556
|
-
placementStyle: itemStyles.get(id) ?? {},
|
|
557
|
-
disabled: !editMode,
|
|
558
|
-
draggable: layoutMap.get(id)?.draggable !== false,
|
|
559
|
-
resizable: layoutMap.get(id)?.resizable !== false,
|
|
560
|
-
interacting,
|
|
561
|
-
dragging: activeId !== null,
|
|
562
|
-
onResize: handleResize,
|
|
563
|
-
onResizeEnd: persistTemporaryLayout,
|
|
564
|
-
resizeSnapPreview: resizeSnapPreview?.id === id ? resizeSnapPreview.snap : null,
|
|
565
|
-
minResizeWidthPx: limitsPx?.minWidthPx ?? minResizeWidthPx,
|
|
566
|
-
maxResizeWidthPx: limitsPx?.maxWidthPx,
|
|
567
|
-
actionableArea: actionableAreaMap.get(
|
|
568
|
-
id
|
|
569
|
-
),
|
|
570
|
-
renderResizeHandle,
|
|
571
|
-
children: child
|
|
572
|
-
},
|
|
573
|
-
id
|
|
574
|
-
);
|
|
575
|
-
}),
|
|
576
|
-
remaining,
|
|
577
|
-
exitingItems.map(({ key, rect, child }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
578
|
-
import_item_exit_overlay.ItemExitOverlay,
|
|
579
|
-
{
|
|
580
|
-
itemKey: key,
|
|
581
|
-
rect,
|
|
582
|
-
onAnimationEnd: () => clearExitingItem(key),
|
|
583
|
-
children: child
|
|
584
|
-
},
|
|
585
|
-
`exiting-${key}`
|
|
586
|
-
))
|
|
587
|
-
]
|
|
588
|
-
}
|
|
589
|
-
) }),
|
|
590
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.DragOverlay, { dropAnimation: dashboardDragDropAnimation, children: dragOverlayContent })
|
|
591
|
-
]
|
|
592
|
-
}
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
);
|
|
596
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
597
|
-
0 && (module.exports = {
|
|
598
|
-
DashboardLanes
|
|
163
|
+
const dashboardDragDropAnimation = (0, ___shared_drag_overlay_drop_animation_ts.createDashboardDragDropAnimation)(lanes_module_default["drag-preview-frame"], lanes_module_default["is-exiting"]);
|
|
164
|
+
const FALLBACK_GAP_PX = 24;
|
|
165
|
+
const DEFAULT_COLUMNS = 6;
|
|
166
|
+
const NO_SORT_STRATEGY = () => null;
|
|
167
|
+
/**
|
|
168
|
+
* Masonry-style surface aligned with `display: grid-lanes`. Items
|
|
169
|
+
* declare a column span; heights are driven by content; placement
|
|
170
|
+
* follows the source-ordered, shortest-lane algorithm with
|
|
171
|
+
* `flow-tolerance` tiebreaking.
|
|
172
|
+
*
|
|
173
|
+
* On browsers that support `display: grid-lanes` natively, the
|
|
174
|
+
* component emits the spec's CSS and lets the engine handle layout.
|
|
175
|
+
* Otherwise, `useLanePlacement` measures item heights and assigns
|
|
176
|
+
* explicit `grid-column-start` / `grid-row-start` values that
|
|
177
|
+
* approximate the same result inside CSS Grid.
|
|
178
|
+
*
|
|
179
|
+
* Each child's `key` must match an entry in the `layout` array;
|
|
180
|
+
* children without a match render at the end of the surface without
|
|
181
|
+
* explicit placement and fall through the lanes auto-flow.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```jsx
|
|
185
|
+
* <DashboardLanes
|
|
186
|
+
* layout={ [
|
|
187
|
+
* { key: 'a' },
|
|
188
|
+
* { key: 'b', width: 2 },
|
|
189
|
+
* { key: 'c' },
|
|
190
|
+
* ] }
|
|
191
|
+
* columns={ 3 }
|
|
192
|
+
* editMode
|
|
193
|
+
* onChangeLayout={ setLayout }
|
|
194
|
+
* >
|
|
195
|
+
* <Tile key="a">A</Tile>
|
|
196
|
+
* <Tile key="b">B</Tile>
|
|
197
|
+
* <Tile key="c">C</Tile>
|
|
198
|
+
* </DashboardLanes>
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @param props Component props.
|
|
202
|
+
* @param ref Forwarded to the surface's root `<div>`.
|
|
203
|
+
*/
|
|
204
|
+
const DashboardLanes = (0, _wordpress_element.forwardRef)(function UnforwardedDashboardLanes(props, ref) {
|
|
205
|
+
const { layout, columns, children, className, style, flowTolerance = 16, rowUnit = 4, minColumnWidth, itemLimits, editMode = false, onChangeLayout, onPreviewLayout, renderResizeHandle, renderDragPreview, renderGridOverlay, ...divProps } = props;
|
|
206
|
+
const [temporaryLayout, setTemporaryLayout] = (0, _wordpress_element.useState)();
|
|
207
|
+
const [activeId, setActiveId] = (0, _wordpress_element.useState)(null);
|
|
208
|
+
const [isResizing, setIsResizing] = (0, _wordpress_element.useState)(false);
|
|
209
|
+
const [resizeSnapPreview, setResizeSnapPreview] = (0, _wordpress_element.useState)(null);
|
|
210
|
+
const latestLayoutRef = (0, _wordpress_element.useRef)(void 0);
|
|
211
|
+
const lastReorderCursorRef = (0, _wordpress_element.useRef)(null);
|
|
212
|
+
const resizeBaselineRef = (0, _wordpress_element.useRef)(null);
|
|
213
|
+
const captureLayoutSnapshotRef = (0, _wordpress_element.useRef)(() => {});
|
|
214
|
+
const childrenCacheRef = (0, _wordpress_element.useRef)(/* @__PURE__ */ new Map());
|
|
215
|
+
const activeLayout = temporaryLayout ?? layout;
|
|
216
|
+
const [container, setContainer] = (0, _wordpress_element.useState)(null);
|
|
217
|
+
const [containerWidth, setContainerWidth] = (0, _wordpress_element.useState)(0);
|
|
218
|
+
const [gapPx, setGapPx] = (0, _wordpress_element.useState)(FALLBACK_GAP_PX);
|
|
219
|
+
const resizeObserverRef = (0, _wordpress_compose.useResizeObserver)(([{ contentRect }]) => {
|
|
220
|
+
setContainerWidth(contentRect.width);
|
|
221
|
+
});
|
|
222
|
+
const mergedRootRef = (0, _wordpress_compose.useMergeRefs)([
|
|
223
|
+
setContainer,
|
|
224
|
+
resizeObserverRef,
|
|
225
|
+
ref
|
|
226
|
+
]);
|
|
227
|
+
(0, _wordpress_element.useLayoutEffect)(() => {
|
|
228
|
+
if (!container) return;
|
|
229
|
+
const { width } = container.getBoundingClientRect();
|
|
230
|
+
if (width > 0) setContainerWidth(width);
|
|
231
|
+
const parsed = Number.parseFloat(window.getComputedStyle(container).columnGap);
|
|
232
|
+
if (Number.isFinite(parsed) && parsed > 0) setGapPx(parsed);
|
|
233
|
+
}, [container]);
|
|
234
|
+
const effectiveColumns = (0, _wordpress_element.useMemo)(() => (0, ___shared_column_policy_ts.resolveColumnCount)({
|
|
235
|
+
columns,
|
|
236
|
+
minColumnWidth
|
|
237
|
+
}, containerWidth, gapPx, DEFAULT_COLUMNS), [
|
|
238
|
+
minColumnWidth,
|
|
239
|
+
gapPx,
|
|
240
|
+
containerWidth,
|
|
241
|
+
columns
|
|
242
|
+
]);
|
|
243
|
+
const columnWidth = (containerWidth - (effectiveColumns - 1) * gapPx) / effectiveColumns;
|
|
244
|
+
const minResizeWidthPx = (0, ___shared_resize_snap_ts.gridSpanToPixelSize)(1, 1, columnWidth, gapPx, null).widthPx;
|
|
245
|
+
const widthBoundsByKey = (0, ___shared_use_span_bounds_ts.useSpanBounds)(itemLimits, columnWidth, gapPx, null, effectiveColumns);
|
|
246
|
+
const resizeLimitsByKey = (0, ___shared_use_span_bounds_ts.useResizePixelLimits)(widthBoundsByKey, columnWidth, gapPx, null);
|
|
247
|
+
const layoutMap = (0, _wordpress_element.useMemo)(() => {
|
|
248
|
+
const map = /* @__PURE__ */ new Map();
|
|
249
|
+
activeLayout.forEach((item) => map.set(item.key, item));
|
|
250
|
+
return map;
|
|
251
|
+
}, [activeLayout]);
|
|
252
|
+
const layoutKeys = (0, _wordpress_element.useMemo)(() => new Set(layout.map((item) => item.key)), [layout]);
|
|
253
|
+
const items = (0, _wordpress_element.useMemo)(() => activeLayout.map((item, index) => ({
|
|
254
|
+
item,
|
|
255
|
+
index
|
|
256
|
+
})).sort((a, b) => (a.item.order ?? a.index) - (b.item.order ?? b.index)).map(({ item }) => item.key), [activeLayout]);
|
|
257
|
+
const renderedSpanByKey = (0, _wordpress_element.useMemo)(() => {
|
|
258
|
+
const map = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const [key, item] of layoutMap) {
|
|
260
|
+
const span = typeof item.width === "number" ? Math.max(1, Math.min(item.width, effectiveColumns)) : 1;
|
|
261
|
+
const bounds = widthBoundsByKey.get(key);
|
|
262
|
+
map.set(key, bounds ? (0, ___shared_resize_snap_ts.clampSpan)(span, bounds.minWidth, bounds.maxWidth) : span);
|
|
263
|
+
}
|
|
264
|
+
return map;
|
|
265
|
+
}, [
|
|
266
|
+
layoutMap,
|
|
267
|
+
effectiveColumns,
|
|
268
|
+
widthBoundsByKey
|
|
269
|
+
]);
|
|
270
|
+
const placementItems = (0, _wordpress_element.useMemo)(() => {
|
|
271
|
+
return items.map((key) => ({
|
|
272
|
+
key,
|
|
273
|
+
span: renderedSpanByKey.get(key) ?? 1,
|
|
274
|
+
lane: layoutMap.get(key)?.lane
|
|
275
|
+
}));
|
|
276
|
+
}, [
|
|
277
|
+
items,
|
|
278
|
+
layoutMap,
|
|
279
|
+
renderedSpanByKey
|
|
280
|
+
]);
|
|
281
|
+
const { itemStyles } = (0, __use_lane_placement_ts.useLanePlacement)(container, {
|
|
282
|
+
items: placementItems,
|
|
283
|
+
lanes: effectiveColumns,
|
|
284
|
+
gap: gapPx,
|
|
285
|
+
flowTolerance,
|
|
286
|
+
rowUnit
|
|
287
|
+
});
|
|
288
|
+
const [childrenMap, actionableAreaMap, remaining, renderedByKey] = (0, _wordpress_element.useMemo)(() => {
|
|
289
|
+
const childMap = /* @__PURE__ */ new Map();
|
|
290
|
+
const actionableMap = /* @__PURE__ */ new Map();
|
|
291
|
+
const rest = [];
|
|
292
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
293
|
+
_wordpress_element.Children.forEach(children, (child) => {
|
|
294
|
+
if (!(0, _wordpress_element.isValidElement)(child)) {
|
|
295
|
+
rest.push(child);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const key = child.key?.toString();
|
|
299
|
+
if (!key) {
|
|
300
|
+
rest.push(child);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const { actionableArea } = child.props;
|
|
304
|
+
const stripped = actionableArea !== void 0 ? (0, _wordpress_element.cloneElement)(child, { actionableArea: void 0 }) : child;
|
|
305
|
+
byKey.set(key, stripped);
|
|
306
|
+
if (layoutKeys.has(key)) {
|
|
307
|
+
if (actionableArea !== void 0) actionableMap.set(key, actionableArea);
|
|
308
|
+
childMap.set(key, stripped);
|
|
309
|
+
} else rest.push(child);
|
|
310
|
+
});
|
|
311
|
+
return [
|
|
312
|
+
childMap,
|
|
313
|
+
actionableMap,
|
|
314
|
+
rest,
|
|
315
|
+
byKey
|
|
316
|
+
];
|
|
317
|
+
}, [children, layoutKeys]);
|
|
318
|
+
(0, _wordpress_element.useLayoutEffect)(() => {
|
|
319
|
+
for (const [key, child] of renderedByKey) childrenCacheRef.current.set(key, child);
|
|
320
|
+
}, [renderedByKey]);
|
|
321
|
+
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 }));
|
|
322
|
+
const handleDragStart = (0, _wordpress_compose.useEvent)((event) => {
|
|
323
|
+
setActiveId(String(event.active.id));
|
|
324
|
+
lastReorderCursorRef.current = null;
|
|
325
|
+
});
|
|
326
|
+
const handleDragCancel = (0, _wordpress_compose.useEvent)(() => {
|
|
327
|
+
setActiveId(null);
|
|
328
|
+
latestLayoutRef.current = void 0;
|
|
329
|
+
lastReorderCursorRef.current = null;
|
|
330
|
+
resizeBaselineRef.current = null;
|
|
331
|
+
setIsResizing(false);
|
|
332
|
+
setResizeSnapPreview(null);
|
|
333
|
+
setTemporaryLayout(void 0);
|
|
334
|
+
});
|
|
335
|
+
const handleDragMove = (0, _wordpress_compose.useEvent)((event) => {
|
|
336
|
+
const { active, over } = event;
|
|
337
|
+
if (!over || active.id === over.id) return;
|
|
338
|
+
const activeRect = active.rect.current.translated;
|
|
339
|
+
if (!activeRect) return;
|
|
340
|
+
const activeCenterX = activeRect.left + activeRect.width / 2;
|
|
341
|
+
const activeCenterY = activeRect.top + activeRect.height / 2;
|
|
342
|
+
const lastCursor = lastReorderCursorRef.current;
|
|
343
|
+
if (lastCursor) {
|
|
344
|
+
const dx = activeCenterX - lastCursor.x;
|
|
345
|
+
const dy = activeCenterY - lastCursor.y;
|
|
346
|
+
if (dx * dx + dy * dy < 100) return;
|
|
347
|
+
}
|
|
348
|
+
const insertAfter = activeCenterX > over.rect.left + over.rect.width / 2;
|
|
349
|
+
const currentIndex = items.indexOf(String(active.id));
|
|
350
|
+
const overIndex = items.indexOf(String(over.id));
|
|
351
|
+
let newIndex;
|
|
352
|
+
if (insertAfter) newIndex = currentIndex > overIndex ? overIndex + 1 : overIndex;
|
|
353
|
+
else newIndex = currentIndex > overIndex ? overIndex : overIndex - 1;
|
|
354
|
+
newIndex = Math.max(0, Math.min(newIndex, items.length - 1));
|
|
355
|
+
if (newIndex === currentIndex) return;
|
|
356
|
+
const updatedItems = (0, ___shared_array_move_with_pinned_ts.arrayMoveWithPinned)(items, currentIndex, newIndex, (key) => layoutMap.get(key)?.draggable === false);
|
|
357
|
+
if (updatedItems.every((key, index) => key === items[index])) return;
|
|
358
|
+
const orderByKey = /* @__PURE__ */ new Map();
|
|
359
|
+
updatedItems.forEach((key, index) => {
|
|
360
|
+
orderByKey.set(key, index);
|
|
361
|
+
});
|
|
362
|
+
const updatedLayout = activeLayout.map((item) => ({
|
|
363
|
+
...item,
|
|
364
|
+
order: orderByKey.get(item.key) ?? 0
|
|
365
|
+
}));
|
|
366
|
+
lastReorderCursorRef.current = {
|
|
367
|
+
x: activeCenterX,
|
|
368
|
+
y: activeCenterY
|
|
369
|
+
};
|
|
370
|
+
latestLayoutRef.current = updatedLayout;
|
|
371
|
+
captureLayoutSnapshotRef.current();
|
|
372
|
+
setTemporaryLayout(updatedLayout);
|
|
373
|
+
onPreviewLayout?.(updatedLayout);
|
|
374
|
+
});
|
|
375
|
+
const persistTemporaryLayout = (0, _wordpress_compose.useEvent)(() => {
|
|
376
|
+
const latest = latestLayoutRef.current;
|
|
377
|
+
latestLayoutRef.current = void 0;
|
|
378
|
+
resizeBaselineRef.current = null;
|
|
379
|
+
setIsResizing(false);
|
|
380
|
+
setResizeSnapPreview(null);
|
|
381
|
+
if (!onChangeLayout || !latest) {
|
|
382
|
+
setTemporaryLayout(void 0);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
onChangeLayout(latest);
|
|
386
|
+
setTemporaryLayout(void 0);
|
|
387
|
+
});
|
|
388
|
+
const handleResize = (0, _wordpress_compose.useEvent)((id, delta) => {
|
|
389
|
+
if (!editMode) return;
|
|
390
|
+
if (!isResizing) setIsResizing(true);
|
|
391
|
+
const relativeDelta = Math.round(delta.width / (columnWidth + gapPx));
|
|
392
|
+
if (resizeBaselineRef.current === null) resizeBaselineRef.current = renderedSpanByKey.get(id) ?? 1;
|
|
393
|
+
const baseline = resizeBaselineRef.current;
|
|
394
|
+
const bounds = widthBoundsByKey.get(id);
|
|
395
|
+
const newWidth = (0, ___shared_resize_snap_ts.clampSpan)(baseline + relativeDelta, bounds?.minWidth ?? 1, bounds?.maxWidth ?? effectiveColumns);
|
|
396
|
+
setResizeSnapPreview({
|
|
397
|
+
id,
|
|
398
|
+
snap: (0, ___shared_resize_snap_ts.gridSpanToPixelSize)(newWidth, 1, columnWidth, gapPx, null)
|
|
399
|
+
});
|
|
400
|
+
if (((latestLayoutRef.current?.find((item) => item.key === id))?.width ?? renderedSpanByKey.get(id)) === newWidth) return;
|
|
401
|
+
const updatedLayout = activeLayout.map((item) => item.key === id ? {
|
|
402
|
+
...item,
|
|
403
|
+
width: newWidth
|
|
404
|
+
} : item);
|
|
405
|
+
latestLayoutRef.current = updatedLayout;
|
|
406
|
+
captureLayoutSnapshotRef.current();
|
|
407
|
+
setTemporaryLayout(updatedLayout);
|
|
408
|
+
onPreviewLayout?.(updatedLayout);
|
|
409
|
+
});
|
|
410
|
+
const interacting = activeId !== null || isResizing;
|
|
411
|
+
const activeClone = activeId ? childrenMap.get(activeId) : null;
|
|
412
|
+
const DragPreview = renderDragPreview;
|
|
413
|
+
const dragOverlayContent = activeId && activeClone ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
414
|
+
className: lanes_module_default["drag-preview-frame"],
|
|
415
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
416
|
+
className: lanes_module_default["drag-preview-frame__lift"],
|
|
417
|
+
children: DragPreview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DragPreview, {
|
|
418
|
+
itemId: activeId,
|
|
419
|
+
children: activeClone
|
|
420
|
+
}) : activeClone
|
|
421
|
+
})
|
|
422
|
+
}) : null;
|
|
423
|
+
const Overlay = renderGridOverlay ?? ___shared_grid_overlay_tsx.GridOverlay;
|
|
424
|
+
const gridOverlay = (0, _wordpress_element.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Overlay, {
|
|
425
|
+
columns: effectiveColumns,
|
|
426
|
+
isActive: editMode
|
|
427
|
+
}), [
|
|
428
|
+
Overlay,
|
|
429
|
+
editMode,
|
|
430
|
+
effectiveColumns
|
|
431
|
+
]);
|
|
432
|
+
const layoutFingerprint = (0, _wordpress_element.useMemo)(() => {
|
|
433
|
+
return `${(0, ___shared_use_layout_shift_animation_ts.getLayoutFingerprint)(activeLayout)}\0${(0, ___shared_use_layout_shift_animation_ts.getPlacementFingerprint)(itemStyles)}`;
|
|
434
|
+
}, [activeLayout, itemStyles]);
|
|
435
|
+
const excludeLayoutAnimationKey = activeId ?? (isResizing ? resizeSnapPreview?.id : null);
|
|
436
|
+
const { captureLayoutSnapshot, getPositionsBeforeLastChange } = (0, ___shared_use_layout_shift_animation_ts.useLayoutShiftAnimation)({
|
|
437
|
+
container,
|
|
438
|
+
enabled: editMode,
|
|
439
|
+
layoutFingerprint,
|
|
440
|
+
excludeItemKey: excludeLayoutAnimationKey
|
|
441
|
+
});
|
|
442
|
+
const { exitingItems, clearExitingItem } = (0, ___shared_use_item_exit_animation_ts.useItemExitAnimation)({
|
|
443
|
+
container,
|
|
444
|
+
enabled: editMode,
|
|
445
|
+
layoutKeys,
|
|
446
|
+
getPositionsBeforeLastChange,
|
|
447
|
+
childrenCacheRef
|
|
448
|
+
});
|
|
449
|
+
const layoutAnimating = editMode;
|
|
450
|
+
(0, _wordpress_element.useLayoutEffect)(() => {
|
|
451
|
+
captureLayoutSnapshotRef.current = captureLayoutSnapshot;
|
|
452
|
+
}, [captureLayoutSnapshot]);
|
|
453
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_dnd_kit_core.DndContext, {
|
|
454
|
+
sensors,
|
|
455
|
+
onDragStart: handleDragStart,
|
|
456
|
+
onDragCancel: handleDragCancel,
|
|
457
|
+
onDragMove: handleDragMove,
|
|
458
|
+
onDragEnd: () => {
|
|
459
|
+
persistTemporaryLayout();
|
|
460
|
+
lastReorderCursorRef.current = null;
|
|
461
|
+
setActiveId(null);
|
|
462
|
+
},
|
|
463
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_dnd_kit_sortable.SortableContext, {
|
|
464
|
+
items,
|
|
465
|
+
strategy: NO_SORT_STRATEGY,
|
|
466
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
467
|
+
...divProps,
|
|
468
|
+
ref: mergedRootRef,
|
|
469
|
+
className: (0, clsx.default)(lanes_module_default.lanes, layoutAnimating && layout_shift_animation_module_default["layout-animating"], className),
|
|
470
|
+
"data-wp-grid-dragging": activeId || void 0,
|
|
471
|
+
"data-wp-grid-resizing": isResizing || void 0,
|
|
472
|
+
style: {
|
|
473
|
+
...style,
|
|
474
|
+
gridTemplateColumns: `repeat(${effectiveColumns}, minmax(0, 1fr))`,
|
|
475
|
+
"--wp-grid-lane-row-unit": `${Math.max(1, rowUnit)}px`
|
|
476
|
+
},
|
|
477
|
+
children: [
|
|
478
|
+
gridOverlay,
|
|
479
|
+
items.map((id) => {
|
|
480
|
+
const child = childrenMap.get(id);
|
|
481
|
+
if (!child) return null;
|
|
482
|
+
const limitsPx = resizeLimitsByKey.get(id);
|
|
483
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__lanes_item_tsx.LanesItem, {
|
|
484
|
+
itemKey: id,
|
|
485
|
+
placementStyle: itemStyles.get(id) ?? {},
|
|
486
|
+
disabled: !editMode,
|
|
487
|
+
draggable: layoutMap.get(id)?.draggable !== false,
|
|
488
|
+
resizable: layoutMap.get(id)?.resizable !== false,
|
|
489
|
+
interacting,
|
|
490
|
+
dragging: activeId !== null,
|
|
491
|
+
onResize: handleResize,
|
|
492
|
+
onResizeEnd: persistTemporaryLayout,
|
|
493
|
+
resizeSnapPreview: resizeSnapPreview?.id === id ? resizeSnapPreview.snap : null,
|
|
494
|
+
minResizeWidthPx: limitsPx?.minWidthPx ?? minResizeWidthPx,
|
|
495
|
+
maxResizeWidthPx: limitsPx?.maxWidthPx,
|
|
496
|
+
actionableArea: actionableAreaMap.get(id),
|
|
497
|
+
renderResizeHandle,
|
|
498
|
+
children: child
|
|
499
|
+
}, id);
|
|
500
|
+
}),
|
|
501
|
+
remaining,
|
|
502
|
+
exitingItems.map(({ key, rect, child }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___shared_item_exit_overlay_tsx.ItemExitOverlay, {
|
|
503
|
+
itemKey: key,
|
|
504
|
+
rect,
|
|
505
|
+
onAnimationEnd: () => clearExitingItem(key),
|
|
506
|
+
children: child
|
|
507
|
+
}, `exiting-${key}`))
|
|
508
|
+
]
|
|
509
|
+
})
|
|
510
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_dnd_kit_core.DragOverlay, {
|
|
511
|
+
dropAnimation: dashboardDragDropAnimation,
|
|
512
|
+
children: dragOverlayContent
|
|
513
|
+
})]
|
|
514
|
+
});
|
|
599
515
|
});
|
|
600
|
-
|
|
516
|
+
exports.DashboardLanes = DashboardLanes;
|
|
517
|
+
|
|
518
|
+
//# sourceMappingURL=index.cjs.map
|