@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,323 +1,260 @@
|
|
|
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
|
-
module.exports = __toCommonJS(grid_item_exports);
|
|
36
|
-
var import_sortable = require("@dnd-kit/sortable");
|
|
37
|
-
var import_clsx = __toESM(require("clsx"));
|
|
38
|
-
var import_element = require("@wordpress/element");
|
|
39
|
-
var import_compose = require("@wordpress/compose");
|
|
40
|
-
var import_react_inert_value = require("@wordpress/react-inert-value");
|
|
41
|
-
|
|
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_sortable = require("@dnd-kit/sortable");
|
|
28
|
+
let clsx = require("clsx");
|
|
29
|
+
clsx = __toESM(clsx);
|
|
30
|
+
let _wordpress_element = require("@wordpress/element");
|
|
31
|
+
let _wordpress_compose = require("@wordpress/compose");
|
|
32
|
+
let _wordpress_react_inert_value = require("@wordpress/react-inert-value");
|
|
33
|
+
let ___shared_grid_item_key_ts = require("../shared/grid-item-key.cjs");
|
|
34
|
+
let ___shared_resize_handle_tsx = require("../shared/resize-handle.cjs");
|
|
35
|
+
___shared_resize_handle_tsx = __toESM(___shared_resize_handle_tsx);
|
|
36
|
+
let ___shared_resize_snap_ts = require("../shared/resize-snap.cjs");
|
|
37
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
42
38
|
// packages/style-runtime/src/index.ts
|
|
43
|
-
|
|
39
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
40
|
+
/**
|
|
41
|
+
* Returns the shared style runtime registry.
|
|
42
|
+
*
|
|
43
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
44
|
+
* package can coordinate through the same document and style maps.
|
|
45
|
+
*
|
|
46
|
+
* @return The shared runtime registry.
|
|
47
|
+
*/
|
|
44
48
|
function getRuntime() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (typeof document !== "undefined") {
|
|
55
|
-
registerDocument(document);
|
|
56
|
-
}
|
|
57
|
-
return globalScope.__wpStyleRuntime;
|
|
49
|
+
const globalScope = globalThis;
|
|
50
|
+
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
51
|
+
globalScope.__wpStyleRuntime = {
|
|
52
|
+
documents: /* @__PURE__ */ new Map(),
|
|
53
|
+
styles: /* @__PURE__ */ new Map(),
|
|
54
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
55
|
+
};
|
|
56
|
+
if (typeof document !== "undefined") registerDocument(document);
|
|
57
|
+
return globalScope.__wpStyleRuntime;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
61
|
+
*
|
|
62
|
+
* @param targetDocument Document to inspect.
|
|
63
|
+
* @param hash Stable hash for the transformed CSS.
|
|
64
|
+
*
|
|
65
|
+
* @return Whether the style hash already exists in the document.
|
|
66
|
+
*/
|
|
59
67
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
64
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
65
|
-
)) {
|
|
66
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
68
|
+
if (!targetDocument.head) return false;
|
|
69
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
70
|
+
return false;
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Injects a registered style into a document, unless that document already
|
|
74
|
+
* contains a style tag for the same hash.
|
|
75
|
+
*
|
|
76
|
+
* @param targetDocument Document to inject the style into.
|
|
77
|
+
* @param hash Stable hash for the transformed CSS.
|
|
78
|
+
* @param css CSS text to inject.
|
|
79
|
+
*/
|
|
72
80
|
function injectStyle(targetDocument, hash, css) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
91
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
92
|
-
targetDocument.head.appendChild(style);
|
|
93
|
-
injectedStyles.add(hash);
|
|
81
|
+
if (!targetDocument.head) return;
|
|
82
|
+
const runtime = getRuntime();
|
|
83
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
84
|
+
if (!injectedStyles) {
|
|
85
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
86
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
87
|
+
}
|
|
88
|
+
if (injectedStyles.has(hash)) return;
|
|
89
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
90
|
+
injectedStyles.add(hash);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const style = targetDocument.createElement("style");
|
|
94
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
95
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
96
|
+
targetDocument.head.appendChild(style);
|
|
97
|
+
injectedStyles.add(hash);
|
|
94
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Registers a document as a style injection target.
|
|
101
|
+
*
|
|
102
|
+
* Existing registered styles are replayed into the document immediately.
|
|
103
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
104
|
+
* same document without one cleanup removing it while another registration is
|
|
105
|
+
* still active.
|
|
106
|
+
*
|
|
107
|
+
* @param targetDocument Document to receive registered styles.
|
|
108
|
+
* @return Cleanup function that unregisters this document registration.
|
|
109
|
+
*/
|
|
95
110
|
function registerDocument(targetDocument) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
if (count <= 1) {
|
|
110
|
-
runtime.documents.delete(targetDocument);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
114
|
-
};
|
|
111
|
+
const runtime = getRuntime();
|
|
112
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
113
|
+
for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
|
|
114
|
+
return () => {
|
|
115
|
+
const count = runtime.documents.get(targetDocument);
|
|
116
|
+
if (count === void 0) return;
|
|
117
|
+
if (count <= 1) {
|
|
118
|
+
runtime.documents.delete(targetDocument);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
122
|
+
};
|
|
115
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Registers a style and injects it into all registered documents.
|
|
126
|
+
*
|
|
127
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
128
|
+
* the same hash will not add duplicate style tags to a document.
|
|
129
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
130
|
+
* replayed into documents that are registered later.
|
|
131
|
+
*
|
|
132
|
+
* @param hash Stable hash for the transformed CSS.
|
|
133
|
+
* @param css CSS text to inject.
|
|
134
|
+
*/
|
|
116
135
|
function registerStyle(hash, css) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
injectStyle(targetDocument, hash, css);
|
|
121
|
-
}
|
|
136
|
+
const runtime = getRuntime();
|
|
137
|
+
runtime.styles.set(hash, css);
|
|
138
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
122
139
|
}
|
|
123
|
-
|
|
124
140
|
// packages/grid/src/shared/actionable-area-slot.module.css
|
|
125
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
var actionable_area_slot_default = { "actionable-area-slot": "_1c54fe8165d3023e__actionable-area-slot" };
|
|
129
|
-
|
|
130
|
-
// packages/grid/src/dashboard-grid/grid-item.tsx
|
|
131
|
-
var import_grid_item_key = require("../shared/grid-item-key.cjs");
|
|
132
|
-
var import_resize_handle = __toESM(require("../shared/resize-handle.cjs"));
|
|
133
|
-
var import_resize_snap = require("../shared/resize-snap.cjs");
|
|
134
|
-
|
|
141
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("36a7a084ce", "._0a2b470abcf47e5b__actionable-area-slot{opacity:1}@media (prefers-reduced-motion:no-preference){._0a2b470abcf47e5b__actionable-area-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-resizing] ._0a2b470abcf47e5b__actionable-area-slot{opacity:0;pointer-events:none}");
|
|
142
|
+
var actionable_area_slot_module_default = { "actionable-area-slot": "_0a2b470abcf47e5b__actionable-area-slot" };
|
|
135
143
|
// packages/grid/src/dashboard-grid/grid-item.module.css
|
|
136
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("33e05f5e81", ".d8e79c99afd8bca5__item{position:relative}._88155a7e5db75630__item-content{height:100%;position:relative}._09df60d54139626b__is-resizing{overflow:visible;z-index:1}._09df60d54139626b__is-resizing ._88155a7e5db75630__item-content{overflow:visible;position:relative;z-index:2}._5e7dab4e781593a1__is-dragging{pointer-events:none}[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{border-radius:var(--wp-grid-placeholder-radius,0)}@media not (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{animation:_41089f4f79a6ecfb__wp-grid-item-placeholder-in 0ms linear var(--wpds-motion-duration-sm,.1s) forwards;opacity:1;outline-color:transparent;outline-style:var(--wp-grid-placeholder-outline-style,dashed);outline-width:0}@keyframes _41089f4f79a6ecfb__wp-grid-item-placeholder-in{to{opacity:var(--wp-grid-placeholder-opacity,.4);outline-color:var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));outline-width:var(--wpds-border-width-sm,2px)}}}@media (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{opacity:var(--wp-grid-placeholder-opacity,.4);outline:var(--wpds-border-width-sm,2px) var(--wp-grid-placeholder-outline-style,dashed) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)))}}@media (forced-colors:active){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{--wp-grid-placeholder-outline-color:Highlight}}.c99f267fd053e634__preview-overlay{background:transparent;border:var(--wpds-border-width-sm,2px) var(--wp-grid-resize-preview-outline-style,solid) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));border-radius:var(--wp-grid-placeholder-radius,0);box-sizing:border-box;inset-inline-start:0;pointer-events:none;position:absolute;top:0;z-index:0}@media (forced-colors:active){.c99f267fd053e634__preview-overlay{border-color:Highlight}}");
|
|
145
|
+
var grid_item_module_default = {
|
|
146
|
+
"item": "d8e79c99afd8bca5__item",
|
|
147
|
+
"item-content": "_88155a7e5db75630__item-content",
|
|
148
|
+
"is-resizing": "_09df60d54139626b__is-resizing",
|
|
149
|
+
"is-dragging": "_5e7dab4e781593a1__is-dragging",
|
|
150
|
+
"wp-grid-item-placeholder-in": "_41089f4f79a6ecfb__wp-grid-item-placeholder-in",
|
|
151
|
+
"preview-overlay": "c99f267fd053e634__preview-overlay"
|
|
152
|
+
};
|
|
141
153
|
// packages/grid/src/dashboard-grid/grid-item.tsx
|
|
142
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
143
154
|
function getItemCursor(disabled, interacting) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (interacting) {
|
|
148
|
-
return void 0;
|
|
149
|
-
}
|
|
150
|
-
return "grab";
|
|
155
|
+
if (disabled) return "default";
|
|
156
|
+
if (interacting) return;
|
|
157
|
+
return "grab";
|
|
151
158
|
}
|
|
152
|
-
function GridItem({
|
|
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
|
-
height: verticalResizable ? initialContentSize.height + resizeDelta.height : void 0
|
|
242
|
-
} : void 0;
|
|
243
|
-
const previewOverlay = resizeSnapPreview ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SnapPreviewOverlay, { snap: resizeSnapPreview }) : null;
|
|
244
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
245
|
-
"div",
|
|
246
|
-
{
|
|
247
|
-
ref: mergedRef,
|
|
248
|
-
className: itemClassName,
|
|
249
|
-
style,
|
|
250
|
-
...{ [import_grid_item_key.GRID_ITEM_DATA_KEY]: item.key },
|
|
251
|
-
"data-wp-grid-item-resizing": isResizing || void 0,
|
|
252
|
-
children: [
|
|
253
|
-
actionableArea ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
254
|
-
"div",
|
|
255
|
-
{
|
|
256
|
-
className: actionable_area_slot_default["actionable-area-slot"],
|
|
257
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
258
|
-
"div",
|
|
259
|
-
{
|
|
260
|
-
style: { display: "contents" },
|
|
261
|
-
inert: (0, import_react_inert_value.inertValue)(dragging),
|
|
262
|
-
children: actionableArea
|
|
263
|
-
}
|
|
264
|
-
)
|
|
265
|
-
}
|
|
266
|
-
) : null,
|
|
267
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
268
|
-
"div",
|
|
269
|
-
{
|
|
270
|
-
ref: setActivatorNodeRef,
|
|
271
|
-
...attributes,
|
|
272
|
-
...listeners,
|
|
273
|
-
style: {
|
|
274
|
-
height: "100%",
|
|
275
|
-
cursor: getItemCursor(dragDisabled, interacting)
|
|
276
|
-
},
|
|
277
|
-
children: [
|
|
278
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
279
|
-
"div",
|
|
280
|
-
{
|
|
281
|
-
ref: contentMergedRef,
|
|
282
|
-
className: grid_item_default["item-content"],
|
|
283
|
-
style: continuousContentStyle,
|
|
284
|
-
children: [
|
|
285
|
-
children,
|
|
286
|
-
!resizeDisabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
287
|
-
import_resize_handle.default,
|
|
288
|
-
{
|
|
289
|
-
itemId: item.key,
|
|
290
|
-
verticalResizable,
|
|
291
|
-
onResize: handleResize,
|
|
292
|
-
onResizeEnd: handleResizeEnd,
|
|
293
|
-
renderResizeHandle
|
|
294
|
-
}
|
|
295
|
-
)
|
|
296
|
-
]
|
|
297
|
-
}
|
|
298
|
-
),
|
|
299
|
-
previewOverlay
|
|
300
|
-
]
|
|
301
|
-
}
|
|
302
|
-
)
|
|
303
|
-
]
|
|
304
|
-
}
|
|
305
|
-
);
|
|
159
|
+
function GridItem({ item, maxColumns, disabled = false, draggable = true, resizable = true, verticalResizable = true, interacting = false, dragging = false, children, actionableArea = null, onResize, onResizeEnd, resizeSnapPreview = null, minResizeWidthPx, minResizeHeightPx, maxResizeWidthPx, maxResizeHeightPx, renderResizeHandle }) {
|
|
160
|
+
const [resizeDelta, setResizeDelta] = (0, _wordpress_element.useState)(null);
|
|
161
|
+
const [initialContentSize, setInitialContentSize] = (0, _wordpress_element.useState)(null);
|
|
162
|
+
const itemRef = (0, _wordpress_element.useRef)(null);
|
|
163
|
+
const contentRef = (0, _wordpress_element.useRef)(null);
|
|
164
|
+
const dragDisabled = disabled || !draggable;
|
|
165
|
+
const resizeDisabled = disabled || !resizable;
|
|
166
|
+
const { attributes, listeners, setNodeRef, setActivatorNodeRef, isDragging } = (0, _dnd_kit_sortable.useSortable)({
|
|
167
|
+
id: item.key,
|
|
168
|
+
disabled: dragDisabled
|
|
169
|
+
});
|
|
170
|
+
const mergedRef = (0, _wordpress_compose.useMergeRefs)([itemRef, setNodeRef]);
|
|
171
|
+
const contentMergedRef = (0, _wordpress_compose.useMergeRefs)([contentRef]);
|
|
172
|
+
const style = {
|
|
173
|
+
gridColumnEnd: `span ${item.width === "full" ? maxColumns : Math.min(typeof item.width === "number" ? item.width : 1, maxColumns)}`,
|
|
174
|
+
gridRowEnd: `span ${item.height || 1}`
|
|
175
|
+
};
|
|
176
|
+
const isResizing = resizeDelta !== null;
|
|
177
|
+
const itemClassName = (0, clsx.default)(grid_item_module_default.item, isDragging && grid_item_module_default["is-dragging"], isResizing && grid_item_module_default["is-resizing"]);
|
|
178
|
+
const handleResize = (delta) => {
|
|
179
|
+
const contentNode = contentRef.current;
|
|
180
|
+
let baselineSize = initialContentSize;
|
|
181
|
+
if (contentNode && !baselineSize) {
|
|
182
|
+
const { width, height } = contentNode.getBoundingClientRect();
|
|
183
|
+
baselineSize = {
|
|
184
|
+
width,
|
|
185
|
+
height
|
|
186
|
+
};
|
|
187
|
+
setInitialContentSize(baselineSize);
|
|
188
|
+
}
|
|
189
|
+
let clamped = {
|
|
190
|
+
width: delta.width,
|
|
191
|
+
height: verticalResizable ? delta.height : 0
|
|
192
|
+
};
|
|
193
|
+
if (baselineSize) clamped = (0, ___shared_resize_snap_ts.clampResizeDelta)(clamped, baselineSize, {
|
|
194
|
+
width: minResizeWidthPx,
|
|
195
|
+
height: verticalResizable ? minResizeHeightPx : void 0
|
|
196
|
+
}, {
|
|
197
|
+
width: maxResizeWidthPx,
|
|
198
|
+
height: verticalResizable ? maxResizeHeightPx : void 0
|
|
199
|
+
});
|
|
200
|
+
setResizeDelta(clamped);
|
|
201
|
+
onResize(item.key, clamped);
|
|
202
|
+
};
|
|
203
|
+
const handleResizeEnd = () => {
|
|
204
|
+
setResizeDelta(null);
|
|
205
|
+
setInitialContentSize(null);
|
|
206
|
+
onResizeEnd();
|
|
207
|
+
};
|
|
208
|
+
const continuousContentStyle = resizeDelta && initialContentSize ? {
|
|
209
|
+
width: initialContentSize.width + resizeDelta.width,
|
|
210
|
+
height: verticalResizable ? initialContentSize.height + resizeDelta.height : void 0
|
|
211
|
+
} : void 0;
|
|
212
|
+
const previewOverlay = resizeSnapPreview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SnapPreviewOverlay, { snap: resizeSnapPreview }) : null;
|
|
213
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
214
|
+
ref: mergedRef,
|
|
215
|
+
className: itemClassName,
|
|
216
|
+
style,
|
|
217
|
+
[___shared_grid_item_key_ts.GRID_ITEM_DATA_KEY]: item.key,
|
|
218
|
+
"data-wp-grid-item-resizing": isResizing || void 0,
|
|
219
|
+
children: [actionableArea ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
220
|
+
className: actionable_area_slot_module_default["actionable-area-slot"],
|
|
221
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
222
|
+
style: { display: "contents" },
|
|
223
|
+
inert: (0, _wordpress_react_inert_value.inertValue)(dragging),
|
|
224
|
+
children: actionableArea
|
|
225
|
+
})
|
|
226
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
227
|
+
ref: setActivatorNodeRef,
|
|
228
|
+
...dragDisabled ? {} : attributes,
|
|
229
|
+
...listeners,
|
|
230
|
+
style: {
|
|
231
|
+
height: "100%",
|
|
232
|
+
cursor: getItemCursor(dragDisabled, interacting)
|
|
233
|
+
},
|
|
234
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
235
|
+
ref: contentMergedRef,
|
|
236
|
+
className: grid_item_module_default["item-content"],
|
|
237
|
+
style: continuousContentStyle,
|
|
238
|
+
children: [children, !resizeDisabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___shared_resize_handle_tsx.default, {
|
|
239
|
+
itemId: item.key,
|
|
240
|
+
verticalResizable,
|
|
241
|
+
onResize: handleResize,
|
|
242
|
+
onResizeEnd: handleResizeEnd,
|
|
243
|
+
renderResizeHandle
|
|
244
|
+
})]
|
|
245
|
+
}), previewOverlay]
|
|
246
|
+
})]
|
|
247
|
+
});
|
|
306
248
|
}
|
|
307
249
|
function SnapPreviewOverlay({ snap }) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
);
|
|
250
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
251
|
+
className: grid_item_module_default["preview-overlay"],
|
|
252
|
+
style: {
|
|
253
|
+
width: snap.widthPx,
|
|
254
|
+
height: snap.heightPx ?? "100%"
|
|
255
|
+
}
|
|
256
|
+
});
|
|
318
257
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
});
|
|
323
|
-
//# sourceMappingURL=grid-item.cjs.map
|
|
258
|
+
exports.GridItem = GridItem;
|
|
259
|
+
|
|
260
|
+
//# sourceMappingURL=grid-item.cjs.map
|