@bettercms-ai/kit 3.2.0 → 4.1.1
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/dist/adapters/lossy.d.ts +4 -0
- package/dist/adapters/lossy.js +4 -0
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/prod-types.d.ts +4 -0
- package/dist/adapters/prod-types.js +4 -1
- package/dist/adapters/prod-types.js.map +1 -1
- package/dist/adapters/schema.js +7 -0
- package/dist/adapters/schema.js.map +1 -1
- package/dist/context.d.ts +81 -4
- package/dist/context.js +58 -1
- package/dist/context.js.map +1 -1
- package/dist/controls/choice.d.ts +1 -1
- package/dist/controls/choice.js +21 -2
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/index.d.ts +1 -0
- package/dist/controls/index.js +3 -2
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/link.d.ts +23 -2
- package/dist/controls/link.js +456 -4
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/media-v16.d.ts +27 -0
- package/dist/controls/media-v16.js +261 -0
- package/dist/controls/media-v16.js.map +1 -0
- package/dist/controls/media.js +63 -1
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/reference-services.d.ts +8 -0
- package/dist/controls/reference.js +78 -2
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/ai-runs.d.ts +13 -0
- package/dist/controls/rich-text/ai-runs.js +71 -0
- package/dist/controls/rich-text/ai-runs.js.map +1 -0
- package/dist/controls/rich-text/block-tool.d.ts +31 -0
- package/dist/controls/rich-text/block-tool.js +62 -0
- package/dist/controls/rich-text/block-tool.js.map +1 -0
- package/dist/controls/rich-text/blocks.d.ts +6 -1
- package/dist/controls/rich-text/blocks.js +404 -24
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +21 -6
- package/dist/controls/rich-text/catalog.js +312 -23
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/code-head.d.ts +30 -0
- package/dist/controls/rich-text/code-head.js +230 -0
- package/dist/controls/rich-text/code-head.js.map +1 -0
- package/dist/controls/rich-text/codec.d.ts +3 -3
- package/dist/controls/rich-text/codec.js +3 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/control.d.ts +1 -1
- package/dist/controls/rich-text/control.js +11 -29
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/dom.d.ts +27 -0
- package/dist/controls/rich-text/dom.js +69 -4
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.js +212 -50
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/ops.js +1 -0
- package/dist/controls/rich-text/ops.js.map +1 -1
- package/dist/controls/rich-text/slash-preview.d.ts +8 -0
- package/dist/controls/rich-text/slash-preview.js +287 -0
- package/dist/controls/rich-text/slash-preview.js.map +1 -0
- package/dist/controls/rich-text/table-grid.d.ts +22 -0
- package/dist/controls/rich-text/table-grid.js +1052 -0
- package/dist/controls/rich-text/table-grid.js.map +1 -0
- package/dist/controls/rich-text/toolbar.js +60 -18
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.d.ts +6 -0
- package/dist/controls/text.js +95 -5
- package/dist/controls/text.js.map +1 -1
- package/dist/core/facets.d.ts +1 -0
- package/dist/core/facets.js +1 -0
- package/dist/core/facets.js.map +1 -1
- package/dist/engine/array.d.ts +7 -0
- package/dist/engine/array.js +164 -45
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/expand.d.ts +1 -1
- package/dist/engine/expand.js +1 -1
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/field-shell.d.ts +12 -0
- package/dist/engine/field-shell.js +217 -63
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +39 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.d.ts +71 -10
- package/dist/engine/grouping.js +223 -26
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/held.d.ts +2 -2
- package/dist/engine/held.js +2 -2
- package/dist/engine/held.js.map +1 -1
- package/dist/engine/kit-field.d.ts +0 -10
- package/dist/engine/kit-field.js +40 -72
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +7 -2
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/kit.css +85 -0
- package/dist/schema/table.d.ts +2 -1
- package/dist/schema/table.js +5 -0
- package/dist/schema/table.js.map +1 -1
- package/dist/schema/types.d.ts +6 -0
- package/dist/schema/types.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +115 -0
- package/dist/tokens.css +268 -0
- package/dist/ui/block-icon-picker.d.ts +38 -0
- package/dist/ui/block-icon-picker.js +141 -0
- package/dist/ui/block-icon-picker.js.map +1 -0
- package/dist/ui/button.js +1 -0
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/code-language-menu.d.ts +24 -0
- package/dist/ui/code-language-menu.js +123 -0
- package/dist/ui/code-language-menu.js.map +1 -0
- package/dist/ui/content-fields.d.ts +47 -0
- package/dist/ui/content-fields.js +278 -0
- package/dist/ui/content-fields.js.map +1 -0
- package/dist/ui/foundations.d.ts +118 -0
- package/dist/ui/foundations.js +564 -0
- package/dist/ui/foundations.js.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +7 -1
- package/dist/ui/inspector.d.ts +394 -0
- package/dist/ui/inspector.js +1173 -0
- package/dist/ui/inspector.js.map +1 -0
- package/dist/ui/overlay.d.ts +7 -2
- package/dist/ui/overlay.js +55 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/shortcut-hint.js +1 -1
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/toast.d.ts +5 -3
- package/dist/ui/toast.js +83 -11
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-card.d.ts +45 -0
- package/dist/ui/tooltip-card.js +135 -0
- package/dist/ui/tooltip-card.js.map +1 -0
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -56,6 +56,12 @@ export interface KitToastOptions {
|
|
|
56
56
|
label: string;
|
|
57
57
|
onClick: () => void;
|
|
58
58
|
};
|
|
59
|
+
/** several actions (prototype `notify` takes one or more); the kit toaster draws them all under look "v16",
|
|
60
|
+
* the first one otherwise. Wins over `action`. */
|
|
61
|
+
actions?: {
|
|
62
|
+
label: string;
|
|
63
|
+
onClick: () => void;
|
|
64
|
+
}[];
|
|
59
65
|
duration?: number;
|
|
60
66
|
icon?: React.ReactNode;
|
|
61
67
|
}
|
|
@@ -64,6 +70,35 @@ export interface KitToast {
|
|
|
64
70
|
(message: string, opts?: KitToastOptions): void;
|
|
65
71
|
success: (message: string, opts?: KitToastOptions) => void;
|
|
66
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The slash menu's "BetterCMS AI" commands (look "v16", prototype content.jsx:1210). The host's `aiCommand` service
|
|
75
|
+
* produces the text; without it the menu offers no AI row.
|
|
76
|
+
*/
|
|
77
|
+
export type AiCommandKind = "prompt" | "continue" | "improve" | "shorter" | "summarize" | "translate" | "spelling";
|
|
78
|
+
export declare const AI_COMMANDS: {
|
|
79
|
+
id: AiCommandKind;
|
|
80
|
+
label: string;
|
|
81
|
+
description: string;
|
|
82
|
+
}[];
|
|
83
|
+
/** The commands that rewrite the block above the caret; the others write new text at the caret. */
|
|
84
|
+
export declare const AI_REWRITE_COMMANDS: readonly AiCommandKind[];
|
|
85
|
+
/** What the body hands the host with a command. All plain text. */
|
|
86
|
+
export interface AiCommandContext {
|
|
87
|
+
/** the whole body */
|
|
88
|
+
text: string;
|
|
89
|
+
/** everything above the caret's line (what Continue writing picks up and Summarize reads) */
|
|
90
|
+
before: string;
|
|
91
|
+
/** the block a rewrite command replaces: the text block right above the caret's line ("" for the writing commands) */
|
|
92
|
+
target: string;
|
|
93
|
+
/** what stands on the caret's line once "/…" is removed (a prompt typed inline) */
|
|
94
|
+
line: string;
|
|
95
|
+
/** a rewrite's target cut at its formatting (bold, italic, links, code…): its text runs in order, which joined
|
|
96
|
+
* give `target`. An answer that keeps these runs (joined by AI_RUN_SEPARATOR, or keeping every formatted run's
|
|
97
|
+
* words unchanged) keeps their formatting; any other answer replaces the target as plain text. [] otherwise. */
|
|
98
|
+
runs: string[];
|
|
99
|
+
}
|
|
100
|
+
/** Join the rewritten `AiCommandContext.runs` with this (U+241E) to keep each run's formatting in a rewrite. */
|
|
101
|
+
export declare const AI_RUN_SEPARATOR = "\u241E";
|
|
67
102
|
/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */
|
|
68
103
|
export type AiPreset = "improve" | "shorter" | "longer" | "simplify" | "grammar" | "translate";
|
|
69
104
|
export declare const AI_PRESETS: {
|
|
@@ -150,6 +185,13 @@ export interface KitServices {
|
|
|
150
185
|
saveSlug?: (to: string) => Promise<void>;
|
|
151
186
|
/** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts "Try again" presses. */
|
|
152
187
|
aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;
|
|
188
|
+
/**
|
|
189
|
+
* The slash menu's "BetterCMS AI" view (look "v16"). Absent → the slash menu has no AI row. The answer is plain text
|
|
190
|
+
* (paragraphs split by a blank line): a rewrite command (AI_REWRITE_COMMANDS) replaces `context.target` with it, any
|
|
191
|
+
* other command writes it at the caret's line. No answer (void) means the host showed its own UI and nothing is
|
|
192
|
+
* written. A rejection is named in a toast.
|
|
193
|
+
*/
|
|
194
|
+
aiCommand?: (kind: AiCommandKind, context: AiCommandContext) => string | void | Promise<string | void>;
|
|
153
195
|
/** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */
|
|
154
196
|
FieldComments?: React.ComponentType<KitFieldCommentsProps>;
|
|
155
197
|
/**
|
|
@@ -158,11 +200,22 @@ export interface KitServices {
|
|
|
158
200
|
*/
|
|
159
201
|
useFieldCommentCount?: (docId: string, fieldKey: string) => number;
|
|
160
202
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
203
|
+
* How the popover around `FieldComments` is drawn (REQ-3-7): its distance from the field, its side shift and its
|
|
204
|
+
* class (width, and `!border-0 !bg-transparent !shadow-none` when the host's composer is the surface). `selection` is
|
|
205
|
+
* true when it opens on selected words (the quote popover). Absent → 8 under the field, 280 to 420 wide.
|
|
164
206
|
*/
|
|
165
|
-
|
|
207
|
+
fieldCommentsPopover?: (p: {
|
|
208
|
+
selection: boolean;
|
|
209
|
+
}) => {
|
|
210
|
+
sideOffset?: number;
|
|
211
|
+
alignOffset?: number;
|
|
212
|
+
className?: string;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* A field WITH open threads: its count button opens the host's Comments panel on that field instead of the in-place
|
|
216
|
+
* popover (REQ-3-7). Absent → the popover opens with the threads.
|
|
217
|
+
*/
|
|
218
|
+
onOpenFieldThreads?: (docId: string, fieldKey: string) => void;
|
|
166
219
|
/**
|
|
167
220
|
* HELD fields (kit 3.2.0), for a hold that depends on the stored value (a value an adapter cannot map back unchanged):
|
|
168
221
|
* a reason → the field at `path` renders read-only in its shell with that reason (`data-kit-held`) and is never
|
|
@@ -434,3 +487,27 @@ export interface FormApi {
|
|
|
434
487
|
}
|
|
435
488
|
export declare const FormProvider: React.Provider<FormApi | null>;
|
|
436
489
|
export declare const useForm: () => FormApi | null;
|
|
490
|
+
/**
|
|
491
|
+
* "v2" (default) is the kit's own look, on every dashboard route. "v16" is the Visual Editor inspector of prototype
|
|
492
|
+
* editor-v16 (INSPECTOR-FRAMEWORK §3): FieldSection draws the Section header (16 icon, 14/20 medium, rule UNDER the
|
|
493
|
+
* group), an array's rows sit in the grey item list card with Add inside and the "n of max" note, and an item screen
|
|
494
|
+
* ends with the red Delete. A host opts in by wrapping its inspector in <KitLookProvider>; nothing else changes.
|
|
495
|
+
*/
|
|
496
|
+
export type KitLook = "v2" | "v16";
|
|
497
|
+
export declare function KitLookProvider({ look, children }: {
|
|
498
|
+
look?: KitLook;
|
|
499
|
+
children: React.ReactNode;
|
|
500
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
501
|
+
export declare const useKitLook: () => KitLook;
|
|
502
|
+
/**
|
|
503
|
+
* P-FDOT (prototype inspector.jsx:1220-1226, kit.css:506-515): the field a canvas click opened. The host sets it to
|
|
504
|
+
* the field's path key (pathKey(path), e.g. "title" or "cta.label"); that field's label gets the 6px violet dot, and
|
|
505
|
+
* `flash` (any value that changes per click, e.g. a counter) runs the violet sweep across it once. The host clears it
|
|
506
|
+
* (null) when the author clicks or types in the field. Null everywhere else: nothing is drawn.
|
|
507
|
+
*/
|
|
508
|
+
export interface KitFocusField {
|
|
509
|
+
key: string;
|
|
510
|
+
flash?: number | string;
|
|
511
|
+
}
|
|
512
|
+
export declare const KitFocusFieldProvider: React.Provider<KitFocusField | null>;
|
|
513
|
+
export declare const useKitFocusField: () => KitFocusField | null;
|
package/dist/context.js
CHANGED
|
@@ -11,6 +11,52 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
* palette, permissions, presence, comments. Has safe defaults so a control can render alone.
|
|
12
12
|
* - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.
|
|
13
13
|
*/
|
|
14
|
+
var AI_COMMANDS = [
|
|
15
|
+
{
|
|
16
|
+
id: "prompt",
|
|
17
|
+
label: "Write a prompt",
|
|
18
|
+
description: "Generate text from a prompt"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "continue",
|
|
22
|
+
label: "Continue writing",
|
|
23
|
+
description: "Pick up where you stopped"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "improve",
|
|
27
|
+
label: "Improve writing",
|
|
28
|
+
description: "Smooth tone and clarity"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "shorter",
|
|
32
|
+
label: "Make shorter",
|
|
33
|
+
description: "Same point, fewer words"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "summarize",
|
|
37
|
+
label: "Summarize",
|
|
38
|
+
description: "Pull out the key points"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "translate",
|
|
42
|
+
label: "Translate",
|
|
43
|
+
description: "Into another language"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "spelling",
|
|
47
|
+
label: "Fix spelling",
|
|
48
|
+
description: "Spelling and grammar"
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
/** The commands that rewrite the block above the caret; the others write new text at the caret. */
|
|
52
|
+
var AI_REWRITE_COMMANDS = [
|
|
53
|
+
"improve",
|
|
54
|
+
"shorter",
|
|
55
|
+
"translate",
|
|
56
|
+
"spelling"
|
|
57
|
+
];
|
|
58
|
+
/** Join the rewritten `AiCommandContext.runs` with this (U+241E) to keep each run's formatting in a rewrite. */
|
|
59
|
+
var AI_RUN_SEPARATOR = "␞";
|
|
14
60
|
var AI_PRESETS = [
|
|
15
61
|
{
|
|
16
62
|
id: "improve",
|
|
@@ -255,7 +301,18 @@ var useKitEnv = () => React.useContext(EnvCtx);
|
|
|
255
301
|
var FormCtx = React.createContext(null);
|
|
256
302
|
var FormProvider = FormCtx.Provider;
|
|
257
303
|
var useForm = () => React.useContext(FormCtx);
|
|
304
|
+
var LookCtx = React.createContext("v2");
|
|
305
|
+
function KitLookProvider({ look = "v16", children }) {
|
|
306
|
+
return /* @__PURE__ */ jsx(LookCtx.Provider, {
|
|
307
|
+
value: look,
|
|
308
|
+
children
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
var useKitLook = () => React.useContext(LookCtx);
|
|
312
|
+
var FocusFieldCtx = React.createContext(null);
|
|
313
|
+
var KitFocusFieldProvider = FocusFieldCtx.Provider;
|
|
314
|
+
var useKitFocusField = () => React.useContext(FocusFieldCtx);
|
|
258
315
|
//#endregion
|
|
259
|
-
export { AI_PRESETS, DEFAULT_ENV, FieldHeaderSlot, FormProvider, KitAddressContext, KitEnvProvider, KitSectionTitle, KitServicesProvider, SITE_PALETTE, fieldAccessOf, registerKitServices, resolveFieldAccess, seesDevSurfaces, useForm, useKitEnv, useKitServices, useRichTextRefs, visibleFields, visibleSchema };
|
|
316
|
+
export { AI_COMMANDS, AI_PRESETS, AI_REWRITE_COMMANDS, AI_RUN_SEPARATOR, DEFAULT_ENV, FieldHeaderSlot, FormProvider, KitAddressContext, KitEnvProvider, KitFocusFieldProvider, KitLookProvider, KitSectionTitle, KitServicesProvider, SITE_PALETTE, fieldAccessOf, registerKitServices, resolveFieldAccess, seesDevSurfaces, useForm, useKitEnv, useKitFocusField, useKitLook, useKitServices, useRichTextRefs, visibleFields, visibleSchema };
|
|
260
317
|
|
|
261
318
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../src/context.tsx"],"sourcesContent":["/**\n * Kit runtime contexts (V2 HEAD 9829bf1 kit/context.tsx).\n *\n * - KitServices — pluggable app services (media library picker, upload sink, toast, AI rewrite, comment threads).\n * Hosts register theirs once (`registerKitServices`) or provide them (`KitServicesProvider`); the kit\n * never imports a feature. A service that is absent hides the surface that needs it.\n * - KitEnv — the editing environment a control renders in: variant (panel | document), doc identity, site\n * palette, permissions, presence, comments. Has safe defaults so a control can render alone.\n * - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.\n */\nimport * as React from \"react\";\nimport type { Cap } from \"./schema/sources\";\nimport type { FieldAccess, FieldPath, FieldSchema, Fieldset, TypeSchema } from \"./schema/types\";\nimport type { KitIssue } from \"./lib/validate\";\nimport type { ControlProps } from \"./types\";\nimport type { LinkTarget } from \"./controls/link\";\n\n/* ── Services ─────────────────────────────────────────────────────────── */\n/** The media asset a picker hands back (the host's media library row, narrowed to what the kit reads). */\nexport interface KitMediaAsset {\n id: string;\n url: string;\n name?: string;\n alt?: string;\n kind?: \"image\" | \"video\" | \"file\" | \"svg\";\n width?: number;\n height?: number;\n size?: number;\n}\nexport interface KitMediaPickerProps {\n open: boolean;\n onOpenChange: (v: boolean) => void;\n onPick: (assets: KitMediaAsset[]) => void;\n multiple?: boolean;\n accept?: (\"image\" | \"video\" | \"file\" | \"svg\")[];\n /** What the dialog is for, in the author's words (\"Replace icon\"). Absent: the host's own title. */\n title?: string;\n /** An icon's Remove, in the dialog's footer (its row has no room for one). Absent: no Remove. */\n onRemove?: () => void;\n /**\n * An icon's first tab: the icons already on this site, each with the value it is stored as. The field's own icon\n * leads, marked `current`: picking it closes the dialog with no write. Absent: no such tab.\n */\n icons?: KitSiteIcon[];\n onPickIcon?: (value: unknown) => void;\n}\n/** One icon already on the site (KitServices.useSiteIcons), as the picker's first tab draws it. */\nexport interface KitSiteIcon {\n url: string;\n value: unknown;\n assetId?: string;\n current?: boolean;\n}\nexport interface KitToastOptions {\n /** the second line under the message (V2 sonner `description`) */\n description?: string;\n action?: { label: string; onClick: () => void };\n duration?: number;\n icon?: React.ReactNode;\n}\n/** The host's toaster. The kit has no toast dependency (V2 re-exported sonner's). */\nexport interface KitToast {\n (message: string, opts?: KitToastOptions): void;\n success: (message: string, opts?: KitToastOptions) => void;\n}\n/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */\nexport type AiPreset = \"improve\" | \"shorter\" | \"longer\" | \"simplify\" | \"grammar\" | \"translate\";\nexport const AI_PRESETS: { id: AiPreset; label: string }[] = [\n { id: \"improve\", label: \"Improve\" },\n { id: \"shorter\", label: \"Shorter\" },\n { id: \"longer\", label: \"Longer\" },\n { id: \"simplify\", label: \"Simplify\" },\n { id: \"grammar\", label: \"Fix spelling & grammar\" },\n { id: \"translate\", label: \"Translate to Spanish\" },\n];\n/**\n * GAP-004: words selected in a rich-text field, to comment on (W3C TextQuoteSelector). `prefix` / `suffix` are up to 32\n * characters of the field's text right before and after them, so the host can find the right occurrence again.\n */\nexport interface KitCommentSelection {\n quote: string;\n prefix?: string;\n suffix?: string;\n}\n/** The in-place field comments popover (V2 FieldThreads over the comments store), drawn by the host. */\nexport interface KitFieldCommentsProps {\n docId: string;\n /** pathKey of the field (\"items.1.answer\") */\n fieldKey: string;\n label: string;\n /** the field's text, first 80 characters */\n quote?: string;\n /** GAP-004: set when the popover opened from a rich-text selection's Comment: the new thread is about these words */\n selection?: KitCommentSelection;\n onClose: () => void;\n /** \"Open in panel\": set when the host has a comments panel (`env.onComment`) */\n onOpenPanel?: () => void;\n}\n/** One field's ⋯ menu, as the host's extra items see it (KitServices.FieldMenuExtras). */\nexport interface KitFieldMenuExtrasProps {\n field: FieldSchema;\n path: FieldPath;\n /** the field is read-only for the lens: a host offers nothing that edits */\n readOnly: boolean;\n}\n/* The popover around FieldComments keeps itself open on Escape while focus is on an element marked `data-esc-owner`\n (V2 guardEscape): the composer marks its input so Escape clears or blurs the draft instead of losing it. */\nexport interface KitServices {\n /** The media library picker. */\n MediaPicker?: React.ComponentType<KitMediaPickerProps>;\n /** Called after an upload so the host can file the assets into its media library. */\n onUploaded?: (assets: KitMediaAsset[]) => void;\n /**\n * Image placements keep their edits BESIDE the url (`${name}Alt` · `${name}Focal` · `${name}Crop` ·\n * `${name}Decorative`) instead of turning the value into an object — the Visuals block model.\n */\n imageSiblings?: boolean;\n /** Real metadata for an image url (the host's media library), so captions never show placeholders. */\n resolveImage?: (url: string) => { name?: string; width?: number; height?: number; size?: number } | undefined;\n /** The host's full image editor (crop, rotate, focal, alt…), opened in place. */\n editImage?: (req: { docId: string; path: FieldPath; title: string }) => void;\n /**\n * RP-047: whether a rich-text body image at this address can be cropped (the crop is drawn by the media library's\n * image URL, so a picture from elsewhere keeps its whole frame). False → the crop is disabled and says why; the focal\n * point still applies. Absent → the crop is offered.\n */\n canCrop?: (url: string) => boolean;\n /** The project's forms for `reference: { to: [\"form\"] }` (the host's Forms store). */\n forms?: () => { id: string; title: string; subtitle: string }[];\n /** Toasts for Copy / Paste / Reset / AI (each with Undo). Absent → the action still runs, silently. */\n toast?: KitToast;\n /**\n * A slug's \"Save new address\" with \"Redirect it to the new address\" ticked (V2 SlugControl): the host files the\n * redirect from the old slug to the new one. Absent → no checkbox is offered, and the toast says the old address\n * will return \"Not found\", which is what happens. A rejection is named in a toast (the new slug is already saved).\n */\n redirectSlug?: (from: string, to: string) => void | Promise<void>;\n /**\n * A slug's \"Save new address\": the host writes the new address before any redirect is filed. Absent → the form's\n * value is the save (V2). A rejection is named in a toast and the old-address box stays for another try.\n */\n saveSlug?: (to: string) => Promise<void>;\n /** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts \"Try again\" presses. */\n aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;\n /** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */\n FieldComments?: React.ComponentType<KitFieldCommentsProps>;\n /**\n * A React hook: open (unresolved) threads on one field, read from the same store FieldComments draws (V2 counted\n * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.\n */\n useFieldCommentCount?: (docId: string, fieldKey: string) => number;\n /**\n * The host's own control for a type (a FieldRenderer arm in the dashboard), drawn for a stored value a kit control\n * hands off because it cannot carry it unchanged (rich text, LegacyFallback). Bare inside the kit FieldShell, which\n * owns the label row and the help; the box is tagged `data-kit-legacy`. Absent → the field says why in words.\n */\n LegacyControl?: React.ComponentType<ControlProps>;\n /**\n * HELD fields (kit 3.2.0), for a hold that depends on the stored value (a value an adapter cannot map back unchanged):\n * a reason → the field at `path` renders read-only in its shell with that reason (`data-kit-held`) and is never\n * written; null/undefined → the field edits as usual. A schema-level hold is `FieldSchema.held`. Called on render, so\n * keep it cheap and pure.\n */\n heldReason?: (at: { field: FieldSchema; path: FieldPath; value: unknown }) => string | null | undefined;\n /**\n * The host's own items for a field's ⋯ menu (the entry editor's Move up · Move down · Move to panel), drawn after\n * History and before Rewrite with AI. It renders kit `MenuItem`s, with its own leading `MenuSeparator`, or null.\n * Absent → the menu is exactly V2's.\n */\n FieldMenuExtras?: React.ComponentType<KitFieldMenuExtrasProps>;\n /**\n * A React HOOK: the project's pages and CMS items a link can point at (controls/link.tsx). The host passes the same\n * function for the life of the form (it is called on every render of a link control). Absent → the link picker says\n * page search isn't available and takes a typed path. `error` is a whole sentence naming what failed (\"Pages couldn't\n * be loaded: …\", \"Items from Blog couldn't be loaded: …\"); the picker shows it under whatever did load.\n */\n useLinkTargets?: () => { targets: LinkTarget[]; loading?: boolean; error?: string };\n /**\n * A React HOOK: every SVG the site already uses (its pages, header and footer, the library's SVGs), for an icon's\n * picker. The host passes the same function for the life of the form. Absent → the picker has no site tab.\n */\n useSiteIcons?: () => KitSiteIcon[];\n /**\n * The entries a rich text's related posts or author bio block shows (kit-richtext-blocks-plan.md RT8). `ids`: the\n * hand-picked entries (an author bio's one author, related posts in hand-picked mode), answered in that order with\n * any the host cannot find left out. `query`: related posts chosen for the reader (owner 2026-10-24: `topic` = same\n * tags or category, `newest` = the collection newest first; `count` of them, `excludeId` the entry being edited).\n * Absent → the blocks show their empty state; a rejection's message is shown as said.\n */\n resolveRichTextRefs?: (req: KitRichTextRefRequest) => Promise<KitRichTextRef[]>;\n}\n\n/** What a related posts or author bio block asks the host for (KitServices.resolveRichTextRefs). */\nexport interface KitRichTextRefRequest {\n kind: \"relatedPosts\" | \"authorBio\";\n ids?: string[];\n query?: { collection?: string; mode: \"topic\" | \"newest\"; count: number; excludeId?: string };\n}\n/**\n * One resolved entry, as the block draws it: a post card (title, cover, category) or an author (avatar, title as name, bio).\n * A post with no `href` has no public page (its collection has no detail route); Related posts names that under its cards.\n */\nexport interface KitRichTextRef {\n id: string;\n title: string;\n href?: string;\n cover?: string;\n category?: string;\n avatar?: string;\n bio?: string;\n}\n\n/**\n * A React HOOK over KitServices.resolveRichTextRefs: `unavailable` when the host offers no resolver (draw the empty\n * state), else `loading`, then `items` or `error` (a sentence). `req` null asks nothing (a block with nothing picked).\n */\nexport function useRichTextRefs(req: KitRichTextRefRequest | null): { items: KitRichTextRef[]; loading: boolean; error?: string; unavailable: boolean } {\n const { resolveRichTextRefs } = useKitServices();\n const key = req ? JSON.stringify(req) : \"\";\n const [state, setState] = React.useState<{ key: string; items: KitRichTextRef[]; error?: string } | null>(null);\n React.useEffect(() => {\n if (!resolveRichTextRefs || !key) return;\n let live = true;\n resolveRichTextRefs(JSON.parse(key) as KitRichTextRefRequest).then(\n (items) => live && setState({ key, items }),\n (e: unknown) => live && setState({ key, items: [], error: e instanceof Error ? e.message : String(e) }),\n );\n return () => void (live = false);\n }, [resolveRichTextRefs, key]);\n if (!resolveRichTextRefs) return { items: [], loading: false, unavailable: true };\n if (!key) return { items: [], loading: false, unavailable: false };\n const done = state?.key === key ? state : null;\n return { items: done?.items ?? [], loading: !done, error: done?.error, unavailable: false };\n}\nlet registry: KitServices = {};\nconst listeners = new Set<() => void>();\n/** Register app services once at module load (e.g. the Content feature registers its media library). */\nexport function registerKitServices(s: KitServices) {\n registry = { ...registry, ...s };\n listeners.forEach((l) => l());\n}\nconst ServicesCtx = React.createContext<KitServices | null>(null);\nexport function KitServicesProvider({ value, children }: { value: KitServices; children: React.ReactNode }) {\n return <ServicesCtx.Provider value={value}>{children}</ServicesCtx.Provider>;\n}\nexport function useKitServices(): KitServices {\n const local = React.useContext(ServicesCtx);\n const global = React.useSyncExternalStore(\n (cb) => {\n listeners.add(cb);\n return () => listeners.delete(cb);\n },\n () => registry,\n () => registry,\n );\n return local ? { ...global, ...local } : global;\n}\n\n/** A host header element a top-level field (by path key) renders its actions into, instead of a label row. */\nexport const FieldHeaderSlot = React.createContext<{ key: string; el: HTMLElement } | null>(null);\n\n/* ── Environment ──────────────────────────────────────────────────────── */\nexport type KitVariant = \"panel\" | \"document\";\nexport interface KitPeer {\n id?: string;\n name: string;\n avatar?: string;\n /** presence colour (avatar ring, field border, caret flag) */\n color?: string;\n /** \"editing\" (soft lock + border) or \"viewing\" */\n status?: \"editing\" | \"viewing\";\n}\nexport interface Swatch {\n name: string;\n value: string;\n token?: string;\n}\n\n/** V2's demo site palette (Caldera). Hosts pass the project's brand palette through `env.palette`. */\nexport const SITE_PALETTE: Swatch[] = [\n { name: \"Ember\", value: \"#E0663B\", token: \"brand.ember\" },\n { name: \"Ochre\", value: \"#D97706\", token: \"brand.ochre\" },\n { name: \"Moss\", value: \"#4F6B4A\", token: \"brand.moss\" },\n { name: \"Lake\", value: \"#2563EB\", token: \"accent.lake\" },\n { name: \"Dusk\", value: \"#7C3AED\", token: \"accent.dusk\" },\n { name: \"Berry\", value: \"#DB2777\", token: \"accent.berry\" },\n { name: \"Char\", value: \"#1E1B18\", token: \"neutral.900\" },\n { name: \"Slate\", value: \"#4B5563\", token: \"neutral.600\" },\n { name: \"Bone\", value: \"#E7E0D6\", token: \"neutral.200\" },\n { name: \"Paper\", value: \"#F6F1EA\", token: \"neutral.50\" },\n];\n\nexport interface KitEnv {\n variant: KitVariant;\n /** Identity of the document/block being edited (rich-text sync, comments, history). */\n docId: string;\n /** The document's title — slug generation. */\n docTitle?: string;\n /** Public URL prefix for slug previews, e.g. \"caldera.bettercms.site/journal/\". */\n urlPrefix?: string;\n /** The document has been published (slug changes warn about the old address). */\n isPublished?: boolean;\n /**\n * The form's slug is the document's ADDRESS (a page's or an entry's URL). Only then does a changed slug on a published\n * document say the old address will stop working and offer the redirect. A slug prop or a key is not an address, so\n * it gets no such box (V2 draws it on document hosts only: its component-prop forms pass no published state).\n */\n slugIsAddress?: boolean;\n palette: Swatch[];\n /** The whole form is read-only for the lens (the host's content.edit rule, a generated twin…). */\n readOnly: boolean;\n /**\n * D58: the host's access check for the lens (`useCan` at the host). The kit never imports the store; it asks this for\n * field-level `access` and for developer surfaces (field keys, IDs, API names: `schema.view` or `api.view`).\n * Hosts that omit it (staff tools, demos) get allow-all.\n */\n can: (cap: Cap) => boolean;\n /** pathKey → teammates in that field */\n presence: Record<string, KitPeer[]>;\n /** pathKey → open comment threads */\n comments: Record<string, number>;\n /** Host comment panel. When absent, field comments live in the in-place popover only. */\n /** `quote`: the words selected in a rich text field when the comment came from its toolbar */\n onComment?: (path: FieldPath, field: FieldSchema, quote?: string) => void;\n /** The whole form is a global block (\"Navigation\") — every field is synced. */\n syncedFrom?: string;\n /** \"Open {title}\" on a reference card: the host edits the referenced entry in place (stacked panel). */\n onOpenReference?: (ref: { collectionId: string; entryId: string; title: string }) => void;\n /** CPO D39: \"inline\" (default) shows help under the label; \"tooltip\" moves it behind the ⓘ — for dense hosts (grid cells, popovers). */\n helpDisplay?: \"inline\" | \"tooltip\";\n /** D61 Review changes: the host's change markers, present only while its History panel is open. */\n review?: KitReview;\n /** D61 field ⋯ › History: the host opens its one History panel on this field. Absent = no History item. */\n onFieldHistory?: (path: FieldPath, field: FieldSchema) => void;\n /**\n * \"quiet\": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field\n * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a\n * switch card. \"preview\": the same chrome-free fields, controls exactly as editors see them (a schema preview, where a\n * comment would land on a sample, never a real document). Default \"full\".\n */\n fieldChrome?: \"full\" | \"preview\" | \"quiet\";\n /**\n * A host's own control for one field, by its path key (\"type\", \"options\"), drawn inside the usual shell. The schema\n * editor's field settings plug their Type, Options, Key and Show this field controls in here. Absent = kit controls only.\n */\n controls?: Record<string, React.ComponentType<ControlProps>>;\n /**\n * A collapsed fieldset's summary as chips, from the host (the schema editor's field settings: \"Required\", \"3 options\").\n * `undefined` falls back to the kit's own one-line summary. Keep it stable (a new function re-renders the form).\n */\n sectionSummary?: (set: Fieldset, value: Record<string, unknown>) => string[] | undefined;\n}\n\n/**\n * D61 Review changes, as the kit sees it. The host owns the history model; the kit only asks, per field path, whether\n * it changed in the range, and renders the host's marker (a 2px bar in the author's colour at the field's left edge,\n * with its hover card) where the at-rest \"changed\" dot would be.\n */\nexport interface KitReview {\n /** changes at or inside this field in the range (0 = unchanged) */\n count: (path: FieldPath) => number;\n /** the presence colour of whoever changed it last (list rows draw their own bar) */\n color: (path: FieldPath) => string | undefined;\n /** the host's change bar and hover card for a changed field (null when unchanged) */\n bar: (path: FieldPath, field: FieldSchema) => React.ReactNode;\n /** Show only changes: unchanged fields fold into one quiet line each run */\n onlyChanges: boolean;\n}\n\n/** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats\n * its section's title (\"Options\" › \"Options\"): the section heading names it. */\nexport const KitSectionTitle = React.createContext<string | null>(null);\n/**\n * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host\n * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.\n */\nexport const KitAddressContext = React.createContext<((slug: string) => React.ReactNode) | null>(null);\nexport const DEFAULT_ENV: KitEnv = {\n variant: \"panel\",\n docId: \"kit\",\n palette: [],\n readOnly: false,\n can: () => true,\n presence: {},\n comments: {},\n};\nconst EnvCtx = React.createContext<KitEnv>(DEFAULT_ENV);\n\n/** D58 field access: fields in the `seo` group default to `{ edit: \"seo.edit\" }`. */\nexport const fieldAccessOf = (field: FieldSchema): FieldAccess | undefined => field.access ?? (field.group === \"seo\" ? { edit: \"seo.edit\" } : undefined);\n\n/**\n * One field for the lens: hidden (no `view`), read-only (plain text: no `edit`, the field is `readOnly`, or the whole form\n * is read-only and the field has no edit cap of its own), or editable. An explicit `edit` cap wins over the form's\n * read-only rule, so an SEO specialist edits SEO fields inside a form they can't otherwise change.\n */\nexport function resolveFieldAccess(field: FieldSchema, env: Pick<KitEnv, \"can\" | \"readOnly\">): { hidden: boolean; readOnly: boolean } {\n const a = fieldAccessOf(field);\n if (a?.view && !env.can(a.view)) return { hidden: true, readOnly: true };\n if (field.readOnly === true) return { hidden: false, readOnly: true };\n if (a?.edit) return { hidden: false, readOnly: !env.can(a.edit) };\n return { hidden: false, readOnly: env.readOnly };\n}\n/** Drop the fields the lens can't `view` (recursively), so they are neither rendered nor validated. Same object back when\n * nothing is hidden. Values of dropped fields stay in the document untouched. */\nexport function visibleFields(fields: FieldSchema[], can: KitEnv[\"can\"]): FieldSchema[] {\n let changed = false;\n const out: FieldSchema[] = [];\n for (const f of fields) {\n const a = fieldAccessOf(f);\n if (a?.view && !can(a.view)) {\n changed = true;\n continue;\n }\n let g = f;\n if (f.fields) {\n const n = visibleFields(f.fields, can);\n if (n !== f.fields) g = { ...g, fields: n };\n }\n if (Array.isArray(f.of)) {\n const n = visibleFields(f.of, can);\n if (n !== f.of) g = { ...g, of: n };\n }\n if (f.slotSettings) {\n const n = visibleFields(f.slotSettings, can);\n if (n !== f.slotSettings) g = { ...g, slotSettings: n };\n }\n if (g !== f) changed = true;\n out.push(g);\n }\n return changed ? out : fields;\n}\nexport function visibleSchema(schema: TypeSchema, can: KitEnv[\"can\"]): TypeSchema {\n const fields = visibleFields(schema.fields, can);\n return fields === schema.fields ? schema : { ...schema, fields };\n}\n\n/** Developer surfaces (field keys, API names, IDs): `schema.view` or `api.view`. */\nexport const seesDevSurfaces = (env: Pick<KitEnv, \"can\">) => env.can(\"schema.view\") || env.can(\"api.view\");\nexport const KitEnvProvider = EnvCtx.Provider;\nexport const useKitEnv = () => React.useContext(EnvCtx);\n\n/* ── Form runtime (inside <SchemaForm>) ──────────────────────────────── */\nexport interface HistoryEntry {\n value: unknown;\n at: number;\n by: string;\n label?: string;\n}\nexport interface FormApi {\n schema: TypeSchema;\n value: Record<string, unknown>;\n /** write a value; `record: false` skips the field undo/history stack (e.g. programmatic sync) */\n setAt: (path: FieldPath, v: unknown, opts?: { record?: boolean; label?: string }) => void;\n getAt: (path: FieldPath) => unknown;\n /** value when the form mounted (field undo baseline) */\n baselineAt: (path: FieldPath) => unknown;\n /** published value (changed dot, Reset to published); undefined when never published */\n publishedAt: (path: FieldPath) => unknown;\n hasPublished: boolean;\n /** component instances (CPO D28): top-level fields inherit from a component unless overridden */\n inherited?: { from: string; isOverridden: (key: string) => boolean; reset: (key: string) => void };\n /** the current navigation path (drill-in stack) */\n path: FieldPath;\n navigate: (path: FieldPath) => void;\n /** the form draws frames for a non-root path. False while SchemaForm renders only the root frame: History and\n * drill-in rows hide or go inert instead of navigating to a path nothing shows (no silent no-op). */\n canNavigate: boolean;\n resolveSchema?: (blockType: string) => TypeSchema | undefined;\n /** blocks offered by \"+ Add block\" in slots (filtered by each slot's allow list) */\n blockLibrary?: TypeSchema[];\n /** all issues by pathKey */\n issues: Map<string, KitIssue>;\n /** the issue shown for a key (rules on blur, required after blur or a publish attempt) */\n visibleIssue: (key: string) => KitIssue | undefined;\n /** visible issues under a path prefix (rollup dots on rows, crumbs and tabs) */\n rollup: (prefix: FieldPath) => { errors: number; warnings: number };\n touch: (key: string) => void;\n showAllErrors: boolean;\n /** per-field undo (Undo last change to {label}) */\n canUndo: (key: string) => boolean;\n undo: (key: string) => void;\n /** versions of a field this session (newest first) */\n history: (key: string) => HistoryEntry[];\n /** the last change to this field came from AI (⋯ shows \"Undo AI change\") */\n aiKeys: Set<string>;\n markAi: (key: string, on: boolean) => void;\n /** remembered UI state per frame (selected group tab, open fieldsets) */\n memory: Map<string, unknown>;\n}\nconst FormCtx = React.createContext<FormApi | null>(null);\nexport const FormProvider = FormCtx.Provider;\nexport const useForm = () => React.useContext(FormCtx);\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,aAAgD;CAC3D;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAU,OAAO;CAAS;CAChC;EAAE,IAAI;EAAY,OAAO;CAAW;CACpC;EAAE,IAAI;EAAW,OAAO;CAAyB;CACjD;EAAE,IAAI;EAAa,OAAO;CAAuB;AACnD;;;;;AA8IA,SAAgB,gBAAgB,KAAwH;CACtJ,MAAM,EAAE,wBAAwB,eAAe;CAC/C,MAAM,MAAM,MAAM,KAAK,UAAU,GAAG,IAAI;CACxC,MAAM,CAAC,OAAO,YAAY,MAAM,SAA0E,IAAI;CAC9G,MAAM,gBAAgB;EACpB,IAAI,CAAC,uBAAuB,CAAC,KAAK;EAClC,IAAI,OAAO;EACX,oBAAo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AU;CACd,MAAM,MAAqB,CAAC;CAC5B,KAAK,MAAM,KAAK,QAAQ;EACtB,MAAM,IAAI,cAAc,CAAC;EACzB,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG;GAC3B,UAAU;GACV;EACF;EACA,IAAI,IAAI;EACR,IAAI,EAAE,QAAQ;GACZ,MAAM,IAAI,cAAc,EAAE,QAAQ,GAAG;GACrC,IAAI,MAAM,EAAE,QAAQ,IAAI;IAAE,GAAG;IAAG,QAAQ;GAAE;EAC5C;EACA,IAAI,MAAM,QAAQ,EAAE,EAAE,GAAG;GACvB,MAAM,IAAI,cAAc,EAAE,IAAI,GAAG;GACjC,IAAI,MAAM,EAAE,IAAI,IAAI;IAAE,GAAG;IAAG,IAAI;GAAE;EACpC;EACA,IAAI,EAAE,cAAc;GAClB,MAAM,IAAI,cAAc,EAAE,cAAc,GAAG;GAC3C,IAAI,MAAM,EAAE,cAAc,IAAI;IAAE,GAAG;IAAG,cAAc;GAAE;EACxD;EACA,IAAI,MAAM,GAAG,UAAU;EACvB,IAAI,KAAK,CAAC;CACZ;CACA,OAAO,UAAU,MAAM;AACzB;AACA,SAAgB,cAAc,QAAoB,KAAgC;CAChF,MAAM,SAAS,cAAc,OAAO,QAAQ,GAAG;CAC/C,OAAO,WAAW,OAAO,SAAS,SAAS;EAAE,GAAG;EAAQ;CAAO;AACjE;;AAGA,IAAa,mBAAmB,QAA6B,IAAI,IAAI,aAAa,KAAK,IAAI,IAAI,UAAU;AACzG,IAAa,iBAAiB,OAAO;AACrC,IAAa,kBAAkB,MAAM,WAAW,MAAM;AAkDtD,IAAM,UAAU,MAAM,cAA8B,IAAI;AACxD,IAAa,eAAe,QAAQ;AACpC,IAAa,gBAAgB,MAAM,WAAW,OAAO"}
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../src/context.tsx"],"sourcesContent":["/**\n * Kit runtime contexts (V2 HEAD 9829bf1 kit/context.tsx).\n *\n * - KitServices — pluggable app services (media library picker, upload sink, toast, AI rewrite, comment threads).\n * Hosts register theirs once (`registerKitServices`) or provide them (`KitServicesProvider`); the kit\n * never imports a feature. A service that is absent hides the surface that needs it.\n * - KitEnv — the editing environment a control renders in: variant (panel | document), doc identity, site\n * palette, permissions, presence, comments. Has safe defaults so a control can render alone.\n * - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.\n */\nimport * as React from \"react\";\nimport type { Cap } from \"./schema/sources\";\nimport type { FieldAccess, FieldPath, FieldSchema, Fieldset, TypeSchema } from \"./schema/types\";\nimport type { KitIssue } from \"./lib/validate\";\nimport type { ControlProps } from \"./types\";\nimport type { LinkTarget } from \"./controls/link\";\n\n/* ── Services ─────────────────────────────────────────────────────────── */\n/** The media asset a picker hands back (the host's media library row, narrowed to what the kit reads). */\nexport interface KitMediaAsset {\n id: string;\n url: string;\n name?: string;\n alt?: string;\n kind?: \"image\" | \"video\" | \"file\" | \"svg\";\n width?: number;\n height?: number;\n size?: number;\n}\nexport interface KitMediaPickerProps {\n open: boolean;\n onOpenChange: (v: boolean) => void;\n onPick: (assets: KitMediaAsset[]) => void;\n multiple?: boolean;\n accept?: (\"image\" | \"video\" | \"file\" | \"svg\")[];\n /** What the dialog is for, in the author's words (\"Replace icon\"). Absent: the host's own title. */\n title?: string;\n /** An icon's Remove, in the dialog's footer (its row has no room for one). Absent: no Remove. */\n onRemove?: () => void;\n /**\n * An icon's first tab: the icons already on this site, each with the value it is stored as. The field's own icon\n * leads, marked `current`: picking it closes the dialog with no write. Absent: no such tab.\n */\n icons?: KitSiteIcon[];\n onPickIcon?: (value: unknown) => void;\n}\n/** One icon already on the site (KitServices.useSiteIcons), as the picker's first tab draws it. */\nexport interface KitSiteIcon {\n url: string;\n value: unknown;\n assetId?: string;\n current?: boolean;\n}\nexport interface KitToastOptions {\n /** the second line under the message (V2 sonner `description`) */\n description?: string;\n action?: { label: string; onClick: () => void };\n /** several actions (prototype `notify` takes one or more); the kit toaster draws them all under look \"v16\",\n * the first one otherwise. Wins over `action`. */\n actions?: { label: string; onClick: () => void }[];\n duration?: number;\n icon?: React.ReactNode;\n}\n/** The host's toaster. The kit has no toast dependency (V2 re-exported sonner's). */\nexport interface KitToast {\n (message: string, opts?: KitToastOptions): void;\n success: (message: string, opts?: KitToastOptions) => void;\n}\n/**\n * The slash menu's \"BetterCMS AI\" commands (look \"v16\", prototype content.jsx:1210). The host's `aiCommand` service\n * produces the text; without it the menu offers no AI row.\n */\nexport type AiCommandKind = \"prompt\" | \"continue\" | \"improve\" | \"shorter\" | \"summarize\" | \"translate\" | \"spelling\";\nexport const AI_COMMANDS: { id: AiCommandKind; label: string; description: string }[] = [\n { id: \"prompt\", label: \"Write a prompt\", description: \"Generate text from a prompt\" },\n { id: \"continue\", label: \"Continue writing\", description: \"Pick up where you stopped\" },\n { id: \"improve\", label: \"Improve writing\", description: \"Smooth tone and clarity\" },\n { id: \"shorter\", label: \"Make shorter\", description: \"Same point, fewer words\" },\n { id: \"summarize\", label: \"Summarize\", description: \"Pull out the key points\" },\n { id: \"translate\", label: \"Translate\", description: \"Into another language\" },\n { id: \"spelling\", label: \"Fix spelling\", description: \"Spelling and grammar\" },\n];\n/** The commands that rewrite the block above the caret; the others write new text at the caret. */\nexport const AI_REWRITE_COMMANDS: readonly AiCommandKind[] = [\"improve\", \"shorter\", \"translate\", \"spelling\"];\n/** What the body hands the host with a command. All plain text. */\nexport interface AiCommandContext {\n /** the whole body */\n text: string;\n /** everything above the caret's line (what Continue writing picks up and Summarize reads) */\n before: string;\n /** the block a rewrite command replaces: the text block right above the caret's line (\"\" for the writing commands) */\n target: string;\n /** what stands on the caret's line once \"/…\" is removed (a prompt typed inline) */\n line: string;\n /** a rewrite's target cut at its formatting (bold, italic, links, code…): its text runs in order, which joined\n * give `target`. An answer that keeps these runs (joined by AI_RUN_SEPARATOR, or keeping every formatted run's\n * words unchanged) keeps their formatting; any other answer replaces the target as plain text. [] otherwise. */\n runs: string[];\n}\n/** Join the rewritten `AiCommandContext.runs` with this (U+241E) to keep each run's formatting in a rewrite. */\nexport const AI_RUN_SEPARATOR = \"␞\";\n/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */\nexport type AiPreset = \"improve\" | \"shorter\" | \"longer\" | \"simplify\" | \"grammar\" | \"translate\";\nexport const AI_PRESETS: { id: AiPreset; label: string }[] = [\n { id: \"improve\", label: \"Improve\" },\n { id: \"shorter\", label: \"Shorter\" },\n { id: \"longer\", label: \"Longer\" },\n { id: \"simplify\", label: \"Simplify\" },\n { id: \"grammar\", label: \"Fix spelling & grammar\" },\n { id: \"translate\", label: \"Translate to Spanish\" },\n];\n/**\n * GAP-004: words selected in a rich-text field, to comment on (W3C TextQuoteSelector). `prefix` / `suffix` are up to 32\n * characters of the field's text right before and after them, so the host can find the right occurrence again.\n */\nexport interface KitCommentSelection {\n quote: string;\n prefix?: string;\n suffix?: string;\n}\n/** The in-place field comments popover (V2 FieldThreads over the comments store), drawn by the host. */\nexport interface KitFieldCommentsProps {\n docId: string;\n /** pathKey of the field (\"items.1.answer\") */\n fieldKey: string;\n label: string;\n /** the field's text, first 80 characters */\n quote?: string;\n /** GAP-004: set when the popover opened from a rich-text selection's Comment: the new thread is about these words */\n selection?: KitCommentSelection;\n onClose: () => void;\n /** \"Open in panel\": set when the host has a comments panel (`env.onComment`) */\n onOpenPanel?: () => void;\n}\n/** One field's ⋯ menu, as the host's extra items see it (KitServices.FieldMenuExtras). */\nexport interface KitFieldMenuExtrasProps {\n field: FieldSchema;\n path: FieldPath;\n /** the field is read-only for the lens: a host offers nothing that edits */\n readOnly: boolean;\n}\n/* The popover around FieldComments keeps itself open on Escape while focus is on an element marked `data-esc-owner`\n (V2 guardEscape): the composer marks its input so Escape clears or blurs the draft instead of losing it. */\nexport interface KitServices {\n /** The media library picker. */\n MediaPicker?: React.ComponentType<KitMediaPickerProps>;\n /** Called after an upload so the host can file the assets into its media library. */\n onUploaded?: (assets: KitMediaAsset[]) => void;\n /**\n * Image placements keep their edits BESIDE the url (`${name}Alt` · `${name}Focal` · `${name}Crop` ·\n * `${name}Decorative`) instead of turning the value into an object — the Visuals block model.\n */\n imageSiblings?: boolean;\n /** Real metadata for an image url (the host's media library), so captions never show placeholders. */\n resolveImage?: (url: string) => { name?: string; width?: number; height?: number; size?: number } | undefined;\n /** The host's full image editor (crop, rotate, focal, alt…), opened in place. */\n editImage?: (req: { docId: string; path: FieldPath; title: string }) => void;\n /**\n * RP-047: whether a rich-text body image at this address can be cropped (the crop is drawn by the media library's\n * image URL, so a picture from elsewhere keeps its whole frame). False → the crop is disabled and says why; the focal\n * point still applies. Absent → the crop is offered.\n */\n canCrop?: (url: string) => boolean;\n /** The project's forms for `reference: { to: [\"form\"] }` (the host's Forms store). */\n forms?: () => { id: string; title: string; subtitle: string }[];\n /** Toasts for Copy / Paste / Reset / AI (each with Undo). Absent → the action still runs, silently. */\n toast?: KitToast;\n /**\n * A slug's \"Save new address\" with \"Redirect it to the new address\" ticked (V2 SlugControl): the host files the\n * redirect from the old slug to the new one. Absent → no checkbox is offered, and the toast says the old address\n * will return \"Not found\", which is what happens. A rejection is named in a toast (the new slug is already saved).\n */\n redirectSlug?: (from: string, to: string) => void | Promise<void>;\n /**\n * A slug's \"Save new address\": the host writes the new address before any redirect is filed. Absent → the form's\n * value is the save (V2). A rejection is named in a toast and the old-address box stays for another try.\n */\n saveSlug?: (to: string) => Promise<void>;\n /** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts \"Try again\" presses. */\n aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;\n /**\n * The slash menu's \"BetterCMS AI\" view (look \"v16\"). Absent → the slash menu has no AI row. The answer is plain text\n * (paragraphs split by a blank line): a rewrite command (AI_REWRITE_COMMANDS) replaces `context.target` with it, any\n * other command writes it at the caret's line. No answer (void) means the host showed its own UI and nothing is\n * written. A rejection is named in a toast.\n */\n aiCommand?: (kind: AiCommandKind, context: AiCommandContext) => string | void | Promise<string | void>;\n /** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */\n FieldComments?: React.ComponentType<KitFieldCommentsProps>;\n /**\n * A React hook: open (unresolved) threads on one field, read from the same store FieldComments draws (V2 counted\n * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.\n */\n useFieldCommentCount?: (docId: string, fieldKey: string) => number;\n /**\n * How the popover around `FieldComments` is drawn (REQ-3-7): its distance from the field, its side shift and its\n * class (width, and `!border-0 !bg-transparent !shadow-none` when the host's composer is the surface). `selection` is\n * true when it opens on selected words (the quote popover). Absent → 8 under the field, 280 to 420 wide.\n */\n fieldCommentsPopover?: (p: { selection: boolean }) => { sideOffset?: number; alignOffset?: number; className?: string };\n /**\n * A field WITH open threads: its count button opens the host's Comments panel on that field instead of the in-place\n * popover (REQ-3-7). Absent → the popover opens with the threads.\n */\n onOpenFieldThreads?: (docId: string, fieldKey: string) => void;\n /**\n * HELD fields (kit 3.2.0), for a hold that depends on the stored value (a value an adapter cannot map back unchanged):\n * a reason → the field at `path` renders read-only in its shell with that reason (`data-kit-held`) and is never\n * written; null/undefined → the field edits as usual. A schema-level hold is `FieldSchema.held`. Called on render, so\n * keep it cheap and pure.\n */\n heldReason?: (at: { field: FieldSchema; path: FieldPath; value: unknown }) => string | null | undefined;\n /**\n * The host's own items for a field's ⋯ menu (the entry editor's Move up · Move down · Move to panel), drawn after\n * History and before Rewrite with AI. It renders kit `MenuItem`s, with its own leading `MenuSeparator`, or null.\n * Absent → the menu is exactly V2's.\n */\n FieldMenuExtras?: React.ComponentType<KitFieldMenuExtrasProps>;\n /**\n * A React HOOK: the project's pages and CMS items a link can point at (controls/link.tsx). The host passes the same\n * function for the life of the form (it is called on every render of a link control). Absent → the link picker says\n * page search isn't available and takes a typed path. `error` is a whole sentence naming what failed (\"Pages couldn't\n * be loaded: …\", \"Items from Blog couldn't be loaded: …\"); the picker shows it under whatever did load.\n */\n useLinkTargets?: () => { targets: LinkTarget[]; loading?: boolean; error?: string };\n /**\n * A React HOOK: every SVG the site already uses (its pages, header and footer, the library's SVGs), for an icon's\n * picker. The host passes the same function for the life of the form. Absent → the picker has no site tab.\n */\n useSiteIcons?: () => KitSiteIcon[];\n /**\n * The entries a rich text's related posts or author bio block shows (kit-richtext-blocks-plan.md RT8). `ids`: the\n * hand-picked entries (an author bio's one author, related posts in hand-picked mode), answered in that order with\n * any the host cannot find left out. `query`: related posts chosen for the reader (owner 2026-10-24: `topic` = same\n * tags or category, `newest` = the collection newest first; `count` of them, `excludeId` the entry being edited).\n * Absent → the blocks show their empty state; a rejection's message is shown as said.\n */\n resolveRichTextRefs?: (req: KitRichTextRefRequest) => Promise<KitRichTextRef[]>;\n}\n\n/** What a related posts or author bio block asks the host for (KitServices.resolveRichTextRefs). */\nexport interface KitRichTextRefRequest {\n kind: \"relatedPosts\" | \"authorBio\";\n ids?: string[];\n query?: { collection?: string; mode: \"topic\" | \"newest\"; count: number; excludeId?: string };\n}\n/**\n * One resolved entry, as the block draws it: a post card (title, cover, category) or an author (avatar, title as name, bio).\n * A post with no `href` has no public page (its collection has no detail route); Related posts names that under its cards.\n */\nexport interface KitRichTextRef {\n id: string;\n title: string;\n href?: string;\n cover?: string;\n category?: string;\n avatar?: string;\n bio?: string;\n}\n\n/**\n * A React HOOK over KitServices.resolveRichTextRefs: `unavailable` when the host offers no resolver (draw the empty\n * state), else `loading`, then `items` or `error` (a sentence). `req` null asks nothing (a block with nothing picked).\n */\nexport function useRichTextRefs(req: KitRichTextRefRequest | null): { items: KitRichTextRef[]; loading: boolean; error?: string; unavailable: boolean } {\n const { resolveRichTextRefs } = useKitServices();\n const key = req ? JSON.stringify(req) : \"\";\n const [state, setState] = React.useState<{ key: string; items: KitRichTextRef[]; error?: string } | null>(null);\n React.useEffect(() => {\n if (!resolveRichTextRefs || !key) return;\n let live = true;\n resolveRichTextRefs(JSON.parse(key) as KitRichTextRefRequest).then(\n (items) => live && setState({ key, items }),\n (e: unknown) => live && setState({ key, items: [], error: e instanceof Error ? e.message : String(e) }),\n );\n return () => void (live = false);\n }, [resolveRichTextRefs, key]);\n if (!resolveRichTextRefs) return { items: [], loading: false, unavailable: true };\n if (!key) return { items: [], loading: false, unavailable: false };\n const done = state?.key === key ? state : null;\n return { items: done?.items ?? [], loading: !done, error: done?.error, unavailable: false };\n}\nlet registry: KitServices = {};\nconst listeners = new Set<() => void>();\n/** Register app services once at module load (e.g. the Content feature registers its media library). */\nexport function registerKitServices(s: KitServices) {\n registry = { ...registry, ...s };\n listeners.forEach((l) => l());\n}\nconst ServicesCtx = React.createContext<KitServices | null>(null);\nexport function KitServicesProvider({ value, children }: { value: KitServices; children: React.ReactNode }) {\n return <ServicesCtx.Provider value={value}>{children}</ServicesCtx.Provider>;\n}\nexport function useKitServices(): KitServices {\n const local = React.useContext(ServicesCtx);\n const global = React.useSyncExternalStore(\n (cb) => {\n listeners.add(cb);\n return () => listeners.delete(cb);\n },\n () => registry,\n () => registry,\n );\n return local ? { ...global, ...local } : global;\n}\n\n/** A host header element a top-level field (by path key) renders its actions into, instead of a label row. */\nexport const FieldHeaderSlot = React.createContext<{ key: string; el: HTMLElement } | null>(null);\n\n/* ── Environment ──────────────────────────────────────────────────────── */\nexport type KitVariant = \"panel\" | \"document\";\nexport interface KitPeer {\n id?: string;\n name: string;\n avatar?: string;\n /** presence colour (avatar ring, field border, caret flag) */\n color?: string;\n /** \"editing\" (soft lock + border) or \"viewing\" */\n status?: \"editing\" | \"viewing\";\n}\nexport interface Swatch {\n name: string;\n value: string;\n token?: string;\n}\n\n/** V2's demo site palette (Caldera). Hosts pass the project's brand palette through `env.palette`. */\nexport const SITE_PALETTE: Swatch[] = [\n { name: \"Ember\", value: \"#E0663B\", token: \"brand.ember\" },\n { name: \"Ochre\", value: \"#D97706\", token: \"brand.ochre\" },\n { name: \"Moss\", value: \"#4F6B4A\", token: \"brand.moss\" },\n { name: \"Lake\", value: \"#2563EB\", token: \"accent.lake\" },\n { name: \"Dusk\", value: \"#7C3AED\", token: \"accent.dusk\" },\n { name: \"Berry\", value: \"#DB2777\", token: \"accent.berry\" },\n { name: \"Char\", value: \"#1E1B18\", token: \"neutral.900\" },\n { name: \"Slate\", value: \"#4B5563\", token: \"neutral.600\" },\n { name: \"Bone\", value: \"#E7E0D6\", token: \"neutral.200\" },\n { name: \"Paper\", value: \"#F6F1EA\", token: \"neutral.50\" },\n];\n\nexport interface KitEnv {\n variant: KitVariant;\n /** Identity of the document/block being edited (rich-text sync, comments, history). */\n docId: string;\n /** The document's title — slug generation. */\n docTitle?: string;\n /** Public URL prefix for slug previews, e.g. \"caldera.bettercms.site/journal/\". */\n urlPrefix?: string;\n /** The document has been published (slug changes warn about the old address). */\n isPublished?: boolean;\n /**\n * The form's slug is the document's ADDRESS (a page's or an entry's URL). Only then does a changed slug on a published\n * document say the old address will stop working and offer the redirect. A slug prop or a key is not an address, so\n * it gets no such box (V2 draws it on document hosts only: its component-prop forms pass no published state).\n */\n slugIsAddress?: boolean;\n palette: Swatch[];\n /** The whole form is read-only for the lens (the host's content.edit rule, a generated twin…). */\n readOnly: boolean;\n /**\n * D58: the host's access check for the lens (`useCan` at the host). The kit never imports the store; it asks this for\n * field-level `access` and for developer surfaces (field keys, IDs, API names: `schema.view` or `api.view`).\n * Hosts that omit it (staff tools, demos) get allow-all.\n */\n can: (cap: Cap) => boolean;\n /** pathKey → teammates in that field */\n presence: Record<string, KitPeer[]>;\n /** pathKey → open comment threads */\n comments: Record<string, number>;\n /** Host comment panel. When absent, field comments live in the in-place popover only. */\n /** `quote`: the words selected in a rich text field when the comment came from its toolbar */\n onComment?: (path: FieldPath, field: FieldSchema, quote?: string) => void;\n /** The whole form is a global block (\"Navigation\") — every field is synced. */\n syncedFrom?: string;\n /** \"Open {title}\" on a reference card: the host edits the referenced entry in place (stacked panel). */\n onOpenReference?: (ref: { collectionId: string; entryId: string; title: string }) => void;\n /** CPO D39: \"inline\" (default) shows help under the label; \"tooltip\" moves it behind the ⓘ — for dense hosts (grid cells, popovers). */\n helpDisplay?: \"inline\" | \"tooltip\";\n /** D61 Review changes: the host's change markers, present only while its History panel is open. */\n review?: KitReview;\n /** D61 field ⋯ › History: the host opens its one History panel on this field. Absent = no History item. */\n onFieldHistory?: (path: FieldPath, field: FieldSchema) => void;\n /**\n * \"quiet\": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field\n * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a\n * switch card. \"preview\": the same chrome-free fields, controls exactly as editors see them (a schema preview, where a\n * comment would land on a sample, never a real document). Default \"full\".\n */\n fieldChrome?: \"full\" | \"preview\" | \"quiet\";\n /**\n * A host's own control for one field, by its path key (\"type\", \"options\"), drawn inside the usual shell. The schema\n * editor's field settings plug their Type, Options, Key and Show this field controls in here. Absent = kit controls only.\n */\n controls?: Record<string, React.ComponentType<ControlProps>>;\n /**\n * A collapsed fieldset's summary as chips, from the host (the schema editor's field settings: \"Required\", \"3 options\").\n * `undefined` falls back to the kit's own one-line summary. Keep it stable (a new function re-renders the form).\n */\n sectionSummary?: (set: Fieldset, value: Record<string, unknown>) => string[] | undefined;\n}\n\n/**\n * D61 Review changes, as the kit sees it. The host owns the history model; the kit only asks, per field path, whether\n * it changed in the range, and renders the host's marker (a 2px bar in the author's colour at the field's left edge,\n * with its hover card) where the at-rest \"changed\" dot would be.\n */\nexport interface KitReview {\n /** changes at or inside this field in the range (0 = unchanged) */\n count: (path: FieldPath) => number;\n /** the presence colour of whoever changed it last (list rows draw their own bar) */\n color: (path: FieldPath) => string | undefined;\n /** the host's change bar and hover card for a changed field (null when unchanged) */\n bar: (path: FieldPath, field: FieldSchema) => React.ReactNode;\n /** Show only changes: unchanged fields fold into one quiet line each run */\n onlyChanges: boolean;\n}\n\n/** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats\n * its section's title (\"Options\" › \"Options\"): the section heading names it. */\nexport const KitSectionTitle = React.createContext<string | null>(null);\n/**\n * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host\n * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.\n */\nexport const KitAddressContext = React.createContext<((slug: string) => React.ReactNode) | null>(null);\nexport const DEFAULT_ENV: KitEnv = {\n variant: \"panel\",\n docId: \"kit\",\n palette: [],\n readOnly: false,\n can: () => true,\n presence: {},\n comments: {},\n};\nconst EnvCtx = React.createContext<KitEnv>(DEFAULT_ENV);\n\n/** D58 field access: fields in the `seo` group default to `{ edit: \"seo.edit\" }`. */\nexport const fieldAccessOf = (field: FieldSchema): FieldAccess | undefined => field.access ?? (field.group === \"seo\" ? { edit: \"seo.edit\" } : undefined);\n\n/**\n * One field for the lens: hidden (no `view`), read-only (plain text: no `edit`, the field is `readOnly`, or the whole form\n * is read-only and the field has no edit cap of its own), or editable. An explicit `edit` cap wins over the form's\n * read-only rule, so an SEO specialist edits SEO fields inside a form they can't otherwise change.\n */\nexport function resolveFieldAccess(field: FieldSchema, env: Pick<KitEnv, \"can\" | \"readOnly\">): { hidden: boolean; readOnly: boolean } {\n const a = fieldAccessOf(field);\n if (a?.view && !env.can(a.view)) return { hidden: true, readOnly: true };\n if (field.readOnly === true) return { hidden: false, readOnly: true };\n if (a?.edit) return { hidden: false, readOnly: !env.can(a.edit) };\n return { hidden: false, readOnly: env.readOnly };\n}\n/** Drop the fields the lens can't `view` (recursively), so they are neither rendered nor validated. Same object back when\n * nothing is hidden. Values of dropped fields stay in the document untouched. */\nexport function visibleFields(fields: FieldSchema[], can: KitEnv[\"can\"]): FieldSchema[] {\n let changed = false;\n const out: FieldSchema[] = [];\n for (const f of fields) {\n const a = fieldAccessOf(f);\n if (a?.view && !can(a.view)) {\n changed = true;\n continue;\n }\n let g = f;\n if (f.fields) {\n const n = visibleFields(f.fields, can);\n if (n !== f.fields) g = { ...g, fields: n };\n }\n if (Array.isArray(f.of)) {\n const n = visibleFields(f.of, can);\n if (n !== f.of) g = { ...g, of: n };\n }\n if (f.slotSettings) {\n const n = visibleFields(f.slotSettings, can);\n if (n !== f.slotSettings) g = { ...g, slotSettings: n };\n }\n if (g !== f) changed = true;\n out.push(g);\n }\n return changed ? out : fields;\n}\nexport function visibleSchema(schema: TypeSchema, can: KitEnv[\"can\"]): TypeSchema {\n const fields = visibleFields(schema.fields, can);\n return fields === schema.fields ? schema : { ...schema, fields };\n}\n\n/** Developer surfaces (field keys, API names, IDs): `schema.view` or `api.view`. */\nexport const seesDevSurfaces = (env: Pick<KitEnv, \"can\">) => env.can(\"schema.view\") || env.can(\"api.view\");\nexport const KitEnvProvider = EnvCtx.Provider;\nexport const useKitEnv = () => React.useContext(EnvCtx);\n\n/* ── Form runtime (inside <SchemaForm>) ──────────────────────────────── */\nexport interface HistoryEntry {\n value: unknown;\n at: number;\n by: string;\n label?: string;\n}\nexport interface FormApi {\n schema: TypeSchema;\n value: Record<string, unknown>;\n /** write a value; `record: false` skips the field undo/history stack (e.g. programmatic sync) */\n setAt: (path: FieldPath, v: unknown, opts?: { record?: boolean; label?: string }) => void;\n getAt: (path: FieldPath) => unknown;\n /** value when the form mounted (field undo baseline) */\n baselineAt: (path: FieldPath) => unknown;\n /** published value (changed dot, Reset to published); undefined when never published */\n publishedAt: (path: FieldPath) => unknown;\n hasPublished: boolean;\n /** component instances (CPO D28): top-level fields inherit from a component unless overridden */\n inherited?: { from: string; isOverridden: (key: string) => boolean; reset: (key: string) => void };\n /** the current navigation path (drill-in stack) */\n path: FieldPath;\n navigate: (path: FieldPath) => void;\n /** the form draws frames for a non-root path. False while SchemaForm renders only the root frame: History and\n * drill-in rows hide or go inert instead of navigating to a path nothing shows (no silent no-op). */\n canNavigate: boolean;\n resolveSchema?: (blockType: string) => TypeSchema | undefined;\n /** blocks offered by \"+ Add block\" in slots (filtered by each slot's allow list) */\n blockLibrary?: TypeSchema[];\n /** all issues by pathKey */\n issues: Map<string, KitIssue>;\n /** the issue shown for a key (rules on blur, required after blur or a publish attempt) */\n visibleIssue: (key: string) => KitIssue | undefined;\n /** visible issues under a path prefix (rollup dots on rows, crumbs and tabs) */\n rollup: (prefix: FieldPath) => { errors: number; warnings: number };\n touch: (key: string) => void;\n showAllErrors: boolean;\n /** per-field undo (Undo last change to {label}) */\n canUndo: (key: string) => boolean;\n undo: (key: string) => void;\n /** versions of a field this session (newest first) */\n history: (key: string) => HistoryEntry[];\n /** the last change to this field came from AI (⋯ shows \"Undo AI change\") */\n aiKeys: Set<string>;\n markAi: (key: string, on: boolean) => void;\n /** remembered UI state per frame (selected group tab, open fieldsets) */\n memory: Map<string, unknown>;\n}\nconst FormCtx = React.createContext<FormApi | null>(null);\nexport const FormProvider = FormCtx.Provider;\nexport const useForm = () => React.useContext(FormCtx);\n\n/* ── Look: which design the engine draws ────────────────────────────── */\n/**\n * \"v2\" (default) is the kit's own look, on every dashboard route. \"v16\" is the Visual Editor inspector of prototype\n * editor-v16 (INSPECTOR-FRAMEWORK §3): FieldSection draws the Section header (16 icon, 14/20 medium, rule UNDER the\n * group), an array's rows sit in the grey item list card with Add inside and the \"n of max\" note, and an item screen\n * ends with the red Delete. A host opts in by wrapping its inspector in <KitLookProvider>; nothing else changes.\n */\nexport type KitLook = \"v2\" | \"v16\";\nconst LookCtx = React.createContext<KitLook>(\"v2\");\nexport function KitLookProvider({ look = \"v16\", children }: { look?: KitLook; children: React.ReactNode }) {\n return <LookCtx.Provider value={look}>{children}</LookCtx.Provider>;\n}\nexport const useKitLook = () => React.useContext(LookCtx);\n\n/**\n * P-FDOT (prototype inspector.jsx:1220-1226, kit.css:506-515): the field a canvas click opened. The host sets it to\n * the field's path key (pathKey(path), e.g. \"title\" or \"cta.label\"); that field's label gets the 6px violet dot, and\n * `flash` (any value that changes per click, e.g. a counter) runs the violet sweep across it once. The host clears it\n * (null) when the author clicks or types in the field. Null everywhere else: nothing is drawn.\n */\nexport interface KitFocusField {\n key: string;\n flash?: number | string;\n}\nconst FocusFieldCtx = React.createContext<KitFocusField | null>(null);\nexport const KitFocusFieldProvider = FocusFieldCtx.Provider;\nexport const useKitFocusField =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
|
|
41
41
|
/** Why a typed tag is not added, or null when it is (the backend's own checks, said in words). */
|
|
42
42
|
export declare function tagRefusal(tag: string, list: string[]): string | null;
|
|
43
43
|
/** Chip input. Says so at its limit, and says why a tag was not added, instead of silently dropping it. */
|
|
44
|
-
export declare function TagsControl(
|
|
44
|
+
export declare function TagsControl(props: ControlProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/controls/choice.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import "../adapters/prod-types.js";
|
|
2
2
|
import { dockIconOf } from "../adapters/icons.js";
|
|
3
3
|
import { cn } from "../lib/cn.js";
|
|
4
|
-
import { useKitEnv, useKitServices } from "../context.js";
|
|
4
|
+
import { useKitEnv, useKitLook, useKitServices } from "../context.js";
|
|
5
5
|
import { KitIcon, iconKey } from "../lib/icons.js";
|
|
6
6
|
import { shortcutHintsOn } from "../ui/shortcut-hint.js";
|
|
7
7
|
import { Checkbox, Segmented, Switch } from "../ui/controls.js";
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/overlay.js";
|
|
9
9
|
import { Select } from "../ui/select.js";
|
|
10
10
|
import { fitsSegmented } from "../ui/choice-switch.js";
|
|
11
|
+
import { TagsInput } from "../ui/content-fields.js";
|
|
11
12
|
import { UnknownValueNote } from "./unknown-value.js";
|
|
12
13
|
import * as React from "react";
|
|
13
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -258,8 +259,10 @@ function SelectInput({ field, value, onChange, readOnly, id, invalid }) {
|
|
|
258
259
|
}
|
|
259
260
|
/** As `SelectControl`: each stored choice no option names any more is kept and flagged, with change-to and remove. */
|
|
260
261
|
function MultiSelectControl(props) {
|
|
262
|
+
const v16 = useKitLook() === "v16";
|
|
261
263
|
const list = Array.isArray(props.value) ? props.value.filter((x) => typeof x === "string") : [];
|
|
262
264
|
const options = opts(props.field.options);
|
|
265
|
+
if (v16 && !options.length && props.field.allowCustom === true) return /* @__PURE__ */ jsx(TagsControlV16, { ...props });
|
|
263
266
|
const unknown = options.length ? list.filter((x) => !options.some((o) => o.value === x)) : [];
|
|
264
267
|
if (unknown.length === 0) return /* @__PURE__ */ jsx(MultiSelectInput, { ...props });
|
|
265
268
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -391,8 +394,24 @@ function tagRefusal(tag, list) {
|
|
|
391
394
|
if (twin !== void 0) return `"${twin}" is already a tag.`;
|
|
392
395
|
return null;
|
|
393
396
|
}
|
|
397
|
+
/** Look "v16": the prototype Tags field (`TagsInput`, content.jsx Tags): the same value and the same refusals. */
|
|
398
|
+
function TagsControlV16({ field, value, onChange, readOnly, id }) {
|
|
399
|
+
const list = Array.isArray(value) ? value.map((x) => str(x)) : [];
|
|
400
|
+
const max = field.validation?.max;
|
|
401
|
+
return /* @__PURE__ */ jsx(TagsInput, {
|
|
402
|
+
id,
|
|
403
|
+
"aria-label": field.title,
|
|
404
|
+
value: list,
|
|
405
|
+
onChange,
|
|
406
|
+
disabled: readOnly,
|
|
407
|
+
validate: (t, tags) => max != null && tags.length >= max ? `${field.title} takes up to ${max}.` : tagRefusal(t, tags) ?? void 0
|
|
408
|
+
});
|
|
409
|
+
}
|
|
394
410
|
/** Chip input. Says so at its limit, and says why a tag was not added, instead of silently dropping it. */
|
|
395
|
-
function TagsControl(
|
|
411
|
+
function TagsControl(props) {
|
|
412
|
+
return useKitLook() === "v16" ? /* @__PURE__ */ jsx(TagsControlV16, { ...props }) : /* @__PURE__ */ jsx(TagsControlV2, { ...props });
|
|
413
|
+
}
|
|
414
|
+
function TagsControlV2({ field, value, onChange, readOnly, id, onBlur }) {
|
|
396
415
|
const list = Array.isArray(value) ? value.map((x) => str(x)) : [];
|
|
397
416
|
const [draft, setDraft] = React.useState("");
|
|
398
417
|
const [refusal, setRefusal] = React.useState(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice.js","names":[],"sources":["../../src/controls/choice.tsx"],"sourcesContent":["/**\n * CHOICE — boolean · select · multiselect · tags (V2 HEAD 9829bf1 kit/controls/choice.tsx, DESIGN 8.10–8.12).\n * Rule (production): few options → segmented, many → dropdown, many values → checkboxes, on/off → switch card.\n * D46: `layout: \"segmented\"` is a request, not a promise. With 4+ options, or labels that would wrap or truncate\n * in a 340px inspector (`fitsSegmented`), it renders the dropdown instead, so every schema follows the rule.\n *\n * Values are the ones production stores, untouched by any adapter (schema.ts plans them AS_IS): boolean, the option's\n * string, a string[] of option values, a string[] of tags. Tags are written the way the backend judges them\n * (tagsValueProblem: trimmed, case-insensitively unique, at most TAG_VALUE_MAX_LENGTH characters), and a tag the\n * control will not add says why under the box instead of vanishing.\n *\n * Option icons are all or none per list (the schema adapter's rule): a list draws icons only when every option names an\n * icon that can be drawn, so labels stay aligned and no option gets a stand-in glyph. The host's glyphs come first\n * (KitServices.IconGlyph, the BetterCMS set the site renders: every stored option icon is one of its names); with no\n * host renderer, the kit's own drawn icons.\n */\nimport * as React from \"react\";\nimport { IconCheck, IconPlus, IconX } from \"@tabler/icons-react\";\nimport { Checkbox, Segmented, Switch } from \"../ui/controls\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { Select } from \"../ui/select\";\nimport { fitsSegmented } from \"../ui/choice-switch\";\nimport { shortcutHintsOn } from \"../ui/shortcut-hint\";\nimport { cn } from \"../lib/cn\";\nimport { KitIcon, iconKey } from \"../lib/icons\";\nimport type { Option } from \"../schema/types\";\nimport { useKitEnv, useKitServices, type KitServices } from \"../context\";\nimport { dockIconOf } from \"../adapters/icons\";\nimport type { ControlProps } from \"../types\";\nimport { TAG_VALUE_MAX_LENGTH } from \"../adapters/prod-types\";\nimport { UnknownValueNote } from \"./unknown-value\";\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v : v == null ? \"\" : String(v));\nconst opts = (o?: Option[]) => o ?? [];\n\n/**\n * Icons for a list: every option's icon when all of them resolve, otherwise none (never a fallback glyph). `Glyph` is\n * the host's renderer (KitServices.IconGlyph): it draws every BetterCMS icon name (the option's kit name read back\n * through dockIconOf); without it, or when a name is not in that set, the kit's own drawn icons.\n */\nexport function optionIcons(options: Option[], className?: string, Glyph?: KitServices[\"IconGlyph\"]): (React.ReactNode | undefined)[] {\n if (options.length === 0) return [];\n const dock = options.map((o) => dockIconOf(o.icon));\n // a block box, as the kit's own <svg> is under preflight: an inline glyph would sit on a line box and grow the row\n if (Glyph && dock.every((n) => n !== undefined)) return dock.map((n) => <Glyph name={n!} className={cn(\"flex\", className)} />);\n const all = options.every((o) => iconKey(o.icon) !== undefined);\n return options.map((o) => (all ? <KitIcon name={o.icon} className={className} /> : undefined));\n}\n\n/** The limit sentence (DESIGN 8.12), shared by multiselect and tags. */\nfunction LimitLine({ max }: { max: number }) {\n return <span className=\"px-0.5 text-kit-xs text-kit-fg-3\">That's the limit of {max}. Remove one to add another.</span>;\n}\n\n/**\n * Roving focus for a radiogroup of buttons (WAI-ARIA radio group, as Segmented does): Tab lands on the selected option\n * (or the first), arrows move and select, Home / End jump.\n */\nfunction useRadioKeys(values: string[], current: string, onPick: (v: string) => void, readOnly?: boolean) {\n const focusable = values.includes(current) ? current : values[0];\n const onKeyDown = (e: React.KeyboardEvent, i: number) => {\n if (readOnly || !values.length) return;\n const n = values.length;\n const next =\n e.key === \"ArrowRight\" || e.key === \"ArrowDown\"\n ? (i + 1) % n\n : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\"\n ? (i - 1 + n) % n\n : e.key === \"Home\"\n ? 0\n : e.key === \"End\"\n ? n - 1\n : -1;\n if (next < 0) return;\n e.preventDefault();\n onPick(values[next]);\n const group = (e.currentTarget as HTMLElement).closest(\"[role=radiogroup]\");\n group?.querySelector<HTMLElement>(`[data-choice-value=\"${CSS.escape(values[next])}\"]`)?.focus();\n };\n return { tabIndexOf: (v: string) => (v === focusable ? 0 : -1), onKeyDown };\n}\n\n/**\n * Adds or removes one id of the control's own in aria-describedby, leaving the ids FieldShell wires (help, issue)\n * in place (as ScaleSlider does).\n */\nexport function useOwnDescription(ref: React.RefObject<HTMLElement | null>, ownId: string | null) {\n const last = React.useRef<string | null>(null);\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const ids = (el.getAttribute(\"aria-describedby\") ?? \"\").split(\" \").filter((t) => t && t !== last.current && t !== ownId);\n if (ownId) ids.push(ownId);\n if (ids.length) el.setAttribute(\"aria-describedby\", ids.join(\" \"));\n else el.removeAttribute(\"aria-describedby\");\n last.current = ownId;\n });\n}\n\n/** Boolean switch (used inside the switch card the shell draws). Commits immediately. */\nexport function BooleanControl({ field, value, onChange, readOnly, id }: ControlProps) {\n if (field.layout === \"checkbox\")\n return <Checkbox id={id} checked={Boolean(value)} disabled={readOnly} onCheckedChange={(c) => onChange(c === true)} aria-label={field.title} nativeButton render={<button type=\"button\" />} />;\n /* V2's switch is a native <button role=\"switch\"> (Radix); Base UI draws a <span> unless asked for the button */\n return <Switch id={id} checked={Boolean(value)} disabled={readOnly} onCheckedChange={(c) => onChange(c)} aria-label={field.title} nativeButton render={<button type=\"button\" />} />;\n}\n\n/**\n * A stored value none of the options names any more (renamed or removed) is kept and flagged under the control, with\n * change-to and remove (H4). @see UnknownValueNote\n */\nexport function SelectControl(props: ControlProps) {\n const options = opts(props.field.options);\n const v = str(props.value);\n if (v === \"\" || options.length === 0 || options.some((o) => o.value === v)) return <SelectInput {...props} />;\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <SelectInput {...props} />\n <UnknownValueNote\n items={[{ key: v, label: `“${v}”`, options: options.map((o) => ({ value: o.value, label: o.label })) }]}\n onRemap={(_, to) => props.onChange(to)}\n onRemove={() => props.onChange(null)}\n readOnly={props.readOnly}\n />\n </div>\n );\n}\n\nfunction SelectInput({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const { variant } = useKitEnv();\n const { IconGlyph } = useKitServices();\n const options = opts(field.options);\n const v = str(value);\n const fits = fitsSegmented(options.map((o) => o.label));\n const layout = field.layout ?? (fits ? \"segmented\" : \"dropdown\");\n const pick = (n: string) => {\n if (!readOnly && n !== v) onChange(n);\n };\n const keys = useRadioKeys(\n options.map((o) => o.value),\n v,\n pick,\n readOnly,\n );\n\n if (layout === \"segmented\" && fits) {\n const icons = optionIcons(options, \"size-3.5\", IconGlyph);\n return (\n <Segmented\n aria-label={field.title}\n value={v}\n onChange={pick}\n items={options.map((o, i) => ({ value: o.value, label: o.label, icon: icons[i], disabled: readOnly }))}\n className=\"w-full [&>button]:min-w-0 [&>button]:flex-1\"\n />\n );\n }\n if (layout === \"radio\")\n return (\n <div role=\"radiogroup\" id={id} aria-label={field.title} className=\"flex flex-col gap-0.5\">\n {options.map((o, i) => (\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n data-choice-value={o.value}\n aria-checked={o.value === v}\n tabIndex={keys.tabIndexOf(o.value)}\n disabled={readOnly}\n onClick={() => pick(o.value)}\n onKeyDown={(e) => keys.onKeyDown(e, i)}\n className=\"flex items-start gap-2.5 rounded-kit-md px-1.5 py-1.5 text-left hover:bg-kit-hover\"\n >\n <span className={cn(\"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors\", o.value === v ? \"border-kit-accent\" : \"border-kit-line-strong\")}>\n {o.value === v ? <span className=\"size-2 rounded-full bg-kit-accent\" /> : null}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block text-kit-sm text-kit-fg\">{o.label}</span>\n {o.description ? <span className=\"block text-kit-xs text-kit-fg-3\">{o.description}</span> : null}\n </span>\n </button>\n ))}\n </div>\n );\n if (layout === \"cards\" || layout === \"grid\") {\n /* V2 draws the icon itself as the button's first child (no wrapper), coloured by the selected state */\n const iconsOn = optionIcons(options, \"size-4 text-kit-fg\", IconGlyph);\n const iconsOff = optionIcons(options, \"size-4 text-kit-fg-3\", IconGlyph);\n return (\n <div role=\"radiogroup\" id={id} aria-label={field.title} className={cn(\"grid gap-1.5\", variant === \"document\" ? \"grid-cols-3\" : \"grid-cols-2\")}>\n {options.map((o, i) => {\n const on = o.value === v;\n return (\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n data-choice-value={o.value}\n aria-checked={on}\n tabIndex={keys.tabIndexOf(o.value)}\n disabled={readOnly}\n onClick={() => pick(o.value)}\n onKeyDown={(e) => keys.onKeyDown(e, i)}\n className={cn(\n \"relative flex flex-col items-start gap-1.5 rounded-kit-lg border p-2.5 text-left transition-[border-color,box-shadow] duration-150\",\n on ? \"border-[var(--kit-emphasis-line)] bg-kit-control-bg shadow-kit-xs\" : \"border-kit-line hover:border-kit-line-strong\",\n )}\n >\n {(on ? iconsOn : iconsOff)[i] ?? null}\n <span className=\"text-kit-sm font-medium text-kit-fg\">{o.label}</span>\n {o.description ? <span className=\"text-kit-xs leading-4 text-kit-fg-3\">{o.description}</span> : null}\n {on ? <IconCheck aria-hidden className=\"absolute right-2 top-2 size-3.5 text-kit-fg\" stroke={2} /> : null}\n </button>\n );\n })}\n </div>\n );\n }\n const icons = optionIcons(options, undefined, IconGlyph);\n return (\n <Select\n id={id}\n aria-label={field.title}\n aria-invalid={invalid}\n size={variant === \"document\" ? \"lg\" : \"md\"}\n value={v || undefined}\n disabled={readOnly}\n onValueChange={pick}\n placeholder={field.placeholder ?? \"Select…\"}\n options={options.map((o, i) => ({ value: o.value, label: o.label, description: o.description, icon: icons[i] }))}\n />\n );\n}\n\n/** As `SelectControl`: each stored choice no option names any more is kept and flagged, with change-to and remove. */\nexport function MultiSelectControl(props: ControlProps) {\n const list = Array.isArray(props.value) ? (props.value as unknown[]).filter((x): x is string => typeof x === \"string\") : [];\n const options = opts(props.field.options);\n const unknown = options.length ? list.filter((x) => !options.some((o) => o.value === x)) : [];\n if (unknown.length === 0) return <MultiSelectInput {...props} />;\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <MultiSelectInput {...props} />\n <UnknownValueNote\n items={unknown.map((x) => ({ key: x, label: `“${x}”`, options: options.filter((o) => !list.includes(o.value)).map((o) => ({ value: o.value, label: o.label })) }))}\n onRemap={(from, to) => props.onChange(list.map((x) => (x === from ? to : x)))}\n onRemove={(from) => props.onChange(list.filter((x) => x !== from))}\n readOnly={props.readOnly}\n />\n </div>\n );\n}\n\nfunction MultiSelectInput({ field, value, onChange, readOnly, id }: ControlProps) {\n const list = Array.isArray(value) ? (value as unknown[]).filter((x): x is string => typeof x === \"string\") : [];\n const options = opts(field.options);\n const max = field.validation?.max;\n const full = max != null && list.length >= max;\n const toggle = (o: string) => {\n if (readOnly) return;\n if (list.includes(o)) onChange(list.filter((x) => x !== o));\n else if (!full) onChange([...list, o]);\n };\n const label = (val: string) => options.find((o) => o.value === val)?.label ?? val;\n /* DK-010: Backspace on the chip row, the Add button or the open list removes the last chip (as the tags control\n does) and never reaches the host, whose own Backspace deletes the selected section. Focus goes to the Add button,\n since the chip that had it may be the one removed. */\n const onBackspace = (e: React.KeyboardEvent) => {\n if (e.key !== \"Backspace\") return;\n e.stopPropagation();\n if (readOnly || !list.length) return;\n e.preventDefault();\n onChange(list.slice(0, -1));\n if ((e.target as HTMLElement).matches(\"[aria-label^='Remove ']\") && id) document.getElementById(id)?.focus();\n };\n /* V2 draws the control bare; the limit line (ours: say why the next pick is refused) wraps it only while it shows */\n const withLimit = (body: React.ReactElement) =>\n full && !readOnly ? (\n <div className=\"flex flex-col gap-1\">\n {body}\n <LimitLine max={max!} />\n </div>\n ) : (\n body\n );\n if (field.layout === \"checkbox\" || field.layout === \"list\")\n return withLimit(\n <>\n <div id={id} role=\"group\" aria-label={field.title} className=\"flex flex-col gap-0.5\">\n {options.map((o) => {\n const on = list.includes(o.value);\n return (\n <label key={o.value} className={cn(\"flex cursor-pointer items-center gap-2.5 rounded-kit-md px-1.5 py-1.5 hover:bg-kit-hover\", !on && full && \"cursor-not-allowed hover:bg-transparent\")}>\n <Checkbox checked={on} disabled={readOnly || (!on && full)} onCheckedChange={() => toggle(o.value)} nativeButton render={<button type=\"button\" />} />\n <span className=\"text-kit-sm text-kit-fg\">{o.label}</span>\n </label>\n );\n })}\n </div>\n </>,\n );\n return withLimit(\n <>\n <Popover>\n {/* read-only there is no trigger to carry the field id, so the chip row is the named group */}\n <div\n id={readOnly ? id : undefined}\n role={readOnly ? \"group\" : undefined}\n aria-label={readOnly ? field.title : undefined}\n onKeyDown={onBackspace}\n className=\"flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-1 transition-colors hover:border-kit-line-strong\"\n >\n {list.map((o) => (\n <span key={o} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md border border-kit-line bg-kit-control-bg pl-2 pr-1 text-kit-sm text-kit-fg shadow-kit-xs\">\n {label(o)}\n {readOnly ? null : (\n <button type=\"button\" aria-label={`Remove ${label(o)}`} onClick={() => toggle(o)} className=\"flex rounded-kit-md p-0.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconX className=\"size-3\" stroke={1.5} />\n </button>\n )}\n </span>\n ))}\n {readOnly ? null : (\n <PopoverTrigger id={id} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md px-1.5 text-kit-sm text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconPlus aria-hidden className=\"size-3.5\" stroke={1.5} />\n {list.length ? \"Add\" : field.placeholder ?? \"Choose…\"}\n </PopoverTrigger>\n )}\n </div>\n <PopoverContent className=\"w-60 p-1\">\n <div role=\"group\" aria-label={field.title} onKeyDown={onBackspace}>\n {options.map((o) => {\n const on = list.includes(o.value);\n const blocked = !on && full;\n return (\n <button\n key={o.value}\n type=\"button\"\n role=\"checkbox\"\n aria-checked={on}\n disabled={blocked}\n onClick={() => toggle(o.value)}\n className={cn(\"flex h-8 w-full items-center gap-2 rounded-kit-md px-2 text-left text-kit-sm hover:bg-kit-hover\", blocked && \"opacity-40 hover:bg-transparent\")}\n >\n <span className={cn(\"flex size-4 items-center justify-center rounded-kit-md border\", on ? \"border-kit-accent bg-kit-accent text-kit-accent-on\" : \"border-kit-line-strong\")}>\n {on ? <IconCheck aria-hidden className=\"size-3\" stroke={3} /> : null}\n </span>\n {o.label}\n </button>\n );\n })}\n </div>\n {full ? <div className=\"px-2 pb-1 pt-1.5\"><LimitLine max={max!} /></div> : null}\n </PopoverContent>\n </Popover>\n </>,\n );\n}\n\n/** Why a typed tag is not added, or null when it is (the backend's own checks, said in words). */\nexport function tagRefusal(tag: string, list: string[]): string | null {\n if (Array.from(tag).length > TAG_VALUE_MAX_LENGTH) return `A tag can be up to ${TAG_VALUE_MAX_LENGTH} characters.`;\n const folded = tag.toLowerCase();\n const twin = list.find((t) => t.trim().toLowerCase() === folded);\n if (twin !== undefined) return `\"${twin}\" is already a tag.`;\n return null;\n}\n\n/** Chip input. Says so at its limit, and says why a tag was not added, instead of silently dropping it. */\nexport function TagsControl({ field, value, onChange, readOnly, id, onBlur }: ControlProps) {\n const list = Array.isArray(value) ? (value as unknown[]).map((x) => str(x)) : [];\n const [draft, setDraft] = React.useState(\"\");\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const reasonId = React.useId();\n const inputRef = React.useRef<HTMLInputElement>(null);\n useOwnDescription(inputRef, refusal ? reasonId : null);\n const max = field.validation?.max;\n const full = max != null && list.length >= max;\n const add = () => {\n const t = draft.trim().replace(/,$/, \"\").trim();\n if (!t || full) {\n setDraft(\"\");\n setRefusal(null);\n return;\n }\n const why = tagRefusal(t, list);\n if (why) {\n // keep the text so it can be fixed; the reason reads under the box\n setRefusal(why);\n return;\n }\n onChange([...list, t]);\n setDraft(\"\");\n setRefusal(null);\n };\n return (\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-1 transition-colors focus-within:border-kit-line-strong focus-within:bg-kit-field-bg hover:border-kit-line-strong\">\n {list.map((t, i) => (\n <span key={`${t}-${i}`} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md bg-kit-selected pl-2 pr-1 text-kit-sm text-kit-fg\">\n {t}\n {readOnly ? null : (\n <button type=\"button\" aria-label={`Remove ${t}`} onClick={() => onChange(list.filter((_, j) => j !== i))} className=\"flex rounded-kit-md p-0.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconX className=\"size-3\" stroke={1.5} />\n </button>\n )}\n </span>\n ))}\n {readOnly ? null : (\n <input\n ref={inputRef}\n id={id}\n value={draft}\n disabled={full}\n onChange={(e) => {\n setDraft(e.target.value);\n if (refusal) setRefusal(null);\n }}\n onBlur={() => {\n add();\n onBlur?.();\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \",\") {\n e.preventDefault();\n add();\n } else if (e.key === \"Backspace\" && !draft && list.length) onChange(list.slice(0, -1));\n }}\n placeholder={full ? \"\" : list.length ? \"Add…\" : field.placeholder ?? (shortcutHintsOn() ? \"Type and press Enter\" : \"Add…\")}\n className=\"h-6 min-w-20 flex-1 bg-transparent px-1.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n )}\n </div>\n {refusal && !readOnly ? (\n <span id={reasonId} role=\"status\" aria-live=\"polite\" className=\"px-0.5 text-kit-xs text-kit-fg-3\">\n {refusal}\n </span>\n ) : null}\n {full && !readOnly ? <LimitLine max={max!} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAM,OAAO,MAAgB,OAAO,MAAM,WAAW,IAAI,KAAK,OAAO,KAAK,OAAO,CAAC;AAClF,IAAM,QAAQ,MAAiB,KAAK,CAAC;;;;;;AAOrC,SAAgB,YAAY,SAAmB,WAAoB,OAAmE;CACpI,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;CAClC,MAAM,OAAO,QAAQ,KAAK,MAAM,WAAW,EAAE,IAAI,CAAC;CAElD,IAAI,SAAS,KAAK,OAAO,MAAM,MAAM,KAAA,CAAS,GAAG,OAAO,KAAK,KAAK,MAAM,oBAAC,OAAD;EAAO,MAAM;EAAI,WAAW,GAAG,QAAQ,SAAS;CAAI,CAAA,CAAC;CAC7H,MAAM,MAAM,QA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AAyB;KACnH,WAAU;IACX,CAAA,CAEA;;GACJ,WAAW,CAAC,WACX,oBAAC,QAAD;IAAM,IAAI;IAAU,MAAK;IAAS,aAAU;IAAS,WAAU;IAC5D,UAAA;GACG,CAAA,IACJ;GACH,QAAQ,CAAC,WAAW,oBAAC,WAAD,EAAgB,IAAO,CAAA,IAAI;EAC7C;;AAET"}
|
|
1
|
+
{"version":3,"file":"choice.js","names":[],"sources":["../../src/controls/choice.tsx"],"sourcesContent":["/**\n * CHOICE — boolean · select · multiselect · tags (V2 HEAD 9829bf1 kit/controls/choice.tsx, DESIGN 8.10–8.12).\n * Rule (production): few options → segmented, many → dropdown, many values → checkboxes, on/off → switch card.\n * D46: `layout: \"segmented\"` is a request, not a promise. With 4+ options, or labels that would wrap or truncate\n * in a 340px inspector (`fitsSegmented`), it renders the dropdown instead, so every schema follows the rule.\n *\n * Values are the ones production stores, untouched by any adapter (schema.ts plans them AS_IS): boolean, the option's\n * string, a string[] of option values, a string[] of tags. Tags are written the way the backend judges them\n * (tagsValueProblem: trimmed, case-insensitively unique, at most TAG_VALUE_MAX_LENGTH characters), and a tag the\n * control will not add says why under the box instead of vanishing.\n *\n * Option icons are all or none per list (the schema adapter's rule): a list draws icons only when every option names an\n * icon that can be drawn, so labels stay aligned and no option gets a stand-in glyph. The host's glyphs come first\n * (KitServices.IconGlyph, the BetterCMS set the site renders: every stored option icon is one of its names); with no\n * host renderer, the kit's own drawn icons.\n */\nimport * as React from \"react\";\nimport { IconCheck, IconPlus, IconX } from \"@tabler/icons-react\";\nimport { Checkbox, Segmented, Switch } from \"../ui/controls\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { Select } from \"../ui/select\";\nimport { fitsSegmented } from \"../ui/choice-switch\";\nimport { shortcutHintsOn } from \"../ui/shortcut-hint\";\nimport { cn } from \"../lib/cn\";\nimport { KitIcon, iconKey } from \"../lib/icons\";\nimport type { Option } from \"../schema/types\";\nimport { useKitEnv, useKitLook, useKitServices, type KitServices } from \"../context\";\nimport { TagsInput } from \"../ui/content-fields\";\nimport { dockIconOf } from \"../adapters/icons\";\nimport type { ControlProps } from \"../types\";\nimport { TAG_VALUE_MAX_LENGTH } from \"../adapters/prod-types\";\nimport { UnknownValueNote } from \"./unknown-value\";\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v : v == null ? \"\" : String(v));\nconst opts = (o?: Option[]) => o ?? [];\n\n/**\n * Icons for a list: every option's icon when all of them resolve, otherwise none (never a fallback glyph). `Glyph` is\n * the host's renderer (KitServices.IconGlyph): it draws every BetterCMS icon name (the option's kit name read back\n * through dockIconOf); without it, or when a name is not in that set, the kit's own drawn icons.\n */\nexport function optionIcons(options: Option[], className?: string, Glyph?: KitServices[\"IconGlyph\"]): (React.ReactNode | undefined)[] {\n if (options.length === 0) return [];\n const dock = options.map((o) => dockIconOf(o.icon));\n // a block box, as the kit's own <svg> is under preflight: an inline glyph would sit on a line box and grow the row\n if (Glyph && dock.every((n) => n !== undefined)) return dock.map((n) => <Glyph name={n!} className={cn(\"flex\", className)} />);\n const all = options.every((o) => iconKey(o.icon) !== undefined);\n return options.map((o) => (all ? <KitIcon name={o.icon} className={className} /> : undefined));\n}\n\n/** The limit sentence (DESIGN 8.12), shared by multiselect and tags. */\nfunction LimitLine({ max }: { max: number }) {\n return <span className=\"px-0.5 text-kit-xs text-kit-fg-3\">That's the limit of {max}. Remove one to add another.</span>;\n}\n\n/**\n * Roving focus for a radiogroup of buttons (WAI-ARIA radio group, as Segmented does): Tab lands on the selected option\n * (or the first), arrows move and select, Home / End jump.\n */\nfunction useRadioKeys(values: string[], current: string, onPick: (v: string) => void, readOnly?: boolean) {\n const focusable = values.includes(current) ? current : values[0];\n const onKeyDown = (e: React.KeyboardEvent, i: number) => {\n if (readOnly || !values.length) return;\n const n = values.length;\n const next =\n e.key === \"ArrowRight\" || e.key === \"ArrowDown\"\n ? (i + 1) % n\n : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\"\n ? (i - 1 + n) % n\n : e.key === \"Home\"\n ? 0\n : e.key === \"End\"\n ? n - 1\n : -1;\n if (next < 0) return;\n e.preventDefault();\n onPick(values[next]);\n const group = (e.currentTarget as HTMLElement).closest(\"[role=radiogroup]\");\n group?.querySelector<HTMLElement>(`[data-choice-value=\"${CSS.escape(values[next])}\"]`)?.focus();\n };\n return { tabIndexOf: (v: string) => (v === focusable ? 0 : -1), onKeyDown };\n}\n\n/**\n * Adds or removes one id of the control's own in aria-describedby, leaving the ids FieldShell wires (help, issue)\n * in place (as ScaleSlider does).\n */\nexport function useOwnDescription(ref: React.RefObject<HTMLElement | null>, ownId: string | null) {\n const last = React.useRef<string | null>(null);\n React.useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const ids = (el.getAttribute(\"aria-describedby\") ?? \"\").split(\" \").filter((t) => t && t !== last.current && t !== ownId);\n if (ownId) ids.push(ownId);\n if (ids.length) el.setAttribute(\"aria-describedby\", ids.join(\" \"));\n else el.removeAttribute(\"aria-describedby\");\n last.current = ownId;\n });\n}\n\n/** Boolean switch (used inside the switch card the shell draws). Commits immediately. */\nexport function BooleanControl({ field, value, onChange, readOnly, id }: ControlProps) {\n if (field.layout === \"checkbox\")\n return <Checkbox id={id} checked={Boolean(value)} disabled={readOnly} onCheckedChange={(c) => onChange(c === true)} aria-label={field.title} nativeButton render={<button type=\"button\" />} />;\n /* V2's switch is a native <button role=\"switch\"> (Radix); Base UI draws a <span> unless asked for the button */\n return <Switch id={id} checked={Boolean(value)} disabled={readOnly} onCheckedChange={(c) => onChange(c)} aria-label={field.title} nativeButton render={<button type=\"button\" />} />;\n}\n\n/**\n * A stored value none of the options names any more (renamed or removed) is kept and flagged under the control, with\n * change-to and remove (H4). @see UnknownValueNote\n */\nexport function SelectControl(props: ControlProps) {\n const options = opts(props.field.options);\n const v = str(props.value);\n if (v === \"\" || options.length === 0 || options.some((o) => o.value === v)) return <SelectInput {...props} />;\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <SelectInput {...props} />\n <UnknownValueNote\n items={[{ key: v, label: `“${v}”`, options: options.map((o) => ({ value: o.value, label: o.label })) }]}\n onRemap={(_, to) => props.onChange(to)}\n onRemove={() => props.onChange(null)}\n readOnly={props.readOnly}\n />\n </div>\n );\n}\n\nfunction SelectInput({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const { variant } = useKitEnv();\n const { IconGlyph } = useKitServices();\n const options = opts(field.options);\n const v = str(value);\n const fits = fitsSegmented(options.map((o) => o.label));\n const layout = field.layout ?? (fits ? \"segmented\" : \"dropdown\");\n const pick = (n: string) => {\n if (!readOnly && n !== v) onChange(n);\n };\n const keys = useRadioKeys(\n options.map((o) => o.value),\n v,\n pick,\n readOnly,\n );\n\n if (layout === \"segmented\" && fits) {\n const icons = optionIcons(options, \"size-3.5\", IconGlyph);\n return (\n <Segmented\n aria-label={field.title}\n value={v}\n onChange={pick}\n items={options.map((o, i) => ({ value: o.value, label: o.label, icon: icons[i], disabled: readOnly }))}\n className=\"w-full [&>button]:min-w-0 [&>button]:flex-1\"\n />\n );\n }\n if (layout === \"radio\")\n return (\n <div role=\"radiogroup\" id={id} aria-label={field.title} className=\"flex flex-col gap-0.5\">\n {options.map((o, i) => (\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n data-choice-value={o.value}\n aria-checked={o.value === v}\n tabIndex={keys.tabIndexOf(o.value)}\n disabled={readOnly}\n onClick={() => pick(o.value)}\n onKeyDown={(e) => keys.onKeyDown(e, i)}\n className=\"flex items-start gap-2.5 rounded-kit-md px-1.5 py-1.5 text-left hover:bg-kit-hover\"\n >\n <span className={cn(\"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors\", o.value === v ? \"border-kit-accent\" : \"border-kit-line-strong\")}>\n {o.value === v ? <span className=\"size-2 rounded-full bg-kit-accent\" /> : null}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block text-kit-sm text-kit-fg\">{o.label}</span>\n {o.description ? <span className=\"block text-kit-xs text-kit-fg-3\">{o.description}</span> : null}\n </span>\n </button>\n ))}\n </div>\n );\n if (layout === \"cards\" || layout === \"grid\") {\n /* V2 draws the icon itself as the button's first child (no wrapper), coloured by the selected state */\n const iconsOn = optionIcons(options, \"size-4 text-kit-fg\", IconGlyph);\n const iconsOff = optionIcons(options, \"size-4 text-kit-fg-3\", IconGlyph);\n return (\n <div role=\"radiogroup\" id={id} aria-label={field.title} className={cn(\"grid gap-1.5\", variant === \"document\" ? \"grid-cols-3\" : \"grid-cols-2\")}>\n {options.map((o, i) => {\n const on = o.value === v;\n return (\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n data-choice-value={o.value}\n aria-checked={on}\n tabIndex={keys.tabIndexOf(o.value)}\n disabled={readOnly}\n onClick={() => pick(o.value)}\n onKeyDown={(e) => keys.onKeyDown(e, i)}\n className={cn(\n \"relative flex flex-col items-start gap-1.5 rounded-kit-lg border p-2.5 text-left transition-[border-color,box-shadow] duration-150\",\n on ? \"border-[var(--kit-emphasis-line)] bg-kit-control-bg shadow-kit-xs\" : \"border-kit-line hover:border-kit-line-strong\",\n )}\n >\n {(on ? iconsOn : iconsOff)[i] ?? null}\n <span className=\"text-kit-sm font-medium text-kit-fg\">{o.label}</span>\n {o.description ? <span className=\"text-kit-xs leading-4 text-kit-fg-3\">{o.description}</span> : null}\n {on ? <IconCheck aria-hidden className=\"absolute right-2 top-2 size-3.5 text-kit-fg\" stroke={2} /> : null}\n </button>\n );\n })}\n </div>\n );\n }\n const icons = optionIcons(options, undefined, IconGlyph);\n return (\n <Select\n id={id}\n aria-label={field.title}\n aria-invalid={invalid}\n size={variant === \"document\" ? \"lg\" : \"md\"}\n value={v || undefined}\n disabled={readOnly}\n onValueChange={pick}\n placeholder={field.placeholder ?? \"Select…\"}\n options={options.map((o, i) => ({ value: o.value, label: o.label, description: o.description, icon: icons[i] }))}\n />\n );\n}\n\n/** As `SelectControl`: each stored choice no option names any more is kept and flagged, with change-to and remove. */\nexport function MultiSelectControl(props: ControlProps) {\n const v16 = useKitLook() === \"v16\";\n const list = Array.isArray(props.value) ? (props.value as unknown[]).filter((x): x is string => typeof x === \"string\") : [];\n const options = opts(props.field.options);\n // look v16 (REQ-6b-3): a free list of words (no options, custom values allowed) is the prototype Tags field\n if (v16 && !options.length && (props.field as { allowCustom?: unknown }).allowCustom === true) return <TagsControlV16 {...props} />;\n const unknown = options.length ? list.filter((x) => !options.some((o) => o.value === x)) : [];\n if (unknown.length === 0) return <MultiSelectInput {...props} />;\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <MultiSelectInput {...props} />\n <UnknownValueNote\n items={unknown.map((x) => ({ key: x, label: `“${x}”`, options: options.filter((o) => !list.includes(o.value)).map((o) => ({ value: o.value, label: o.label })) }))}\n onRemap={(from, to) => props.onChange(list.map((x) => (x === from ? to : x)))}\n onRemove={(from) => props.onChange(list.filter((x) => x !== from))}\n readOnly={props.readOnly}\n />\n </div>\n );\n}\n\nfunction MultiSelectInput({ field, value, onChange, readOnly, id }: ControlProps) {\n const list = Array.isArray(value) ? (value as unknown[]).filter((x): x is string => typeof x === \"string\") : [];\n const options = opts(field.options);\n const max = field.validation?.max;\n const full = max != null && list.length >= max;\n const toggle = (o: string) => {\n if (readOnly) return;\n if (list.includes(o)) onChange(list.filter((x) => x !== o));\n else if (!full) onChange([...list, o]);\n };\n const label = (val: string) => options.find((o) => o.value === val)?.label ?? val;\n /* DK-010: Backspace on the chip row, the Add button or the open list removes the last chip (as the tags control\n does) and never reaches the host, whose own Backspace deletes the selected section. Focus goes to the Add button,\n since the chip that had it may be the one removed. */\n const onBackspace = (e: React.KeyboardEvent) => {\n if (e.key !== \"Backspace\") return;\n e.stopPropagation();\n if (readOnly || !list.length) return;\n e.preventDefault();\n onChange(list.slice(0, -1));\n if ((e.target as HTMLElement).matches(\"[aria-label^='Remove ']\") && id) document.getElementById(id)?.focus();\n };\n /* V2 draws the control bare; the limit line (ours: say why the next pick is refused) wraps it only while it shows */\n const withLimit = (body: React.ReactElement) =>\n full && !readOnly ? (\n <div className=\"flex flex-col gap-1\">\n {body}\n <LimitLine max={max!} />\n </div>\n ) : (\n body\n );\n if (field.layout === \"checkbox\" || field.layout === \"list\")\n return withLimit(\n <>\n <div id={id} role=\"group\" aria-label={field.title} className=\"flex flex-col gap-0.5\">\n {options.map((o) => {\n const on = list.includes(o.value);\n return (\n <label key={o.value} className={cn(\"flex cursor-pointer items-center gap-2.5 rounded-kit-md px-1.5 py-1.5 hover:bg-kit-hover\", !on && full && \"cursor-not-allowed hover:bg-transparent\")}>\n <Checkbox checked={on} disabled={readOnly || (!on && full)} onCheckedChange={() => toggle(o.value)} nativeButton render={<button type=\"button\" />} />\n <span className=\"text-kit-sm text-kit-fg\">{o.label}</span>\n </label>\n );\n })}\n </div>\n </>,\n );\n return withLimit(\n <>\n <Popover>\n {/* read-only there is no trigger to carry the field id, so the chip row is the named group */}\n <div\n id={readOnly ? id : undefined}\n role={readOnly ? \"group\" : undefined}\n aria-label={readOnly ? field.title : undefined}\n onKeyDown={onBackspace}\n className=\"flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-1 transition-colors hover:border-kit-line-strong\"\n >\n {list.map((o) => (\n <span key={o} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md border border-kit-line bg-kit-control-bg pl-2 pr-1 text-kit-sm text-kit-fg shadow-kit-xs\">\n {label(o)}\n {readOnly ? null : (\n <button type=\"button\" aria-label={`Remove ${label(o)}`} onClick={() => toggle(o)} className=\"flex rounded-kit-md p-0.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconX className=\"size-3\" stroke={1.5} />\n </button>\n )}\n </span>\n ))}\n {readOnly ? null : (\n <PopoverTrigger id={id} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md px-1.5 text-kit-sm text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconPlus aria-hidden className=\"size-3.5\" stroke={1.5} />\n {list.length ? \"Add\" : field.placeholder ?? \"Choose…\"}\n </PopoverTrigger>\n )}\n </div>\n <PopoverContent className=\"w-60 p-1\">\n <div role=\"group\" aria-label={field.title} onKeyDown={onBackspace}>\n {options.map((o) => {\n const on = list.includes(o.value);\n const blocked = !on && full;\n return (\n <button\n key={o.value}\n type=\"button\"\n role=\"checkbox\"\n aria-checked={on}\n disabled={blocked}\n onClick={() => toggle(o.value)}\n className={cn(\"flex h-8 w-full items-center gap-2 rounded-kit-md px-2 text-left text-kit-sm hover:bg-kit-hover\", blocked && \"opacity-40 hover:bg-transparent\")}\n >\n <span className={cn(\"flex size-4 items-center justify-center rounded-kit-md border\", on ? \"border-kit-accent bg-kit-accent text-kit-accent-on\" : \"border-kit-line-strong\")}>\n {on ? <IconCheck aria-hidden className=\"size-3\" stroke={3} /> : null}\n </span>\n {o.label}\n </button>\n );\n })}\n </div>\n {full ? <div className=\"px-2 pb-1 pt-1.5\"><LimitLine max={max!} /></div> : null}\n </PopoverContent>\n </Popover>\n </>,\n );\n}\n\n/** Why a typed tag is not added, or null when it is (the backend's own checks, said in words). */\nexport function tagRefusal(tag: string, list: string[]): string | null {\n if (Array.from(tag).length > TAG_VALUE_MAX_LENGTH) return `A tag can be up to ${TAG_VALUE_MAX_LENGTH} characters.`;\n const folded = tag.toLowerCase();\n const twin = list.find((t) => t.trim().toLowerCase() === folded);\n if (twin !== undefined) return `\"${twin}\" is already a tag.`;\n return null;\n}\n\n/** Look \"v16\": the prototype Tags field (`TagsInput`, content.jsx Tags): the same value and the same refusals. */\nfunction TagsControlV16({ field, value, onChange, readOnly, id }: ControlProps) {\n const list = Array.isArray(value) ? (value as unknown[]).map((x) => str(x)) : [];\n const max = field.validation?.max;\n return (\n <TagsInput\n id={id}\n aria-label={field.title}\n value={list}\n onChange={onChange}\n disabled={readOnly}\n validate={(t, tags) => (max != null && tags.length >= max ? `${field.title} takes up to ${max}.` : tagRefusal(t, tags) ?? undefined)}\n />\n );\n}\n/** Chip input. Says so at its limit, and says why a tag was not added, instead of silently dropping it. */\nexport function TagsControl(props: ControlProps) {\n return useKitLook() === \"v16\" ? <TagsControlV16 {...props} /> : <TagsControlV2 {...props} />;\n}\nfunction TagsControlV2({ field, value, onChange, readOnly, id, onBlur }: ControlProps) {\n const list = Array.isArray(value) ? (value as unknown[]).map((x) => str(x)) : [];\n const [draft, setDraft] = React.useState(\"\");\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const reasonId = React.useId();\n const inputRef = React.useRef<HTMLInputElement>(null);\n useOwnDescription(inputRef, refusal ? reasonId : null);\n const max = field.validation?.max;\n const full = max != null && list.length >= max;\n const add = () => {\n const t = draft.trim().replace(/,$/, \"\").trim();\n if (!t || full) {\n setDraft(\"\");\n setRefusal(null);\n return;\n }\n const why = tagRefusal(t, list);\n if (why) {\n // keep the text so it can be fixed; the reason reads under the box\n setRefusal(why);\n return;\n }\n onChange([...list, t]);\n setDraft(\"\");\n setRefusal(null);\n };\n return (\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-1 transition-colors focus-within:border-kit-line-strong focus-within:bg-kit-field-bg hover:border-kit-line-strong\">\n {list.map((t, i) => (\n <span key={`${t}-${i}`} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md bg-kit-selected pl-2 pr-1 text-kit-sm text-kit-fg\">\n {t}\n {readOnly ? null : (\n <button type=\"button\" aria-label={`Remove ${t}`} onClick={() => onChange(list.filter((_, j) => j !== i))} className=\"flex rounded-kit-md p-0.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconX className=\"size-3\" stroke={1.5} />\n </button>\n )}\n </span>\n ))}\n {readOnly ? null : (\n <input\n ref={inputRef}\n id={id}\n value={draft}\n disabled={full}\n onChange={(e) => {\n setDraft(e.target.value);\n if (refusal) setRefusal(null);\n }}\n onBlur={() => {\n add();\n onBlur?.();\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \",\") {\n e.preventDefault();\n add();\n } else if (e.key === \"Backspace\" && !draft && list.length) onChange(list.slice(0, -1));\n }}\n placeholder={full ? \"\" : list.length ? \"Add…\" : field.placeholder ?? (shortcutHintsOn() ? \"Type and press Enter\" : \"Add…\")}\n className=\"h-6 min-w-20 flex-1 bg-transparent px-1.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n )}\n </div>\n {refusal && !readOnly ? (\n <span id={reasonId} role=\"status\" aria-live=\"polite\" className=\"px-0.5 text-kit-xs text-kit-fg-3\">\n {refusal}\n </span>\n ) : null}\n {full && !readOnly ? <LimitLine max={max!} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAM,OAAO,MAAgB,OAAO,MAAM,WAAW,IAAI,KAAK,OAAO,KAAK,OAAO,CAAC;AAClF,IAAM,QAAQ,MAAiB,KAAK,CAAC;;;;;;AAOrC,SAAgB,YAAY,SAAmB,WAAoB,OAAmE;CACpI,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;CAClC,MAAM,OAAO,QAAQ,KAAK,MAAM,WAAW,EAAE,IAAI,CAAC;CAElD,IAAI,SAAS,KAAK,OAAO,MAAM,MAAM,KAAA,CAAS,GAAG,OAAO,KAAK,KAAK,MAAM,oBAAC,OAAD;EAAO,MAAM;EAAI,WAAW,GAAG,QAAQ,SAAS;CAAI,CAAA,CAAC;CAC7H,MAAM,MAAM,QAAQ,OAAO,MAAM,QAAQ,EAAE,IAAI,MAAM,KAAA,CAAS;CAC9D,OAAO,QAAQ,KAAK,MAAO,MAAM,oBAAC,SAAD;EAAS,MAAM,EAAE;EAAiB;CAAY,CAAA,IAAI,KAAA,CAAU;AAC/F;;AAGA,SAAS,UAAU,EAAE,OAAwB;CAC3C,OAAO,qBAAC,QAAD;EAAM,WAAU;EAAhB,UAAA;GAAmD;GAAqB;GAAI;EAAkC;;AACvH;;;;;AAMA,SAAS,aAAa,QAAkB,SAAiB,Q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