@tightknitai/block-kitchen 0.8.9 → 0.8.11

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.
@@ -580,6 +580,125 @@ interface SendResult {
580
580
  ok: boolean;
581
581
  error?: string;
582
582
  }
583
+ /**
584
+ * Which token can edit a loaded message, as computed by the host.
585
+ * `chat.update` only edits a message authored by the calling token:
586
+ * - `'bot'` — the message was posted by this app; edit via the bot token.
587
+ * - `'user'` — the message was posted by the current user; edit via their
588
+ * user token (gated behind {@link BlockKitchenProps.loadSendAsUserStatus}).
589
+ */
590
+ type EditableVia = 'bot' | 'user';
591
+ /**
592
+ * Input passed to {@link EditingConfig.onLoadMessage}. The user pastes a
593
+ * Slack message permalink (Slack's "Copy link"); the host parses
594
+ * `channel + ts` out of it — the package never touches raw timestamps.
595
+ */
596
+ interface LoadMessageInput {
597
+ link: string;
598
+ }
599
+ /**
600
+ * Result of loading an existing message for editing, computed by the host.
601
+ *
602
+ * On `ok`, the package enters edit mode: it hydrates the editor with
603
+ * `blocks`, locks the destination to `channelId`, and constrains the
604
+ * post-as identity to `editableVia`.
605
+ *
606
+ * On `!ok`, the package renders the host's `reason` inline and offers
607
+ * "Open as a new message instead". If the message round-trips through the
608
+ * block editor (e.g. someone else's block message), the host may include
609
+ * `blocks` so that fallback can hydrate the draft; for non-block or
610
+ * attachment-only messages, omit it.
611
+ */
612
+ type LoadResult = {
613
+ ok: true;
614
+ channelId: string;
615
+ /** Channel name for the edit-mode badge (display only). Falls back to `channelId`. */
616
+ channelName?: string;
617
+ ts: string;
618
+ blocks: SupportedBlock[];
619
+ editableVia: EditableVia;
620
+ workspaceName?: string;
621
+ /**
622
+ * Display name of the existing message's author. When provided, the
623
+ * preview header shows it instead of `workspaceName`. Optional.
624
+ */
625
+ username?: string;
626
+ /**
627
+ * Avatar image URL of the existing message's author, shown in the
628
+ * preview header. Optional; ignored if it isn't a safe `http(s)` URL.
629
+ */
630
+ iconUrl?: string;
631
+ } | {
632
+ ok: false;
633
+ reason: string;
634
+ blocks?: SupportedBlock[];
635
+ };
636
+ /**
637
+ * Payload passed to {@link EditingConfig.onUpdate}. Sibling to
638
+ * {@link SendPayload} but carries the source `channel + ts`. `chat.update`
639
+ * requires re-sending the full blocks payload (no partial update).
640
+ */
641
+ interface UpdatePayload {
642
+ channelId: string;
643
+ ts: string;
644
+ blocks: SupportedBlock[];
645
+ asUser: boolean;
646
+ }
647
+ /**
648
+ * Result returned from {@link EditingConfig.onUpdate}. Mirrors
649
+ * {@link SendResult}; `error` is rendered as-is.
650
+ */
651
+ interface UpdateResult {
652
+ ok: boolean;
653
+ error?: string;
654
+ }
655
+ /**
656
+ * One entry in the "recent messages from this app" picker, returned by
657
+ * {@link EditingConfig.loadRecentMessages}. These are editable-by-construction
658
+ * — the app authored them — so they load straight into edit mode without a
659
+ * separate verdict round-trip. `editableVia` defaults to `'bot'` when omitted.
660
+ */
661
+ interface RecentMessage {
662
+ channelId: string;
663
+ /** Channel name for display + the edit-mode badge. Falls back to `channelId`. */
664
+ channelName?: string;
665
+ ts: string;
666
+ blocks: SupportedBlock[];
667
+ editableVia?: EditableVia;
668
+ /** Short preview shown in the picker row (e.g. the first line of the message). */
669
+ label?: string;
670
+ workspaceName?: string;
671
+ /** Display name of the message's author; shown in the preview header. Optional. */
672
+ username?: string;
673
+ /** Avatar image URL shown in the preview header. Optional; ignored unless a safe `http(s)` URL. */
674
+ iconUrl?: string;
675
+ }
676
+ /**
677
+ * Opt-in edit-mode configuration. Presence of {@link BlockKitchenProps.editing}
678
+ * enables loading an existing message and dispatching an update; omit it to
679
+ * keep the send-only behavior. The package stays integration-agnostic — it
680
+ * makes no network calls and has no Slack-token knowledge; the host brokers
681
+ * I/O and computes the editability verdict.
682
+ */
683
+ interface EditingConfig {
684
+ /**
685
+ * Host parses the pasted permalink, fetches the message, and returns a
686
+ * host-computed editability verdict plus blocks. See {@link LoadResult}.
687
+ */
688
+ onLoadMessage: (input: LoadMessageInput) => Promise<LoadResult>;
689
+ /**
690
+ * Dispatches the update for the loaded message. Sibling to
691
+ * {@link BlockKitchenProps.onSend}; carries `channel + ts`.
692
+ */
693
+ onUpdate: (payload: UpdatePayload) => Promise<UpdateResult>;
694
+ /**
695
+ * Optional. When provided, the load dialog adds a "recent messages from this
696
+ * app" picker alongside the paste-a-link input. Returns messages the app
697
+ * authored (editable-by-construction); picking one loads it straight into
698
+ * edit mode. Omit to offer the paste-link entry only.
699
+ */
700
+ loadRecentMessages?: () => Promise<RecentMessage[]>;
701
+ }
583
702
  /**
584
703
  * A workspace custom emoji as configured in Slack. Mirrors the shape Slack's
585
704
  * `emoji.list` API returns once normalized:
@@ -703,6 +822,35 @@ interface BlockKitchenProps {
703
822
  * `{ ok: true }` on success or `{ ok: false, error }` on failure.
704
823
  */
705
824
  onSend: (payload: SendPayload) => Promise<SendResult>;
825
+ /**
826
+ * Opt-in edit mode. When provided, the toolbar exposes an "Edit existing
827
+ * message" entry: the user pastes a Slack message link, the host loads it
828
+ * and returns an editability verdict ({@link EditingConfig.onLoadMessage}),
829
+ * and a successful load flips the primary action from Send to "Update
830
+ * message" ({@link EditingConfig.onUpdate}). Omit to keep today's send-only
831
+ * behavior. The user-token path reuses {@link BlockKitchenProps.loadSendAsUserStatus}.
832
+ */
833
+ editing?: EditingConfig;
834
+ /**
835
+ * Label + accessible name for the toolbar button that opens the
836
+ * load-message dialog (the edit-mode entry point). Defaults to
837
+ * `'Load message'`. Only shown when {@link BlockKitchenProps.editing} is set
838
+ * and no message is currently loaded.
839
+ */
840
+ loadButtonLabel?: string;
841
+ /**
842
+ * Label for the toolbar's primary button when a message is loaded for
843
+ * editing. The button is a split control: clicking it updates the message
844
+ * in place; a menu beside it also offers "Send as a new message" (post the
845
+ * current blocks as a brand-new message). Defaults to `'Review & update'`.
846
+ */
847
+ updateButtonLabel?: string;
848
+ /**
849
+ * Label for the update dialog's final confirm button, which dispatches the
850
+ * update via {@link EditingConfig.onUpdate}. Defaults to `'Update message'`
851
+ * (and shows `'Updating…'` while in flight).
852
+ */
853
+ confirmUpdateLabel?: string;
706
854
  /**
707
855
  * The palette shown on the left-hand side. When omitted, the built-in
708
856
  * `defaultPalette` is used. Pass a custom array (typically built by
@@ -814,9 +962,9 @@ interface BlockKitchenProps {
814
962
  previewTheme?: PreviewTheme;
815
963
  /**
816
964
  * Label for the toolbar's Send button, which opens the send dialog.
817
- * Defaults to `'Send'`. Use this to signal that a configuration step
818
- * follows (e.g. `'Send to channel…'`) without hardcoding
819
- * product-specific copy in the package. Also used as the button's
965
+ * Defaults to `'Review & send'` (the dialog is the review step). Use this to
966
+ * override the copy (e.g. `'Send to channel…'`) without hardcoding
967
+ * product-specific text in the package. Also used as the button's
820
968
  * accessible name.
821
969
  */
822
970
  sendButtonLabel?: string;
@@ -853,4 +1001,4 @@ interface BlockKitchenProps {
853
1001
  theme?: BrandTheme | BrandPreset;
854
1002
  }
855
1003
 
856
- export { extraAlertVariant as $, type AlertBlock as A, type BlockKitchenProps as B, type CardBlock as C, type DataVisualizationBlock as D, type PreviewSurface as E, type FeedbackButtonSubobject as F, type PreviewTheme as G, type HeaderLevel as H, type IconButtonElement as I, type SendPayload as J, type SendResult as K, type SupportedBlock as L, type MarkdownBlock as M, type SupportedBlockType as N, type SupportedHeaderBlock as O, type PaletteSection as P, type TableCell as Q, type TableColumnSetting as R, type SendAsUserStatus as S, type TableBlock as T, type TaskCardBlock as U, type TaskCardStatus as V, type Template as W, type UrlSourceElement as X, type VideoBlock as Y, buildVariantById as Z, defaultPalette as _, type AlertLevel as a, legacyInputVariants as a0, type BrandPreset as b, type BrandTheme as c, type BrandTokens as d, type BuilderBlock as e, type CarouselBlock as f, type CartesianChart as g, type ChannelOption as h, type Chart as i, type ChartAxisConfig as j, type ChartDataPoint as k, type ChartSeries as l, type ChartType as m, type ContainerBlock as n, type ContainerChildBlock as o, type ContextActionsBlock as p, type ContextActionsElement as q, type CustomEmoji as r, type FeedbackButtonsElement as s, type IconButtonIcon as t, type InputBlock as u, type PaletteVariant as v, type PieChart as w, type PieChartSegment as x, type PlanBlock as y, type PreviewHooks as z };
1004
+ export { type Template as $, type AlertBlock as A, type BlockKitchenProps as B, type CardBlock as C, type DataVisualizationBlock as D, type EditableVia as E, type FeedbackButtonSubobject as F, type PlanBlock as G, type HeaderLevel as H, type IconButtonElement as I, type PreviewHooks as J, type PreviewSurface as K, type LoadMessageInput as L, type MarkdownBlock as M, type PreviewTheme as N, type SendPayload as O, type PaletteSection as P, type SendResult as Q, type RecentMessage as R, type SendAsUserStatus as S, type SupportedBlock as T, type SupportedBlockType as U, type SupportedHeaderBlock as V, type TableBlock as W, type TableCell as X, type TableColumnSetting as Y, type TaskCardBlock as Z, type TaskCardStatus as _, type AlertLevel as a, type UpdatePayload as a0, type UpdateResult as a1, type UrlSourceElement as a2, type VideoBlock as a3, buildVariantById as a4, defaultPalette as a5, extraAlertVariant as a6, legacyInputVariants as a7, type BrandPreset as b, type BrandTheme as c, type BrandTokens as d, type BuilderBlock as e, type CarouselBlock as f, type CartesianChart as g, type ChannelOption as h, type Chart as i, type ChartAxisConfig as j, type ChartDataPoint as k, type ChartSeries as l, type ChartType as m, type ContainerBlock as n, type ContainerChildBlock as o, type ContextActionsBlock as p, type ContextActionsElement as q, type CustomEmoji as r, type EditingConfig as s, type FeedbackButtonsElement as t, type IconButtonIcon as u, type InputBlock as v, type LoadResult as w, type PaletteVariant as x, type PieChart as y, type PieChartSegment as z };
@@ -580,6 +580,125 @@ interface SendResult {
580
580
  ok: boolean;
581
581
  error?: string;
582
582
  }
583
+ /**
584
+ * Which token can edit a loaded message, as computed by the host.
585
+ * `chat.update` only edits a message authored by the calling token:
586
+ * - `'bot'` — the message was posted by this app; edit via the bot token.
587
+ * - `'user'` — the message was posted by the current user; edit via their
588
+ * user token (gated behind {@link BlockKitchenProps.loadSendAsUserStatus}).
589
+ */
590
+ type EditableVia = 'bot' | 'user';
591
+ /**
592
+ * Input passed to {@link EditingConfig.onLoadMessage}. The user pastes a
593
+ * Slack message permalink (Slack's "Copy link"); the host parses
594
+ * `channel + ts` out of it — the package never touches raw timestamps.
595
+ */
596
+ interface LoadMessageInput {
597
+ link: string;
598
+ }
599
+ /**
600
+ * Result of loading an existing message for editing, computed by the host.
601
+ *
602
+ * On `ok`, the package enters edit mode: it hydrates the editor with
603
+ * `blocks`, locks the destination to `channelId`, and constrains the
604
+ * post-as identity to `editableVia`.
605
+ *
606
+ * On `!ok`, the package renders the host's `reason` inline and offers
607
+ * "Open as a new message instead". If the message round-trips through the
608
+ * block editor (e.g. someone else's block message), the host may include
609
+ * `blocks` so that fallback can hydrate the draft; for non-block or
610
+ * attachment-only messages, omit it.
611
+ */
612
+ type LoadResult = {
613
+ ok: true;
614
+ channelId: string;
615
+ /** Channel name for the edit-mode badge (display only). Falls back to `channelId`. */
616
+ channelName?: string;
617
+ ts: string;
618
+ blocks: SupportedBlock[];
619
+ editableVia: EditableVia;
620
+ workspaceName?: string;
621
+ /**
622
+ * Display name of the existing message's author. When provided, the
623
+ * preview header shows it instead of `workspaceName`. Optional.
624
+ */
625
+ username?: string;
626
+ /**
627
+ * Avatar image URL of the existing message's author, shown in the
628
+ * preview header. Optional; ignored if it isn't a safe `http(s)` URL.
629
+ */
630
+ iconUrl?: string;
631
+ } | {
632
+ ok: false;
633
+ reason: string;
634
+ blocks?: SupportedBlock[];
635
+ };
636
+ /**
637
+ * Payload passed to {@link EditingConfig.onUpdate}. Sibling to
638
+ * {@link SendPayload} but carries the source `channel + ts`. `chat.update`
639
+ * requires re-sending the full blocks payload (no partial update).
640
+ */
641
+ interface UpdatePayload {
642
+ channelId: string;
643
+ ts: string;
644
+ blocks: SupportedBlock[];
645
+ asUser: boolean;
646
+ }
647
+ /**
648
+ * Result returned from {@link EditingConfig.onUpdate}. Mirrors
649
+ * {@link SendResult}; `error` is rendered as-is.
650
+ */
651
+ interface UpdateResult {
652
+ ok: boolean;
653
+ error?: string;
654
+ }
655
+ /**
656
+ * One entry in the "recent messages from this app" picker, returned by
657
+ * {@link EditingConfig.loadRecentMessages}. These are editable-by-construction
658
+ * — the app authored them — so they load straight into edit mode without a
659
+ * separate verdict round-trip. `editableVia` defaults to `'bot'` when omitted.
660
+ */
661
+ interface RecentMessage {
662
+ channelId: string;
663
+ /** Channel name for display + the edit-mode badge. Falls back to `channelId`. */
664
+ channelName?: string;
665
+ ts: string;
666
+ blocks: SupportedBlock[];
667
+ editableVia?: EditableVia;
668
+ /** Short preview shown in the picker row (e.g. the first line of the message). */
669
+ label?: string;
670
+ workspaceName?: string;
671
+ /** Display name of the message's author; shown in the preview header. Optional. */
672
+ username?: string;
673
+ /** Avatar image URL shown in the preview header. Optional; ignored unless a safe `http(s)` URL. */
674
+ iconUrl?: string;
675
+ }
676
+ /**
677
+ * Opt-in edit-mode configuration. Presence of {@link BlockKitchenProps.editing}
678
+ * enables loading an existing message and dispatching an update; omit it to
679
+ * keep the send-only behavior. The package stays integration-agnostic — it
680
+ * makes no network calls and has no Slack-token knowledge; the host brokers
681
+ * I/O and computes the editability verdict.
682
+ */
683
+ interface EditingConfig {
684
+ /**
685
+ * Host parses the pasted permalink, fetches the message, and returns a
686
+ * host-computed editability verdict plus blocks. See {@link LoadResult}.
687
+ */
688
+ onLoadMessage: (input: LoadMessageInput) => Promise<LoadResult>;
689
+ /**
690
+ * Dispatches the update for the loaded message. Sibling to
691
+ * {@link BlockKitchenProps.onSend}; carries `channel + ts`.
692
+ */
693
+ onUpdate: (payload: UpdatePayload) => Promise<UpdateResult>;
694
+ /**
695
+ * Optional. When provided, the load dialog adds a "recent messages from this
696
+ * app" picker alongside the paste-a-link input. Returns messages the app
697
+ * authored (editable-by-construction); picking one loads it straight into
698
+ * edit mode. Omit to offer the paste-link entry only.
699
+ */
700
+ loadRecentMessages?: () => Promise<RecentMessage[]>;
701
+ }
583
702
  /**
584
703
  * A workspace custom emoji as configured in Slack. Mirrors the shape Slack's
585
704
  * `emoji.list` API returns once normalized:
@@ -703,6 +822,35 @@ interface BlockKitchenProps {
703
822
  * `{ ok: true }` on success or `{ ok: false, error }` on failure.
704
823
  */
705
824
  onSend: (payload: SendPayload) => Promise<SendResult>;
825
+ /**
826
+ * Opt-in edit mode. When provided, the toolbar exposes an "Edit existing
827
+ * message" entry: the user pastes a Slack message link, the host loads it
828
+ * and returns an editability verdict ({@link EditingConfig.onLoadMessage}),
829
+ * and a successful load flips the primary action from Send to "Update
830
+ * message" ({@link EditingConfig.onUpdate}). Omit to keep today's send-only
831
+ * behavior. The user-token path reuses {@link BlockKitchenProps.loadSendAsUserStatus}.
832
+ */
833
+ editing?: EditingConfig;
834
+ /**
835
+ * Label + accessible name for the toolbar button that opens the
836
+ * load-message dialog (the edit-mode entry point). Defaults to
837
+ * `'Load message'`. Only shown when {@link BlockKitchenProps.editing} is set
838
+ * and no message is currently loaded.
839
+ */
840
+ loadButtonLabel?: string;
841
+ /**
842
+ * Label for the toolbar's primary button when a message is loaded for
843
+ * editing. The button is a split control: clicking it updates the message
844
+ * in place; a menu beside it also offers "Send as a new message" (post the
845
+ * current blocks as a brand-new message). Defaults to `'Review & update'`.
846
+ */
847
+ updateButtonLabel?: string;
848
+ /**
849
+ * Label for the update dialog's final confirm button, which dispatches the
850
+ * update via {@link EditingConfig.onUpdate}. Defaults to `'Update message'`
851
+ * (and shows `'Updating…'` while in flight).
852
+ */
853
+ confirmUpdateLabel?: string;
706
854
  /**
707
855
  * The palette shown on the left-hand side. When omitted, the built-in
708
856
  * `defaultPalette` is used. Pass a custom array (typically built by
@@ -814,9 +962,9 @@ interface BlockKitchenProps {
814
962
  previewTheme?: PreviewTheme;
815
963
  /**
816
964
  * Label for the toolbar's Send button, which opens the send dialog.
817
- * Defaults to `'Send'`. Use this to signal that a configuration step
818
- * follows (e.g. `'Send to channel…'`) without hardcoding
819
- * product-specific copy in the package. Also used as the button's
965
+ * Defaults to `'Review & send'` (the dialog is the review step). Use this to
966
+ * override the copy (e.g. `'Send to channel…'`) without hardcoding
967
+ * product-specific text in the package. Also used as the button's
820
968
  * accessible name.
821
969
  */
822
970
  sendButtonLabel?: string;
@@ -853,4 +1001,4 @@ interface BlockKitchenProps {
853
1001
  theme?: BrandTheme | BrandPreset;
854
1002
  }
855
1003
 
856
- export { extraAlertVariant as $, type AlertBlock as A, type BlockKitchenProps as B, type CardBlock as C, type DataVisualizationBlock as D, type PreviewSurface as E, type FeedbackButtonSubobject as F, type PreviewTheme as G, type HeaderLevel as H, type IconButtonElement as I, type SendPayload as J, type SendResult as K, type SupportedBlock as L, type MarkdownBlock as M, type SupportedBlockType as N, type SupportedHeaderBlock as O, type PaletteSection as P, type TableCell as Q, type TableColumnSetting as R, type SendAsUserStatus as S, type TableBlock as T, type TaskCardBlock as U, type TaskCardStatus as V, type Template as W, type UrlSourceElement as X, type VideoBlock as Y, buildVariantById as Z, defaultPalette as _, type AlertLevel as a, legacyInputVariants as a0, type BrandPreset as b, type BrandTheme as c, type BrandTokens as d, type BuilderBlock as e, type CarouselBlock as f, type CartesianChart as g, type ChannelOption as h, type Chart as i, type ChartAxisConfig as j, type ChartDataPoint as k, type ChartSeries as l, type ChartType as m, type ContainerBlock as n, type ContainerChildBlock as o, type ContextActionsBlock as p, type ContextActionsElement as q, type CustomEmoji as r, type FeedbackButtonsElement as s, type IconButtonIcon as t, type InputBlock as u, type PaletteVariant as v, type PieChart as w, type PieChartSegment as x, type PlanBlock as y, type PreviewHooks as z };
1004
+ export { type Template as $, type AlertBlock as A, type BlockKitchenProps as B, type CardBlock as C, type DataVisualizationBlock as D, type EditableVia as E, type FeedbackButtonSubobject as F, type PlanBlock as G, type HeaderLevel as H, type IconButtonElement as I, type PreviewHooks as J, type PreviewSurface as K, type LoadMessageInput as L, type MarkdownBlock as M, type PreviewTheme as N, type SendPayload as O, type PaletteSection as P, type SendResult as Q, type RecentMessage as R, type SendAsUserStatus as S, type SupportedBlock as T, type SupportedBlockType as U, type SupportedHeaderBlock as V, type TableBlock as W, type TableCell as X, type TableColumnSetting as Y, type TaskCardBlock as Z, type TaskCardStatus as _, type AlertLevel as a, type UpdatePayload as a0, type UpdateResult as a1, type UrlSourceElement as a2, type VideoBlock as a3, buildVariantById as a4, defaultPalette as a5, extraAlertVariant as a6, legacyInputVariants as a7, type BrandPreset as b, type BrandTheme as c, type BrandTokens as d, type BuilderBlock as e, type CarouselBlock as f, type CartesianChart as g, type ChannelOption as h, type Chart as i, type ChartAxisConfig as j, type ChartDataPoint as k, type ChartSeries as l, type ChartType as m, type ContainerBlock as n, type ContainerChildBlock as o, type ContextActionsBlock as p, type ContextActionsElement as q, type CustomEmoji as r, type EditingConfig as s, type FeedbackButtonsElement as t, type IconButtonIcon as u, type InputBlock as v, type LoadResult as w, type PaletteVariant as x, type PieChart as y, type PieChartSegment as z };
@@ -1,3 +1,3 @@
1
- export { P as PaletteSection, v as PaletteVariant, L as SupportedBlock, N as SupportedBlockType, Z as buildVariantById, _ as defaultPalette, $ as extraAlertVariant, a0 as legacyInputVariants } from './palette-DBTHRygt.cjs';
1
+ export { P as PaletteSection, x as PaletteVariant, T as SupportedBlock, U as SupportedBlockType, a4 as buildVariantById, a5 as defaultPalette, a6 as extraAlertVariant, a7 as legacyInputVariants } from './palette-Bup05opK.cjs';
2
2
  import 'react';
3
3
  import 'slack-web-api-client';
package/dist/palette.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { P as PaletteSection, v as PaletteVariant, L as SupportedBlock, N as SupportedBlockType, Z as buildVariantById, _ as defaultPalette, $ as extraAlertVariant, a0 as legacyInputVariants } from './palette-DBTHRygt.js';
1
+ export { P as PaletteSection, x as PaletteVariant, T as SupportedBlock, U as SupportedBlockType, a4 as buildVariantById, a5 as defaultPalette, a6 as extraAlertVariant, a7 as legacyInputVariants } from './palette-Bup05opK.js';
2
2
  import 'react';
3
3
  import 'slack-web-api-client';