@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,125 +1,143 @@
|
|
|
1
|
-
// packages/grid/src/shared/item-exit-overlay.tsx
|
|
2
1
|
import { GRID_ITEM_DATA_KEY } from "./grid-item-key.mjs";
|
|
3
|
-
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
// packages/style-runtime/src/index.ts
|
|
5
|
-
|
|
4
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the shared style runtime registry.
|
|
7
|
+
*
|
|
8
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
9
|
+
* package can coordinate through the same document and style maps.
|
|
10
|
+
*
|
|
11
|
+
* @return The shared runtime registry.
|
|
12
|
+
*/
|
|
6
13
|
function getRuntime() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (typeof document !== "undefined") {
|
|
17
|
-
registerDocument(document);
|
|
18
|
-
}
|
|
19
|
-
return globalScope.__wpStyleRuntime;
|
|
14
|
+
const globalScope = globalThis;
|
|
15
|
+
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
16
|
+
globalScope.__wpStyleRuntime = {
|
|
17
|
+
documents: /* @__PURE__ */ new Map(),
|
|
18
|
+
styles: /* @__PURE__ */ new Map(),
|
|
19
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
20
|
+
};
|
|
21
|
+
if (typeof document !== "undefined") registerDocument(document);
|
|
22
|
+
return globalScope.__wpStyleRuntime;
|
|
20
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
26
|
+
*
|
|
27
|
+
* @param targetDocument Document to inspect.
|
|
28
|
+
* @param hash Stable hash for the transformed CSS.
|
|
29
|
+
*
|
|
30
|
+
* @return Whether the style hash already exists in the document.
|
|
31
|
+
*/
|
|
21
32
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
26
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
27
|
-
)) {
|
|
28
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
+
if (!targetDocument.head) return false;
|
|
34
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
35
|
+
return false;
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Injects a registered style into a document, unless that document already
|
|
39
|
+
* contains a style tag for the same hash.
|
|
40
|
+
*
|
|
41
|
+
* @param targetDocument Document to inject the style into.
|
|
42
|
+
* @param hash Stable hash for the transformed CSS.
|
|
43
|
+
* @param css CSS text to inject.
|
|
44
|
+
*/
|
|
34
45
|
function injectStyle(targetDocument, hash, css) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
53
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
54
|
-
targetDocument.head.appendChild(style);
|
|
55
|
-
injectedStyles.add(hash);
|
|
46
|
+
if (!targetDocument.head) return;
|
|
47
|
+
const runtime = getRuntime();
|
|
48
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
49
|
+
if (!injectedStyles) {
|
|
50
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
51
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
52
|
+
}
|
|
53
|
+
if (injectedStyles.has(hash)) return;
|
|
54
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
55
|
+
injectedStyles.add(hash);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const style = targetDocument.createElement("style");
|
|
59
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
60
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
61
|
+
targetDocument.head.appendChild(style);
|
|
62
|
+
injectedStyles.add(hash);
|
|
56
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers a document as a style injection target.
|
|
66
|
+
*
|
|
67
|
+
* Existing registered styles are replayed into the document immediately.
|
|
68
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
69
|
+
* same document without one cleanup removing it while another registration is
|
|
70
|
+
* still active.
|
|
71
|
+
*
|
|
72
|
+
* @param targetDocument Document to receive registered styles.
|
|
73
|
+
* @return Cleanup function that unregisters this document registration.
|
|
74
|
+
*/
|
|
57
75
|
function registerDocument(targetDocument) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (count <= 1) {
|
|
72
|
-
runtime.documents.delete(targetDocument);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
76
|
-
};
|
|
76
|
+
const runtime = getRuntime();
|
|
77
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
78
|
+
for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
|
|
79
|
+
return () => {
|
|
80
|
+
const count = runtime.documents.get(targetDocument);
|
|
81
|
+
if (count === void 0) return;
|
|
82
|
+
if (count <= 1) {
|
|
83
|
+
runtime.documents.delete(targetDocument);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
87
|
+
};
|
|
77
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Registers a style and injects it into all registered documents.
|
|
91
|
+
*
|
|
92
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
93
|
+
* the same hash will not add duplicate style tags to a document.
|
|
94
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
95
|
+
* replayed into documents that are registered later.
|
|
96
|
+
*
|
|
97
|
+
* @param hash Stable hash for the transformed CSS.
|
|
98
|
+
* @param css CSS text to inject.
|
|
99
|
+
*/
|
|
78
100
|
function registerStyle(hash, css) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
injectStyle(targetDocument, hash, css);
|
|
83
|
-
}
|
|
101
|
+
const runtime = getRuntime();
|
|
102
|
+
runtime.styles.set(hash, css);
|
|
103
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
84
104
|
}
|
|
85
|
-
|
|
86
105
|
// packages/grid/src/shared/item-exit-animation.module.css
|
|
87
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("485367d6fa", ".e7a043178c12eb10__exit-overlay{opacity:1;overflow:hidden;pointer-events:none;position:absolute;transform:scale(1);transform-origin:center center;z-index:2}@media not (prefers-reduced-motion:reduce){.e7a043178c12eb10__exit-overlay{animation:_60b4685f351fbbe2__wp-grid-item-exit-opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1)) forwards,_5c9d51cb3a3d655b__wp-grid-item-exit-scale var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}}@keyframes _60b4685f351fbbe2__wp-grid-item-exit-opacity{0%{opacity:1}to{opacity:0}}@keyframes _5c9d51cb3a3d655b__wp-grid-item-exit-scale{0%{transform:scale(1)}to{transform:scale(.88)}}@media (prefers-reduced-motion:reduce){.e7a043178c12eb10__exit-overlay{display:none}}");
|
|
107
|
+
var item_exit_animation_module_default = {
|
|
108
|
+
"exit-overlay": "e7a043178c12eb10__exit-overlay",
|
|
109
|
+
"wp-grid-item-exit-opacity": "_60b4685f351fbbe2__wp-grid-item-exit-opacity",
|
|
110
|
+
"wp-grid-item-exit-scale": "_5c9d51cb3a3d655b__wp-grid-item-exit-scale"
|
|
111
|
+
};
|
|
92
112
|
// packages/grid/src/shared/item-exit-overlay.tsx
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
);
|
|
113
|
+
/**
|
|
114
|
+
* Ghost tile shown at the removed item's last position while siblings
|
|
115
|
+
* reflow. Not a sortable grid cell — only visual exit feedback.
|
|
116
|
+
*
|
|
117
|
+
* @param root0 Component props.
|
|
118
|
+
* @param root0.itemKey Layout key of the removed tile.
|
|
119
|
+
* @param root0.rect Last bounds relative to the grid surface.
|
|
120
|
+
* @param root0.children Cached tile content to render in the ghost.
|
|
121
|
+
* @param root0.onAnimationEnd Called when the exit animation finishes.
|
|
122
|
+
*/
|
|
123
|
+
function ItemExitOverlay({ itemKey, rect, children, onAnimationEnd }) {
|
|
124
|
+
return /* @__PURE__ */ jsx("div", {
|
|
125
|
+
className: item_exit_animation_module_default["exit-overlay"],
|
|
126
|
+
style: {
|
|
127
|
+
left: rect.left,
|
|
128
|
+
top: rect.top,
|
|
129
|
+
width: rect.width,
|
|
130
|
+
height: rect.height
|
|
131
|
+
},
|
|
132
|
+
[GRID_ITEM_DATA_KEY]: itemKey,
|
|
133
|
+
"data-wp-grid-item-exiting": "",
|
|
134
|
+
onAnimationEnd: (event) => {
|
|
135
|
+
if (event.target !== event.currentTarget) return;
|
|
136
|
+
onAnimationEnd();
|
|
137
|
+
},
|
|
138
|
+
children
|
|
139
|
+
});
|
|
121
140
|
}
|
|
122
|
-
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
//# sourceMappingURL=item-exit-overlay.mjs.map
|
|
141
|
+
export { ItemExitOverlay };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=item-exit-overlay.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/shared/item-exit-overlay.tsx", "../../../style-runtime/src/index.ts", "../../src/shared/item-exit-animation.module.css"],
|
|
4
|
-
"sourcesContent": ["import { GRID_ITEM_DATA_KEY } from './grid-item-key';\nimport exitStyles from './item-exit-animation.module.css';\nimport type { RectSnapshot } from './use-layout-shift-animation';\n\nexport type ItemExitOverlayRect = Pick<\n\tRectSnapshot,\n\t'left' | 'top' | 'width' | 'height'\n>;\n\nexport type ItemExitOverlayProps = {\n\titemKey: string;\n\trect: ItemExitOverlayRect;\n\tchildren: React.ReactNode;\n\tonAnimationEnd: () => void;\n};\n\n/**\n * Ghost tile shown at the removed item's last position while siblings\n * reflow. Not a sortable grid cell — only visual exit feedback.\n *\n * @param root0 Component props.\n * @param root0.itemKey Layout key of the removed tile.\n * @param root0.rect Last bounds relative to the grid surface.\n * @param root0.children Cached tile content to render in the ghost.\n * @param root0.onAnimationEnd Called when the exit animation finishes.\n */\nexport function ItemExitOverlay( {\n\titemKey,\n\trect,\n\tchildren,\n\tonAnimationEnd,\n}: ItemExitOverlayProps ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ exitStyles[ 'exit-overlay' ] }\n\t\t\tstyle={ {\n\t\t\t\tleft: rect.left,\n\t\t\t\ttop: rect.top,\n\t\t\t\twidth: rect.width,\n\t\t\t\theight: rect.height,\n\t\t\t} }\n\t\t\t{ ...{ [ GRID_ITEM_DATA_KEY ]: itemKey } }\n\t\t\tdata-wp-grid-item-exiting=\"\"\n\t\t\tonAnimationEnd={ ( event ) => {\n\t\t\t\tif ( event.target !== event.currentTarget ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonAnimationEnd();\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"1e0c56b346\", \".f5f31b390af63a56__exit-overlay{opacity:1;overflow:hidden;pointer-events:none;position:absolute;transform:scale(1);transform-origin:center center;z-index:2}@media not (prefers-reduced-motion:reduce){.f5f31b390af63a56__exit-overlay{animation:_5e96d3d4062490e6__wp-grid-item-exit-opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1)) forwards,a74da0751a183719__wp-grid-item-exit-scale var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}}@keyframes _5e96d3d4062490e6__wp-grid-item-exit-opacity{0%{opacity:1}to{opacity:0}}@keyframes a74da0751a183719__wp-grid-item-exit-scale{0%{transform:scale(1)}to{transform:scale(.88)}}@media (prefers-reduced-motion:reduce){.f5f31b390af63a56__exit-overlay{display:none}}\");\n}\nexport default {\"exit-overlay\":\"f5f31b390af63a56__exit-overlay\",\"wp-grid-item-exit-opacity\":\"_5e96d3d4062490e6__wp-grid-item-exit-opacity\",\"wp-grid-item-exit-scale\":\"a74da0751a183719__wp-grid-item-exit-scale\"};\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,0BAA0B;;;ACUnC,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAUA,SAAS,0BACR,gBACA,MACU;AACV,MAAK,CAAE,eAAe,MAAO;AAC5B,WAAO;AAAA,EACR;AAEA,aAAY,SAAS,eAAe,KAAK;AAAA,IACxC,SAAU,oBAAqB;AAAA,EAChC,GAAI;AACH,QAAK,MAAM,aAAc,oBAAqB,MAAM,MAAO;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;AAC3E,MAAK,CAAE,eAAe,MAAO;AAC5B;AAAA,EACD;AAEA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;AAEhE,MAAK,CAAE,gBAAiB;AACvB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAK,gBAAgB,cAAe;AAAA,EAC5D;AAEA,MAAK,eAAe,IAAK,IAAK,GAAI;AACjC;AAAA,EACD;AAKA,MAAK,0BAA2B,gBAAgB,IAAK,GAAI;AACxD,mBAAe,IAAK,IAAK;AACzB;AAAA,EACD;AAEA,QAAM,QAAQ,eAAe,cAAe,OAAQ;AACpD,QAAM,aAAc,sBAAsB,IAAK;AAC/C,QAAM,YAAa,eAAe,eAAgB,GAAI,CAAE;AACxD,iBAAe,KAAK,YAAa,KAAM;AACvC,iBAAe,IAAK,IAAK;AAC1B;AAaO,SAAS,iBAAkB,gBAA2B;AAC5D,QAAM,UAAU,WAAW;AAE3B,UAAQ,UAAU;AAAA,IACjB;AAAA,KACE,QAAQ,UAAU,IAAK,cAAe,KAAK,KAAM;AAAA,EACpD;AAEA,aAAY,CAAE,MAAM,GAAI,KAAK,QAAQ,QAAS;AAC7C,gBAAa,gBAAgB,MAAM,GAAI;AAAA,EACxC;AAEA,SAAO,MAAM;AACZ,UAAM,QAAQ,QAAQ,UAAU,IAAK,cAAe;AAEpD,QAAK,UAAU,QAAY;AAC1B;AAAA,IACD;AAEA,QAAK,SAAS,GAAI;AACjB,cAAQ,UAAU,OAAQ,cAAe;AACzC;AAAA,IACD;AAEA,YAAQ,UAAU,IAAK,gBAAgB,QAAQ,CAAE;AAAA,EAClD;AACD;AAaO,SAAS,cAAe,MAAc,KAAc;AAC1D,QAAM,UAAU,WAAW;AAE3B,UAAQ,OAAO,IAAK,MAAM,GAAI;AAE9B,aAAY,kBAAkB,QAAQ,UAAU,KAAK,GAAI;AACxD,gBAAa,gBAAgB,MAAM,GAAI;AAAA,EACxC;AACD;;;ACpKA,IAAI,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa,QAAQ;AACtE,gBAAc,cAAc,qyBAAqyB;AACl0B;AACA,IAAO,8BAAQ,EAAC,gBAAe,kCAAiC,6BAA4B,gDAA+C,2BAA0B,4CAA2C;;;AF6B9M;AAPK,SAAS,gBAAiB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA0B;AACzB,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,4BAAY,cAAe;AAAA,MACvC,OAAQ;AAAA,QACP,MAAM,KAAK;AAAA,QACX,KAAK,KAAK;AAAA,QACV,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA,MACd;AAAA,MACE,GAAG,EAAE,CAAE,kBAAmB,GAAG,QAAQ;AAAA,MACvC,6BAA0B;AAAA,MAC1B,gBAAiB,CAAE,UAAW;AAC7B,YAAK,MAAM,WAAW,MAAM,eAAgB;AAC3C;AAAA,QACD;AACA,uBAAe;AAAA,MAChB;AAAA,MAEE;AAAA;AAAA,EACH;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"item-exit-overlay.mjs","names":["exitStyles"],"sources":["../../../style-runtime/src/index.ts","../../src/shared/item-exit-animation.module.css","../../src/shared/item-exit-overlay.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"485367d6fa\", \".e7a043178c12eb10__exit-overlay{opacity:1;overflow:hidden;pointer-events:none;position:absolute;transform:scale(1);transform-origin:center center;z-index:2}@media not (prefers-reduced-motion:reduce){.e7a043178c12eb10__exit-overlay{animation:_60b4685f351fbbe2__wp-grid-item-exit-opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1)) forwards,_5c9d51cb3a3d655b__wp-grid-item-exit-scale var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}}@keyframes _60b4685f351fbbe2__wp-grid-item-exit-opacity{0%{opacity:1}to{opacity:0}}@keyframes _5c9d51cb3a3d655b__wp-grid-item-exit-scale{0%{transform:scale(1)}to{transform:scale(.88)}}@media (prefers-reduced-motion:reduce){.e7a043178c12eb10__exit-overlay{display:none}}\");\n}\nexport default {\"exit-overlay\":\"e7a043178c12eb10__exit-overlay\",\"wp-grid-item-exit-opacity\":\"_60b4685f351fbbe2__wp-grid-item-exit-opacity\",\"wp-grid-item-exit-scale\":\"_5c9d51cb3a3d655b__wp-grid-item-exit-scale\"};\n","import { GRID_ITEM_DATA_KEY } from './grid-item-key';\nimport exitStyles from './item-exit-animation.module.css';\nimport type { RectSnapshot } from './use-layout-shift-animation';\n\nexport type ItemExitOverlayRect = Pick<\n\tRectSnapshot,\n\t'left' | 'top' | 'width' | 'height'\n>;\n\nexport type ItemExitOverlayProps = {\n\titemKey: string;\n\trect: ItemExitOverlayRect;\n\tchildren: React.ReactNode;\n\tonAnimationEnd: () => void;\n};\n\n/**\n * Ghost tile shown at the removed item's last position while siblings\n * reflow. Not a sortable grid cell — only visual exit feedback.\n *\n * @param root0 Component props.\n * @param root0.itemKey Layout key of the removed tile.\n * @param root0.rect Last bounds relative to the grid surface.\n * @param root0.children Cached tile content to render in the ghost.\n * @param root0.onAnimationEnd Called when the exit animation finishes.\n */\nexport function ItemExitOverlay( {\n\titemKey,\n\trect,\n\tchildren,\n\tonAnimationEnd,\n}: ItemExitOverlayProps ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ exitStyles[ 'exit-overlay' ] }\n\t\t\tstyle={ {\n\t\t\t\tleft: rect.left,\n\t\t\t\ttop: rect.top,\n\t\t\t\twidth: rect.width,\n\t\t\t\theight: rect.height,\n\t\t\t} }\n\t\t\t{ ...{ [ GRID_ITEM_DATA_KEY ]: itemKey } }\n\t\t\tdata-wp-grid-item-exiting=\"\"\n\t\t\tonAnimationEnd={ ( event ) => {\n\t\t\t\tif ( event.target !== event.currentTarget ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonAnimationEnd();\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;;;;;;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;CAC3E,IAAK,CAAE,eAAe,MACrB;CAGD,MAAM,UAAU,WAAW;CAC3B,IAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;CAEhE,IAAK,CAAE,gBAAiB;EACvB,iCAAiB,IAAI,IAAI;EACzB,QAAQ,eAAe,IAAK,gBAAgB,cAAe;CAC5D;CAEA,IAAK,eAAe,IAAK,IAAK,GAC7B;CAMD,IAAK,0BAA2B,gBAAgB,IAAK,GAAI;EACxD,eAAe,IAAK,IAAK;EACzB;CACD;CAEA,MAAM,QAAQ,eAAe,cAAe,OAAQ;CACpD,MAAM,aAAc,sBAAsB,IAAK;CAC/C,MAAM,YAAa,eAAe,eAAgB,GAAI,CAAE;CACxD,eAAe,KAAK,YAAa,KAAM;CACvC,eAAe,IAAK,IAAK;AAC1B;;;;;;;;;;;;AAaA,SAAgB,iBAAkB,gBAA2B;CAC5D,MAAM,UAAU,WAAW;CAE3B,QAAQ,UAAU,IACjB,iBACE,QAAQ,UAAU,IAAK,cAAe,KAAK,KAAM,CACpD;CAEA,KAAM,MAAM,CAAE,MAAM,QAAS,QAAQ,QACpC,YAAa,gBAAgB,MAAM,GAAI;CAGxC,aAAa;EACZ,MAAM,QAAQ,QAAQ,UAAU,IAAK,cAAe;EAEpD,IAAK,UAAU,KAAA,GACd;EAGD,IAAK,SAAS,GAAI;GACjB,QAAQ,UAAU,OAAQ,cAAe;GACzC;EACD;EAEA,QAAQ,UAAU,IAAK,gBAAgB,QAAQ,CAAE;CAClD;AACD;;;;;;;;;;;;AAaA,SAAgB,cAAe,MAAc,KAAc;CAC1D,MAAM,UAAU,WAAW;CAE3B,QAAQ,OAAO,IAAK,MAAM,GAAI;CAE9B,KAAM,MAAM,kBAAkB,QAAQ,UAAU,KAAK,GACpD,YAAa,gBAAgB,MAAM,GAAI;AAEzC;;ACpKA,IAAI,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa,QAC9D,cAAc,cAAc,uyBAAuyB;AAEp0B,IAAA,qCAAe;CAAC,gBAAe;CAAiC,6BAA4B;CAA+C,2BAA0B;AAA4C;;;;;;;;;;;;ACsBjN,SAAgB,gBAAiB,EAChC,SACA,MACA,UACA,kBACyB;CACzB,OACC,oBAAC,OAAD;EACC,WAAYA,mCAAY;EACxB,OAAQ;GACP,MAAM,KAAK;GACX,KAAK,KAAK;GACV,OAAO,KAAK;GACZ,QAAQ,KAAK;EACd;GACS,qBAAsB;EAC/B,6BAA0B;EAC1B,iBAAmB,UAAW;GAC7B,IAAK,MAAM,WAAW,MAAM,eAC3B;GAED,eAAe;EAChB;EAEE;CACE,CAAA;AAEP"}
|