@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.
- 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 +91 -0
- 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 +406 -24
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +45 -7
- package/dist/controls/rich-text/catalog.js +507 -37
- 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 +1 -1
- package/dist/controls/rich-text/codec.js +4 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/dom.d.ts +27 -0
- package/dist/controls/rich-text/dom.js +77 -7
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.js +243 -55
- 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/rewriteSelection.d.ts +25 -0
- package/dist/controls/rich-text/rewriteSelection.js +28 -0
- package/dist/controls/rich-text/rewriteSelection.js.map +1 -0
- package/dist/controls/rich-text/slash-preview.d.ts +8 -0
- package/dist/controls/rich-text/slash-preview.js +300 -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 +1057 -0
- package/dist/controls/rich-text/table-grid.js.map +1 -0
- package/dist/controls/rich-text/toolbar.js +61 -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/field-shell.d.ts +12 -0
- package/dist/engine/field-shell.js +222 -64
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +42 -4
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.d.ts +71 -10
- package/dist/engine/grouping.js +227 -29
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +2 -2
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/kit-field.js +38 -4
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.d.ts +2 -0
- package/dist/engine/schema-form.js +9 -2
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/dist/kit.css +59 -0
- package/dist/lib/reduced-motion.d.ts +1 -0
- package/dist/lib/reduced-motion.js +19 -0
- package/dist/lib/reduced-motion.js.map +1 -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 +215 -0
- package/dist/tokens.css +274 -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 +279 -0
- package/dist/ui/content-fields.js.map +1 -0
- package/dist/ui/controls.js +3 -2
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/floating-panel.js +3 -2
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/foundations.d.ts +118 -0
- package/dist/ui/foundations.js +565 -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 +412 -0
- package/dist/ui/inspector.js +1218 -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/tab.js +3 -2
- package/dist/ui/tab.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
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { AI_COMMANDS, useKitLook, useKitServices } from "../../context.js";
|
|
3
|
+
import { platformKeys } from "../../ui/shortcut-hint.js";
|
|
4
|
+
import { useKitReducedMotion } from "../../lib/reduced-motion.js";
|
|
2
5
|
import { PopoverContent } from "../../ui/overlay.js";
|
|
6
|
+
import { SlashPreviewCard } from "./slash-preview.js";
|
|
3
7
|
import * as React from "react";
|
|
4
8
|
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";
|
|
9
|
+
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";
|
|
10
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
6
11
|
//#region src/controls/rich-text/catalog.tsx
|
|
7
12
|
/**
|
|
8
13
|
* RICH TEXT · the block catalogue shared by the toolbar Insert menu, the gutter "+" and the "/" slash menu (V2 HEAD
|
|
@@ -24,13 +29,34 @@ import { IconArrowLeft, IconBlockquote, IconChevronRight, IconClick, IconCode, I
|
|
|
24
29
|
* "Components" group (V2: "Article" and "Page sections"), and no live preview flyout is drawn beside a row.
|
|
25
30
|
*/
|
|
26
31
|
var i = (I) => /* @__PURE__ */ jsx(I, { stroke: 1.5 });
|
|
32
|
+
/** The Markdown the editor turns into each block as it is typed (ops.ts liveMarkdown, enterCodeFence), or the key that
|
|
33
|
+
* makes it: the row's key hint. Only shortcuts the editor really has: "[] " (checklist.tsx checklistShortcut, when the
|
|
34
|
+
* field allows a checklist; the row is listed only then) and ⌘⌥0 (editor.tsx onKeyDown Digit0, always a paragraph). */
|
|
35
|
+
var HINTS = {
|
|
36
|
+
p: "⌘⌥0",
|
|
37
|
+
h1: "#",
|
|
38
|
+
h2: "##",
|
|
39
|
+
h3: "###",
|
|
40
|
+
h4: "####",
|
|
41
|
+
h5: "#####",
|
|
42
|
+
h6: "######",
|
|
43
|
+
ul: "-",
|
|
44
|
+
ol: "1.",
|
|
45
|
+
quote: ">",
|
|
46
|
+
code: "```",
|
|
47
|
+
hr: "---",
|
|
48
|
+
task: "[]"
|
|
49
|
+
};
|
|
50
|
+
/** A key hint as this platform writes it ("⌘⌥0" → "Ctrl+Alt+0" off Apple; Markdown hints are unchanged). */
|
|
51
|
+
var hintText = (hint) => platformKeys(hint);
|
|
27
52
|
var rows = (list) => list.map(([id, label, description, icon, aliases]) => ({
|
|
28
53
|
key: id,
|
|
29
54
|
id,
|
|
30
55
|
label,
|
|
31
56
|
description,
|
|
32
57
|
icon,
|
|
33
|
-
aliases
|
|
58
|
+
aliases,
|
|
59
|
+
hint: HINTS[id]
|
|
34
60
|
}));
|
|
35
61
|
var TEXT = rows([
|
|
36
62
|
[
|
|
@@ -284,6 +310,17 @@ var DATA = rows([[
|
|
|
284
310
|
"comparison",
|
|
285
311
|
"spreadsheet"
|
|
286
312
|
]
|
|
313
|
+
], [
|
|
314
|
+
"stats",
|
|
315
|
+
"Stats",
|
|
316
|
+
"Big numbers in a row",
|
|
317
|
+
i(IconChartBar),
|
|
318
|
+
[
|
|
319
|
+
"numbers",
|
|
320
|
+
"metrics",
|
|
321
|
+
"kpi",
|
|
322
|
+
"figures"
|
|
323
|
+
]
|
|
287
324
|
]]);
|
|
288
325
|
/** Found by search, not listed: rare in a body (H1 is the page title). */
|
|
289
326
|
var SEARCH_ONLY = rows([
|
|
@@ -357,7 +394,8 @@ var NEEDS = {
|
|
|
357
394
|
footnote: "footnote",
|
|
358
395
|
columns: "columns",
|
|
359
396
|
related: "related",
|
|
360
|
-
author: "author"
|
|
397
|
+
author: "author",
|
|
398
|
+
stats: "stats"
|
|
361
399
|
};
|
|
362
400
|
var MORE = {
|
|
363
401
|
key: "more",
|
|
@@ -373,6 +411,153 @@ var BACK = {
|
|
|
373
411
|
description: "",
|
|
374
412
|
icon: i(IconArrowLeft)
|
|
375
413
|
};
|
|
414
|
+
var INSERT_MEDIA = [
|
|
415
|
+
[
|
|
416
|
+
"image",
|
|
417
|
+
"Image",
|
|
418
|
+
"Upload or pick from Media"
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
"video",
|
|
422
|
+
"Video",
|
|
423
|
+
"YouTube, Vimeo or a file"
|
|
424
|
+
],
|
|
425
|
+
[
|
|
426
|
+
"file",
|
|
427
|
+
"File",
|
|
428
|
+
"A download link"
|
|
429
|
+
]
|
|
430
|
+
];
|
|
431
|
+
var INSERT_DATA = [
|
|
432
|
+
[
|
|
433
|
+
"table",
|
|
434
|
+
"Table",
|
|
435
|
+
"Rows and columns"
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
"stats",
|
|
439
|
+
"Stats",
|
|
440
|
+
"Big numbers in a row"
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
"code",
|
|
444
|
+
"Code block",
|
|
445
|
+
"Code with highlighting"
|
|
446
|
+
],
|
|
447
|
+
[
|
|
448
|
+
"callout",
|
|
449
|
+
"Callout",
|
|
450
|
+
"A highlighted note"
|
|
451
|
+
],
|
|
452
|
+
[
|
|
453
|
+
"toggle",
|
|
454
|
+
"Toggle",
|
|
455
|
+
"Hide details under a heading"
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
"hr",
|
|
459
|
+
"Divider",
|
|
460
|
+
"A line between parts"
|
|
461
|
+
]
|
|
462
|
+
];
|
|
463
|
+
var SITE_BLOCKS = {
|
|
464
|
+
...MORE,
|
|
465
|
+
label: "Site blocks",
|
|
466
|
+
description: "Sections built for this site"
|
|
467
|
+
};
|
|
468
|
+
var AI_PATHS = {
|
|
469
|
+
ai: [
|
|
470
|
+
["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"],
|
|
471
|
+
["p1", "M20 3v4M22 5h-4"],
|
|
472
|
+
["p2", "M4 17v2M5 18H3"]
|
|
473
|
+
],
|
|
474
|
+
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"]],
|
|
475
|
+
continue: [
|
|
476
|
+
["l", "M3 6h18M3 12h12"],
|
|
477
|
+
["l3", "M3 18h8"],
|
|
478
|
+
["arr", "M14 18h7M18 15l3 3-3 3"]
|
|
479
|
+
],
|
|
480
|
+
improve: [
|
|
481
|
+
["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"],
|
|
482
|
+
["s1", "M5 6v4M7 8H3"],
|
|
483
|
+
["s2", "M19 14v4M21 16h-4"],
|
|
484
|
+
["s3", "M10 2v2M11 3H9"]
|
|
485
|
+
],
|
|
486
|
+
shorter: [["tr", "M14 10l7-7M20 10h-6V4"], ["bl", "M3 21l7-7M4 14h6v6"]],
|
|
487
|
+
summarize: [
|
|
488
|
+
["l1", "M3 5h11"],
|
|
489
|
+
["l2", "M3 10h11"],
|
|
490
|
+
["l3", "M3 15h7"],
|
|
491
|
+
["l4", "M3 20h5"],
|
|
492
|
+
["arr", "M18 9v11M15 17l3 3 3-3"]
|
|
493
|
+
],
|
|
494
|
+
translate: [["g", "M5 8l6 6M4 14l6-6 2-3M2 5h12M7 2h1"], ["a", "M22 22l-5-10-5 10M14 18h6"]],
|
|
495
|
+
spelling: [["a", "M6 16l6-12 6 12M8 12h8"], ["ck", "M16 20l2 2 4-4"]]
|
|
496
|
+
};
|
|
497
|
+
var DRAWN = /* @__PURE__ */ new Set([
|
|
498
|
+
"ul",
|
|
499
|
+
"l3",
|
|
500
|
+
"ck"
|
|
501
|
+
]);
|
|
502
|
+
/** kit-ai-move's offset per stroke (prototype content.css:247-278), set on the path itself: component-local, not a token. */
|
|
503
|
+
var MOVE = {
|
|
504
|
+
"prompt.pen": ["1.7px", "-1.7px"],
|
|
505
|
+
"continue.arr": ["2.5px", "0px"],
|
|
506
|
+
"shorter.tr": ["-1.7px", "1.7px"],
|
|
507
|
+
"shorter.bl": ["1.7px", "-1.7px"],
|
|
508
|
+
"summarize.l1": ["0px", "-1.7px"],
|
|
509
|
+
"summarize.l2": ["0px", "-1.7px"],
|
|
510
|
+
"summarize.l3": ["0px", "-1.7px"],
|
|
511
|
+
"summarize.l4": ["0px", "-1.7px"],
|
|
512
|
+
"summarize.arr": ["0px", "2px"],
|
|
513
|
+
"translate.g": ["-1px", "-1.7px"],
|
|
514
|
+
"translate.a": ["1px", "1.7px"],
|
|
515
|
+
"spelling.a": ["0px", "-1.4px"]
|
|
516
|
+
};
|
|
517
|
+
var AiIcon = ({ n }) => /* @__PURE__ */ jsx("svg", {
|
|
518
|
+
className: `kit-aii kit-aii-${n}`,
|
|
519
|
+
width: "16",
|
|
520
|
+
height: "16",
|
|
521
|
+
viewBox: "0 0 24 24",
|
|
522
|
+
fill: "none",
|
|
523
|
+
stroke: "currentColor",
|
|
524
|
+
strokeWidth: "1.7",
|
|
525
|
+
strokeLinecap: "round",
|
|
526
|
+
strokeLinejoin: "round",
|
|
527
|
+
"aria-hidden": true,
|
|
528
|
+
children: AI_PATHS[n].map(([c, d]) => {
|
|
529
|
+
const move = MOVE[`${n}.${c}`];
|
|
530
|
+
return /* @__PURE__ */ jsx("path", {
|
|
531
|
+
className: c,
|
|
532
|
+
d,
|
|
533
|
+
pathLength: DRAWN.has(c) ? 1 : void 0,
|
|
534
|
+
style: move ? {
|
|
535
|
+
"--dx": move[0],
|
|
536
|
+
"--dy": move[1]
|
|
537
|
+
} : void 0
|
|
538
|
+
}, c);
|
|
539
|
+
})
|
|
540
|
+
});
|
|
541
|
+
/** The slash menu's Featured row: opens the AI view. */
|
|
542
|
+
var AI_ROW = {
|
|
543
|
+
key: "ai",
|
|
544
|
+
kind: "ai",
|
|
545
|
+
label: "BetterCMS AI",
|
|
546
|
+
description: "Write and edit with AI",
|
|
547
|
+
icon: /* @__PURE__ */ jsx(AiIcon, { n: "ai" }),
|
|
548
|
+
aliases: [
|
|
549
|
+
"ai",
|
|
550
|
+
"write",
|
|
551
|
+
"assistant"
|
|
552
|
+
]
|
|
553
|
+
};
|
|
554
|
+
var AI_ITEMS = AI_COMMANDS.map((c) => ({
|
|
555
|
+
key: `ai:${c.id}`,
|
|
556
|
+
ai: c.id,
|
|
557
|
+
label: c.label,
|
|
558
|
+
description: c.description,
|
|
559
|
+
icon: /* @__PURE__ */ jsx(AiIcon, { n: c.id })
|
|
560
|
+
}));
|
|
376
561
|
var componentRow = (c) => ({
|
|
377
562
|
key: `c:${c.id}`,
|
|
378
563
|
kind: "component",
|
|
@@ -445,9 +630,17 @@ var rank = (q, list, recent) => list.map((it, i) => {
|
|
|
445
630
|
i
|
|
446
631
|
};
|
|
447
632
|
}).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
|
-
/**
|
|
449
|
-
|
|
633
|
+
/**
|
|
634
|
+
* `folder`: the More components view (its way back first, then the components, searched by `query`).
|
|
635
|
+
* `aiOffered`: the "BetterCMS AI" Featured row leads the list (look "v16", the host has an AI command service);
|
|
636
|
+
* `aiView`: its view (the way back, then the commands: all seven, or the host's `KitServices.aiCommandKinds` in
|
|
637
|
+
* AI_COMMANDS order; when that leaves none there is no AI row at all).
|
|
638
|
+
*/
|
|
639
|
+
function useCatalog(query, allows, folder = false, own, aiOffered = false, aiView = false) {
|
|
450
640
|
const recent = useRecents();
|
|
641
|
+
const kinds = useKitServices().aiCommandKinds;
|
|
642
|
+
const aiItems = React.useMemo(() => kinds ? AI_ITEMS.filter((it) => kinds.includes(it.ai)) : AI_ITEMS, [kinds]);
|
|
643
|
+
const ai = aiOffered && aiItems.length > 0;
|
|
451
644
|
const provided = React.useContext(ComponentsContext);
|
|
452
645
|
const lib = own === void 0 ? provided : own;
|
|
453
646
|
return React.useMemo(() => {
|
|
@@ -458,7 +651,14 @@ function useCatalog(query, allows, folder = false, own) {
|
|
|
458
651
|
let sections;
|
|
459
652
|
let noMatch = false;
|
|
460
653
|
let emptyText = "No match.";
|
|
461
|
-
if (
|
|
654
|
+
if (aiView && ai) sections = [{
|
|
655
|
+
title: null,
|
|
656
|
+
items: [BACK]
|
|
657
|
+
}, {
|
|
658
|
+
title: "BetterCMS AI",
|
|
659
|
+
items: aiItems
|
|
660
|
+
}];
|
|
661
|
+
else if (folder) {
|
|
462
662
|
const found = q ? rank(q, comps, recent) : comps;
|
|
463
663
|
noMatch = !!q && !!comps.length && !found.length;
|
|
464
664
|
if (!comps.length) emptyText = lib?.error ?? (lib?.loading ? "Loading blocks…" : "This field takes no blocks.");
|
|
@@ -471,6 +671,7 @@ function useCatalog(query, allows, folder = false, own) {
|
|
|
471
671
|
}];
|
|
472
672
|
} else if (q) {
|
|
473
673
|
const found = rank(q, [
|
|
674
|
+
...ai ? [AI_ROW] : [],
|
|
474
675
|
...keep(TEXT),
|
|
475
676
|
...keep(MEDIA),
|
|
476
677
|
...keep(DATA),
|
|
@@ -484,6 +685,10 @@ function useCatalog(query, allows, folder = false, own) {
|
|
|
484
685
|
items: found
|
|
485
686
|
}];
|
|
486
687
|
} else sections = [
|
|
688
|
+
{
|
|
689
|
+
title: "Featured",
|
|
690
|
+
items: ai ? [AI_ROW] : []
|
|
691
|
+
},
|
|
487
692
|
{
|
|
488
693
|
title: "Text",
|
|
489
694
|
items: keep(TEXT)
|
|
@@ -523,11 +728,57 @@ function useCatalog(query, allows, folder = false, own) {
|
|
|
523
728
|
allows,
|
|
524
729
|
recent,
|
|
525
730
|
lib,
|
|
526
|
-
folder
|
|
731
|
+
folder,
|
|
732
|
+
ai,
|
|
733
|
+
aiItems,
|
|
734
|
+
aiView
|
|
527
735
|
]);
|
|
528
736
|
}
|
|
529
|
-
|
|
530
|
-
|
|
737
|
+
/**
|
|
738
|
+
* Look "v16" Insert ▾ (prototype content.jsx:1263-1306): no search. "Site blocks · Sections built for this site" first,
|
|
739
|
+
* only when the host has site blocks (its component list has some, or is still loading); then Media; then Data and
|
|
740
|
+
* layout. Rows the field does not allow are left out.
|
|
741
|
+
*/
|
|
742
|
+
function insertCatalog(allows, lib) {
|
|
743
|
+
const byId = new Map([
|
|
744
|
+
...TEXT,
|
|
745
|
+
...MEDIA,
|
|
746
|
+
...DATA,
|
|
747
|
+
...ARTICLE,
|
|
748
|
+
...SEARCH_ONLY
|
|
749
|
+
].map((it) => [it.id, it]));
|
|
750
|
+
const pick = (list) => list.filter(([id]) => byId.has(id) && blockAllowed(id, allows)).map(([id, label, description]) => ({
|
|
751
|
+
...byId.get(id),
|
|
752
|
+
label,
|
|
753
|
+
description
|
|
754
|
+
}));
|
|
755
|
+
const sections = [
|
|
756
|
+
{
|
|
757
|
+
title: null,
|
|
758
|
+
items: !!lib && (!!lib.components.length || !!lib.loading) ? [SITE_BLOCKS] : []
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
title: "Media",
|
|
762
|
+
items: pick(INSERT_MEDIA)
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
title: "Data and layout",
|
|
766
|
+
items: pick(INSERT_DATA)
|
|
767
|
+
}
|
|
768
|
+
].filter((sec) => sec.items.length);
|
|
769
|
+
const flat = sections.flatMap((sec) => sec.items);
|
|
770
|
+
return {
|
|
771
|
+
sections,
|
|
772
|
+
flat,
|
|
773
|
+
empty: !flat.length,
|
|
774
|
+
noMatch: false,
|
|
775
|
+
emptyText: "This field takes no blocks."
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText = "No match.", noMatch, detail, listId, className, query, playIcon = null, onListKeyDown, listRef }) {
|
|
779
|
+
const v16 = useKitLook() === "v16";
|
|
780
|
+
const own = React.useRef(null);
|
|
781
|
+
const box = listRef ?? own;
|
|
531
782
|
React.useEffect(() => {
|
|
532
783
|
const b = box.current;
|
|
533
784
|
const row = b?.querySelector(`[data-idx="${active}"]`);
|
|
@@ -540,23 +791,84 @@ function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText
|
|
|
540
791
|
id: listId,
|
|
541
792
|
role: "listbox",
|
|
542
793
|
"aria-label": "Blocks",
|
|
543
|
-
|
|
794
|
+
...onListKeyDown ? {
|
|
795
|
+
tabIndex: -1,
|
|
796
|
+
onKeyDown: onListKeyDown,
|
|
797
|
+
"aria-activedescendant": flat.length ? `${listId}-${active}` : void 0
|
|
798
|
+
} : {},
|
|
799
|
+
className: cn("relative overflow-y-auto", v16 ? "max-h-[344px] px-1 pb-1 [scrollbar-width:thin]" : "max-h-[320px] p-1.5", onListKeyDown && "outline-none", className),
|
|
544
800
|
children: [
|
|
545
801
|
noMatch ? /* @__PURE__ */ jsx("div", {
|
|
546
|
-
className: "px-2 pb-1 pt-1.5 text-kit-sm text-kit-fg-3",
|
|
547
|
-
children: "No match."
|
|
802
|
+
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",
|
|
803
|
+
children: v16 && query?.trim() ? `Nothing matches “${query.trim()}”` : "No match."
|
|
548
804
|
}) : null,
|
|
549
805
|
sections.map((s, si) => /* @__PURE__ */ jsxs("div", {
|
|
550
806
|
role: "group",
|
|
551
807
|
"aria-label": s.title ?? void 0,
|
|
552
808
|
className: cn(!s.title && si > 0 && s.items[0]?.kind === "folder" && "mt-1.5 border-t border-kit-line-subtle pt-1.5"),
|
|
553
809
|
children: [s.title ? /* @__PURE__ */ jsx("div", {
|
|
554
|
-
className: "px-2 pb-0.5 pt-2 text-kit-2xs font-medium text-kit-fg-3",
|
|
810
|
+
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
811
|
children: s.title
|
|
556
812
|
}) : null, s.items.map((it) => {
|
|
557
813
|
const idx = flat.indexOf(it);
|
|
558
814
|
const on = idx === active;
|
|
559
815
|
const desc = detail && it.kind !== "back" && it.kind !== "folder" ? it.description : "";
|
|
816
|
+
if (v16) {
|
|
817
|
+
const common = {
|
|
818
|
+
type: "button",
|
|
819
|
+
role: "option",
|
|
820
|
+
"aria-selected": on,
|
|
821
|
+
"aria-disabled": it.disabled ? true : void 0,
|
|
822
|
+
"data-idx": idx,
|
|
823
|
+
"data-aii-entry": idx === playIcon ? "" : void 0,
|
|
824
|
+
id: `${listId}-${idx}`,
|
|
825
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
826
|
+
onMouseMove: () => !on && onHover(idx),
|
|
827
|
+
onClick: () => !it.disabled && onPick(it)
|
|
828
|
+
};
|
|
829
|
+
if (it.kind === "back") return /* @__PURE__ */ jsxs("button", {
|
|
830
|
+
...common,
|
|
831
|
+
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"),
|
|
832
|
+
children: [/* @__PURE__ */ jsx(IconChevronLeft, {
|
|
833
|
+
"aria-hidden": true,
|
|
834
|
+
className: "size-3.5 shrink-0",
|
|
835
|
+
stroke: 1.8
|
|
836
|
+
}), "Back to all blocks"]
|
|
837
|
+
}, it.key);
|
|
838
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
839
|
+
...common,
|
|
840
|
+
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"),
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ jsx("span", {
|
|
843
|
+
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",
|
|
844
|
+
children: it.icon
|
|
845
|
+
}),
|
|
846
|
+
/* @__PURE__ */ jsxs("span", {
|
|
847
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
848
|
+
children: [/* @__PURE__ */ jsx("b", {
|
|
849
|
+
className: "truncate text-[13px] font-medium leading-[18px] text-kit-insp-tip-title",
|
|
850
|
+
children: it.label
|
|
851
|
+
}), it.description ? /* @__PURE__ */ jsx("small", {
|
|
852
|
+
className: "truncate text-[12px] leading-4 text-kit-group-sub",
|
|
853
|
+
children: it.description
|
|
854
|
+
}) : null]
|
|
855
|
+
}),
|
|
856
|
+
it.count != null ? /* @__PURE__ */ jsx("span", {
|
|
857
|
+
className: "text-[12px] leading-4 tabular-nums text-kit-group-sub",
|
|
858
|
+
children: it.count
|
|
859
|
+
}) : null,
|
|
860
|
+
it.kind === "folder" || it.kind === "ai" ? /* @__PURE__ */ jsx(IconChevronRight, {
|
|
861
|
+
"aria-hidden": true,
|
|
862
|
+
className: "size-3.5 shrink-0 text-kit-insp-faint",
|
|
863
|
+
stroke: 1.8
|
|
864
|
+
}) : it.hint ? /* @__PURE__ */ jsx("kbd", {
|
|
865
|
+
"data-hint": "shortcuts",
|
|
866
|
+
className: "shrink-0 font-kit-sans text-[12px] leading-4 text-kit-group-sub",
|
|
867
|
+
children: hintText(it.hint)
|
|
868
|
+
}) : null
|
|
869
|
+
]
|
|
870
|
+
}, it.key);
|
|
871
|
+
}
|
|
560
872
|
return /* @__PURE__ */ jsxs("button", {
|
|
561
873
|
type: "button",
|
|
562
874
|
role: "option",
|
|
@@ -598,7 +910,7 @@ function CatalogList({ sections, flat, active, onHover, onPick, empty, emptyText
|
|
|
598
910
|
})]
|
|
599
911
|
}, s.title ?? `s${si}`)),
|
|
600
912
|
empty && !noMatch ? /* @__PURE__ */ jsx("div", {
|
|
601
|
-
className: "px-2 py-6 text-center text-kit-sm text-kit-fg-3",
|
|
913
|
+
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
914
|
children: emptyText
|
|
603
915
|
}) : null
|
|
604
916
|
]
|
|
@@ -620,7 +932,7 @@ function catalogKey(e, flat, active, setActive, pick, homeEnd = true) {
|
|
|
620
932
|
if (e.key === "ArrowUp") return setActive((active - 1 + n) % n), true;
|
|
621
933
|
if (homeEnd && e.key === "Home") return setActive(0), true;
|
|
622
934
|
if (homeEnd && e.key === "End") return setActive(n - 1), true;
|
|
623
|
-
if (e.key === "ArrowRight" && flat[active]?.kind === "folder") return pick(flat[active]), true;
|
|
935
|
+
if (e.key === "ArrowRight" && (flat[active]?.kind === "folder" || flat[active]?.kind === "ai")) return pick(flat[active]), true;
|
|
624
936
|
if (e.key === "Enter" || e.key === "Tab") {
|
|
625
937
|
const it = flat[active];
|
|
626
938
|
if (it && !it.disabled) pick(it);
|
|
@@ -628,13 +940,36 @@ function catalogKey(e, flat, active, setActive, pick, homeEnd = true) {
|
|
|
628
940
|
}
|
|
629
941
|
return false;
|
|
630
942
|
}
|
|
631
|
-
function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start", side = "bottom" }) {
|
|
943
|
+
function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start", side = "bottom", list = "full" }) {
|
|
632
944
|
const [q, setQ] = React.useState("");
|
|
633
945
|
const [active, setActive] = React.useState(0);
|
|
634
946
|
const input = React.useRef(null);
|
|
947
|
+
const listRef = React.useRef(null);
|
|
635
948
|
const listId = React.useId();
|
|
636
949
|
const [folder, setFolder] = React.useState(false);
|
|
637
|
-
const
|
|
950
|
+
const full = useCatalog(q, allows, folder);
|
|
951
|
+
const v16 = useKitLook() === "v16";
|
|
952
|
+
const curated = v16 && list === "curated";
|
|
953
|
+
const lib = React.useContext(ComponentsContext);
|
|
954
|
+
const { sections, flat, empty, emptyText, noMatch } = React.useMemo(() => curated ? insertCatalog(allows, lib) : null, [
|
|
955
|
+
curated,
|
|
956
|
+
allows,
|
|
957
|
+
lib
|
|
958
|
+
]) ?? full;
|
|
959
|
+
const reduce = !!useKitReducedMotion();
|
|
960
|
+
const [sideOpen, setSideOpen] = React.useState(false);
|
|
961
|
+
const [sideFlip, setSideFlip] = React.useState(false);
|
|
962
|
+
const [sActive, setSActive] = React.useState(0);
|
|
963
|
+
const openSide = () => {
|
|
964
|
+
const menu = document.getElementById(listId)?.parentElement;
|
|
965
|
+
if (menu) setSideFlip(menu.getBoundingClientRect().right + 6 + 300 > window.innerWidth - 8);
|
|
966
|
+
setSideOpen(true);
|
|
967
|
+
setSActive(0);
|
|
968
|
+
};
|
|
969
|
+
const sideCat = useCatalog("", allows, true);
|
|
970
|
+
const sideFlat = sideCat.flat.filter((it) => it.kind !== "back");
|
|
971
|
+
const sideId = React.useId();
|
|
972
|
+
const useSide = v16 && !q;
|
|
638
973
|
React.useEffect(() => setActive(folder && flat.length > 1 ? 1 : 0), [q, folder]);
|
|
639
974
|
const leave = () => {
|
|
640
975
|
setFolder(false);
|
|
@@ -642,43 +977,64 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
|
|
|
642
977
|
input.current?.focus();
|
|
643
978
|
};
|
|
644
979
|
const pick = (it) => {
|
|
645
|
-
if (it.kind === "folder")
|
|
980
|
+
if (it.kind === "folder" && useSide) openSide();
|
|
981
|
+
else if (it.kind === "folder") {
|
|
646
982
|
setFolder(true);
|
|
647
983
|
setQ("");
|
|
648
984
|
input.current?.focus();
|
|
649
985
|
} else if (it.kind === "back") leave();
|
|
650
986
|
else onInsert(it);
|
|
651
987
|
};
|
|
988
|
+
const onKey = (e) => {
|
|
989
|
+
if (useSide && sideOpen) {
|
|
990
|
+
if (e.key === "ArrowLeft") {
|
|
991
|
+
e.preventDefault();
|
|
992
|
+
setSideOpen(false);
|
|
993
|
+
} else if (catalogKey(e, sideFlat, sActive, setSActive, pick, true)) e.preventDefault();
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
if (useSide && e.key === "ArrowRight" && flat[active]?.kind === "folder") {
|
|
997
|
+
e.preventDefault();
|
|
998
|
+
openSide();
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (folder && e.key === "Backspace" && !q) {
|
|
1002
|
+
e.preventDefault();
|
|
1003
|
+
e.stopPropagation();
|
|
1004
|
+
leave();
|
|
1005
|
+
} else if (catalogKey(e, flat, active, setActive, pick, !q)) e.preventDefault();
|
|
1006
|
+
};
|
|
1007
|
+
const sideX = reduce ? 0 : sideFlip ? 4 : -4;
|
|
652
1008
|
return /* @__PURE__ */ jsxs(PopoverContent, {
|
|
653
1009
|
side,
|
|
654
1010
|
align,
|
|
655
|
-
className: "flex max-h-[420px] w-[320px] flex-col overflow-hidden p-0",
|
|
656
|
-
initialFocus: input,
|
|
1011
|
+
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",
|
|
1012
|
+
initialFocus: curated ? listRef : input,
|
|
657
1013
|
finalFocus: keepFocusOnClose ? () => !keepFocusOnClose() : void 0,
|
|
658
1014
|
onKeyDownCapture: (e) => {
|
|
1015
|
+
if (useSide && sideOpen && e.key === "Escape") {
|
|
1016
|
+
e.preventDefault();
|
|
1017
|
+
e.stopPropagation();
|
|
1018
|
+
setSideOpen(false);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
659
1021
|
if (!folder || e.key !== "Escape") return;
|
|
660
1022
|
e.preventDefault();
|
|
661
1023
|
e.stopPropagation();
|
|
662
1024
|
leave();
|
|
663
1025
|
},
|
|
664
1026
|
children: [
|
|
665
|
-
/* @__PURE__ */ jsxs("div", {
|
|
666
|
-
className: "flex h-10 shrink-0 items-center gap-2 border-b border-kit-
|
|
1027
|
+
curated ? null : /* @__PURE__ */ jsxs("div", {
|
|
1028
|
+
className: cn("flex h-10 shrink-0 items-center gap-2 border-b px-3", v16 ? "border-kit-insp-divider" : "border-kit-line"),
|
|
667
1029
|
children: [/* @__PURE__ */ jsx(IconSearch, {
|
|
668
|
-
className: "size-4 shrink-0 text-kit-fg-3",
|
|
669
|
-
stroke: 1.5,
|
|
1030
|
+
className: v16 ? "size-3.5 shrink-0 text-kit-group-sub" : "size-4 shrink-0 text-kit-fg-3",
|
|
1031
|
+
stroke: v16 ? 1.8 : 1.5,
|
|
670
1032
|
"aria-hidden": true
|
|
671
1033
|
}), /* @__PURE__ */ jsx("input", {
|
|
672
1034
|
ref: input,
|
|
673
1035
|
value: q,
|
|
674
1036
|
onChange: (e) => setQ(e.target.value),
|
|
675
|
-
onKeyDown:
|
|
676
|
-
if (folder && e.key === "Backspace" && !q) {
|
|
677
|
-
e.preventDefault();
|
|
678
|
-
e.stopPropagation();
|
|
679
|
-
leave();
|
|
680
|
-
} else if (catalogKey(e, flat, active, setActive, pick, !q)) e.preventDefault();
|
|
681
|
-
},
|
|
1037
|
+
onKeyDown: onKey,
|
|
682
1038
|
role: "combobox",
|
|
683
1039
|
"aria-expanded": true,
|
|
684
1040
|
"aria-controls": listId,
|
|
@@ -692,22 +1048,136 @@ function InsertMenuContent({ onInsert, allows, keepFocusOnClose, align = "start"
|
|
|
692
1048
|
sections,
|
|
693
1049
|
flat,
|
|
694
1050
|
active,
|
|
695
|
-
onHover:
|
|
1051
|
+
onHover: (i) => {
|
|
1052
|
+
setActive(i);
|
|
1053
|
+
if (!useSide) return;
|
|
1054
|
+
if (flat[i]?.kind !== "folder") setSideOpen(false);
|
|
1055
|
+
else if (!sideOpen) openSide();
|
|
1056
|
+
},
|
|
696
1057
|
onPick: pick,
|
|
697
1058
|
empty,
|
|
698
1059
|
emptyText,
|
|
699
1060
|
noMatch,
|
|
700
1061
|
detail: !!q || folder,
|
|
701
1062
|
listId,
|
|
702
|
-
|
|
1063
|
+
query: q,
|
|
1064
|
+
className: cn("min-h-0 flex-1", curated && "pt-1"),
|
|
1065
|
+
...curated ? {
|
|
1066
|
+
onListKeyDown: onKey,
|
|
1067
|
+
listRef
|
|
1068
|
+
} : {}
|
|
703
1069
|
}),
|
|
704
|
-
/* @__PURE__ */ jsx(Footer, {})
|
|
1070
|
+
v16 ? null : /* @__PURE__ */ jsx(Footer, {}),
|
|
1071
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: useSide && sideOpen ? /* @__PURE__ */ jsx(motion.div, {
|
|
1072
|
+
role: "menu",
|
|
1073
|
+
"aria-label": "Blocks for this site",
|
|
1074
|
+
initial: {
|
|
1075
|
+
opacity: 0,
|
|
1076
|
+
x: sideX
|
|
1077
|
+
},
|
|
1078
|
+
animate: {
|
|
1079
|
+
opacity: 1,
|
|
1080
|
+
x: 0,
|
|
1081
|
+
transition: {
|
|
1082
|
+
duration: .15,
|
|
1083
|
+
ease: "easeOut"
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
exit: {
|
|
1087
|
+
opacity: 0,
|
|
1088
|
+
x: sideX,
|
|
1089
|
+
transition: {
|
|
1090
|
+
duration: .1,
|
|
1091
|
+
ease: "easeIn"
|
|
1092
|
+
}
|
|
1093
|
+
},
|
|
1094
|
+
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)]", sideFlip ? "right-full mr-1.5" : "left-full ml-1.5"),
|
|
1095
|
+
children: /* @__PURE__ */ jsx(CatalogList, {
|
|
1096
|
+
sections: [{
|
|
1097
|
+
title: "Blocks for this site",
|
|
1098
|
+
items: sideFlat
|
|
1099
|
+
}],
|
|
1100
|
+
flat: sideFlat,
|
|
1101
|
+
active: sActive,
|
|
1102
|
+
onHover: setSActive,
|
|
1103
|
+
onPick: pick,
|
|
1104
|
+
empty: !sideFlat.length,
|
|
1105
|
+
emptyText: sideCat.emptyText,
|
|
1106
|
+
detail: true,
|
|
1107
|
+
listId: sideId,
|
|
1108
|
+
className: "min-h-0 flex-1"
|
|
1109
|
+
})
|
|
1110
|
+
}, "side") : null })
|
|
705
1111
|
]
|
|
706
1112
|
});
|
|
707
1113
|
}
|
|
708
|
-
function SlashMenuPanel({ query, folder = false, active, setActive, onPick, allows, maxHeight }) {
|
|
1114
|
+
function SlashMenuPanel({ query, folder = false, active, setActive, onPick, allows, maxHeight, aiOffered = false, aiView = false }) {
|
|
709
1115
|
const listId = React.useId();
|
|
710
|
-
const { sections, flat, empty, emptyText, noMatch } = useCatalog(query, allows, folder);
|
|
1116
|
+
const { sections, flat, empty, emptyText, noMatch } = useCatalog(query, allows, folder, void 0, aiOffered, aiView);
|
|
1117
|
+
const v16 = useKitLook() === "v16";
|
|
1118
|
+
const reduce = !!useKitReducedMotion();
|
|
1119
|
+
const [wasAi, setWasAi] = React.useState(aiView);
|
|
1120
|
+
const [aiEntry, setAiEntry] = React.useState(null);
|
|
1121
|
+
if (wasAi !== aiView) {
|
|
1122
|
+
setWasAi(aiView);
|
|
1123
|
+
setAiEntry(aiView && !reduce ? active : null);
|
|
1124
|
+
}
|
|
1125
|
+
const panelRef = React.useRef(null);
|
|
1126
|
+
const [pvTop, setPvTop] = React.useState(0);
|
|
1127
|
+
React.useLayoutEffect(() => {
|
|
1128
|
+
if (!v16) return;
|
|
1129
|
+
const panel = panelRef.current;
|
|
1130
|
+
const row = panel?.querySelector(`[data-idx="${active}"]`);
|
|
1131
|
+
if (!panel || !row) return;
|
|
1132
|
+
setPvTop(Math.max(0, Math.round(row.getBoundingClientRect().top - panel.getBoundingClientRect().top - 6)));
|
|
1133
|
+
}, [
|
|
1134
|
+
v16,
|
|
1135
|
+
active,
|
|
1136
|
+
query,
|
|
1137
|
+
folder,
|
|
1138
|
+
aiView
|
|
1139
|
+
]);
|
|
1140
|
+
if (v16) return /* @__PURE__ */ jsxs("div", {
|
|
1141
|
+
"data-kit-scope": "",
|
|
1142
|
+
className: "relative w-[300px]",
|
|
1143
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
1144
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1145
|
+
ref: panelRef,
|
|
1146
|
+
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)]",
|
|
1147
|
+
style: maxHeight ? { maxHeight } : void 0,
|
|
1148
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1149
|
+
className: "flex h-10 shrink-0 items-center gap-2 border-b border-kit-insp-divider px-3 text-[13px]",
|
|
1150
|
+
children: [/* @__PURE__ */ jsx(IconSearch, {
|
|
1151
|
+
"aria-hidden": true,
|
|
1152
|
+
className: "size-3.5 shrink-0 text-kit-group-sub",
|
|
1153
|
+
stroke: 1.8
|
|
1154
|
+
}), query ? /* @__PURE__ */ jsx("b", {
|
|
1155
|
+
className: "min-w-0 flex-1 truncate font-normal text-kit-insp-tip-title",
|
|
1156
|
+
children: query
|
|
1157
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
1158
|
+
className: "min-w-0 flex-1 truncate text-kit-group-sub",
|
|
1159
|
+
children: folder ? "Search blocks" : "Search or pick a block"
|
|
1160
|
+
})]
|
|
1161
|
+
}), /* @__PURE__ */ jsx(CatalogList, {
|
|
1162
|
+
sections,
|
|
1163
|
+
flat,
|
|
1164
|
+
active,
|
|
1165
|
+
onHover: setActive,
|
|
1166
|
+
onPick,
|
|
1167
|
+
empty,
|
|
1168
|
+
emptyText,
|
|
1169
|
+
noMatch,
|
|
1170
|
+
detail: true,
|
|
1171
|
+
listId,
|
|
1172
|
+
query,
|
|
1173
|
+
playIcon: aiEntry,
|
|
1174
|
+
className: "min-h-0 flex-1"
|
|
1175
|
+
})]
|
|
1176
|
+
}), /* @__PURE__ */ jsx(SlashPreviewCard, {
|
|
1177
|
+
item: flat[active],
|
|
1178
|
+
top: pvTop
|
|
1179
|
+
})]
|
|
1180
|
+
});
|
|
711
1181
|
return /* @__PURE__ */ jsxs("div", {
|
|
712
1182
|
"data-kit-scope": "",
|
|
713
1183
|
className: "glass-strong flex w-[320px] flex-col overflow-hidden rounded-kit-xl border border-kit-line",
|
|
@@ -743,6 +1213,6 @@ function SlashMenuPanel({ query, folder = false, active, setActive, onPick, allo
|
|
|
743
1213
|
});
|
|
744
1214
|
}
|
|
745
1215
|
//#endregion
|
|
746
|
-
export { CatalogComponentsProvider, CatalogList, InsertMenuContent, SlashMenuPanel, blockAllowed, catalogKey, noteRecent, useCatalog, useCatalogComponents };
|
|
1216
|
+
export { CatalogComponentsProvider, CatalogList, InsertMenuContent, SlashMenuPanel, blockAllowed, catalogKey, hintText, insertCatalog, noteRecent, useCatalog, useCatalogComponents };
|
|
747
1217
|
|
|
748
1218
|
//# sourceMappingURL=catalog.js.map
|