@bison-lab/payload-core 4.15.0 → 4.15.1
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/dist/admin.mjs +32 -5
- package/dist/admin.mjs.map +1 -1
- package/package.json +3 -3
package/dist/admin.mjs
CHANGED
|
@@ -4281,6 +4281,8 @@ const BlockLibraryField = (props) => {
|
|
|
4281
4281
|
const [shown, setShown] = useState("hero");
|
|
4282
4282
|
const [active, setActive] = useState(null);
|
|
4283
4283
|
const [landing, setLanding] = useState(null);
|
|
4284
|
+
const landingRef = useRef(null);
|
|
4285
|
+
landingRef.current = landing;
|
|
4284
4286
|
const gallery = useRef(null);
|
|
4285
4287
|
const openCategory = useCallback((id) => {
|
|
4286
4288
|
setOpen(id);
|
|
@@ -4310,7 +4312,10 @@ const BlockLibraryField = (props) => {
|
|
|
4310
4312
|
const root = gallery.current;
|
|
4311
4313
|
const resize = root && typeof ResizeObserver !== "undefined" ? new ResizeObserver(land) : null;
|
|
4312
4314
|
if (root) resize?.observe(root);
|
|
4313
|
-
const release = () =>
|
|
4315
|
+
const release = () => {
|
|
4316
|
+
landingRef.current = null;
|
|
4317
|
+
setLanding(null);
|
|
4318
|
+
};
|
|
4314
4319
|
const timer = window.setTimeout(release, LANDING_HOLD_MS);
|
|
4315
4320
|
const events = [
|
|
4316
4321
|
"wheel",
|
|
@@ -4340,10 +4345,22 @@ const BlockLibraryField = (props) => {
|
|
|
4340
4345
|
}];
|
|
4341
4346
|
const visible = groups.flatMap((group) => group.rows);
|
|
4342
4347
|
const visibleKey = visible.map((row) => row.slug).join(",");
|
|
4348
|
+
const inViewRef = useRef(/* @__PURE__ */ new Set());
|
|
4349
|
+
const visibleKeyRef = useRef("");
|
|
4350
|
+
visibleKeyRef.current = visibleKey;
|
|
4351
|
+
const pickInView = useCallback(() => {
|
|
4352
|
+
if (landingRef.current) return;
|
|
4353
|
+
const first = visibleKeyRef.current.split(",").find((slug) => inViewRef.current.has(slug));
|
|
4354
|
+
if (first) setActive(first);
|
|
4355
|
+
}, []);
|
|
4356
|
+
useEffect(() => {
|
|
4357
|
+
if (!landing) pickInView();
|
|
4358
|
+
}, [landing, pickInView]);
|
|
4343
4359
|
useEffect(() => {
|
|
4344
4360
|
const root = gallery.current;
|
|
4345
4361
|
if (!root || typeof IntersectionObserver === "undefined") return;
|
|
4346
4362
|
const inView = /* @__PURE__ */ new Set();
|
|
4363
|
+
inViewRef.current = inView;
|
|
4347
4364
|
const observer = new IntersectionObserver((entries) => {
|
|
4348
4365
|
for (const entry of entries) {
|
|
4349
4366
|
const slug = entry.target.dataset.blockCard;
|
|
@@ -4351,12 +4368,15 @@ const BlockLibraryField = (props) => {
|
|
|
4351
4368
|
if (entry.isIntersecting) inView.add(slug);
|
|
4352
4369
|
else inView.delete(slug);
|
|
4353
4370
|
}
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
}, { rootMargin: "0px 0px -55% 0px" });
|
|
4371
|
+
pickInView();
|
|
4372
|
+
}, { rootMargin: SCROLL_SPY_ROOT_MARGIN });
|
|
4357
4373
|
root.querySelectorAll("[data-block-card]").forEach((card) => observer.observe(card));
|
|
4358
4374
|
return () => observer.disconnect();
|
|
4359
|
-
}, [
|
|
4375
|
+
}, [
|
|
4376
|
+
visibleKey,
|
|
4377
|
+
searching,
|
|
4378
|
+
pickInView
|
|
4379
|
+
]);
|
|
4360
4380
|
const card = (row) => /* @__PURE__ */ jsx(LibraryCard, {
|
|
4361
4381
|
row,
|
|
4362
4382
|
write: loaded.some((entry) => entry.slug === row.slug) ? writeRow(row.slug) : null,
|
|
@@ -4396,6 +4416,13 @@ const BlockLibraryField = (props) => {
|
|
|
4396
4416
|
]
|
|
4397
4417
|
}) });
|
|
4398
4418
|
};
|
|
4419
|
+
/**
|
|
4420
|
+
* The scroll-spy's reading band: from 20% down the viewport to 45%. The top
|
|
4421
|
+
* margin keeps out a card whose last strip sits under Payload's sticky
|
|
4422
|
+
* document header, which otherwise wins as "first in view" after a
|
|
4423
|
+
* `#slug` landing scrolls the next card to the top (BIS-149).
|
|
4424
|
+
*/
|
|
4425
|
+
const SCROLL_SPY_ROOT_MARGIN = "-20% 0px -55% 0px";
|
|
4399
4426
|
/** How long a `#slug` landing holds its card in place while islands above it resize. */
|
|
4400
4427
|
const LANDING_HOLD_MS = 4e3;
|
|
4401
4428
|
/** The rail's categories in catalogue order, each listing its cards. */
|