@bison-lab/payload-core 5.10.0 → 5.13.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 +125 -10
- package/dist/admin-branding-CEKdfYah.mjs +178 -0
- package/dist/admin-branding-CEKdfYah.mjs.map +1 -0
- package/dist/admin-head-CcpH7P4C.mjs +187 -0
- package/dist/admin-head-CcpH7P4C.mjs.map +1 -0
- package/dist/admin-head-QfW81bDy.d.mts +63 -0
- package/dist/admin-head-QfW81bDy.d.mts.map +1 -0
- package/dist/admin-server.d.mts +52 -0
- package/dist/admin-server.d.mts.map +1 -0
- package/dist/admin-server.mjs +94 -0
- package/dist/admin-server.mjs.map +1 -0
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +97 -6
- package/dist/admin.mjs.map +1 -1
- package/dist/{alternates-DxBTUXHh.mjs → alternates-Tv5-ccza.mjs} +1 -1
- package/dist/{alternates-DxBTUXHh.mjs.map → alternates-Tv5-ccza.mjs.map} +1 -1
- package/dist/{alternates-DlRTsaVe.d.mts → alternates-aRncEUBI.d.mts} +1 -1
- package/dist/{alternates-DlRTsaVe.d.mts.map → alternates-aRncEUBI.d.mts.map} +1 -1
- package/dist/block-library.d.mts +1 -1
- package/dist/block-library.mjs +1 -1
- package/dist/{block-thumbnails-DC34uFtE.mjs → block-thumbnails-DvILqW_e.mjs} +1 -1
- package/dist/{block-thumbnails-DC34uFtE.mjs.map → block-thumbnails-DvILqW_e.mjs.map} +1 -1
- package/dist/block-thumbnails-cli.mjs +1 -1
- package/dist/block-thumbnails.mjs +1 -1
- package/dist/{capability-Kd5LgQpm.mjs → capability-B4FLx4OX.mjs} +4 -159
- package/dist/capability-B4FLx4OX.mjs.map +1 -0
- package/dist/{capability-NlorUIta.d.mts → capability-DonuHSPG.d.mts} +1 -1
- package/dist/{capability-NlorUIta.d.mts.map → capability-DonuHSPG.d.mts.map} +1 -1
- package/dist/{catalogue-CJ0RlTg4.d.mts → catalogue-tVovXWp9.d.mts} +1 -1
- package/dist/{catalogue-CJ0RlTg4.d.mts.map → catalogue-tVovXWp9.d.mts.map} +1 -1
- package/dist/{facet-field-DO3VT_Cz.mjs → facet-field-7p6_MhsT.mjs} +1 -1
- package/dist/{facet-field-DO3VT_Cz.mjs.map → facet-field-7p6_MhsT.mjs.map} +1 -1
- package/dist/{facet-field-Cd6lffed.d.mts → facet-field-Dbcu1L91.d.mts} +1 -1
- package/dist/{facet-field-Cd6lffed.d.mts.map → facet-field-Dbcu1L91.d.mts.map} +1 -1
- package/dist/{types-B1MmE-L3.d.mts → identity-B4Lew8Fu.d.mts} +40 -24
- package/dist/identity-B4Lew8Fu.d.mts.map +1 -0
- package/dist/{identity-CN6EOeDM.mjs → identity-CkUE_uN2.mjs} +11 -3
- package/dist/{identity-CN6EOeDM.mjs.map → identity-CkUE_uN2.mjs.map} +1 -1
- package/dist/index.d.mts +58 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +150 -60
- package/dist/index.mjs.map +1 -1
- package/dist/island-97l5VY8l.mjs.map +1 -1
- package/dist/languages-B_iiWwxE.mjs +179 -0
- package/dist/languages-B_iiWwxE.mjs.map +1 -0
- package/dist/languages-cDe9Lznx.d.mts +86 -0
- package/dist/languages-cDe9Lznx.d.mts.map +1 -0
- package/dist/{locale-tnKLkutC.d.mts → locale-CTT3nn6T.d.mts} +1 -1
- package/dist/locale-CTT3nn6T.d.mts.map +1 -0
- package/dist/{locale-B6rUVwpg.mjs → locale-DaEJ1d2O.mjs} +1 -1
- package/dist/{locale-B6rUVwpg.mjs.map → locale-DaEJ1d2O.mjs.map} +1 -1
- package/dist/locale-routing.d.mts +129 -0
- package/dist/locale-routing.d.mts.map +1 -0
- package/dist/locale-routing.mjs +256 -0
- package/dist/locale-routing.mjs.map +1 -0
- package/dist/lookup-DiOCro-_.mjs +165 -0
- package/dist/lookup-DiOCro-_.mjs.map +1 -0
- package/dist/lookup-uyEKHlLX.d.mts +41 -0
- package/dist/lookup-uyEKHlLX.d.mts.map +1 -0
- package/dist/{messages-XFoL9RtF.mjs → messages-Bv6JIEiG.mjs} +2 -2
- package/dist/{messages-XFoL9RtF.mjs.map → messages-Bv6JIEiG.mjs.map} +1 -1
- package/dist/metadata.d.mts +2 -2
- package/dist/metadata.mjs +1 -1
- package/dist/navigation.d.mts +2 -2
- package/dist/navigation.mjs +1 -1
- package/dist/og.d.mts +2 -2
- package/dist/og.mjs +2 -2
- package/dist/{preview-Br1SQCKn.mjs → preview-BE7P1ezl.mjs} +5 -120
- package/dist/preview-BE7P1ezl.mjs.map +1 -0
- package/dist/{preview-B69Dhi8T.d.mts → preview-DSQN4uYa.d.mts} +2 -2
- package/dist/{preview-B69Dhi8T.d.mts.map → preview-DSQN4uYa.d.mts.map} +1 -1
- package/dist/{published-Vu_QX2Vv.mjs → published-BF2F3od_.mjs} +2 -2
- package/dist/{published-Vu_QX2Vv.mjs.map → published-BF2F3od_.mjs.map} +1 -1
- package/dist/{published-hqtvmVUD.mjs → published-BzihgcSf.mjs} +1 -1
- package/dist/{published-hqtvmVUD.mjs.map → published-BzihgcSf.mjs.map} +1 -1
- package/dist/{published-B80KqlcU.mjs → published-C8bW5jvC.mjs} +3 -3
- package/dist/{published-B80KqlcU.mjs.map → published-C8bW5jvC.mjs.map} +1 -1
- package/dist/{published-2I-k6zEo.d.mts → published-DYpXTy84.d.mts} +3 -3
- package/dist/{published-2I-k6zEo.d.mts.map → published-DYpXTy84.d.mts.map} +1 -1
- package/dist/{published-BhYTEAK_.d.mts → published-VTz_aYaQ.d.mts} +2 -2
- package/dist/{published-BhYTEAK_.d.mts.map → published-VTz_aYaQ.d.mts.map} +1 -1
- package/dist/{root-page-key-kx3C1eyp.mjs → root-page-key-ywNz2k4L.mjs} +1 -1
- package/dist/{root-page-key-kx3C1eyp.mjs.map → root-page-key-ywNz2k4L.mjs.map} +1 -1
- package/dist/seo.d.mts +1 -1
- package/dist/seo.mjs +2 -2
- package/dist/{strings-Fd7kUCT7.mjs → strings-_9n8BefX.mjs} +1 -1
- package/dist/{strings-Fd7kUCT7.mjs.map → strings-_9n8BefX.mjs.map} +1 -1
- package/dist/taxonomy.d.mts +1 -1
- package/dist/taxonomy.mjs +1 -1
- package/dist/theme.d.mts +6 -5
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +6 -63
- package/dist/{title-BVV3o329.d.mts → title-DBSLJfrW.d.mts} +1 -1
- package/dist/{title-BVV3o329.d.mts.map → title-DBSLJfrW.d.mts.map} +1 -1
- package/dist/translate-messages-cli.mjs +2 -2
- package/dist/translate.d.mts +2 -77
- package/dist/translate.d.mts.map +1 -1
- package/dist/translate.mjs +4 -3
- package/dist/translate.mjs.map +1 -1
- package/dist/{wireframe-Ba65SOj8.mjs → wireframe-DjPHSACa.mjs} +1 -1
- package/dist/{wireframe-Ba65SOj8.mjs.map → wireframe-DjPHSACa.mjs.map} +1 -1
- package/dist/wireframe-cli.mjs +1 -1
- package/dist/wireframe.mjs +1 -1
- package/package.json +13 -5
- package/dist/capability-Kd5LgQpm.mjs.map +0 -1
- package/dist/locale-tnKLkutC.d.mts.map +0 -1
- package/dist/preview-Br1SQCKn.mjs.map +0 -1
- package/dist/theme.mjs.map +0 -1
- package/dist/types-B1MmE-L3.d.mts.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { g as ThemeHead, n as ThemeIdentityAsset, t as ResolvedThemeIdentity } from "./identity-B4Lew8Fu.mjs";
|
|
2
|
+
import { t as ThemePayload } from "./published-DYpXTy84.mjs";
|
|
3
|
+
import { ThemeConfig } from "@bison-lab/tokens";
|
|
4
|
+
|
|
5
|
+
//#region src/theme/admin-head.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The `payload` a server component gets: the Theme reader plus the
|
|
8
|
+
* sanitized config, where `createTheme` left the identity fallback.
|
|
9
|
+
*/
|
|
10
|
+
interface AdminBrandingPayload extends ThemePayload {
|
|
11
|
+
config: {
|
|
12
|
+
globals?: readonly {
|
|
13
|
+
slug: string;
|
|
14
|
+
admin?: {
|
|
15
|
+
custom?: Record<string, unknown>;
|
|
16
|
+
} | null;
|
|
17
|
+
}[] | null;
|
|
18
|
+
};
|
|
19
|
+
logger?: {
|
|
20
|
+
error: (details: {
|
|
21
|
+
err: unknown;
|
|
22
|
+
msg: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
interface AdminHeadOptions {
|
|
27
|
+
/** Where the site's `serveFont` route answers. Default `"/fonts"`. */
|
|
28
|
+
fontsBaseUrl?: string;
|
|
29
|
+
/** Default `"data-theme"`: the attribute Payload flips on `<html>` for its own dark mode. */
|
|
30
|
+
attribute?: "class" | "data-theme";
|
|
31
|
+
}
|
|
32
|
+
interface AdminHeadData extends Pick<ThemeHead, "css" | "preloads"> {
|
|
33
|
+
/** The Theme favicon (upload, else the fallback), or `null` to keep Payload's. */
|
|
34
|
+
favicon: ThemeIdentityAsset | null;
|
|
35
|
+
identity: ResolvedThemeIdentity;
|
|
36
|
+
}
|
|
37
|
+
/** Uploaded logo, dark logo, mark and favicon, else the Theme Global's fallback. */
|
|
38
|
+
declare function getAdminIdentity(payload: AdminBrandingPayload): Promise<ResolvedThemeIdentity>;
|
|
39
|
+
/**
|
|
40
|
+
* The login and auth-screen stylesheet. Every auth screen (login, forgot
|
|
41
|
+
* password, reset password, create first user, unauthorized) renders
|
|
42
|
+
* through Payload's MinimalTemplate, and reset has no custom-view hook, so
|
|
43
|
+
* this is all CSS on `.template-minimal`. Colors are Theme variables
|
|
44
|
+
* (`--primary` and its 50–950 scale), so the rules never change: the
|
|
45
|
+
* Theme `<style>` beside them does. Forgot and reset have no logo slot,
|
|
46
|
+
* so the logo reaches them as a pseudo-element; login has its own
|
|
47
|
+
* (`graphics.Logo`).
|
|
48
|
+
*
|
|
49
|
+
* In `@layer payload`, which Payload declares after its own
|
|
50
|
+
* `payload-default`, so these win on layer order, not specificity.
|
|
51
|
+
*/
|
|
52
|
+
declare function adminAuthCss(identity: ResolvedThemeIdentity): string;
|
|
53
|
+
/**
|
|
54
|
+
* Everything the admin `<head>` needs from the Theme, read once per
|
|
55
|
+
* request: the Theme stylesheet (`themeHeadFromDoc`, dark palette on
|
|
56
|
+
* `[data-theme="dark"]`), the auth-screen rules after it, the font
|
|
57
|
+
* preloads, and the favicon. No cache, so a Theme save shows on the next
|
|
58
|
+
* request. `AdminHead` in `@bison-lab/payload-core/admin-server` renders it.
|
|
59
|
+
*/
|
|
60
|
+
declare function getAdminHead(payload: AdminBrandingPayload, seed: ThemeConfig, options?: AdminHeadOptions): Promise<AdminHeadData>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { getAdminHead as a, adminAuthCss as i, AdminHeadData as n, getAdminIdentity as o, AdminHeadOptions as r, AdminBrandingPayload as t };
|
|
63
|
+
//# sourceMappingURL=admin-head-QfW81bDy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-head-QfW81bDy.d.mts","names":[],"sources":["../src/theme/admin-head.ts"],"mappings":";;;;;;AAgBA;;;UAAiB,oBAAA,SAA6B,YAAA;EAC5C,MAAA;IACE,OAAA;MAEM,IAAA;MACA,KAAA;QAAU,MAAA,GAAS,MAAA;MAAA;IAAA;EAAA;EAI3B,MAAA;IAAW,KAAA,GAAQ,OAAA;MAAW,GAAA;MAAc,GAAA;IAAA;EAAA;AAAA;AAAA,UAG7B,gBAAA;;EAEf,YAAA;EAES;EAAT,SAAA;AAAA;AAAA,UAGe,aAAA,SAAsB,IAAA,CAAK,SAAA;EAAA;EAE1C,OAAA,EAAS,kBAAA;EACT,QAAA,EAAU,qBAAA;AAAA;;iBA+BU,gBAAA,CACpB,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,qBAAA;;;;;;;;;AAFX;;;;;iBAsCgB,YAAA,CAAa,QAAA,EAAU,qBAAA;;;;;;;;iBAsEjB,YAAA,CACpB,OAAA,EAAS,oBAAA,EACT,IAAA,EAAM,WAAA,EACN,OAAA,GAAS,gBAAA,GACR,OAAA,CAAQ,aAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { r as AdminHeadOptions, t as AdminBrandingPayload } from "./admin-head-QfW81bDy.mjs";
|
|
2
|
+
import { ThemeConfig } from "@bison-lab/tokens";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/admin-server.d.ts
|
|
6
|
+
interface AdminGraphicProps {
|
|
7
|
+
/**
|
|
8
|
+
* Payload passes it to the admin's server components, but not everywhere
|
|
9
|
+
* it renders the graphics: the admin Open Graph image route
|
|
10
|
+
* (`@payloadcms/next` routes/rest/og) renders `graphics.Icon` with only
|
|
11
|
+
* `clientProps: { fill: "white" }`. Without it, Payload's own graphic.
|
|
12
|
+
*/
|
|
13
|
+
payload?: AdminBrandingPayload;
|
|
14
|
+
/** Passed through to Payload's icon; the OG image route asks for `"white"`. */
|
|
15
|
+
fill?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `graphics.Logo`, on the login screen: the Theme logo (and dark logo),
|
|
19
|
+
* else the Theme Global's identity fallback, else Payload's own.
|
|
20
|
+
*/
|
|
21
|
+
declare function AdminLogo({
|
|
22
|
+
payload
|
|
23
|
+
}: AdminGraphicProps): Promise<react_jsx_runtime0.JSX.Element>;
|
|
24
|
+
/**
|
|
25
|
+
* `graphics.Icon`, in the admin header: the Theme mobile menu logo
|
|
26
|
+
* (`logoMark`), else the fallback mark, else Payload's own.
|
|
27
|
+
*/
|
|
28
|
+
declare function AdminIcon({
|
|
29
|
+
payload,
|
|
30
|
+
fill
|
|
31
|
+
}: AdminGraphicProps): Promise<react_jsx_runtime0.JSX.Element>;
|
|
32
|
+
interface AdminHeadProps extends AdminHeadOptions {
|
|
33
|
+
payload: AdminBrandingPayload;
|
|
34
|
+
/** The site's `bison.config.json`, as passed to `createTheme`. */
|
|
35
|
+
seed: ThemeConfig;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The admin `<head>` from the published Theme: font preloads, the favicon
|
|
39
|
+
* link, and one `<style>` holding the Theme variables and the login,
|
|
40
|
+
* forgot and reset screen rules. Rendered by the site's
|
|
41
|
+
* `(payload)/layout.tsx` inside `RootLayout`; React hoists the links into
|
|
42
|
+
* `<head>`. It reads on every request, so a Theme save shows on the next
|
|
43
|
+
* one with no deploy.
|
|
44
|
+
*/
|
|
45
|
+
declare function AdminHead({
|
|
46
|
+
payload,
|
|
47
|
+
seed,
|
|
48
|
+
...options
|
|
49
|
+
}: AdminHeadProps): Promise<react_jsx_runtime0.JSX.Element>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { type AdminBrandingPayload, AdminGraphicProps, AdminHead, type AdminHeadOptions, AdminHeadProps, AdminIcon, AdminLogo };
|
|
52
|
+
//# sourceMappingURL=admin-server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-server.d.mts","names":[],"sources":["../src/admin-server.tsx"],"mappings":";;;;;UA2BiB,iBAAA;EASf;;;AA6BF;;;EA/BE,OAAA,GAAU,oBAAA;EA+BiC;EA7B3C,IAAA;AAAA;;;;;iBA6BoB,SAAA,CAAA;EAAY;AAAA,GAAW,iBAAA,GAAiB,OAAA,CAAA,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;iBA4BxC,SAAA,CAAA;EAAY,OAAA;EAAS;AAAA,GAAQ,iBAAA,GAAiB,OAAA,CAAA,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,UAYnD,cAAA,SAAuB,gBAAA;EACtC,OAAA,EAAS,oBAAA;;EAET,IAAA,EAAM,WAAA;AAAA;;;;;;;;;iBAWc,SAAA,CAAA;EAAY,OAAA;EAAS,IAAA;EAAA,GAAS;AAAA,GAAW,cAAA,GAAc,OAAA,CAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import "./identity-CkUE_uN2.mjs";
|
|
2
|
+
import "./admin-branding-CEKdfYah.mjs";
|
|
3
|
+
import { n as getAdminHead, r as getAdminIdentity } from "./admin-head-CcpH7P4C.mjs";
|
|
4
|
+
import { PayloadIcon, PayloadLogo } from "@payloadcms/ui/shared";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/admin-server.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The light logo shows until Payload's `<html data-theme="dark">`; then the
|
|
9
|
+
* dark logo, when there is one, takes its place. A single image cannot
|
|
10
|
+
* flip with the theme, hence two.
|
|
11
|
+
*/
|
|
12
|
+
const GRAPHICS_CSS = `
|
|
13
|
+
.bl-admin-logo{display:inline-flex;max-width:100%}
|
|
14
|
+
.bl-admin-logo img{display:block;width:auto;height:auto;max-width:min(100%,16rem);max-height:5rem}
|
|
15
|
+
.bl-admin-logo .bl-admin-logo__dark{display:none}
|
|
16
|
+
[data-theme="dark"] .bl-admin-logo--has-dark .bl-admin-logo__light{display:none}
|
|
17
|
+
[data-theme="dark"] .bl-admin-logo .bl-admin-logo__dark{display:block}
|
|
18
|
+
.bl-admin-icon{display:block;width:100%;height:100%;object-fit:contain}
|
|
19
|
+
`;
|
|
20
|
+
function GraphicsStyles() {
|
|
21
|
+
return /* @__PURE__ */ jsx("style", {
|
|
22
|
+
href: "bl-admin-graphics",
|
|
23
|
+
precedence: "default",
|
|
24
|
+
children: GRAPHICS_CSS
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `graphics.Logo`, on the login screen: the Theme logo (and dark logo),
|
|
29
|
+
* else the Theme Global's identity fallback, else Payload's own.
|
|
30
|
+
*/
|
|
31
|
+
async function AdminLogo({ payload }) {
|
|
32
|
+
if (!payload) return /* @__PURE__ */ jsx(PayloadLogo, {});
|
|
33
|
+
const { lockup, lockupDark } = await getAdminIdentity(payload);
|
|
34
|
+
if (!lockup) return /* @__PURE__ */ jsx(PayloadLogo, {});
|
|
35
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
36
|
+
className: lockupDark ? "bl-admin-logo bl-admin-logo--has-dark" : "bl-admin-logo",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx(GraphicsStyles, {}),
|
|
39
|
+
/* @__PURE__ */ jsx("img", {
|
|
40
|
+
className: "bl-admin-logo__light",
|
|
41
|
+
src: lockup.url,
|
|
42
|
+
alt: lockup.alt
|
|
43
|
+
}),
|
|
44
|
+
lockupDark ? /* @__PURE__ */ jsx("img", {
|
|
45
|
+
className: "bl-admin-logo__dark",
|
|
46
|
+
src: lockupDark.url,
|
|
47
|
+
alt: lockupDark.alt
|
|
48
|
+
}) : null
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `graphics.Icon`, in the admin header: the Theme mobile menu logo
|
|
54
|
+
* (`logoMark`), else the fallback mark, else Payload's own.
|
|
55
|
+
*/
|
|
56
|
+
async function AdminIcon({ payload, fill }) {
|
|
57
|
+
if (!payload) return /* @__PURE__ */ jsx(PayloadIcon, { fill });
|
|
58
|
+
const { mark } = await getAdminIdentity(payload);
|
|
59
|
+
if (!mark) return /* @__PURE__ */ jsx(PayloadIcon, { fill });
|
|
60
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(GraphicsStyles, {}), /* @__PURE__ */ jsx("img", {
|
|
61
|
+
className: "bl-admin-icon",
|
|
62
|
+
src: mark.url,
|
|
63
|
+
alt: mark.alt
|
|
64
|
+
})] });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The admin `<head>` from the published Theme: font preloads, the favicon
|
|
68
|
+
* link, and one `<style>` holding the Theme variables and the login,
|
|
69
|
+
* forgot and reset screen rules. Rendered by the site's
|
|
70
|
+
* `(payload)/layout.tsx` inside `RootLayout`; React hoists the links into
|
|
71
|
+
* `<head>`. It reads on every request, so a Theme save shows on the next
|
|
72
|
+
* one with no deploy.
|
|
73
|
+
*/
|
|
74
|
+
async function AdminHead({ payload, seed, ...options }) {
|
|
75
|
+
const head = await getAdminHead(payload, seed, options);
|
|
76
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
77
|
+
head.preloads.map(({ href, type }) => /* @__PURE__ */ jsx("link", {
|
|
78
|
+
rel: "preload",
|
|
79
|
+
as: "font",
|
|
80
|
+
type,
|
|
81
|
+
href,
|
|
82
|
+
crossOrigin: ""
|
|
83
|
+
}, href)),
|
|
84
|
+
head.favicon ? /* @__PURE__ */ jsx("link", {
|
|
85
|
+
rel: "icon",
|
|
86
|
+
href: head.favicon.url
|
|
87
|
+
}) : null,
|
|
88
|
+
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: head.css } })
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { AdminHead, AdminIcon, AdminLogo };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=admin-server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-server.mjs","names":[],"sources":["../src/admin-server.tsx"],"sourcesContent":["/**\n * Admin server components: the Theme-branded admin graphics and head.\n *\n * No `\"use client\"` banner: every export is a Server Component that reads\n * the Theme with `payload` before it renders. `AdminLogo` and `AdminIcon`\n * are referenced by path string (`ADMIN_LOGO`, `ADMIN_ICON`, which\n * `adminNav()` sets unless the site has its own) and `payload\n * generate:importmap` writes the import. `AdminHead` is the one a site\n * renders itself, in `(payload)/layout.tsx`.\n */\n\nimport type { ThemeConfig } from \"@bison-lab/tokens\";\n\n// Payload's own graphics from its unbannered `shared` subpath, as\n// `@payloadcms/next`'s own Logo element takes them. Not through `./admin`:\n// Payload's OG image route calls graphics.Icon from a route handler,\n// outside the client boundary, where a `\"use client\"` export is a stub\n// that throws.\nimport { PayloadIcon, PayloadLogo } from \"@payloadcms/ui/shared\";\n\nimport {\n getAdminHead,\n getAdminIdentity,\n type AdminBrandingPayload,\n type AdminHeadOptions,\n} from \"./theme/admin-head\";\n\nexport interface AdminGraphicProps {\n /**\n * Payload passes it to the admin's server components, but not everywhere\n * it renders the graphics: the admin Open Graph image route\n * (`@payloadcms/next` routes/rest/og) renders `graphics.Icon` with only\n * `clientProps: { fill: \"white\" }`. Without it, Payload's own graphic.\n */\n payload?: AdminBrandingPayload;\n /** Passed through to Payload's icon; the OG image route asks for `\"white\"`. */\n fill?: string;\n}\n\n/**\n * The light logo shows until Payload's `<html data-theme=\"dark\">`; then the\n * dark logo, when there is one, takes its place. A single image cannot\n * flip with the theme, hence two.\n */\nconst GRAPHICS_CSS = `\n.bl-admin-logo{display:inline-flex;max-width:100%}\n.bl-admin-logo img{display:block;width:auto;height:auto;max-width:min(100%,16rem);max-height:5rem}\n.bl-admin-logo .bl-admin-logo__dark{display:none}\n[data-theme=\"dark\"] .bl-admin-logo--has-dark .bl-admin-logo__light{display:none}\n[data-theme=\"dark\"] .bl-admin-logo .bl-admin-logo__dark{display:block}\n.bl-admin-icon{display:block;width:100%;height:100%;object-fit:contain}\n`;\n\nfunction GraphicsStyles() {\n return (\n <style href=\"bl-admin-graphics\" precedence=\"default\">\n {GRAPHICS_CSS}\n </style>\n );\n}\n\n/**\n * `graphics.Logo`, on the login screen: the Theme logo (and dark logo),\n * else the Theme Global's identity fallback, else Payload's own.\n */\nexport async function AdminLogo({ payload }: AdminGraphicProps) {\n if (!payload) return <PayloadLogo />;\n const identity = await getAdminIdentity(payload);\n const { lockup, lockupDark } = identity;\n if (!lockup) return <PayloadLogo />;\n return (\n <span\n className={\n lockupDark ? \"bl-admin-logo bl-admin-logo--has-dark\" : \"bl-admin-logo\"\n }\n >\n <GraphicsStyles />\n <img className=\"bl-admin-logo__light\" src={lockup.url} alt={lockup.alt} />\n {lockupDark ? (\n <img\n className=\"bl-admin-logo__dark\"\n src={lockupDark.url}\n alt={lockupDark.alt}\n />\n ) : null}\n </span>\n );\n}\n\n/**\n * `graphics.Icon`, in the admin header: the Theme mobile menu logo\n * (`logoMark`), else the fallback mark, else Payload's own.\n */\nexport async function AdminIcon({ payload, fill }: AdminGraphicProps) {\n if (!payload) return <PayloadIcon fill={fill} />;\n const { mark } = await getAdminIdentity(payload);\n if (!mark) return <PayloadIcon fill={fill} />;\n return (\n <>\n <GraphicsStyles />\n <img className=\"bl-admin-icon\" src={mark.url} alt={mark.alt} />\n </>\n );\n}\n\nexport interface AdminHeadProps extends AdminHeadOptions {\n payload: AdminBrandingPayload;\n /** The site's `bison.config.json`, as passed to `createTheme`. */\n seed: ThemeConfig;\n}\n\n/**\n * The admin `<head>` from the published Theme: font preloads, the favicon\n * link, and one `<style>` holding the Theme variables and the login,\n * forgot and reset screen rules. Rendered by the site's\n * `(payload)/layout.tsx` inside `RootLayout`; React hoists the links into\n * `<head>`. It reads on every request, so a Theme save shows on the next\n * one with no deploy.\n */\nexport async function AdminHead({ payload, seed, ...options }: AdminHeadProps) {\n const head = await getAdminHead(payload, seed, options);\n return (\n <>\n {head.preloads.map(({ href, type }) => (\n <link\n key={href}\n rel=\"preload\"\n as=\"font\"\n type={type}\n href={href}\n crossOrigin=\"\"\n />\n ))}\n {head.favicon ? <link rel=\"icon\" href={head.favicon.url} /> : null}\n <style dangerouslySetInnerHTML={{ __html: head.css }} />\n </>\n );\n}\n\nexport type { AdminBrandingPayload, AdminHeadOptions };\n"],"mappings":";;;;;;;;;;;AA4CA,MAAM,eAAe;;;;;;;;AASrB,SAAS,iBAAiB;AACxB,QACE,oBAAC,SAAD;EAAO,MAAK;EAAoB,YAAW;YACxC;EACK,CAAA;;;;;;AAQZ,eAAsB,UAAU,EAAE,WAA8B;AAC9D,KAAI,CAAC,QAAS,QAAO,oBAAC,aAAD,EAAe,CAAA;CAEpC,MAAM,EAAE,QAAQ,eADC,MAAM,iBAAiB,QAAQ;AAEhD,KAAI,CAAC,OAAQ,QAAO,oBAAC,aAAD,EAAe,CAAA;AACnC,QACE,qBAAC,QAAD;EACE,WACE,aAAa,0CAA0C;YAF3D;GAKE,oBAAC,gBAAD,EAAkB,CAAA;GAClB,oBAAC,OAAD;IAAK,WAAU;IAAuB,KAAK,OAAO;IAAK,KAAK,OAAO;IAAO,CAAA;GACzE,aACC,oBAAC,OAAD;IACE,WAAU;IACV,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,CAAA,GACA;GACC;;;;;;;AAQX,eAAsB,UAAU,EAAE,SAAS,QAA2B;AACpE,KAAI,CAAC,QAAS,QAAO,oBAAC,aAAD,EAAmB,MAAQ,CAAA;CAChD,MAAM,EAAE,SAAS,MAAM,iBAAiB,QAAQ;AAChD,KAAI,CAAC,KAAM,QAAO,oBAAC,aAAD,EAAmB,MAAQ,CAAA;AAC7C,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,gBAAD,EAAkB,CAAA,EAClB,oBAAC,OAAD;EAAK,WAAU;EAAgB,KAAK,KAAK;EAAK,KAAK,KAAK;EAAO,CAAA,CAC9D,EAAA,CAAA;;;;;;;;;;AAkBP,eAAsB,UAAU,EAAE,SAAS,MAAM,GAAG,WAA2B;CAC7E,MAAM,OAAO,MAAM,aAAa,SAAS,MAAM,QAAQ;AACvD,QACE,qBAAA,UAAA,EAAA,UAAA;EACG,KAAK,SAAS,KAAK,EAAE,MAAM,WAC1B,oBAAC,QAAD;GAEE,KAAI;GACJ,IAAG;GACG;GACA;GACN,aAAY;GACZ,EANK,KAML,CACF;EACD,KAAK,UAAU,oBAAC,QAAD;GAAM,KAAI;GAAO,MAAM,KAAK,QAAQ;GAAO,CAAA,GAAG;EAC9D,oBAAC,SAAD,EAAO,yBAAyB,EAAE,QAAQ,KAAK,KAAK,EAAI,CAAA;EACvD,EAAA,CAAA"}
|
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-cell.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/features/types.ts","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/refused-submit.tsx","../src/admin/list-align-styles.tsx","../src/admin/block-drawer-styles.tsx","../src/admin/rich-text-editor-font-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/taxonomy/facet-field.ts","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx","../src/admin/translate-now.tsx","../src/admin/translation-key-panel.tsx","../src/admin/translation-activity-panel.tsx","../src/admin/translation-status-bar.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;;;
|
|
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-cell.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/features/types.ts","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/refused-submit.tsx","../src/admin/list-align-styles.tsx","../src/admin/block-drawer-styles.tsx","../src/admin/rich-text-editor-font-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/taxonomy/facet-field.ts","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx","../src/admin/translate-now.tsx","../src/admin/translation-key-panel.tsx","../src/admin/translation-activity-panel.tsx","../src/admin/translation-status-bar.tsx"],"mappings":"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"}
|
package/dist/admin.mjs
CHANGED
|
@@ -2239,6 +2239,7 @@ function themeChildChanges(child, published, incoming) {
|
|
|
2239
2239
|
});
|
|
2240
2240
|
const lines = [];
|
|
2241
2241
|
if (uploadId(published.logo) !== uploadId(incoming.logo)) lines.push("Logo updated");
|
|
2242
|
+
if (uploadId(published.logoDark) !== uploadId(incoming.logoDark)) lines.push("Dark logo updated");
|
|
2242
2243
|
if (uploadId(published.favicon) !== uploadId(incoming.favicon)) lines.push("Favicon updated");
|
|
2243
2244
|
if (uploadId(published.logoMark) !== uploadId(incoming.logoMark)) lines.push("Mobile menu logo updated");
|
|
2244
2245
|
return lines;
|
|
@@ -2385,6 +2386,7 @@ function formDoc(fields) {
|
|
|
2385
2386
|
density: fields["appearance.density"]?.value
|
|
2386
2387
|
},
|
|
2387
2388
|
logo: fields.logo?.value,
|
|
2389
|
+
logoDark: fields.logoDark?.value,
|
|
2388
2390
|
favicon: fields.favicon?.value,
|
|
2389
2391
|
logoMark: fields.logoMark?.value
|
|
2390
2392
|
};
|
|
@@ -3168,10 +3170,11 @@ function isRootPageKey(value) {
|
|
|
3168
3170
|
return value === "/";
|
|
3169
3171
|
}
|
|
3170
3172
|
//#endregion
|
|
3171
|
-
//#region src/fields/slug.ts
|
|
3172
|
-
/**
|
|
3173
|
-
|
|
3174
|
-
|
|
3173
|
+
//#region src/fields/slug-normalize.ts
|
|
3174
|
+
/**
|
|
3175
|
+
* The slug text rules, apart from the field so the proxy's Redirects lookup
|
|
3176
|
+
* (`./locale-routing`) can use them without loading Payload.
|
|
3177
|
+
*/
|
|
3175
3178
|
/** One address segment from typed text: NFKD, lowercase, hyphenated, no slashes. */
|
|
3176
3179
|
function slugifySegment(segment) {
|
|
3177
3180
|
return segment.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -3183,6 +3186,11 @@ function slugifySegment(segment) {
|
|
|
3183
3186
|
function normalizeSlug(value) {
|
|
3184
3187
|
return value.split("/").map(slugifySegment).filter(Boolean).join("/");
|
|
3185
3188
|
}
|
|
3189
|
+
//#endregion
|
|
3190
|
+
//#region src/fields/slug.ts
|
|
3191
|
+
/** Sentinel the Parent control writes while the editor is naming a new folder. */
|
|
3192
|
+
const NEW_FOLDER_PARENT = "__new__";
|
|
3193
|
+
const SLUG_UNLOCK_WARNING = "This page is live. Changing the address will send visitors from the old URL to the new one.";
|
|
3186
3194
|
/** The folder prefix Parent stores. `__new__` resolves through `newFolder`. */
|
|
3187
3195
|
function parentPrefix(parent, newFolder) {
|
|
3188
3196
|
if (parent === "__new__") return normalizeSlug(newFolder ?? "");
|
|
@@ -4837,6 +4845,15 @@ function ThemeKitAccent({ children }) {
|
|
|
4837
4845
|
* collection / global share one lift. A MutationObserver re-applies
|
|
4838
4846
|
* after Payload redraws the controls.
|
|
4839
4847
|
*
|
|
4848
|
+
* The lifted nodes still belong to Payload's React tree, which keeps
|
|
4849
|
+
* updating them in place. React also expects them under the parent it
|
|
4850
|
+
* rendered them into: inserting a sibling before one, or removing one,
|
|
4851
|
+
* would throw `NotFoundError` and unmount the controls, leaving a frozen
|
|
4852
|
+
* copy on the title row (#354). So each lift leaves a comment where the
|
|
4853
|
+
* node was and guards that one parent (see `guardParent`), never
|
|
4854
|
+
* `Node.prototype`. A comment does not stop `.doc-controls__meta:empty`
|
|
4855
|
+
* matching, so the empty band still collapses.
|
|
4856
|
+
*
|
|
4840
4857
|
* It also carries `RefusedSubmitProvider`, so a refused publish keeps its
|
|
4841
4858
|
* field errors and stays publishable (#357).
|
|
4842
4859
|
*/
|
|
@@ -4856,6 +4873,77 @@ const TITLE_ACTIONS_CSS = `
|
|
|
4856
4873
|
const TITLE_ROW_CLASS = "bl-doc-title-row";
|
|
4857
4874
|
const STATUS = ".doc-controls__status";
|
|
4858
4875
|
const ACTIONS = ".doc-controls__controls-wrapper";
|
|
4876
|
+
/** The comment a lift leaves at a lifted node's place in React's parent. */
|
|
4877
|
+
const placeholders = /* @__PURE__ */ new WeakMap();
|
|
4878
|
+
const guardedParents = /* @__PURE__ */ new WeakSet();
|
|
4879
|
+
/** The placeholder of `node` when it was lifted out of `parent`. */
|
|
4880
|
+
function placeholderIn(parent, node) {
|
|
4881
|
+
const mark = node ? placeholders.get(node) : void 0;
|
|
4882
|
+
return mark && mark.parentNode === parent && node?.parentNode !== parent ? mark : null;
|
|
4883
|
+
}
|
|
4884
|
+
/**
|
|
4885
|
+
* Teaches one parent the lift moved a node out of to answer React as if
|
|
4886
|
+
* the node were still there: an insert before it lands at its
|
|
4887
|
+
* placeholder, moving it moves the placeholder (the node stays on the
|
|
4888
|
+
* title row), and removing it removes both, wherever the node now sits.
|
|
4889
|
+
* Every other call goes through untouched. `moveBefore` is not guarded:
|
|
4890
|
+
* react-dom 19.2 never calls it.
|
|
4891
|
+
*/
|
|
4892
|
+
function guardParent(parent) {
|
|
4893
|
+
if (guardedParents.has(parent)) return;
|
|
4894
|
+
guardedParents.add(parent);
|
|
4895
|
+
const insertBefore = parent.insertBefore;
|
|
4896
|
+
const appendChild = parent.appendChild;
|
|
4897
|
+
const removeChild = parent.removeChild;
|
|
4898
|
+
parent.insertBefore = function(node, child) {
|
|
4899
|
+
const ref = placeholderIn(parent, child) ?? child;
|
|
4900
|
+
const mark = placeholderIn(parent, node);
|
|
4901
|
+
if (mark) {
|
|
4902
|
+
if (mark !== ref) insertBefore.call(parent, mark, ref);
|
|
4903
|
+
return node;
|
|
4904
|
+
}
|
|
4905
|
+
return insertBefore.call(parent, node, ref);
|
|
4906
|
+
};
|
|
4907
|
+
parent.appendChild = function(node) {
|
|
4908
|
+
const mark = placeholderIn(parent, node);
|
|
4909
|
+
if (mark) {
|
|
4910
|
+
appendChild.call(parent, mark);
|
|
4911
|
+
return node;
|
|
4912
|
+
}
|
|
4913
|
+
return appendChild.call(parent, node);
|
|
4914
|
+
};
|
|
4915
|
+
parent.removeChild = function(child) {
|
|
4916
|
+
const mark = placeholderIn(parent, child);
|
|
4917
|
+
if (mark) {
|
|
4918
|
+
removeChild.call(parent, mark);
|
|
4919
|
+
placeholders.delete(child);
|
|
4920
|
+
child.parentNode?.removeChild(child);
|
|
4921
|
+
return child;
|
|
4922
|
+
}
|
|
4923
|
+
return removeChild.call(parent, child);
|
|
4924
|
+
};
|
|
4925
|
+
}
|
|
4926
|
+
/** Moves `node` into `group`, leaving a guarded placeholder where it was. */
|
|
4927
|
+
function lift(group, node, before) {
|
|
4928
|
+
const parent = node.parentNode;
|
|
4929
|
+
if (parent) {
|
|
4930
|
+
guardParent(parent);
|
|
4931
|
+
placeholders.get(node)?.remove();
|
|
4932
|
+
const mark = node.ownerDocument.createComment(TITLE_ROW_CLASS);
|
|
4933
|
+
parent.insertBefore(mark, node);
|
|
4934
|
+
placeholders.set(node, mark);
|
|
4935
|
+
}
|
|
4936
|
+
group.insertBefore(node, before);
|
|
4937
|
+
}
|
|
4938
|
+
/**
|
|
4939
|
+
* A lifted node whose placeholder left the group's tree belongs to a
|
|
4940
|
+
* controls band React unmounted: React removed the band, not the node,
|
|
4941
|
+
* so the copy on the title row is frozen.
|
|
4942
|
+
*/
|
|
4943
|
+
function isOrphaned(group, node) {
|
|
4944
|
+
const mark = placeholders.get(node);
|
|
4945
|
+
return !!mark && mark.getRootNode() !== group.getRootNode();
|
|
4946
|
+
}
|
|
4859
4947
|
/**
|
|
4860
4948
|
* Moves a node Payload just rendered into the group. A lifted node of
|
|
4861
4949
|
* the same kind is dropped first: when Payload remounts its controls
|
|
@@ -4865,7 +4953,7 @@ const ACTIONS = ".doc-controls__controls-wrapper";
|
|
|
4865
4953
|
function place(group, node, selector, before) {
|
|
4866
4954
|
if (!node) return;
|
|
4867
4955
|
for (const stale of Array.from(group.querySelectorAll(`:scope > ${selector}`))) stale.remove();
|
|
4868
|
-
group
|
|
4956
|
+
lift(group, node, before);
|
|
4869
4957
|
}
|
|
4870
4958
|
/**
|
|
4871
4959
|
* The element that bounds one document view. Payload's `Drawer` renders
|
|
@@ -4896,10 +4984,13 @@ function ownControl(root, view, selector) {
|
|
|
4896
4984
|
function liftTitleActions(root = document) {
|
|
4897
4985
|
for (const header of Array.from(root.querySelectorAll(".doc-header__header"))) {
|
|
4898
4986
|
const view = viewOf(header);
|
|
4987
|
+
let group = header.querySelector(`:scope > .${TITLE_ROW_CLASS}`);
|
|
4988
|
+
if (group) {
|
|
4989
|
+
for (const lifted of Array.from(group.children)) if (isOrphaned(group, lifted)) lifted.remove();
|
|
4990
|
+
}
|
|
4899
4991
|
const status = ownControl(root, view, STATUS);
|
|
4900
4992
|
const actions = ownControl(root, view, ACTIONS);
|
|
4901
4993
|
if (!status && !actions) continue;
|
|
4902
|
-
let group = header.querySelector(`:scope > .${TITLE_ROW_CLASS}`);
|
|
4903
4994
|
if (!group) {
|
|
4904
4995
|
group = header.ownerDocument.createElement("div");
|
|
4905
4996
|
group.className = TITLE_ROW_CLASS;
|