@tightknitai/block-kitchen 0.10.24 → 0.10.26

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.
@@ -99,6 +99,35 @@ interface PaletteVariant {
99
99
  * mode, and unnecessary for a variant whose label already stands alone.
100
100
  */
101
101
  basicLabel?: string;
102
+ /**
103
+ * A short tag shown beside the label, e.g. the plan a block belongs to
104
+ * ("Enterprise"). Shown whether or not the variant is `locked`.
105
+ */
106
+ badge?: PaletteVariantBadge;
107
+ /**
108
+ * Shows the variant without letting anyone add it: it can't be dragged,
109
+ * and it has no add button. Use it to show a block the user's plan doesn't
110
+ * include, alongside a `badge` saying which one does. Picking it calls
111
+ * `onLockedSelect`.
112
+ */
113
+ locked?: boolean;
114
+ /**
115
+ * Called when the user picks a `locked` variant, e.g. to open an upgrade
116
+ * prompt. Without it a locked variant is inert.
117
+ */
118
+ onLockedSelect?: () => void;
119
+ }
120
+ /** A tag shown beside a palette variant's label. See {@link PaletteVariant.badge}. */
121
+ interface PaletteVariantBadge {
122
+ /** Visible text, e.g. `'Enterprise'`. */
123
+ label: string;
124
+ /** Optional icon shown before the text, e.g. a Lucide icon component. */
125
+ icon?: ComponentType<SVGProps<SVGSVGElement>>;
126
+ /**
127
+ * Extra classes for the tag, merged over its defaults (conflicting Tailwind
128
+ * classes win), so it can match the host's own plan badges.
129
+ */
130
+ className?: string;
102
131
  }
103
132
  /**
104
133
  * One section in the palette. Sections group related variants under a
@@ -757,6 +786,36 @@ interface BlockAction {
757
786
  /** Called with the block's position when the button is clicked. */
758
787
  onSelect: (position: BlockPosition) => void;
759
788
  }
789
+ /** What a {@link CustomBlockEditor}'s component is rendered with. */
790
+ interface CustomBlockEditorProps {
791
+ /** The block being edited. */
792
+ block: SupportedBlock;
793
+ /**
794
+ * Replaces the block. The result must still be ordinary Block Kit: it is
795
+ * previewed, validated and sent like any other block.
796
+ */
797
+ onChange: (next: SupportedBlock) => void;
798
+ }
799
+ /**
800
+ * A host-owned form for blocks your app gives a meaning of its own, e.g. a
801
+ * "Share on LinkedIn" button whose URL is built from the post text. It
802
+ * replaces the built-in form in the block's edit popover. The block itself
803
+ * stays ordinary Block Kit, so preview, validation and sending don't change.
804
+ */
805
+ interface CustomBlockEditor {
806
+ /** Stable identifier. */
807
+ id: string;
808
+ /** Names the block in the editor's heading, e.g. "Edit Share on LinkedIn". */
809
+ label: string;
810
+ /**
811
+ * Whether this editor handles a block; the first match wins. Match on what
812
+ * the block itself holds (a URL, an `action_id`): a message loaded back
813
+ * from Slack carries nothing else.
814
+ */
815
+ match: (block: SupportedBlock) => boolean;
816
+ /** The form. Rendered as a component, so it can use hooks. */
817
+ component: ComponentType<CustomBlockEditorProps>;
818
+ }
760
819
  /**
761
820
  * A host-owned primary action for compose-only mode, rendered in the
762
821
  * toolbar slot where the built-in "Review & send" button normally sits.
@@ -1168,6 +1227,12 @@ interface BlockKitchenBaseProps {
1168
1227
  * {@link BlockPosition}); return `null` for a block with nothing to show.
1169
1228
  */
1170
1229
  renderBlockAdornment?: (position: BlockPosition) => ReactNode;
1230
+ /**
1231
+ * Opt-in host forms that replace the built-in editor for the blocks they
1232
+ * match. See {@link CustomBlockEditor}. Expected to be referentially
1233
+ * stable across renders (define at module scope or wrap in `useMemo`).
1234
+ */
1235
+ blockEditors?: readonly CustomBlockEditor[];
1171
1236
  /**
1172
1237
  * Workspace custom emoji (`emoji.list`) the preview should resolve. Entries
1173
1238
  * with a non-null `url` render as the workspace image; alias entries fall
@@ -1318,6 +1383,14 @@ interface BlockKitchenBaseProps {
1318
1383
  href?: string;
1319
1384
  label?: string;
1320
1385
  };
1386
+ /**
1387
+ * Whether Ctrl/Cmd+Z undoes and Ctrl/Cmd+Shift+Z (or Ctrl+Y) redoes, like
1388
+ * the toolbar's Undo / Redo buttons. Defaults to `true`. They act while
1389
+ * focus is in the builder, or while nothing on the page has focus and the
1390
+ * last click landed in the builder, and never in a text field. Pass `false`
1391
+ * to leave those keys entirely to the host.
1392
+ */
1393
+ undoRedoShortcuts?: boolean;
1321
1394
  /**
1322
1395
  * Initial preview theme (uncontrolled). Defaults to `'light'`. Pass the
1323
1396
  * host app's current theme (e.g. from `next-themes` or your own theme
@@ -1468,4 +1541,4 @@ interface BlockKitchenComposeOnlyProps {
1468
1541
  */
1469
1542
  type BlockKitchenProps = BlockKitchenBaseProps & (BlockKitchenSendProps | BlockKitchenComposeOnlyProps);
1470
1543
 
1471
- export { type PaletteMode as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomEmoji as D, type DataTableActionCell as E, type DataTableBlock as F, type DataTableCell as G, type DataTableRawNumberCell as H, type DataVisualizationBlock as I, type EditableVia as J, type FeedbackButtonSubobject as K, type FeedbackButtonsElement as L, type HeaderLevel as M, type IconButtonElement as N, type IconButtonIcon as O, type PreviewSurface as P, type InputBlock as Q, type LoadMessageInput as R, type SupportedBlock as S, type Template as T, type LoadResult as U, type LoadedMessage as V, type LoadingConfig as W, type MarkdownBlock as X, type MentionChannel as Y, type MentionUser as Z, type MentionsConfig as _, type SendAsUserStatus as a, type PaletteSection as a0, type PaletteVariant as a1, type PieChart as a2, type PieChartSegment as a3, type PlanBlock as a4, type PreviewHooks as a5, type PrimaryActionConfig as a6, type PrimaryActionContext as a7, type RecentMessage as a8, type SendResult as a9, type SupportedBlockType as aa, type SupportedHeaderBlock as ab, type TableBlock as ac, type TableCell as ad, type TableColumnSetting as ae, type TableRawTextCell as af, type TaskCardBlock as ag, type TaskCardStatus as ah, type UpdatePayload as ai, type UpdateResult as aj, type UrlSourceElement as ak, type ValidationSummary as al, type VideoBlock as am, defaultPalette as an, extraAlertVariant as ao, legacyInputVariants as ap, buildVariantById as aq, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };
1544
+ export { type MentionUser as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomBlockEditor as D, type CustomBlockEditorProps as E, type CustomEmoji as F, type DataTableActionCell as G, type DataTableBlock as H, type DataTableCell as I, type DataTableRawNumberCell as J, type DataVisualizationBlock as K, type EditableVia as L, type FeedbackButtonSubobject as M, type FeedbackButtonsElement as N, type HeaderLevel as O, type PreviewSurface as P, type IconButtonElement as Q, type IconButtonIcon as R, type SupportedBlock as S, type Template as T, type InputBlock as U, type LoadMessageInput as V, type LoadResult as W, type LoadedMessage as X, type LoadingConfig as Y, type MarkdownBlock as Z, type MentionChannel as _, type SendAsUserStatus as a, type MentionsConfig as a0, type PaletteMode as a1, type PaletteSection as a2, type PaletteVariant as a3, type PaletteVariantBadge as a4, type PieChart as a5, type PieChartSegment as a6, type PlanBlock as a7, type PreviewHooks as a8, type PrimaryActionConfig as a9, type PrimaryActionContext as aa, type RecentMessage as ab, type SendResult as ac, type SupportedBlockType as ad, type SupportedHeaderBlock as ae, type TableBlock as af, type TableCell as ag, type TableColumnSetting as ah, type TableRawTextCell as ai, type TaskCardBlock as aj, type TaskCardStatus as ak, type UpdatePayload as al, type UpdateResult as am, type UrlSourceElement as an, type ValidationSummary as ao, type VideoBlock as ap, defaultPalette as aq, extraAlertVariant as ar, legacyInputVariants as as, buildVariantById as at, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };
@@ -99,6 +99,35 @@ interface PaletteVariant {
99
99
  * mode, and unnecessary for a variant whose label already stands alone.
100
100
  */
101
101
  basicLabel?: string;
102
+ /**
103
+ * A short tag shown beside the label, e.g. the plan a block belongs to
104
+ * ("Enterprise"). Shown whether or not the variant is `locked`.
105
+ */
106
+ badge?: PaletteVariantBadge;
107
+ /**
108
+ * Shows the variant without letting anyone add it: it can't be dragged,
109
+ * and it has no add button. Use it to show a block the user's plan doesn't
110
+ * include, alongside a `badge` saying which one does. Picking it calls
111
+ * `onLockedSelect`.
112
+ */
113
+ locked?: boolean;
114
+ /**
115
+ * Called when the user picks a `locked` variant, e.g. to open an upgrade
116
+ * prompt. Without it a locked variant is inert.
117
+ */
118
+ onLockedSelect?: () => void;
119
+ }
120
+ /** A tag shown beside a palette variant's label. See {@link PaletteVariant.badge}. */
121
+ interface PaletteVariantBadge {
122
+ /** Visible text, e.g. `'Enterprise'`. */
123
+ label: string;
124
+ /** Optional icon shown before the text, e.g. a Lucide icon component. */
125
+ icon?: ComponentType<SVGProps<SVGSVGElement>>;
126
+ /**
127
+ * Extra classes for the tag, merged over its defaults (conflicting Tailwind
128
+ * classes win), so it can match the host's own plan badges.
129
+ */
130
+ className?: string;
102
131
  }
103
132
  /**
104
133
  * One section in the palette. Sections group related variants under a
@@ -757,6 +786,36 @@ interface BlockAction {
757
786
  /** Called with the block's position when the button is clicked. */
758
787
  onSelect: (position: BlockPosition) => void;
759
788
  }
789
+ /** What a {@link CustomBlockEditor}'s component is rendered with. */
790
+ interface CustomBlockEditorProps {
791
+ /** The block being edited. */
792
+ block: SupportedBlock;
793
+ /**
794
+ * Replaces the block. The result must still be ordinary Block Kit: it is
795
+ * previewed, validated and sent like any other block.
796
+ */
797
+ onChange: (next: SupportedBlock) => void;
798
+ }
799
+ /**
800
+ * A host-owned form for blocks your app gives a meaning of its own, e.g. a
801
+ * "Share on LinkedIn" button whose URL is built from the post text. It
802
+ * replaces the built-in form in the block's edit popover. The block itself
803
+ * stays ordinary Block Kit, so preview, validation and sending don't change.
804
+ */
805
+ interface CustomBlockEditor {
806
+ /** Stable identifier. */
807
+ id: string;
808
+ /** Names the block in the editor's heading, e.g. "Edit Share on LinkedIn". */
809
+ label: string;
810
+ /**
811
+ * Whether this editor handles a block; the first match wins. Match on what
812
+ * the block itself holds (a URL, an `action_id`): a message loaded back
813
+ * from Slack carries nothing else.
814
+ */
815
+ match: (block: SupportedBlock) => boolean;
816
+ /** The form. Rendered as a component, so it can use hooks. */
817
+ component: ComponentType<CustomBlockEditorProps>;
818
+ }
760
819
  /**
761
820
  * A host-owned primary action for compose-only mode, rendered in the
762
821
  * toolbar slot where the built-in "Review & send" button normally sits.
@@ -1168,6 +1227,12 @@ interface BlockKitchenBaseProps {
1168
1227
  * {@link BlockPosition}); return `null` for a block with nothing to show.
1169
1228
  */
1170
1229
  renderBlockAdornment?: (position: BlockPosition) => ReactNode;
1230
+ /**
1231
+ * Opt-in host forms that replace the built-in editor for the blocks they
1232
+ * match. See {@link CustomBlockEditor}. Expected to be referentially
1233
+ * stable across renders (define at module scope or wrap in `useMemo`).
1234
+ */
1235
+ blockEditors?: readonly CustomBlockEditor[];
1171
1236
  /**
1172
1237
  * Workspace custom emoji (`emoji.list`) the preview should resolve. Entries
1173
1238
  * with a non-null `url` render as the workspace image; alias entries fall
@@ -1318,6 +1383,14 @@ interface BlockKitchenBaseProps {
1318
1383
  href?: string;
1319
1384
  label?: string;
1320
1385
  };
1386
+ /**
1387
+ * Whether Ctrl/Cmd+Z undoes and Ctrl/Cmd+Shift+Z (or Ctrl+Y) redoes, like
1388
+ * the toolbar's Undo / Redo buttons. Defaults to `true`. They act while
1389
+ * focus is in the builder, or while nothing on the page has focus and the
1390
+ * last click landed in the builder, and never in a text field. Pass `false`
1391
+ * to leave those keys entirely to the host.
1392
+ */
1393
+ undoRedoShortcuts?: boolean;
1321
1394
  /**
1322
1395
  * Initial preview theme (uncontrolled). Defaults to `'light'`. Pass the
1323
1396
  * host app's current theme (e.g. from `next-themes` or your own theme
@@ -1468,4 +1541,4 @@ interface BlockKitchenComposeOnlyProps {
1468
1541
  */
1469
1542
  type BlockKitchenProps = BlockKitchenBaseProps & (BlockKitchenSendProps | BlockKitchenComposeOnlyProps);
1470
1543
 
1471
- export { type PaletteMode as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomEmoji as D, type DataTableActionCell as E, type DataTableBlock as F, type DataTableCell as G, type DataTableRawNumberCell as H, type DataVisualizationBlock as I, type EditableVia as J, type FeedbackButtonSubobject as K, type FeedbackButtonsElement as L, type HeaderLevel as M, type IconButtonElement as N, type IconButtonIcon as O, type PreviewSurface as P, type InputBlock as Q, type LoadMessageInput as R, type SupportedBlock as S, type Template as T, type LoadResult as U, type LoadedMessage as V, type LoadingConfig as W, type MarkdownBlock as X, type MentionChannel as Y, type MentionUser as Z, type MentionsConfig as _, type SendAsUserStatus as a, type PaletteSection as a0, type PaletteVariant as a1, type PieChart as a2, type PieChartSegment as a3, type PlanBlock as a4, type PreviewHooks as a5, type PrimaryActionConfig as a6, type PrimaryActionContext as a7, type RecentMessage as a8, type SendResult as a9, type SupportedBlockType as aa, type SupportedHeaderBlock as ab, type TableBlock as ac, type TableCell as ad, type TableColumnSetting as ae, type TableRawTextCell as af, type TaskCardBlock as ag, type TaskCardStatus as ah, type UpdatePayload as ai, type UpdateResult as aj, type UrlSourceElement as ak, type ValidationSummary as al, type VideoBlock as am, defaultPalette as an, extraAlertVariant as ao, legacyInputVariants as ap, buildVariantById as aq, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };
1544
+ export { type MentionUser as $, type AlertBlock as A, type BlockKitchenProps as B, type ChannelOption as C, type CustomBlockEditor as D, type CustomBlockEditorProps as E, type CustomEmoji as F, type DataTableActionCell as G, type DataTableBlock as H, type DataTableCell as I, type DataTableRawNumberCell as J, type DataVisualizationBlock as K, type EditableVia as L, type FeedbackButtonSubobject as M, type FeedbackButtonsElement as N, type HeaderLevel as O, type PreviewSurface as P, type IconButtonElement as Q, type IconButtonIcon as R, type SupportedBlock as S, type Template as T, type InputBlock as U, type LoadMessageInput as V, type LoadResult as W, type LoadedMessage as X, type LoadingConfig as Y, type MarkdownBlock as Z, type MentionChannel as _, type SendAsUserStatus as a, type MentionsConfig as a0, type PaletteMode as a1, type PaletteSection as a2, type PaletteVariant as a3, type PaletteVariantBadge as a4, type PieChart as a5, type PieChartSegment as a6, type PlanBlock as a7, type PreviewHooks as a8, type PrimaryActionConfig as a9, type PrimaryActionContext as aa, type RecentMessage as ab, type SendResult as ac, type SupportedBlockType as ad, type SupportedHeaderBlock as ae, type TableBlock as af, type TableCell as ag, type TableColumnSetting as ah, type TableRawTextCell as ai, type TaskCardBlock as aj, type TaskCardStatus as ak, type UpdatePayload as al, type UpdateResult as am, type UrlSourceElement as an, type ValidationSummary as ao, type VideoBlock as ap, defaultPalette as aq, extraAlertVariant as ar, legacyInputVariants as as, buildVariantById as at, type SendPayload as b, type SendExtrasContext as c, type PreviewTheme as d, type AlertLevel as e, type BlockAction as f, type BlockKitchenBaseProps as g, type BlockKitchenComposeOnlyProps as h, type BlockKitchenSendProps as i, type BlockPosition as j, type BrandPreset as k, type BrandTheme as l, type BrandTokens as m, type BuilderBlock as n, type CardBlock as o, type CarouselBlock as p, type CartesianChart as q, type Chart as r, type ChartAxisConfig as s, type ChartDataPoint as t, type ChartSeries as u, type ChartType as v, type ContainerBlock as w, type ContainerChildBlock as x, type ContextActionsBlock as y, type ContextActionsElement as z };