@bison-lab/payload-core 3.33.2 → 3.36.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 +14 -3
- package/dist/admin.d.mts +2 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +192 -59
- package/dist/admin.mjs.map +1 -1
- package/dist/identity-DOGDpCgK.mjs.map +1 -1
- package/dist/index.d.mts +21 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +72 -9
- package/dist/index.mjs.map +1 -1
- package/dist/looks-BbL309kO.mjs.map +1 -1
- package/dist/{preview-DNtjFJws.d.mts → preview-B2u9AkFF.d.mts} +2 -2
- package/dist/{preview-DNtjFJws.d.mts.map → preview-B2u9AkFF.d.mts.map} +1 -1
- package/dist/theme.d.mts +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -137,7 +137,11 @@ Contrast is the automatic label on editable fills at 7:1; it
|
|
|
137
137
|
is never enforced and lives in the Needs-attention modal, not on the page.
|
|
138
138
|
`bison.config.json` is the seed a site starts from, not the source of truth.
|
|
139
139
|
Pass `destructive` (or `seed.brandDestructive`); otherwise Theme uses the
|
|
140
|
-
library’s `DESTRUCTIVE_SCALE_HEX` (`#
|
|
140
|
+
library’s `DESTRUCTIVE_SCALE_HEX` (`#FF7C6B`). Success falls back to `#83CEA2`.
|
|
141
|
+
Changing a brand hex or **This color is** leaves the chips as they were;
|
|
142
|
+
**Regenerate scale** rewrites the ramp with the hex pinned at that step.
|
|
143
|
+
Success and Destructive family banners use the same scale steps as the
|
|
144
|
+
visitor Alert.
|
|
141
145
|
|
|
142
146
|
**1. Register the Global.** Access is required — Theme does not read the
|
|
143
147
|
Roles or Features Global. Pass `canUseFeature("theme")` as `update`
|
|
@@ -430,8 +434,15 @@ A site that already stored footer columns on the `nav` document copies
|
|
|
430
434
|
|
|
431
435
|
## FAQ Library
|
|
432
436
|
|
|
433
|
-
`createQuestions` is one document per FAQ (question,
|
|
434
|
-
with a kit List that replaces Payload's stock collection list.
|
|
437
|
+
`createQuestions` is one document per FAQ (question, richText answer, drafts)
|
|
438
|
+
with a kit List that replaces Payload's stock collection list. The answer is
|
|
439
|
+
Payload's default Lexical editor — the same one the pages rich-text block
|
|
440
|
+
uses; the kit dialog mounts it, not the stock document form. Hidden
|
|
441
|
+
`answerText` is the varchar the list searches; `syncAnswerText` (the
|
|
442
|
+
collection `beforeChange` hook, also exported) writes it whenever `answer`
|
|
443
|
+
is in the incoming data. A site that replaces `hooks.beforeChange` must
|
|
444
|
+
keep that hook or search stops matching answers. Do not `contains` on
|
|
445
|
+
`answer` — Postgres rejects `ilike` against jsonb. `createTaxonomy`
|
|
435
446
|
is a name-only terms collection, hidden from the nav; add and delete for
|
|
436
447
|
`manage: true` facets happen on that list. Pass Anatomy-like collections and
|
|
437
448
|
Topics through `organizeBy` — the package does not know "anatomy". Feature
|
package/dist/admin.d.mts
CHANGED
|
@@ -14,7 +14,8 @@ declare const ColorField: TextFieldClientComponent;
|
|
|
14
14
|
//#region src/admin/color-scale-field.d.ts
|
|
15
15
|
/**
|
|
16
16
|
* One system (or library row) color: hex, source step, include/exclude.
|
|
17
|
-
* Writes the group's stored fields. A committed hex or step
|
|
17
|
+
* Writes the group's stored fields. A committed hex or step marks the
|
|
18
|
+
* scale stale; Regenerate scale rewrites the ramp.
|
|
18
19
|
*/
|
|
19
20
|
declare const ColorScaleField: GroupFieldClientComponent;
|
|
20
21
|
//#endregion
|
package/dist/admin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/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
|
|
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;;;;;;;;cChCZ,gBAAA,EAAkB,wBAAA;;;;;;;;;ArBZ/B;;csB0Ca,mBAAA,EAAqB,yBAAA;;;iBCflB,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;;;A1BGpB;;;iB0B6CgB,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;;;;;;;;A7BClC;U8BFiB,cAAA;;EAEf,MAAA;E9ByED;E8BvEC,IAAA;;EAEA,KAAA;E7BmBW;E6BjBX,MAAA;AAAA;AAAA,UAGe,eAAA;E7BiEhB;E6B/DC,IAAA;;EAEA,KAAA;E5BgBW;E4BdX,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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as colorDocFromState, i as SYSTEM_COLOR_KEYS, n as pageEditorLooks, r as pageEditorTokens, s as stateFromColorDoc } from "./looks-BbL309kO.mjs";
|
|
3
3
|
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAuth, useBulkUpload, useConfig, useField, useForm, useFormFields, useListQuery, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
4
|
-
import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, setColorScaleInclude } from "@bison-lab/tokens";
|
|
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, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Fold, Input, KitProvider, Label, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Table, TableActions, TableCell, TableHead, TableRow,
|
|
7
|
+
import { Badge, Button as Button$1, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Fold, Input, KitProvider, Label, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Table, TableActions, TableCell, TableHead, TableRow, Thumbnail } 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";
|
|
11
11
|
import "payload";
|
|
12
|
+
import { RenderLexical } from "@payloadcms/richtext-lexical/client";
|
|
12
13
|
import { formatAdminURL, formatFilesize } from "payload/shared";
|
|
13
14
|
//#region src/admin/color-field.tsx
|
|
14
15
|
const HEX_ERROR = "Enter a six-digit hex colour like #1e3a5f";
|
|
@@ -320,6 +321,29 @@ function destructiveHueWarning(hex) {
|
|
|
320
321
|
function hslCss(value) {
|
|
321
322
|
return `hsl(${value})`;
|
|
322
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* The scale steps the visitor Alert uses for Success and Destructive.
|
|
326
|
+
* Light: 50 wash, 300 border, 900 ink, 600 mark on 100. Dark: 900 at 60%,
|
|
327
|
+
* 700 border, 100 ink, 300 mark on 800.
|
|
328
|
+
*/
|
|
329
|
+
function statusAlertPaint(scale, mode) {
|
|
330
|
+
if (mode === "dark") return {
|
|
331
|
+
fill: scale[900],
|
|
332
|
+
border: scale[700],
|
|
333
|
+
ink: scale[100],
|
|
334
|
+
mark: scale[300],
|
|
335
|
+
markWell: scale[800],
|
|
336
|
+
fillMix: .6
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
fill: scale[50],
|
|
340
|
+
border: scale[300],
|
|
341
|
+
ink: scale[900],
|
|
342
|
+
mark: scale[600],
|
|
343
|
+
markWell: scale[100],
|
|
344
|
+
fillMix: 1
|
|
345
|
+
};
|
|
346
|
+
}
|
|
323
347
|
/** Which appearances fail, in words. Empty when both pass. */
|
|
324
348
|
function hardToReadModes(item) {
|
|
325
349
|
const light = item.light.shortfall > 0;
|
|
@@ -518,12 +542,20 @@ const PREVIEW_VARS = [
|
|
|
518
542
|
"--bl-preview-muted",
|
|
519
543
|
"--bl-preview-input"
|
|
520
544
|
];
|
|
521
|
-
/**
|
|
545
|
+
/** Grey surfaces ignore brand; primary and destructive still come from the form. */
|
|
522
546
|
const PREVIEW_BRAND = {
|
|
523
547
|
primary: "#111111",
|
|
524
548
|
secondary: "#111111",
|
|
525
549
|
success: "#111111"
|
|
526
550
|
};
|
|
551
|
+
function brandForPreview(grey, brand) {
|
|
552
|
+
return {
|
|
553
|
+
...PREVIEW_BRAND,
|
|
554
|
+
grey,
|
|
555
|
+
primary: brand?.primary && isThemeHex(brand.primary) ? brand.primary : PREVIEW_BRAND.primary,
|
|
556
|
+
destructive: brand?.destructive && isThemeHex(brand.destructive) ? brand.destructive : void 0
|
|
557
|
+
};
|
|
558
|
+
}
|
|
527
559
|
function readDocumentTheme() {
|
|
528
560
|
if (typeof document === "undefined") return "light";
|
|
529
561
|
return document.documentElement.getAttribute("data-theme") === "dark" ? "dark" : "light";
|
|
@@ -554,14 +586,8 @@ function useThemePreviewMode() {
|
|
|
554
586
|
}, []);
|
|
555
587
|
return mode;
|
|
556
588
|
}
|
|
557
|
-
function previewVarsFor(grey, mode) {
|
|
558
|
-
const palette = mode === "dark" ? deriveDarkPalette(
|
|
559
|
-
...PREVIEW_BRAND,
|
|
560
|
-
grey
|
|
561
|
-
}) : deriveLightPalette({
|
|
562
|
-
...PREVIEW_BRAND,
|
|
563
|
-
grey
|
|
564
|
-
});
|
|
589
|
+
function previewVarsFor(grey, mode, brand) {
|
|
590
|
+
const palette = mode === "dark" ? deriveDarkPalette(brandForPreview(grey, brand)) : deriveLightPalette(brandForPreview(grey, brand));
|
|
565
591
|
return {
|
|
566
592
|
"--bl-preview-bg": `hsl(${palette.background})`,
|
|
567
593
|
"--bl-preview-card": `hsl(${palette.card})`,
|
|
@@ -569,11 +595,26 @@ function previewVarsFor(grey, mode) {
|
|
|
569
595
|
"--bl-preview-text": `hsl(${palette.foreground})`,
|
|
570
596
|
"--bl-preview-muted": `hsl(${palette["muted-foreground"]})`,
|
|
571
597
|
"--bl-preview-input": `hsl(${palette.input})`,
|
|
598
|
+
"--primary": palette.primary,
|
|
599
|
+
"--primary-foreground": palette["primary-foreground"],
|
|
600
|
+
"--destructive": palette.destructive,
|
|
601
|
+
"--destructive-foreground": palette["destructive-foreground"],
|
|
602
|
+
"--bl-kit-accent": `hsl(${palette.primary})`,
|
|
572
603
|
"--theme-elevation-0": `hsl(${palette.card})`,
|
|
573
604
|
"--theme-elevation-150": `hsl(${palette.border})`,
|
|
574
605
|
"--theme-elevation-800": `hsl(${palette.foreground})`
|
|
575
606
|
};
|
|
576
607
|
}
|
|
608
|
+
function usePreviewBrand() {
|
|
609
|
+
return useFormFields(([fields]) => {
|
|
610
|
+
const primary = fields["colors.brand.primary.hex"]?.value;
|
|
611
|
+
const destructive = fields["colors.brand.destructive.hex"]?.value;
|
|
612
|
+
return {
|
|
613
|
+
primary: typeof primary === "string" ? primary : void 0,
|
|
614
|
+
destructive: typeof destructive === "string" ? destructive : void 0
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
}
|
|
577
618
|
function useGreyScale() {
|
|
578
619
|
return useFormFields(([fields]) => {
|
|
579
620
|
const value = fields["colors.greyScale"]?.value;
|
|
@@ -589,7 +630,7 @@ function usePreviewCanvas() {
|
|
|
589
630
|
return {
|
|
590
631
|
mode,
|
|
591
632
|
className: "bl-preview-canvas",
|
|
592
|
-
style: previewVarsFor(useGreyScale(), mode)
|
|
633
|
+
style: previewVarsFor(useGreyScale(), mode, usePreviewBrand())
|
|
593
634
|
};
|
|
594
635
|
}
|
|
595
636
|
//#endregion
|
|
@@ -683,6 +724,17 @@ const STATUS_COPY = {
|
|
|
683
724
|
drift: "This color may no longer read as a destructive or error state."
|
|
684
725
|
}
|
|
685
726
|
};
|
|
727
|
+
function familyBannerStyle(state, mode) {
|
|
728
|
+
const paint = statusAlertPaint(state.scale, mode);
|
|
729
|
+
const fill = paint.fillMix < 1 ? `color-mix(in srgb, ${hslCss(paint.fill)} ${Math.round(paint.fillMix * 100)}%, var(--bl-preview-card, transparent))` : hslCss(paint.fill);
|
|
730
|
+
return {
|
|
731
|
+
"--bl-family-fill": fill,
|
|
732
|
+
"--bl-family-border": hslCss(paint.border),
|
|
733
|
+
"--bl-family-ink": hslCss(paint.ink),
|
|
734
|
+
"--bl-family-mark": hslCss(paint.mark),
|
|
735
|
+
"--bl-family-mark-well": hslCss(paint.markWell)
|
|
736
|
+
};
|
|
737
|
+
}
|
|
686
738
|
function IncludeMark({ on }) {
|
|
687
739
|
return /* @__PURE__ */ jsx("span", {
|
|
688
740
|
className: "bl-scale-card__status",
|
|
@@ -715,10 +767,10 @@ function ColorScaleCard({ id, name, hint, required, custom, state, onChange, onD
|
|
|
715
767
|
const included = new Set(includedShadeSteps(state));
|
|
716
768
|
const hueDrift = role === "success" ? Boolean(successHueWarning(state.hex)) : role === "destructive" ? Boolean(destructiveHueWarning(state.hex)) : false;
|
|
717
769
|
function commitHex(hex) {
|
|
718
|
-
onChange(
|
|
770
|
+
onChange(updateColorScale(state, { hex }));
|
|
719
771
|
}
|
|
720
772
|
function commitStep(step) {
|
|
721
|
-
onChange(
|
|
773
|
+
onChange(updateColorScale(state, { sourceStep: step }));
|
|
722
774
|
}
|
|
723
775
|
function toggleStep(step) {
|
|
724
776
|
if (step === state.sourceStep) {
|
|
@@ -736,6 +788,7 @@ function ColorScaleCard({ id, name, hint, required, custom, state, onChange, onD
|
|
|
736
788
|
children: /* @__PURE__ */ jsxs("article", {
|
|
737
789
|
className: `bl-scale-card ${canvas.className}`,
|
|
738
790
|
"data-preview": canvas.mode,
|
|
791
|
+
"data-stale": state.stale ? "" : void 0,
|
|
739
792
|
style: canvas.style,
|
|
740
793
|
children: [
|
|
741
794
|
/* @__PURE__ */ jsxs("header", {
|
|
@@ -770,38 +823,67 @@ function ColorScaleCard({ id, name, hint, required, custom, state, onChange, onD
|
|
|
770
823
|
}),
|
|
771
824
|
/* @__PURE__ */ jsxs("div", {
|
|
772
825
|
className: "bl-scale-card__row",
|
|
773
|
-
children: [
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
826
|
+
children: [
|
|
827
|
+
/* @__PURE__ */ jsxs(Field, {
|
|
828
|
+
as: "div",
|
|
829
|
+
children: [/* @__PURE__ */ jsx(Label, { children: "Brand hex" }), /* @__PURE__ */ jsx(BrandHexField, {
|
|
830
|
+
name,
|
|
831
|
+
value: state.hex,
|
|
832
|
+
onChange: commitHex,
|
|
833
|
+
readOnly
|
|
834
|
+
})]
|
|
835
|
+
}),
|
|
836
|
+
/* @__PURE__ */ jsxs(Field, {
|
|
837
|
+
as: "div",
|
|
838
|
+
children: [/* @__PURE__ */ jsx(Label, { children: "This color is" }), /* @__PURE__ */ jsxs(Select, {
|
|
839
|
+
value: String(state.sourceStep),
|
|
840
|
+
onValueChange: (value) => commitStep(Number(value)),
|
|
841
|
+
disabled: readOnly,
|
|
842
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
843
|
+
"aria-label": "This color is",
|
|
844
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
845
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: SHADE_STEPS.map((step) => /* @__PURE__ */ jsx(SelectItem, {
|
|
846
|
+
value: String(step),
|
|
847
|
+
children: step
|
|
848
|
+
}, step)) })]
|
|
849
|
+
})]
|
|
850
|
+
}),
|
|
851
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
852
|
+
type: "button",
|
|
853
|
+
variant: state.stale ? "primary" : "outline",
|
|
786
854
|
disabled: readOnly,
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
value: String(step),
|
|
792
|
-
children: step
|
|
793
|
-
}, step)) })]
|
|
794
|
-
})]
|
|
795
|
-
})]
|
|
855
|
+
onClick: () => onChange(regenerateColorScale(state)),
|
|
856
|
+
children: "Regenerate scale"
|
|
857
|
+
})
|
|
858
|
+
]
|
|
796
859
|
}),
|
|
860
|
+
state.stale ? /* @__PURE__ */ jsx("p", {
|
|
861
|
+
className: "bl-scale-card__stale",
|
|
862
|
+
children: "The chips still show the last generated scale. Regenerate after you set the hex and which step it is."
|
|
863
|
+
}) : null,
|
|
797
864
|
role ? /* @__PURE__ */ jsxs("div", {
|
|
798
865
|
className: "bl-scale-card__family",
|
|
799
866
|
"data-role": role,
|
|
800
867
|
"data-drift": hueDrift ? "" : void 0,
|
|
868
|
+
style: familyBannerStyle(state, canvas.mode),
|
|
801
869
|
children: [/* @__PURE__ */ jsx("div", {
|
|
802
870
|
className: "bl-scale-card__family-mark",
|
|
803
871
|
"aria-hidden": "true",
|
|
804
|
-
children: "
|
|
872
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
873
|
+
viewBox: "0 0 16 16",
|
|
874
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
875
|
+
d: "M8 3.4v6.1",
|
|
876
|
+
fill: "none",
|
|
877
|
+
stroke: "currentColor",
|
|
878
|
+
strokeWidth: "2.2",
|
|
879
|
+
strokeLinecap: "round"
|
|
880
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
881
|
+
cx: "8",
|
|
882
|
+
cy: "12.2",
|
|
883
|
+
r: "1.2",
|
|
884
|
+
fill: "currentColor"
|
|
885
|
+
})]
|
|
886
|
+
})
|
|
805
887
|
}), /* @__PURE__ */ jsxs("div", { children: [
|
|
806
888
|
/* @__PURE__ */ jsx("div", {
|
|
807
889
|
className: "bl-scale-card__family-title",
|
|
@@ -916,15 +998,15 @@ const COLOR_SCALE_CARD_CSS = `
|
|
|
916
998
|
.bl-scale-card__title{margin:0;font-size:1rem}
|
|
917
999
|
.bl-scale-card__hint{margin:.35rem 0 0;color:var(--bl-preview-muted,var(--theme-elevation-500,#64748b));font-size:12px}
|
|
918
1000
|
.bl-scale-card__delete{border:0;background:none;color:#be123c;font:inherit;font-size:13px;font-weight:600;cursor:pointer}
|
|
919
|
-
.bl-scale-card__row{display:grid;grid-template-columns:
|
|
1001
|
+
.bl-scale-card__row{display:grid;grid-template-columns:max-content 8rem max-content;gap:.75rem;margin-top:1rem;align-items:end}
|
|
920
1002
|
.bl-scale-card__row .bl-nav-kit__field{margin-bottom:0}
|
|
921
|
-
.bl-scale-
|
|
922
|
-
.bl-scale-
|
|
923
|
-
.bl-scale-
|
|
1003
|
+
.bl-scale-card__row .bl-brand-hex .bl-nav-kit__input{width:8.5ch;min-width:8.5ch}
|
|
1004
|
+
.bl-scale-card__stale{margin:.55rem 0 0;font-size:12px;font-weight:600;color:#92400e}
|
|
1005
|
+
.bl-scale-card[data-stale] .bl-scale-card__chip{opacity:.55}
|
|
1006
|
+
.bl-scale-card__family{display:flex;gap:.75rem;align-items:flex-start;margin-top:1rem;padding:.75rem .85rem;border-radius:8px;border:1px solid var(--bl-family-border);background:var(--bl-family-fill);color:var(--bl-family-ink)}
|
|
924
1007
|
.bl-scale-card__family[data-drift]{box-shadow:0 0 0 2px #fbbf24}
|
|
925
|
-
.bl-scale-card__family-mark{flex:none;width:1.25rem;height:1.25rem;border-radius:999px;display:grid;place-items:center;
|
|
926
|
-
.bl-scale-card__family
|
|
927
|
-
.bl-scale-card__family[data-role=destructive] .bl-scale-card__family-mark{background:#ffe4e6;color:#be123c}
|
|
1008
|
+
.bl-scale-card__family-mark{flex:none;width:1.25rem;height:1.25rem;border-radius:999px;display:grid;place-items:center;background:var(--bl-family-mark-well);color:var(--bl-family-mark)}
|
|
1009
|
+
.bl-scale-card__family-mark svg{display:block;width:10px;height:10px}
|
|
928
1010
|
.bl-scale-card__family-title{font-size:12px;font-weight:600}
|
|
929
1011
|
.bl-scale-card__family p{margin:.25rem 0 0;font-size:11px;line-height:1.45;opacity:.85}
|
|
930
1012
|
.bl-scale-card__family-drift{font-weight:600;opacity:1}
|
|
@@ -955,6 +1037,7 @@ const COLOR_SCALE_CARD_CSS = `
|
|
|
955
1037
|
.bl-scale-card__panel-head button{border:0;background:none;font:inherit;font-size:1.25rem;line-height:1;color:#64748b;cursor:pointer}
|
|
956
1038
|
.bl-scale-card__panel-done{margin-top:1rem;min-height:2.1rem;padding:.35rem .85rem;border:0;border-radius:8px;background:#0f172a;color:#fff;font:inherit;font-weight:600;cursor:pointer}
|
|
957
1039
|
.bl-scale-card[data-preview=dark] .bl-scale-card__step[data-source] .bl-scale-card__chip{box-shadow:0 0 0 2px var(--bl-preview-text,#fafafa)}
|
|
1040
|
+
.bl-scale-card[data-preview=dark] .bl-scale-card__stale{color:#fde68a}
|
|
958
1041
|
` + READABILITY_LIST_CSS + THEME_COLORS_LAYOUT_CSS;
|
|
959
1042
|
//#endregion
|
|
960
1043
|
//#region src/admin/color-scale-field.tsx
|
|
@@ -975,7 +1058,8 @@ function includedStepsFromForm(path, value, getDataByPath) {
|
|
|
975
1058
|
}
|
|
976
1059
|
/**
|
|
977
1060
|
* One system (or library row) color: hex, source step, include/exclude.
|
|
978
|
-
* Writes the group's stored fields. A committed hex or step
|
|
1061
|
+
* Writes the group's stored fields. A committed hex or step marks the
|
|
1062
|
+
* scale stale; Regenerate scale rewrites the ramp.
|
|
979
1063
|
*/
|
|
980
1064
|
const ColorScaleField = ({ field, path, readOnly }) => {
|
|
981
1065
|
const hex = useField({ path: `${path}.hex` });
|
|
@@ -2006,8 +2090,8 @@ const GREY_SCALE_FIELD_CSS = `
|
|
|
2006
2090
|
.bl-grey__head h2{margin:0;font-size:1.1rem}
|
|
2007
2091
|
.bl-grey__head p{margin:.35rem 0 0;max-width:40rem;font-size:13px;color:var(--bl-preview-muted,var(--theme-elevation-500,#64748b))}
|
|
2008
2092
|
.bl-grey__choices{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:.6rem;padding:0 1.15rem 1.15rem;border:1px solid var(--bl-preview-border,var(--theme-elevation-150,#e2e8f0));border-top:0;border-radius:0 0 12px 12px;background:var(--bl-preview-card,var(--theme-elevation-0,#fff));color:var(--bl-preview-text,inherit)}
|
|
2009
|
-
.bl-grey__choice{display:flex;flex-direction:column;gap:.45rem;padding:.75rem;border:1px solid var(--bl-preview-border,var(--theme-elevation-150,#e2e8f0));border-radius:12px;background:
|
|
2010
|
-
.bl-grey__choice[data-selected]{
|
|
2093
|
+
.bl-grey__choice{display:flex;flex-direction:column;gap:.45rem;padding:.75rem;border:1px solid var(--bl-preview-border,var(--theme-elevation-150,#e2e8f0));border-radius:12px;background:transparent;color:inherit;cursor:pointer}
|
|
2094
|
+
.bl-grey__choice[data-selected]{border-width:2px;border-color:hsl(var(--primary))}
|
|
2011
2095
|
.bl-grey__choice input{position:absolute;opacity:0;pointer-events:none}
|
|
2012
2096
|
.bl-grey__ramp{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px}
|
|
2013
2097
|
.bl-grey__ramp i{display:block;height:2rem;border-radius:6px}
|
|
@@ -4109,7 +4193,9 @@ const QUESTIONS_LIST_CSS = `
|
|
|
4109
4193
|
.bl-faq-library__taxrow .bl-faq-library__taxmeta{display:inline-flex;align-items:center;gap:14px}
|
|
4110
4194
|
.bl-faq-library__addrow{display:flex;gap:7px;padding:10px;border-top:1px solid var(--bl-kit-border);background:var(--bl-kit-surface-well)}
|
|
4111
4195
|
.bl-faq-library__addrow .bl-nav-kit__input{flex:1;min-width:0}
|
|
4112
|
-
.bl-faq-
|
|
4196
|
+
.bl-faq-library__answer-editor{min-height:180px}
|
|
4197
|
+
.bl-faq-library__answer-editor .rich-text-lexical{border:1px solid var(--bl-kit-border);border-radius:var(--bl-kit-radius-sm);background:var(--bl-kit-surface)}
|
|
4198
|
+
.bl-faq-library__modal .bl-nav-kit__modal-card{width:min(840px,calc(100vw - 2rem))}
|
|
4113
4199
|
.bl-faq-library__modal-card{width:min(760px,calc(100vw - 2rem));max-height:calc(100vh - 48px);overflow:auto;background:var(--bl-kit-surface);border:1px solid var(--bl-kit-border);border-radius:var(--bl-kit-radius-lg);box-shadow:var(--bl-kit-shadow)}
|
|
4114
4200
|
.bl-faq-library__grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}
|
|
4115
4201
|
.bl-faq-library__section{font-weight:800;margin:4px 0 12px;padding-top:14px;border-top:1px solid var(--bl-kit-border-divider)}
|
|
@@ -4143,6 +4229,46 @@ const QUESTIONS_LIST_CSS = `
|
|
|
4143
4229
|
}
|
|
4144
4230
|
`;
|
|
4145
4231
|
//#endregion
|
|
4232
|
+
//#region src/questions/lexical-text.ts
|
|
4233
|
+
/**
|
|
4234
|
+
* Plain text inside a Lexical document (or a leftover string). Empty
|
|
4235
|
+
* when there are no text nodes, or only whitespace — the same rule the
|
|
4236
|
+
* kit dialog uses to refuse an empty answer.
|
|
4237
|
+
*/
|
|
4238
|
+
function lexicalPlainText(value) {
|
|
4239
|
+
if (value == null) return "";
|
|
4240
|
+
if (typeof value === "string") return value.replace(/\s+/g, " ").trim();
|
|
4241
|
+
return collect(value).replace(/\s+/g, " ").trim();
|
|
4242
|
+
}
|
|
4243
|
+
const BLOCK_SIBLING = new Set([
|
|
4244
|
+
"paragraph",
|
|
4245
|
+
"heading",
|
|
4246
|
+
"quote",
|
|
4247
|
+
"list",
|
|
4248
|
+
"listitem"
|
|
4249
|
+
]);
|
|
4250
|
+
function isBlockSibling(node) {
|
|
4251
|
+
if (!node || typeof node !== "object") return false;
|
|
4252
|
+
return BLOCK_SIBLING.has(String(node.type));
|
|
4253
|
+
}
|
|
4254
|
+
function collect(node) {
|
|
4255
|
+
if (typeof node === "string") return node;
|
|
4256
|
+
if (!node || typeof node !== "object") return "";
|
|
4257
|
+
const rec = node;
|
|
4258
|
+
if (typeof rec.text === "string") return rec.text;
|
|
4259
|
+
if (rec.type === "linebreak") return " ";
|
|
4260
|
+
if (rec.root) return collect(rec.root);
|
|
4261
|
+
if (!Array.isArray(rec.children)) return "";
|
|
4262
|
+
let out = "";
|
|
4263
|
+
for (const child of rec.children) {
|
|
4264
|
+
const piece = collect(child);
|
|
4265
|
+
if (!piece) continue;
|
|
4266
|
+
if (out && isBlockSibling(child)) out += " ";
|
|
4267
|
+
out += piece;
|
|
4268
|
+
}
|
|
4269
|
+
return out;
|
|
4270
|
+
}
|
|
4271
|
+
//#endregion
|
|
4146
4272
|
//#region src/admin/questions-list.tsx
|
|
4147
4273
|
const ALL = "__all__";
|
|
4148
4274
|
const PAGE_SIZE = 25;
|
|
@@ -4288,7 +4414,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4288
4414
|
const [faqOpen, setFaqOpen] = useState(false);
|
|
4289
4415
|
const [editing, setEditing] = useState(null);
|
|
4290
4416
|
const [draftQuestion, setDraftQuestion] = useState("");
|
|
4291
|
-
const [draftAnswer, setDraftAnswer] = useState(
|
|
4417
|
+
const [draftAnswer, setDraftAnswer] = useState(null);
|
|
4292
4418
|
const [draftFacets, setDraftFacets] = useState({});
|
|
4293
4419
|
const [published, setPublished] = useState(true);
|
|
4294
4420
|
const [inlineTopic, setInlineTopic] = useState(null);
|
|
@@ -4321,7 +4447,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4321
4447
|
const where = { and: [] };
|
|
4322
4448
|
const and = where.and;
|
|
4323
4449
|
const q = search.trim();
|
|
4324
|
-
if (q) and.push({ or: [{ question: { contains: q } }, {
|
|
4450
|
+
if (q) and.push({ or: [{ question: { contains: q } }, { answerText: { contains: q } }] });
|
|
4325
4451
|
for (const [field, value] of Object.entries(filters)) if (value) and.push({ [field]: { equals: value } });
|
|
4326
4452
|
const params = new URLSearchParams({
|
|
4327
4453
|
depth: "1",
|
|
@@ -4393,7 +4519,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4393
4519
|
function openFaq(doc) {
|
|
4394
4520
|
setEditing(doc);
|
|
4395
4521
|
setDraftQuestion(doc?.question ?? "");
|
|
4396
|
-
setDraftAnswer(doc?.answer ??
|
|
4522
|
+
setDraftAnswer(doc?.answer ?? null);
|
|
4397
4523
|
setPublished(doc ? doc._status !== "draft" : true);
|
|
4398
4524
|
const selected = {};
|
|
4399
4525
|
for (const entry of organizeBy) selected[entry.name] = doc ? idsFrom(doc[entry.name]) : [];
|
|
@@ -4414,8 +4540,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4414
4540
|
}
|
|
4415
4541
|
async function saveFaq() {
|
|
4416
4542
|
const question = draftQuestion.trim();
|
|
4417
|
-
|
|
4418
|
-
if (!question || !answer) {
|
|
4543
|
+
if (!question || !lexicalPlainText(draftAnswer)) {
|
|
4419
4544
|
setError("Question and answer are required.");
|
|
4420
4545
|
return;
|
|
4421
4546
|
}
|
|
@@ -4423,7 +4548,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4423
4548
|
setError(null);
|
|
4424
4549
|
const body = {
|
|
4425
4550
|
question,
|
|
4426
|
-
answer,
|
|
4551
|
+
answer: draftAnswer,
|
|
4427
4552
|
_status: published ? "published" : "draft",
|
|
4428
4553
|
...Object.fromEntries(organizeBy.map((entry) => [entry.name, draftFacets[entry.name] ?? []]))
|
|
4429
4554
|
};
|
|
@@ -4594,7 +4719,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4594
4719
|
children: doc.question
|
|
4595
4720
|
}), /* @__PURE__ */ jsx("p", {
|
|
4596
4721
|
className: "bl-faq-library__answer",
|
|
4597
|
-
children: doc.answer
|
|
4722
|
+
children: lexicalPlainText(doc.answer)
|
|
4598
4723
|
})] }),
|
|
4599
4724
|
organizeBy.map((entry) => {
|
|
4600
4725
|
const chips = chipsFrom$1(doc[entry.name]);
|
|
@@ -4744,10 +4869,18 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4744
4869
|
onChange: (event) => setDraftQuestion(event.target.value),
|
|
4745
4870
|
placeholder: "e.g. How long does recovery usually take?"
|
|
4746
4871
|
})] }),
|
|
4747
|
-
/* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(Label, { children: "Answer" }), /* @__PURE__ */ jsx(
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4872
|
+
/* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(Label, { children: "Answer" }), /* @__PURE__ */ jsx("div", {
|
|
4873
|
+
className: "bl-faq-library__answer-editor",
|
|
4874
|
+
children: /* @__PURE__ */ jsx(RenderLexical, {
|
|
4875
|
+
field: {
|
|
4876
|
+
name: "answer",
|
|
4877
|
+
type: "richText"
|
|
4878
|
+
},
|
|
4879
|
+
path: "answer",
|
|
4880
|
+
schemaPath: `collection.${collectionSlug}.answer`,
|
|
4881
|
+
value: draftAnswer && typeof draftAnswer === "object" ? draftAnswer : void 0,
|
|
4882
|
+
setValue: (next) => setDraftAnswer(next)
|
|
4883
|
+
}, editing ? String(editing.id) : "new")
|
|
4751
4884
|
})] }),
|
|
4752
4885
|
organizeBy.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
4753
4886
|
className: "bl-faq-library__section",
|