@wordpress/grid 0.1.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/CHANGELOG.md +33 -0
- package/LICENSE.md +788 -0
- package/README.md +534 -0
- package/build/dashboard-grid/grid-item.cjs +308 -0
- package/build/dashboard-grid/grid-item.cjs.map +7 -0
- package/build/dashboard-grid/index.cjs +591 -0
- package/build/dashboard-grid/index.cjs.map +7 -0
- package/build/dashboard-grid/resolve-fill-widths.cjs +189 -0
- package/build/dashboard-grid/resolve-fill-widths.cjs.map +7 -0
- package/build/dashboard-grid/types.cjs +19 -0
- package/build/dashboard-grid/types.cjs.map +7 -0
- package/build/dashboard-lanes/index.cjs +558 -0
- package/build/dashboard-lanes/index.cjs.map +7 -0
- package/build/dashboard-lanes/lane-placement.cjs +110 -0
- package/build/dashboard-lanes/lane-placement.cjs.map +7 -0
- package/build/dashboard-lanes/lanes-item.cjs +295 -0
- package/build/dashboard-lanes/lanes-item.cjs.map +7 -0
- package/build/dashboard-lanes/types.cjs +19 -0
- package/build/dashboard-lanes/types.cjs.map +7 -0
- package/build/dashboard-lanes/use-lane-placement.cjs +206 -0
- package/build/dashboard-lanes/use-lane-placement.cjs.map +7 -0
- package/build/index.cjs +34 -0
- package/build/index.cjs.map +7 -0
- package/build/shared/drag-overlay-drop-animation.cjs +70 -0
- package/build/shared/drag-overlay-drop-animation.cjs.map +7 -0
- package/build/shared/grid-item-key.cjs +31 -0
- package/build/shared/grid-item-key.cjs.map +7 -0
- package/build/shared/grid-overlay.cjs +187 -0
- package/build/shared/grid-overlay.cjs.map +7 -0
- package/build/shared/item-exit-overlay.cjs +150 -0
- package/build/shared/item-exit-overlay.cjs.map +7 -0
- package/build/shared/resize-handle.cjs +224 -0
- package/build/shared/resize-handle.cjs.map +7 -0
- package/build/shared/resize-snap.cjs +47 -0
- package/build/shared/resize-snap.cjs.map +7 -0
- package/build/shared/types.cjs +19 -0
- package/build/shared/types.cjs.map +7 -0
- package/build/shared/use-item-exit-animation.cjs +148 -0
- package/build/shared/use-item-exit-animation.cjs.map +7 -0
- package/build/shared/use-layout-shift-animation.cjs +167 -0
- package/build/shared/use-layout-shift-animation.cjs.map +7 -0
- package/build-module/dashboard-grid/grid-item.mjs +273 -0
- package/build-module/dashboard-grid/grid-item.mjs.map +7 -0
- package/build-module/dashboard-grid/index.mjs +579 -0
- package/build-module/dashboard-grid/index.mjs.map +7 -0
- package/build-module/dashboard-grid/resolve-fill-widths.mjs +164 -0
- package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +7 -0
- package/build-module/dashboard-grid/types.mjs +1 -0
- package/build-module/dashboard-grid/types.mjs.map +7 -0
- package/build-module/dashboard-lanes/index.mjs +547 -0
- package/build-module/dashboard-lanes/index.mjs.map +7 -0
- package/build-module/dashboard-lanes/lane-placement.mjs +85 -0
- package/build-module/dashboard-lanes/lane-placement.mjs.map +7 -0
- package/build-module/dashboard-lanes/lanes-item.mjs +260 -0
- package/build-module/dashboard-lanes/lanes-item.mjs.map +7 -0
- package/build-module/dashboard-lanes/types.mjs +1 -0
- package/build-module/dashboard-lanes/types.mjs.map +7 -0
- package/build-module/dashboard-lanes/use-lane-placement.mjs +181 -0
- package/build-module/dashboard-lanes/use-lane-placement.mjs.map +7 -0
- package/build-module/index.mjs +8 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs +47 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs.map +7 -0
- package/build-module/shared/grid-item-key.mjs +6 -0
- package/build-module/shared/grid-item-key.mjs.map +7 -0
- package/build-module/shared/grid-overlay.mjs +152 -0
- package/build-module/shared/grid-overlay.mjs.map +7 -0
- package/build-module/shared/item-exit-overlay.mjs +125 -0
- package/build-module/shared/item-exit-overlay.mjs.map +7 -0
- package/build-module/shared/resize-handle.mjs +193 -0
- package/build-module/shared/resize-handle.mjs.map +7 -0
- package/build-module/shared/resize-snap.mjs +21 -0
- package/build-module/shared/resize-snap.mjs.map +7 -0
- package/build-module/shared/types.mjs +1 -0
- package/build-module/shared/types.mjs.map +7 -0
- package/build-module/shared/use-item-exit-animation.mjs +128 -0
- package/build-module/shared/use-item-exit-animation.mjs.map +7 -0
- package/build-module/shared/use-layout-shift-animation.mjs +140 -0
- package/build-module/shared/use-layout-shift-animation.mjs.map +7 -0
- package/build-types/dashboard-grid/grid-item.d.ts +3 -0
- package/build-types/dashboard-grid/grid-item.d.ts.map +1 -0
- package/build-types/dashboard-grid/index.d.ts +35 -0
- package/build-types/dashboard-grid/index.d.ts.map +1 -0
- package/build-types/dashboard-grid/resolve-fill-widths.d.ts +26 -0
- package/build-types/dashboard-grid/resolve-fill-widths.d.ts.map +1 -0
- package/build-types/dashboard-grid/stories/index.story.d.ts +98 -0
- package/build-types/dashboard-grid/stories/index.story.d.ts.map +1 -0
- package/build-types/dashboard-grid/types.d.ts +232 -0
- package/build-types/dashboard-grid/types.d.ts.map +1 -0
- package/build-types/dashboard-lanes/index.d.ts +40 -0
- package/build-types/dashboard-lanes/index.d.ts.map +1 -0
- package/build-types/dashboard-lanes/lane-placement.d.ts +126 -0
- package/build-types/dashboard-lanes/lane-placement.d.ts.map +1 -0
- package/build-types/dashboard-lanes/lanes-item.d.ts +52 -0
- package/build-types/dashboard-lanes/lanes-item.d.ts.map +1 -0
- package/build-types/dashboard-lanes/stories/index.story.d.ts +64 -0
- package/build-types/dashboard-lanes/stories/index.story.d.ts.map +1 -0
- package/build-types/dashboard-lanes/types.d.ts +151 -0
- package/build-types/dashboard-lanes/types.d.ts.map +1 -0
- package/build-types/dashboard-lanes/use-lane-placement.d.ts +74 -0
- package/build-types/dashboard-lanes/use-lane-placement.d.ts.map +1 -0
- package/build-types/index.d.ts +6 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/shared/drag-overlay-drop-animation.d.ts +13 -0
- package/build-types/shared/drag-overlay-drop-animation.d.ts.map +1 -0
- package/build-types/shared/grid-item-key.d.ts +6 -0
- package/build-types/shared/grid-item-key.d.ts.map +1 -0
- package/build-types/shared/grid-overlay.d.ts +19 -0
- package/build-types/shared/grid-overlay.d.ts.map +1 -0
- package/build-types/shared/item-exit-overlay.d.ts +20 -0
- package/build-types/shared/item-exit-overlay.d.ts.map +1 -0
- package/build-types/shared/resize-handle.d.ts +23 -0
- package/build-types/shared/resize-handle.d.ts.map +1 -0
- package/build-types/shared/resize-snap.d.ts +41 -0
- package/build-types/shared/resize-snap.d.ts.map +1 -0
- package/build-types/shared/types.d.ts +144 -0
- package/build-types/shared/types.d.ts.map +1 -0
- package/build-types/shared/use-item-exit-animation.d.ts +37 -0
- package/build-types/shared/use-item-exit-animation.d.ts.map +1 -0
- package/build-types/shared/use-layout-shift-animation.d.ts +77 -0
- package/build-types/shared/use-layout-shift-animation.d.ts.map +1 -0
- package/package.json +80 -0
- package/src/dashboard-grid/grid-item.module.css +94 -0
- package/src/dashboard-grid/grid-item.tsx +205 -0
- package/src/dashboard-grid/grid.module.css +134 -0
- package/src/dashboard-grid/index.tsx +713 -0
- package/src/dashboard-grid/resolve-fill-widths.ts +224 -0
- package/src/dashboard-grid/stories/index.story.tsx +930 -0
- package/src/dashboard-grid/test/keyboard-activation.test.tsx +76 -0
- package/src/dashboard-grid/test/resolve-fill-widths.test.ts +250 -0
- package/src/dashboard-grid/types.ts +271 -0
- package/src/dashboard-lanes/index.tsx +629 -0
- package/src/dashboard-lanes/lane-placement.ts +245 -0
- package/src/dashboard-lanes/lanes-item.module.css +93 -0
- package/src/dashboard-lanes/lanes-item.tsx +236 -0
- package/src/dashboard-lanes/lanes.module.css +152 -0
- package/src/dashboard-lanes/stories/index.story.tsx +518 -0
- package/src/dashboard-lanes/test/keyboard-activation.test.tsx +71 -0
- package/src/dashboard-lanes/test/lane-placement.test.ts +442 -0
- package/src/dashboard-lanes/test/use-lane-placement.test.tsx +358 -0
- package/src/dashboard-lanes/types.ts +176 -0
- package/src/dashboard-lanes/use-lane-placement.ts +313 -0
- package/src/index.ts +17 -0
- package/src/shared/actionable-area-slot.module.css +16 -0
- package/src/shared/drag-overlay-drop-animation.ts +66 -0
- package/src/shared/grid-item-key.ts +5 -0
- package/src/shared/grid-overlay.module.css +82 -0
- package/src/shared/grid-overlay.tsx +93 -0
- package/src/shared/item-exit-animation.module.css +49 -0
- package/src/shared/item-exit-overlay.tsx +57 -0
- package/src/shared/layout-shift-animation.module.css +16 -0
- package/src/shared/resize-handle.module.css +88 -0
- package/src/shared/resize-handle.tsx +163 -0
- package/src/shared/resize-snap.ts +63 -0
- package/src/shared/test/resize-snap.test.ts +35 -0
- package/src/shared/types.ts +164 -0
- package/src/shared/use-item-exit-animation.ts +199 -0
- package/src/shared/use-layout-shift-animation.ts +284 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/grid/src/shared/item-exit-overlay.tsx
|
|
21
|
+
var item_exit_overlay_exports = {};
|
|
22
|
+
__export(item_exit_overlay_exports, {
|
|
23
|
+
ItemExitOverlay: () => ItemExitOverlay
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(item_exit_overlay_exports);
|
|
26
|
+
var import_grid_item_key = require("./grid-item-key.cjs");
|
|
27
|
+
|
|
28
|
+
// packages/style-runtime/src/index.ts
|
|
29
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
30
|
+
function getRuntime() {
|
|
31
|
+
const globalScope = globalThis;
|
|
32
|
+
if (globalScope.__wpStyleRuntime) {
|
|
33
|
+
return globalScope.__wpStyleRuntime;
|
|
34
|
+
}
|
|
35
|
+
globalScope.__wpStyleRuntime = {
|
|
36
|
+
documents: /* @__PURE__ */ new Map(),
|
|
37
|
+
styles: /* @__PURE__ */ new Map(),
|
|
38
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
39
|
+
};
|
|
40
|
+
if (typeof document !== "undefined") {
|
|
41
|
+
registerDocument(document);
|
|
42
|
+
}
|
|
43
|
+
return globalScope.__wpStyleRuntime;
|
|
44
|
+
}
|
|
45
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
46
|
+
if (!targetDocument.head) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
50
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
51
|
+
)) {
|
|
52
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function injectStyle(targetDocument, hash, css) {
|
|
59
|
+
if (!targetDocument.head) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const runtime = getRuntime();
|
|
63
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
64
|
+
if (!injectedStyles) {
|
|
65
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
66
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
67
|
+
}
|
|
68
|
+
if (injectedStyles.has(hash)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
72
|
+
injectedStyles.add(hash);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const style = targetDocument.createElement("style");
|
|
76
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
77
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
78
|
+
targetDocument.head.appendChild(style);
|
|
79
|
+
injectedStyles.add(hash);
|
|
80
|
+
}
|
|
81
|
+
function registerDocument(targetDocument) {
|
|
82
|
+
const runtime = getRuntime();
|
|
83
|
+
runtime.documents.set(
|
|
84
|
+
targetDocument,
|
|
85
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
86
|
+
);
|
|
87
|
+
for (const [hash, css] of runtime.styles) {
|
|
88
|
+
injectStyle(targetDocument, hash, css);
|
|
89
|
+
}
|
|
90
|
+
return () => {
|
|
91
|
+
const count = runtime.documents.get(targetDocument);
|
|
92
|
+
if (count === void 0) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (count <= 1) {
|
|
96
|
+
runtime.documents.delete(targetDocument);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function registerStyle(hash, css) {
|
|
103
|
+
const runtime = getRuntime();
|
|
104
|
+
runtime.styles.set(hash, css);
|
|
105
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
106
|
+
injectStyle(targetDocument, hash, css);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// packages/grid/src/shared/item-exit-animation.module.css
|
|
111
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
112
|
+
registerStyle("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}}");
|
|
113
|
+
}
|
|
114
|
+
var item_exit_animation_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" };
|
|
115
|
+
|
|
116
|
+
// packages/grid/src/shared/item-exit-overlay.tsx
|
|
117
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
118
|
+
function ItemExitOverlay({
|
|
119
|
+
itemKey,
|
|
120
|
+
rect,
|
|
121
|
+
children,
|
|
122
|
+
onAnimationEnd
|
|
123
|
+
}) {
|
|
124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: item_exit_animation_default["exit-overlay"],
|
|
128
|
+
style: {
|
|
129
|
+
left: rect.left,
|
|
130
|
+
top: rect.top,
|
|
131
|
+
width: rect.width,
|
|
132
|
+
height: rect.height
|
|
133
|
+
},
|
|
134
|
+
...{ [import_grid_item_key.GRID_ITEM_DATA_KEY]: itemKey },
|
|
135
|
+
"data-wp-grid-item-exiting": "",
|
|
136
|
+
onAnimationEnd: (event) => {
|
|
137
|
+
if (event.target !== event.currentTarget) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
onAnimationEnd();
|
|
141
|
+
},
|
|
142
|
+
children
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
ItemExitOverlay
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=item-exit-overlay.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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": ["/**\n * Internal dependencies\n */\nimport { 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": ";;;;;;;;;;;;;;;;;;;;A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AW,MAAM,eAAgB;AAC3C;AAAA,QACD;AACA,uBAAe;AAAA,MAChB;AAAA,MAEE;AAAA;AAAA,EACH;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
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
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/grid/src/shared/resize-handle.tsx
|
|
31
|
+
var resize_handle_exports = {};
|
|
32
|
+
__export(resize_handle_exports, {
|
|
33
|
+
default: () => ResizeHandleWrapper
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(resize_handle_exports);
|
|
36
|
+
var import_core = require("@dnd-kit/core");
|
|
37
|
+
var import_clsx = __toESM(require("clsx"));
|
|
38
|
+
var import_element = require("@wordpress/element");
|
|
39
|
+
var import_compose = require("@wordpress/compose");
|
|
40
|
+
|
|
41
|
+
// packages/style-runtime/src/index.ts
|
|
42
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
43
|
+
function getRuntime() {
|
|
44
|
+
const globalScope = globalThis;
|
|
45
|
+
if (globalScope.__wpStyleRuntime) {
|
|
46
|
+
return globalScope.__wpStyleRuntime;
|
|
47
|
+
}
|
|
48
|
+
globalScope.__wpStyleRuntime = {
|
|
49
|
+
documents: /* @__PURE__ */ new Map(),
|
|
50
|
+
styles: /* @__PURE__ */ new Map(),
|
|
51
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
52
|
+
};
|
|
53
|
+
if (typeof document !== "undefined") {
|
|
54
|
+
registerDocument(document);
|
|
55
|
+
}
|
|
56
|
+
return globalScope.__wpStyleRuntime;
|
|
57
|
+
}
|
|
58
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
59
|
+
if (!targetDocument.head) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
63
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
64
|
+
)) {
|
|
65
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function injectStyle(targetDocument, hash, css) {
|
|
72
|
+
if (!targetDocument.head) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const runtime = getRuntime();
|
|
76
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
77
|
+
if (!injectedStyles) {
|
|
78
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
79
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
80
|
+
}
|
|
81
|
+
if (injectedStyles.has(hash)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
85
|
+
injectedStyles.add(hash);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const style = targetDocument.createElement("style");
|
|
89
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
90
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
91
|
+
targetDocument.head.appendChild(style);
|
|
92
|
+
injectedStyles.add(hash);
|
|
93
|
+
}
|
|
94
|
+
function registerDocument(targetDocument) {
|
|
95
|
+
const runtime = getRuntime();
|
|
96
|
+
runtime.documents.set(
|
|
97
|
+
targetDocument,
|
|
98
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
99
|
+
);
|
|
100
|
+
for (const [hash, css] of runtime.styles) {
|
|
101
|
+
injectStyle(targetDocument, hash, css);
|
|
102
|
+
}
|
|
103
|
+
return () => {
|
|
104
|
+
const count = runtime.documents.get(targetDocument);
|
|
105
|
+
if (count === void 0) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (count <= 1) {
|
|
109
|
+
runtime.documents.delete(targetDocument);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function registerStyle(hash, css) {
|
|
116
|
+
const runtime = getRuntime();
|
|
117
|
+
runtime.styles.set(hash, css);
|
|
118
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
119
|
+
injectStyle(targetDocument, hash, css);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// packages/grid/src/shared/resize-handle.module.css
|
|
124
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
125
|
+
registerStyle("13645360b3", '._91523dc3a37aecb8__resize-handle-slot{opacity:1}@media (prefers-reduced-motion:no-preference){._91523dc3a37aecb8__resize-handle-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-dragging] ._91523dc3a37aecb8__resize-handle-slot,[data-wp-grid-resizing] ._91523dc3a37aecb8__resize-handle-slot{opacity:0;pointer-events:none}[data-wp-grid-resizing]\n[data-wp-grid-item-resizing]\n._91523dc3a37aecb8__resize-handle-slot{opacity:1;pointer-events:auto}._4da787f72dc00d8b__resize-handle{border-block-end:12px solid var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-inline-start:12px solid transparent;bottom:0;cursor:nwse-resize;height:0;inset-inline-end:0;position:absolute;width:0;z-index:1}._885412b44a137da0__is-horizontal-only{align-items:center;background:transparent;border-style:none;bottom:auto;cursor:ew-resize;display:flex;height:40px;justify-content:center;top:50%;transform:translateY(-50%);width:16px}._885412b44a137da0__is-horizontal-only:before{background-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-radius:2px;content:"";height:24px;width:4px}@media (forced-colors:active){._885412b44a137da0__is-horizontal-only:before{background-color:Highlight}}');
|
|
126
|
+
}
|
|
127
|
+
var resize_handle_default = { "resize-handle-slot": "_91523dc3a37aecb8__resize-handle-slot", "resize-handle": "_4da787f72dc00d8b__resize-handle", "is-horizontal-only": "_885412b44a137da0__is-horizontal-only" };
|
|
128
|
+
|
|
129
|
+
// packages/grid/src/shared/resize-handle.tsx
|
|
130
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
131
|
+
function lockDocumentCursorWhileActive(getDocument, cursor) {
|
|
132
|
+
const root = getDocument().documentElement;
|
|
133
|
+
const previous = root.style.cursor;
|
|
134
|
+
root.style.cursor = cursor;
|
|
135
|
+
return () => {
|
|
136
|
+
root.style.cursor = previous;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function ResizeHandle({
|
|
140
|
+
itemId,
|
|
141
|
+
verticalResizable = true,
|
|
142
|
+
renderResizeHandle
|
|
143
|
+
}) {
|
|
144
|
+
const { attributes, listeners, setNodeRef, isDragging } = (0, import_core.useDraggable)({
|
|
145
|
+
id: "draggable",
|
|
146
|
+
data: { itemId }
|
|
147
|
+
});
|
|
148
|
+
const ownerDocumentRef = (0, import_element.useRef)(null);
|
|
149
|
+
const setOwnerDocumentRef = (0, import_element.useCallback)((node) => {
|
|
150
|
+
ownerDocumentRef.current = node?.ownerDocument ?? null;
|
|
151
|
+
}, []);
|
|
152
|
+
const mergedRef = (0, import_compose.useMergeRefs)([setOwnerDocumentRef, setNodeRef]);
|
|
153
|
+
(0, import_element.useEffect)(() => {
|
|
154
|
+
if (!isDragging) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const cursor = verticalResizable ? "nwse-resize" : "ew-resize";
|
|
158
|
+
return lockDocumentCursorWhileActive(
|
|
159
|
+
() => ownerDocumentRef.current ?? document,
|
|
160
|
+
cursor
|
|
161
|
+
);
|
|
162
|
+
}, [isDragging, verticalResizable]);
|
|
163
|
+
if (renderResizeHandle) {
|
|
164
|
+
const RenderResizeHandle = renderResizeHandle;
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
+
RenderResizeHandle,
|
|
167
|
+
{
|
|
168
|
+
ref: mergedRef,
|
|
169
|
+
listeners,
|
|
170
|
+
attributes,
|
|
171
|
+
verticalResizable,
|
|
172
|
+
isResizing: isDragging,
|
|
173
|
+
itemId
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
ref: mergedRef,
|
|
181
|
+
className: (0, import_clsx.default)(
|
|
182
|
+
resize_handle_default["resize-handle"],
|
|
183
|
+
!verticalResizable && resize_handle_default["is-horizontal-only"]
|
|
184
|
+
),
|
|
185
|
+
...listeners,
|
|
186
|
+
...attributes
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
function ResizeHandleWrapper(props) {
|
|
191
|
+
const throttleDelay = 16;
|
|
192
|
+
const throttledResize = (0, import_compose.useThrottle)((delta) => {
|
|
193
|
+
if (props.onResize) {
|
|
194
|
+
props.onResize(delta);
|
|
195
|
+
}
|
|
196
|
+
}, throttleDelay);
|
|
197
|
+
const handleDragMove = (event) => {
|
|
198
|
+
if (event.active.id !== "draggable") {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
throttledResize({
|
|
202
|
+
width: event.delta.x,
|
|
203
|
+
height: event.delta.y
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
const handleDragEnd = () => {
|
|
207
|
+
if (props.onResizeEnd) {
|
|
208
|
+
props.onResizeEnd();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
212
|
+
import_core.DndContext,
|
|
213
|
+
{
|
|
214
|
+
autoScroll: {
|
|
215
|
+
threshold: { x: 5e-3, y: 5e-3 },
|
|
216
|
+
acceleration: 1
|
|
217
|
+
},
|
|
218
|
+
onDragMove: handleDragMove,
|
|
219
|
+
onDragEnd: handleDragEnd,
|
|
220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: resize_handle_default["resize-handle-slot"], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResizeHandle, { ...props }) })
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=resize-handle.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shared/resize-handle.tsx", "../../../style-runtime/src/index.ts", "../../src/shared/resize-handle.module.css"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { DndContext, useDraggable } from '@dnd-kit/core';\nimport type { DragMoveEvent } from '@dnd-kit/core';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMergeRefs, useThrottle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { ResizeDelta, ResizeHandleProps } from './types';\nimport styles from './resize-handle.module.css';\n\n/**\n * Sets `document.documentElement.style.cursor` for the duration of a drag\n * and restores it on cleanup. Lives outside the component so cursor writes\n * are not analyzed as mutating values derived from refs in the component\n * body (react-hooks/immutability).\n *\n * @param getDocument Returns the document whose root element should receive\n * the cursor (handle owner, or global `document`).\n * @param cursor CSS cursor value while active.\n * @return Cleanup that restores the previous cursor.\n */\nfunction lockDocumentCursorWhileActive(\n\tgetDocument: () => Document,\n\tcursor: string\n): () => void {\n\tconst root = getDocument().documentElement;\n\tconst previous = root.style.cursor;\n\troot.style.cursor = cursor;\n\treturn () => {\n\t\troot.style.cursor = previous;\n\t};\n}\n\nfunction ResizeHandle( {\n\titemId,\n\tverticalResizable = true,\n\trenderResizeHandle,\n}: ResizeHandleProps ) {\n\tconst { attributes, listeners, setNodeRef, isDragging } = useDraggable( {\n\t\tid: 'draggable',\n\t\tdata: { itemId },\n\t} );\n\n\t// Snapshot owner document on mount/update via ref callback so the\n\t// cursor-lock effect can resolve the correct document in an iframe.\n\tconst ownerDocumentRef = useRef< Document | null >( null );\n\tconst setOwnerDocumentRef = useCallback( ( node: HTMLElement | null ) => {\n\t\townerDocumentRef.current = node?.ownerDocument ?? null;\n\t}, [] );\n\tconst mergedRef = useMergeRefs( [ setOwnerDocumentRef, setNodeRef ] );\n\n\t// Lock the document cursor while the gesture is active. Without\n\t// this, the OS pointer reverts to the default arrow as soon as it\n\t// leaves the handle's hit area, even though the resize is still\n\t// in progress.\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\treturn;\n\t\t}\n\t\tconst cursor = verticalResizable ? 'nwse-resize' : 'ew-resize';\n\t\treturn lockDocumentCursorWhileActive(\n\t\t\t() => ownerDocumentRef.current ?? document,\n\t\t\tcursor\n\t\t);\n\t}, [ isDragging, verticalResizable ] );\n\n\tif ( renderResizeHandle ) {\n\t\tconst RenderResizeHandle = renderResizeHandle;\n\t\treturn (\n\t\t\t<RenderResizeHandle\n\t\t\t\tref={ mergedRef }\n\t\t\t\tlisteners={ listeners }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tverticalResizable={ verticalResizable }\n\t\t\t\tisResizing={ isDragging }\n\t\t\t\titemId={ itemId }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ mergedRef }\n\t\t\tclassName={ clsx(\n\t\t\t\tstyles[ 'resize-handle' ],\n\t\t\t\t! verticalResizable && styles[ 'is-horizontal-only' ]\n\t\t\t) }\n\t\t\t{ ...listeners }\n\t\t\t{ ...attributes }\n\t\t/>\n\t);\n}\n\n/**\n * Renders a corner resize handle inside an isolated `<DndContext>`.\n * Reports the cursor offset since the gesture started (in pixels)\n * via `onResize`, throttled to one animation frame so the grid\n * commit loop runs at most once per paint.\n *\n * Auto-scroll is enabled with a tight trigger zone and a low\n * acceleration so a resize gesture near the viewport edge scrolls\n * the page only when the user deliberately pushes against the very\n * edge, and even then at a pace the user can interrupt by releasing.\n * Default tuning would otherwise produce a runaway loop where the\n * page scrolls fast, dnd-kit's document-coordinate `delta` inflates\n * with the scroll, and the tile keeps growing without further user\n * input.\n *\n * @param props Component props.\n */\nexport default function ResizeHandleWrapper( props: ResizeHandleProps ) {\n\tconst throttleDelay = 16;\n\tconst throttledResize = useThrottle( ( delta: ResizeDelta ) => {\n\t\tif ( props.onResize ) {\n\t\t\tprops.onResize( delta );\n\t\t}\n\t}, throttleDelay );\n\n\t// `event.delta` is the cursor offset from the gesture start —\n\t// not from the handle's current position — so it stays stable\n\t// even when the tile (and therefore the handle) jumps a column.\n\t// The grid's resize logic snapshots the start width and adds\n\t// `delta`, so the two must share the same frame of reference.\n\tconst handleDragMove = ( event: DragMoveEvent ) => {\n\t\tif ( event.active.id !== 'draggable' ) {\n\t\t\treturn;\n\t\t}\n\t\tthrottledResize( {\n\t\t\twidth: event.delta.x,\n\t\t\theight: event.delta.y,\n\t\t} );\n\t};\n\n\tconst handleDragEnd = () => {\n\t\tif ( props.onResizeEnd ) {\n\t\t\tprops.onResizeEnd();\n\t\t}\n\t};\n\n\treturn (\n\t\t<DndContext\n\t\t\tautoScroll={ {\n\t\t\t\tthreshold: { x: 0.005, y: 0.005 },\n\t\t\t\tacceleration: 1,\n\t\t\t} }\n\t\t\tonDragMove={ handleDragMove }\n\t\t\tonDragEnd={ handleDragEnd }\n\t\t>\n\t\t\t<div className={ styles[ 'resize-handle-slot' ] }>\n\t\t\t\t<ResizeHandle { ...props } />\n\t\t\t</div>\n\t\t</DndContext>\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(\"13645360b3\", \"._91523dc3a37aecb8__resize-handle-slot{opacity:1}@media (prefers-reduced-motion:no-preference){._91523dc3a37aecb8__resize-handle-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-dragging] ._91523dc3a37aecb8__resize-handle-slot,[data-wp-grid-resizing] ._91523dc3a37aecb8__resize-handle-slot{opacity:0;pointer-events:none}[data-wp-grid-resizing]\\n[data-wp-grid-item-resizing]\\n._91523dc3a37aecb8__resize-handle-slot{opacity:1;pointer-events:auto}._4da787f72dc00d8b__resize-handle{border-block-end:12px solid var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-inline-start:12px solid transparent;bottom:0;cursor:nwse-resize;height:0;inset-inline-end:0;position:absolute;width:0;z-index:1}._885412b44a137da0__is-horizontal-only{align-items:center;background:transparent;border-style:none;bottom:auto;cursor:ew-resize;display:flex;height:40px;justify-content:center;top:50%;transform:translateY(-50%);width:16px}._885412b44a137da0__is-horizontal-only:before{background-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-radius:2px;content:\\\"\\\";height:24px;width:4px}@media (forced-colors:active){._885412b44a137da0__is-horizontal-only:before{background-color:Highlight}}\");\n}\nexport default {\"resize-handle-slot\":\"_91523dc3a37aecb8__resize-handle-slot\",\"resize-handle\":\"_4da787f72dc00d8b__resize-handle\",\"is-horizontal-only\":\"_885412b44a137da0__is-horizontal-only\"};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAyC;AAEzC,kBAAiB;AAKjB,qBAA+C;AAC/C,qBAA0C;;;ACD1C,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,oB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;AAAA,QACb;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM;AAAA,MACN,eAAY,YAAAA;AAAA,QACX,sBAAQ,eAAgB;AAAA,QACxB,CAAE,qBAAqB,sBAAQ,oBAAqB;AAAA,MACrD;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA;AAAA,EACN;AAEF;AAmBe,SAAR,oBAAsC,OAA2B;AACvE,QAAM,gBAAgB;AACtB,QAAM,sBAAkB,4BAAa,CAAE,UAAwB;AAC9D,QAAK,MAAM,UAAW;AACrB,YAAM,SAAU,KAAM;AAAA,IACvB;AAAA,EACD,GAAG,aAAc;AAOjB,QAAM,iBAAiB,CAAE,UAA0B;AAClD,QAAK,MAAM,OAAO,OAAO,aAAc;AACtC;AAAA,IACD;AACA,oBAAiB;AAAA,MAChB,OAAO,MAAM,MAAM;AAAA,MACnB,QAAQ,MAAM,MAAM;AAAA,IACrB,CAAE;AAAA,EACH;AAEA,QAAM,gBAAgB,MAAM;AAC3B,QAAK,MAAM,aAAc;AACxB,YAAM,YAAY;AAAA,IACnB;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,YAAa;AAAA,QACZ,WAAW,EAAE,GAAG,MAAO,GAAG,KAAM;AAAA,QAChC,cAAc;AAAA,MACf;AAAA,MACA,YAAa;AAAA,MACb,WAAY;AAAA,MAEZ,sDAAC,SAAI,WAAY,sBAAQ,oBAAqB,GAC7C,sDAAC,gBAAe,GAAG,OAAQ,GAC5B;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["clsx"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/grid/src/shared/resize-snap.ts
|
|
21
|
+
var resize_snap_exports = {};
|
|
22
|
+
__export(resize_snap_exports, {
|
|
23
|
+
clampResizeDelta: () => clampResizeDelta,
|
|
24
|
+
gridSpanToPixelSize: () => gridSpanToPixelSize
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(resize_snap_exports);
|
|
27
|
+
function clampResizeDelta(delta, initialSize, minSize) {
|
|
28
|
+
const maxShrinkWidth = initialSize.width - minSize.width;
|
|
29
|
+
const width = Math.max(delta.width, -maxShrinkWidth);
|
|
30
|
+
if (minSize.height === void 0) {
|
|
31
|
+
return { ...delta, width };
|
|
32
|
+
}
|
|
33
|
+
const maxShrinkHeight = initialSize.height - minSize.height;
|
|
34
|
+
const height = Math.max(delta.height, -maxShrinkHeight);
|
|
35
|
+
return { width, height };
|
|
36
|
+
}
|
|
37
|
+
function gridSpanToPixelSize(columnSpan, rowSpan, columnWidth, gapPx, rowHeightPx) {
|
|
38
|
+
const widthPx = columnSpan * columnWidth + (columnSpan - 1) * gapPx;
|
|
39
|
+
const heightPx = rowHeightPx === null ? null : rowSpan * rowHeightPx + (rowSpan - 1) * gapPx;
|
|
40
|
+
return { widthPx, heightPx };
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
clampResizeDelta,
|
|
45
|
+
gridSpanToPixelSize
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=resize-snap.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shared/resize-snap.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ResizeDelta } from './types';\n\n/**\n * Pixel dimensions for the snapped resize preview outline.\n */\nexport type ResizeSnapSize = {\n\twidthPx: number;\n\t/** When `null`, the preview spans the item's content height (lanes). */\n\theightPx: number | null;\n};\n\n/**\n * Clamps a resize delta so the tile cannot shrink below the given\n * minimum width (and height when provided).\n *\n * @param delta Cursor offset from the gesture start in pixels.\n * @param initialSize Size captured at gesture start.\n * @param initialSize.width Initial width in pixels.\n * @param initialSize.height Initial height in pixels.\n * @param minSize Minimum tile size in pixels.\n * @param minSize.width Minimum width in pixels.\n * @param minSize.height Minimum height in pixels, when vertical resize applies.\n */\nexport function clampResizeDelta(\n\tdelta: ResizeDelta,\n\tinitialSize: { width: number; height: number },\n\tminSize: { width: number; height?: number }\n): ResizeDelta {\n\tconst maxShrinkWidth = initialSize.width - minSize.width;\n\tconst width = Math.max( delta.width, -maxShrinkWidth );\n\tif ( minSize.height === undefined ) {\n\t\treturn { ...delta, width };\n\t}\n\tconst maxShrinkHeight = initialSize.height - minSize.height;\n\tconst height = Math.max( delta.height, -maxShrinkHeight );\n\treturn { width, height };\n}\n\n/**\n * Converts grid spans to pixel width/height for the resize-preview\n * outline, using the same track math the surface uses for placement.\n *\n * @param columnSpan Number of columns the snap target spans.\n * @param rowSpan Number of rows the snap target spans.\n * @param columnWidth Width of one column track in pixels.\n * @param gapPx Gap between tracks in pixels.\n * @param rowHeightPx Row track height in pixels, or `null` when rows\n * are content-sized.\n */\nexport function gridSpanToPixelSize(\n\tcolumnSpan: number,\n\trowSpan: number,\n\tcolumnWidth: number,\n\tgapPx: number,\n\trowHeightPx: number | null\n): ResizeSnapSize {\n\tconst widthPx = columnSpan * columnWidth + ( columnSpan - 1 ) * gapPx;\n\tconst heightPx =\n\t\trowHeightPx === null\n\t\t\t? null\n\t\t\t: rowSpan * rowHeightPx + ( rowSpan - 1 ) * gapPx;\n\treturn { widthPx, heightPx };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBO,SAAS,iBACf,OACA,aACA,SACc;AACd,QAAM,iBAAiB,YAAY,QAAQ,QAAQ;AACnD,QAAM,QAAQ,KAAK,IAAK,MAAM,OAAO,CAAC,cAAe;AACrD,MAAK,QAAQ,WAAW,QAAY;AACnC,WAAO,EAAE,GAAG,OAAO,MAAM;AAAA,EAC1B;AACA,QAAM,kBAAkB,YAAY,SAAS,QAAQ;AACrD,QAAM,SAAS,KAAK,IAAK,MAAM,QAAQ,CAAC,eAAgB;AACxD,SAAO,EAAE,OAAO,OAAO;AACxB;AAaO,SAAS,oBACf,YACA,SACA,aACA,OACA,aACiB;AACjB,QAAM,UAAU,aAAa,eAAgB,aAAa,KAAM;AAChE,QAAM,WACL,gBAAgB,OACb,OACA,UAAU,eAAgB,UAAU,KAAM;AAC9C,SAAO,EAAE,SAAS,SAAS;AAC5B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/grid/src/shared/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shared/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { useDraggable } from '@dnd-kit/core';\n\n// `useDraggable`'s `listeners` and `attributes` types are not exported\n// from `@dnd-kit/core`'s public surface, so derive them from the hook\n// itself rather than via a deep import.\ntype DraggableBindings = ReturnType< typeof useDraggable >;\n\n/**\n * Cursor offset reported by the resize handle, in pixels relative to\n * the gesture start. Width and height are independent so the surface\n * can step columns and rows separately.\n */\nexport type ResizeDelta = {\n\twidth: number;\n\theight: number;\n};\n\n/**\n * Props received by a custom resize handle component. Spread `listeners`\n * and `attributes` onto the element that should respond to the gesture,\n * and assign `ref` to the same element so dnd-kit can track it.\n */\nexport interface ResizeHandleRenderProps {\n\t/**\n\t * Ref callback to attach to the gesture-bearing element.\n\t */\n\tref: DraggableBindings[ 'setNodeRef' ];\n\n\t/**\n\t * Pointer/keyboard event listeners that initiate the drag.\n\t */\n\tlisteners: DraggableBindings[ 'listeners' ];\n\n\t/**\n\t * Accessibility and dnd-kit attributes (role, aria-*, tabIndex…).\n\t */\n\tattributes: DraggableBindings[ 'attributes' ];\n\n\t/**\n\t * Whether vertical resizing is allowed for this tile. Useful for\n\t * adapting the cursor or visual cue.\n\t */\n\tverticalResizable: boolean;\n\n\t/**\n\t * True while the user is actively dragging this handle. Use it to\n\t * swap colors, icons, or transforms during the gesture.\n\t */\n\tisResizing: boolean;\n\n\t/**\n\t * Owning item's `key`. Available so consumers can render per-tile\n\t * content if needed.\n\t */\n\titemId?: string;\n}\n\n/**\n * Props received by a custom drag-preview component. The surface mounts\n * the component inside `<DragOverlay>` and supplies the active tile's\n * cloned children plus its `key`. The component is responsible for the\n * visual chrome of the dragged clone (shadow, radius, padding); the\n * surface keeps a thin functional wrapper around it that owns the lift\n * cue, the cursor, and pointer pass-through during the gesture.\n */\nexport interface DragPreviewRenderProps {\n\t/**\n\t * The cloned tile content the surface mounts inside the\n\t * `<DragOverlay>` portal. Render it where the visual wrapper\n\t * expects the tile body.\n\t */\n\tchildren: React.ReactNode;\n\n\t/**\n\t * Owning tile's `key`. Useful when the visual chrome needs to\n\t * vary by which tile is being dragged.\n\t */\n\titemId: string;\n}\n\n/**\n * Props received by a custom grid overlay component. The overlay\n * paints behind the tiles in edit mode to visualize the column tracks\n * and (when `rowHeight` is defined) the row tracks. Receives a\n * snapshot of the surface's resolved layout parameters so the visual\n * can reproduce the tracks pixel-accurately without re-deriving them.\n *\n * Reused by both `DashboardGrid` and `DashboardLanes`: lanes pass no\n * `rowHeight` because heights are content-driven.\n */\nexport interface GridOverlayRenderProps {\n\t/**\n\t * Number of column tracks in the active surface. In responsive\n\t * mode (`minColumnWidth`), this is the count derived from the\n\t * container width, not the prop value.\n\t */\n\tcolumns: number;\n\n\t/**\n\t * Row height in pixels for surfaces with uniform rows. Omitted on\n\t * surfaces with content-driven heights (lanes) or when row height\n\t * is `'auto'`; in those cases row markers are omitted.\n\t */\n\trowHeight?: number;\n\n\t/**\n\t * Number of row tracks to mirror in each column. Derived from the\n\t * grid container height when `rowHeight` is numeric; omitted when\n\t * row height is unknown.\n\t */\n\trows?: number;\n\n\t/**\n\t * Whether the overlay should be visible. Surfaces render the\n\t * overlay even when `false` so the implementation can transition\n\t * opacity in and out; while `false`, the overlay must hide itself\n\t * (and ideally release paint cost via `visibility: hidden` or an\n\t * equivalent).\n\t */\n\tisActive: boolean;\n}\n\n/**\n * Props for the internal `<ResizeHandle />` wrapper.\n */\nexport interface ResizeHandleProps {\n\t/**\n\t * Owning item's `key`. Forwarded as `data.itemId` on the draggable\n\t * so the parent can correlate the gesture with a tile if needed.\n\t */\n\titemId?: string;\n\n\t/**\n\t * Whether the handle should track vertical movement. When false,\n\t * the handle still appears but only emits horizontal deltas, and\n\t * the cursor is constrained to the column resize axis.\n\t *\n\t * @default true\n\t */\n\tverticalResizable?: boolean;\n\n\t/**\n\t * Callback fired while the handle is being dragged. Receives the\n\t * cursor offset from the gesture start in pixels.\n\t */\n\tonResize?: ( delta: ResizeDelta ) => void;\n\n\t/**\n\t * Callback fired when the gesture ends.\n\t */\n\tonResizeEnd?: () => void;\n\n\t/**\n\t * Component that overrides the default corner triangle with a\n\t * custom element. Receives gesture wiring (`ref`, `listeners`,\n\t * `attributes`) plus context. The surface keeps ownership of the\n\t * `<DndContext>` and the throttled delta loop; consumers are only\n\t * responsible for the visual.\n\t */\n\trenderResizeHandle?: React.ComponentType< ResizeHandleRenderProps >;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|