@bison-lab/payload-core 3.19.0 → 3.19.1
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 +4 -3
- package/dist/admin.d.mts +12 -9
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +68 -51
- package/dist/admin.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -347,9 +347,10 @@ the document so the sidebar can paint. Save writes immediately.
|
|
|
347
347
|
`adminNav()` sets `admin.components.Nav` to the package Nav. A consuming
|
|
348
348
|
site must not write a Nav component. An empty document falls back to
|
|
349
349
|
Payload's first-seen walk (collections, then globals, bucketed by
|
|
350
|
-
`admin.group`).
|
|
351
|
-
|
|
352
|
-
|
|
350
|
+
`admin.group`). Once the document has groups, that list is the sidebar —
|
|
351
|
+
omitted collections and globals stay off it. `group: false` stays off.
|
|
352
|
+
`resolveAdminNav` is the layout source so a later skin (SPI-10) does not
|
|
353
|
+
invent a second one.
|
|
353
354
|
|
|
354
355
|
```ts
|
|
355
356
|
import { adminNav, createAdminNav } from "@bison-lab/payload-core";
|
package/dist/admin.d.mts
CHANGED
|
@@ -195,17 +195,20 @@ declare function AdminNav({
|
|
|
195
195
|
*/
|
|
196
196
|
declare function AdminNavRowLabel(): react_jsx_runtime0.JSX.Element;
|
|
197
197
|
//#endregion
|
|
198
|
+
//#region src/admin/admin-nav-item-row-label.d.ts
|
|
199
|
+
/**
|
|
200
|
+
* Item accordion title. Shows the chosen collection or global name
|
|
201
|
+
* (Pages), or “Item” when the row is still empty.
|
|
202
|
+
*/
|
|
203
|
+
declare function AdminNavItemRowLabel(): react_jsx_runtime0.JSX.Element;
|
|
204
|
+
//#endregion
|
|
198
205
|
//#region src/admin/admin-nav-entity-field.d.ts
|
|
199
206
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
207
|
+
* Payload's select of collections or globals. Subscribes to sibling Type
|
|
208
|
+
* with `useField` so the list updates when Type changes — `getDataByPath`
|
|
209
|
+
* does not re-render this field.
|
|
203
210
|
*/
|
|
204
|
-
declare
|
|
205
|
-
path
|
|
206
|
-
}: {
|
|
207
|
-
path: string;
|
|
208
|
-
}): react_jsx_runtime0.JSX.Element;
|
|
211
|
+
declare const AdminNavEntityField: TextFieldClientComponent;
|
|
209
212
|
//#endregion
|
|
210
|
-
export { AdminNav, AdminNavEntityField, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, PairingField, PublishChild, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, ThemeDocumentControls, ThemeSaveButton };
|
|
213
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, PairingField, PublishChild, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, ThemeDocumentControls, ThemeSaveButton };
|
|
211
214
|
//# 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/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","../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-entity-field.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;cCsBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCNjB,YAAA,EAAc,yBAAA;;;;;;;;;cCTd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cMyDa,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;;;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;;;;;;;;cCqBX,gBAAA,EAAkB,yBAAA;;;;;;iBC1Bf,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;;;iBCjBlB,oBAAA,CAAA;EAAuB;AAAA;EAAc,QAAA,GAAW,SAAA;AAAA,IAAW,kBAAA,CAAA,GAAA,CAAA,OAAA;;;iBCtB3D,iBAAA,CAAA;EAAoB;AAAA;EAAU,IAAA;AAAA,IAAc,kBAAA,CAAA,GAAA,CAAA,OAAA;;;UCmB3C,uBAAA;EACf,WAAA;EACA,OAAA;AAAA;;;UC5Be,aAAA;EACf,eAAA,GAAkB,uBAAA;AAAA;;;;AvBGpB;;iBuBsCgB,QAAA,CAAA;EAAW;AAAA,GAAmB,aAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;iBC5C3C,gBAAA,CAAA,GAAgB,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/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","../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"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;cCsBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCNjB,YAAA,EAAc,yBAAA;;;;;;;;;cCTd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;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;;;;;;;cCEvB,mBAAA,EAAqB,wBAAA"}
|
package/dist/admin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as colorDocFromState, i as SYSTEM_COLOR_KEYS, n as pageEditorLooks, r as pageEditorTokens, s as stateFromColorDoc } from "./looks-BbL309kO.mjs";
|
|
3
|
-
import { ArrayField, Button, CheckboxInput, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, fieldBaseClass, useAuth, useConfig, useField, useForm, useFormFields, useNav, useRowLabel } from "@payloadcms/ui";
|
|
3
|
+
import { ArrayField, Button, CheckboxInput, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAuth, useConfig, useField, useForm, useFormFields, useNav, useRowLabel } from "@payloadcms/ui";
|
|
4
4
|
import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, setColorScaleInclude } from "@bison-lab/tokens";
|
|
5
5
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -3468,34 +3468,13 @@ function itemFromSaved(item, byKey) {
|
|
|
3468
3468
|
}
|
|
3469
3469
|
function fromDocument(doc, entities) {
|
|
3470
3470
|
const byKey = new Map(entities.map((entity) => [keyOf(entity.type, entity.slug), entity]));
|
|
3471
|
-
|
|
3471
|
+
return (doc.groups ?? []).map((row) => ({
|
|
3472
3472
|
label: typeof row.label === "string" ? row.label : "",
|
|
3473
3473
|
items: (row.items ?? []).flatMap((item) => {
|
|
3474
3474
|
const resolved = itemFromSaved(item ?? {}, byKey);
|
|
3475
3475
|
return resolved ? [resolved] : [];
|
|
3476
3476
|
})
|
|
3477
3477
|
}));
|
|
3478
|
-
const seen = new Set(groups.flatMap((group) => group.items.map((item) => keyOf(item.type, item.slug))));
|
|
3479
|
-
for (const entity of entities) {
|
|
3480
|
-
if (entity.group === false) continue;
|
|
3481
|
-
const key = keyOf(entity.type, entity.slug);
|
|
3482
|
-
if (seen.has(key)) continue;
|
|
3483
|
-
let group = groups.find((entry) => entry.label === entity.group);
|
|
3484
|
-
if (!group) {
|
|
3485
|
-
group = {
|
|
3486
|
-
label: entity.group,
|
|
3487
|
-
items: []
|
|
3488
|
-
};
|
|
3489
|
-
groups.push(group);
|
|
3490
|
-
}
|
|
3491
|
-
group.items.push({
|
|
3492
|
-
type: entity.type,
|
|
3493
|
-
slug: entity.slug,
|
|
3494
|
-
label: entity.label
|
|
3495
|
-
});
|
|
3496
|
-
seen.add(key);
|
|
3497
|
-
}
|
|
3498
|
-
return groups;
|
|
3499
3478
|
}
|
|
3500
3479
|
/**
|
|
3501
3480
|
* Layout for the package Nav (and later SPI-10). Permissions are
|
|
@@ -3584,10 +3563,15 @@ function AdminNav({ visibleEntities }) {
|
|
|
3584
3563
|
className: `${BASE}__links`,
|
|
3585
3564
|
children: groups.map((group, index) => {
|
|
3586
3565
|
const items = group.items.map((item) => {
|
|
3566
|
+
const href = item.type === "collection" ? `${adminRoute}/collections/${item.slug}` : `${adminRoute}/globals/${item.slug}`;
|
|
3587
3567
|
return /* @__PURE__ */ jsx(Link, {
|
|
3588
|
-
href: item.type === "collection" ? `${adminRoute}/collections/${item.slug}` : `${adminRoute}/globals/${item.slug}`,
|
|
3589
3568
|
className: `${BASE}__link`,
|
|
3590
|
-
|
|
3569
|
+
href,
|
|
3570
|
+
prefetch: false,
|
|
3571
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
3572
|
+
className: `${BASE}__link-label`,
|
|
3573
|
+
children: item.label
|
|
3574
|
+
})
|
|
3591
3575
|
}, `${item.type}:${item.slug}`);
|
|
3592
3576
|
});
|
|
3593
3577
|
if (!group.label) return /* @__PURE__ */ jsx("div", {
|
|
@@ -3621,37 +3605,70 @@ function AdminNavRowLabel() {
|
|
|
3621
3605
|
return /* @__PURE__ */ jsx("span", { children: typeof data.label === "string" && data.label.trim() ? data.label.trim() : "Group" });
|
|
3622
3606
|
}
|
|
3623
3607
|
//#endregion
|
|
3624
|
-
//#region src/admin
|
|
3608
|
+
//#region src/admin-nav/entity-options.ts
|
|
3609
|
+
function entityType(type) {
|
|
3610
|
+
return type === "global" ? "global" : "collection";
|
|
3611
|
+
}
|
|
3625
3612
|
/**
|
|
3626
|
-
*
|
|
3627
|
-
*
|
|
3628
|
-
* are not on the sidebar.
|
|
3613
|
+
* Collections or globals a Developer may pin. Sibling Type decides which
|
|
3614
|
+
* list. `group: false` stays off — those entities are not on the sidebar.
|
|
3629
3615
|
*/
|
|
3630
|
-
function
|
|
3631
|
-
const
|
|
3632
|
-
|
|
3633
|
-
const type = getDataByPath(path.replace(/\.slug$/, ".type"));
|
|
3634
|
-
const { config } = useConfig();
|
|
3635
|
-
const options = type === "global" ? (config.globals ?? []).filter((entity) => entity.admin?.group !== false).map((entity) => ({
|
|
3636
|
-
value: entity.slug,
|
|
3637
|
-
label: typeof entity.label === "string" ? entity.label : entity.slug
|
|
3638
|
-
})) : (config.collections ?? []).filter((entity) => entity.admin?.group !== false).map((entity) => ({
|
|
3616
|
+
function adminNavEntityOptions(config, type) {
|
|
3617
|
+
const kind = entityType(type);
|
|
3618
|
+
return (kind === "global" ? config.globals ?? [] : config.collections ?? []).filter((entity) => entity.admin?.group !== false).map((entity) => ({
|
|
3639
3619
|
value: entity.slug,
|
|
3640
|
-
label: typeof entity.labels?.plural === "string" ? entity.labels.plural : entity.slug
|
|
3620
|
+
label: kind === "global" ? typeof entity.label === "string" && entity.label ? entity.label : entity.slug : typeof entity.labels?.plural === "string" && entity.labels.plural ? entity.labels.plural : entity.slug
|
|
3641
3621
|
}));
|
|
3642
|
-
return /* @__PURE__ */ jsxs("label", { children: ["Slug", /* @__PURE__ */ jsxs("select", {
|
|
3643
|
-
value: typeof value === "string" ? value : "",
|
|
3644
|
-
onChange: (event) => setValue(event.target.value),
|
|
3645
|
-
children: [/* @__PURE__ */ jsx("option", {
|
|
3646
|
-
value: "",
|
|
3647
|
-
children: "Select…"
|
|
3648
|
-
}), options.map((option) => /* @__PURE__ */ jsx("option", {
|
|
3649
|
-
value: option.value,
|
|
3650
|
-
children: option.label
|
|
3651
|
-
}, option.value))]
|
|
3652
|
-
})] });
|
|
3653
3622
|
}
|
|
3623
|
+
/** Array row title. Empty slug falls back to “Item”, never “Item 01”. */
|
|
3624
|
+
function adminNavEntityLabel(config, type, slug) {
|
|
3625
|
+
if (typeof slug !== "string" || !slug) return "Item";
|
|
3626
|
+
return adminNavEntityOptions(config, type).find((option) => option.value === slug)?.label ?? slug;
|
|
3627
|
+
}
|
|
3628
|
+
//#endregion
|
|
3629
|
+
//#region src/admin/admin-nav-item-row-label.tsx
|
|
3630
|
+
/**
|
|
3631
|
+
* Item accordion title. Shows the chosen collection or global name
|
|
3632
|
+
* (Pages), or “Item” when the row is still empty.
|
|
3633
|
+
*/
|
|
3634
|
+
function AdminNavItemRowLabel() {
|
|
3635
|
+
const { data } = useRowLabel();
|
|
3636
|
+
const { config } = useConfig();
|
|
3637
|
+
return /* @__PURE__ */ jsx("span", { children: adminNavEntityLabel(config, data.type, data.slug) });
|
|
3638
|
+
}
|
|
3639
|
+
//#endregion
|
|
3640
|
+
//#region src/admin/admin-nav-entity-field.tsx
|
|
3641
|
+
/**
|
|
3642
|
+
* Payload's select of collections or globals. Subscribes to sibling Type
|
|
3643
|
+
* with `useField` so the list updates when Type changes — `getDataByPath`
|
|
3644
|
+
* does not re-render this field.
|
|
3645
|
+
*/
|
|
3646
|
+
const AdminNavEntityField = ({ field, path, permissions, readOnly, schemaPath }) => {
|
|
3647
|
+
const { value: type } = useField({ path: path.replace(/\.slug$/, ".type") });
|
|
3648
|
+
const { config } = useConfig();
|
|
3649
|
+
const options = adminNavEntityOptions(config, type);
|
|
3650
|
+
return /* @__PURE__ */ jsx(SelectField, {
|
|
3651
|
+
field: {
|
|
3652
|
+
name: field.name,
|
|
3653
|
+
label: field.label,
|
|
3654
|
+
required: field.required,
|
|
3655
|
+
admin: {
|
|
3656
|
+
...field.admin,
|
|
3657
|
+
isClearable: false,
|
|
3658
|
+
isSortable: false,
|
|
3659
|
+
placeholder: "Select…"
|
|
3660
|
+
},
|
|
3661
|
+
type: "select",
|
|
3662
|
+
hasMany: false,
|
|
3663
|
+
options
|
|
3664
|
+
},
|
|
3665
|
+
path,
|
|
3666
|
+
permissions,
|
|
3667
|
+
readOnly,
|
|
3668
|
+
schemaPath
|
|
3669
|
+
});
|
|
3670
|
+
};
|
|
3654
3671
|
//#endregion
|
|
3655
|
-
export { AdminNav, AdminNavEntityField, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, PairingField, PublishChild, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, ThemeDocumentControls, ThemeSaveButton };
|
|
3672
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, PairingField, PublishChild, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, ThemeDocumentControls, ThemeSaveButton };
|
|
3656
3673
|
|
|
3657
3674
|
//# sourceMappingURL=admin.mjs.map
|