@bison-lab/payload-core 4.9.2 → 4.10.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/dist/admin.d.mts +3 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +31 -10
- package/dist/admin.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +17 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/admin.d.mts
CHANGED
|
@@ -265,7 +265,9 @@ declare function AdminNavItemRowLabel(): react_jsx_runtime0.JSX.Element;
|
|
|
265
265
|
/**
|
|
266
266
|
* Payload's select of collections or globals. Subscribes to sibling Type
|
|
267
267
|
* with `useField` so the list updates when Type changes — `getDataByPath`
|
|
268
|
-
* does not re-render this field.
|
|
268
|
+
* does not re-render this field. Offers only what Payload would paint for
|
|
269
|
+
* this login: the client config has no `admin.hidden`, so visibility
|
|
270
|
+
* comes from `useEntityVisibility`.
|
|
269
271
|
*/
|
|
270
272
|
declare const AdminNavEntityField: TextFieldClientComponent;
|
|
271
273
|
//#endregion
|
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/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,QAAA;EAAU;AAAA,GAAW,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;cCEhE,iBAAA,EAAmB,wBAAA;AAAA,iBAEhB,gBAAA,CAAA;EAAmB;AAAA,GAAW,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cCA1D,aAAA,EAAe,wBAAA;;;;;;;;cC8Cf,UAAA,EAAY,0BAAA;;;;;;;;cCpBZ,gBAAA,EAAkB,wBAAA;;;;;;;;;AvBxB/B;;cwB2Ca,mBAAA,EAAqB,yBAAA;;;;;;;;;AxB3ClC;cyBuJa,iBAAA,EAAmB,yBAAA;;;iBC5HhB,oBAAA,CAAA;EAAuB;AAAA;EAAc,QAAA,GAAW,SAAA;AAAA,IAAW,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;iBC/B3D,eAAA,CAAA;EAAkB,GAAA;EAAK;AAAA;EAAc,GAAA;EAAc,QAAA,GAAW,SAAA;AAAA,IAAW,kBAAA,CAAA,GAAA,CAAA,OAAA;;;iBCOzE,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;;;A9BGpB;;;iB8B6CgB,QAAA,CAAA;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
|
|
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,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;;;iB8B6CgB,QAAA,CAAA;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;;;;;;;;;AhCGpC;ciCCa,mBAAA,EAAqB,wBAAA;;;;;;;;AjCDlC;UkCFiB,cAAA;;EAEf,MAAA;ElCyED;EkCvEC,IAAA;;EAEA,KAAA;EjCmBW;EiCjBX,MAAA;AAAA;AAAA,UAGe,eAAA;EjCiEhB;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;;;iBCkH7B,aAAA,CAAc,KAAA,EAAO,mBAAA,GAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
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, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAuth, useBulkUpload, useConfig, useField, useForm, useFormFields, useListDrawerContext, useListQuery, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
3
|
+
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAuth, useBulkUpload, useConfig, useEntityVisibility, useField, useForm, useFormFields, useListDrawerContext, useListQuery, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
4
4
|
import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, regenerateColorScale, setColorScaleInclude, updateColorScale } 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";
|
|
@@ -4153,8 +4153,13 @@ function DocumentCreateNew({ path }) {
|
|
|
4153
4153
|
const ADMIN_NAV_SLUG = "admin-nav";
|
|
4154
4154
|
//#endregion
|
|
4155
4155
|
//#region src/admin-nav/resolve.ts
|
|
4156
|
-
|
|
4157
|
-
|
|
4156
|
+
/**
|
|
4157
|
+
* `group: false` and `hidden: true` are both "never on the sidebar".
|
|
4158
|
+
* A function `hidden` is per viewer and arrives as `visibleEntities`.
|
|
4159
|
+
*/
|
|
4160
|
+
function sidebarGroup(entity) {
|
|
4161
|
+
if (entity.admin?.group === false || entity.admin?.hidden === true) return false;
|
|
4162
|
+
const group = entity.admin?.group;
|
|
4158
4163
|
if (typeof group === "string") return group;
|
|
4159
4164
|
return "";
|
|
4160
4165
|
}
|
|
@@ -4173,13 +4178,13 @@ function catalog(config) {
|
|
|
4173
4178
|
type: "collection",
|
|
4174
4179
|
slug: entity.slug,
|
|
4175
4180
|
label: entityLabel(entity, "collection"),
|
|
4176
|
-
group: sidebarGroup(entity
|
|
4181
|
+
group: sidebarGroup(entity)
|
|
4177
4182
|
}));
|
|
4178
4183
|
const globals = (config.globals ?? []).map((entity) => ({
|
|
4179
4184
|
type: "global",
|
|
4180
4185
|
slug: entity.slug,
|
|
4181
4186
|
label: entityLabel(entity, "global"),
|
|
4182
|
-
group: sidebarGroup(entity
|
|
4187
|
+
group: sidebarGroup(entity)
|
|
4183
4188
|
}));
|
|
4184
4189
|
return [...collections, ...globals];
|
|
4185
4190
|
}
|
|
@@ -4364,12 +4369,25 @@ function entityType(type) {
|
|
|
4364
4369
|
return type === "global" ? "global" : "collection";
|
|
4365
4370
|
}
|
|
4366
4371
|
/**
|
|
4372
|
+
* `admin.hidden: true` is hidden for every login, so no sidebar can carry
|
|
4373
|
+
* it. A function `hidden` depends on the viewer and is left to
|
|
4374
|
+
* `visibleEntities`, which Payload evaluates per request.
|
|
4375
|
+
*/
|
|
4376
|
+
function isAlwaysHidden(entity) {
|
|
4377
|
+
return entity.admin?.group === false || entity.admin?.hidden === true;
|
|
4378
|
+
}
|
|
4379
|
+
/**
|
|
4367
4380
|
* Collections or globals a Developer may pin. Sibling Type decides which
|
|
4368
|
-
* list. `group: false`
|
|
4381
|
+
* list. `group: false` and `hidden: true` stay off — those entities are
|
|
4382
|
+
* not on the sidebar. `visibleEntities` (Payload's per-user list, from
|
|
4383
|
+
* `useEntityVisibility`) narrows it further when given: the client config
|
|
4384
|
+
* drops `admin.hidden`, so a function `hidden` is only known there.
|
|
4369
4385
|
*/
|
|
4370
|
-
function adminNavEntityOptions(config, type) {
|
|
4386
|
+
function adminNavEntityOptions(config, type, visibleEntities) {
|
|
4371
4387
|
const kind = entityType(type);
|
|
4372
|
-
|
|
4388
|
+
const entities = kind === "global" ? config.globals ?? [] : config.collections ?? [];
|
|
4389
|
+
const visible = visibleEntities ? new Set(kind === "global" ? visibleEntities.globals ?? [] : visibleEntities.collections ?? []) : null;
|
|
4390
|
+
return entities.filter((entity) => !isAlwaysHidden(entity)).filter((entity) => visible === null || visible.has(entity.slug)).map((entity) => ({
|
|
4373
4391
|
value: entity.slug,
|
|
4374
4392
|
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
|
|
4375
4393
|
}));
|
|
@@ -4395,12 +4413,15 @@ function AdminNavItemRowLabel() {
|
|
|
4395
4413
|
/**
|
|
4396
4414
|
* Payload's select of collections or globals. Subscribes to sibling Type
|
|
4397
4415
|
* with `useField` so the list updates when Type changes — `getDataByPath`
|
|
4398
|
-
* does not re-render this field.
|
|
4416
|
+
* does not re-render this field. Offers only what Payload would paint for
|
|
4417
|
+
* this login: the client config has no `admin.hidden`, so visibility
|
|
4418
|
+
* comes from `useEntityVisibility`.
|
|
4399
4419
|
*/
|
|
4400
4420
|
const AdminNavEntityField = ({ field, path, permissions, readOnly, schemaPath }) => {
|
|
4401
4421
|
const { value: type } = useField({ path: path.replace(/\.slug$/, ".type") });
|
|
4402
4422
|
const { config } = useConfig();
|
|
4403
|
-
const
|
|
4423
|
+
const { visibleEntities } = useEntityVisibility();
|
|
4424
|
+
const options = adminNavEntityOptions(config, type, visibleEntities);
|
|
4404
4425
|
return /* @__PURE__ */ jsx(SelectField, {
|
|
4405
4426
|
field: {
|
|
4406
4427
|
name: field.name,
|