@bison-lab/payload-blocks 3.11.0 → 3.21.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 +63 -40
- package/dist/admin.d.mts +5 -2
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +818 -5
- package/dist/admin.mjs.map +1 -1
- package/dist/header-CV7K-3yB.mjs +226 -0
- package/dist/header-CV7K-3yB.mjs.map +1 -0
- package/dist/index.d.mts +43 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +46 -5
- package/dist/index.mjs.map +1 -1
- package/dist/link-32261jXB.mjs +49 -0
- package/dist/link-32261jXB.mjs.map +1 -0
- package/dist/react.d.mts +52 -7
- package/dist/react.d.mts.map +1 -1
- package/dist/react.mjs +5 -145
- package/dist/react.mjs.map +1 -1
- package/dist/rich-text.d.mts +1 -1
- package/dist/rich-text.mjs +2 -1
- package/dist/rich-text.mjs.map +1 -1
- package/dist/{seam-CmLb3BSo.mjs → seam-Cz7oiQ5z.mjs} +2 -47
- package/dist/seam-Cz7oiQ5z.mjs.map +1 -0
- package/dist/{types-ODMRyOpH.d.mts → types-BurBx5me.d.mts} +15 -4
- package/dist/{types-ODMRyOpH.d.mts.map → types-BurBx5me.d.mts.map} +1 -1
- package/package.json +5 -2
- package/dist/link-CnwLtm47.mjs +0 -41
- package/dist/link-CnwLtm47.mjs.map +0 -1
- package/dist/seam-CmLb3BSo.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Payload site already has).
|
|
|
24
24
|
| `@bison-lab/payload-blocks` | Block configs, field builders, row types, `resolveMedia` | Node. This is what `payload.config.ts` imports, and it touches no React. |
|
|
25
25
|
| `@bison-lab/payload-blocks/react` | Renderers, `RenderBlocks`, the image and link seams, the rendering types | Client (`"use client"`). |
|
|
26
26
|
| `@bison-lab/payload-blocks/rich-text` | The `richText` renderer, `internalDocToHrefFrom`, and `richTextBlockRenderer()` to build one that resolves internal links | Client. Split out because it is the only thing that needs `@payloadcms/richtext-lexical`. |
|
|
27
|
-
| `@bison-lab/payload-blocks/admin` | `MinRowsArrayField` and `
|
|
27
|
+
| `@bison-lab/payload-blocks/admin` | `MinRowsArrayField`, `LinkField`, and `NavItemsField`, the admin fields the configs reference by path | Client, inside the Payload admin. Resolved through the site's import map, never imported by hand. |
|
|
28
28
|
|
|
29
29
|
The renderers are client components because the blocks they render are: every
|
|
30
30
|
`@bison-lab/ui` export is a client reference, and these blocks are interactive
|
|
@@ -337,60 +337,69 @@ stylesheet scans both packages:
|
|
|
337
337
|
## Wiring a header
|
|
338
338
|
|
|
339
339
|
Two more blocks build a header rather than a page: `megaMenuBlock` and
|
|
340
|
-
`LinkBlock`. They go in
|
|
341
|
-
|
|
342
|
-
the icon list are the site's — the CMS only ever offers approved values
|
|
340
|
+
`LinkBlock`. They go in `createNavigation({ blocks })`'s `header.items`.
|
|
341
|
+
`megaMenuBlock` is a factory because the featured-link variants and
|
|
342
|
+
the icon list are the site's — the CMS only ever offers approved values.
|
|
343
|
+
The items field uses `NAV_ITEMS_FIELD` (the kit editor) instead of
|
|
344
|
+
Payload's stock blocks UI:
|
|
343
345
|
|
|
344
346
|
```ts
|
|
347
|
+
import { createNavigation } from '@bison-lab/payload-core'
|
|
345
348
|
import { LinkBlock, megaMenuBlock } from '@bison-lab/payload-blocks'
|
|
346
349
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
LinkBlock,
|
|
362
|
-
],
|
|
363
|
-
},
|
|
364
|
-
],
|
|
365
|
-
}
|
|
350
|
+
globals: [
|
|
351
|
+
...createNavigation({
|
|
352
|
+
blocks: [
|
|
353
|
+
megaMenuBlock({
|
|
354
|
+
variants: [
|
|
355
|
+
{ label: 'Lumbar', value: 'lumbar' },
|
|
356
|
+
{ label: 'SI joint', value: 'si' },
|
|
357
|
+
],
|
|
358
|
+
icons: [{ label: 'Help', value: 'help' }],
|
|
359
|
+
}),
|
|
360
|
+
LinkBlock,
|
|
361
|
+
],
|
|
362
|
+
}),
|
|
363
|
+
]
|
|
366
364
|
```
|
|
367
365
|
|
|
368
|
-
Then `payload generate:types
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
366
|
+
Then `payload generate:types`, `payload generate:importmap`, and
|
|
367
|
+
`payload migrate:create`. Until the import map includes
|
|
368
|
+
`@bison-lab/payload-blocks/admin#NavItemsField`, the items field renders
|
|
369
|
+
as nothing, not the stock blocks UI.
|
|
370
|
+
|
|
371
|
+
An editor sees a rail of bar items (Link vs Mega type cards from
|
|
372
|
+
`@bison-lab/admin-ui`), destinations
|
|
373
|
+
through `LINK_FIELD`, a two-up column builder, and a sticky
|
|
374
|
+
`FloatingNavBlock` preview under the published theme. Advanced CSS
|
|
375
|
+
column widths stay on the schema so existing rows do not migrate; the
|
|
376
|
+
kit does not render them. The column widths, read as fractions, must add
|
|
377
|
+
up to 100%: the rule is the array's own `validate`, so the editor sees
|
|
378
|
+
"The columns add up to 75%. They need to add up to 100%." as they build,
|
|
379
|
+
and the global's publish refuses the same. Custom widths skip it. The
|
|
380
|
+
mega trigger's landing page is now the same `type` / `page` / `href`
|
|
381
|
+
picker as every other destination — a schema change, so sites run
|
|
382
|
+
`payload migrate:create`.
|
|
377
383
|
|
|
378
|
-
In the site header, one call turns the
|
|
379
|
-
|
|
384
|
+
In the site header, one call turns the fetched Header global into
|
|
385
|
+
`FloatingNavBlock` props. Looks come from chrome roles
|
|
386
|
+
(`megaMenuVariantsFromLooks`), not a list on Header:
|
|
380
387
|
|
|
381
388
|
```tsx
|
|
382
389
|
'use client'
|
|
383
|
-
import { FloatingNavBlock } from '@bison-lab/ui'
|
|
384
|
-
import {
|
|
390
|
+
import { FloatingNavBlock, megaMenuVariantsFromLooks } from '@bison-lab/ui'
|
|
391
|
+
import { headerFromNavigation } from '@bison-lab/payload-blocks/react'
|
|
385
392
|
import { usePathname } from 'next/navigation'
|
|
386
393
|
|
|
387
|
-
export function SiteHeader({
|
|
394
|
+
export function SiteHeader({ doc }: { doc: Navigation }) {
|
|
388
395
|
const pathname = usePathname()
|
|
389
396
|
return (
|
|
390
397
|
<FloatingNavBlock
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
398
|
+
{...headerFromNavigation(doc, {
|
|
399
|
+
looks: megaMenuVariantsFromLooks(['lumbar', 'si'], {
|
|
400
|
+
lumbar: <Marker region="lumbar" />,
|
|
401
|
+
si: <Marker region="si" />,
|
|
402
|
+
}),
|
|
394
403
|
icons: { help: <CircleHelp className="size-4" aria-hidden /> },
|
|
395
404
|
isActive: (href) => pathname.startsWith(href),
|
|
396
405
|
linkComponent: NextBlockLink,
|
|
@@ -401,6 +410,20 @@ export function SiteHeader({ items }: { items: Navigation['items'] }) {
|
|
|
401
410
|
}
|
|
402
411
|
```
|
|
403
412
|
|
|
413
|
+
`headerItemsFromBlocks` is still the items half, if a site is not ready
|
|
414
|
+
for the Settings fields.
|
|
415
|
+
|
|
416
|
+
## Navigation settings
|
|
417
|
+
|
|
418
|
+
Bar behaviour moved out of code and onto Header → Settings: `bar.hideOnScroll`,
|
|
419
|
+
`bar.viewport`, and `bar.defaultMaxWidth`. Live preview stays on Header
|
|
420
|
+
(the pane already points at the site's header route). The kit editor
|
|
421
|
+
holds the edited mega row open through `openItem` so an admin sees the
|
|
422
|
+
panel they are changing. Featured looks stay on the chrome-role registry
|
|
423
|
+
(BIS-85 / SPI-89) — Header has no `variants` array. A site without the
|
|
424
|
+
consume bump (SPI-99) never sees the Settings tab. After this schema
|
|
425
|
+
change run `payload generate:types` and `payload migrate:create`.
|
|
426
|
+
|
|
404
427
|
`MegaMenuBlockRenderer` renders one panel on its own, which is what a live
|
|
405
428
|
preview of the row wants; it is not a page block and has no place in the
|
|
406
429
|
registry. A row with no columns, or whose columns hold no complete links,
|
package/dist/admin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { ArrayFieldClientComponent, RowFieldClientComponent } from "payload";
|
|
2
|
+
import { ArrayFieldClientComponent, BlocksFieldClientComponent, RowFieldClientComponent } from "payload";
|
|
3
3
|
|
|
4
4
|
//#region src/admin/link-field.d.ts
|
|
5
5
|
declare const LinkField: RowFieldClientComponent;
|
|
@@ -26,5 +26,8 @@ declare const LinkField: RowFieldClientComponent;
|
|
|
26
26
|
*/
|
|
27
27
|
declare const MinRowsArrayField: ArrayFieldClientComponent;
|
|
28
28
|
//#endregion
|
|
29
|
-
|
|
29
|
+
//#region src/admin/nav-items-field.d.ts
|
|
30
|
+
declare const NavItemsField: BlocksFieldClientComponent;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { LinkField, MinRowsArrayField, NavItemsField };
|
|
30
33
|
//# sourceMappingURL=admin.d.mts.map
|
package/dist/admin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/link-field.tsx","../src/admin/min-rows-array-field.tsx"],"mappings":";;;;cAuEa,SAAA,EAAW,uBAAA;;;;;AAAxB;;;;;;;;AChDA
|
|
1
|
+
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/link-field.tsx","../src/admin/min-rows-array-field.tsx","../src/admin/nav-items-field.tsx"],"mappings":";;;;cAuEa,SAAA,EAAW,uBAAA;;;;;AAAxB;;;;;;;;AChDA;;;;;;;;ACqKA;cDrKa,iBAAA,EAAmB,yBAAA;;;cCqKnB,aAAA,EAAe,0BAAA"}
|