@bison-lab/payload-core 4.14.0 → 4.15.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 +88 -2
- package/dist/admin.d.mts +14 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +149 -20
- package/dist/admin.mjs.map +1 -1
- package/dist/block-library.d.mts +1 -1
- package/dist/{catalogue-9MO2jy69.d.mts → catalogue-CFXM1yAZ.d.mts} +8 -1
- package/dist/catalogue-CFXM1yAZ.d.mts.map +1 -0
- package/dist/{facet-field-DHpNdS_u.d.mts → facet-field-_8bYI1i0.d.mts} +1 -1
- package/dist/{facet-field-DHpNdS_u.d.mts.map → facet-field-_8bYI1i0.d.mts.map} +1 -1
- package/dist/index.d.mts +53 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +199 -2
- package/dist/index.mjs.map +1 -1
- package/dist/metadata.d.mts +1 -1
- package/dist/navigation.d.mts +1 -1
- package/dist/{preview-D-Psltpf.d.mts → preview-Vaa1KXJP.d.mts} +1 -1
- package/dist/{preview-D-Psltpf.d.mts.map → preview-Vaa1KXJP.d.mts.map} +1 -1
- package/dist/published-BjmUCpdY.mjs.map +1 -1
- package/dist/{published-DhARD4W8.d.mts → published-FUgC5Mc8.d.mts} +1 -1
- package/dist/{published-DhARD4W8.d.mts.map → published-FUgC5Mc8.d.mts.map} +1 -1
- package/dist/taxonomy.d.mts +1 -1
- package/dist/theme.d.mts +1 -1
- package/dist/{title-7VASfaFO.d.mts → title-ImlifZ_6.d.mts} +1 -1
- package/dist/{title-7VASfaFO.d.mts.map → title-ImlifZ_6.d.mts.map} +1 -1
- package/dist/wireframe-BTocmmyY.mjs +298 -0
- package/dist/wireframe-BTocmmyY.mjs.map +1 -0
- package/dist/wireframe-cli.d.mts +1 -0
- package/dist/wireframe-cli.mjs +110 -0
- package/dist/wireframe-cli.mjs.map +1 -0
- package/dist/wireframe.d.mts +119 -0
- package/dist/wireframe.d.mts.map +1 -0
- package/dist/wireframe.mjs +2 -0
- package/package.json +11 -4
- package/dist/catalogue-9MO2jy69.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -19,16 +19,17 @@ Media list with `next/navigation`, which Payload's admin already loads); `@bison
|
|
|
19
19
|
Pin the plugin to the same version as `payload`; Payload releases them in
|
|
20
20
|
lockstep.
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Nine entry points, and why
|
|
23
23
|
|
|
24
24
|
| Import | Contents | Runs where |
|
|
25
25
|
| ---------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
26
|
-
| `@bison-lab/payload-core` | `seoPlugin`, `createTheme`, `createBrandAssets`, `createRoles`, `createFeatures`, `createBlockLibrary`, `createPages`, `createUsers`, `createMedia`, `createRedirects`, `createQuestions`, `createTaxonomy`, `facetField`, `createAdminNav`, `adminNav`, `createNavigation`, `adminOnlyApiTab`, `documentTitleActions`, `listAlign`, `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
|
+
| `@bison-lab/payload-core` | `seoPlugin`, `createTheme`, `createBrandAssets`, `createRoles`, `createFeatures`, `createBlockLibrary`, `createPages`, `createUsers`, `createMedia`, `createRedirects`, `createQuestions`, `createTaxonomy`, `facetField`, `createAdminNav`, `adminNav`, `createNavigation`, `adminOnlyApiTab`, `documentTitleActions`, `listAlign`, `blockDrawer`, `seedTheme`, `seedRoles`, `seedFeatures`, predicates, `lookField`, `colorTokenField`, import-map strings, title and text helpers, types | Node. What `payload.config.ts` imports; it loads the plugin. |
|
|
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
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
|
+
| `@bison-lab/payload-core/wireframe` | `captureWireframes`, `extractWireframe`, `wireframeSvg`, `svgDataUri`; the `bison-wireframes` bin | Node, beside Playwright. What a site's thumbnail script imports; no Payload, no React. |
|
|
32
33
|
| `@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
34
|
| `@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
35
|
|
|
@@ -337,6 +338,22 @@ editorial availability. Save is Payload's document chrome. The field is
|
|
|
337
338
|
`BLOCK_LIBRARY_FIELD`
|
|
338
339
|
(`@bison-lab/payload-core/admin#BlockLibraryField`): a category rail and
|
|
339
340
|
a gallery of islands. Each island is an iframe of `previewPath(slug)`.
|
|
341
|
+
|
|
342
|
+
The rail (BIS-143) is admin-ui's `CategoryRail`: a search box over an
|
|
343
|
+
accordion. Each header reads `Category (n)`, n counting every block in it,
|
|
344
|
+
switched-off ones included; an empty category has no header. One category
|
|
345
|
+
is open at a time and the gallery shows all of its cards in catalogue
|
|
346
|
+
order; closing the open header keeps those cards on screen. Under the open
|
|
347
|
+
header each block is a `#<slug>` link to its card (the card's `id`), and
|
|
348
|
+
the link for the card in view is marked as you scroll. A URL with
|
|
349
|
+
`#<slug>` opens that block's category and scrolls to its card, on load and
|
|
350
|
+
on every hash change. A query matches a block's label or slug, or a
|
|
351
|
+
category's name: every matching category opens, counts become matches, the
|
|
352
|
+
gallery shows the matching cards under their category headings, and an
|
|
353
|
+
empty result says so with a Clear search button. Clearing returns to the
|
|
354
|
+
category that was open; clicking a header mid-search opens that whole
|
|
355
|
+
category. At 768px and below the rail stacks above the gallery as the same
|
|
356
|
+
accordion. Islands load lazily.
|
|
340
357
|
That route, and `filterOptions` that hide an off slug, are the consuming
|
|
341
358
|
site (SPI-53). Islands are meant to render the sample under `themeHead`.
|
|
342
359
|
|
|
@@ -399,6 +416,75 @@ createBlockLibrary({
|
|
|
399
416
|
`access.update` defaults to `isAdmin`. Pass `access` to change who may
|
|
400
417
|
edit availability. Then `payload generate:importmap` and `payload migrate:create`.
|
|
401
418
|
|
|
419
|
+
### The Add Block drawer
|
|
420
|
+
|
|
421
|
+
Payload has no slot to replace its Add Block drawer, and three places open
|
|
422
|
+
it: the blocks field's Add button, Add below in a row's ⋯ menu, and the
|
|
423
|
+
Preview overlay. `blockDrawer()` (BIS-148) sets what that drawer reads on
|
|
424
|
+
every catalogue block, in every collection and global, so all three agree:
|
|
425
|
+
|
|
426
|
+
- **`admin.group`**: the block's Block library category label, with the
|
|
427
|
+
list ordered by category, then catalogue order. The drawer reads Hero,
|
|
428
|
+
Feature, Process, … like the Block library. Blocks outside the catalogue
|
|
429
|
+
(a Header's `megaMenu` and `navLink`) are left alone and go last, which
|
|
430
|
+
is also where Payload draws ungrouped blocks.
|
|
431
|
+
- **`admin.images.thumbnail`**: a black-and-white wireframe of the block.
|
|
432
|
+
The package ships one for each of its page blocks
|
|
433
|
+
(`block-library/wireframes.generated.ts`, `resources` included). A site
|
|
434
|
+
extra passes its own as `thumbnail` on its `createBlockLibrary` entry; it
|
|
435
|
+
is kept in the Global's server-only `custom`, not in the client config.
|
|
436
|
+
A block config that already sets a thumbnail or `imageURL` keeps it.
|
|
437
|
+
- **Larger cards**: one admin stylesheet (`BLOCK_DRAWER_CSS`, mounted as the
|
|
438
|
+
`BLOCK_DRAWER_STYLES` provider) lays the drawer out three across, two at
|
|
439
|
+
Payload's 1024px break, one at 768px, instead of Payload's six.
|
|
440
|
+
|
|
441
|
+
Which blocks the drawer offers is still the site's `filterOptions` from the
|
|
442
|
+
Block library; this plugin changes how they look, not which appear.
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
import { blockDrawer, createBlockLibrary } from "@bison-lab/payload-core";
|
|
446
|
+
|
|
447
|
+
export default buildConfig({
|
|
448
|
+
globals: [
|
|
449
|
+
createBlockLibrary({
|
|
450
|
+
previewPath: (slug) => `/block-library/${slug}`,
|
|
451
|
+
blocks: [{ slug: "ctaBand", label: "CTA band", category: "cta", thumbnail: SITE_WIREFRAMES.ctaBand }],
|
|
452
|
+
}),
|
|
453
|
+
],
|
|
454
|
+
plugins: [blockDrawer()],
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
Run `payload generate:importmap` once for the stylesheet provider.
|
|
459
|
+
|
|
460
|
+
**Wireframes** come from `bison-wireframes`, a bin on this package that
|
|
461
|
+
opens each block's Block library preview in a headless browser at 1280px,
|
|
462
|
+
reads where headings, text lines, images, buttons, fields and painted
|
|
463
|
+
surfaces sit (`extractWireframe`, from the `./wireframe` entry), and draws
|
|
464
|
+
them as 480 × 320 greyscale shapes (`wireframeSvg`): bars for text, a
|
|
465
|
+
crossed box for an image, pills for buttons, a dark fill for a dark band.
|
|
466
|
+
No copy and no brand color, so a Theme change does not stale it; rerun it
|
|
467
|
+
when a layout changes. Run it from the site, which supplies Playwright:
|
|
468
|
+
|
|
469
|
+
```sh
|
|
470
|
+
WIREFRAME_EMAIL=… WIREFRAME_PASSWORD=… pnpm exec bison-wireframes \
|
|
471
|
+
--base http://localhost:3039 --slugs ctaBand,productMap \
|
|
472
|
+
--out src/blocks/wireframes.generated.ts --svg-dir /tmp/wireframes
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
The login (any user the preview route accepts) comes from the environment.
|
|
476
|
+
`--preview` changes the route pattern (`/block-library/{slug}` by default),
|
|
477
|
+
`--selector` the element that holds the sample (`BlockLibraryIsland`'s by
|
|
478
|
+
default), and `--export` the constant's name. The login is required unless
|
|
479
|
+
`--no-login` names a public route. A preview that answers an error status,
|
|
480
|
+
or renders nothing the selector matches, fails the run and writes nothing,
|
|
481
|
+
so a sign-in wall or a mistyped slug never becomes a block's picture. A sample that reads data
|
|
482
|
+
(Product Map reads Products and Anatomy) needs that data in the database
|
|
483
|
+
the site is serving. To refresh the package's own map, run it against a
|
|
484
|
+
site's preview route for the package slugs, and against the docs site's
|
|
485
|
+
`/preview/{slug}/` page (`--selector "main[data-block]" --no-login`) for
|
|
486
|
+
`hero`, which no site installs.
|
|
487
|
+
|
|
402
488
|
### Section controls
|
|
403
489
|
|
|
404
490
|
Every page block carries the same four section settings (Background,
|
package/dist/admin.d.mts
CHANGED
|
@@ -240,6 +240,19 @@ declare function ListAlignStyles({
|
|
|
240
240
|
children?: ReactNode;
|
|
241
241
|
}): react_jsx_runtime0.JSX.Element;
|
|
242
242
|
//#endregion
|
|
243
|
+
//#region src/admin/block-drawer-styles.d.ts
|
|
244
|
+
/**
|
|
245
|
+
* The Add Block drawer's stylesheet from `blockDrawer()`, handed in as
|
|
246
|
+
* `clientProps` so the admin computes nothing at render.
|
|
247
|
+
*/
|
|
248
|
+
declare function BlockDrawerStyles({
|
|
249
|
+
css,
|
|
250
|
+
children
|
|
251
|
+
}: {
|
|
252
|
+
css?: string;
|
|
253
|
+
children?: ReactNode;
|
|
254
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
255
|
+
//#endregion
|
|
243
256
|
//#region src/admin/document-create-new.d.ts
|
|
244
257
|
declare function DocumentCreateNew({
|
|
245
258
|
path
|
|
@@ -355,5 +368,5 @@ declare function MediaAltAutofill({
|
|
|
355
368
|
//#region src/admin/media-list-view.d.ts
|
|
356
369
|
declare function MediaListView(props: ListViewClientProps): react_jsx_runtime0.JSX.Element;
|
|
357
370
|
//#endregion
|
|
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 };
|
|
371
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, 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 };
|
|
359
372
|
//# 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-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,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;;;;;;;;;iBCOR,SAAA,CAAA;EAAY,QAAA;EAAU;AAAA,GAAS,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;cCc3D,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;;;;;;;;cCqBf,UAAA,EAAY,0BAAA;;;;;;;;cCKZ,gBAAA,EAAkB,wBAAA;;;;;;;;;AxBxB/B;;cyB2Ca,mBAAA,EAAqB,yBAAA;;;;;;;;;AzB3ClC;;;;;;;
|
|
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/block-drawer-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":"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"}
|
package/dist/admin.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, Field
|
|
|
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";
|
|
7
|
-
import { Badge, Button as Button$1, CancelGlyph, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Fold, Input, KitProvider, Label, LockGlyph, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Table, TableActions, TableCell, TableHead, TableRow, Thumbnail } from "@bison-lab/admin-ui";
|
|
7
|
+
import { Badge, Button as Button$1, CancelGlyph, CategoryRail, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Fold, Input, KitProvider, Label, LockGlyph, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Table, TableActions, TableCell, TableHead, TableRow, Thumbnail, filterCategories } from "@bison-lab/admin-ui";
|
|
8
8
|
import { HexColorPicker } from "react-colorful";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
import { findFont, fontFaceCss, isFontId } from "@bison-lab/fonts";
|
|
@@ -3956,7 +3956,7 @@ const BLOCK_LIBRARY_CATEGORIES = [
|
|
|
3956
3956
|
];
|
|
3957
3957
|
//#endregion
|
|
3958
3958
|
//#region src/admin/block-library-field.tsx
|
|
3959
|
-
const LIST_CSS$1 = `.bl-block-library{display:grid;grid-template-columns:
|
|
3959
|
+
const LIST_CSS$1 = `.bl-block-library{display:grid;grid-template-columns:15rem minmax(0,1fr);gap:1.5rem;align-items:start}.bl-block-library__rail{position:sticky;top:calc(var(--doc-controls-height,0px) + 1rem);max-height:calc(100vh - var(--doc-controls-height,0px) - 2rem);overflow-y:auto}.bl-block-library__group h2{margin:0 0 .75rem;font-size:15px;font-weight:650}.bl-block-library__group+.bl-block-library__group{margin-block-start:1.5rem}.bl-block-library__card{display:flex;flex-direction:column;gap:.5rem;margin-block-end:1.25rem;scroll-margin-top:calc(var(--doc-controls-height,0px) + 1rem)}.bl-block-library__card header{display:flex;justify-content:space-between;align-items:center;gap:1rem}.bl-block-library__controls{display:flex;flex-wrap:wrap;gap:.25rem 1.25rem;margin:0;padding:0;border:0}.bl-block-library__controls legend{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.bl-block-library__control{display:inline-flex;align-items:center;gap:.5rem;font-size:13px}.bl-block-library__control[data-locked]{color:var(--theme-elevation-400,#94a3b8)}.bl-block-library__legend{margin:0 0 1.5rem;padding:.75rem 1rem;border:1px solid var(--theme-elevation-150,#e2e8f0);border-radius:12px;font-size:13px;line-height:1.45}.bl-block-library__legend h2{margin:0 0 .25rem;font-size:13px;font-weight:650}.bl-block-library__legend p{margin:0 0 .5rem;color:var(--theme-elevation-600,#475569)}.bl-block-library__legend dl{display:grid;grid-template-columns:max-content 1fr;gap:.25rem 1rem;margin:0}.bl-block-library__legend dt{font-weight:600}.bl-block-library__legend dd{margin:0;color:var(--theme-elevation-600,#475569)}.bl-block-library__refusal{margin:0;color:var(--theme-error-500,#b91c1c)}.bl-block-library__drafts{margin:.5rem 0 0;padding-inline-start:1.25rem}.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)}@media (max-width:768px){.bl-block-library{grid-template-columns:minmax(0,1fr)}.bl-block-library__rail{position:static;max-height:none;overflow:visible}.bl-block-library__legend dl{grid-template-columns:minmax(0,1fr);gap:0}.bl-block-library__legend dd{margin-block-end:.4rem}}`;
|
|
3960
3960
|
function holderLabel(holder) {
|
|
3961
3961
|
const title = holder.title?.trim() || "Untitled";
|
|
3962
3962
|
const slug = holder.slug?.trim();
|
|
@@ -4067,7 +4067,9 @@ function LibraryCard({ row, write, src, toggle, usageURL }) {
|
|
|
4067
4067
|
}
|
|
4068
4068
|
};
|
|
4069
4069
|
return /* @__PURE__ */ jsxs("article", {
|
|
4070
|
+
id: row.slug,
|
|
4070
4071
|
className: "bl-block-library__card",
|
|
4072
|
+
"data-block-card": row.slug,
|
|
4071
4073
|
children: [
|
|
4072
4074
|
/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("span", { children: row.label }), toggle ? /* @__PURE__ */ jsx(Switch, {
|
|
4073
4075
|
checked: row.enabled !== false,
|
|
@@ -4093,6 +4095,7 @@ function LibraryCard({ row, write, src, toggle, usageURL }) {
|
|
|
4093
4095
|
ref: frame,
|
|
4094
4096
|
title: row.label,
|
|
4095
4097
|
src,
|
|
4098
|
+
loading: "lazy",
|
|
4096
4099
|
style: height === null ? void 0 : { height }
|
|
4097
4100
|
}),
|
|
4098
4101
|
/* @__PURE__ */ jsxs(ConfirmDialog, {
|
|
@@ -4271,9 +4274,96 @@ const BlockLibraryField = (props) => {
|
|
|
4271
4274
|
]);
|
|
4272
4275
|
const rows = [...loaded, ...missing];
|
|
4273
4276
|
const previews = previewsOf(props.field);
|
|
4274
|
-
const [category, setCategory] = useState("hero");
|
|
4275
4277
|
const navbarCount = rows.filter((row) => row.kind === "navbar").length;
|
|
4276
|
-
const
|
|
4278
|
+
const categories = useMemo(() => railCategories(rows), [rows]);
|
|
4279
|
+
const [query, setQuery] = useState("");
|
|
4280
|
+
const [open, setOpen] = useState("hero");
|
|
4281
|
+
const [shown, setShown] = useState("hero");
|
|
4282
|
+
const [active, setActive] = useState(null);
|
|
4283
|
+
const [landing, setLanding] = useState(null);
|
|
4284
|
+
const gallery = useRef(null);
|
|
4285
|
+
const openCategory = useCallback((id) => {
|
|
4286
|
+
setOpen(id);
|
|
4287
|
+
if (id) setShown(id);
|
|
4288
|
+
}, []);
|
|
4289
|
+
const categoryOf = useCallback((slug) => rows.find((row) => row.slug === slug)?.category ?? null, [rows]);
|
|
4290
|
+
const categoryOfRef = useRef(categoryOf);
|
|
4291
|
+
categoryOfRef.current = categoryOf;
|
|
4292
|
+
useEffect(() => {
|
|
4293
|
+
const land = () => {
|
|
4294
|
+
const slug = slugFromHash(window.location.hash);
|
|
4295
|
+
const category = slug ? categoryOfRef.current(slug) : null;
|
|
4296
|
+
if (!slug || !category) return;
|
|
4297
|
+
setQuery("");
|
|
4298
|
+
openCategory(category);
|
|
4299
|
+
setActive(slug);
|
|
4300
|
+
setLanding(slug);
|
|
4301
|
+
};
|
|
4302
|
+
land();
|
|
4303
|
+
window.addEventListener("hashchange", land);
|
|
4304
|
+
return () => window.removeEventListener("hashchange", land);
|
|
4305
|
+
}, [openCategory]);
|
|
4306
|
+
useEffect(() => {
|
|
4307
|
+
if (!landing) return;
|
|
4308
|
+
const land = () => document.getElementById(landing)?.scrollIntoView({ block: "start" });
|
|
4309
|
+
land();
|
|
4310
|
+
const root = gallery.current;
|
|
4311
|
+
const resize = root && typeof ResizeObserver !== "undefined" ? new ResizeObserver(land) : null;
|
|
4312
|
+
if (root) resize?.observe(root);
|
|
4313
|
+
const release = () => setLanding(null);
|
|
4314
|
+
const timer = window.setTimeout(release, LANDING_HOLD_MS);
|
|
4315
|
+
const events = [
|
|
4316
|
+
"wheel",
|
|
4317
|
+
"touchstart",
|
|
4318
|
+
"keydown",
|
|
4319
|
+
"pointerdown"
|
|
4320
|
+
];
|
|
4321
|
+
for (const name of events) window.addEventListener(name, release, {
|
|
4322
|
+
once: true,
|
|
4323
|
+
passive: true
|
|
4324
|
+
});
|
|
4325
|
+
return () => {
|
|
4326
|
+
resize?.disconnect();
|
|
4327
|
+
window.clearTimeout(timer);
|
|
4328
|
+
for (const name of events) window.removeEventListener(name, release);
|
|
4329
|
+
};
|
|
4330
|
+
}, [landing]);
|
|
4331
|
+
const searching = query.trim().length > 0;
|
|
4332
|
+
const groups = searching ? filterCategories(categories, query).map((category) => ({
|
|
4333
|
+
id: category.id,
|
|
4334
|
+
label: category.label,
|
|
4335
|
+
rows: category.items.flatMap((item) => rows.filter((row) => row.slug === item.id))
|
|
4336
|
+
})) : [{
|
|
4337
|
+
id: shown,
|
|
4338
|
+
label: categories.find((category) => category.id === shown)?.label ?? "",
|
|
4339
|
+
rows: rows.filter((row) => row.category === shown)
|
|
4340
|
+
}];
|
|
4341
|
+
const visible = groups.flatMap((group) => group.rows);
|
|
4342
|
+
const visibleKey = visible.map((row) => row.slug).join(",");
|
|
4343
|
+
useEffect(() => {
|
|
4344
|
+
const root = gallery.current;
|
|
4345
|
+
if (!root || typeof IntersectionObserver === "undefined") return;
|
|
4346
|
+
const inView = /* @__PURE__ */ new Set();
|
|
4347
|
+
const observer = new IntersectionObserver((entries) => {
|
|
4348
|
+
for (const entry of entries) {
|
|
4349
|
+
const slug = entry.target.dataset.blockCard;
|
|
4350
|
+
if (!slug) continue;
|
|
4351
|
+
if (entry.isIntersecting) inView.add(slug);
|
|
4352
|
+
else inView.delete(slug);
|
|
4353
|
+
}
|
|
4354
|
+
const first = visibleKey.split(",").find((slug) => inView.has(slug));
|
|
4355
|
+
if (first) setActive(first);
|
|
4356
|
+
}, { rootMargin: "0px 0px -55% 0px" });
|
|
4357
|
+
root.querySelectorAll("[data-block-card]").forEach((card) => observer.observe(card));
|
|
4358
|
+
return () => observer.disconnect();
|
|
4359
|
+
}, [visibleKey, searching]);
|
|
4360
|
+
const card = (row) => /* @__PURE__ */ jsx(LibraryCard, {
|
|
4361
|
+
row,
|
|
4362
|
+
write: loaded.some((entry) => entry.slug === row.slug) ? writeRow(row.slug) : null,
|
|
4363
|
+
src: previews[row.slug] ?? "",
|
|
4364
|
+
toggle: row.kind !== "navbar" || navbarCount > 1,
|
|
4365
|
+
usageURL
|
|
4366
|
+
}, row.slug);
|
|
4277
4367
|
return /* @__PURE__ */ jsx(KitProvider, { children: /* @__PURE__ */ jsxs("div", {
|
|
4278
4368
|
className: "bl-block-library",
|
|
4279
4369
|
children: [
|
|
@@ -4282,27 +4372,53 @@ const BlockLibraryField = (props) => {
|
|
|
4282
4372
|
precedence: "default",
|
|
4283
4373
|
children: LIST_CSS$1
|
|
4284
4374
|
}),
|
|
4285
|
-
/* @__PURE__ */ jsx(
|
|
4375
|
+
/* @__PURE__ */ jsx(CategoryRail, {
|
|
4286
4376
|
className: "bl-block-library__rail",
|
|
4287
|
-
role: "navigation",
|
|
4288
4377
|
"aria-label": "Block categories",
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4378
|
+
categories,
|
|
4379
|
+
query,
|
|
4380
|
+
onQueryChange: setQuery,
|
|
4381
|
+
openId: open,
|
|
4382
|
+
onOpenChange: openCategory,
|
|
4383
|
+
activeItemId: active,
|
|
4384
|
+
onItemClick: (item) => setActive(item.id),
|
|
4385
|
+
searchLabel: "Search blocks",
|
|
4386
|
+
noun: "blocks"
|
|
4295
4387
|
}),
|
|
4296
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4388
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4389
|
+
ref: gallery,
|
|
4390
|
+
children: [visible.some((row) => row.kind !== "navbar") ? /* @__PURE__ */ jsx(SectionControlLegend, {}) : null, groups.map((group) => /* @__PURE__ */ jsxs("section", {
|
|
4391
|
+
className: "bl-block-library__group",
|
|
4392
|
+
...searching ? { "aria-label": group.label } : {},
|
|
4393
|
+
children: [searching ? /* @__PURE__ */ jsx("h2", { children: group.label }) : null, group.rows.map(card)]
|
|
4394
|
+
}, group.id))]
|
|
4395
|
+
})
|
|
4303
4396
|
]
|
|
4304
4397
|
}) });
|
|
4305
4398
|
};
|
|
4399
|
+
/** How long a `#slug` landing holds its card in place while islands above it resize. */
|
|
4400
|
+
const LANDING_HOLD_MS = 4e3;
|
|
4401
|
+
/** The rail's categories in catalogue order, each listing its cards. */
|
|
4402
|
+
function railCategories(rows) {
|
|
4403
|
+
return BLOCK_LIBRARY_CATEGORIES.map((category) => ({
|
|
4404
|
+
id: category.id,
|
|
4405
|
+
label: category.label,
|
|
4406
|
+
items: rows.filter((row) => row.category === category.id).map((row) => ({
|
|
4407
|
+
id: row.slug,
|
|
4408
|
+
label: row.label
|
|
4409
|
+
}))
|
|
4410
|
+
}));
|
|
4411
|
+
}
|
|
4412
|
+
/** The slug a `#<slug>` hash names, or `null`. */
|
|
4413
|
+
function slugFromHash(hash) {
|
|
4414
|
+
const raw = hash.replace(/^#/, "");
|
|
4415
|
+
if (!raw) return null;
|
|
4416
|
+
try {
|
|
4417
|
+
return decodeURIComponent(raw);
|
|
4418
|
+
} catch {
|
|
4419
|
+
return null;
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4306
4422
|
//#endregion
|
|
4307
4423
|
//#region src/admin/theme-kit-accent.tsx
|
|
4308
4424
|
function primaryHex(doc) {
|
|
@@ -4404,6 +4520,19 @@ function ListAlignStyles({ css, children }) {
|
|
|
4404
4520
|
}) : null, children] });
|
|
4405
4521
|
}
|
|
4406
4522
|
//#endregion
|
|
4523
|
+
//#region src/admin/block-drawer-styles.tsx
|
|
4524
|
+
/**
|
|
4525
|
+
* The Add Block drawer's stylesheet from `blockDrawer()`, handed in as
|
|
4526
|
+
* `clientProps` so the admin computes nothing at render.
|
|
4527
|
+
*/
|
|
4528
|
+
function BlockDrawerStyles({ css, children }) {
|
|
4529
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [css ? /* @__PURE__ */ jsx("style", {
|
|
4530
|
+
href: "bl-block-drawer",
|
|
4531
|
+
precedence: "default",
|
|
4532
|
+
children: css
|
|
4533
|
+
}) : null, children] });
|
|
4534
|
+
}
|
|
4535
|
+
//#endregion
|
|
4407
4536
|
//#region src/admin/document-create-new.tsx
|
|
4408
4537
|
/**
|
|
4409
4538
|
* Same words as a collection list Create New — no icon, no "Area" or
|
|
@@ -6734,6 +6863,6 @@ function ChevronMark() {
|
|
|
6734
6863
|
});
|
|
6735
6864
|
}
|
|
6736
6865
|
//#endregion
|
|
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 };
|
|
6866
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, 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 };
|
|
6738
6867
|
|
|
6739
6868
|
//# sourceMappingURL=admin.mjs.map
|