@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,288 +1,232 @@
|
|
|
1
|
-
// packages/grid/src/dashboard-grid/grid-item.tsx
|
|
2
1
|
import { useSortable } from "@dnd-kit/sortable";
|
|
3
2
|
import clsx from "clsx";
|
|
4
|
-
import {
|
|
3
|
+
import { useRef, useState } from "@wordpress/element";
|
|
5
4
|
import { useMergeRefs } from "@wordpress/compose";
|
|
6
5
|
import { inertValue } from "@wordpress/react-inert-value";
|
|
7
|
-
|
|
6
|
+
import { GRID_ITEM_DATA_KEY } from "../shared/grid-item-key.mjs";
|
|
7
|
+
import ResizeHandle from "../shared/resize-handle.mjs";
|
|
8
|
+
import { clampResizeDelta } from "../shared/resize-snap.mjs";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
// packages/style-runtime/src/index.ts
|
|
9
|
-
|
|
11
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
12
|
+
/**
|
|
13
|
+
* Returns the shared style runtime registry.
|
|
14
|
+
*
|
|
15
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
16
|
+
* package can coordinate through the same document and style maps.
|
|
17
|
+
*
|
|
18
|
+
* @return The shared runtime registry.
|
|
19
|
+
*/
|
|
10
20
|
function getRuntime() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (typeof document !== "undefined") {
|
|
21
|
-
registerDocument(document);
|
|
22
|
-
}
|
|
23
|
-
return globalScope.__wpStyleRuntime;
|
|
21
|
+
const globalScope = globalThis;
|
|
22
|
+
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
23
|
+
globalScope.__wpStyleRuntime = {
|
|
24
|
+
documents: /* @__PURE__ */ new Map(),
|
|
25
|
+
styles: /* @__PURE__ */ new Map(),
|
|
26
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
27
|
+
};
|
|
28
|
+
if (typeof document !== "undefined") registerDocument(document);
|
|
29
|
+
return globalScope.__wpStyleRuntime;
|
|
24
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
33
|
+
*
|
|
34
|
+
* @param targetDocument Document to inspect.
|
|
35
|
+
* @param hash Stable hash for the transformed CSS.
|
|
36
|
+
*
|
|
37
|
+
* @return Whether the style hash already exists in the document.
|
|
38
|
+
*/
|
|
25
39
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
30
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
31
|
-
)) {
|
|
32
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
40
|
+
if (!targetDocument.head) return false;
|
|
41
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
42
|
+
return false;
|
|
37
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Injects a registered style into a document, unless that document already
|
|
46
|
+
* contains a style tag for the same hash.
|
|
47
|
+
*
|
|
48
|
+
* @param targetDocument Document to inject the style into.
|
|
49
|
+
* @param hash Stable hash for the transformed CSS.
|
|
50
|
+
* @param css CSS text to inject.
|
|
51
|
+
*/
|
|
38
52
|
function injectStyle(targetDocument, hash, css) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
57
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
58
|
-
targetDocument.head.appendChild(style);
|
|
59
|
-
injectedStyles.add(hash);
|
|
53
|
+
if (!targetDocument.head) return;
|
|
54
|
+
const runtime = getRuntime();
|
|
55
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
56
|
+
if (!injectedStyles) {
|
|
57
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
58
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
59
|
+
}
|
|
60
|
+
if (injectedStyles.has(hash)) return;
|
|
61
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
62
|
+
injectedStyles.add(hash);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const style = targetDocument.createElement("style");
|
|
66
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
67
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
68
|
+
targetDocument.head.appendChild(style);
|
|
69
|
+
injectedStyles.add(hash);
|
|
60
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Registers a document as a style injection target.
|
|
73
|
+
*
|
|
74
|
+
* Existing registered styles are replayed into the document immediately.
|
|
75
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
76
|
+
* same document without one cleanup removing it while another registration is
|
|
77
|
+
* still active.
|
|
78
|
+
*
|
|
79
|
+
* @param targetDocument Document to receive registered styles.
|
|
80
|
+
* @return Cleanup function that unregisters this document registration.
|
|
81
|
+
*/
|
|
61
82
|
function registerDocument(targetDocument) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
if (count <= 1) {
|
|
76
|
-
runtime.documents.delete(targetDocument);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
80
|
-
};
|
|
83
|
+
const runtime = getRuntime();
|
|
84
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
85
|
+
for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
|
|
86
|
+
return () => {
|
|
87
|
+
const count = runtime.documents.get(targetDocument);
|
|
88
|
+
if (count === void 0) return;
|
|
89
|
+
if (count <= 1) {
|
|
90
|
+
runtime.documents.delete(targetDocument);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
94
|
+
};
|
|
81
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Registers a style and injects it into all registered documents.
|
|
98
|
+
*
|
|
99
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
100
|
+
* the same hash will not add duplicate style tags to a document.
|
|
101
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
102
|
+
* replayed into documents that are registered later.
|
|
103
|
+
*
|
|
104
|
+
* @param hash Stable hash for the transformed CSS.
|
|
105
|
+
* @param css CSS text to inject.
|
|
106
|
+
*/
|
|
82
107
|
function registerStyle(hash, css) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
injectStyle(targetDocument, hash, css);
|
|
87
|
-
}
|
|
108
|
+
const runtime = getRuntime();
|
|
109
|
+
runtime.styles.set(hash, css);
|
|
110
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
88
111
|
}
|
|
89
|
-
|
|
90
112
|
// packages/grid/src/shared/actionable-area-slot.module.css
|
|
91
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
var actionable_area_slot_default = { "actionable-area-slot": "_1c54fe8165d3023e__actionable-area-slot" };
|
|
95
|
-
|
|
96
|
-
// packages/grid/src/dashboard-grid/grid-item.tsx
|
|
97
|
-
import { GRID_ITEM_DATA_KEY } from "../shared/grid-item-key.mjs";
|
|
98
|
-
import ResizeHandle from "../shared/resize-handle.mjs";
|
|
99
|
-
import { clampResizeDelta } from "../shared/resize-snap.mjs";
|
|
100
|
-
|
|
113
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("36a7a084ce", "._0a2b470abcf47e5b__actionable-area-slot{opacity:1}@media (prefers-reduced-motion:no-preference){._0a2b470abcf47e5b__actionable-area-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-resizing] ._0a2b470abcf47e5b__actionable-area-slot{opacity:0;pointer-events:none}");
|
|
114
|
+
var actionable_area_slot_module_default = { "actionable-area-slot": "_0a2b470abcf47e5b__actionable-area-slot" };
|
|
101
115
|
// packages/grid/src/dashboard-grid/grid-item.module.css
|
|
102
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("33e05f5e81", ".d8e79c99afd8bca5__item{position:relative}._88155a7e5db75630__item-content{height:100%;position:relative}._09df60d54139626b__is-resizing{overflow:visible;z-index:1}._09df60d54139626b__is-resizing ._88155a7e5db75630__item-content{overflow:visible;position:relative;z-index:2}._5e7dab4e781593a1__is-dragging{pointer-events:none}[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{border-radius:var(--wp-grid-placeholder-radius,0)}@media not (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{animation:_41089f4f79a6ecfb__wp-grid-item-placeholder-in 0ms linear var(--wpds-motion-duration-sm,.1s) forwards;opacity:1;outline-color:transparent;outline-style:var(--wp-grid-placeholder-outline-style,dashed);outline-width:0}@keyframes _41089f4f79a6ecfb__wp-grid-item-placeholder-in{to{opacity:var(--wp-grid-placeholder-opacity,.4);outline-color:var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));outline-width:var(--wpds-border-width-sm,2px)}}}@media (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{opacity:var(--wp-grid-placeholder-opacity,.4);outline:var(--wpds-border-width-sm,2px) var(--wp-grid-placeholder-outline-style,dashed) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)))}}@media (forced-colors:active){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{--wp-grid-placeholder-outline-color:Highlight}}.c99f267fd053e634__preview-overlay{background:transparent;border:var(--wpds-border-width-sm,2px) var(--wp-grid-resize-preview-outline-style,solid) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));border-radius:var(--wp-grid-placeholder-radius,0);box-sizing:border-box;inset-inline-start:0;pointer-events:none;position:absolute;top:0;z-index:0}@media (forced-colors:active){.c99f267fd053e634__preview-overlay{border-color:Highlight}}");
|
|
117
|
+
var grid_item_module_default = {
|
|
118
|
+
"item": "d8e79c99afd8bca5__item",
|
|
119
|
+
"item-content": "_88155a7e5db75630__item-content",
|
|
120
|
+
"is-resizing": "_09df60d54139626b__is-resizing",
|
|
121
|
+
"is-dragging": "_5e7dab4e781593a1__is-dragging",
|
|
122
|
+
"wp-grid-item-placeholder-in": "_41089f4f79a6ecfb__wp-grid-item-placeholder-in",
|
|
123
|
+
"preview-overlay": "c99f267fd053e634__preview-overlay"
|
|
124
|
+
};
|
|
107
125
|
// packages/grid/src/dashboard-grid/grid-item.tsx
|
|
108
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
109
126
|
function getItemCursor(disabled, interacting) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (interacting) {
|
|
114
|
-
return void 0;
|
|
115
|
-
}
|
|
116
|
-
return "grab";
|
|
127
|
+
if (disabled) return "default";
|
|
128
|
+
if (interacting) return;
|
|
129
|
+
return "grab";
|
|
117
130
|
}
|
|
118
|
-
function GridItem({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
height: verticalResizable ? initialContentSize.height + resizeDelta.height : void 0
|
|
208
|
-
} : void 0;
|
|
209
|
-
const previewOverlay = resizeSnapPreview ? /* @__PURE__ */ jsx(SnapPreviewOverlay, { snap: resizeSnapPreview }) : null;
|
|
210
|
-
return /* @__PURE__ */ jsxs(
|
|
211
|
-
"div",
|
|
212
|
-
{
|
|
213
|
-
ref: mergedRef,
|
|
214
|
-
className: itemClassName,
|
|
215
|
-
style,
|
|
216
|
-
...{ [GRID_ITEM_DATA_KEY]: item.key },
|
|
217
|
-
"data-wp-grid-item-resizing": isResizing || void 0,
|
|
218
|
-
children: [
|
|
219
|
-
actionableArea ? /* @__PURE__ */ jsx(
|
|
220
|
-
"div",
|
|
221
|
-
{
|
|
222
|
-
className: actionable_area_slot_default["actionable-area-slot"],
|
|
223
|
-
children: /* @__PURE__ */ jsx(
|
|
224
|
-
"div",
|
|
225
|
-
{
|
|
226
|
-
style: { display: "contents" },
|
|
227
|
-
inert: inertValue(dragging),
|
|
228
|
-
children: actionableArea
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
}
|
|
232
|
-
) : null,
|
|
233
|
-
/* @__PURE__ */ jsxs(
|
|
234
|
-
"div",
|
|
235
|
-
{
|
|
236
|
-
ref: setActivatorNodeRef,
|
|
237
|
-
...attributes,
|
|
238
|
-
...listeners,
|
|
239
|
-
style: {
|
|
240
|
-
height: "100%",
|
|
241
|
-
cursor: getItemCursor(dragDisabled, interacting)
|
|
242
|
-
},
|
|
243
|
-
children: [
|
|
244
|
-
/* @__PURE__ */ jsxs(
|
|
245
|
-
"div",
|
|
246
|
-
{
|
|
247
|
-
ref: contentMergedRef,
|
|
248
|
-
className: grid_item_default["item-content"],
|
|
249
|
-
style: continuousContentStyle,
|
|
250
|
-
children: [
|
|
251
|
-
children,
|
|
252
|
-
!resizeDisabled && /* @__PURE__ */ jsx(
|
|
253
|
-
ResizeHandle,
|
|
254
|
-
{
|
|
255
|
-
itemId: item.key,
|
|
256
|
-
verticalResizable,
|
|
257
|
-
onResize: handleResize,
|
|
258
|
-
onResizeEnd: handleResizeEnd,
|
|
259
|
-
renderResizeHandle
|
|
260
|
-
}
|
|
261
|
-
)
|
|
262
|
-
]
|
|
263
|
-
}
|
|
264
|
-
),
|
|
265
|
-
previewOverlay
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
);
|
|
131
|
+
function GridItem({ item, maxColumns, disabled = false, draggable = true, resizable = true, verticalResizable = true, interacting = false, dragging = false, children, actionableArea = null, onResize, onResizeEnd, resizeSnapPreview = null, minResizeWidthPx, minResizeHeightPx, maxResizeWidthPx, maxResizeHeightPx, renderResizeHandle }) {
|
|
132
|
+
const [resizeDelta, setResizeDelta] = useState(null);
|
|
133
|
+
const [initialContentSize, setInitialContentSize] = useState(null);
|
|
134
|
+
const itemRef = useRef(null);
|
|
135
|
+
const contentRef = useRef(null);
|
|
136
|
+
const dragDisabled = disabled || !draggable;
|
|
137
|
+
const resizeDisabled = disabled || !resizable;
|
|
138
|
+
const { attributes, listeners, setNodeRef, setActivatorNodeRef, isDragging } = useSortable({
|
|
139
|
+
id: item.key,
|
|
140
|
+
disabled: dragDisabled
|
|
141
|
+
});
|
|
142
|
+
const mergedRef = useMergeRefs([itemRef, setNodeRef]);
|
|
143
|
+
const contentMergedRef = useMergeRefs([contentRef]);
|
|
144
|
+
const style = {
|
|
145
|
+
gridColumnEnd: `span ${item.width === "full" ? maxColumns : Math.min(typeof item.width === "number" ? item.width : 1, maxColumns)}`,
|
|
146
|
+
gridRowEnd: `span ${item.height || 1}`
|
|
147
|
+
};
|
|
148
|
+
const isResizing = resizeDelta !== null;
|
|
149
|
+
const itemClassName = clsx(grid_item_module_default.item, isDragging && grid_item_module_default["is-dragging"], isResizing && grid_item_module_default["is-resizing"]);
|
|
150
|
+
const handleResize = (delta) => {
|
|
151
|
+
const contentNode = contentRef.current;
|
|
152
|
+
let baselineSize = initialContentSize;
|
|
153
|
+
if (contentNode && !baselineSize) {
|
|
154
|
+
const { width, height } = contentNode.getBoundingClientRect();
|
|
155
|
+
baselineSize = {
|
|
156
|
+
width,
|
|
157
|
+
height
|
|
158
|
+
};
|
|
159
|
+
setInitialContentSize(baselineSize);
|
|
160
|
+
}
|
|
161
|
+
let clamped = {
|
|
162
|
+
width: delta.width,
|
|
163
|
+
height: verticalResizable ? delta.height : 0
|
|
164
|
+
};
|
|
165
|
+
if (baselineSize) clamped = clampResizeDelta(clamped, baselineSize, {
|
|
166
|
+
width: minResizeWidthPx,
|
|
167
|
+
height: verticalResizable ? minResizeHeightPx : void 0
|
|
168
|
+
}, {
|
|
169
|
+
width: maxResizeWidthPx,
|
|
170
|
+
height: verticalResizable ? maxResizeHeightPx : void 0
|
|
171
|
+
});
|
|
172
|
+
setResizeDelta(clamped);
|
|
173
|
+
onResize(item.key, clamped);
|
|
174
|
+
};
|
|
175
|
+
const handleResizeEnd = () => {
|
|
176
|
+
setResizeDelta(null);
|
|
177
|
+
setInitialContentSize(null);
|
|
178
|
+
onResizeEnd();
|
|
179
|
+
};
|
|
180
|
+
const continuousContentStyle = resizeDelta && initialContentSize ? {
|
|
181
|
+
width: initialContentSize.width + resizeDelta.width,
|
|
182
|
+
height: verticalResizable ? initialContentSize.height + resizeDelta.height : void 0
|
|
183
|
+
} : void 0;
|
|
184
|
+
const previewOverlay = resizeSnapPreview ? /* @__PURE__ */ jsx(SnapPreviewOverlay, { snap: resizeSnapPreview }) : null;
|
|
185
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
186
|
+
ref: mergedRef,
|
|
187
|
+
className: itemClassName,
|
|
188
|
+
style,
|
|
189
|
+
[GRID_ITEM_DATA_KEY]: item.key,
|
|
190
|
+
"data-wp-grid-item-resizing": isResizing || void 0,
|
|
191
|
+
children: [actionableArea ? /* @__PURE__ */ jsx("div", {
|
|
192
|
+
className: actionable_area_slot_module_default["actionable-area-slot"],
|
|
193
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
194
|
+
style: { display: "contents" },
|
|
195
|
+
inert: inertValue(dragging),
|
|
196
|
+
children: actionableArea
|
|
197
|
+
})
|
|
198
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
199
|
+
ref: setActivatorNodeRef,
|
|
200
|
+
...dragDisabled ? {} : attributes,
|
|
201
|
+
...listeners,
|
|
202
|
+
style: {
|
|
203
|
+
height: "100%",
|
|
204
|
+
cursor: getItemCursor(dragDisabled, interacting)
|
|
205
|
+
},
|
|
206
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
207
|
+
ref: contentMergedRef,
|
|
208
|
+
className: grid_item_module_default["item-content"],
|
|
209
|
+
style: continuousContentStyle,
|
|
210
|
+
children: [children, !resizeDisabled && /* @__PURE__ */ jsx(ResizeHandle, {
|
|
211
|
+
itemId: item.key,
|
|
212
|
+
verticalResizable,
|
|
213
|
+
onResize: handleResize,
|
|
214
|
+
onResizeEnd: handleResizeEnd,
|
|
215
|
+
renderResizeHandle
|
|
216
|
+
})]
|
|
217
|
+
}), previewOverlay]
|
|
218
|
+
})]
|
|
219
|
+
});
|
|
272
220
|
}
|
|
273
221
|
function SnapPreviewOverlay({ snap }) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
);
|
|
222
|
+
return /* @__PURE__ */ jsx("div", {
|
|
223
|
+
className: grid_item_module_default["preview-overlay"],
|
|
224
|
+
style: {
|
|
225
|
+
width: snap.widthPx,
|
|
226
|
+
height: snap.heightPx ?? "100%"
|
|
227
|
+
}
|
|
228
|
+
});
|
|
284
229
|
}
|
|
285
|
-
export {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
//# sourceMappingURL=grid-item.mjs.map
|
|
230
|
+
export { GridItem };
|
|
231
|
+
|
|
232
|
+
//# sourceMappingURL=grid-item.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dashboard-grid/grid-item.tsx", "../../../style-runtime/src/index.ts", "../../src/shared/actionable-area-slot.module.css", "../../src/dashboard-grid/grid-item.module.css"],
|
|
4
|
-
"sourcesContent": ["import { useSortable } from '@dnd-kit/sortable';\nimport clsx from 'clsx';\nimport { useState, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { inertValue } from '@wordpress/react-inert-value';\nimport actionableAreaStyles from '../shared/actionable-area-slot.module.css';\nimport { GRID_ITEM_DATA_KEY } from '../shared/grid-item-key';\nimport ResizeHandle from '../shared/resize-handle';\nimport { clampResizeDelta, type ResizeSnapSize } from '../shared/resize-snap';\nimport type { ResizeDelta } from '../shared/types';\nimport type { GridItemProps } from './types';\nimport styles from './grid-item.module.css';\n\nfunction getItemCursor(\n\tdisabled: boolean,\n\tinteracting: boolean\n): React.CSSProperties[ 'cursor' ] {\n\tif ( disabled ) {\n\t\treturn 'default';\n\t}\n\n\tif ( interacting ) {\n\t\treturn undefined;\n\t}\n\n\treturn 'grab';\n}\n\nexport function GridItem( {\n\titem,\n\tmaxColumns,\n\tdisabled = false,\n\tdraggable = true,\n\tresizable = true,\n\tverticalResizable = true,\n\tinteracting = false,\n\tdragging = false,\n\tchildren,\n\tactionableArea = null,\n\tonResize,\n\tonResizeEnd,\n\tresizeSnapPreview = null,\n\tminResizeWidthPx,\n\tminResizeHeightPx,\n\tmaxResizeWidthPx,\n\tmaxResizeHeightPx,\n\trenderResizeHandle,\n}: GridItemProps ) {\n\tconst [ resizeDelta, setResizeDelta ] = useState< ResizeDelta | null >(\n\t\tnull\n\t);\n\tconst [ initialContentSize, setInitialContentSize ] = useState< {\n\t\twidth: number;\n\t\theight: number;\n\t} | null >( null );\n\tconst itemRef = useRef< HTMLDivElement >( null );\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst dragDisabled = disabled || ! draggable;\n\tconst resizeDisabled = disabled || ! resizable;\n\tconst {\n\t\tattributes,\n\t\tlisteners,\n\t\tsetNodeRef,\n\t\tsetActivatorNodeRef,\n\t\tisDragging,\n\t} = useSortable( {\n\t\tid: item.key,\n\t\tdisabled: dragDisabled,\n\t} );\n\tconst mergedRef = useMergeRefs( [ itemRef, setNodeRef ] );\n\tconst contentMergedRef = useMergeRefs( [ contentRef ] );\n\t/*\n\t * With `<DragOverlay>` handling the cursor-following clone, the\n\t * sortable item stays put in its grid cell and acts as a\n\t * placeholder. No `transform` is applied here — applying one\n\t * would double-move the placeholder alongside the overlay.\n\t */\n\tconst style = {\n\t\tgridColumnEnd: `span ${\n\t\t\titem.width === 'full'\n\t\t\t\t? maxColumns\n\t\t\t\t: Math.min(\n\t\t\t\t\t\ttypeof item.width === 'number' ? item.width : 1,\n\t\t\t\t\t\tmaxColumns\n\t\t\t\t\t)\n\t\t}`,\n\t\tgridRowEnd: `span ${ item.height || 1 }`,\n\t};\n\n\tconst isResizing = resizeDelta !== null;\n\tconst itemClassName = clsx(\n\t\tstyles.item,\n\t\tisDragging && styles[ 'is-dragging' ],\n\t\tisResizing && styles[ 'is-resizing' ]\n\t);\n\n\tconst handleResize = ( delta: ResizeDelta ) => {\n\t\tconst contentNode = contentRef.current;\n\t\tlet baselineSize = initialContentSize;\n\t\tif ( contentNode && ! baselineSize ) {\n\t\t\tconst { width, height } = contentNode.getBoundingClientRect();\n\t\t\tbaselineSize = { width, height };\n\t\t\tsetInitialContentSize( baselineSize );\n\t\t}\n\t\tlet clamped: ResizeDelta = {\n\t\t\twidth: delta.width,\n\t\t\theight: verticalResizable ? delta.height : 0,\n\t\t};\n\t\tif ( baselineSize ) {\n\t\t\tclamped = clampResizeDelta(\n\t\t\t\tclamped,\n\t\t\t\tbaselineSize,\n\t\t\t\t{\n\t\t\t\t\twidth: minResizeWidthPx,\n\t\t\t\t\theight: verticalResizable ? minResizeHeightPx : undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\twidth: maxResizeWidthPx,\n\t\t\t\t\theight: verticalResizable ? maxResizeHeightPx : undefined,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\tsetResizeDelta( clamped );\n\t\tonResize( item.key, clamped );\n\t};\n\n\tconst handleResizeEnd = () => {\n\t\tsetResizeDelta( null );\n\t\tsetInitialContentSize( null );\n\t\tonResizeEnd();\n\t};\n\n\tconst continuousContentStyle: React.CSSProperties | undefined =\n\t\tresizeDelta && initialContentSize\n\t\t\t? {\n\t\t\t\t\twidth: initialContentSize.width + resizeDelta.width,\n\t\t\t\t\theight: verticalResizable\n\t\t\t\t\t\t? initialContentSize.height + resizeDelta.height\n\t\t\t\t\t\t: undefined,\n\t\t\t\t}\n\t\t\t: undefined;\n\n\tconst previewOverlay = resizeSnapPreview ? (\n\t\t<SnapPreviewOverlay snap={ resizeSnapPreview } />\n\t) : null;\n\n\treturn (\n\t\t<div\n\t\t\tref={ mergedRef }\n\t\t\tclassName={ itemClassName }\n\t\t\tstyle={ style }\n\t\t\t{ ...{ [ GRID_ITEM_DATA_KEY ]: item.key } }\n\t\t\tdata-wp-grid-item-resizing={ isResizing || undefined }\n\t\t>\n\t\t\t{ actionableArea ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ actionableAreaStyles[ 'actionable-area-slot' ] }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={ { display: 'contents' } }\n\t\t\t\t\t\tinert={ inertValue( dragging ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ actionableArea }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null }\n\n\t\t\t<div\n\t\t\t\tref={ setActivatorNodeRef }\n\t\t\t\t{ ...attributes }\n\t\t\t\t{ ...listeners }\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tcursor: getItemCursor( dragDisabled, interacting ),\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={ contentMergedRef }\n\t\t\t\t\tclassName={ styles[ 'item-content' ] }\n\t\t\t\t\tstyle={ continuousContentStyle }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t\t{ ! resizeDisabled && (\n\t\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\t\titemId={ item.key }\n\t\t\t\t\t\t\tverticalResizable={ verticalResizable }\n\t\t\t\t\t\t\tonResize={ handleResize }\n\t\t\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\t\t\trenderResizeHandle={ renderResizeHandle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ previewOverlay }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction SnapPreviewOverlay( { snap }: { snap: ResizeSnapSize } ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ styles[ 'preview-overlay' ] }\n\t\t\tstyle={ {\n\t\t\t\twidth: snap.widthPx,\n\t\t\t\theight: snap.heightPx ?? '100%',\n\t\t\t} }\n\t\t/>\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(\"ac1094954c\", \"._1c54fe8165d3023e__actionable-area-slot{opacity:1}@media (prefers-reduced-motion:no-preference){._1c54fe8165d3023e__actionable-area-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-resizing] ._1c54fe8165d3023e__actionable-area-slot{opacity:0;pointer-events:none}\");\n}\nexport default {\"actionable-area-slot\":\"_1c54fe8165d3023e__actionable-area-slot\"};\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"62860ded21\", \"._5d1abcb332a18701__item{position:relative}._54de57c12d3ce67e__item-content{height:100%;position:relative}._3e086aa073b9bbd9__is-resizing{overflow:visible;z-index:1}._3e086aa073b9bbd9__is-resizing ._54de57c12d3ce67e__item-content{overflow:visible;position:relative;z-index:2}._81d4e1a6c979f1e4__is-dragging{pointer-events:none}[data-wp-grid-dragging] ._81d4e1a6c979f1e4__is-dragging{border-radius:var(--wp-grid-placeholder-radius,0)}@media not (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._81d4e1a6c979f1e4__is-dragging{animation:_0447be8a7068a873__wp-grid-item-placeholder-in 0ms linear var(--wpds-motion-duration-sm,.1s) forwards;opacity:1;outline-color:transparent;outline-style:var(--wp-grid-placeholder-outline-style,dashed);outline-width:0}@keyframes _0447be8a7068a873__wp-grid-item-placeholder-in{to{opacity:var(--wp-grid-placeholder-opacity,.4);outline-color:var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));outline-width:var(--wpds-border-width-sm,2px)}}}@media (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._81d4e1a6c979f1e4__is-dragging{opacity:var(--wp-grid-placeholder-opacity,.4);outline:var(--wpds-border-width-sm,2px) var(--wp-grid-placeholder-outline-style,dashed) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)))}}@media (forced-colors:active){[data-wp-grid-dragging] ._81d4e1a6c979f1e4__is-dragging{--wp-grid-placeholder-outline-color:Highlight}}._2028fc095dbc5cb2__preview-overlay{background:transparent;border:var(--wpds-border-width-sm,2px) var(--wp-grid-resize-preview-outline-style,solid) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));border-radius:var(--wp-grid-placeholder-radius,0);box-sizing:border-box;inset-inline-start:0;pointer-events:none;position:absolute;top:0;z-index:0}@media (forced-colors:active){._2028fc095dbc5cb2__preview-overlay{border-color:Highlight}}\");\n}\nexport default {\"item\":\"_5d1abcb332a18701__item\",\"item-content\":\"_54de57c12d3ce67e__item-content\",\"is-resizing\":\"_3e086aa073b9bbd9__is-resizing\",\"is-dragging\":\"_81d4e1a6c979f1e4__is-dragging\",\"wp-grid-item-placeholder-in\":\"_0447be8a7068a873__wp-grid-item-placeholder-in\",\"preview-overlay\":\"_2028fc095dbc5cb2__preview-overlay\"};\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,mBAAmB;AAC5B,OAAO,UAAU;AACjB,SAAS,UAAU,cAAc;AACjC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;;;ACM3B,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,M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AAQ;AAAA,QACP,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK,YAAY;AAAA,MAC1B;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"grid-item.mjs","names":["styles","actionableAreaStyles"],"sources":["../../../style-runtime/src/index.ts","../../src/shared/actionable-area-slot.module.css","../../src/dashboard-grid/grid-item.module.css","../../src/dashboard-grid/grid-item.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(\"36a7a084ce\", \"._0a2b470abcf47e5b__actionable-area-slot{opacity:1}@media (prefers-reduced-motion:no-preference){._0a2b470abcf47e5b__actionable-area-slot{transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}[data-wp-grid-resizing] ._0a2b470abcf47e5b__actionable-area-slot{opacity:0;pointer-events:none}\");\n}\nexport default {\"actionable-area-slot\":\"_0a2b470abcf47e5b__actionable-area-slot\"};\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"33e05f5e81\", \".d8e79c99afd8bca5__item{position:relative}._88155a7e5db75630__item-content{height:100%;position:relative}._09df60d54139626b__is-resizing{overflow:visible;z-index:1}._09df60d54139626b__is-resizing ._88155a7e5db75630__item-content{overflow:visible;position:relative;z-index:2}._5e7dab4e781593a1__is-dragging{pointer-events:none}[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{border-radius:var(--wp-grid-placeholder-radius,0)}@media not (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{animation:_41089f4f79a6ecfb__wp-grid-item-placeholder-in 0ms linear var(--wpds-motion-duration-sm,.1s) forwards;opacity:1;outline-color:transparent;outline-style:var(--wp-grid-placeholder-outline-style,dashed);outline-width:0}@keyframes _41089f4f79a6ecfb__wp-grid-item-placeholder-in{to{opacity:var(--wp-grid-placeholder-opacity,.4);outline-color:var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));outline-width:var(--wpds-border-width-sm,2px)}}}@media (prefers-reduced-motion:reduce){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{opacity:var(--wp-grid-placeholder-opacity,.4);outline:var(--wpds-border-width-sm,2px) var(--wp-grid-placeholder-outline-style,dashed) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)))}}@media (forced-colors:active){[data-wp-grid-dragging] ._5e7dab4e781593a1__is-dragging{--wp-grid-placeholder-outline-color:Highlight}}.c99f267fd053e634__preview-overlay{background:transparent;border:var(--wpds-border-width-sm,2px) var(--wp-grid-resize-preview-outline-style,solid) var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));border-radius:var(--wp-grid-placeholder-radius,0);box-sizing:border-box;inset-inline-start:0;pointer-events:none;position:absolute;top:0;z-index:0}@media (forced-colors:active){.c99f267fd053e634__preview-overlay{border-color:Highlight}}\");\n}\nexport default {\"item\":\"d8e79c99afd8bca5__item\",\"item-content\":\"_88155a7e5db75630__item-content\",\"is-resizing\":\"_09df60d54139626b__is-resizing\",\"is-dragging\":\"_5e7dab4e781593a1__is-dragging\",\"wp-grid-item-placeholder-in\":\"_41089f4f79a6ecfb__wp-grid-item-placeholder-in\",\"preview-overlay\":\"c99f267fd053e634__preview-overlay\"};\n","import { useSortable } from '@dnd-kit/sortable';\nimport clsx from 'clsx';\nimport { useState, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { inertValue } from '@wordpress/react-inert-value';\nimport actionableAreaStyles from '../shared/actionable-area-slot.module.css';\nimport { GRID_ITEM_DATA_KEY } from '../shared/grid-item-key';\nimport ResizeHandle from '../shared/resize-handle';\nimport { clampResizeDelta, type ResizeSnapSize } from '../shared/resize-snap';\nimport type { ResizeDelta } from '../shared/types';\nimport type { GridItemProps } from './types';\nimport styles from './grid-item.module.css';\n\nfunction getItemCursor(\n\tdisabled: boolean,\n\tinteracting: boolean\n): React.CSSProperties[ 'cursor' ] {\n\tif ( disabled ) {\n\t\treturn 'default';\n\t}\n\n\tif ( interacting ) {\n\t\treturn undefined;\n\t}\n\n\treturn 'grab';\n}\n\nexport function GridItem( {\n\titem,\n\tmaxColumns,\n\tdisabled = false,\n\tdraggable = true,\n\tresizable = true,\n\tverticalResizable = true,\n\tinteracting = false,\n\tdragging = false,\n\tchildren,\n\tactionableArea = null,\n\tonResize,\n\tonResizeEnd,\n\tresizeSnapPreview = null,\n\tminResizeWidthPx,\n\tminResizeHeightPx,\n\tmaxResizeWidthPx,\n\tmaxResizeHeightPx,\n\trenderResizeHandle,\n}: GridItemProps ) {\n\tconst [ resizeDelta, setResizeDelta ] = useState< ResizeDelta | null >(\n\t\tnull\n\t);\n\tconst [ initialContentSize, setInitialContentSize ] = useState< {\n\t\twidth: number;\n\t\theight: number;\n\t} | null >( null );\n\tconst itemRef = useRef< HTMLDivElement >( null );\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst dragDisabled = disabled || ! draggable;\n\tconst resizeDisabled = disabled || ! resizable;\n\tconst {\n\t\tattributes,\n\t\tlisteners,\n\t\tsetNodeRef,\n\t\tsetActivatorNodeRef,\n\t\tisDragging,\n\t} = useSortable( {\n\t\tid: item.key,\n\t\tdisabled: dragDisabled,\n\t} );\n\tconst mergedRef = useMergeRefs( [ itemRef, setNodeRef ] );\n\tconst contentMergedRef = useMergeRefs( [ contentRef ] );\n\t/*\n\t * With `<DragOverlay>` handling the cursor-following clone, the\n\t * sortable item stays put in its grid cell and acts as a\n\t * placeholder. No `transform` is applied here — applying one\n\t * would double-move the placeholder alongside the overlay.\n\t */\n\tconst style = {\n\t\tgridColumnEnd: `span ${\n\t\t\titem.width === 'full'\n\t\t\t\t? maxColumns\n\t\t\t\t: Math.min(\n\t\t\t\t\t\ttypeof item.width === 'number' ? item.width : 1,\n\t\t\t\t\t\tmaxColumns\n\t\t\t\t\t)\n\t\t}`,\n\t\tgridRowEnd: `span ${ item.height || 1 }`,\n\t};\n\n\tconst isResizing = resizeDelta !== null;\n\tconst itemClassName = clsx(\n\t\tstyles.item,\n\t\tisDragging && styles[ 'is-dragging' ],\n\t\tisResizing && styles[ 'is-resizing' ]\n\t);\n\n\tconst handleResize = ( delta: ResizeDelta ) => {\n\t\tconst contentNode = contentRef.current;\n\t\tlet baselineSize = initialContentSize;\n\t\tif ( contentNode && ! baselineSize ) {\n\t\t\tconst { width, height } = contentNode.getBoundingClientRect();\n\t\t\tbaselineSize = { width, height };\n\t\t\tsetInitialContentSize( baselineSize );\n\t\t}\n\t\tlet clamped: ResizeDelta = {\n\t\t\twidth: delta.width,\n\t\t\theight: verticalResizable ? delta.height : 0,\n\t\t};\n\t\tif ( baselineSize ) {\n\t\t\tclamped = clampResizeDelta(\n\t\t\t\tclamped,\n\t\t\t\tbaselineSize,\n\t\t\t\t{\n\t\t\t\t\twidth: minResizeWidthPx,\n\t\t\t\t\theight: verticalResizable ? minResizeHeightPx : undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\twidth: maxResizeWidthPx,\n\t\t\t\t\theight: verticalResizable ? maxResizeHeightPx : undefined,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\tsetResizeDelta( clamped );\n\t\tonResize( item.key, clamped );\n\t};\n\n\tconst handleResizeEnd = () => {\n\t\tsetResizeDelta( null );\n\t\tsetInitialContentSize( null );\n\t\tonResizeEnd();\n\t};\n\n\tconst continuousContentStyle: React.CSSProperties | undefined =\n\t\tresizeDelta && initialContentSize\n\t\t\t? {\n\t\t\t\t\twidth: initialContentSize.width + resizeDelta.width,\n\t\t\t\t\theight: verticalResizable\n\t\t\t\t\t\t? initialContentSize.height + resizeDelta.height\n\t\t\t\t\t\t: undefined,\n\t\t\t\t}\n\t\t\t: undefined;\n\n\tconst previewOverlay = resizeSnapPreview ? (\n\t\t<SnapPreviewOverlay snap={ resizeSnapPreview } />\n\t) : null;\n\n\treturn (\n\t\t<div\n\t\t\tref={ mergedRef }\n\t\t\tclassName={ itemClassName }\n\t\t\tstyle={ style }\n\t\t\t{ ...{ [ GRID_ITEM_DATA_KEY ]: item.key } }\n\t\t\tdata-wp-grid-item-resizing={ isResizing || undefined }\n\t\t>\n\t\t\t{ actionableArea ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ actionableAreaStyles[ 'actionable-area-slot' ] }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={ { display: 'contents' } }\n\t\t\t\t\t\tinert={ inertValue( dragging ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ actionableArea }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null }\n\n\t\t\t<div\n\t\t\t\tref={ setActivatorNodeRef }\n\t\t\t\t{ ...( dragDisabled ? {} : attributes ) }\n\t\t\t\t{ ...listeners }\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tcursor: getItemCursor( dragDisabled, interacting ),\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={ contentMergedRef }\n\t\t\t\t\tclassName={ styles[ 'item-content' ] }\n\t\t\t\t\tstyle={ continuousContentStyle }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t\t{ ! resizeDisabled && (\n\t\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\t\titemId={ item.key }\n\t\t\t\t\t\t\tverticalResizable={ verticalResizable }\n\t\t\t\t\t\t\tonResize={ handleResize }\n\t\t\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\t\t\trenderResizeHandle={ renderResizeHandle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ previewOverlay }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction SnapPreviewOverlay( { snap }: { snap: ResizeSnapSize } ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ styles[ 'preview-overlay' ] }\n\t\t\tstyle={ {\n\t\t\t\twidth: snap.widthPx,\n\t\t\t\theight: snap.heightPx ?? '100%',\n\t\t\t} }\n\t\t/>\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,0BA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