@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.
Files changed (135) 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 +81 -4
  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 +404 -24
  37. package/dist/controls/rich-text/blocks.js.map +1 -1
  38. package/dist/controls/rich-text/catalog.d.ts +21 -6
  39. package/dist/controls/rich-text/catalog.js +312 -23
  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 +3 -3
  45. package/dist/controls/rich-text/codec.js +3 -1
  46. package/dist/controls/rich-text/codec.js.map +1 -1
  47. package/dist/controls/rich-text/control.d.ts +1 -1
  48. package/dist/controls/rich-text/control.js +11 -29
  49. package/dist/controls/rich-text/control.js.map +1 -1
  50. package/dist/controls/rich-text/dom.d.ts +27 -0
  51. package/dist/controls/rich-text/dom.js +69 -4
  52. package/dist/controls/rich-text/dom.js.map +1 -1
  53. package/dist/controls/rich-text/editor.js +212 -50
  54. package/dist/controls/rich-text/editor.js.map +1 -1
  55. package/dist/controls/rich-text/ops.js +1 -0
  56. package/dist/controls/rich-text/ops.js.map +1 -1
  57. package/dist/controls/rich-text/slash-preview.d.ts +8 -0
  58. package/dist/controls/rich-text/slash-preview.js +287 -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 +1052 -0
  62. package/dist/controls/rich-text/table-grid.js.map +1 -0
  63. package/dist/controls/rich-text/toolbar.js +60 -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/expand.d.ts +1 -1
  75. package/dist/engine/expand.js +1 -1
  76. package/dist/engine/expand.js.map +1 -1
  77. package/dist/engine/field-shell.d.ts +12 -0
  78. package/dist/engine/field-shell.js +217 -63
  79. package/dist/engine/field-shell.js.map +1 -1
  80. package/dist/engine/frame.js +39 -2
  81. package/dist/engine/frame.js.map +1 -1
  82. package/dist/engine/grouping.d.ts +71 -10
  83. package/dist/engine/grouping.js +223 -26
  84. package/dist/engine/grouping.js.map +1 -1
  85. package/dist/engine/held.d.ts +2 -2
  86. package/dist/engine/held.js +2 -2
  87. package/dist/engine/held.js.map +1 -1
  88. package/dist/engine/kit-field.d.ts +0 -10
  89. package/dist/engine/kit-field.js +40 -72
  90. package/dist/engine/kit-field.js.map +1 -1
  91. package/dist/engine/schema-form.js +7 -2
  92. package/dist/engine/schema-form.js.map +1 -1
  93. package/dist/index.d.ts +1 -1
  94. package/dist/index.js +14 -7
  95. package/dist/index.js.map +1 -1
  96. package/dist/kit.css +85 -0
  97. package/dist/schema/table.d.ts +2 -1
  98. package/dist/schema/table.js +5 -0
  99. package/dist/schema/table.js.map +1 -1
  100. package/dist/schema/types.d.ts +6 -0
  101. package/dist/schema/types.js.map +1 -1
  102. package/dist/styles.css +1 -1
  103. package/dist/theme.css +115 -0
  104. package/dist/tokens.css +268 -0
  105. package/dist/ui/block-icon-picker.d.ts +38 -0
  106. package/dist/ui/block-icon-picker.js +141 -0
  107. package/dist/ui/block-icon-picker.js.map +1 -0
  108. package/dist/ui/button.js +1 -0
  109. package/dist/ui/button.js.map +1 -1
  110. package/dist/ui/code-language-menu.d.ts +24 -0
  111. package/dist/ui/code-language-menu.js +123 -0
  112. package/dist/ui/code-language-menu.js.map +1 -0
  113. package/dist/ui/content-fields.d.ts +47 -0
  114. package/dist/ui/content-fields.js +278 -0
  115. package/dist/ui/content-fields.js.map +1 -0
  116. package/dist/ui/foundations.d.ts +118 -0
  117. package/dist/ui/foundations.js +564 -0
  118. package/dist/ui/foundations.js.map +1 -0
  119. package/dist/ui/index.d.ts +6 -0
  120. package/dist/ui/index.js +7 -1
  121. package/dist/ui/inspector.d.ts +394 -0
  122. package/dist/ui/inspector.js +1173 -0
  123. package/dist/ui/inspector.js.map +1 -0
  124. package/dist/ui/overlay.d.ts +7 -2
  125. package/dist/ui/overlay.js +55 -20
  126. package/dist/ui/overlay.js.map +1 -1
  127. package/dist/ui/shortcut-hint.js +1 -1
  128. package/dist/ui/shortcut-hint.js.map +1 -1
  129. package/dist/ui/toast.d.ts +5 -3
  130. package/dist/ui/toast.js +83 -11
  131. package/dist/ui/toast.js.map +1 -1
  132. package/dist/ui/tooltip-card.d.ts +45 -0
  133. package/dist/ui/tooltip-card.js +135 -0
  134. package/dist/ui/tooltip-card.js.map +1 -0
  135. package/package.json +1 -1
@@ -1,8 +1,10 @@
1
1
  import { cn } from "../../lib/cn.js";
2
+ import { AI_COMMANDS, useKitLook } from "../../context.js";
2
3
  import { PopoverContent } from "../../ui/overlay.js";
4
+ import { SlashPreviewCard } from "./slash-preview.js";
3
5
  import * as React from "react";
4
6
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { IconArrowLeft, IconBlockquote, IconChevronRight, IconClick, IconCode, IconColumns2, IconComponents, IconFileText, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconInfoCircle, IconLayoutGrid, IconLayoutNavbarCollapse, IconList, IconListCheck, IconListDetails, IconListNumbers, IconListTree, IconNews, IconPhoto, IconPilcrow, IconQuote, IconSearch, IconSeparatorHorizontal, IconSuperscript, IconTable, IconTerminal2, IconUserCircle, IconVideo } from "@tabler/icons-react";
7
+ import { IconArrowLeft, IconBlockquote, IconChartBar, IconChevronLeft, IconChevronRight, IconClick, IconCode, IconColumns2, IconComponents, IconFileText, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconInfoCircle, IconLayoutGrid, IconLayoutNavbarCollapse, IconList, IconListCheck, IconListDetails, IconListNumbers, IconListTree, IconNews, IconPhoto, IconPilcrow, IconQuote, IconSearch, IconSeparatorHorizontal, IconSuperscript, IconTable, IconTerminal2, IconUserCircle, IconVideo } from "@tabler/icons-react";
6
8
  //#region src/controls/rich-text/catalog.tsx
7
9
  /**
8
10
  * RICH TEXT · the block catalogue shared by the toolbar Insert menu, the gutter "+" and the "/" slash menu (V2 HEAD
@@ -24,13 +26,28 @@ import { IconArrowLeft, IconBlockquote, IconChevronRight, IconClick, IconCode, I
24
26
  * "Components" group (V2: "Article" and "Page sections"), and no live preview flyout is drawn beside a row.
25
27
  */
26
28
  var i = (I) => /* @__PURE__ */ jsx(I, { stroke: 1.5 });
29
+ /** The Markdown the editor turns into each block as it is typed (ops.ts liveMarkdown, enterCodeFence): the row's key hint. */
30
+ var HINTS = {
31
+ h1: "#",
32
+ h2: "##",
33
+ h3: "###",
34
+ h4: "####",
35
+ h5: "#####",
36
+ h6: "######",
37
+ ul: "-",
38
+ ol: "1.",
39
+ quote: ">",
40
+ code: "```",
41
+ hr: "---"
42
+ };
27
43
  var rows = (list) => list.map(([id, label, description, icon, aliases]) => ({
28
44
  key: id,
29
45
  id,
30
46
  label,
31
47
  description,
32
48
  icon,
33
- aliases
49
+ aliases,
50
+ hint: HINTS[id]
34
51
  }));
35
52
  var TEXT = rows([
36
53
  [
@@ -284,6 +301,17 @@ var DATA = rows([[
284
301
  "comparison",
285
302
  "spreadsheet"
286
303
  ]
304
+ ], [
305
+ "stats",
306
+ "Stats",
307
+ "Big numbers in a row",
308
+ i(IconChartBar),
309
+ [
310
+ "numbers",
311
+ "metrics",
312
+ "kpi",
313
+ "figures"
314
+ ]
287
315
  ]]);
288
316
  /** Found by search, not listed: rare in a body (H1 is the page title). */
289
317
  var SEARCH_ONLY = rows([
@@ -357,7 +385,8 @@ var NEEDS = {
357
385
  footnote: "footnote",
358
386
  columns: "columns",
359
387
  related: "related",
360
- author: "author"
388
+ author: "author",
389
+ stats: "stats"
361
390
  };
362
391
  var MORE = {
363
392
  key: "more",
@@ -373,6 +402,77 @@ var BACK = {
373
402
  description: "",
374
403
  icon: i(IconArrowLeft)
375
404
  };
405
+ var AI_PATHS = {
406
+ ai: [
407
+ ["star", "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"],
408
+ ["p1", "M20 3v4M22 5h-4"],
409
+ ["p2", "M4 17v2M5 18H3"]
410
+ ],
411
+ prompt: [["pen", "M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854zM15 5l3 3"], ["ul", "M12 20h9"]],
412
+ continue: [
413
+ ["l", "M3 6h18M3 12h12"],
414
+ ["l3", "M3 18h8"],
415
+ ["arr", "M14 18h7M18 15l3 3-3 3"]
416
+ ],
417
+ improve: [
418
+ ["wand", "M21.64 3.64l-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72M14 7l3 3"],
419
+ ["s1", "M5 6v4M7 8H3"],
420
+ ["s2", "M19 14v4M21 16h-4"],
421
+ ["s3", "M10 2v2M11 3H9"]
422
+ ],
423
+ shorter: [["tr", "M14 10l7-7M20 10h-6V4"], ["bl", "M3 21l7-7M4 14h6v6"]],
424
+ summarize: [
425
+ ["l1", "M3 5h11"],
426
+ ["l2", "M3 10h11"],
427
+ ["l3", "M3 15h7"],
428
+ ["l4", "M3 20h5"],
429
+ ["arr", "M18 9v11M15 17l3 3 3-3"]
430
+ ],
431
+ translate: [["g", "M5 8l6 6M4 14l6-6 2-3M2 5h12M7 2h1"], ["a", "M22 22l-5-10-5 10M14 18h6"]],
432
+ spelling: [["a", "M6 16l6-12 6 12M8 12h8"], ["ck", "M16 20l2 2 4-4"]]
433
+ };
434
+ var DRAWN = /* @__PURE__ */ new Set([
435
+ "ul",
436
+ "l3",
437
+ "ck"
438
+ ]);
439
+ var AiIcon = ({ n }) => /* @__PURE__ */ jsx("svg", {
440
+ className: `kit-aii kit-aii-${n}`,
441
+ width: "16",
442
+ height: "16",
443
+ viewBox: "0 0 24 24",
444
+ fill: "none",
445
+ stroke: "currentColor",
446
+ strokeWidth: "1.7",
447
+ strokeLinecap: "round",
448
+ strokeLinejoin: "round",
449
+ "aria-hidden": true,
450
+ children: AI_PATHS[n].map(([c, d]) => /* @__PURE__ */ jsx("path", {
451
+ className: c,
452
+ d,
453
+ pathLength: DRAWN.has(c) ? 1 : void 0
454
+ }, c))
455
+ });
456
+ /** The slash menu's Featured row: opens the AI view. */
457
+ var AI_ROW = {
458
+ key: "ai",
459
+ kind: "ai",
460
+ label: "BetterCMS AI",
461
+ description: "Write and edit with AI",
462
+ icon: /* @__PURE__ */ jsx(AiIcon, { n: "ai" }),
463
+ aliases: [
464
+ "ai",
465
+ "write",
466
+ "assistant"
467
+ ]
468
+ };
469
+ var AI_ITEMS = AI_COMMANDS.map((c) => ({
470
+ key: `ai:${c.id}`,
471
+ ai: c.id,
472
+ label: c.label,
473
+ description: c.description,
474
+ icon: /* @__PURE__ */ jsx(AiIcon, { n: c.id })
475
+ }));
376
476
  var componentRow = (c) => ({
377
477
  key: `c:${c.id}`,
378
478
  kind: "component",
@@ -445,8 +545,12 @@ var rank = (q, list, recent) => list.map((it, i) => {
445
545
  i
446
546
  };
447
547
  }).filter((x) => x.s > 0).sort((a, b) => b.s - a.s || a.r - b.r || a.i - b.i).map((x) => x.it);
448
- /** `folder`: the More components view (its way back first, then the components, searched by `query`). */
449
- function useCatalog(query, allows, folder = false, own) {
548
+ /**
549
+ * `folder`: the More components view (its way back first, then the components, searched by `query`).
550
+ * `aiOffered`: the "BetterCMS AI" Featured row leads the list (look "v16", the host has an AI command service);
551
+ * `aiView`: its view (the way back, then the seven commands).
552
+ */
553
+ function useCatalog(query, allows, folder = false, own, aiOffered = false, aiView = false) {
450
554
  const recent = useRecents();
451
555
  const provided = React.useContext(ComponentsContext);
452
556
  const lib = own === void 0 ? provided : own;
@@ -458,7 +562,14 @@ function useCatalog(query, allows, folder = false, own) {
458
562
  let sections;
459
563
  let noMatch = false;
460
564
  let emptyText = "No match.";
461
- if (folder) {
565
+ if (aiView) sections = [{
566
+ title: null,
567
+ items: [BACK]
568
+ }, {
569
+ title: "BetterCMS AI",
570
+ items: AI_ITEMS
571
+ }];
572
+ else if (folder) {
462
573
  const found = q ? rank(q, comps, recent) : comps;
463
574
  noMatch = !!q && !!comps.length && !found.length;
464
575
  if (!comps.length) emptyText = lib?.error ?? (lib?.loading ? "Loading blocks…" : "This field takes no blocks.");
@@ -471,6 +582,7 @@ function useCatalog(query, allows, folder = false, own) {
471
582
  }];
472
583
  } else if (q) {
473
584
  const found = rank(q, [
585
+ ...aiOffered ? [AI_ROW] : [],
474
586
  ...keep(TEXT),
475
587
  ...keep(MEDIA),
476
588
  ...keep(DATA),
@@ -484,6 +596,10 @@ function useCatalog(query, allows, folder = false, own) {
484
596
  items: found
485
597
  }];
486
598
  } else sections = [
599
+ {
600
+ title: "Featured",
601
+ items: aiOffered ? [AI_ROW] : []
602
+ },
487
603
  {
488
604
  title: "Text",
489
605
  items: keep(TEXT)
@@ -523,10 +639,13 @@ function useCatalog(query, allows, folder = false, own) {
523
639
  allows,
524
640
  recent,
525
641
  lib,
526
- folder
642
+ folder,
643
+ aiOffered,
644
+ aiView
527
645
  ]);
528
646
  }
529
- function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText = "No match.", noMatch, detail, listId, className }) {
647
+ function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText = "No match.", noMatch, detail, listId, className, query }) {
648
+ const v16 = useKitLook() === "v16";
530
649
  const box = React.useRef(null);
531
650
  React.useEffect(() => {
532
651
  const b = box.current;
@@ -540,23 +659,77 @@ function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText
540
659
  id: listId,
541
660
  role: "listbox",
542
661
  "aria-label": "Blocks",
543
- className: cn("relative max-h-[320px] overflow-y-auto p-1.5", className),
662
+ className: cn("relative overflow-y-auto", v16 ? "max-h-[344px] px-1 pb-1 [scrollbar-width:thin]" : "max-h-[320px] p-1.5", className),
544
663
  children: [
545
664
  noMatch ? /* @__PURE__ */ jsx("div", {
546
- className: "px-2 pb-1 pt-1.5 text-kit-sm text-kit-fg-3",
547
- children: "No match."
665
+ className: v16 ? "px-2 py-3 text-[13px] text-kit-group-sub" : "px-2 pb-1 pt-1.5 text-kit-sm text-kit-fg-3",
666
+ children: v16 && query?.trim() ? `Nothing matches “${query.trim()}”` : "No match."
548
667
  }) : null,
549
668
  sections.map((s, si) => /* @__PURE__ */ jsxs("div", {
550
669
  role: "group",
551
670
  "aria-label": s.title ?? void 0,
552
671
  className: cn(!s.title && si > 0 && s.items[0]?.kind === "folder" && "mt-1.5 border-t border-kit-line-subtle pt-1.5"),
553
672
  children: [s.title ? /* @__PURE__ */ jsx("div", {
554
- className: "px-2 pb-0.5 pt-2 text-kit-2xs font-medium text-kit-fg-3",
673
+ className: v16 ? "px-2 pb-1 pt-2.5 text-[11px] font-medium leading-4 text-kit-group-sub" : "px-2 pb-0.5 pt-2 text-kit-2xs font-medium text-kit-fg-3",
555
674
  children: s.title
556
675
  }) : null, s.items.map((it) => {
557
676
  const idx = flat.indexOf(it);
558
677
  const on = idx === active;
559
678
  const desc = detail && it.kind !== "back" && it.kind !== "folder" ? it.description : "";
679
+ if (v16) {
680
+ const common = {
681
+ type: "button",
682
+ role: "option",
683
+ "aria-selected": on,
684
+ "aria-disabled": it.disabled ? true : void 0,
685
+ "data-idx": idx,
686
+ id: `${listId}-${idx}`,
687
+ onMouseDown: (e) => e.preventDefault(),
688
+ onMouseMove: () => !on && onHover(idx),
689
+ onClick: () => !it.disabled && onPick(it)
690
+ };
691
+ if (it.kind === "back") return /* @__PURE__ */ jsxs("button", {
692
+ ...common,
693
+ className: cn("mt-1 flex h-8 w-full items-center gap-1.5 rounded-[6px] px-2 text-left text-[12px] font-medium text-kit-insp-tip-body", on && "bg-kit-insp-card"),
694
+ children: [/* @__PURE__ */ jsx(IconChevronLeft, {
695
+ "aria-hidden": true,
696
+ className: "size-3.5 shrink-0",
697
+ stroke: 1.8
698
+ }), "Back to all blocks"]
699
+ }, it.key);
700
+ return /* @__PURE__ */ jsxs("button", {
701
+ ...common,
702
+ className: cn("flex h-11 w-full items-center gap-2.5 rounded-[6px] px-1.5 text-left", on && "bg-kit-insp-card", it.disabled && "cursor-default opacity-60"),
703
+ children: [
704
+ /* @__PURE__ */ jsx("span", {
705
+ className: "grid size-8 shrink-0 place-items-center overflow-hidden rounded-[6px] bg-kit-insp-tip-bg text-kit-insp-tip-body shadow-[inset_0_0_0_1px_var(--kit-insp-line)] [&_svg]:size-4",
706
+ children: it.icon
707
+ }),
708
+ /* @__PURE__ */ jsxs("span", {
709
+ className: "flex min-w-0 flex-1 flex-col",
710
+ children: [/* @__PURE__ */ jsx("b", {
711
+ className: "truncate text-[13px] font-medium leading-[18px] text-kit-insp-tip-title",
712
+ children: it.label
713
+ }), it.description ? /* @__PURE__ */ jsx("small", {
714
+ className: "truncate text-[12px] leading-4 text-kit-group-sub",
715
+ children: it.description
716
+ }) : null]
717
+ }),
718
+ it.count != null ? /* @__PURE__ */ jsx("span", {
719
+ className: "text-[12px] leading-4 tabular-nums text-kit-group-sub",
720
+ children: it.count
721
+ }) : null,
722
+ it.kind === "folder" || it.kind === "ai" ? /* @__PURE__ */ jsx(IconChevronRight, {
723
+ "aria-hidden": true,
724
+ className: "size-3.5 shrink-0 text-kit-insp-faint",
725
+ stroke: 1.8
726
+ }) : it.hint ? /* @__PURE__ */ jsx("kbd", {
727
+ className: "shrink-0 font-kit-sans text-[12px] leading-4 text-kit-group-sub",
728
+ children: it.hint
729
+ }) : null
730
+ ]
731
+ }, it.key);
732
+ }
560
733
  return /* @__PURE__ */ jsxs("button", {
561
734
  type: "button",
562
735
  role: "option",
@@ -598,7 +771,7 @@ function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText
598
771
  })]
599
772
  }, s.title ?? `s${si}`)),
600
773
  empty && !noMatch ? /* @__PURE__ */ jsx("div", {
601
- className: "px-2 py-6 text-center text-kit-sm text-kit-fg-3",
774
+ className: v16 ? "px-2 py-3 text-[13px] text-kit-group-sub" : "px-2 py-6 text-center text-kit-sm text-kit-fg-3",
602
775
  children: emptyText
603
776
  }) : null
604
777
  ]
@@ -620,7 +793,7 @@ function catalogKey(e, flat, active, setActive, pick, homeEnd = true) {
620
793
  if (e.key === "ArrowUp") return setActive((active - 1 + n) % n), true;
621
794
  if (homeEnd && e.key === "Home") return setActive(0), true;
622
795
  if (homeEnd && e.key === "End") return setActive(n - 1), true;
623
- if (e.key === "ArrowRight" && flat[active]?.kind === "folder") return pick(flat[active]), true;
796
+ if (e.key === "ArrowRight" && (flat[active]?.kind === "folder" || flat[active]?.kind === "ai")) return pick(flat[active]), true;
624
797
  if (e.key === "Enter" || e.key === "Tab") {
625
798
  const it = flat[active];
626
799
  if (it && !it.disabled) pick(it);
@@ -635,6 +808,19 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
635
808
  const listId = React.useId();
636
809
  const [folder, setFolder] = React.useState(false);
637
810
  const { sections, flat, empty, emptyText, noMatch } = useCatalog(q, allows, folder);
811
+ const v16 = useKitLook() === "v16";
812
+ const [sideOpen, setSideOpen] = React.useState(false);
813
+ const [sideFlip, setSideFlip] = React.useState(false);
814
+ const sideRef = React.useCallback((el) => {
815
+ const menu = el?.parentElement;
816
+ if (!menu) return;
817
+ setSideFlip(menu.getBoundingClientRect().right + 6 + 300 > window.innerWidth - 8);
818
+ }, []);
819
+ const [sActive, setSActive] = React.useState(0);
820
+ const sideCat = useCatalog("", allows, true);
821
+ const sideFlat = sideCat.flat.filter((it) => it.kind !== "back");
822
+ const sideId = React.useId();
823
+ const useSide = v16 && !q;
638
824
  React.useEffect(() => setActive(folder && flat.length > 1 ? 1 : 0), [q, folder]);
639
825
  const leave = () => {
640
826
  setFolder(false);
@@ -642,7 +828,10 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
642
828
  input.current?.focus();
643
829
  };
644
830
  const pick = (it) => {
645
- if (it.kind === "folder") {
831
+ if (it.kind === "folder" && useSide) {
832
+ setSideOpen(true);
833
+ setSActive(0);
834
+ } else if (it.kind === "folder") {
646
835
  setFolder(true);
647
836
  setQ("");
648
837
  input.current?.focus();
@@ -652,10 +841,16 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
652
841
  return /* @__PURE__ */ jsxs(PopoverContent, {
653
842
  side,
654
843
  align,
655
- className: "flex max-h-[420px] w-[320px] flex-col overflow-hidden p-0",
844
+ className: v16 ? "relative flex max-h-[420px] w-[280px] flex-col rounded-[10px] !border-0 !bg-kit-insp-tip-bg p-0 !shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_12px_28px_rgb(0_0_0/0.12)] ![backdrop-filter:none]" : "flex max-h-[420px] w-[320px] flex-col overflow-hidden p-0",
656
845
  initialFocus: input,
657
846
  finalFocus: keepFocusOnClose ? () => !keepFocusOnClose() : void 0,
658
847
  onKeyDownCapture: (e) => {
848
+ if (useSide && sideOpen && e.key === "Escape") {
849
+ e.preventDefault();
850
+ e.stopPropagation();
851
+ setSideOpen(false);
852
+ return;
853
+ }
659
854
  if (!folder || e.key !== "Escape") return;
660
855
  e.preventDefault();
661
856
  e.stopPropagation();
@@ -663,16 +858,29 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
663
858
  },
664
859
  children: [
665
860
  /* @__PURE__ */ jsxs("div", {
666
- className: "flex h-10 shrink-0 items-center gap-2 border-b border-kit-line px-3",
861
+ className: cn("flex h-10 shrink-0 items-center gap-2 border-b px-3", v16 ? "border-kit-insp-divider" : "border-kit-line"),
667
862
  children: [/* @__PURE__ */ jsx(IconSearch, {
668
- className: "size-4 shrink-0 text-kit-fg-3",
669
- stroke: 1.5,
863
+ className: v16 ? "size-3.5 shrink-0 text-kit-group-sub" : "size-4 shrink-0 text-kit-fg-3",
864
+ stroke: v16 ? 1.8 : 1.5,
670
865
  "aria-hidden": true
671
866
  }), /* @__PURE__ */ jsx("input", {
672
867
  ref: input,
673
868
  value: q,
674
869
  onChange: (e) => setQ(e.target.value),
675
870
  onKeyDown: (e) => {
871
+ if (useSide && sideOpen) {
872
+ if (e.key === "ArrowLeft") {
873
+ e.preventDefault();
874
+ setSideOpen(false);
875
+ } else if (catalogKey(e, sideFlat, sActive, setSActive, pick, true)) e.preventDefault();
876
+ return;
877
+ }
878
+ if (useSide && e.key === "ArrowRight" && flat[active]?.kind === "folder") {
879
+ e.preventDefault();
880
+ setSideOpen(true);
881
+ setSActive(0);
882
+ return;
883
+ }
676
884
  if (folder && e.key === "Backspace" && !q) {
677
885
  e.preventDefault();
678
886
  e.stopPropagation();
@@ -692,22 +900,103 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
692
900
  sections,
693
901
  flat,
694
902
  active,
695
- onHover: setActive,
903
+ onHover: (i) => {
904
+ setActive(i);
905
+ if (useSide) setSideOpen(flat[i]?.kind === "folder");
906
+ },
696
907
  onPick: pick,
697
908
  empty,
698
909
  emptyText,
699
910
  noMatch,
700
911
  detail: !!q || folder,
701
912
  listId,
913
+ query: q,
702
914
  className: "min-h-0 flex-1"
703
915
  }),
704
- /* @__PURE__ */ jsx(Footer, {})
916
+ v16 ? null : /* @__PURE__ */ jsx(Footer, {}),
917
+ useSide && sideOpen ? /* @__PURE__ */ jsx("div", {
918
+ ref: sideRef,
919
+ role: "menu",
920
+ "aria-label": "Blocks for this site",
921
+ className: cn("absolute top-0 flex max-h-[420px] w-[300px] flex-col overflow-hidden rounded-[10px] bg-kit-insp-tip-bg shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_12px_28px_rgb(0_0_0/0.12)] motion-safe:animate-[kit-fade-in_150ms_ease-out]", sideFlip ? "right-full mr-1.5" : "left-full ml-1.5"),
922
+ children: /* @__PURE__ */ jsx(CatalogList, {
923
+ sections: [{
924
+ title: "Blocks for this site",
925
+ items: sideFlat
926
+ }],
927
+ flat: sideFlat,
928
+ active: sActive,
929
+ onHover: setSActive,
930
+ onPick: pick,
931
+ empty: !sideFlat.length,
932
+ emptyText: sideCat.emptyText,
933
+ detail: true,
934
+ listId: sideId,
935
+ className: "min-h-0 flex-1"
936
+ })
937
+ }) : null
705
938
  ]
706
939
  });
707
940
  }
708
- function SlashMenuPanel({ query, folder = false, active, setActive, onPick, allows, maxHeight }) {
941
+ function SlashMenuPanel({ query, folder = false, active, setActive, onPick, allows, maxHeight, aiOffered = false, aiView = false }) {
709
942
  const listId = React.useId();
710
- const { sections, flat, empty, emptyText, noMatch } = useCatalog(query, allows, folder);
943
+ const { sections, flat, empty, emptyText, noMatch } = useCatalog(query, allows, folder, void 0, aiOffered, aiView);
944
+ const v16 = useKitLook() === "v16";
945
+ const panelRef = React.useRef(null);
946
+ const [pvTop, setPvTop] = React.useState(0);
947
+ React.useLayoutEffect(() => {
948
+ if (!v16) return;
949
+ const panel = panelRef.current;
950
+ const row = panel?.querySelector(`[data-idx="${active}"]`);
951
+ if (!panel || !row) return;
952
+ setPvTop(Math.max(0, Math.round(row.getBoundingClientRect().top - panel.getBoundingClientRect().top - 6)));
953
+ }, [
954
+ v16,
955
+ active,
956
+ query,
957
+ folder,
958
+ aiView
959
+ ]);
960
+ if (v16) return /* @__PURE__ */ jsxs("div", {
961
+ "data-kit-scope": "",
962
+ className: "relative w-[300px]",
963
+ onMouseDown: (e) => e.preventDefault(),
964
+ children: [/* @__PURE__ */ jsxs("div", {
965
+ ref: panelRef,
966
+ className: "flex w-[300px] flex-col overflow-hidden rounded-[10px] bg-kit-insp-tip-bg shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_12px_28px_rgb(0_0_0/0.12)]",
967
+ style: maxHeight ? { maxHeight } : void 0,
968
+ children: [/* @__PURE__ */ jsxs("div", {
969
+ className: "flex h-10 shrink-0 items-center gap-2 border-b border-kit-insp-divider px-3 text-[13px]",
970
+ children: [/* @__PURE__ */ jsx(IconSearch, {
971
+ "aria-hidden": true,
972
+ className: "size-3.5 shrink-0 text-kit-group-sub",
973
+ stroke: 1.8
974
+ }), query ? /* @__PURE__ */ jsx("b", {
975
+ className: "min-w-0 flex-1 truncate font-normal text-kit-insp-tip-title",
976
+ children: query
977
+ }) : /* @__PURE__ */ jsx("span", {
978
+ className: "min-w-0 flex-1 truncate text-kit-group-sub",
979
+ children: folder ? "Search blocks" : "Search or pick a block"
980
+ })]
981
+ }), /* @__PURE__ */ jsx(CatalogList, {
982
+ sections,
983
+ flat,
984
+ active,
985
+ onHover: setActive,
986
+ onPick,
987
+ empty,
988
+ emptyText,
989
+ noMatch,
990
+ detail: true,
991
+ listId,
992
+ query,
993
+ className: "min-h-0 flex-1"
994
+ })]
995
+ }), /* @__PURE__ */ jsx(SlashPreviewCard, {
996
+ item: flat[active],
997
+ top: pvTop
998
+ })]
999
+ });
711
1000
  return /* @__PURE__ */ jsxs("div", {
712
1001
  "data-kit-scope": "",
713
1002
  className: "glass-strong flex w-[320px] flex-col overflow-hidden rounded-kit-xl border border-kit-line",