@bison-lab/payload-core 3.13.0 → 3.15.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
@@ -25,7 +25,7 @@ lockstep.
25
25
  | `@bison-lab/payload-core` | `seoPlugin`, `createTheme`, `createBrandAssets`, `createRoles`, `createFeatures`, `createPages`, `createUsers`, `createMedia`, `adminOnlyApiTab`, `seedTheme`, `seedRoles`, `seedFeatures`, predicates, `lookField`, `colorTokenField`, import-map strings, title and text helpers, types | Node. What `payload.config.ts` imports; it loads the plugin. |
26
26
  | `@bison-lab/payload-core/metadata` | `pageMetadata`, the title helpers, the same types | Server. What a page route imports; it does not load the plugin. |
27
27
  | `@bison-lab/payload-core/theme` | `getPublishedTheme`, `getPublishedIdentity`, `themeConfigFromDoc`, `themeHead`, `themeHeadFromDoc` | Server. What a root layout imports; it does not load the plugin or React. |
28
- | `@bison-lab/payload-core/admin` | Theme child fields, the Roles and Features matrices, and the Users Roles checklist | Admin. Referenced by import-map string; `generate:importmap` writes it. |
28
+ | `@bison-lab/payload-core/admin` | Theme fields, the Roles and Features matrices, and the Users Roles checklist | Admin. Referenced by import-map string; `generate:importmap` writes it. |
29
29
  | `@bison-lab/payload-core/react` | `ThemePreview` (legacy; Theme has no preview pane) | Client. Kept so an older site import does not break. |
30
30
 
31
31
  ## What editors get
@@ -125,13 +125,13 @@ The sitemap is the site's: filter `meta.noIndex` out of it.
125
125
 
126
126
  ## Adopting the Theme global
127
127
 
128
- Theme in the admin nav is a group like Content and Settings: Colors,
129
- Typography, Appearance, and Identity. Those are ordinary Payload Globals
130
- (`admin.group: "Theme"`), not custom views. `createTheme` returns them plus
131
- a hidden store (`theme`) that `getPublishedTheme` already reads. Save on a
132
- page is Payload's Save; it writes that slice onto the store. Document
133
- locking is off — these are settings forms. Theme has no draft mode and
134
- no preview pane. Contrast is the automatic label on editable fills at 7:1; it
128
+ Theme in the admin nav is one Global (`theme`) in `admin.group: "Theme"`.
129
+ Colors, Typography, Appearance, and Identity are field tabs on that
130
+ document, not custom views and not extra Globals. Save is Payload's Save
131
+ on the whole form every tab is hydrated from the live row, so an
132
+ untouched tab does not revert. `getPublishedTheme` reads that same row.
133
+ Document locking is off. Theme has no draft mode and no preview pane.
134
+ Contrast is the automatic label on editable fills at 7:1; it
135
135
  is never enforced and lives in the Needs-attention modal, not on the page.
136
136
  `bison.config.json` is the seed a site starts from, not the source of truth.
137
137
  Pass `destructive` (or `seed.brandDestructive`); otherwise Theme uses the
@@ -194,7 +194,7 @@ or pass empty arrays, and every additional color is unused and deletes
194
194
  immediately. A new look surface is added to `colorUsages`, not copied
195
195
  into a site helper. Site adopt names the slugs (SPI-93).
196
196
 
197
- Then `payload generate:importmap` (the Theme child fields resolve from
197
+ Then `payload generate:importmap` (the Theme fields resolve from
198
198
  `@bison-lab/payload-core/admin`), `payload generate:types`, and
199
199
  `payload migrate:create`.
200
200
 
@@ -261,10 +261,13 @@ has its accessible name. Then `payload migrate:create`.
261
261
  ## Roles
262
262
 
263
263
  Settings → Roles is an Admin-editable array. Rank is drag-to-reorder.
264
- Ticks are Content, Brand, Publish, and Users. Defaults ship in the
265
- package (Brand on Designer only; Admin + Designer both store; Developer
266
- is exclusive). A site may pass `extras` into `createRoles` each extra
267
- is a slug, a display label, and default ticks — and an Admin can add
264
+ Ticks are the catalogue rows released on Features. Developer is
265
+ implicit every catalogue feature, including ones not released. That
266
+ row is visible only to a Developer, with every tick on and locked.
267
+ Defaults ship in the package (Theme
268
+ screens on Designer; Designer also has Users and Roles; Admin + Designer
269
+ both store). A site may pass `extras` into `createRoles` — each extra
270
+ is a slug, a display label, and default `grants` — and an Admin can add
268
271
  further custom rows and edit any row’s name. Seed slugs stay read-only.
269
272
  `canManageBrand` and the other predicates read the saved Global and fall
270
273
  back to that seed (plus extras). The package never writes `developer`
@@ -272,38 +275,63 @@ onto a user row.
272
275
 
273
276
  ```ts
274
277
  createRoles({
275
- extras: [{ role: "editor", label: "Editor", content: true, brand: false, publish: false, users: false }],
278
+ extras: [{ role: "editor", label: "Editor", grants: ["content"] }],
276
279
  });
277
280
  ```
278
281
 
279
282
  ## Features
280
283
 
281
- Settings → Features is a feature × role grid. The catalogue is code:
282
- Pages, Media, Theme, Brand assets, Users, Roles, and Features. A site
283
- may pass `extras` into `createFeatures` those rows appear only there.
284
- `canUseFeature(slug)` reads the saved grid and falls back to Content →
285
- Pages/Media and Brand Theme/Brand assets when the Global is empty.
286
- Users, Roles, and Features cannot be turned off; Developer is always
287
- allowed. `createPages` / `createMedia` use `canUseFeature` for create
288
- and update (and `admin.hidden`). Theme and brand-assets still take
289
- `access` arguments pass `canUseFeature("theme")` /
290
- `canUseFeature("brand-assets")` as `update`.
284
+ Settings → Features is a Developer-only release valve: one switch per
285
+ catalogue row. Off hides the tick on Roles; Developer still has the
286
+ feature. The catalogue is code, grouped for the UI: Pages (Content,
287
+ Publish), Media, Theme (Colors, Typography, Appearance, Identity, Brand
288
+ assets), and Users (Users, Roles). Features itself is not a row. The
289
+ document API tab and Better Editor overlay settings are not rows either
290
+ they stay code-locked to Developer (`adminOnlyApiTab`,
291
+ `developerOnlyAccess` / `hideUnlessDeveloper`). A site may pass `extras`
292
+ into `createFeatures` — those rows appear only there, including a
293
+ future Navigation global:
291
294
 
292
295
  ```ts
293
296
  createFeatures({
294
- extras: [{ slug: "doctors", label: "Doctor search" }],
297
+ extras: [
298
+ { slug: "doctors", label: "Doctor search", group: "users" },
299
+ { slug: "navigation", label: "Navigation" },
300
+ ],
295
301
  });
302
+
303
+ // On that Global:
304
+ // access: { update: canUseFeature("navigation") }
305
+ // Drafts use the same Publish tick as Pages to go live.
296
306
  ```
297
307
 
308
+ `canUseFeature(slug)` is true when the row is released and a held role
309
+ is granted it, or when the login is Developer. An empty Global falls
310
+ back to the catalogue defaults. Group slugs `pages` and `theme` are
311
+ true when any child is. `createPages` / `createMedia` use
312
+ `canUseFeature` for create and update (and `admin.hidden`). Theme and
313
+ brand-assets still take `access` arguments — pass
314
+ `canUseFeature("theme")` / `canUseFeature("brand-assets")` as `update`.
315
+ `admin.hidden` is presentation; Access Control is enforcement. Nav
316
+ hiding follows `user.allowedFeatures` on the JWT (computed at user
317
+ read from the live Features and Roles Globals) so Payload's
318
+ `admin.hidden({ user })` matches the API.
319
+
298
320
  ## Pages, users, and media
299
321
 
300
322
  `createPages`, `createUsers`, `createMedia`, `slugField`, and
301
323
  `adminOnlyApiTab` ship from the same React-free entry. Pages take the
302
324
  site's hero and layout blocks, reserved-slug predicate, and preview
303
- path. Users sit under Settings next to Roles, take `secureCookies`, and
304
- offer whatever rows the Global (or the seed plus the same `extras`) has.
305
- The checklist labels are the editable names. `adminOnlyApiTab` shows the
306
- document API tab only to Developer.
325
+ path. Create follows the Content tick. Update without Publish is
326
+ constrained to `_status: draft` an Author can save a draft and cannot
327
+ publish or edit a live page. Users sit under Settings next to Roles,
328
+ take `secureCookies`, and offer whatever rows the Global (or the seed
329
+ plus the same `extras`) has. `users.roles` and `users.allowedFeatures`
330
+ set `saveToJWT: true`. The checklist labels are the editable names.
331
+ `adminOnlyApiTab` shows the document API tab only to Developer. Overlay
332
+ settings (Better Editor) take `developerOnlyAccess` and
333
+ `hideUnlessDeveloper` on the site — the package does not add that
334
+ plugin as a peer.
307
335
 
308
336
  ## No generated types
309
337
 
package/dist/admin.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { ThemeConfig } from "@bison-lab/tokens";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
- import { ArrayFieldClientComponent, GroupFieldClientComponent, SelectFieldClientComponent, TextFieldClientComponent, UIFieldClientComponent } from "payload";
4
+ import { ArrayFieldClientComponent, GroupFieldClientComponent, JSONFieldClientComponent, SelectFieldClientComponent, TextFieldClientComponent, UIFieldClientComponent } from "payload";
5
5
 
6
6
  //#region src/admin/color-field.d.ts
7
7
  /**
@@ -104,7 +104,8 @@ declare const LookField: TextFieldClientComponent;
104
104
  //#region src/admin/roles-matrix-field.d.ts
105
105
  /**
106
106
  * Payload's array field: drag rank stays, add is for custom rows, seed
107
- * rows have no remove. Reset restores seed ticks and package labels.
107
+ * rows have no remove. Developer stays in the saved array and is shown
108
+ * only to a Developer. Reset restores seed ticks and package labels.
108
109
  */
109
110
  declare const RolesMatrixField: ArrayFieldClientComponent;
110
111
  //#endregion
@@ -120,6 +121,13 @@ declare function RolesRowLabel(): react_jsx_runtime0.JSX.Element;
120
121
  */
121
122
  declare const RoleSlugField: TextFieldClientComponent;
122
123
  //#endregion
124
+ //#region src/admin/role-name-field.d.ts
125
+ /**
126
+ * Role name. Letters and spaces only, so the hidden slug stays
127
+ * `the-greatest-designer` from `The Greatest Designer`.
128
+ */
129
+ declare const RoleNameField: TextFieldClientComponent;
130
+ //#endregion
123
131
  //#region src/admin/roles-field.d.ts
124
132
  /**
125
133
  * Users Roles checklist. Order and labels come from the field options (the
@@ -128,12 +136,24 @@ declare const RoleSlugField: TextFieldClientComponent;
128
136
  */
129
137
  declare const RolesField: SelectFieldClientComponent;
130
138
  //#endregion
139
+ //#region src/admin/roles-grants-field.d.ts
140
+ /**
141
+ * Released catalogue rows as ticks. Unreleased features do not appear,
142
+ * except on Developer: every catalogue row is shown granted and locked
143
+ * so a new Feature is visibly included.
144
+ */
145
+ declare const RolesGrantsField: JSONFieldClientComponent;
146
+ //#endregion
131
147
  //#region src/admin/features-matrix-field.d.ts
132
148
  /**
133
- * Feature × role grid. Columns come from the Roles Global (or the seed).
134
- * Locked rows and Developer cannot be cleared.
149
+ * One release switch per catalogue row, grouped. Off hides the tick on
150
+ * Roles; Developer still has the feature.
151
+ *
152
+ * Writes both the array value and each row's `released` checkbox path.
153
+ * Payload still registers those child fields; toggling only the parent
154
+ * array leaves them false and Save stores the old flags.
135
155
  */
136
156
  declare const FeaturesMatrixField: ArrayFieldClientComponent;
137
157
  //#endregion
138
- export { AppearanceField, ColorField, ColorScaleField, ContrastReport, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, PairingField, PublishChild, RoleSlugField, RolesField, RolesMatrixField, RolesRowLabel, SectionHeading, ThemeDocumentControls, ThemeSaveButton };
158
+ export { AppearanceField, ColorField, ColorScaleField, ContrastReport, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, PairingField, PublishChild, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, ThemeDocumentControls, ThemeSaveButton };
139
159
  //# sourceMappingURL=admin.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/roles-field.tsx","../src/admin/features-matrix-field.tsx"],"mappings":";;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;cCsBZ,eAAA,EAAiB,yBAAA;;;;;;;;ADtB9B;cEgBa,YAAA,EAAc,yBAAA;;;;;;;;AFhB3B;cGOa,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;;;;;cCuDjB,cAAA,EAAgB,0BAAA;;;;;;;cChDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cCgJhB,YAAA,EAAc,sBAAA;;;;;;;;iBC3IX,qBAAA,CAAA,GAAqB,kBAAA,CAAA,GAAA,CAAA,OAAA;AVDrC;;;;AAAA,iBUgBgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cC7CnB,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;cCYX,gBAAA,EAAkB,yBAAA;;;;;;iBCjBf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;cCChB,aAAA,EAAe,wBAAA;;;;;;;;cC+Cf,UAAA,EAAY,0BAAA;;;;;;;cCtCZ,mBAAA,EAAqB,yBAAA"}
1
+ {"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx"],"mappings":";;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;cCsBZ,eAAA,EAAiB,yBAAA;;;;;;;;ADtB9B;cEgBa,YAAA,EAAc,yBAAA;;;;;;;;AFhB3B;cGOa,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;;;;;cCuDjB,cAAA,EAAgB,0BAAA;;;;;;;cChDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cCgJhB,YAAA,EAAc,sBAAA;;;;;;;;iBC3IX,qBAAA,CAAA,GAAqB,kBAAA,CAAA,GAAA,CAAA,OAAA;AVDrC;;;;AAAA,iBUgBgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cC7CnB,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;;cCsBX,gBAAA,EAAkB,yBAAA;;;;;;iBC3Bf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;cCChB,aAAA,EAAe,wBAAA;;;;;;;cCCf,aAAA,EAAe,wBAAA;;;;;;;;cC8Cf,UAAA,EAAY,0BAAA;;;;;;;;cChCZ,gBAAA,EAAkB,wBAAA;;;;;;;;AlBZ/B;;;cmB0Ca,mBAAA,EAAqB,yBAAA"}