@tightknitai/block-kitchen 0.10.6 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.cjs +167 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +168 -87
- package/dist/index.js.map +1 -1
- package/dist/{palette-QbOx7kAa.d.cts → palette-CvSGn2z6.d.cts} +13 -6
- package/dist/{palette-QbOx7kAa.d.ts → palette-CvSGn2z6.d.ts} +13 -6
- package/dist/palette.cjs +10 -2
- package/dist/palette.cjs.map +1 -1
- package/dist/palette.d.cts +1 -1
- package/dist/palette.d.ts +1 -1
- package/dist/palette.js +10 -2
- package/dist/palette.js.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-
|
|
4
|
-
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-
|
|
3
|
+
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-CvSGn2z6.cjs';
|
|
4
|
+
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-CvSGn2z6.cjs';
|
|
5
5
|
export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.cjs';
|
|
6
6
|
import 'slack-web-api-client';
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-
|
|
4
|
-
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-
|
|
3
|
+
import { B as BlockKitchenProps, S as SupportedBlock, C as ChannelOption, a as SendAsUserStatus, b as SendPayload, c as SendExtrasContext, T as Template, P as PreviewSurface, d as PreviewTheme } from './palette-CvSGn2z6.js';
|
|
4
|
+
export { A as AlertBlock, e as AlertLevel, f as BlockKitchenBaseProps, g as BlockKitchenComposeOnlyProps, h as BlockKitchenSendProps, i as BrandPreset, j as BrandTheme, k as BrandTokens, l as BuilderBlock, m as CardBlock, n as CarouselBlock, o as CartesianChart, p as Chart, q as ChartAxisConfig, r as ChartDataPoint, s as ChartSeries, t as ChartType, u as ContainerBlock, v as ContainerChildBlock, w as ContextActionsBlock, x as ContextActionsElement, y as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, F as FeedbackButtonSubobject, z as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, G as IconButtonIcon, J as InputBlock, L as LoadMessageInput, K as LoadResult, M as LoadedMessage, N as LoadingConfig, O as MarkdownBlock, Q as PaletteMode, R as PaletteSection, U as PaletteVariant, V as PieChart, W as PieChartSegment, X as PlanBlock, Y as PreviewHooks, Z as PrimaryActionConfig, _ as PrimaryActionContext, $ as RecentMessage, a0 as SendResult, a1 as SupportedBlockType, a2 as SupportedHeaderBlock, a3 as TableBlock, a4 as TableCell, a5 as TableColumnSetting, a6 as TaskCardBlock, a7 as TaskCardStatus, a8 as UpdatePayload, a9 as UpdateResult, aa as UrlSourceElement, ab as ValidationSummary, ac as VideoBlock, ad as defaultPalette, ae as extraAlertVariant, af as legacyInputVariants } from './palette-CvSGn2z6.js';
|
|
5
5
|
export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.js';
|
|
6
6
|
import 'slack-web-api-client';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useSensors, useSensor, PointerSensor, TouchSensor, KeyboardSensor, pointerWithin, closestCenter, DndContext, DragOverlay, useDroppable, useDraggable } from '@dnd-kit/core';
|
|
2
2
|
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
3
|
-
import { X, Circle, Sparkles, FileText, AlignLeft, MousePointerClick, TextCursorInput, LayoutTemplate, Bell, Pilcrow, Image, Video, GalleryHorizontal, Table, ChartColumnBig, Container, Loader2, ExternalLink, AlertTriangle, GripVertical, Sun, Moon, MessageSquare, AppWindow, Home, Plus, ChevronDown, BookOpen, Undo2, Redo2, Trash2, Code2, Pencil, Send, Search, Check, Copy, Info, CheckCircle2,
|
|
3
|
+
import { X, Circle, Sparkles, FileText, AlignLeft, MousePointerClick, TextCursorInput, LayoutTemplate, Bell, Pilcrow, Image, Video, GalleryHorizontal, Table, ChartColumnBig, Container, Loader2, ExternalLink, AlertTriangle, ChevronRight, ChevronLeft, GripVertical, Sun, Moon, MessageSquare, AppWindow, Home, Plus, ChevronDown, BookOpen, Undo2, Redo2, Trash2, Code2, Pencil, Send, Search, Check, Copy, Info, CheckCircle2, LayoutGrid, ArrowUp, ArrowDown, Type, Bold, Italic, Strikethrough, Underline, Code, List, ListOrdered, Quote, Smile, Link as Link$1 } from 'lucide-react';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { createContext, useState, useRef, useEffect, useCallback, useMemo, useId, useContext } from 'react';
|
|
6
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
6
|
import { clsx } from 'clsx';
|
|
9
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
10
10
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
11
11
|
import { validateBlockKit, CARD_ACTIONS_MAX } from '@tightknitai/slack-block-kit-validator';
|
|
12
12
|
import { nanoid } from 'nanoid';
|
|
@@ -23,6 +23,9 @@ import { Node, ReactNodeViewRenderer, mergeAttributes, NodeViewWrapper, useEdito
|
|
|
23
23
|
import StarterKit from '@tiptap/starter-kit';
|
|
24
24
|
|
|
25
25
|
// src/components/block-kitchen.tsx
|
|
26
|
+
function cn(...inputs) {
|
|
27
|
+
return twMerge(clsx(inputs));
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
// src/lib/container-blocks.ts
|
|
28
31
|
var CONTAINER_CHILD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -704,6 +707,7 @@ var defaultPalette = [
|
|
|
704
707
|
{
|
|
705
708
|
id: "structure_header",
|
|
706
709
|
label: "Header",
|
|
710
|
+
basic: true,
|
|
707
711
|
factory: () => ({
|
|
708
712
|
type: "header",
|
|
709
713
|
text: { type: "plain_text", text: "Heading text", emoji: true }
|
|
@@ -712,6 +716,7 @@ var defaultPalette = [
|
|
|
712
716
|
{
|
|
713
717
|
id: "structure_divider",
|
|
714
718
|
label: "Divider",
|
|
719
|
+
basic: true,
|
|
715
720
|
factory: () => ({ type: "divider" })
|
|
716
721
|
},
|
|
717
722
|
{
|
|
@@ -819,8 +824,9 @@ var defaultPalette = [
|
|
|
819
824
|
{
|
|
820
825
|
id: "rich_text_section",
|
|
821
826
|
label: "Rich Text Section",
|
|
822
|
-
// The
|
|
823
|
-
//
|
|
827
|
+
// The block a message is mostly made of, and so one of the handful
|
|
828
|
+
// simple mode offers — listed there without its section heading,
|
|
829
|
+
// hence the self-describing label.
|
|
824
830
|
basic: true,
|
|
825
831
|
factory: () => ({
|
|
826
832
|
type: "rich_text",
|
|
@@ -857,6 +863,11 @@ var defaultPalette = [
|
|
|
857
863
|
{
|
|
858
864
|
id: "image_no_title",
|
|
859
865
|
label: "No title",
|
|
866
|
+
// The plain image is the one an ordinary message reaches for, so it
|
|
867
|
+
// carries simple mode's image slot — under its own name there, with
|
|
868
|
+
// no "Image" heading overhead to lend "No title" its meaning.
|
|
869
|
+
basic: true,
|
|
870
|
+
basicLabel: "Image",
|
|
860
871
|
factory: () => ({
|
|
861
872
|
type: "image",
|
|
862
873
|
image_url: "https://placehold.co/600x300?text=Image",
|
|
@@ -1679,9 +1690,6 @@ function labelForBlockType(type) {
|
|
|
1679
1690
|
return "Container";
|
|
1680
1691
|
}
|
|
1681
1692
|
}
|
|
1682
|
-
function cn(...inputs) {
|
|
1683
|
-
return twMerge(clsx(inputs));
|
|
1684
|
-
}
|
|
1685
1693
|
var Sheet = DialogPrimitive.Root;
|
|
1686
1694
|
var SheetOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1687
1695
|
DialogPrimitive.Overlay,
|
|
@@ -3782,14 +3790,14 @@ function isDefaultOpen(sectionName, config) {
|
|
|
3782
3790
|
return config.includes(sectionName);
|
|
3783
3791
|
}
|
|
3784
3792
|
var PALETTE_TITLE = "Message Elements";
|
|
3785
|
-
var ADVANCED_HELP = "Browse every Slack block type \u2014 sections, images, buttons, inputs, tables and more
|
|
3786
|
-
var BASIC_HELP = "Go back to the short list:
|
|
3793
|
+
var ADVANCED_HELP = "Browse every Slack block type \u2014 sections, images, buttons, inputs, tables and more.";
|
|
3794
|
+
var BASIC_HELP = "Go back to the short list: the few blocks an ordinary message is made of.";
|
|
3787
3795
|
function basicVariants(sections) {
|
|
3788
3796
|
const out = [];
|
|
3789
3797
|
for (const section of sections) {
|
|
3790
3798
|
for (const variant of section.variants) {
|
|
3791
3799
|
if (variant.basic) {
|
|
3792
|
-
out.push(variant);
|
|
3800
|
+
out.push(variant.basicLabel ? { ...variant, label: variant.basicLabel } : variant);
|
|
3793
3801
|
}
|
|
3794
3802
|
}
|
|
3795
3803
|
}
|
|
@@ -3818,10 +3826,12 @@ function Palette({
|
|
|
3818
3826
|
showSearch = true,
|
|
3819
3827
|
searchPlaceholder = "Search blocks\u2026",
|
|
3820
3828
|
mode = "advanced",
|
|
3829
|
+
defaultAdvanced = false,
|
|
3830
|
+
onAdvancedChange,
|
|
3821
3831
|
variant = "aside"
|
|
3822
3832
|
}) {
|
|
3823
3833
|
const [query, setQuery] = useState("");
|
|
3824
|
-
const [advancedOpen, setAdvancedOpen] = useState(
|
|
3834
|
+
const [advancedOpen, setAdvancedOpen] = useState(defaultAdvanced);
|
|
3825
3835
|
const [prevMode, setPrevMode] = useState(mode);
|
|
3826
3836
|
if (prevMode !== mode) {
|
|
3827
3837
|
setPrevMode(mode);
|
|
@@ -3843,69 +3853,70 @@ function Palette({
|
|
|
3843
3853
|
{
|
|
3844
3854
|
className: cn(
|
|
3845
3855
|
"flex min-h-0 flex-col overflow-x-hidden overflow-y-auto",
|
|
3846
|
-
isSheet ? "w-full flex-1 bg-background" : "w-
|
|
3856
|
+
isSheet ? "w-full flex-1 bg-background" : "w-56 shrink-0 border-r bg-muted/20"
|
|
3847
3857
|
),
|
|
3848
3858
|
children: [
|
|
3849
|
-
offersSimple || searchVisible ?
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
/* @__PURE__ */ jsx(
|
|
3863
|
-
"span",
|
|
3864
|
-
{
|
|
3865
|
-
className: cn(
|
|
3866
|
-
"min-w-0 truncate font-medium uppercase tracking-wide text-muted-foreground",
|
|
3867
|
-
isSheet ? "text-xs" : "text-[11px]"
|
|
3868
|
-
),
|
|
3869
|
-
children: PALETTE_TITLE
|
|
3870
|
-
}
|
|
3871
|
-
),
|
|
3872
|
-
/* @__PURE__ */ jsx(
|
|
3873
|
-
ModeLink,
|
|
3874
|
-
{
|
|
3875
|
-
advanced,
|
|
3876
|
-
isSheet,
|
|
3877
|
-
onToggle: () => {
|
|
3878
|
-
setQuery("");
|
|
3879
|
-
setAdvancedOpen((v) => !v);
|
|
3880
|
-
}
|
|
3881
|
-
}
|
|
3882
|
-
)
|
|
3883
|
-
] })
|
|
3884
|
-
) : null,
|
|
3885
|
-
searchVisible ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3859
|
+
offersSimple || searchVisible ? (
|
|
3860
|
+
// Two elements so the header is opaque *and* the exact color of the
|
|
3861
|
+
// rail. Painted with the rail's own `bg-muted/20`, it composited over
|
|
3862
|
+
// the scrolled list instead and headings read through the search box
|
|
3863
|
+
// (a `backdrop-blur` softened them, it didn't hide them). Restoring
|
|
3864
|
+
// the `bg-background` base under the tint rebuilds the rail's own two
|
|
3865
|
+
// layers, so the match holds under any theme.
|
|
3866
|
+
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 shrink-0 bg-background", children: /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2 border-b px-3 pt-3 pb-2", isSheet ? "bg-background" : "bg-muted/20"), children: [
|
|
3867
|
+
offersSimple ? (
|
|
3868
|
+
// Titled row: with the sections gone, simple mode's header would
|
|
3869
|
+
// otherwise be a lone right-aligned link over empty space, and
|
|
3870
|
+
// nothing would name what the rail below it holds.
|
|
3871
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
3886
3872
|
/* @__PURE__ */ jsx(
|
|
3887
|
-
|
|
3873
|
+
"span",
|
|
3888
3874
|
{
|
|
3889
3875
|
className: cn(
|
|
3890
|
-
"
|
|
3891
|
-
isSheet ? "
|
|
3892
|
-
)
|
|
3876
|
+
"min-w-0 truncate font-medium uppercase tracking-wide text-muted-foreground",
|
|
3877
|
+
isSheet ? "text-xs" : "text-[11px]"
|
|
3878
|
+
),
|
|
3879
|
+
children: PALETTE_TITLE
|
|
3893
3880
|
}
|
|
3894
3881
|
),
|
|
3895
3882
|
/* @__PURE__ */ jsx(
|
|
3896
|
-
|
|
3883
|
+
ModeLink,
|
|
3897
3884
|
{
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3885
|
+
advanced,
|
|
3886
|
+
isSheet,
|
|
3887
|
+
onToggle: () => {
|
|
3888
|
+
setQuery("");
|
|
3889
|
+
const next = !advancedOpen;
|
|
3890
|
+
setAdvancedOpen(next);
|
|
3891
|
+
onAdvancedChange?.(next);
|
|
3892
|
+
}
|
|
3904
3893
|
}
|
|
3905
3894
|
)
|
|
3906
|
-
] })
|
|
3907
|
-
|
|
3908
|
-
|
|
3895
|
+
] })
|
|
3896
|
+
) : null,
|
|
3897
|
+
searchVisible ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3898
|
+
/* @__PURE__ */ jsx(
|
|
3899
|
+
Search,
|
|
3900
|
+
{
|
|
3901
|
+
className: cn(
|
|
3902
|
+
"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground",
|
|
3903
|
+
isSheet ? "h-4 w-4" : "h-3.5 w-3.5"
|
|
3904
|
+
)
|
|
3905
|
+
}
|
|
3906
|
+
),
|
|
3907
|
+
/* @__PURE__ */ jsx(
|
|
3908
|
+
Input,
|
|
3909
|
+
{
|
|
3910
|
+
type: "search",
|
|
3911
|
+
value: query,
|
|
3912
|
+
onChange: (e) => setQuery(e.target.value),
|
|
3913
|
+
placeholder: searchPlaceholder,
|
|
3914
|
+
"aria-label": searchPlaceholder,
|
|
3915
|
+
className: cn(isSheet ? "h-10 pl-8 text-base" : "h-8 pl-7 text-sm")
|
|
3916
|
+
}
|
|
3917
|
+
)
|
|
3918
|
+
] }) : null
|
|
3919
|
+
] }) })
|
|
3909
3920
|
) : null,
|
|
3910
3921
|
/* @__PURE__ */ jsx("div", { className: cn("flex flex-col", isSheet ? "px-2 pb-6" : "p-3"), children: !advanced ? (
|
|
3911
3922
|
// Simple mode: a flat list, no section headings — with this few
|
|
@@ -4005,8 +4016,8 @@ function PaletteItem({
|
|
|
4005
4016
|
isDragging && "opacity-50"
|
|
4006
4017
|
),
|
|
4007
4018
|
children: [
|
|
4008
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
4009
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
4019
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: variant.label }),
|
|
4020
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground transition-colors group-hover:bg-primary/10 group-hover:text-primary", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
|
|
4010
4021
|
]
|
|
4011
4022
|
}
|
|
4012
4023
|
);
|
|
@@ -4016,7 +4027,7 @@ function PaletteItem({
|
|
|
4016
4027
|
{
|
|
4017
4028
|
ref: setNodeRef,
|
|
4018
4029
|
className: cn(
|
|
4019
|
-
"group flex items-center gap-2 rounded px-2 py-1
|
|
4030
|
+
"group flex items-center gap-2 rounded px-2 py-1 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground has-[:focus-visible]:bg-accent has-[:focus-visible]:text-foreground",
|
|
4020
4031
|
isDragging && "opacity-50"
|
|
4021
4032
|
),
|
|
4022
4033
|
children: [
|
|
@@ -4024,7 +4035,7 @@ function PaletteItem({
|
|
|
4024
4035
|
"div",
|
|
4025
4036
|
{
|
|
4026
4037
|
ref: setActivatorNodeRef,
|
|
4027
|
-
className: "-my-1
|
|
4038
|
+
className: "-my-1 flex min-w-0 flex-1 cursor-grab items-center gap-2 rounded py-1 active:cursor-grabbing focus-visible:outline-none",
|
|
4028
4039
|
...attributes,
|
|
4029
4040
|
...listeners,
|
|
4030
4041
|
children: [
|
|
@@ -10001,7 +10012,7 @@ function Toolbar2({
|
|
|
10001
10012
|
variant: "ghost",
|
|
10002
10013
|
size: "sm",
|
|
10003
10014
|
onClick: onOpenPalette,
|
|
10004
|
-
className: "md:hidden",
|
|
10015
|
+
className: "gap-1 md:hidden",
|
|
10005
10016
|
"aria-label": "Add a block",
|
|
10006
10017
|
children: [
|
|
10007
10018
|
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
@@ -10121,18 +10132,29 @@ function Toolbar2({
|
|
|
10121
10132
|
size: "sm",
|
|
10122
10133
|
onClick: onClear,
|
|
10123
10134
|
disabled: !canClear,
|
|
10124
|
-
className: "hover:bg-destructive/10 hover:text-destructive",
|
|
10135
|
+
className: "group gap-0 hover:bg-destructive/10 hover:text-destructive",
|
|
10125
10136
|
"aria-label": "Clear all blocks",
|
|
10126
10137
|
children: [
|
|
10127
10138
|
/* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" }),
|
|
10128
|
-
/* @__PURE__ */ jsx(
|
|
10139
|
+
/* @__PURE__ */ jsx(ExpandingLabel, { children: "Clear" })
|
|
10140
|
+
]
|
|
10141
|
+
}
|
|
10142
|
+
),
|
|
10143
|
+
/* @__PURE__ */ jsxs(
|
|
10144
|
+
Button,
|
|
10145
|
+
{
|
|
10146
|
+
type: "button",
|
|
10147
|
+
variant: "ghost",
|
|
10148
|
+
size: "sm",
|
|
10149
|
+
onClick: onOpenJson,
|
|
10150
|
+
className: "group gap-0",
|
|
10151
|
+
"aria-label": "View JSON",
|
|
10152
|
+
children: [
|
|
10153
|
+
/* @__PURE__ */ jsx(Code2, { className: "h-3.5 w-3.5" }),
|
|
10154
|
+
/* @__PURE__ */ jsx(ExpandingLabel, { children: "View JSON" })
|
|
10129
10155
|
]
|
|
10130
10156
|
}
|
|
10131
10157
|
),
|
|
10132
|
-
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: onOpenJson, "aria-label": "View JSON", children: [
|
|
10133
|
-
/* @__PURE__ */ jsx(Code2, { className: "h-3.5 w-3.5" }),
|
|
10134
|
-
/* @__PURE__ */ jsx("span", { className: "hidden md:inline", children: "View JSON" })
|
|
10135
|
-
] }),
|
|
10136
10158
|
!showSend ? primaryAction ? (
|
|
10137
10159
|
// Compose-only mode with a host-owned primary action: same
|
|
10138
10160
|
// placement and styling as the built-in send button. No icon —
|
|
@@ -10242,6 +10264,19 @@ function Toolbar2({
|
|
|
10242
10264
|
] }) : null
|
|
10243
10265
|
] });
|
|
10244
10266
|
}
|
|
10267
|
+
function ExpandingLabel({ children }) {
|
|
10268
|
+
return /* @__PURE__ */ jsx(
|
|
10269
|
+
"span",
|
|
10270
|
+
{
|
|
10271
|
+
className: cn(
|
|
10272
|
+
"grid grid-cols-[0fr] transition-[grid-template-columns] duration-200 ease-out",
|
|
10273
|
+
"group-hover:grid-cols-[1fr] group-focus-visible:grid-cols-[1fr]",
|
|
10274
|
+
"motion-reduce:transition-none"
|
|
10275
|
+
),
|
|
10276
|
+
children: /* @__PURE__ */ jsx("span", { className: "overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "block whitespace-nowrap pl-1.5", children }) })
|
|
10277
|
+
}
|
|
10278
|
+
);
|
|
10279
|
+
}
|
|
10245
10280
|
function Menu({
|
|
10246
10281
|
ariaLabel,
|
|
10247
10282
|
options,
|
|
@@ -10533,12 +10568,20 @@ function BlockKitchen(props) {
|
|
|
10533
10568
|
useNotifyOnChange(activeEditTarget, loadedMessageKey, loading?.onLoadedMessageChange);
|
|
10534
10569
|
const [issuesOpen, setIssuesOpen] = useState(false);
|
|
10535
10570
|
const [paletteOpen, setPaletteOpen] = useState(false);
|
|
10571
|
+
const [paletteCollapsed, setPaletteCollapsed] = useState(false);
|
|
10572
|
+
const [paletteAdvanced, setPaletteAdvanced] = useState(false);
|
|
10573
|
+
const [prevPaletteMode, setPrevPaletteMode] = useState(paletteMode);
|
|
10574
|
+
if (prevPaletteMode !== paletteMode) {
|
|
10575
|
+
setPrevPaletteMode(paletteMode);
|
|
10576
|
+
setPaletteAdvanced(false);
|
|
10577
|
+
}
|
|
10536
10578
|
const [openBlockId, setOpenBlockId] = useState(null);
|
|
10537
10579
|
const [uncontrolledPreviewTheme, setUncontrolledPreviewTheme] = useState(defaultPreviewTheme);
|
|
10538
10580
|
const isPreviewThemeControlled = controlledPreviewTheme !== void 0;
|
|
10539
10581
|
const previewTheme = controlledPreviewTheme ?? uncontrolledPreviewTheme;
|
|
10540
10582
|
const [previewSurface, setPreviewSurface] = useState(allowedSurfaces[0]);
|
|
10541
10583
|
const [activePaletteVariantId, setActivePaletteVariantId] = useState(null);
|
|
10584
|
+
const paletteSheetRef = useRef(null);
|
|
10542
10585
|
const isMobile = useIsMobile();
|
|
10543
10586
|
const mergedPreviewHooks = useMemo(() => {
|
|
10544
10587
|
if (!customEmojis || customEmojis.length === 0) {
|
|
@@ -10664,7 +10707,7 @@ function BlockKitchen(props) {
|
|
|
10664
10707
|
/* @__PURE__ */ jsxs(
|
|
10665
10708
|
"div",
|
|
10666
10709
|
{
|
|
10667
|
-
className: "bk-root flex h-full w-full flex-col overflow-hidden rounded-md border bg-background text-foreground",
|
|
10710
|
+
className: "bk-root flex h-full max-h-[var(--bk-max-height,100svh)] w-full flex-col overflow-hidden rounded-md border bg-background text-foreground",
|
|
10668
10711
|
onKeyDown: handleKeyDown,
|
|
10669
10712
|
children: [
|
|
10670
10713
|
/* @__PURE__ */ jsx(
|
|
@@ -10722,17 +10765,48 @@ function BlockKitchen(props) {
|
|
|
10722
10765
|
}
|
|
10723
10766
|
),
|
|
10724
10767
|
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 items-stretch", children: [
|
|
10725
|
-
/* @__PURE__ */
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10768
|
+
/* @__PURE__ */ jsxs("div", { className: "relative hidden min-h-0 shrink-0 md:flex", children: [
|
|
10769
|
+
/* @__PURE__ */ jsx("div", { hidden: paletteCollapsed, className: cn("min-h-0", !paletteCollapsed && "flex"), children: /* @__PURE__ */ jsx(
|
|
10770
|
+
Palette,
|
|
10771
|
+
{
|
|
10772
|
+
onAddBlock: (block) => addBlock(block),
|
|
10773
|
+
sections: paletteSections,
|
|
10774
|
+
mode: paletteMode,
|
|
10775
|
+
showSearch: showPaletteSearch,
|
|
10776
|
+
searchPlaceholder: paletteSearchPlaceholder,
|
|
10777
|
+
defaultOpenSections,
|
|
10778
|
+
defaultAdvanced: paletteAdvanced,
|
|
10779
|
+
onAdvancedChange: setPaletteAdvanced
|
|
10780
|
+
}
|
|
10781
|
+
) }),
|
|
10782
|
+
paletteCollapsed ? (
|
|
10783
|
+
// In a host that hands the builder no height of its own,
|
|
10784
|
+
// the rail is what the shell takes its height from (see
|
|
10785
|
+
// the shell's `max-h` note above) — so hiding it would
|
|
10786
|
+
// shrink the whole frame to the height of the message and
|
|
10787
|
+
// grow it back on the way out. This stands in for the rail
|
|
10788
|
+
// at no width. Inert to everything but layout.
|
|
10789
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: "w-0 shrink-0 md:h-[var(--bk-max-height,100svh)]" })
|
|
10790
|
+
) : null,
|
|
10791
|
+
/* @__PURE__ */ jsx(
|
|
10792
|
+
"button",
|
|
10793
|
+
{
|
|
10794
|
+
type: "button",
|
|
10795
|
+
onClick: () => setPaletteCollapsed((v) => !v),
|
|
10796
|
+
"aria-expanded": !paletteCollapsed,
|
|
10797
|
+
"aria-label": paletteCollapsed ? "Show block palette" : "Hide block palette",
|
|
10798
|
+
title: paletteCollapsed ? "Show block palette" : "Hide block palette",
|
|
10799
|
+
className: cn(
|
|
10800
|
+
// A hairline outline in the rail's own border color, so
|
|
10801
|
+
// the handle reads as part of the edge it rides rather
|
|
10802
|
+
// than a chevron floating loose over the border line.
|
|
10803
|
+
"absolute top-1/2 z-10 flex h-10 w-4 -translate-y-1/2 cursor-pointer appearance-none items-center justify-center rounded-sm border bg-background p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
10804
|
+
paletteCollapsed ? "left-0" : "right-0 translate-x-1/2"
|
|
10805
|
+
),
|
|
10806
|
+
children: paletteCollapsed ? /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4", strokeWidth: 1.5 }) : /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4", strokeWidth: 1.5 })
|
|
10807
|
+
}
|
|
10808
|
+
)
|
|
10809
|
+
] }),
|
|
10736
10810
|
/* @__PURE__ */ jsx(
|
|
10737
10811
|
Surface,
|
|
10738
10812
|
{
|
|
@@ -10765,8 +10839,13 @@ function BlockKitchen(props) {
|
|
|
10765
10839
|
/* @__PURE__ */ jsx(Sheet, { open: paletteOpen && isMobile, onOpenChange: setPaletteOpen, children: /* @__PURE__ */ jsxs(
|
|
10766
10840
|
SheetContent,
|
|
10767
10841
|
{
|
|
10842
|
+
ref: paletteSheetRef,
|
|
10768
10843
|
side: "bottom",
|
|
10769
10844
|
className: "bk-portal-content flex h-[85svh] max-h-[85svh] flex-col gap-3 p-0 sm:max-w-none",
|
|
10845
|
+
onOpenAutoFocus: (e) => {
|
|
10846
|
+
e.preventDefault();
|
|
10847
|
+
paletteSheetRef.current?.focus();
|
|
10848
|
+
},
|
|
10770
10849
|
children: [
|
|
10771
10850
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 px-4 pt-5", children: [
|
|
10772
10851
|
/* @__PURE__ */ jsx(SheetTitle, { children: "Add a block" }),
|
|
@@ -10784,6 +10863,8 @@ function BlockKitchen(props) {
|
|
|
10784
10863
|
showSearch: showPaletteSearch,
|
|
10785
10864
|
searchPlaceholder: paletteSearchPlaceholder,
|
|
10786
10865
|
defaultOpenSections,
|
|
10866
|
+
defaultAdvanced: paletteAdvanced,
|
|
10867
|
+
onAdvancedChange: setPaletteAdvanced,
|
|
10787
10868
|
variant: "sheet"
|
|
10788
10869
|
}
|
|
10789
10870
|
) })
|