@bettercms-ai/kit 4.0.0 → 4.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/adapters/lossy.d.ts +4 -0
  2. package/dist/adapters/lossy.js +4 -0
  3. package/dist/adapters/lossy.js.map +1 -1
  4. package/dist/adapters/prod-types.d.ts +4 -0
  5. package/dist/adapters/prod-types.js +4 -1
  6. package/dist/adapters/prod-types.js.map +1 -1
  7. package/dist/adapters/schema.js +7 -0
  8. package/dist/adapters/schema.js.map +1 -1
  9. package/dist/context.d.ts +91 -0
  10. package/dist/context.js +58 -1
  11. package/dist/context.js.map +1 -1
  12. package/dist/controls/choice.d.ts +1 -1
  13. package/dist/controls/choice.js +21 -2
  14. package/dist/controls/choice.js.map +1 -1
  15. package/dist/controls/index.d.ts +1 -0
  16. package/dist/controls/index.js +3 -2
  17. package/dist/controls/index.js.map +1 -1
  18. package/dist/controls/link.d.ts +23 -2
  19. package/dist/controls/link.js +456 -4
  20. package/dist/controls/link.js.map +1 -1
  21. package/dist/controls/media-v16.d.ts +27 -0
  22. package/dist/controls/media-v16.js +261 -0
  23. package/dist/controls/media-v16.js.map +1 -0
  24. package/dist/controls/media.js +63 -1
  25. package/dist/controls/media.js.map +1 -1
  26. package/dist/controls/reference-services.d.ts +8 -0
  27. package/dist/controls/reference.js +78 -2
  28. package/dist/controls/reference.js.map +1 -1
  29. package/dist/controls/rich-text/ai-runs.d.ts +13 -0
  30. package/dist/controls/rich-text/ai-runs.js +71 -0
  31. package/dist/controls/rich-text/ai-runs.js.map +1 -0
  32. package/dist/controls/rich-text/block-tool.d.ts +31 -0
  33. package/dist/controls/rich-text/block-tool.js +62 -0
  34. package/dist/controls/rich-text/block-tool.js.map +1 -0
  35. package/dist/controls/rich-text/blocks.d.ts +6 -1
  36. package/dist/controls/rich-text/blocks.js +406 -24
  37. package/dist/controls/rich-text/blocks.js.map +1 -1
  38. package/dist/controls/rich-text/catalog.d.ts +45 -7
  39. package/dist/controls/rich-text/catalog.js +507 -37
  40. package/dist/controls/rich-text/catalog.js.map +1 -1
  41. package/dist/controls/rich-text/code-head.d.ts +30 -0
  42. package/dist/controls/rich-text/code-head.js +230 -0
  43. package/dist/controls/rich-text/code-head.js.map +1 -0
  44. package/dist/controls/rich-text/codec.d.ts +1 -1
  45. package/dist/controls/rich-text/codec.js +4 -1
  46. package/dist/controls/rich-text/codec.js.map +1 -1
  47. package/dist/controls/rich-text/dom.d.ts +27 -0
  48. package/dist/controls/rich-text/dom.js +77 -7
  49. package/dist/controls/rich-text/dom.js.map +1 -1
  50. package/dist/controls/rich-text/editor.js +243 -55
  51. package/dist/controls/rich-text/editor.js.map +1 -1
  52. package/dist/controls/rich-text/ops.js +1 -0
  53. package/dist/controls/rich-text/ops.js.map +1 -1
  54. package/dist/controls/rich-text/rewriteSelection.d.ts +25 -0
  55. package/dist/controls/rich-text/rewriteSelection.js +28 -0
  56. package/dist/controls/rich-text/rewriteSelection.js.map +1 -0
  57. package/dist/controls/rich-text/slash-preview.d.ts +8 -0
  58. package/dist/controls/rich-text/slash-preview.js +300 -0
  59. package/dist/controls/rich-text/slash-preview.js.map +1 -0
  60. package/dist/controls/rich-text/table-grid.d.ts +22 -0
  61. package/dist/controls/rich-text/table-grid.js +1057 -0
  62. package/dist/controls/rich-text/table-grid.js.map +1 -0
  63. package/dist/controls/rich-text/toolbar.js +61 -18
  64. package/dist/controls/rich-text/toolbar.js.map +1 -1
  65. package/dist/controls/text.d.ts +6 -0
  66. package/dist/controls/text.js +95 -5
  67. package/dist/controls/text.js.map +1 -1
  68. package/dist/core/facets.d.ts +1 -0
  69. package/dist/core/facets.js +1 -0
  70. package/dist/core/facets.js.map +1 -1
  71. package/dist/engine/array.d.ts +7 -0
  72. package/dist/engine/array.js +164 -45
  73. package/dist/engine/array.js.map +1 -1
  74. package/dist/engine/field-shell.d.ts +12 -0
  75. package/dist/engine/field-shell.js +222 -64
  76. package/dist/engine/field-shell.js.map +1 -1
  77. package/dist/engine/frame.js +42 -4
  78. package/dist/engine/frame.js.map +1 -1
  79. package/dist/engine/grouping.d.ts +71 -10
  80. package/dist/engine/grouping.js +227 -29
  81. package/dist/engine/grouping.js.map +1 -1
  82. package/dist/engine/item-list.js +2 -2
  83. package/dist/engine/item-list.js.map +1 -1
  84. package/dist/engine/kit-field.js +38 -4
  85. package/dist/engine/kit-field.js.map +1 -1
  86. package/dist/engine/schema-form.d.ts +2 -0
  87. package/dist/engine/schema-form.js +9 -2
  88. package/dist/engine/schema-form.js.map +1 -1
  89. package/dist/index.d.ts +1 -1
  90. package/dist/index.js +13 -6
  91. package/dist/index.js.map +1 -1
  92. package/dist/kit.css +59 -0
  93. package/dist/lib/reduced-motion.d.ts +1 -0
  94. package/dist/lib/reduced-motion.js +19 -0
  95. package/dist/lib/reduced-motion.js.map +1 -0
  96. package/dist/schema/table.d.ts +2 -1
  97. package/dist/schema/table.js +5 -0
  98. package/dist/schema/table.js.map +1 -1
  99. package/dist/schema/types.d.ts +6 -0
  100. package/dist/schema/types.js.map +1 -1
  101. package/dist/styles.css +1 -1
  102. package/dist/theme.css +215 -0
  103. package/dist/tokens.css +274 -0
  104. package/dist/ui/block-icon-picker.d.ts +38 -0
  105. package/dist/ui/block-icon-picker.js +141 -0
  106. package/dist/ui/block-icon-picker.js.map +1 -0
  107. package/dist/ui/button.js +1 -0
  108. package/dist/ui/button.js.map +1 -1
  109. package/dist/ui/code-language-menu.d.ts +24 -0
  110. package/dist/ui/code-language-menu.js +123 -0
  111. package/dist/ui/code-language-menu.js.map +1 -0
  112. package/dist/ui/content-fields.d.ts +47 -0
  113. package/dist/ui/content-fields.js +279 -0
  114. package/dist/ui/content-fields.js.map +1 -0
  115. package/dist/ui/controls.js +3 -2
  116. package/dist/ui/controls.js.map +1 -1
  117. package/dist/ui/floating-panel.js +3 -2
  118. package/dist/ui/floating-panel.js.map +1 -1
  119. package/dist/ui/foundations.d.ts +118 -0
  120. package/dist/ui/foundations.js +565 -0
  121. package/dist/ui/foundations.js.map +1 -0
  122. package/dist/ui/index.d.ts +6 -0
  123. package/dist/ui/index.js +7 -1
  124. package/dist/ui/inspector.d.ts +412 -0
  125. package/dist/ui/inspector.js +1218 -0
  126. package/dist/ui/inspector.js.map +1 -0
  127. package/dist/ui/overlay.d.ts +7 -2
  128. package/dist/ui/overlay.js +55 -20
  129. package/dist/ui/overlay.js.map +1 -1
  130. package/dist/ui/shortcut-hint.js +1 -1
  131. package/dist/ui/shortcut-hint.js.map +1 -1
  132. package/dist/ui/tab.js +3 -2
  133. package/dist/ui/tab.js.map +1 -1
  134. package/dist/ui/toast.d.ts +5 -3
  135. package/dist/ui/toast.js +83 -11
  136. package/dist/ui/toast.js.map +1 -1
  137. package/dist/ui/tooltip-card.d.ts +45 -0
  138. package/dist/ui/tooltip-card.js +135 -0
  139. package/dist/ui/tooltip-card.js.map +1 -0
  140. package/package.json +1 -1
@@ -1,9 +1,11 @@
1
1
  import { pathKey, same } from "../lib/path.js";
2
- import { isTextual, plainText } from "../lib/schema.js";
2
+ import { emptyFor, initialFor, isEmptyValue, isTextual, plainText } from "../lib/schema.js";
3
3
  import { cn } from "../lib/cn.js";
4
- import { AI_PRESETS, FieldHeaderSlot, KitSectionTitle, seesDevSurfaces, useForm, useKitEnv, useKitServices } from "../context.js";
4
+ import { AI_PRESETS, FieldHeaderSlot, KitSectionTitle, seesDevSurfaces, useForm, useKitEnv, useKitFocusField, useKitLook, useKitServices } from "../context.js";
5
5
  import { Button, Sparkle } from "../ui/button.js";
6
+ import { InfoTooltip } from "../ui/tooltip-card.js";
6
7
  import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverAnchor, PopoverContent, Tooltip } from "../ui/overlay.js";
8
+ import { FieldCounter, FieldSweep, FocusDot, counterState, overLimitText, useOverLimit } from "../ui/inspector.js";
7
9
  import { RowChrome } from "./bits.js";
8
10
  import { Avatar, avatarRingSpread } from "../ui/display.js";
9
11
  import { presenceColor } from "../ui/presence.js";
@@ -12,7 +14,7 @@ import { resolveHelp } from "../schema/help.js";
12
14
  import { textLength } from "../lib/validate.js";
13
15
  import * as React from "react";
14
16
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
- import { IconAlertCircle, IconAlertTriangle, IconArrowBackUp, IconBraces, IconClipboard, IconCopy, IconDots, IconHistory, IconInfoCircle, IconLock, IconMessage, IconMessagePlus, IconRefresh, IconRotate, IconWorld } from "@tabler/icons-react";
17
+ import { IconAlertCircle, IconAlertTriangle, IconArrowBackUp, IconBraces, IconClipboard, IconCopy, IconDots, IconEraser, IconHistory, IconInfoCircle, IconLink, IconLock, IconMessage, IconMessagePlus, IconRefresh, IconRestore, IconRotate, IconWorld } from "@tabler/icons-react";
16
18
  import { AnimatePresence, motion } from "framer-motion";
17
19
  import { createPortal } from "react-dom";
18
20
  //#region src/engine/field-shell.tsx
@@ -121,6 +123,25 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
121
123
  setCommentsOpen(false);
122
124
  setCommentSel(null);
123
125
  };
126
+ const openRef = React.useRef(() => {});
127
+ openRef.current = (sel) => {
128
+ if (!canComment) return;
129
+ if (env.onComment) return env.onComment(path, field);
130
+ setCommentSel(sel ?? null);
131
+ setCommentArea(fieldPopoverCollision(document.getElementById(id)?.closest("[data-field-key]") ?? null));
132
+ setCommentsOpen(true);
133
+ };
134
+ React.useEffect(() => {
135
+ const box = document.getElementById(id)?.closest("[data-field-key]");
136
+ if (!box) return;
137
+ const on = (e) => {
138
+ e.stopPropagation();
139
+ openRef.current(e.detail);
140
+ };
141
+ box.addEventListener(KIT_OPEN_FIELD_COMMENTS, on);
142
+ return () => box.removeEventListener(KIT_OPEN_FIELD_COMMENTS, on);
143
+ }, [id]);
144
+ const v16 = useKitLook() === "v16";
124
145
  const openCount = env.comments[key] ?? 0;
125
146
  const useStoreCount = env.onComment ? void 0 : services.useFieldCommentCount;
126
147
  const changed = !!form?.hasPublished && !same(value, form.publishedAt(path));
@@ -135,7 +156,13 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
135
156
  const limit = field.validation?.max ?? field.validation?.recommendedMax;
136
157
  const len = textLength(value);
137
158
  const near = !!limit && len >= limit * .8;
138
- const counter = limit && (field.type === "string" || field.type === "text" || field.type === "richtext") ? /* @__PURE__ */ jsxs("span", {
159
+ const counted = !!limit && (field.type === "string" || field.type === "text" || field.type === "richtext");
160
+ const overLimit = useOverLimit(v16 && counted && counterState(len, limit) === "over");
161
+ const counter = counted ? v16 ? counterState(len, limit) === "ok" ? null : /* @__PURE__ */ jsx(FieldCounter, {
162
+ value: len,
163
+ max: limit,
164
+ size: env.counterSize ?? 11
165
+ }) : /* @__PURE__ */ jsxs("span", {
139
166
  "data-slot": "field-counter",
140
167
  className: cn("tabular-nums text-kit-xs", !near && "hidden group-focus-within/field:inline", field.validation?.max && len > field.validation.max ? "text-kit-danger-fg" : field.validation?.recommendedMax && len > field.validation.recommendedMax ? "text-kit-warning-fg" : "text-kit-fg-3"),
141
168
  children: [
@@ -178,7 +205,14 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
178
205
  if (next) el.setAttribute("aria-describedby", next);
179
206
  else el.removeAttribute("aria-describedby");
180
207
  }, [id, describedBy]);
181
- const info = tip ? /* @__PURE__ */ jsx(Tooltip, {
208
+ const info = tip ? v16 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(InfoTooltip, {
209
+ title: field.title,
210
+ children: tip
211
+ }), /* @__PURE__ */ jsx("span", {
212
+ id: moreId,
213
+ className: "sr-only",
214
+ children: tip
215
+ })] }) : /* @__PURE__ */ jsx(Tooltip, {
182
216
  content: /* @__PURE__ */ jsx("span", {
183
217
  className: "block max-w-[260px] whitespace-normal font-normal leading-4",
184
218
  children: tip
@@ -204,8 +238,8 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
204
238
  children: field.title
205
239
  }), field.validation?.required ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
206
240
  "aria-hidden": true,
207
- className: "text-kit-fg-2",
208
- children: "*"
241
+ className: v16 ? "whitespace-pre" : "text-kit-fg-2",
242
+ children: v16 ? " *" : "*"
209
243
  }), /* @__PURE__ */ jsx("span", {
210
244
  className: "sr-only",
211
245
  children: "(required)"
@@ -288,11 +322,31 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
288
322
  })
289
323
  })
290
324
  }) : null,
325
+ v16 && !bare ? /* @__PURE__ */ jsx(Tooltip, {
326
+ content: "Copy link to field",
327
+ children: /* @__PURE__ */ jsx("button", {
328
+ type: "button",
329
+ "data-field-reveal": "",
330
+ "aria-label": `Copy link to ${field.title}`,
331
+ className: "-my-0.5 size-5 items-center justify-center rounded-[4px] text-kit-fg-3 hover:bg-kit-insp-track hover:text-kit-fg focus-visible:outline-2 focus-visible:outline-offset-1 [&_svg]:size-4",
332
+ onClick: () => {
333
+ const href = `${window.location.href.split("#")[0]}#${encodeURIComponent(key)}`;
334
+ const w = navigator.clipboard?.writeText(href);
335
+ if (!w) return services.toast?.("Copy is not available in this browser");
336
+ w.then(() => services.toast?.("Link to field copied"), () => services.toast?.("The browser refused to copy the link"));
337
+ },
338
+ children: /* @__PURE__ */ jsx(IconLink, {
339
+ stroke: 1.5,
340
+ "aria-hidden": true
341
+ })
342
+ })
343
+ }) : null,
291
344
  canComment ? /* @__PURE__ */ jsx(CommentButton, {
292
345
  count: openCount,
293
346
  useCount: useStoreCount ? () => useStoreCount(env.docId, key) : void 0,
294
347
  label: field.title,
295
348
  open: commentsOpen,
349
+ onThreads: !env.onComment && services.onOpenFieldThreads ? () => services.onOpenFieldThreads(env.docId, key) : void 0,
296
350
  onOpen: (el) => {
297
351
  if (env.onComment) return env.onComment(path, field);
298
352
  setCommentSel(null);
@@ -312,7 +366,8 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
312
366
  })
313
367
  ] });
314
368
  const control = /* @__PURE__ */ jsx("div", {
315
- className: cn("relative", editor && "[&_.border-kit-field-border]:border-[var(--peer)]"),
369
+ className: cn("relative", editor && "[&_.border-kit-field-border]:border-[var(--peer)]", overLimit.className),
370
+ onAnimationEnd: overLimit.onAnimationEnd,
316
371
  style: editor ? { "--peer": editor.color ?? presenceColor(editor.id ?? editor.name) } : void 0,
317
372
  children
318
373
  });
@@ -342,7 +397,7 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
342
397
  "aria-hidden": true
343
398
  }), /* @__PURE__ */ jsxs("span", {
344
399
  className: "min-w-0",
345
- children: [issue.message, issue.fix && !readOnly ? /* @__PURE__ */ jsxs(Fragment, { children: [" ", /* @__PURE__ */ jsx("button", {
400
+ children: [v16 && issue.kind === "rule" && limit && len > limit && /^Keep it under \d+ characters/.test(issue.message) ? overLimitText(limit) : issue.message, issue.fix && !readOnly ? /* @__PURE__ */ jsxs(Fragment, { children: [" ", /* @__PURE__ */ jsx("button", {
346
401
  type: "button",
347
402
  onClick: issue.fix.apply,
348
403
  className: "font-medium text-kit-fg underline-offset-2 hover:underline",
@@ -355,12 +410,14 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
355
410
  children: meta
356
411
  }) : null]
357
412
  }) : null;
358
- const labelEl = /* @__PURE__ */ jsx("label", {
413
+ const focus = useKitFocusField();
414
+ const focused = !!focus && focus.key === key;
415
+ const labelEl = /* @__PURE__ */ jsxs("label", {
359
416
  htmlFor: id,
360
417
  id: `${id}-label`,
361
418
  className: "flex min-w-0 items-center gap-1 text-kit-sm font-medium text-kit-fg-2 transition-colors group-focus-within/field:text-kit-fg",
362
419
  title: longTitle,
363
- children: label
420
+ children: [label, focused ? /* @__PURE__ */ jsx(FocusDot, {}) : null]
364
421
  });
365
422
  const body = layout === "row" ? /* @__PURE__ */ jsxs("div", {
366
423
  className: cn("group/field relative flex min-w-0 flex-col gap-1.5", className),
@@ -468,13 +525,15 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
468
525
  message
469
526
  ]
470
527
  }) : /* @__PURE__ */ jsxs("div", {
471
- className: cn("group/field relative flex min-w-0 flex-col gap-1.5", className),
528
+ className: cn("group/field relative flex min-w-0 flex-col gap-1.5", focused && "isolate", className),
472
529
  "data-field-key": key,
473
530
  "data-field": path.length === 1 ? key : void 0,
474
531
  "data-slot": "kit-field",
475
532
  "data-inherited": inh && !overridden ? "" : void 0,
476
533
  "data-overridden": overridden ? "" : void 0,
534
+ "data-cur": focused ? "" : void 0,
477
535
  children: [
536
+ focused && focus?.flash != null ? /* @__PURE__ */ jsx(FieldSweep, {}, String(focus.flash)) : null,
478
537
  bar,
479
538
  repeatsSection ? /* @__PURE__ */ jsx("label", {
480
539
  htmlFor: id,
@@ -520,6 +579,7 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
520
579
  message
521
580
  ]
522
581
  });
582
+ const commentPop = commentsOpen && services.fieldCommentsPopover ? services.fieldCommentsPopover({ selection: !!commentSel }) : null;
523
583
  return /* @__PURE__ */ jsx(FieldCommentRequest.Provider, {
524
584
  value: requestComment,
525
585
  children: /* @__PURE__ */ jsxs(Popover, {
@@ -539,10 +599,11 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
539
599
  children: body
540
600
  }), commentsOpen && InPlaceComments ? /* @__PURE__ */ jsx(PopoverContent, {
541
601
  align: "start",
542
- sideOffset: 8,
602
+ sideOffset: commentPop?.sideOffset ?? 8,
603
+ alignOffset: commentPop?.alignOffset,
543
604
  ...commentArea,
544
605
  initialFocus: false,
545
- className: "w-[clamp(280px,var(--anchor-width),420px)] p-0",
606
+ className: cn("p-0", commentPop?.className ?? "w-[clamp(280px,var(--anchor-width),420px)]"),
546
607
  children: /* @__PURE__ */ jsx(InPlaceComments, {
547
608
  docId: env.docId,
548
609
  fieldKey: key,
@@ -572,6 +633,12 @@ function FieldShell({ field, path, id, value, onChange, readOnly, issue, action,
572
633
  })
573
634
  });
574
635
  }
636
+ /** REQ-2-6: the event a field's box answers by opening its comments (`detail`: the quoted selection, or none). */
637
+ var KIT_OPEN_FIELD_COMMENTS = "kit:open-field-comments";
638
+ /** Opens the comments of the field whose `[data-field-key]` box is `box` (a plain field's selected words as `selection`). */
639
+ function openFieldComments(box, selection) {
640
+ box.dispatchEvent(new CustomEvent(KIT_OPEN_FIELD_COMMENTS, { detail: selection }));
641
+ }
575
642
  /** V2 features/comments fieldPopoverCollision: inside a scrolling panel, collide with that panel below its sticky header. */
576
643
  function fieldPopoverCollision(anchor) {
577
644
  let area = anchor?.parentElement ?? null;
@@ -602,14 +669,16 @@ function StoreCommentButton({ useCount, ...props }) {
602
669
  count: useCount()
603
670
  });
604
671
  }
605
- function CountedCommentButton({ count, label, open, onOpen }) {
672
+ function CountedCommentButton({ count, label, open, onOpen, onThreads }) {
673
+ const v16 = useKitLook() === "v16";
674
+ const n = `${count} comment${count === 1 ? "" : "s"}`;
606
675
  if (count > 0) return /* @__PURE__ */ jsx(Tooltip, {
607
- content: `${count} open comment${count === 1 ? "" : "s"} on ${label}`,
676
+ content: v16 ? `${n} · open thread` : `${count} open comment${count === 1 ? "" : "s"} on ${label}`,
608
677
  children: /* @__PURE__ */ jsxs("button", {
609
678
  type: "button",
610
- onClick: (e) => onOpen(e.currentTarget),
679
+ onClick: (e) => onThreads ? onThreads() : onOpen(e.currentTarget),
611
680
  "data-state": open ? "open" : "closed",
612
- "aria-label": `${count} open comments on ${label}`,
681
+ "aria-label": v16 ? `${n} on ${label} · open thread` : `${count} open comments on ${label}`,
613
682
  className: "-my-0.5 inline-flex h-5 items-center gap-0.5 rounded-kit-md px-1 text-kit-2xs font-medium text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[state=open]:bg-kit-hover data-[state=open]:text-kit-fg",
614
683
  children: [/* @__PURE__ */ jsx(IconMessage, {
615
684
  className: "size-3.5",
@@ -622,12 +691,12 @@ function CountedCommentButton({ count, label, open, onOpen }) {
622
691
  })
623
692
  });
624
693
  return /* @__PURE__ */ jsx(Tooltip, {
625
- content: "Add comment",
694
+ content: v16 ? "Comment" : "Add comment",
626
695
  children: /* @__PURE__ */ jsx("button", {
627
696
  type: "button",
628
697
  onClick: (e) => onOpen(e.currentTarget),
629
698
  "data-state": open ? "open" : "closed",
630
- "aria-label": `Add comment to ${label}`,
699
+ "aria-label": v16 ? `Comment on ${label}` : `Add comment to ${label}`,
631
700
  "data-field-reveal": "",
632
701
  className: cn("-my-0.5 size-6 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg"),
633
702
  children: /* @__PURE__ */ jsx(IconMessagePlus, {
@@ -704,6 +773,20 @@ function PeerStack({ peers, size = 16 }) {
704
773
  }, "peers") : null
705
774
  });
706
775
  }
776
+ /** The field ⋯ menu alone, for a field drawn without its shell (a top-level Object group's header, look v16). */
777
+ function FieldActionsMenu({ field, path, value, onChange, readOnly }) {
778
+ const form = useForm();
779
+ const changed = !!form?.hasPublished && !same(value, form.publishedAt(path));
780
+ return /* @__PURE__ */ jsx(FieldMenu, {
781
+ field,
782
+ path,
783
+ value,
784
+ onChange,
785
+ readOnly: !!readOnly,
786
+ changed,
787
+ onAi: () => {}
788
+ });
789
+ }
707
790
  function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
708
791
  const form = useForm();
709
792
  const env = useKitEnv();
@@ -714,6 +797,54 @@ function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
714
797
  const prose = field.type === "string" || field.type === "text" || field.type === "richtext" && !!richText;
715
798
  const editable = !readOnly;
716
799
  const dev = seesDevSurfaces(env);
800
+ const v16 = useKitLook() === "v16";
801
+ const copyField = () => {
802
+ const html = richTextHtml(richText, field, path, value);
803
+ clip = {
804
+ type: field.type,
805
+ value: structuredCloneish(value),
806
+ label: field.title,
807
+ ...html !== void 0 ? { html } : {}
808
+ };
809
+ const text = textual ? plainText(value) || "" : typeof value === "string" ? value : JSON.stringify(value ?? null, null, 2);
810
+ navigator.clipboard?.writeText(text).catch(() => {});
811
+ toast?.success(`${field.title} copied`);
812
+ };
813
+ const copyApi = () => {
814
+ navigator.clipboard?.writeText(api).catch(() => {});
815
+ toast?.success(`Copied ${api}`);
816
+ };
817
+ const resetPublished = editable && form?.hasPublished && changed ? /* @__PURE__ */ jsx(MenuItem, {
818
+ icon: /* @__PURE__ */ jsx(IconRotate, { stroke: 1.5 }),
819
+ onClick: () => {
820
+ const prev = value;
821
+ onChange(form.publishedAt(path));
822
+ toast?.(`${field.title} reset to published`, {
823
+ action: {
824
+ label: "Undo",
825
+ onClick: () => onChange(prev)
826
+ },
827
+ duration: 1e4
828
+ });
829
+ },
830
+ children: "Reset to published"
831
+ }) : null;
832
+ const aiRows = editable && prose && aiRewrite ? /* @__PURE__ */ jsxs(Fragment, { children: [
833
+ /* @__PURE__ */ jsx(MenuSeparator, {}),
834
+ form?.aiKeys.has(key) ? /* @__PURE__ */ jsx(MenuItem, {
835
+ icon: /* @__PURE__ */ jsx(IconArrowBackUp, { stroke: 1.5 }),
836
+ onClick: () => {
837
+ form.undo(key);
838
+ form.markAi(key, false);
839
+ },
840
+ children: "Undo AI change"
841
+ }) : null,
842
+ /* @__PURE__ */ jsx(MenuItem, {
843
+ icon: /* @__PURE__ */ jsx(Sparkle, { size: 16 }),
844
+ onClick: () => window.setTimeout(onAi, 0),
845
+ children: "Rewrite with AI"
846
+ })
847
+ ] }) : null;
717
848
  return /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(Tooltip, {
718
849
  content: "Field actions",
719
850
  children: /* @__PURE__ */ jsx(MenuTrigger, {
@@ -726,25 +857,26 @@ function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
726
857
  "aria-hidden": true
727
858
  })
728
859
  })
729
- }), /* @__PURE__ */ jsxs(MenuContent, {
860
+ }), /* @__PURE__ */ jsx(MenuContent, {
730
861
  align: "end",
731
862
  className: "w-60",
732
- children: [
863
+ children: v16 ? /* @__PURE__ */ jsxs(Fragment, { children: [
733
864
  /* @__PURE__ */ jsx(MenuItem, {
734
865
  icon: /* @__PURE__ */ jsx(IconCopy, { stroke: 1.5 }),
735
- onClick: () => {
736
- const html = richTextHtml(richText, field, path, value);
737
- clip = {
738
- type: field.type,
739
- value: structuredCloneish(value),
740
- label: field.title,
741
- ...html !== void 0 ? { html } : {}
742
- };
743
- const text = textual ? plainText(value) || "" : typeof value === "string" ? value : JSON.stringify(value ?? null, null, 2);
744
- navigator.clipboard?.writeText(text).catch(() => {});
745
- toast?.success(`${field.title} copied`);
746
- },
747
- children: "Copy value"
866
+ shortcut: "⌘C",
867
+ onClick: copyField,
868
+ children: "Copy field"
869
+ }),
870
+ /* @__PURE__ */ jsx(MenuItem, {
871
+ icon: /* @__PURE__ */ jsx(IconBraces, { stroke: 1.5 }),
872
+ onClick: copyApi,
873
+ children: /* @__PURE__ */ jsxs("span", {
874
+ className: "flex w-full items-center justify-between gap-3",
875
+ children: ["Copy API name", /* @__PURE__ */ jsx("span", {
876
+ className: "truncate text-[12px] leading-4 text-kit-insp-faint",
877
+ children: api.length > 22 ? `…${api.slice(-20)}` : api
878
+ })]
879
+ })
748
880
  }),
749
881
  editable ? /* @__PURE__ */ jsx(PasteItem, {
750
882
  field,
@@ -752,12 +884,36 @@ function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
752
884
  value,
753
885
  onChange
754
886
  }) : null,
755
- editable && form?.hasPublished && changed ? /* @__PURE__ */ jsx(MenuItem, {
756
- icon: /* @__PURE__ */ jsx(IconRotate, { stroke: 1.5 }),
887
+ editable || env.onFieldHistory ? /* @__PURE__ */ jsx(MenuSeparator, {}) : null,
888
+ editable ? /* @__PURE__ */ jsx(MenuItem, {
889
+ icon: /* @__PURE__ */ jsx(IconRestore, { stroke: 1.5 }),
890
+ onClick: () => {
891
+ const prev = value;
892
+ onChange(initialFor(field));
893
+ toast?.(`${field.title} reset to default`, {
894
+ action: {
895
+ label: "Undo",
896
+ onClick: () => onChange(prev)
897
+ },
898
+ duration: 1e4
899
+ });
900
+ },
901
+ children: "Reset to default"
902
+ }) : null,
903
+ resetPublished,
904
+ env.onFieldHistory ? /* @__PURE__ */ jsx(MenuItem, {
905
+ icon: /* @__PURE__ */ jsx(IconHistory, { stroke: 1.5 }),
906
+ onClick: () => env.onFieldHistory(path, field),
907
+ children: "View field history"
908
+ }) : null,
909
+ editable ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuSeparator, {}), /* @__PURE__ */ jsx(MenuItem, {
910
+ danger: true,
911
+ icon: /* @__PURE__ */ jsx(IconEraser, { stroke: 1.5 }),
912
+ disabled: isEmptyValue(value),
757
913
  onClick: () => {
758
914
  const prev = value;
759
- onChange(form.publishedAt(path));
760
- toast?.(`${field.title} reset to published`, {
915
+ onChange(emptyFor(field));
916
+ toast?.(`${field.title} cleared`, {
761
917
  action: {
762
918
  label: "Undo",
763
919
  onClick: () => onChange(prev)
@@ -765,8 +921,27 @@ function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
765
921
  duration: 1e4
766
922
  });
767
923
  },
768
- children: "Reset to published"
924
+ children: "Clear field"
925
+ })] }) : null,
926
+ FieldMenuExtras ? /* @__PURE__ */ jsx(FieldMenuExtras, {
927
+ field,
928
+ path,
929
+ readOnly
769
930
  }) : null,
931
+ aiRows
932
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
933
+ /* @__PURE__ */ jsx(MenuItem, {
934
+ icon: /* @__PURE__ */ jsx(IconCopy, { stroke: 1.5 }),
935
+ onClick: copyField,
936
+ children: "Copy value"
937
+ }),
938
+ editable ? /* @__PURE__ */ jsx(PasteItem, {
939
+ field,
940
+ path,
941
+ value,
942
+ onChange
943
+ }) : null,
944
+ resetPublished,
770
945
  env.onFieldHistory ? /* @__PURE__ */ jsx(MenuItem, {
771
946
  icon: /* @__PURE__ */ jsx(IconHistory, { stroke: 1.5 }),
772
947
  onClick: () => env.onFieldHistory(path, field),
@@ -777,29 +952,11 @@ function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
777
952
  path,
778
953
  readOnly
779
954
  }) : null,
780
- editable && prose && aiRewrite ? /* @__PURE__ */ jsxs(Fragment, { children: [
781
- /* @__PURE__ */ jsx(MenuSeparator, {}),
782
- form?.aiKeys.has(key) ? /* @__PURE__ */ jsx(MenuItem, {
783
- icon: /* @__PURE__ */ jsx(IconArrowBackUp, { stroke: 1.5 }),
784
- onClick: () => {
785
- form.undo(key);
786
- form.markAi(key, false);
787
- },
788
- children: "Undo AI change"
789
- }) : null,
790
- /* @__PURE__ */ jsx(MenuItem, {
791
- icon: /* @__PURE__ */ jsx(Sparkle, { size: 16 }),
792
- onClick: () => window.setTimeout(onAi, 0),
793
- children: "Rewrite with AI"
794
- })
795
- ] }) : null,
955
+ aiRows,
796
956
  dev ? /* @__PURE__ */ jsx(MenuSeparator, {}) : null,
797
957
  dev ? /* @__PURE__ */ jsx(MenuItem, {
798
958
  icon: /* @__PURE__ */ jsx(IconBraces, { stroke: 1.5 }),
799
- onClick: () => {
800
- navigator.clipboard?.writeText(api).catch(() => {});
801
- toast?.success(`Copied ${api}`);
802
- },
959
+ onClick: copyApi,
803
960
  children: /* @__PURE__ */ jsxs("span", {
804
961
  className: "flex w-full items-center justify-between gap-3",
805
962
  children: ["Copy API name", /* @__PURE__ */ jsx("span", {
@@ -808,16 +965,17 @@ function FieldMenu({ field, path, value, onChange, readOnly, changed, onAi }) {
808
965
  })]
809
966
  })
810
967
  }) : null
811
- ]
968
+ ] })
812
969
  })] });
813
970
  }
814
971
  /** Reads the shared clipboard when the menu opens (it mounts with the popup), so a copy in another field is seen. */
815
972
  function PasteItem({ field, path, value, onChange }) {
816
973
  const { toast, richText } = useKitServices();
974
+ const v16 = useKitLook() === "v16";
817
975
  const textual = isTextual(field.type);
818
976
  const needsCodec = !!clip && field.type === "richtext" && clip.type !== "richtext" && !richText;
819
977
  const pasteOk = clip && !needsCodec && (clip.type === field.type || textual && isTextual(clip.type));
820
- const pasteReason = !clip ? "Copy a value from a field first." : needsCodec ? "This rich text field takes a copied rich text value only." : pasteOk ? null : `Clipboard holds ${kindOf(clip.type)}. This field takes ${kindOf(field.type)}.`;
978
+ const pasteReason = !clip ? v16 ? "Copy a field first" : "Copy a value from a field first." : needsCodec ? "This rich text field takes a copied rich text value only." : pasteOk ? null : `Clipboard holds ${kindOf(clip.type)}. This field takes ${kindOf(field.type)}.`;
821
979
  return /* @__PURE__ */ jsx(MenuItem, {
822
980
  icon: /* @__PURE__ */ jsx(IconClipboard, { stroke: 1.5 }),
823
981
  disabled: !pasteOk,
@@ -845,7 +1003,7 @@ function PasteItem({ field, path, value, onChange }) {
845
1003
  },
846
1004
  children: /* @__PURE__ */ jsxs("span", {
847
1005
  className: "flex flex-col",
848
- children: ["Paste value", pasteReason ? /* @__PURE__ */ jsx("span", {
1006
+ children: [v16 ? "Paste field" : "Paste value", pasteReason ? /* @__PURE__ */ jsx("span", {
849
1007
  className: "whitespace-normal text-kit-xs text-kit-fg-3",
850
1008
  children: pasteReason
851
1009
  }) : null]
@@ -1022,6 +1180,6 @@ function TypeOut({ text, speed = 14 }) {
1022
1180
  }) : null] });
1023
1181
  }
1024
1182
  //#endregion
1025
- export { FieldCommentRequest, FieldShell, LABEL_HINT_AT, PeerStack, apiName, resetFieldClipboard };
1183
+ export { FieldActionsMenu, FieldCommentRequest, FieldShell, KIT_OPEN_FIELD_COMMENTS, LABEL_HINT_AT, PeerStack, apiName, openFieldComments, resetFieldClipboard };
1026
1184
 
1027
1185
  //# sourceMappingURL=field-shell.js.map