@bison-lab/payload-core 4.15.1 → 4.16.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 +41 -31
- package/dist/admin.mjs +54 -17
- package/dist/admin.mjs.map +1 -1
- package/dist/block-library.d.mts +1 -1
- package/dist/block-thumbnails--AJzSdzJ.mjs +130 -0
- package/dist/block-thumbnails--AJzSdzJ.mjs.map +1 -0
- package/dist/block-thumbnails-cli.d.mts +1 -0
- package/dist/block-thumbnails-cli.mjs +121 -0
- package/dist/block-thumbnails-cli.mjs.map +1 -0
- package/dist/block-thumbnails.d.mts +74 -0
- package/dist/block-thumbnails.d.mts.map +1 -0
- package/dist/block-thumbnails.mjs +2 -0
- package/dist/{catalogue-CFXM1yAZ.d.mts → catalogue-DMoDgScN.d.mts} +6 -5
- package/dist/catalogue-DMoDgScN.d.mts.map +1 -0
- package/dist/{facet-field-_8bYI1i0.d.mts → facet-field-DKzRCYrh.d.mts} +1 -1
- package/dist/{facet-field-_8bYI1i0.d.mts.map → facet-field-DKzRCYrh.d.mts.map} +1 -1
- package/dist/index.d.mts +27 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +80 -21
- package/dist/index.mjs.map +1 -1
- package/dist/metadata.d.mts +1 -1
- package/dist/navigation.d.mts +1 -1
- package/dist/{preview-Vaa1KXJP.d.mts → preview-T5VFcS32.d.mts} +1 -1
- package/dist/{preview-Vaa1KXJP.d.mts.map → preview-T5VFcS32.d.mts.map} +1 -1
- package/dist/published-BjmUCpdY.mjs.map +1 -1
- package/dist/{published-FUgC5Mc8.d.mts → published-IX1-6JEa.d.mts} +1 -1
- package/dist/{published-FUgC5Mc8.d.mts.map → published-IX1-6JEa.d.mts.map} +1 -1
- package/dist/taxonomy.d.mts +1 -1
- package/dist/theme.d.mts +1 -1
- package/dist/{title-ImlifZ_6.d.mts → title-BvjHeRo5.d.mts} +1 -1
- package/dist/{title-ImlifZ_6.d.mts.map → title-BvjHeRo5.d.mts.map} +1 -1
- package/dist/{wireframe-BTocmmyY.mjs → wireframe-ApjwNWAN.mjs} +6 -1
- package/dist/{wireframe-BTocmmyY.mjs.map → wireframe-ApjwNWAN.mjs.map} +1 -1
- package/dist/wireframe-cli.mjs +5 -1
- package/dist/wireframe-cli.mjs.map +1 -1
- package/dist/wireframe.d.mts +5 -0
- package/dist/wireframe.d.mts.map +1 -1
- package/dist/wireframe.mjs +1 -1
- package/package.json +6 -1
- package/dist/catalogue-CFXM1yAZ.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Media list with `next/navigation`, which Payload's admin already loads); `@bison
|
|
|
19
19
|
Pin the plugin to the same version as `payload`; Payload releases them in
|
|
20
20
|
lockstep.
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Ten entry points, and why
|
|
23
23
|
|
|
24
24
|
| Import | Contents | Runs where |
|
|
25
25
|
| ---------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
@@ -29,7 +29,8 @@ lockstep.
|
|
|
29
29
|
| `@bison-lab/payload-core/navigation` | `getNavigation`, the Header and Footer slugs | Server. What a site header imports; it does not load the plugin or React. |
|
|
30
30
|
| `@bison-lab/payload-core/block-library` | `getSectionControls`, `sectionControlsFromLibrary`, `SectionControls`, the catalogue readers, the island height message | Server. What a page route and the Block Settings fold import; it does not load the plugin or React. |
|
|
31
31
|
| `@bison-lab/payload-core/taxonomy` | `facetField`, `FacetEntry` | Anywhere. What a block config imports to tag content from a taxonomy; no plugin, no React, so a browser bundle can take it (`@bison-lab/payload-blocks` main entry reaches the docs island and Storybook). |
|
|
32
|
-
| `@bison-lab/payload-core/
|
|
32
|
+
| `@bison-lab/payload-core/block-thumbnails` | `captureThumbnails`, `thumbnailCss`, `NEUTRAL_THEME`, `thumbnailVersion`; the `bison-block-thumbnails` bin | Node, beside Playwright. What a site's thumbnail script imports; no Payload, no React. |
|
|
33
|
+
| `@bison-lab/payload-core/wireframe` | Deprecated: the 4.15 wireframe generator and the `bison-wireframes` bin | Node. Kept for one release so a site's script keeps working; use `./block-thumbnails`. Goes in the next major. |
|
|
33
34
|
| `@bison-lab/payload-core/admin` | Theme fields, the Roles and Features matrices, the Block library field, Admin nav, the Users Roles checklist, and the FAQ Library list | Admin. Referenced by import-map string; `generate:importmap` writes it. |
|
|
34
35
|
| `@bison-lab/payload-core/react` | `BlockLibraryIsland`; `ThemePreview` (legacy; Theme has no preview pane) | Client. What a Block library preview route wraps its sample in. |
|
|
35
36
|
|
|
@@ -428,12 +429,18 @@ every catalogue block, in every collection and global, so all three agree:
|
|
|
428
429
|
Feature, Process, … like the Block library. Blocks outside the catalogue
|
|
429
430
|
(a Header's `megaMenu` and `navLink`) are left alone and go last, which
|
|
430
431
|
is also where Payload draws ungrouped blocks.
|
|
431
|
-
- **`admin.images.thumbnail`**: a
|
|
432
|
-
|
|
433
|
-
(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
432
|
+
- **`admin.images.thumbnail`**: a screenshot of the block's sample (generic
|
|
433
|
+
copy and photos from `@bison-lab/payload-blocks`) under a neutral slate
|
|
434
|
+
theme (BIS-151). The package ships one for each of its page blocks
|
|
435
|
+
(`block-library/thumbnails.generated.ts`, `resources` included) and
|
|
436
|
+
serves it from `GET /api/block-library/thumbnail/:slug`, a root endpoint
|
|
437
|
+
the plugin registers: signed-in users only, `image/jpeg`, cached for a
|
|
438
|
+
year behind a `?v=` that changes with the picture. The admin's client
|
|
439
|
+
config carries only that URL. A site extra passes its own `thumbnail`
|
|
440
|
+
URL on its `createBlockLibrary` entry (a file it serves, such as
|
|
441
|
+
`/block-thumbnails/ctaBand.jpg` from `public/`); it is kept in the
|
|
442
|
+
Global's server-only `custom`. A block config that already sets a
|
|
443
|
+
thumbnail or `imageURL` keeps it.
|
|
437
444
|
- **Larger cards**: one admin stylesheet (`BLOCK_DRAWER_CSS`, mounted as the
|
|
438
445
|
`BLOCK_DRAWER_STYLES` provider) lays the drawer out three across, two at
|
|
439
446
|
Payload's 1024px break, one at 768px, instead of Payload's six.
|
|
@@ -448,7 +455,7 @@ export default buildConfig({
|
|
|
448
455
|
globals: [
|
|
449
456
|
createBlockLibrary({
|
|
450
457
|
previewPath: (slug) => `/block-library/${slug}`,
|
|
451
|
-
blocks: [{ slug: "ctaBand", label: "CTA band", category: "cta", thumbnail:
|
|
458
|
+
blocks: [{ slug: "ctaBand", label: "CTA band", category: "cta", thumbnail: "/block-thumbnails/ctaBand.jpg" }],
|
|
452
459
|
}),
|
|
453
460
|
],
|
|
454
461
|
plugins: [blockDrawer()],
|
|
@@ -457,33 +464,36 @@ export default buildConfig({
|
|
|
457
464
|
|
|
458
465
|
Run `payload generate:importmap` once for the stylesheet provider.
|
|
459
466
|
|
|
460
|
-
**
|
|
461
|
-
opens each block's Block library preview in a headless browser at
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
when a layout changes. Run it from the site, which supplies Playwright:
|
|
467
|
+
**Screenshots** come from `bison-block-thumbnails`, a bin on this package
|
|
468
|
+
that opens each block's Block library preview in a headless browser at
|
|
469
|
+
1280px, lays the neutral theme over the site's (`thumbnailCss`: the
|
|
470
|
+
`NEUTRAL_THEME` tokens from `buildThemeCss`, a system font stack, no
|
|
471
|
+
motion, dev-server chrome hidden), centers the block in a 3:2 box, and
|
|
472
|
+
saves a 960 × 640 JPEG (`captureThumbnails`, from the `./block-thumbnails`
|
|
473
|
+
entry). Run it from the site, which supplies Playwright:
|
|
468
474
|
|
|
469
475
|
```sh
|
|
470
|
-
|
|
476
|
+
THUMBNAIL_EMAIL=… THUMBNAIL_PASSWORD=… pnpm exec bison-block-thumbnails \
|
|
471
477
|
--base http://localhost:3039 --slugs ctaBand,productMap \
|
|
472
|
-
--out
|
|
478
|
+
--out-dir public/block-thumbnails
|
|
473
479
|
```
|
|
474
480
|
|
|
475
|
-
The login (any user the preview route accepts) comes from the environment
|
|
476
|
-
`--
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
481
|
+
The login (any user the preview route accepts) comes from the environment
|
|
482
|
+
and is required unless `--no-login` names a public route. `--preview`
|
|
483
|
+
changes the route pattern (`/block-library/{slug}` by default; a site can
|
|
484
|
+
add a query, such as `?thumbnail=1`, to swap in generic stand-ins for data
|
|
485
|
+
its sample reads), and `--selector` the element that holds the sample
|
|
486
|
+
(`BlockLibraryIsland`'s by default). `--out-dir` writes `<slug>.jpg` files;
|
|
487
|
+
`--module` writes a TypeScript module of base64 JPEGs (`--export` names
|
|
488
|
+
the constant), which is how this package ships its own. A preview that
|
|
489
|
+
answers an error status, or renders nothing the selector matches, fails
|
|
490
|
+
the run and writes nothing, so a sign-in wall or a mistyped slug never
|
|
491
|
+
becomes a block's picture. Rerun it when a block's layout or sample
|
|
492
|
+
changes. To refresh the package's own, run it with `--module
|
|
493
|
+
src/block-library/thumbnails.generated.ts --export PACKAGE_THUMBNAILS`
|
|
494
|
+
against a site's preview route with this release's payload-blocks
|
|
495
|
+
installed; the `hero` alias reuses the sweep hero's picture, since no site
|
|
496
|
+
installs it.
|
|
487
497
|
|
|
488
498
|
### Section controls
|
|
489
499
|
|
package/dist/admin.mjs
CHANGED
|
@@ -4281,8 +4281,9 @@ 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
|
|
4285
|
-
|
|
4284
|
+
const [pinned, setPinned] = useState(null);
|
|
4285
|
+
const pinnedRef = useRef(null);
|
|
4286
|
+
pinnedRef.current = pinned;
|
|
4286
4287
|
const gallery = useRef(null);
|
|
4287
4288
|
const openCategory = useCallback((id) => {
|
|
4288
4289
|
setOpen(id);
|
|
@@ -4299,6 +4300,7 @@ const BlockLibraryField = (props) => {
|
|
|
4299
4300
|
setQuery("");
|
|
4300
4301
|
openCategory(category);
|
|
4301
4302
|
setActive(slug);
|
|
4303
|
+
setPinned(slug);
|
|
4302
4304
|
setLanding(slug);
|
|
4303
4305
|
};
|
|
4304
4306
|
land();
|
|
@@ -4312,25 +4314,16 @@ const BlockLibraryField = (props) => {
|
|
|
4312
4314
|
const root = gallery.current;
|
|
4313
4315
|
const resize = root && typeof ResizeObserver !== "undefined" ? new ResizeObserver(land) : null;
|
|
4314
4316
|
if (root) resize?.observe(root);
|
|
4315
|
-
const release = () =>
|
|
4316
|
-
landingRef.current = null;
|
|
4317
|
-
setLanding(null);
|
|
4318
|
-
};
|
|
4317
|
+
const release = () => setLanding(null);
|
|
4319
4318
|
const timer = window.setTimeout(release, LANDING_HOLD_MS);
|
|
4320
|
-
const
|
|
4321
|
-
"wheel",
|
|
4322
|
-
"touchstart",
|
|
4323
|
-
"keydown",
|
|
4324
|
-
"pointerdown"
|
|
4325
|
-
];
|
|
4326
|
-
for (const name of events) window.addEventListener(name, release, {
|
|
4319
|
+
for (const name of EDITOR_MOVES) window.addEventListener(name, release, {
|
|
4327
4320
|
once: true,
|
|
4328
4321
|
passive: true
|
|
4329
4322
|
});
|
|
4330
4323
|
return () => {
|
|
4331
4324
|
resize?.disconnect();
|
|
4332
4325
|
window.clearTimeout(timer);
|
|
4333
|
-
for (const name of
|
|
4326
|
+
for (const name of EDITOR_MOVES) window.removeEventListener(name, release);
|
|
4334
4327
|
};
|
|
4335
4328
|
}, [landing]);
|
|
4336
4329
|
const searching = query.trim().length > 0;
|
|
@@ -4349,13 +4342,48 @@ const BlockLibraryField = (props) => {
|
|
|
4349
4342
|
const visibleKeyRef = useRef("");
|
|
4350
4343
|
visibleKeyRef.current = visibleKey;
|
|
4351
4344
|
const pickInView = useCallback(() => {
|
|
4352
|
-
if (
|
|
4345
|
+
if (pinnedRef.current) return;
|
|
4353
4346
|
const first = visibleKeyRef.current.split(",").find((slug) => inViewRef.current.has(slug));
|
|
4354
4347
|
if (first) setActive(first);
|
|
4355
4348
|
}, []);
|
|
4356
4349
|
useEffect(() => {
|
|
4357
|
-
if (!
|
|
4358
|
-
|
|
4350
|
+
if (!pinned) return;
|
|
4351
|
+
const unpin = () => {
|
|
4352
|
+
pinnedRef.current = null;
|
|
4353
|
+
setPinned(null);
|
|
4354
|
+
pickInView();
|
|
4355
|
+
};
|
|
4356
|
+
const inside = (element, target) => Boolean(element && target instanceof Node && element.contains(target));
|
|
4357
|
+
const onMove = (event) => {
|
|
4358
|
+
if ((event.type === "pointerdown" || event.type === "touchstart") && inside(document.getElementById(pinned), event.target)) return;
|
|
4359
|
+
unpin();
|
|
4360
|
+
};
|
|
4361
|
+
for (const name of EDITOR_MOVES) window.addEventListener(name, onMove, { passive: true });
|
|
4362
|
+
let resizedAt = Number.NEGATIVE_INFINITY;
|
|
4363
|
+
const root = gallery.current;
|
|
4364
|
+
const resize = !landing && root && typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
4365
|
+
resizedAt = performance.now();
|
|
4366
|
+
}) : null;
|
|
4367
|
+
if (root) resize?.observe(root);
|
|
4368
|
+
const onScroll = (event) => {
|
|
4369
|
+
if (performance.now() - resizedAt < RESIZE_SCROLL_MS) return;
|
|
4370
|
+
if (event.target instanceof Element && event.target.closest(".bl-block-library__rail")) return;
|
|
4371
|
+
unpin();
|
|
4372
|
+
};
|
|
4373
|
+
if (!landing) document.addEventListener("scroll", onScroll, {
|
|
4374
|
+
capture: true,
|
|
4375
|
+
passive: true
|
|
4376
|
+
});
|
|
4377
|
+
return () => {
|
|
4378
|
+
for (const name of EDITOR_MOVES) window.removeEventListener(name, onMove);
|
|
4379
|
+
resize?.disconnect();
|
|
4380
|
+
if (!landing) document.removeEventListener("scroll", onScroll, { capture: true });
|
|
4381
|
+
};
|
|
4382
|
+
}, [
|
|
4383
|
+
pinned,
|
|
4384
|
+
landing,
|
|
4385
|
+
pickInView
|
|
4386
|
+
]);
|
|
4359
4387
|
useEffect(() => {
|
|
4360
4388
|
const root = gallery.current;
|
|
4361
4389
|
if (!root || typeof IntersectionObserver === "undefined") return;
|
|
@@ -4423,6 +4451,15 @@ const BlockLibraryField = (props) => {
|
|
|
4423
4451
|
* `#slug` landing scrolls the next card to the top (BIS-149).
|
|
4424
4452
|
*/
|
|
4425
4453
|
const SCROLL_SPY_ROOT_MARGIN = "-20% 0px -55% 0px";
|
|
4454
|
+
/** A scroll this soon after the gallery resized is the browser's, not the editor's. */
|
|
4455
|
+
const RESIZE_SCROLL_MS = 250;
|
|
4456
|
+
/** What counts as the editor taking over from a `#slug` landing. */
|
|
4457
|
+
const EDITOR_MOVES = [
|
|
4458
|
+
"wheel",
|
|
4459
|
+
"touchstart",
|
|
4460
|
+
"keydown",
|
|
4461
|
+
"pointerdown"
|
|
4462
|
+
];
|
|
4426
4463
|
/** How long a `#slug` landing holds its card in place while islands above it resize. */
|
|
4427
4464
|
const LANDING_HOLD_MS = 4e3;
|
|
4428
4465
|
/** The rail's categories in catalogue order, each listing its cards. */
|