@bison-lab/payload-core 4.6.0 → 4.9.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
@@ -22,7 +22,7 @@ lockstep.
22
22
 
23
23
  | Import | Contents | Runs where |
24
24
  | ---------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
25
- | `@bison-lab/payload-core` | `seoPlugin`, `createTheme`, `createBrandAssets`, `createRoles`, `createFeatures`, `createBlockLibrary`, `createPages`, `createUsers`, `createMedia`, `createRedirects`, `createQuestions`, `createTaxonomy`, `createAdminNav`, `adminNav`, `createNavigation`, `adminOnlyApiTab`, `documentTitleActions`, `seedTheme`, `seedRoles`, `seedFeatures`, predicates, `lookField`, `colorTokenField`, import-map strings, title and text helpers, types | Node. What `payload.config.ts` imports; it loads the plugin. |
25
+ | `@bison-lab/payload-core` | `seoPlugin`, `createTheme`, `createBrandAssets`, `createRoles`, `createFeatures`, `createBlockLibrary`, `createPages`, `createUsers`, `createMedia`, `createRedirects`, `createQuestions`, `createTaxonomy`, `createAdminNav`, `adminNav`, `createNavigation`, `adminOnlyApiTab`, `documentTitleActions`, `listAlign`, `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
28
  | `@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. |
@@ -336,10 +336,38 @@ switches back, so an editor picks which one the site uses. A site extra is appen
336
336
  only in the category it names. A site may not add `megaMenu` or `navLink`
337
337
  as cards.
338
338
 
339
- Disabling the last hero, the last navbar, or a slug any document still
340
- holds (published or draft) is refused, and the message names those
341
- documents. No page row is deleted. Stripping drafts on disable is BIS-131.
342
- A second navbar package is BIS-132.
339
+ Turning a card off distinguishes published from draft:
340
+
341
+ - **The last hero or the last navbar** is refused.
342
+ - **Published** — a live page (or any live document) holds the slug, or
343
+ it is the published Header's navbar: refused. The message names the
344
+ published documents and mentions any drafts; nothing is deleted.
345
+ - **Drafts only** — the switch opens a `ConfirmDialog` that names the
346
+ drafts. Confirm turns the switch off; the **Save** that turns the slug
347
+ off deletes its rows from those drafts, each written as a new draft
348
+ version (`payload.update({ draft: true })`) inside the Save's
349
+ transaction. Published versions are never written. Cancel leaves it on.
350
+ - **Unused** — off, no dialog.
351
+
352
+ The server is the authority: the Save hook re-reads usage, refuses while
353
+ anything published holds the slug, and strips drafts otherwise, whether
354
+ the Save came from the admin or the API. The admin asks
355
+ `GET /api/globals/block-library/usage?slug=…` (same access as `update`)
356
+ before it turns a switch off. `blockUsage` and `stripDrafts` are exported.
357
+ A page whose only section was stripped stays a draft until a section is
358
+ added: publish still hits `LAYOUT_REQUIRED_MESSAGE`. A block embedded in
359
+ rich text (a Lexical block node) is stripped too. A refusal is a public
360
+ 400, so the admin shows its message. A read that fails while checking
361
+ usage fails the check (the switch stays on) rather than answering from
362
+ part of the site. An editor who has a stripped draft open still holds the
363
+ row in their form; their next autosave writes it back, so turn a block off
364
+ when nobody is editing the drafts it names.
365
+
366
+ The Header's navbar is `header.navbar` when the Header document carries
367
+ one, otherwise the catalogue's first navbar (`floatingNav`). The package
368
+ Header has no such field yet; the picker arrives with a second navbar
369
+ package (BIS-132), so until then the published Header always holds
370
+ `floatingNav`.
343
371
 
344
372
  ```ts
345
373
  import { createBlockLibrary } from "@bison-lab/payload-core";
@@ -356,7 +384,7 @@ edit availability. Then `payload generate:importmap` and `payload migrate:create
356
384
  ## Pages, users, and media
357
385
 
358
386
  `createPages`, `createUsers`, `createMedia`, `slugField`,
359
- `createRedirects`, `adminOnlyApiTab`, and `documentTitleActions` ship from the same
387
+ `createRedirects`, `adminOnlyApiTab`, `documentTitleActions`, and `listAlign` ship from the same
360
388
  React-free entry. Pages take the
361
389
  site's hero and layout blocks, reserved-slug predicate, preview
362
390
  path, and optional `folderRoots` (`patients`, `providers`, …). Parent
@@ -394,7 +422,16 @@ set `saveToJWT: true`. The checklist labels are the editable names.
394
422
  primary actions on the title row — the same slot collection lists use
395
423
  for Create New — and hides the dead Edit tab when it has no sibling.
396
424
  One-list Globals pass `documentCreateNew("roles")` (or a site field
397
- path) so Create New uses those same words, with no icon. Overlay
425
+ path) so Create New uses those same words, with no icon.
426
+ `listAlign()` keeps a list column's header and cells together: a field
427
+ declares `admin: { custom: { listAlign: "center" | "end" } }` and the
428
+ plugin writes one stylesheet (`listAlignCss`) from every collection's
429
+ fields, mounted as the `LIST_ALIGN` provider. Payload's header holds a
430
+ full-width flex `.sort-column`, so `text-align` alone never moves it;
431
+ centered, the label shrinks to its word and the sort arrows hang outside
432
+ it, and end-aligned, the arrows lead. Never write a per-column selector
433
+ in a site stylesheet. The kit `Table` takes the same idea as
434
+ `align={[…]}`, one entry per column track. Overlay
398
435
  settings (Better Editor) take `developerOnlyAccess` and
399
436
  `hideUnlessDeveloper` on the site — the package does not add that
400
437
  plugin as a peer.
package/dist/admin.d.mts CHANGED
@@ -195,7 +195,9 @@ declare const FeaturesMatrixField: ArrayFieldClientComponent;
195
195
  /**
196
196
  * Category rail and a gallery of live islands. Each island is the sample
197
197
  * at `previewPath(slug)` under the published theme (the route is SPI-53).
198
- * `megaMenu` and `navLink` are not cards.
198
+ * `megaMenu` and `navLink` are not cards. Turning a card off is refused
199
+ * while a published document holds it, and asks before a Save that strips
200
+ * it from drafts.
199
201
  */
200
202
  declare const BlockLibraryField: ArrayFieldClientComponent;
201
203
  //#endregion
@@ -206,6 +208,20 @@ declare function DocumentTitleActions({
206
208
  children?: ReactNode;
207
209
  }): react_jsx_runtime0.JSX.Element;
208
210
  //#endregion
211
+ //#region src/admin/list-align-styles.d.ts
212
+ /**
213
+ * The stylesheet `listAlign()` built from each field's
214
+ * `admin.custom.listAlign`. Computed once at config time and handed in
215
+ * as `clientProps`, so the admin does no walking at render.
216
+ */
217
+ declare function ListAlignStyles({
218
+ css,
219
+ children
220
+ }: {
221
+ css?: string;
222
+ children?: ReactNode;
223
+ }): react_jsx_runtime0.JSX.Element;
224
+ //#endregion
209
225
  //#region src/admin/document-create-new.d.ts
210
226
  declare function DocumentCreateNew({
211
227
  path
@@ -305,5 +321,5 @@ declare function MediaAltAutofill({
305
321
  //#region src/admin/media-list-view.d.ts
306
322
  declare function MediaListView(props: ListViewClientProps): react_jsx_runtime0.JSX.Element;
307
323
  //#endregion
308
- export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
324
+ export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
309
325
  //# 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/preview-mode.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/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/page-slug-cell.tsx","../src/admin/required-page-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;;cCuBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCMjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cC0IhB,YAAA,EAAc,sBAAA;;;;;;;;iBCtIX,qBAAA,CAAA;;AVAhB;;;iBUQgB,eAAA,CAAA,GAAe,kBAAA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;EAAW;AAAA,GAAmB,aAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;iBCnD3C,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBCGhB,oBAAA,CAAA,GAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;cCEvB,mBAAA,EAAqB,wBAAA;;;;;;;;AhCClC;UiCFiB,cAAA;;EAEf,MAAA;EjCyED;EiCvEC,IAAA;;EAEA,KAAA;EhCmBW;EgCjBX,MAAA;AAAA;AAAA,UAGe,eAAA;EhCiEhB;EgC/DC,IAAA;;EAEA,KAAA;E/BgBW;E+BdX,UAAA;;;;;EAKA,MAAA;;EAEA,IAAA,GAAO,cAAA;AAAA;;;iBCyKO,aAAA,CACd,KAAA,EAAO,mBAAA;EAAwB,UAAA,YAAsB,eAAA;AAAA,IAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBChM1D,gBAAA,CAAA;EAAmB;AAAA;EAAU,IAAA;AAAA;;;iBC2G7B,aAAA,CAAc,KAAA,EAAO,mBAAA,GAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
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/preview-mode.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/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/page-slug-cell.tsx","../src/admin/required-page-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/list-align-styles.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;;cCuBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCMjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cC0IhB,YAAA,EAAc,sBAAA;;;;;;;;iBCtIX,qBAAA,CAAA;;AVAhB;;;iBUQgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;KCpCpB,gBAAA;AAAA,iBAgDI,mBAAA,CAAoB,IAAA,EAAM,gBAAA;;;;;;;cCjD7B,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;;cCqBX,gBAAA,EAAkB,yBAAA;;;;;;iBC1Bf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;cCChB,aAAA,EAAe,wBAAA;;;;;;;;;cC4Bf,SAAA,EAAW,wBAAA;;;;;;;iBC3BR,aAAA,CAAc,KAAA,EAAO,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;iBCJ9C,YAAA,CAAA;EAAe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EhB;EiC/DC,IAAA;;EAEA,KAAA;EhCgBW;EgCdX,UAAA;;;;;EAKA,MAAA;;EAEA,IAAA,GAAO,cAAA;AAAA;;;iBCyKO,aAAA,CACd,KAAA,EAAO,mBAAA;EAAwB,UAAA,YAAsB,eAAA;AAAA,IAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBChM1D,gBAAA,CAAA;EAAmB;AAAA;EAAU,IAAA;AAAA;;;iBC0G7B,aAAA,CAAc,KAAA,EAAO,mBAAA,GAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
package/dist/admin.mjs CHANGED
@@ -3803,6 +3803,7 @@ const FeaturesMatrixField = (props) => {
3803
3803
  };
3804
3804
  //#endregion
3805
3805
  //#region src/block-library/types.ts
3806
+ const BLOCK_LIBRARY_SLUG = "block-library";
3806
3807
  const BLOCK_LIBRARY_CATEGORIES = [
3807
3808
  {
3808
3809
  id: "hero",
@@ -3847,25 +3848,91 @@ const BLOCK_LIBRARY_CATEGORIES = [
3847
3848
  ];
3848
3849
  //#endregion
3849
3850
  //#region src/admin/block-library-field.tsx
3850
- const LIST_CSS$1 = `.bl-block-library{display:grid;grid-template-columns:12rem 1fr;gap:1.5rem;align-items:start}.bl-block-library__rail{display:flex;flex-direction:column;gap:.25rem}.bl-block-library__rail button{text-align:left;background:transparent;border:0;padding:.4rem .6rem;border-radius:8px;cursor:pointer}.bl-block-library__rail button[aria-current=true]{background:var(--theme-elevation-100,#f1f5f9);font-weight:650}.bl-block-library__card{display:flex;flex-direction:column;gap:.5rem;margin-block-end:1.25rem}.bl-block-library__card header{display:flex;justify-content:space-between;align-items:center;gap:1rem}.bl-block-library iframe{width:100%;height:720px;border:1px solid var(--theme-elevation-150,#e2e8f0);border-radius:12px;background:var(--theme-elevation-0,#fff)}`;
3851
- function LibraryCard({ path, index, row, rows, setRows, src, toggle }) {
3851
+ const LIST_CSS$1 = `.bl-block-library{display:grid;grid-template-columns:12rem 1fr;gap:1.5rem;align-items:start}.bl-block-library__rail{display:flex;flex-direction:column;gap:.25rem}.bl-block-library__rail button{text-align:left;background:transparent;border:0;padding:.4rem .6rem;border-radius:8px;cursor:pointer}.bl-block-library__rail button[aria-current=true]{background:var(--theme-elevation-100,#f1f5f9);font-weight:650}.bl-block-library__card{display:flex;flex-direction:column;gap:.5rem;margin-block-end:1.25rem}.bl-block-library__card header{display:flex;justify-content:space-between;align-items:center;gap:1rem}.bl-block-library__refusal{margin:0;color:var(--theme-error-500,#b91c1c)}.bl-block-library__drafts{margin:.5rem 0 0;padding-inline-start:1.25rem}.bl-block-library iframe{width:100%;height:720px;border:1px solid var(--theme-elevation-150,#e2e8f0);border-radius:12px;background:var(--theme-elevation-0,#fff)}`;
3852
+ function holderLabel(holder) {
3853
+ const title = holder.title?.trim() || "Untitled";
3854
+ const slug = holder.slug?.trim();
3855
+ return slug ? `${title} (${slug})` : title;
3856
+ }
3857
+ function refusalOf(label, usage) {
3858
+ return `${label} cannot be turned off. It is published on: ${usage.published.map(holderLabel).join(", ")}. Remove it from those first.${usage.drafts.length > 0 ? ` Drafts also use it: ${usage.drafts.map(holderLabel).join(", ")}.` : ""}`;
3859
+ }
3860
+ function isUsage(value) {
3861
+ return Boolean(value) && typeof value === "object" && Array.isArray(value.published) && Array.isArray(value.drafts);
3862
+ }
3863
+ function LibraryCard({ path, index, row, setRow, src, toggle, usageURL }) {
3852
3864
  const { setValue: setEnabled } = useField({ path: `${path}.${index}.enabled` });
3865
+ const [refusal, setRefusal] = useState(null);
3866
+ const [drafts, setDrafts] = useState(null);
3867
+ const [checking, setChecking] = useState(false);
3868
+ const apply = (enabled) => {
3869
+ setEnabled(enabled);
3870
+ setRow(index, enabled);
3871
+ };
3872
+ /**
3873
+ * Off asks the server where the slug is used. Published refuses; drafts
3874
+ * only ask first, because the Save that turns it off deletes those rows.
3875
+ */
3876
+ const turnOff = async () => {
3877
+ setRefusal(null);
3878
+ setChecking(true);
3879
+ try {
3880
+ const response = await fetch(`${usageURL}?slug=${encodeURIComponent(row.slug)}`, { credentials: "include" });
3881
+ const usage = response.ok ? await response.json() : null;
3882
+ if (!isUsage(usage)) throw new Error("usage");
3883
+ if (usage.published.length > 0) setRefusal(refusalOf(row.label, usage));
3884
+ else if (usage.drafts.length > 0) setDrafts(usage.drafts);
3885
+ else apply(false);
3886
+ } catch {
3887
+ setRefusal(`Could not check where ${row.label} is used. It stays on; try again.`);
3888
+ } finally {
3889
+ setChecking(false);
3890
+ }
3891
+ };
3853
3892
  return /* @__PURE__ */ jsxs("article", {
3854
3893
  className: "bl-block-library__card",
3855
- children: [/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("span", { children: row.label }), toggle ? /* @__PURE__ */ jsx(Switch, {
3856
- checked: row.enabled !== false,
3857
- "aria-label": `Enable ${row.label}`,
3858
- onCheckedChange: (enabled) => {
3859
- setEnabled(enabled);
3860
- setRows(rows.map((entry, i) => i === index ? {
3861
- ...entry,
3862
- enabled
3863
- } : entry));
3864
- }
3865
- }) : null] }), /* @__PURE__ */ jsx("iframe", {
3866
- title: row.label,
3867
- src
3868
- })]
3894
+ children: [
3895
+ /* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("span", { children: row.label }), toggle ? /* @__PURE__ */ jsx(Switch, {
3896
+ checked: row.enabled !== false,
3897
+ disabled: checking,
3898
+ "aria-label": `Enable ${row.label}`,
3899
+ onCheckedChange: (enabled) => {
3900
+ if (enabled) {
3901
+ setRefusal(null);
3902
+ apply(true);
3903
+ } else turnOff();
3904
+ }
3905
+ }) : null] }),
3906
+ refusal ? /* @__PURE__ */ jsx("p", {
3907
+ className: "bl-block-library__refusal",
3908
+ role: "alert",
3909
+ children: refusal
3910
+ }) : null,
3911
+ /* @__PURE__ */ jsx("iframe", {
3912
+ title: row.label,
3913
+ src
3914
+ }),
3915
+ /* @__PURE__ */ jsxs(ConfirmDialog, {
3916
+ open: drafts !== null,
3917
+ title: `Remove ${row.label} from ${drafts?.length === 1 ? "1 draft" : `${drafts?.length ?? 0} drafts`}?`,
3918
+ cancelLabel: "Cancel",
3919
+ confirmLabel: "Remove from drafts",
3920
+ confirmVariant: "danger",
3921
+ onCancel: () => setDrafts(null),
3922
+ onConfirm: () => {
3923
+ setDrafts(null);
3924
+ apply(false);
3925
+ },
3926
+ children: [/* @__PURE__ */ jsxs("p", { children: [
3927
+ "No published page uses ",
3928
+ row.label,
3929
+ ". Saving deletes its rows from these drafts and turns it off. Published pages are not changed."
3930
+ ] }), /* @__PURE__ */ jsx("ul", {
3931
+ className: "bl-block-library__drafts",
3932
+ children: (drafts ?? []).map((holder) => /* @__PURE__ */ jsx("li", { children: holderLabel(holder) }, holderLabel(holder)))
3933
+ })]
3934
+ })
3935
+ ]
3869
3936
  });
3870
3937
  }
3871
3938
  function asRows(value) {
@@ -3885,13 +3952,23 @@ function seededRows(field) {
3885
3952
  /**
3886
3953
  * Category rail and a gallery of live islands. Each island is the sample
3887
3954
  * at `previewPath(slug)` under the published theme (the route is SPI-53).
3888
- * `megaMenu` and `navLink` are not cards.
3955
+ * `megaMenu` and `navLink` are not cards. Turning a card off is refused
3956
+ * while a published document holds it, and asks before a Save that strips
3957
+ * it from drafts.
3889
3958
  */
3890
3959
  const BlockLibraryField = (props) => {
3891
3960
  const { setValue, value } = useField({ path: props.path });
3961
+ const { config } = useConfig();
3962
+ const usageURL = `${config.serverURL ?? ""}${config.routes?.api ?? "/api"}/globals/${BLOCK_LIBRARY_SLUG}/usage`;
3892
3963
  const loaded = asRows(value);
3893
3964
  const seeded = seededRows(props.field);
3894
3965
  const rows = loaded.length > 0 ? loaded : seeded;
3966
+ const rowsRef = useRef(rows);
3967
+ rowsRef.current = rows;
3968
+ const setRow = useCallback((index, enabled) => setValue(rowsRef.current.map((entry, i) => i === index ? {
3969
+ ...entry,
3970
+ enabled
3971
+ } : entry)), [setValue]);
3895
3972
  useEffect(() => {
3896
3973
  if (loaded.length === 0 && seeded.length > 0) setValue(seeded);
3897
3974
  }, [
@@ -3929,10 +4006,10 @@ const BlockLibraryField = (props) => {
3929
4006
  path: props.path,
3930
4007
  index,
3931
4008
  row,
3932
- rows,
3933
- setRows: (next) => setValue(next),
4009
+ setRow,
3934
4010
  src: previews[row.slug] ?? "",
3935
- toggle: row.kind !== "navbar" || navbarCount > 1
4011
+ toggle: row.kind !== "navbar" || navbarCount > 1,
4012
+ usageURL
3936
4013
  }, row.slug)) })
3937
4014
  ]
3938
4015
  }) }) });
@@ -4024,6 +4101,20 @@ function DocumentTitleActions({ children }) {
4024
4101
  }), children] });
4025
4102
  }
4026
4103
  //#endregion
4104
+ //#region src/admin/list-align-styles.tsx
4105
+ /**
4106
+ * The stylesheet `listAlign()` built from each field's
4107
+ * `admin.custom.listAlign`. Computed once at config time and handed in
4108
+ * as `clientProps`, so the admin does no walking at render.
4109
+ */
4110
+ function ListAlignStyles({ css, children }) {
4111
+ return /* @__PURE__ */ jsxs(Fragment, { children: [css ? /* @__PURE__ */ jsx("style", {
4112
+ href: "bl-list-align",
4113
+ precedence: "default",
4114
+ children: css
4115
+ }) : null, children] });
4116
+ }
4117
+ //#endregion
4027
4118
  //#region src/admin/document-create-new.tsx
4028
4119
  /**
4029
4120
  * Same words as a collection list Create New — no icon, no "Area" or
@@ -4352,8 +4443,8 @@ const QUESTIONS_LIST_CSS = `
4352
4443
  .bl-faq-library__search .bl-nav-kit__input{padding-left:34px}
4353
4444
  .bl-faq-library__filter{width:auto;min-width:150px}
4354
4445
  .bl-faq-library__table{box-shadow:0 1px 2px rgba(20,25,35,.04),0 8px 28px rgba(20,25,35,.05)}
4355
- .bl-faq-library__table .bl-nav-kit__table-row{align-items:flex-start;padding:14px}
4356
- .bl-faq-library__table .bl-nav-kit__table-head{align-items:center;padding:11px 14px}
4446
+ .bl-faq-library__table .bl-nav-kit__table-row{align-items:flex-start;padding-block:14px}
4447
+ .bl-faq-library__table .bl-nav-kit__table-head{align-items:center;padding-block:11px}
4357
4448
  .bl-faq-library__question{font-weight:700;margin:0 0 4px}
4358
4449
  .bl-faq-library__answer{margin:0;color:var(--bl-kit-ink-muted);max-width:640px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
4359
4450
  .bl-faq-library__chips{display:flex;flex-wrap:wrap;gap:5px}
@@ -5438,7 +5529,6 @@ const LIST_CSS = `
5438
5529
  .bl-media-list__sort-mark[data-dir="asc"] svg:first-child,.bl-media-list__sort-mark[data-dir="desc"] svg:last-child{opacity:1;color:var(--bl-kit-accent,#2563eb)}
5439
5530
  .bl-media-list .bl-nav-kit__table-row:not(.bl-nav-kit__table-head):nth-child(even){--bl-table-row-bg:var(--bl-kit-surface-well);background-color:var(--bl-table-row-bg)}
5440
5531
  .bl-media-list .bl-nav-kit__table-cell--shade.bl-nav-kit__table-cell--pin-start{min-width:0;overflow:hidden}
5441
- .bl-media-list .bl-nav-kit__table-cell--pin-end{justify-content:center}
5442
5532
  .bl-media-list .bl-nav-kit__table-cell--pin-end .bl-nav-kit__table-actions{justify-content:center;width:max-content}
5443
5533
  .bl-media-list__empty{padding:48px 16px;text-align:center;color:var(--bl-kit-ink-muted)}
5444
5534
  .bl-media-list__checks{display:flex;flex-direction:column;gap:2px}
@@ -5606,6 +5696,11 @@ function MediaListPage({ collectionSlug, hasCreatePermission, hasDeletePermissio
5606
5696
  const chips = useMemo(() => chipsFrom(applied), [applied]);
5607
5697
  const shown = COLUMN_KEYS.filter((key) => visible[key]);
5608
5698
  const columns = gridColumns(shown);
5699
+ const align = [
5700
+ void 0,
5701
+ ...shown.map((key) => key === "inUse" ? "center" : void 0),
5702
+ "center"
5703
+ ];
5609
5704
  useLayoutEffect(() => {
5610
5705
  const root = rootRef.current;
5611
5706
  const table = root?.querySelector(".bl-nav-kit__table");
@@ -5953,6 +6048,7 @@ function MediaListPage({ collectionSlug, hasCreatePermission, hasDeletePermissio
5953
6048
  }) : null,
5954
6049
  /* @__PURE__ */ jsxs(Table, {
5955
6050
  columns,
6051
+ align,
5956
6052
  children: [/* @__PURE__ */ jsxs(TableHead, { children: [
5957
6053
  /* @__PURE__ */ jsx(TableCell, {
5958
6054
  pin: "start",
@@ -6264,6 +6360,6 @@ function ChevronMark() {
6264
6360
  });
6265
6361
  }
6266
6362
  //#endregion
6267
- export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
6363
+ export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
6268
6364
 
6269
6365
  //# sourceMappingURL=admin.mjs.map