@bison-lab/payload-core 4.12.3 → 4.14.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 +13 -3
- package/dist/admin.d.mts +13 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +88 -24
- package/dist/admin.mjs.map +1 -1
- package/dist/block-library.d.mts +29 -1
- package/dist/block-library.d.mts.map +1 -0
- package/dist/block-library.mjs +33 -1
- package/dist/block-library.mjs.map +1 -0
- package/dist/index.d.mts +18 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +119 -32
- package/dist/index.mjs.map +1 -1
- package/dist/{looks-BbL309kO.mjs → island-97l5VY8l.mjs} +23 -2
- package/dist/island-97l5VY8l.mjs.map +1 -0
- package/dist/react.d.mts +21 -1
- package/dist/react.d.mts.map +1 -1
- package/dist/react.mjs +47 -3
- package/dist/react.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/looks-BbL309kO.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Peers: `payload`, `@payloadcms/plugin-seo`, and `@payloadcms/plugin-redirects` a
|
|
|
15
15
|
and `@bison-lab/fonts` are required because Theme is required. `@payloadcms/ui`,
|
|
16
16
|
`next` and `react` are needed for admin fields (`./admin` refreshes the
|
|
17
17
|
Media list with `next/navigation`, which Payload's admin already loads); `@bison-lab/ui` and
|
|
18
|
-
`@payloadcms/live-preview-react` are peers of the
|
|
18
|
+
`@payloadcms/live-preview-react` are peers of the `./react` entry.
|
|
19
19
|
Pin the plugin to the same version as `payload`; Payload releases them in
|
|
20
20
|
lockstep.
|
|
21
21
|
|
|
@@ -27,10 +27,10 @@ lockstep.
|
|
|
27
27
|
| `@bison-lab/payload-core/metadata` | `pageMetadata`, the title helpers, the same types | Server. What a page route imports; it does not load the plugin. |
|
|
28
28
|
| `@bison-lab/payload-core/theme` | `getPublishedTheme`, `getPublishedIdentity`, `themeConfigFromDoc`, `themeHead`, `themeHeadFromDoc` | Server. What a root layout imports; it does not load the plugin or React. |
|
|
29
29
|
| `@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. |
|
|
30
|
-
| `@bison-lab/payload-core/block-library` | `getSectionControls`, `sectionControlsFromLibrary`, `SectionControls`, the catalogue readers | Server. What a page route and the Block Settings fold import; it does not load the plugin or React. |
|
|
30
|
+
| `@bison-lab/payload-core/block-library` | `getSectionControls`, `sectionControlsFromLibrary`, `SectionControls`, the catalogue readers, the island height message | Server. What a page route and the Block Settings fold import; it does not load the plugin or React. |
|
|
31
31
|
| `@bison-lab/payload-core/taxonomy` | `facetField`, `FacetEntry` | Anywhere. What a block config imports to tag content from a taxonomy; no plugin, no React, so a browser bundle can take it (`@bison-lab/payload-blocks` main entry reaches the docs island and Storybook). |
|
|
32
32
|
| `@bison-lab/payload-core/admin` | Theme fields, the Roles and Features matrices, the Block library field, Admin nav, the Users Roles checklist, and the FAQ Library list | Admin. Referenced by import-map string; `generate:importmap` writes it. |
|
|
33
|
-
| `@bison-lab/payload-core/react` | `ThemePreview` (legacy; Theme has no preview pane)
|
|
33
|
+
| `@bison-lab/payload-core/react` | `BlockLibraryIsland`; `ThemePreview` (legacy; Theme has no preview pane) | Client. What a Block library preview route wraps its sample in. |
|
|
34
34
|
|
|
35
35
|
## What editors get
|
|
36
36
|
|
|
@@ -276,6 +276,14 @@ seed slugs stay read-only.
|
|
|
276
276
|
back to that seed (plus extras). The package never writes `developer`
|
|
277
277
|
onto a user row.
|
|
278
278
|
|
|
279
|
+
Removing a row removes that slug from every user in the same save, so a
|
|
280
|
+
later row saved under the same slug cannot hand it back. A user whose
|
|
281
|
+
only role it was is left with none. A save that would leave no user
|
|
282
|
+
holding Developer or a role with the Users tick is refused
|
|
283
|
+
(`ROLES_LOCKOUT_MESSAGE`), whether by deleting the row or unticking
|
|
284
|
+
Users. `pruneUserRoles(req)` strips every slug not on the saved Global;
|
|
285
|
+
call it once from a migration to clean users saved before this rule.
|
|
286
|
+
|
|
279
287
|
```ts
|
|
280
288
|
createRoles({
|
|
281
289
|
extras: [{ role: "editor", label: "Editor", grants: ["content"] }],
|
|
@@ -332,6 +340,8 @@ a gallery of islands. Each island is an iframe of `previewPath(slug)`.
|
|
|
332
340
|
That route, and `filterOptions` that hide an off slug, are the consuming
|
|
333
341
|
site (SPI-53). Islands are meant to render the sample under `themeHead`.
|
|
334
342
|
|
|
343
|
+
Wrap the sample in `BlockLibraryIsland` (`@bison-lab/payload-core/react`) and the card is as tall as the block (BIS-147). The island pads the sample evenly and posts its height to the admin window; the card takes it from its own frame on its own origin only, between a floor (an empty or `position: fixed` sample stays a visible card) and a ceiling (a `vh`-sized sample cannot grow the card forever). An island that never reports keeps the fixed 720px card.
|
|
344
|
+
|
|
335
345
|
`megaMenu` and `navLink` are header item blocks, not cards. Navigation's
|
|
336
346
|
card is `floatingNav`. While it is the only navbar, that card has no
|
|
337
347
|
switch: there is nothing else to turn on. A second header brings the
|
package/dist/admin.d.mts
CHANGED
|
@@ -107,6 +107,18 @@ declare const IdentityFallback: UIFieldClientComponent;
|
|
|
107
107
|
*/
|
|
108
108
|
declare const LookField: TextFieldClientComponent;
|
|
109
109
|
//#endregion
|
|
110
|
+
//#region src/admin/roles-cell.d.ts
|
|
111
|
+
/**
|
|
112
|
+
* Users list Roles column. Labels come from the saved Roles Global, the
|
|
113
|
+
* same list the edit field offers, so a renamed role reads its new name
|
|
114
|
+
* and a slug whose row was deleted is not shown at all. Until that loads
|
|
115
|
+
* (or when this login cannot read Roles), the field's seed options stand in.
|
|
116
|
+
*/
|
|
117
|
+
declare function RolesCell({
|
|
118
|
+
cellData,
|
|
119
|
+
field
|
|
120
|
+
}: DefaultCellComponentProps): react_jsx_runtime0.JSX.Element;
|
|
121
|
+
//#endregion
|
|
110
122
|
//#region src/admin/roles-matrix-field.d.ts
|
|
111
123
|
/**
|
|
112
124
|
* Payload's array field: drag rank stays, add is for custom rows.
|
|
@@ -343,5 +355,5 @@ declare function MediaAltAutofill({
|
|
|
343
355
|
//#region src/admin/media-list-view.d.ts
|
|
344
356
|
declare function MediaListView(props: ListViewClientProps): react_jsx_runtime0.JSX.Element;
|
|
345
357
|
//#endregion
|
|
346
|
-
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 };
|
|
358
|
+
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, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
347
359
|
//# 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/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/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"],"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;;;;;;;;
|
|
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/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/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"],"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,Y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ditorLooks, c as colorDocFromState, n as clampIslandHeight, o as pageEditorTokens, r as islandHeightOf, s as SYSTEM_COLOR_KEYS, u as stateFromColorDoc } from "./island-97l5VY8l.mjs";
|
|
3
3
|
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAllFormFields, 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";
|
|
@@ -2951,6 +2951,69 @@ function resetRolesMatrix(current) {
|
|
|
2951
2951
|
return [...defaultRolesFieldValue(), ...extras];
|
|
2952
2952
|
}
|
|
2953
2953
|
//#endregion
|
|
2954
|
+
//#region src/admin/use-live-roles.ts
|
|
2955
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
2956
|
+
function fetchLiveRoles(url) {
|
|
2957
|
+
const pending = inFlight.get(url);
|
|
2958
|
+
if (pending) return pending;
|
|
2959
|
+
const request = fetch(url, { credentials: "include" }).then((response) => response.ok ? response.json() : null).then((doc) => {
|
|
2960
|
+
if (!doc) return null;
|
|
2961
|
+
const parsed = parseRolesMatrix(doc.roles);
|
|
2962
|
+
return parsed.ok ? roleSelectOptions(parsed.rows) : null;
|
|
2963
|
+
}).catch(() => null).finally(() => {
|
|
2964
|
+
setTimeout(() => inFlight.delete(url), 0);
|
|
2965
|
+
});
|
|
2966
|
+
inFlight.set(url, request);
|
|
2967
|
+
return request;
|
|
2968
|
+
}
|
|
2969
|
+
/**
|
|
2970
|
+
* The saved Roles Global as options, or `null` until it has loaded (or
|
|
2971
|
+
* when this login cannot read it).
|
|
2972
|
+
*/
|
|
2973
|
+
function useLiveRoles() {
|
|
2974
|
+
const { config } = useConfig();
|
|
2975
|
+
const [live, setLive] = useState(null);
|
|
2976
|
+
const api = config?.routes?.api;
|
|
2977
|
+
const serverURL = config?.serverURL ?? "";
|
|
2978
|
+
useEffect(() => {
|
|
2979
|
+
if (!api) return;
|
|
2980
|
+
let cancelled = false;
|
|
2981
|
+
fetchLiveRoles(`${serverURL}${api}/globals/${ROLES_SLUG}?depth=0`).then((options) => {
|
|
2982
|
+
if (!cancelled && options) setLive(options);
|
|
2983
|
+
});
|
|
2984
|
+
return () => {
|
|
2985
|
+
cancelled = true;
|
|
2986
|
+
};
|
|
2987
|
+
}, [api, serverURL]);
|
|
2988
|
+
return live;
|
|
2989
|
+
}
|
|
2990
|
+
//#endregion
|
|
2991
|
+
//#region src/admin/roles-cell.tsx
|
|
2992
|
+
function staticOptions(field) {
|
|
2993
|
+
return ("options" in field && Array.isArray(field.options) ? field.options : []).map((option) => typeof option === "string" ? {
|
|
2994
|
+
value: option,
|
|
2995
|
+
label: option
|
|
2996
|
+
} : {
|
|
2997
|
+
value: String(option.value),
|
|
2998
|
+
label: typeof option.label === "string" ? option.label : String(option.value)
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
* Users list Roles column. Labels come from the saved Roles Global, the
|
|
3003
|
+
* same list the edit field offers, so a renamed role reads its new name
|
|
3004
|
+
* and a slug whose row was deleted is not shown at all. Until that loads
|
|
3005
|
+
* (or when this login cannot read Roles), the field's seed options stand in.
|
|
3006
|
+
*/
|
|
3007
|
+
function RolesCell({ cellData, field }) {
|
|
3008
|
+
const live = useLiveRoles();
|
|
3009
|
+
const roles = Array.isArray(cellData) ? cellData.filter((role) => typeof role === "string") : [];
|
|
3010
|
+
const options = live ?? staticOptions(field);
|
|
3011
|
+
return /* @__PURE__ */ jsx("span", { children: roles.flatMap((role) => {
|
|
3012
|
+
const option = options.find((entry) => entry.value === role);
|
|
3013
|
+
return option ? [option.label] : [];
|
|
3014
|
+
}).join(", ") });
|
|
3015
|
+
}
|
|
3016
|
+
//#endregion
|
|
2954
3017
|
//#region src/admin/roles-matrix-field.tsx
|
|
2955
3018
|
const HIDE_ROW_CHROME = `.bl-roles-matrix .array-actions__add,.bl-roles-matrix .array-actions__duplicate,.bl-roles-matrix .array-actions__copy{display:none}.bl-roles-matrix .array-field__add-row{display:none}.bl-roles-matrix--hide-developer .array-field__row:has([data-role-seed="developer"]),.bl-roles-matrix--hide-developer .collapsible:has([data-role-seed="developer"]){display:none}.bl-roles-matrix__toolbar{display:flex;justify-content:flex-end;gap:.5rem;margin-block-end:.75rem}.bl-roles-matrix__reset{min-height:2.25rem;padding:.35rem .9rem;border:1px solid var(--theme-elevation-150,#e2e8f0);border-radius:8px;background:transparent;color:inherit;font:inherit;cursor:pointer}body.bl-roles-matrix-seed-menu .array-actions__remove{display:none}`;
|
|
2956
3019
|
function seedRoleFromTrigger(trigger) {
|
|
@@ -3496,25 +3559,6 @@ function optionValue(option) {
|
|
|
3496
3559
|
function optionLabel(option) {
|
|
3497
3560
|
return typeof option === "string" ? option : String(option.label);
|
|
3498
3561
|
}
|
|
3499
|
-
function useOfferedRoles(fallback) {
|
|
3500
|
-
const { config } = useConfig();
|
|
3501
|
-
const [live, setLive] = useState(null);
|
|
3502
|
-
const api = config?.routes?.api;
|
|
3503
|
-
const serverURL = config?.serverURL ?? "";
|
|
3504
|
-
useEffect(() => {
|
|
3505
|
-
if (!api) return;
|
|
3506
|
-
let cancelled = false;
|
|
3507
|
-
fetch(`${serverURL}${api}/globals/${ROLES_SLUG}?depth=0`, { credentials: "include" }).then((response) => response.ok ? response.json() : null).then((doc) => {
|
|
3508
|
-
if (cancelled || !doc) return;
|
|
3509
|
-
const parsed = parseRolesMatrix(doc.roles);
|
|
3510
|
-
if (parsed.ok) setLive(roleSelectOptions(parsed.rows));
|
|
3511
|
-
}).catch(() => void 0);
|
|
3512
|
-
return () => {
|
|
3513
|
-
cancelled = true;
|
|
3514
|
-
};
|
|
3515
|
-
}, [api, serverURL]);
|
|
3516
|
-
return live ?? fallback;
|
|
3517
|
-
}
|
|
3518
3562
|
/**
|
|
3519
3563
|
* Users Roles checklist. Order and labels come from the field options (the
|
|
3520
3564
|
* Roles Global, or the seed plus extras). Copy is `roleDescription`.
|
|
@@ -3522,10 +3566,11 @@ function useOfferedRoles(fallback) {
|
|
|
3522
3566
|
*/
|
|
3523
3567
|
const RolesField = ({ field, path: pathFromProps, readOnly, validate }) => {
|
|
3524
3568
|
const { admin: { description } = {}, label, localized, options = [], required } = field;
|
|
3525
|
-
const
|
|
3569
|
+
const fallback = (options.length ? options : roleSelectOptions()).map((option) => ({
|
|
3526
3570
|
value: optionValue(option),
|
|
3527
3571
|
label: optionLabel(option)
|
|
3528
|
-
}))
|
|
3572
|
+
}));
|
|
3573
|
+
const offered = useLiveRoles() ?? fallback;
|
|
3529
3574
|
const { disabled, errorMessage, path, setValue, showError, value } = useField({
|
|
3530
3575
|
potentiallyStalePath: pathFromProps,
|
|
3531
3576
|
validate: useCallback((value, validationOptions) => {
|
|
@@ -3984,6 +4029,23 @@ function LibraryCard({ row, write, src, toggle, usageURL }) {
|
|
|
3984
4029
|
const [drafts, setDrafts] = useState(null);
|
|
3985
4030
|
const [checking, setChecking] = useState(false);
|
|
3986
4031
|
const apply = (enabled) => write?.("enabled", enabled);
|
|
4032
|
+
const frame = useRef(null);
|
|
4033
|
+
const [height, setHeight] = useState(null);
|
|
4034
|
+
/**
|
|
4035
|
+
* The island reports its height (BIS-147). Only this card's own frame,
|
|
4036
|
+
* from this origin, may size it; until it reports, the card keeps the
|
|
4037
|
+
* fallback height.
|
|
4038
|
+
*/
|
|
4039
|
+
useEffect(() => {
|
|
4040
|
+
const onMessage = (event) => {
|
|
4041
|
+
const own = frame.current?.contentWindow;
|
|
4042
|
+
if (!own || event.source !== own || event.origin !== window.location.origin) return;
|
|
4043
|
+
const reported = islandHeightOf(event.data);
|
|
4044
|
+
if (reported !== null) setHeight(clampIslandHeight(reported));
|
|
4045
|
+
};
|
|
4046
|
+
window.addEventListener("message", onMessage);
|
|
4047
|
+
return () => window.removeEventListener("message", onMessage);
|
|
4048
|
+
}, []);
|
|
3987
4049
|
/**
|
|
3988
4050
|
* Off asks the server where the slug is used. Published refuses; drafts
|
|
3989
4051
|
* only ask first, because the Save that turns it off deletes those rows.
|
|
@@ -4028,8 +4090,10 @@ function LibraryCard({ row, write, src, toggle, usageURL }) {
|
|
|
4028
4090
|
children: refusal
|
|
4029
4091
|
}) : null,
|
|
4030
4092
|
/* @__PURE__ */ jsx("iframe", {
|
|
4093
|
+
ref: frame,
|
|
4031
4094
|
title: row.label,
|
|
4032
|
-
src
|
|
4095
|
+
src,
|
|
4096
|
+
style: height === null ? void 0 : { height }
|
|
4033
4097
|
}),
|
|
4034
4098
|
/* @__PURE__ */ jsxs(ConfirmDialog, {
|
|
4035
4099
|
open: drafts !== null,
|
|
@@ -6670,6 +6734,6 @@ function ChevronMark() {
|
|
|
6670
6734
|
});
|
|
6671
6735
|
}
|
|
6672
6736
|
//#endregion
|
|
6673
|
-
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 };
|
|
6737
|
+
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, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
6674
6738
|
|
|
6675
6739
|
//# sourceMappingURL=admin.mjs.map
|