@bison-lab/payload-core 4.0.0 → 4.1.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 +38 -2
- package/dist/admin.d.mts +9 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +145 -9
- package/dist/admin.mjs.map +1 -1
- package/dist/index.d.mts +112 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +345 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,11 +22,11 @@ lockstep.
|
|
|
22
22
|
|
|
23
23
|
| Import | Contents | Runs where |
|
|
24
24
|
| ---------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
25
|
-
| `@bison-lab/payload-core` | `seoPlugin`, `createTheme`, `createBrandAssets`, `createRoles`, `createFeatures`, `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`, `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. |
|
|
29
|
-
| `@bison-lab/payload-core/admin` | Theme fields, the Roles and Features matrices, Admin nav, the Users Roles checklist, and the FAQ Library list | Admin. Referenced by import-map string; `generate:importmap` writes it. |
|
|
29
|
+
| `@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. |
|
|
30
30
|
| `@bison-lab/payload-core/react` | `ThemePreview` (legacy; Theme has no preview pane) | Client. Kept so an older site import does not break. |
|
|
31
31
|
|
|
32
32
|
## What editors get
|
|
@@ -317,6 +317,42 @@ document. Nav hiding follows `user.allowedFeatures` on the JWT
|
|
|
317
317
|
(computed at user read from the live Features and Roles Globals) so
|
|
318
318
|
Payload's `admin.hidden({ user })` matches the API.
|
|
319
319
|
|
|
320
|
+
## Block library
|
|
321
|
+
|
|
322
|
+
Settings → Block library is one card per installed option. Editors browse
|
|
323
|
+
package categories (Hero, Feature, Process, FAQ, Testimonials, Stats,
|
|
324
|
+
Content, Contact, CTA, Navigation) and switch a card on or off. Off is
|
|
325
|
+
editorial availability. Save is Payload's document chrome. The field is
|
|
326
|
+
`BLOCK_LIBRARY_FIELD`
|
|
327
|
+
(`@bison-lab/payload-core/admin#BlockLibraryField`): a category rail and
|
|
328
|
+
a gallery of islands. Each island is an iframe of `previewPath(slug)`.
|
|
329
|
+
That route, and `filterOptions` that hide an off slug, are the consuming
|
|
330
|
+
site (SPI-53). Islands are meant to render the sample under `themeHead`.
|
|
331
|
+
|
|
332
|
+
`megaMenu` and `navLink` are header item blocks, not cards. Navigation's
|
|
333
|
+
card is `floatingNav`. While it is the only navbar, that card has no
|
|
334
|
+
switch: there is nothing else to turn on. A second header brings the
|
|
335
|
+
switches back, so an editor picks which one the site uses. A site extra is appended with `blocks` and appears
|
|
336
|
+
only in the category it names. A site may not add `megaMenu` or `navLink`
|
|
337
|
+
as cards.
|
|
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.
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
import { createBlockLibrary } from "@bison-lab/payload-core";
|
|
346
|
+
|
|
347
|
+
createBlockLibrary({
|
|
348
|
+
previewPath: (slug) => `/block-library/${slug}`,
|
|
349
|
+
blocks: [{ slug: "ctaBand", label: "Doctor finder", category: "cta", kind: "section" }],
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
`access.update` defaults to `isAdmin`. Pass `access` to change who may
|
|
354
|
+
edit availability. Then `payload generate:importmap` and `payload migrate:create`.
|
|
355
|
+
|
|
320
356
|
## Pages, users, and media
|
|
321
357
|
|
|
322
358
|
`createPages`, `createUsers`, `createMedia`, `slugField`,
|
package/dist/admin.d.mts
CHANGED
|
@@ -177,6 +177,14 @@ declare const RolesGrantsField: JSONFieldClientComponent;
|
|
|
177
177
|
*/
|
|
178
178
|
declare const FeaturesMatrixField: ArrayFieldClientComponent;
|
|
179
179
|
//#endregion
|
|
180
|
+
//#region src/admin/block-library-field.d.ts
|
|
181
|
+
/**
|
|
182
|
+
* Category rail and a gallery of live islands. Each island is the sample
|
|
183
|
+
* at `previewPath(slug)` under the published theme (the route is SPI-53).
|
|
184
|
+
* `megaMenu` and `navLink` are not cards.
|
|
185
|
+
*/
|
|
186
|
+
declare const BlockLibraryField: ArrayFieldClientComponent;
|
|
187
|
+
//#endregion
|
|
180
188
|
//#region src/admin/document-title-actions.d.ts
|
|
181
189
|
declare function DocumentTitleActions({
|
|
182
190
|
children
|
|
@@ -283,5 +291,5 @@ declare function MediaAltAutofill({
|
|
|
283
291
|
//#region src/admin/media-list-view.d.ts
|
|
284
292
|
declare function MediaListView(props: ListViewClientProps): react_jsx_runtime0.JSX.Element;
|
|
285
293
|
//#endregion
|
|
286
|
-
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageTitleCell, PairingField, PublishChild, QuestionsList, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
294
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageTitleCell, PairingField, PublishChild, QuestionsList, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
287
295
|
//# 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/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","../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;;;;;;;;;cC2Bf,SAAA,EAAW,wBAAA;;;;;;;iBC1BR,aAAA,CAAc,KAAA,EAAO,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cCAjD,aAAA,EAAe,wBAAA;;;;;;;;cC8Cf,UAAA,EAAY,0BAAA;;;;;;;;cCpBZ,gBAAA,EAAkB,wBAAA;;;;;;;;;ArBxB/B;;csB2Ca,mBAAA,EAAqB,yBAAA;;;
|
|
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/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,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;;;;;;;;;cC2Bf,SAAA,EAAW,wBAAA;;;;;;;iBC1BR,aAAA,CAAc,KAAA,EAAO,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cCAjD,aAAA,EAAe,wBAAA;;;;;;;;cC8Cf,UAAA,EAAY,0BAAA;;;;;;;;cCpBZ,gBAAA,EAAkB,wBAAA;;;;;;;;;ArBxB/B;;csB2Ca,mBAAA,EAAqB,yBAAA;;;;;;;;cCiBrB,iBAAA,EAAmB,yBAAA;;;iBCjChB,oBAAA,CAAA;EAAuB;AAAA;EAAc,QAAA,GAAW,SAAA;AAAA,IAAW,kBAAA,CAAA,GAAA,CAAA,OAAA;;;iBCxB3D,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;;;A3BGpB;;;iB2B6CgB,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;;;;;;;;cCEvB,mBAAA,EAAqB,wBAAA;;;;;;;;A9BClC;U+BFiB,cAAA;;EAEf,MAAA;E/ByED;E+BvEC,IAAA;;EAEA,KAAA;E9BmBW;E8BjBX,MAAA;AAAA;AAAA,UAGe,eAAA;E9BiEhB;E8B/DC,IAAA;;EAEA,KAAA;E7BgBW;E6BdX,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"}
|
package/dist/admin.mjs
CHANGED
|
@@ -3583,7 +3583,7 @@ const RolesField = ({ field, path: pathFromProps, readOnly, validate }) => {
|
|
|
3583
3583
|
};
|
|
3584
3584
|
//#endregion
|
|
3585
3585
|
//#region src/admin/roles-grants-field.tsx
|
|
3586
|
-
const LIST_CSS$
|
|
3586
|
+
const LIST_CSS$3 = `.bl-role-grants{margin-block:.2rem 0;font-size:16px}.bl-role-grants__group{margin-block:.75rem 0}.bl-role-grants__group-title{font-size:13px;letter-spacing:.02em;color:var(--theme-elevation-400,#94a3b8);font-weight:650;margin-block-end:.25rem}.bl-role-grants__row{display:flex;align-items:center;gap:.65rem;padding:.35rem 0}.bl-role-grants__row.is-implicit{opacity:.85}.bl-role-grants input{inline-size:1.15rem;block-size:1.15rem}.bl-role-grants input:disabled{cursor:default}.bl-role-grants__note{margin-block:.35rem 0;font-size:13px;color:var(--theme-elevation-500,#64748b)}`;
|
|
3587
3587
|
function asGrants(value) {
|
|
3588
3588
|
if (!Array.isArray(value)) return [];
|
|
3589
3589
|
return value.filter((entry) => typeof entry === "string");
|
|
@@ -3649,7 +3649,7 @@ const RolesGrantsField = (props) => {
|
|
|
3649
3649
|
/* @__PURE__ */ jsx("style", {
|
|
3650
3650
|
href: "bl-role-grants",
|
|
3651
3651
|
precedence: "default",
|
|
3652
|
-
children: LIST_CSS$
|
|
3652
|
+
children: LIST_CSS$3
|
|
3653
3653
|
}),
|
|
3654
3654
|
implicitAll ? /* @__PURE__ */ jsx("p", {
|
|
3655
3655
|
className: "bl-role-grants__note",
|
|
@@ -3680,8 +3680,8 @@ const RolesGrantsField = (props) => {
|
|
|
3680
3680
|
};
|
|
3681
3681
|
//#endregion
|
|
3682
3682
|
//#region src/admin/features-matrix-field.tsx
|
|
3683
|
-
const LIST_CSS$
|
|
3684
|
-
function asRows(value) {
|
|
3683
|
+
const LIST_CSS$2 = `.bl-features{margin-block:.35rem 0;font-size:16px}.bl-features__group{margin-block:1rem 0}.bl-features__group-title{font-size:14px;letter-spacing:.02em;color:var(--theme-elevation-400,#94a3b8);font-weight:650;margin-block-end:.35rem}.bl-features__row{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.55rem 0;border-bottom:1px solid var(--theme-elevation-150,#e2e8f0)}.bl-features__row:last-child{border-bottom:0}.bl-features input{inline-size:1.15rem;block-size:1.15rem}`;
|
|
3684
|
+
function asRows$1(value) {
|
|
3685
3685
|
return Array.isArray(value) ? value : [];
|
|
3686
3686
|
}
|
|
3687
3687
|
function FeatureReleaseRow({ path, index, row, rows, setRows }) {
|
|
@@ -3717,11 +3717,11 @@ const FeaturesMatrixField = (props) => {
|
|
|
3717
3717
|
const api = config?.routes?.api;
|
|
3718
3718
|
const serverURL = config?.serverURL ?? "";
|
|
3719
3719
|
useEffect(() => {
|
|
3720
|
-
if (!api || asRows(value).length > 0) return;
|
|
3720
|
+
if (!api || asRows$1(value).length > 0) return;
|
|
3721
3721
|
let cancelled = false;
|
|
3722
3722
|
fetch(`${serverURL}${api}/globals/${FEATURES_SLUG}?depth=0`, { credentials: "include" }).then((response) => response.ok ? response.json() : null).then((doc) => {
|
|
3723
3723
|
if (cancelled || !doc) return;
|
|
3724
|
-
const incoming = asRows(doc.features);
|
|
3724
|
+
const incoming = asRows$1(doc.features);
|
|
3725
3725
|
if (incoming.length > 0) setValue(incoming, true);
|
|
3726
3726
|
}).catch(() => void 0);
|
|
3727
3727
|
return () => {
|
|
@@ -3733,13 +3733,13 @@ const FeaturesMatrixField = (props) => {
|
|
|
3733
3733
|
setValue,
|
|
3734
3734
|
value
|
|
3735
3735
|
]);
|
|
3736
|
-
const rows = asRows(value);
|
|
3736
|
+
const rows = asRows$1(value);
|
|
3737
3737
|
return /* @__PURE__ */ jsxs("div", {
|
|
3738
3738
|
className: "bl-features",
|
|
3739
3739
|
children: [/* @__PURE__ */ jsx("style", {
|
|
3740
3740
|
href: "bl-features",
|
|
3741
3741
|
precedence: "default",
|
|
3742
|
-
children: LIST_CSS$
|
|
3742
|
+
children: LIST_CSS$2
|
|
3743
3743
|
}), FEATURE_GROUPS.map((group) => {
|
|
3744
3744
|
const members = rows.map((row, index) => ({
|
|
3745
3745
|
row,
|
|
@@ -3763,6 +3763,142 @@ const FeaturesMatrixField = (props) => {
|
|
|
3763
3763
|
});
|
|
3764
3764
|
};
|
|
3765
3765
|
//#endregion
|
|
3766
|
+
//#region src/block-library/types.ts
|
|
3767
|
+
const BLOCK_LIBRARY_CATEGORIES = [
|
|
3768
|
+
{
|
|
3769
|
+
id: "hero",
|
|
3770
|
+
label: "Hero"
|
|
3771
|
+
},
|
|
3772
|
+
{
|
|
3773
|
+
id: "feature",
|
|
3774
|
+
label: "Feature"
|
|
3775
|
+
},
|
|
3776
|
+
{
|
|
3777
|
+
id: "process",
|
|
3778
|
+
label: "Process"
|
|
3779
|
+
},
|
|
3780
|
+
{
|
|
3781
|
+
id: "faq",
|
|
3782
|
+
label: "FAQ"
|
|
3783
|
+
},
|
|
3784
|
+
{
|
|
3785
|
+
id: "testimonials",
|
|
3786
|
+
label: "Testimonials"
|
|
3787
|
+
},
|
|
3788
|
+
{
|
|
3789
|
+
id: "stats",
|
|
3790
|
+
label: "Stats"
|
|
3791
|
+
},
|
|
3792
|
+
{
|
|
3793
|
+
id: "content",
|
|
3794
|
+
label: "Content"
|
|
3795
|
+
},
|
|
3796
|
+
{
|
|
3797
|
+
id: "contact",
|
|
3798
|
+
label: "Contact"
|
|
3799
|
+
},
|
|
3800
|
+
{
|
|
3801
|
+
id: "cta",
|
|
3802
|
+
label: "CTA"
|
|
3803
|
+
},
|
|
3804
|
+
{
|
|
3805
|
+
id: "navigation",
|
|
3806
|
+
label: "Navigation"
|
|
3807
|
+
}
|
|
3808
|
+
];
|
|
3809
|
+
//#endregion
|
|
3810
|
+
//#region src/admin/block-library-field.tsx
|
|
3811
|
+
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)}`;
|
|
3812
|
+
function LibraryCard({ path, index, row, rows, setRows, src, toggle }) {
|
|
3813
|
+
const { setValue: setEnabled } = useField({ path: `${path}.${index}.enabled` });
|
|
3814
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
3815
|
+
className: "bl-block-library__card",
|
|
3816
|
+
children: [/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("span", { children: row.label }), toggle ? /* @__PURE__ */ jsx(Switch, {
|
|
3817
|
+
checked: row.enabled !== false,
|
|
3818
|
+
"aria-label": `Enable ${row.label}`,
|
|
3819
|
+
onCheckedChange: (enabled) => {
|
|
3820
|
+
setEnabled(enabled);
|
|
3821
|
+
setRows(rows.map((entry, i) => i === index ? {
|
|
3822
|
+
...entry,
|
|
3823
|
+
enabled
|
|
3824
|
+
} : entry));
|
|
3825
|
+
}
|
|
3826
|
+
}) : null] }), /* @__PURE__ */ jsx("iframe", {
|
|
3827
|
+
title: row.label,
|
|
3828
|
+
src
|
|
3829
|
+
})]
|
|
3830
|
+
});
|
|
3831
|
+
}
|
|
3832
|
+
function asRows(value) {
|
|
3833
|
+
return Array.isArray(value) ? value : [];
|
|
3834
|
+
}
|
|
3835
|
+
function customOf(field) {
|
|
3836
|
+
return field.admin?.custom ?? {};
|
|
3837
|
+
}
|
|
3838
|
+
function previewsOf(field) {
|
|
3839
|
+
const previews = customOf(field).previews;
|
|
3840
|
+
if (!previews || typeof previews !== "object") return {};
|
|
3841
|
+
return previews;
|
|
3842
|
+
}
|
|
3843
|
+
function seededRows(field) {
|
|
3844
|
+
return asRows(customOf(field).rows);
|
|
3845
|
+
}
|
|
3846
|
+
/**
|
|
3847
|
+
* Category rail and a gallery of live islands. Each island is the sample
|
|
3848
|
+
* at `previewPath(slug)` under the published theme (the route is SPI-53).
|
|
3849
|
+
* `megaMenu` and `navLink` are not cards.
|
|
3850
|
+
*/
|
|
3851
|
+
const BlockLibraryField = (props) => {
|
|
3852
|
+
const { setValue, value } = useField({ path: props.path });
|
|
3853
|
+
const loaded = asRows(value);
|
|
3854
|
+
const seeded = seededRows(props.field);
|
|
3855
|
+
const rows = loaded.length > 0 ? loaded : seeded;
|
|
3856
|
+
useEffect(() => {
|
|
3857
|
+
if (loaded.length === 0 && seeded.length > 0) setValue(seeded);
|
|
3858
|
+
}, [
|
|
3859
|
+
loaded.length,
|
|
3860
|
+
seeded,
|
|
3861
|
+
setValue
|
|
3862
|
+
]);
|
|
3863
|
+
const previews = previewsOf(props.field);
|
|
3864
|
+
const [category, setCategory] = useState("hero");
|
|
3865
|
+
const navbarCount = rows.filter((row) => row.kind === "navbar").length;
|
|
3866
|
+
const visible = rows.map((row, index) => ({
|
|
3867
|
+
row,
|
|
3868
|
+
index
|
|
3869
|
+
})).filter(({ row }) => row.category === category);
|
|
3870
|
+
return /* @__PURE__ */ jsx(KitProvider, { children: /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsxs("div", {
|
|
3871
|
+
className: "bl-block-library",
|
|
3872
|
+
children: [
|
|
3873
|
+
/* @__PURE__ */ jsx("style", {
|
|
3874
|
+
href: "bl-block-library",
|
|
3875
|
+
precedence: "default",
|
|
3876
|
+
children: LIST_CSS$1
|
|
3877
|
+
}),
|
|
3878
|
+
/* @__PURE__ */ jsx("div", {
|
|
3879
|
+
className: "bl-block-library__rail",
|
|
3880
|
+
role: "navigation",
|
|
3881
|
+
"aria-label": "Block categories",
|
|
3882
|
+
children: BLOCK_LIBRARY_CATEGORIES.map((entry) => /* @__PURE__ */ jsx("button", {
|
|
3883
|
+
type: "button",
|
|
3884
|
+
"aria-current": entry.id === category,
|
|
3885
|
+
onClick: () => setCategory(entry.id),
|
|
3886
|
+
children: entry.label
|
|
3887
|
+
}, entry.id))
|
|
3888
|
+
}),
|
|
3889
|
+
/* @__PURE__ */ jsx("div", { children: visible.map(({ row, index }) => /* @__PURE__ */ jsx(LibraryCard, {
|
|
3890
|
+
path: props.path,
|
|
3891
|
+
index,
|
|
3892
|
+
row,
|
|
3893
|
+
rows,
|
|
3894
|
+
setRows: (next) => setValue(next),
|
|
3895
|
+
src: previews[row.slug] ?? "",
|
|
3896
|
+
toggle: row.kind !== "navbar" || navbarCount > 1
|
|
3897
|
+
}, row.slug)) })
|
|
3898
|
+
]
|
|
3899
|
+
}) }) });
|
|
3900
|
+
};
|
|
3901
|
+
//#endregion
|
|
3766
3902
|
//#region src/admin/theme-kit-accent.tsx
|
|
3767
3903
|
function primaryHex(doc) {
|
|
3768
3904
|
const hex = doc?.colors?.brand?.primary?.hex;
|
|
@@ -6089,6 +6225,6 @@ function ChevronMark() {
|
|
|
6089
6225
|
});
|
|
6090
6226
|
}
|
|
6091
6227
|
//#endregion
|
|
6092
|
-
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageTitleCell, PairingField, PublishChild, QuestionsList, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
6228
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageTitleCell, PairingField, PublishChild, QuestionsList, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
6093
6229
|
|
|
6094
6230
|
//# sourceMappingURL=admin.mjs.map
|