@bison-lab/payload-blocks 3.5.0 → 3.20.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 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 `LinkField`, the admin fields the configs reference by path | Client, inside the Payload admin. Resolved through the site's import map, never imported by hand. |
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
@@ -110,6 +110,22 @@ for `type: external`, and `required` binds whichever is active. A site's own
110
110
  block takes the same field through `linkFields()` or `linkField()`, and can
111
111
  point it at another collection with `pagesCollection`.
112
112
 
113
+ `lookField()` and `colorTokenField()` read the published Theme. Options are
114
+ the scales Color Settings offers page editors (Primary, Secondary, Accent,
115
+ Highlight, plus every custom color) and only the included steps. Success and
116
+ Destructive stay off that list. Adding Coral on Colors makes `coral` /
117
+ `coral-400` appear with no package bump. The picker is
118
+ `@bison-lab/payload-core/admin#LookField` — run `payload generate:importmap`.
119
+ Pass the Theme document into `themeHeadFromDoc` so those keys paint
120
+ (`[data-look]` + `--coral-*`).
121
+
122
+ ```ts
123
+ import { lookField, colorTokenField } from '@bison-lab/payload-blocks'
124
+
125
+ lookField()
126
+ colorTokenField({ name: 'fill' })
127
+ ```
128
+
113
129
  **2. Own the registry.**
114
130
 
115
131
  The registry is a parameter, not an export, so the compile-time layout lock
@@ -321,43 +337,49 @@ stylesheet scans both packages:
321
337
  ## Wiring a header
322
338
 
323
339
  Two more blocks build a header rather than a page: `megaMenuBlock` and
324
- `LinkBlock`. They go in a global's `items` array, and the site owns that
325
- global. `megaMenuBlock` is a factory because the featured-link variants and
326
- 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:
327
345
 
328
346
  ```ts
347
+ import { createNavigation } from '@bison-lab/payload-core'
329
348
  import { LinkBlock, megaMenuBlock } from '@bison-lab/payload-blocks'
330
349
 
331
- export const Navigation: GlobalConfig = {
332
- slug: 'navigation',
333
- fields: [
334
- {
335
- name: 'items',
336
- type: 'blocks',
337
- blocks: [
338
- megaMenuBlock({
339
- variants: [
340
- { label: 'Lumbar', value: 'lumbar' },
341
- { label: 'SI joint', value: 'si' },
342
- ],
343
- icons: [{ label: 'Help', value: 'help' }],
344
- }),
345
- LinkBlock,
346
- ],
347
- },
348
- ],
349
- }
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
+ ]
350
364
  ```
351
365
 
352
- Then `payload generate:types` and `payload migrate:create`.
353
-
354
- An editor sees: label, landing page, the panel's max width, one to four
355
- columns (each a width, an optional divider, and sections of links), a footer
356
- with an overview link and a call to action, and an **Advanced** collapsible
357
- for CSS widths. The column widths, read as fractions, must add up to 100%:
358
- the rule is the array's own `validate`, so the editor sees "The columns add
359
- up to 75%. They need to add up to 100%." as they build, and the global's
360
- publish refuses the same. Custom widths skip it.
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`.
361
383
 
362
384
  In the site header, one call turns the rows into `FloatingNavBlock` items.
363
385
  The variants and icons here are the looks behind the values above:
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
- export { LinkField, MinRowsArrayField };
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
@@ -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;;;;;;;;;cAAa,iBAAA,EAAmB,yBAAA"}
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"}