@tightknitai/block-kitchen 0.9.8 → 0.9.10

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/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
- import { B as BlockKitchenProps, $ as Template, K as PreviewSurface, N as PreviewTheme } from './palette-CKP8CK5Z.cjs';
3
- export { A as AlertBlock, a as AlertLevel, b as BrandPreset, c as BrandTheme, d as BrandTokens, e as BuilderBlock, C as CardBlock, f as CarouselBlock, g as CartesianChart, h as ChannelOption, i as Chart, j as ChartAxisConfig, k as ChartDataPoint, l as ChartSeries, m as ChartType, n as ContainerBlock, o as ContainerChildBlock, p as ContextActionsBlock, q as ContextActionsElement, r as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, s as EditingConfig, F as FeedbackButtonSubobject, t as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, u as IconButtonIcon, v as InputBlock, L as LoadMessageInput, w as LoadResult, M as MarkdownBlock, P as PaletteSection, x as PaletteVariant, y as PieChart, z as PieChartSegment, G as PlanBlock, J as PreviewHooks, R as RecentMessage, S as SendAsUserStatus, O as SendPayload, Q as SendResult, T as SupportedBlock, U as SupportedBlockType, V as SupportedHeaderBlock, W as TableBlock, X as TableCell, Y as TableColumnSetting, Z as TaskCardBlock, _ as TaskCardStatus, a0 as UpdatePayload, a1 as UpdateResult, a2 as UrlSourceElement, a3 as VideoBlock, a5 as defaultPalette, a6 as extraAlertVariant, a7 as legacyInputVariants } from './palette-CKP8CK5Z.cjs';
2
+ import { ReactNode } from 'react';
3
+ import { c as BlockKitchenProps, Z as SupportedBlock, k as ChannelOption, V as SendAsUserStatus, X as SendPayload, W as SendExtrasContext, a5 as Template, Q as PreviewSurface, R as PreviewTheme } from './palette-Duj901T6.cjs';
4
+ export { A as AlertBlock, a as AlertLevel, B as BlockKitchenBaseProps, b as BlockKitchenComposeOnlyProps, d as BlockKitchenSendProps, e as BrandPreset, f as BrandTheme, g as BrandTokens, h as BuilderBlock, C as CardBlock, i as CarouselBlock, j as CartesianChart, l as Chart, m as ChartAxisConfig, n as ChartDataPoint, o as ChartSeries, p as ChartType, q as ContainerBlock, r as ContainerChildBlock, s as ContextActionsBlock, t as ContextActionsElement, u as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, v as EditingConfig, F as FeedbackButtonSubobject, w as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, x as IconButtonIcon, y as InputBlock, L as LoadMessageInput, z as LoadResult, M as MarkdownBlock, P as PaletteSection, G as PaletteVariant, J as PieChart, K as PieChartSegment, N as PlanBlock, O as PreviewHooks, S as PrimaryActionConfig, T as PrimaryActionContext, U as RecentMessage, Y as SendResult, _ as SupportedBlockType, $ as SupportedHeaderBlock, a0 as TableBlock, a1 as TableCell, a2 as TableColumnSetting, a3 as TaskCardBlock, a4 as TaskCardStatus, a6 as UpdatePayload, a7 as UpdateResult, a8 as UrlSourceElement, a9 as ValidationSummary, aa as VideoBlock, ac as defaultPalette, ad as extraAlertVariant, ae as legacyInputVariants } from './palette-Duj901T6.cjs';
4
5
  export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.cjs';
5
6
  import 'slack-web-api-client';
6
7
 
@@ -14,6 +15,85 @@ import 'slack-web-api-client';
14
15
  */
15
16
  declare function BlockKitchen(props: BlockKitchenProps): react.JSX.Element;
16
17
 
18
+ /**
19
+ * Props for {@link SendDialog}. Exported so hosts building a bespoke send
20
+ * flow (compose-only mode) can reuse the built-in dialog standalone instead
21
+ * of rebuilding channel loading, identity, and sending states from scratch.
22
+ */
23
+ interface SendDialogProps {
24
+ /** Whether the dialog is open. */
25
+ open: boolean;
26
+ /** Notified when the user closes the dialog. */
27
+ onOpenChange: (open: boolean) => void;
28
+ /** The draft blocks to send (builder-native format). */
29
+ blocks: SupportedBlock[];
30
+ /** Returns channels available to send to. Called when the dialog opens. */
31
+ loadChannels: () => Promise<ChannelOption[]>;
32
+ /** Returns user-token status + OAuth URL. */
33
+ loadSendAsUserStatus: () => Promise<SendAsUserStatus>;
34
+ /** Terminal action; should return `{ ok }` or `{ ok: false, error }`. */
35
+ onSend: (payload: SendPayload) => Promise<{
36
+ ok: boolean;
37
+ error?: string;
38
+ }>;
39
+ /**
40
+ * Renders host-defined fields below the built-in pickers; collected
41
+ * values are delivered on {@link SendPayload.extras}.
42
+ */
43
+ renderSendExtras?: (context: SendExtrasContext) => ReactNode;
44
+ /** Label for the final confirm button. Defaults to `'Send'`. */
45
+ confirmSendLabel?: string;
46
+ /** Total validation errors against the current draft. */
47
+ errorCount: number;
48
+ /** Asks the parent to open the global issues panel. */
49
+ onShowIssues?: () => void;
50
+ }
51
+ /**
52
+ * Modal dialog that collects the destination channel + send-as identity
53
+ * (plus any host-defined extras), then calls the consumer's `onSend`.
54
+ *
55
+ * Channels and user-token status are loaded async via callback props on open.
56
+ * The consumer brokers all I/O; the dialog never makes a network call.
57
+ * @param props - {@link SendDialogProps}
58
+ * @returns the rendered send dialog
59
+ */
60
+ declare function SendDialog({ open, onOpenChange, blocks, loadChannels, loadSendAsUserStatus, onSend, renderSendExtras, confirmSendLabel, errorCount, onShowIssues }: SendDialogProps): react.JSX.Element;
61
+
62
+ /**
63
+ * Tracks the "act as the user" Slack token status for a dialog and drives the
64
+ * OAuth sign-in flow. Shared by {@link SendDialog} and {@link UpdateDialog}.
65
+ *
66
+ * While `open && enabled` it fetches status on open and refreshes on window
67
+ * focus. Once `startSignIn` opens the OAuth tab it also background-polls until
68
+ * the token appears or the retry cap is hit, so the dialog unlocks itself
69
+ * without a manual reload. All work stops when the dialog closes, the token
70
+ * path doesn't apply, or the component unmounts.
71
+ *
72
+ * @param loadStatus - consumer callback returning user-token status + OAuth URL
73
+ * @param options.open - whether the host dialog is open
74
+ * @param options.enabled - whether the user-token path applies (idle when false)
75
+ * @returns `{ userStatus, polling, startSignIn }`
76
+ */
77
+ declare function useSlackSignIn(loadStatus: () => Promise<SendAsUserStatus>, { open, enabled }: {
78
+ open: boolean;
79
+ enabled: boolean;
80
+ }): {
81
+ userStatus: SendAsUserStatus | null;
82
+ polling: boolean;
83
+ startSignIn: () => void;
84
+ };
85
+ /**
86
+ * The "Sign in with Slack" button used by both dialogs. Opens OAuth and shows a
87
+ * spinner while {@link useSlackSignIn} polls for the completed round-trip. The
88
+ * surrounding explanatory copy stays with each caller since it differs.
89
+ * @param props.onClick - starts the sign-in flow (typically `startSignIn`)
90
+ * @param props.polling - whether a background poll is in flight
91
+ */
92
+ declare function SlackSignInButton({ onClick, polling }: {
93
+ onClick: () => void;
94
+ polling: boolean;
95
+ }): react.JSX.Element;
96
+
17
97
  /**
18
98
  * Standalone, page-sized picker that displays {@link Template}s as a
19
99
  * grid of cards with live block previews, organized into category
@@ -51,4 +131,4 @@ declare function TemplatePicker({ templates, onSelect, surface, theme, heading,
51
131
  className?: string;
52
132
  }): react.JSX.Element;
53
133
 
54
- export { BlockKitchen, BlockKitchenProps, PreviewSurface, PreviewTheme, Template, TemplatePicker };
134
+ export { BlockKitchen, BlockKitchenProps, ChannelOption, PreviewSurface, PreviewTheme, SendAsUserStatus, SendDialog, type SendDialogProps, SendExtrasContext, SendPayload, SlackSignInButton, SupportedBlock, Template, TemplatePicker, useSlackSignIn };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
- import { B as BlockKitchenProps, $ as Template, K as PreviewSurface, N as PreviewTheme } from './palette-CKP8CK5Z.js';
3
- export { A as AlertBlock, a as AlertLevel, b as BrandPreset, c as BrandTheme, d as BrandTokens, e as BuilderBlock, C as CardBlock, f as CarouselBlock, g as CartesianChart, h as ChannelOption, i as Chart, j as ChartAxisConfig, k as ChartDataPoint, l as ChartSeries, m as ChartType, n as ContainerBlock, o as ContainerChildBlock, p as ContextActionsBlock, q as ContextActionsElement, r as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, s as EditingConfig, F as FeedbackButtonSubobject, t as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, u as IconButtonIcon, v as InputBlock, L as LoadMessageInput, w as LoadResult, M as MarkdownBlock, P as PaletteSection, x as PaletteVariant, y as PieChart, z as PieChartSegment, G as PlanBlock, J as PreviewHooks, R as RecentMessage, S as SendAsUserStatus, O as SendPayload, Q as SendResult, T as SupportedBlock, U as SupportedBlockType, V as SupportedHeaderBlock, W as TableBlock, X as TableCell, Y as TableColumnSetting, Z as TaskCardBlock, _ as TaskCardStatus, a0 as UpdatePayload, a1 as UpdateResult, a2 as UrlSourceElement, a3 as VideoBlock, a5 as defaultPalette, a6 as extraAlertVariant, a7 as legacyInputVariants } from './palette-CKP8CK5Z.js';
2
+ import { ReactNode } from 'react';
3
+ import { c as BlockKitchenProps, Z as SupportedBlock, k as ChannelOption, V as SendAsUserStatus, X as SendPayload, W as SendExtrasContext, a5 as Template, Q as PreviewSurface, R as PreviewTheme } from './palette-Duj901T6.js';
4
+ export { A as AlertBlock, a as AlertLevel, B as BlockKitchenBaseProps, b as BlockKitchenComposeOnlyProps, d as BlockKitchenSendProps, e as BrandPreset, f as BrandTheme, g as BrandTokens, h as BuilderBlock, C as CardBlock, i as CarouselBlock, j as CartesianChart, l as Chart, m as ChartAxisConfig, n as ChartDataPoint, o as ChartSeries, p as ChartType, q as ContainerBlock, r as ContainerChildBlock, s as ContextActionsBlock, t as ContextActionsElement, u as CustomEmoji, D as DataVisualizationBlock, E as EditableVia, v as EditingConfig, F as FeedbackButtonSubobject, w as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, x as IconButtonIcon, y as InputBlock, L as LoadMessageInput, z as LoadResult, M as MarkdownBlock, P as PaletteSection, G as PaletteVariant, J as PieChart, K as PieChartSegment, N as PlanBlock, O as PreviewHooks, S as PrimaryActionConfig, T as PrimaryActionContext, U as RecentMessage, Y as SendResult, _ as SupportedBlockType, $ as SupportedHeaderBlock, a0 as TableBlock, a1 as TableCell, a2 as TableColumnSetting, a3 as TaskCardBlock, a4 as TaskCardStatus, a6 as UpdatePayload, a7 as UpdateResult, a8 as UrlSourceElement, a9 as ValidationSummary, aa as VideoBlock, ac as defaultPalette, ad as extraAlertVariant, ae as legacyInputVariants } from './palette-Duj901T6.js';
4
5
  export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.js';
5
6
  import 'slack-web-api-client';
6
7
 
@@ -14,6 +15,85 @@ import 'slack-web-api-client';
14
15
  */
15
16
  declare function BlockKitchen(props: BlockKitchenProps): react.JSX.Element;
16
17
 
18
+ /**
19
+ * Props for {@link SendDialog}. Exported so hosts building a bespoke send
20
+ * flow (compose-only mode) can reuse the built-in dialog standalone instead
21
+ * of rebuilding channel loading, identity, and sending states from scratch.
22
+ */
23
+ interface SendDialogProps {
24
+ /** Whether the dialog is open. */
25
+ open: boolean;
26
+ /** Notified when the user closes the dialog. */
27
+ onOpenChange: (open: boolean) => void;
28
+ /** The draft blocks to send (builder-native format). */
29
+ blocks: SupportedBlock[];
30
+ /** Returns channels available to send to. Called when the dialog opens. */
31
+ loadChannels: () => Promise<ChannelOption[]>;
32
+ /** Returns user-token status + OAuth URL. */
33
+ loadSendAsUserStatus: () => Promise<SendAsUserStatus>;
34
+ /** Terminal action; should return `{ ok }` or `{ ok: false, error }`. */
35
+ onSend: (payload: SendPayload) => Promise<{
36
+ ok: boolean;
37
+ error?: string;
38
+ }>;
39
+ /**
40
+ * Renders host-defined fields below the built-in pickers; collected
41
+ * values are delivered on {@link SendPayload.extras}.
42
+ */
43
+ renderSendExtras?: (context: SendExtrasContext) => ReactNode;
44
+ /** Label for the final confirm button. Defaults to `'Send'`. */
45
+ confirmSendLabel?: string;
46
+ /** Total validation errors against the current draft. */
47
+ errorCount: number;
48
+ /** Asks the parent to open the global issues panel. */
49
+ onShowIssues?: () => void;
50
+ }
51
+ /**
52
+ * Modal dialog that collects the destination channel + send-as identity
53
+ * (plus any host-defined extras), then calls the consumer's `onSend`.
54
+ *
55
+ * Channels and user-token status are loaded async via callback props on open.
56
+ * The consumer brokers all I/O; the dialog never makes a network call.
57
+ * @param props - {@link SendDialogProps}
58
+ * @returns the rendered send dialog
59
+ */
60
+ declare function SendDialog({ open, onOpenChange, blocks, loadChannels, loadSendAsUserStatus, onSend, renderSendExtras, confirmSendLabel, errorCount, onShowIssues }: SendDialogProps): react.JSX.Element;
61
+
62
+ /**
63
+ * Tracks the "act as the user" Slack token status for a dialog and drives the
64
+ * OAuth sign-in flow. Shared by {@link SendDialog} and {@link UpdateDialog}.
65
+ *
66
+ * While `open && enabled` it fetches status on open and refreshes on window
67
+ * focus. Once `startSignIn` opens the OAuth tab it also background-polls until
68
+ * the token appears or the retry cap is hit, so the dialog unlocks itself
69
+ * without a manual reload. All work stops when the dialog closes, the token
70
+ * path doesn't apply, or the component unmounts.
71
+ *
72
+ * @param loadStatus - consumer callback returning user-token status + OAuth URL
73
+ * @param options.open - whether the host dialog is open
74
+ * @param options.enabled - whether the user-token path applies (idle when false)
75
+ * @returns `{ userStatus, polling, startSignIn }`
76
+ */
77
+ declare function useSlackSignIn(loadStatus: () => Promise<SendAsUserStatus>, { open, enabled }: {
78
+ open: boolean;
79
+ enabled: boolean;
80
+ }): {
81
+ userStatus: SendAsUserStatus | null;
82
+ polling: boolean;
83
+ startSignIn: () => void;
84
+ };
85
+ /**
86
+ * The "Sign in with Slack" button used by both dialogs. Opens OAuth and shows a
87
+ * spinner while {@link useSlackSignIn} polls for the completed round-trip. The
88
+ * surrounding explanatory copy stays with each caller since it differs.
89
+ * @param props.onClick - starts the sign-in flow (typically `startSignIn`)
90
+ * @param props.polling - whether a background poll is in flight
91
+ */
92
+ declare function SlackSignInButton({ onClick, polling }: {
93
+ onClick: () => void;
94
+ polling: boolean;
95
+ }): react.JSX.Element;
96
+
17
97
  /**
18
98
  * Standalone, page-sized picker that displays {@link Template}s as a
19
99
  * grid of cards with live block previews, organized into category
@@ -51,4 +131,4 @@ declare function TemplatePicker({ templates, onSelect, surface, theme, heading,
51
131
  className?: string;
52
132
  }): react.JSX.Element;
53
133
 
54
- export { BlockKitchen, BlockKitchenProps, PreviewSurface, PreviewTheme, Template, TemplatePicker };
134
+ export { BlockKitchen, BlockKitchenProps, ChannelOption, PreviewSurface, PreviewTheme, SendAsUserStatus, SendDialog, type SendDialogProps, SendExtrasContext, SendPayload, SlackSignInButton, SupportedBlock, Template, TemplatePicker, useSlackSignIn };