@nkootstra/block-kit 0.0.1 → 0.1.1
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/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/index-FPjJcmn3.d.ts +911 -0
- package/dist/index-gBduJdQh.d.ts +127 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +10861 -0
- package/dist/index.js.map +1 -0
- package/dist/mrkdwn.d.ts +3 -0
- package/dist/mrkdwn.js +3 -0
- package/dist/parser-GbXBz4_f.js +441 -0
- package/dist/parser-GbXBz4_f.js.map +1 -0
- package/dist/server.d.ts +60 -0
- package/dist/server.js +83 -0
- package/dist/server.js.map +1 -0
- package/dist/styles.css +4820 -0
- package/dist/transport.d.ts +50 -0
- package/dist/transport.js +84 -0
- package/dist/transport.js.map +1 -0
- package/dist/web-api.d.ts +45 -0
- package/dist/web-api.js +121 -0
- package/dist/web-api.js.map +1 -0
- package/package.json +64 -3
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentType, FocusEvent, MouseEvent, ReactElement, ReactNode } from "react";
|
|
3
|
+
import { AnyBlock, MrkdwnElement, PlainTextElement } from "@slack/types";
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
/** A block or element as it appears in the JSON. Components narrow it to the fields they read. */
|
|
6
|
+
interface Json {
|
|
7
|
+
type: string;
|
|
8
|
+
[field: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
interface BlockProps<T = Json> {
|
|
11
|
+
block: T;
|
|
12
|
+
/** The block's `block_id`, or the one generated for it. */
|
|
13
|
+
blockId: string;
|
|
14
|
+
index: number;
|
|
15
|
+
}
|
|
16
|
+
interface ElementProps<T = Json> {
|
|
17
|
+
element: T;
|
|
18
|
+
blockId: string;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/Blocks.d.ts
|
|
22
|
+
declare function Blocks({ blocks }: {
|
|
23
|
+
blocks: readonly (AnyBlock | Json)[];
|
|
24
|
+
}): import("react").JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/blocks/Block.d.ts
|
|
27
|
+
/** Renders one block. `index` is used for the generated block_id, as Slack does for blocks without one. */
|
|
28
|
+
declare function Block({ block, index }: {
|
|
29
|
+
block: Json;
|
|
30
|
+
index: number;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/blocks/index.d.ts
|
|
34
|
+
declare const blockComponents: Record<string, ComponentType<BlockProps<any>>>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/payloads.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Builders for the exact JSON Slack sends to an app's request URL: `block_actions`,
|
|
39
|
+
* `view_submission` and `view_closed`. Shapes are cross-checked against `@slack/bolt`'s
|
|
40
|
+
* `BlockAction`, `ViewSubmitAction` and `ViewClosedAction` types and Slack's documented examples.
|
|
41
|
+
*
|
|
42
|
+
* These are plain functions (no React) so `@nkootstra/block-kit/server` and tests can use
|
|
43
|
+
* them without pulling in the renderer.
|
|
44
|
+
*/
|
|
45
|
+
interface PayloadTeam {
|
|
46
|
+
id: string;
|
|
47
|
+
domain: string;
|
|
48
|
+
enterprise_id?: string;
|
|
49
|
+
enterprise_name?: string;
|
|
50
|
+
}
|
|
51
|
+
interface PayloadUser {
|
|
52
|
+
id: string;
|
|
53
|
+
username?: string;
|
|
54
|
+
/** Only present for Home tab actions, per Slack's docs. */
|
|
55
|
+
name?: string;
|
|
56
|
+
team_id?: string;
|
|
57
|
+
}
|
|
58
|
+
/** Identity fields Slack stamps onto every payload. Defaulted so a demo/emulator works with no setup. */
|
|
59
|
+
interface PayloadIdentity {
|
|
60
|
+
team?: PayloadTeam | null;
|
|
61
|
+
user?: PayloadUser;
|
|
62
|
+
apiAppId?: string;
|
|
63
|
+
token?: string;
|
|
64
|
+
triggerId?: string;
|
|
65
|
+
responseUrl?: string;
|
|
66
|
+
}
|
|
67
|
+
declare const DEFAULT_IDENTITY: {
|
|
68
|
+
team: PayloadTeam | null;
|
|
69
|
+
user: PayloadUser;
|
|
70
|
+
apiAppId: string;
|
|
71
|
+
token: string;
|
|
72
|
+
triggerId: string;
|
|
73
|
+
responseUrl: string;
|
|
74
|
+
};
|
|
75
|
+
type ResolvedIdentity = typeof DEFAULT_IDENTITY;
|
|
76
|
+
/** The `message` surface's container: the message the block_actions/actions came from. */
|
|
77
|
+
interface MessageContainer {
|
|
78
|
+
type: "message";
|
|
79
|
+
channelId?: string;
|
|
80
|
+
messageTs: string;
|
|
81
|
+
isEphemeral?: boolean;
|
|
82
|
+
/** Raw message object, if available, sent back verbatim as payload.message. */
|
|
83
|
+
message?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** A view as Slack would echo it back: enough fields to build view_submission/view_closed/block_actions. */
|
|
86
|
+
interface ViewLike {
|
|
87
|
+
/** Slack assigns this at `views.open` time; default to a placeholder id for standalone previews. */
|
|
88
|
+
id?: string;
|
|
89
|
+
type: "modal" | "home";
|
|
90
|
+
callback_id?: string;
|
|
91
|
+
private_metadata?: string;
|
|
92
|
+
hash?: string;
|
|
93
|
+
blocks: AnyBlock[];
|
|
94
|
+
title?: {
|
|
95
|
+
type: "plain_text";
|
|
96
|
+
text: string;
|
|
97
|
+
emoji?: boolean;
|
|
98
|
+
} | null;
|
|
99
|
+
close?: {
|
|
100
|
+
type: "plain_text";
|
|
101
|
+
text: string;
|
|
102
|
+
emoji?: boolean;
|
|
103
|
+
} | null;
|
|
104
|
+
submit?: {
|
|
105
|
+
type: "plain_text";
|
|
106
|
+
text: string;
|
|
107
|
+
emoji?: boolean;
|
|
108
|
+
} | null;
|
|
109
|
+
root_view_id?: string | null;
|
|
110
|
+
previous_view_id?: string | null;
|
|
111
|
+
clear_on_close?: boolean;
|
|
112
|
+
notify_on_close?: boolean;
|
|
113
|
+
external_id?: string;
|
|
114
|
+
}
|
|
115
|
+
/** The `modal`/`home` surface's container: the view the block_actions came from. */
|
|
116
|
+
interface ViewContainer {
|
|
117
|
+
type: "view";
|
|
118
|
+
view: ViewLike;
|
|
119
|
+
}
|
|
120
|
+
type Container = MessageContainer | ViewContainer;
|
|
121
|
+
declare function toViewOutput(view: ViewLike, state: StateValues, identity: ResolvedIdentity): {
|
|
122
|
+
id: string;
|
|
123
|
+
team_id: string;
|
|
124
|
+
app_installed_team_id: string;
|
|
125
|
+
app_id: string;
|
|
126
|
+
bot_id: string;
|
|
127
|
+
callback_id: string;
|
|
128
|
+
type: "modal" | "home";
|
|
129
|
+
title: {
|
|
130
|
+
type: "plain_text";
|
|
131
|
+
text: string;
|
|
132
|
+
emoji?: boolean;
|
|
133
|
+
} | null;
|
|
134
|
+
close: {
|
|
135
|
+
type: "plain_text";
|
|
136
|
+
text: string;
|
|
137
|
+
emoji?: boolean;
|
|
138
|
+
} | null;
|
|
139
|
+
submit: {
|
|
140
|
+
type: "plain_text";
|
|
141
|
+
text: string;
|
|
142
|
+
emoji?: boolean;
|
|
143
|
+
} | null;
|
|
144
|
+
blocks: AnyBlock[];
|
|
145
|
+
private_metadata: string;
|
|
146
|
+
state: {
|
|
147
|
+
values: StateValues;
|
|
148
|
+
};
|
|
149
|
+
hash: string;
|
|
150
|
+
clear_on_close: boolean;
|
|
151
|
+
notify_on_close: boolean;
|
|
152
|
+
root_view_id: string;
|
|
153
|
+
previous_view_id: string | null;
|
|
154
|
+
external_id: string;
|
|
155
|
+
};
|
|
156
|
+
interface BuildBlockActionsPayloadOptions {
|
|
157
|
+
action: BlockAction;
|
|
158
|
+
state: StateValues;
|
|
159
|
+
container: Container;
|
|
160
|
+
identity?: PayloadIdentity;
|
|
161
|
+
}
|
|
162
|
+
interface BlockActionsPayloadBase {
|
|
163
|
+
type: "block_actions";
|
|
164
|
+
actions: BlockAction[];
|
|
165
|
+
team: PayloadTeam | null;
|
|
166
|
+
user: PayloadUser;
|
|
167
|
+
token?: string;
|
|
168
|
+
response_url?: string;
|
|
169
|
+
trigger_id?: string;
|
|
170
|
+
api_app_id?: string;
|
|
171
|
+
}
|
|
172
|
+
interface MessageBlockActionsPayload extends BlockActionsPayloadBase {
|
|
173
|
+
channel?: {
|
|
174
|
+
id: string;
|
|
175
|
+
name: string;
|
|
176
|
+
};
|
|
177
|
+
message: Record<string, unknown>;
|
|
178
|
+
state: {
|
|
179
|
+
values: StateValues;
|
|
180
|
+
};
|
|
181
|
+
container: {
|
|
182
|
+
type: "message";
|
|
183
|
+
message_ts: string;
|
|
184
|
+
channel_id?: string;
|
|
185
|
+
is_ephemeral: boolean;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
interface ViewBlockActionsPayload extends BlockActionsPayloadBase {
|
|
189
|
+
view: ReturnType<typeof toViewOutput>;
|
|
190
|
+
container: {
|
|
191
|
+
type: "view";
|
|
192
|
+
view_id: string;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
type BlockActionsPayload = MessageBlockActionsPayload | ViewBlockActionsPayload;
|
|
196
|
+
/** Slack's `block_actions` payload, for either a message's or a view's interactive elements. */
|
|
197
|
+
declare function buildBlockActionsPayload(options: BuildBlockActionsPayloadOptions & {
|
|
198
|
+
container: MessageContainer;
|
|
199
|
+
}): MessageBlockActionsPayload;
|
|
200
|
+
declare function buildBlockActionsPayload(options: BuildBlockActionsPayloadOptions & {
|
|
201
|
+
container: ViewContainer;
|
|
202
|
+
}): ViewBlockActionsPayload;
|
|
203
|
+
declare function buildBlockActionsPayload(options: BuildBlockActionsPayloadOptions): BlockActionsPayload;
|
|
204
|
+
interface BuildViewSubmissionPayloadOptions {
|
|
205
|
+
view: ViewLike;
|
|
206
|
+
state: StateValues;
|
|
207
|
+
identity?: PayloadIdentity;
|
|
208
|
+
responseUrls?: Array<{
|
|
209
|
+
block_id: string;
|
|
210
|
+
action_id: string;
|
|
211
|
+
channel_id: string;
|
|
212
|
+
response_url: string;
|
|
213
|
+
}>;
|
|
214
|
+
}
|
|
215
|
+
/** Slack's `view_submission` payload, sent when the modal's Submit button is pressed. */
|
|
216
|
+
declare function buildViewSubmissionPayload({ view, state, identity, responseUrls }: BuildViewSubmissionPayloadOptions): {
|
|
217
|
+
type: "view_submission";
|
|
218
|
+
team: PayloadTeam | null;
|
|
219
|
+
user: {
|
|
220
|
+
id: string;
|
|
221
|
+
name: string;
|
|
222
|
+
team_id: string | undefined;
|
|
223
|
+
};
|
|
224
|
+
api_app_id: string;
|
|
225
|
+
token: string;
|
|
226
|
+
trigger_id: string;
|
|
227
|
+
view: {
|
|
228
|
+
id: string;
|
|
229
|
+
team_id: string;
|
|
230
|
+
app_installed_team_id: string;
|
|
231
|
+
app_id: string;
|
|
232
|
+
bot_id: string;
|
|
233
|
+
callback_id: string;
|
|
234
|
+
type: "modal" | "home";
|
|
235
|
+
title: {
|
|
236
|
+
type: "plain_text";
|
|
237
|
+
text: string;
|
|
238
|
+
emoji?: boolean;
|
|
239
|
+
} | null;
|
|
240
|
+
close: {
|
|
241
|
+
type: "plain_text";
|
|
242
|
+
text: string;
|
|
243
|
+
emoji?: boolean;
|
|
244
|
+
} | null;
|
|
245
|
+
submit: {
|
|
246
|
+
type: "plain_text";
|
|
247
|
+
text: string;
|
|
248
|
+
emoji?: boolean;
|
|
249
|
+
} | null;
|
|
250
|
+
blocks: AnyBlock[];
|
|
251
|
+
private_metadata: string;
|
|
252
|
+
state: {
|
|
253
|
+
values: StateValues;
|
|
254
|
+
};
|
|
255
|
+
hash: string;
|
|
256
|
+
clear_on_close: boolean;
|
|
257
|
+
notify_on_close: boolean;
|
|
258
|
+
root_view_id: string;
|
|
259
|
+
previous_view_id: string | null;
|
|
260
|
+
external_id: string;
|
|
261
|
+
};
|
|
262
|
+
response_urls: {
|
|
263
|
+
block_id: string;
|
|
264
|
+
action_id: string;
|
|
265
|
+
channel_id: string;
|
|
266
|
+
response_url: string;
|
|
267
|
+
}[];
|
|
268
|
+
};
|
|
269
|
+
interface BuildViewClosedPayloadOptions {
|
|
270
|
+
view: ViewLike;
|
|
271
|
+
state: StateValues;
|
|
272
|
+
identity?: PayloadIdentity;
|
|
273
|
+
/** True when Slack cleared the whole view stack (vs. just closing the top view). */
|
|
274
|
+
isCleared?: boolean;
|
|
275
|
+
}
|
|
276
|
+
/** Slack's `view_closed` payload, sent when the modal's close (X) button is pressed. */
|
|
277
|
+
declare function buildViewClosedPayload({ view, state, identity, isCleared }: BuildViewClosedPayloadOptions): {
|
|
278
|
+
type: "view_closed";
|
|
279
|
+
team: PayloadTeam | null;
|
|
280
|
+
user: {
|
|
281
|
+
id: string;
|
|
282
|
+
name: string;
|
|
283
|
+
team_id: string | undefined;
|
|
284
|
+
};
|
|
285
|
+
api_app_id: string;
|
|
286
|
+
token: string;
|
|
287
|
+
view: {
|
|
288
|
+
id: string;
|
|
289
|
+
team_id: string;
|
|
290
|
+
app_installed_team_id: string;
|
|
291
|
+
app_id: string;
|
|
292
|
+
bot_id: string;
|
|
293
|
+
callback_id: string;
|
|
294
|
+
type: "modal" | "home";
|
|
295
|
+
title: {
|
|
296
|
+
type: "plain_text";
|
|
297
|
+
text: string;
|
|
298
|
+
emoji?: boolean;
|
|
299
|
+
} | null;
|
|
300
|
+
close: {
|
|
301
|
+
type: "plain_text";
|
|
302
|
+
text: string;
|
|
303
|
+
emoji?: boolean;
|
|
304
|
+
} | null;
|
|
305
|
+
submit: {
|
|
306
|
+
type: "plain_text";
|
|
307
|
+
text: string;
|
|
308
|
+
emoji?: boolean;
|
|
309
|
+
} | null;
|
|
310
|
+
blocks: AnyBlock[];
|
|
311
|
+
private_metadata: string;
|
|
312
|
+
state: {
|
|
313
|
+
values: StateValues;
|
|
314
|
+
};
|
|
315
|
+
hash: string;
|
|
316
|
+
clear_on_close: boolean;
|
|
317
|
+
notify_on_close: boolean;
|
|
318
|
+
root_view_id: string;
|
|
319
|
+
previous_view_id: string | null;
|
|
320
|
+
external_id: string;
|
|
321
|
+
};
|
|
322
|
+
is_cleared: boolean;
|
|
323
|
+
};
|
|
324
|
+
/** The subset of `ack()` response actions a modal reacts to: validation errors, or view navigation. */
|
|
325
|
+
type ViewResponseAction = {
|
|
326
|
+
response_action: "errors";
|
|
327
|
+
errors: Record<string, string>;
|
|
328
|
+
} | {
|
|
329
|
+
response_action: "update";
|
|
330
|
+
view: ViewLike;
|
|
331
|
+
} | {
|
|
332
|
+
response_action: "push";
|
|
333
|
+
view: ViewLike;
|
|
334
|
+
} | {
|
|
335
|
+
response_action: "clear";
|
|
336
|
+
};
|
|
337
|
+
/** A static/external select option, as returned to a `block_suggestion` request. */
|
|
338
|
+
interface SuggestionOption {
|
|
339
|
+
text: {
|
|
340
|
+
type: "plain_text";
|
|
341
|
+
text: string;
|
|
342
|
+
emoji?: boolean;
|
|
343
|
+
};
|
|
344
|
+
value: string;
|
|
345
|
+
description?: {
|
|
346
|
+
type: "plain_text";
|
|
347
|
+
text: string;
|
|
348
|
+
emoji?: boolean;
|
|
349
|
+
};
|
|
350
|
+
url?: string;
|
|
351
|
+
}
|
|
352
|
+
/** What an app answers a `block_suggestion` request with: flat options or labelled groups. */
|
|
353
|
+
type OptionsResponse = {
|
|
354
|
+
options: SuggestionOption[];
|
|
355
|
+
} | {
|
|
356
|
+
option_groups: Array<{
|
|
357
|
+
label: {
|
|
358
|
+
type: "plain_text";
|
|
359
|
+
text: string;
|
|
360
|
+
emoji?: boolean;
|
|
361
|
+
};
|
|
362
|
+
options: SuggestionOption[];
|
|
363
|
+
}>;
|
|
364
|
+
};
|
|
365
|
+
interface BuildBlockSuggestionPayloadOptions {
|
|
366
|
+
actionId: string;
|
|
367
|
+
blockId: string;
|
|
368
|
+
/** What the user has typed into the select's search box so far. */
|
|
369
|
+
value: string;
|
|
370
|
+
container: Container;
|
|
371
|
+
state: StateValues;
|
|
372
|
+
identity?: PayloadIdentity;
|
|
373
|
+
}
|
|
374
|
+
/** Slack's `block_suggestion` payload, sent while the user types into an `external_select`. */
|
|
375
|
+
declare function buildBlockSuggestionPayload({ actionId, blockId, value, container, state, identity }: BuildBlockSuggestionPayloadOptions): {
|
|
376
|
+
container: {
|
|
377
|
+
type: "message";
|
|
378
|
+
message_ts: string;
|
|
379
|
+
channel_id: string | undefined;
|
|
380
|
+
is_ephemeral: boolean;
|
|
381
|
+
view_id?: undefined;
|
|
382
|
+
};
|
|
383
|
+
channel: {
|
|
384
|
+
id: string;
|
|
385
|
+
name: string;
|
|
386
|
+
} | undefined;
|
|
387
|
+
message: Record<string, unknown>;
|
|
388
|
+
type: "block_suggestion";
|
|
389
|
+
user: PayloadUser;
|
|
390
|
+
api_app_id: string;
|
|
391
|
+
token: string;
|
|
392
|
+
action_id: string;
|
|
393
|
+
block_id: string;
|
|
394
|
+
value: string;
|
|
395
|
+
team: PayloadTeam | null;
|
|
396
|
+
} | {
|
|
397
|
+
container: {
|
|
398
|
+
type: "view";
|
|
399
|
+
view_id: string;
|
|
400
|
+
message_ts?: undefined;
|
|
401
|
+
channel_id?: undefined;
|
|
402
|
+
is_ephemeral?: undefined;
|
|
403
|
+
};
|
|
404
|
+
view: {
|
|
405
|
+
id: string;
|
|
406
|
+
team_id: string;
|
|
407
|
+
app_installed_team_id: string;
|
|
408
|
+
app_id: string;
|
|
409
|
+
bot_id: string;
|
|
410
|
+
callback_id: string;
|
|
411
|
+
type: "modal" | "home";
|
|
412
|
+
title: {
|
|
413
|
+
type: "plain_text";
|
|
414
|
+
text: string;
|
|
415
|
+
emoji?: boolean;
|
|
416
|
+
} | null;
|
|
417
|
+
close: {
|
|
418
|
+
type: "plain_text";
|
|
419
|
+
text: string;
|
|
420
|
+
emoji?: boolean;
|
|
421
|
+
} | null;
|
|
422
|
+
submit: {
|
|
423
|
+
type: "plain_text";
|
|
424
|
+
text: string;
|
|
425
|
+
emoji?: boolean;
|
|
426
|
+
} | null;
|
|
427
|
+
blocks: AnyBlock[];
|
|
428
|
+
private_metadata: string;
|
|
429
|
+
state: {
|
|
430
|
+
values: StateValues;
|
|
431
|
+
};
|
|
432
|
+
hash: string;
|
|
433
|
+
clear_on_close: boolean;
|
|
434
|
+
notify_on_close: boolean;
|
|
435
|
+
root_view_id: string;
|
|
436
|
+
previous_view_id: string | null;
|
|
437
|
+
external_id: string;
|
|
438
|
+
};
|
|
439
|
+
type: "block_suggestion";
|
|
440
|
+
user: PayloadUser;
|
|
441
|
+
api_app_id: string;
|
|
442
|
+
token: string;
|
|
443
|
+
action_id: string;
|
|
444
|
+
block_id: string;
|
|
445
|
+
value: string;
|
|
446
|
+
team: PayloadTeam | null;
|
|
447
|
+
};
|
|
448
|
+
type BlockSuggestionPayload = ReturnType<typeof buildBlockSuggestionPayload>;
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/context.d.ts
|
|
451
|
+
/**
|
|
452
|
+
* The action object Slack puts in `block_actions.actions[]`. The extra fields depend on the
|
|
453
|
+
* element type (`value`, `selected_option`, `selected_date`, ...), exactly as Slack sends them.
|
|
454
|
+
*/
|
|
455
|
+
interface BlockAction {
|
|
456
|
+
type: string;
|
|
457
|
+
action_id: string;
|
|
458
|
+
block_id: string;
|
|
459
|
+
action_ts: string;
|
|
460
|
+
text?: {
|
|
461
|
+
type: "plain_text";
|
|
462
|
+
text: string;
|
|
463
|
+
emoji?: boolean;
|
|
464
|
+
};
|
|
465
|
+
value?: string;
|
|
466
|
+
url?: string;
|
|
467
|
+
style?: "primary" | "danger";
|
|
468
|
+
[field: string]: unknown;
|
|
469
|
+
}
|
|
470
|
+
/** One entry of `view.state.values[block_id][action_id]`, e.g. `{ type: "datepicker", selected_date: "2024-01-01" }`. */
|
|
471
|
+
interface ElementState {
|
|
472
|
+
type: string;
|
|
473
|
+
[field: string]: unknown;
|
|
474
|
+
}
|
|
475
|
+
/** Slack's `state.values`: element values keyed by block_id, then action_id. */
|
|
476
|
+
type StateValues = Record<string, Record<string, ElementState>>;
|
|
477
|
+
type Surface = "message" | "modal" | "home";
|
|
478
|
+
/** What a user mention's profile card shows; everything but the name is optional. */
|
|
479
|
+
interface UserProfile {
|
|
480
|
+
/** Display name, shown bold at the top of the card. */
|
|
481
|
+
name: string;
|
|
482
|
+
/** Full name, shown under the display name when it differs. */
|
|
483
|
+
realName?: string;
|
|
484
|
+
title?: string;
|
|
485
|
+
pronouns?: string;
|
|
486
|
+
avatarUrl?: string;
|
|
487
|
+
/** Custom status, e.g. `{ emoji: "palm_tree", text: "On vacation" }`. */
|
|
488
|
+
status?: {
|
|
489
|
+
emoji?: string;
|
|
490
|
+
text?: string;
|
|
491
|
+
};
|
|
492
|
+
/** IANA zone used for the card's "local time" row, e.g. `Europe/Amsterdam`. */
|
|
493
|
+
timeZone?: string;
|
|
494
|
+
}
|
|
495
|
+
/** Resolves ids in mrkdwn and rich text to display names. Return undefined when unknown. */
|
|
496
|
+
interface Resolvers {
|
|
497
|
+
user?: (id: string) => string | undefined;
|
|
498
|
+
/**
|
|
499
|
+
* Profile details for the card that opens when a user mention is clicked. Falls back to the
|
|
500
|
+
* name from `user` when omitted.
|
|
501
|
+
*/
|
|
502
|
+
userProfile?: (id: string) => UserProfile | undefined;
|
|
503
|
+
channel?: (id: string) => string | undefined;
|
|
504
|
+
usergroup?: (id: string) => string | undefined;
|
|
505
|
+
}
|
|
506
|
+
interface EmojiOptions {
|
|
507
|
+
/**
|
|
508
|
+
* Builds the image URL for a unified code point sequence such as `1f44d-1f3fd`. Defaults to the
|
|
509
|
+
* Apple set from emoji-datasource-apple on jsDelivr.
|
|
510
|
+
*/
|
|
511
|
+
imageUrl?: (unified: string) => string;
|
|
512
|
+
/** Workspace custom emoji: name → image URL, or `alias:<name>`. */
|
|
513
|
+
custom?: Record<string, string>;
|
|
514
|
+
}
|
|
515
|
+
/** A modal opened through {@link ViewsApi}, with the validation errors last returned for it. */
|
|
516
|
+
interface StackedView {
|
|
517
|
+
view: ViewLike & {
|
|
518
|
+
id: string;
|
|
519
|
+
};
|
|
520
|
+
errors: Record<string, string>;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Slack's `views.*` calls, for answering an interaction the way an app would: open a modal from a
|
|
524
|
+
* button, push a second one on top, or update one in place (e.g. after a `dispatch_action` input).
|
|
525
|
+
* Opened modals render on top of the provider's children, up to Slack's limit of 3.
|
|
526
|
+
*/
|
|
527
|
+
interface ViewsApi {
|
|
528
|
+
/** `views.open`: replaces any open modals with this one. Returns the new view's id. */
|
|
529
|
+
open: (view: ViewLike) => string;
|
|
530
|
+
/** `views.push`: stacks a modal on top of the current one. Returns the new view's id. */
|
|
531
|
+
push: (view: ViewLike) => string;
|
|
532
|
+
/**
|
|
533
|
+
* `views.update`: swaps a modal's content, keeping its id and any input values whose
|
|
534
|
+
* `block_id`/`action_id` are unchanged. Targets `viewId` or `externalId`, else the top modal.
|
|
535
|
+
*/
|
|
536
|
+
update: (view: ViewLike, target?: {
|
|
537
|
+
viewId?: string;
|
|
538
|
+
externalId?: string;
|
|
539
|
+
}) => void;
|
|
540
|
+
/** Closes the top modal, returning to the one below it. */
|
|
541
|
+
close: () => void;
|
|
542
|
+
/** Closes every open modal. */
|
|
543
|
+
clear: () => void;
|
|
544
|
+
/** `views.publish`: replaces the content of the `<HomeTab>` rendered under this provider. */
|
|
545
|
+
publish: (view: ViewLike) => void;
|
|
546
|
+
}
|
|
547
|
+
/** New content for a message, as an app would send with `chat.update` or a `response_url`. */
|
|
548
|
+
interface MessageUpdate {
|
|
549
|
+
blocks?: AnyBlock[];
|
|
550
|
+
text?: string;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Answers an interaction by changing the message it came from, like posting to its `response_url`
|
|
554
|
+
* with `replace_original` / `delete_original`, or calling `chat.update` / `chat.delete`.
|
|
555
|
+
*/
|
|
556
|
+
interface MessageApi {
|
|
557
|
+
/** Replaces the message's blocks and fallback text. */
|
|
558
|
+
update: (message: MessageUpdate) => void;
|
|
559
|
+
/** Removes the message. */
|
|
560
|
+
delete: () => void;
|
|
561
|
+
}
|
|
562
|
+
/** What an interaction happened in: the message/view it came from, and a handle to change the message. */
|
|
563
|
+
interface SurfaceScopeValue {
|
|
564
|
+
container: Container;
|
|
565
|
+
message?: MessageApi;
|
|
566
|
+
}
|
|
567
|
+
interface ActionContext {
|
|
568
|
+
/** State of every input on the surface at the time of the action, like `state.values`. */
|
|
569
|
+
state: StateValues;
|
|
570
|
+
/** Opens, pushes or updates modals in response, like an app calling `views.*`. */
|
|
571
|
+
views: ViewsApi;
|
|
572
|
+
/** Set for actions in a `<Message>`: replaces or deletes that message. */
|
|
573
|
+
message?: MessageApi;
|
|
574
|
+
}
|
|
575
|
+
/** The second argument of `onPayload`. */
|
|
576
|
+
interface PayloadContext {
|
|
577
|
+
views: ViewsApi;
|
|
578
|
+
/** Set for actions in a `<Message>`: replaces or deletes that message. */
|
|
579
|
+
message?: MessageApi;
|
|
580
|
+
}
|
|
581
|
+
/** What `onSubmit` may return: Slack's `response_action` ack, or nothing to just close the modal. */
|
|
582
|
+
type SubmitResult = ViewResponseAction | undefined | void;
|
|
583
|
+
interface BlockKitContextValue {
|
|
584
|
+
surface: Surface;
|
|
585
|
+
/** The provider's `theme`. Popovers, tooltips and dialogs render outside its wrapper, so they set it themselves. */
|
|
586
|
+
theme?: "light" | "dark";
|
|
587
|
+
onAction?: (action: BlockAction, context: ActionContext) => void;
|
|
588
|
+
/** Same actions as `onAction`, wrapped in the full Slack `block_actions` payload (team/user/container/...). */
|
|
589
|
+
onPayload?: (payload: ReturnType<typeof buildBlockActionsPayload>, context: PayloadContext) => void;
|
|
590
|
+
/** Called with a `view_submission` payload when a `<Modal>`'s Submit button is pressed. */
|
|
591
|
+
onSubmit?: (payload: ReturnType<typeof buildViewSubmissionPayload>, context: {
|
|
592
|
+
views: ViewsApi;
|
|
593
|
+
}) => SubmitResult | Promise<SubmitResult>;
|
|
594
|
+
/** Called with a `view_closed` payload when a `<Modal>`'s close (X) button is pressed. */
|
|
595
|
+
onClose?: (payload: ReturnType<typeof buildViewClosedPayload>) => void;
|
|
596
|
+
resolvers: Resolvers;
|
|
597
|
+
emoji: EmojiOptions;
|
|
598
|
+
/** Validation errors keyed by block_id, as returned in `response_action: "errors"`. */
|
|
599
|
+
errors: Record<string, string>;
|
|
600
|
+
/** IANA zone for `<!date>` tokens and date elements. Undefined means the viewer's zone. */
|
|
601
|
+
timeZone?: string;
|
|
602
|
+
state: StateValues;
|
|
603
|
+
/** Records an element's current value. Elements call this on every change. */
|
|
604
|
+
setValue: (blockId: string, actionId: string, value: ElementState | undefined) => void;
|
|
605
|
+
/**
|
|
606
|
+
* Reports an action, passing the current state along. `scope` is the surface it happened in;
|
|
607
|
+
* surfaces bind it for their elements, so elements never pass it themselves.
|
|
608
|
+
*/
|
|
609
|
+
dispatch: (action: Partial<Pick<BlockAction, "action_ts">> & Omit<BlockAction, "action_ts">, scope?: SurfaceScopeValue) => void;
|
|
610
|
+
/** Identity fields (team/user/trigger_id/...) used to build full Slack payloads. */
|
|
611
|
+
identity: PayloadIdentity;
|
|
612
|
+
/**
|
|
613
|
+
* Registers the message/view a surface is rendering, so `dispatch` can build a full
|
|
614
|
+
* `block_actions` payload for `onPayload`. Surfaces call this via `useContainer`; not meant to
|
|
615
|
+
* be called directly.
|
|
616
|
+
*/
|
|
617
|
+
setContainer: (container: Container | undefined) => void;
|
|
618
|
+
views: ViewsApi;
|
|
619
|
+
/**
|
|
620
|
+
* Asks the app for an `external_select`'s options with a `block_suggestion` payload. Resolves
|
|
621
|
+
* to undefined when there's no `onOptions` handler or no known container.
|
|
622
|
+
*/
|
|
623
|
+
loadOptions?: (actionId: string, blockId: string, value: string, scope?: SurfaceScopeValue) => Promise<OptionsResponse | undefined>;
|
|
624
|
+
/** Set on a modal opened through `views`: the stack entry it renders. */
|
|
625
|
+
stackedView?: StackedView;
|
|
626
|
+
/** Applies a submit's `response_action` (or closes) for a stacked modal. */
|
|
627
|
+
respond?: (viewId: string, result: SubmitResult) => void;
|
|
628
|
+
}
|
|
629
|
+
interface BlockKitProviderProps {
|
|
630
|
+
children: ReactNode;
|
|
631
|
+
surface?: Surface;
|
|
632
|
+
onAction?: (action: BlockAction, context: ActionContext) => void;
|
|
633
|
+
/**
|
|
634
|
+
* Same actions as `onAction`, wrapped in the full Slack `block_actions` payload (team, user,
|
|
635
|
+
* container, response_url, ...) that an app's request URL would receive. Requires the surface
|
|
636
|
+
* being rendered (`<Message>`, `<Modal>`, `<HomeTab>`) to know its container, which they do
|
|
637
|
+
* automatically.
|
|
638
|
+
*/
|
|
639
|
+
onPayload?: (payload: ReturnType<typeof buildBlockActionsPayload>, context: PayloadContext) => void;
|
|
640
|
+
/**
|
|
641
|
+
* Called with a `view_submission` payload when a `<Modal>`'s Submit button is pressed. For a
|
|
642
|
+
* modal opened through `views`, return a `response_action` (`errors`, `update`, `push`,
|
|
643
|
+
* `clear`) to react as Slack would, or nothing to close it. If it throws or rejects (the app
|
|
644
|
+
* couldn't be reached), the modal stays open.
|
|
645
|
+
*/
|
|
646
|
+
onSubmit?: (payload: ReturnType<typeof buildViewSubmissionPayload>, context: {
|
|
647
|
+
views: ViewsApi;
|
|
648
|
+
}) => SubmitResult | Promise<SubmitResult>;
|
|
649
|
+
/** Called with a `view_closed` payload when a `<Modal>`'s close (X) button is pressed. */
|
|
650
|
+
onClose?: (payload: ReturnType<typeof buildViewClosedPayload>) => void;
|
|
651
|
+
/**
|
|
652
|
+
* Answers an `external_select`'s `block_suggestion` request with options, as an app's options
|
|
653
|
+
* load URL would. Without it, external selects accept a typed value on Enter instead.
|
|
654
|
+
*/
|
|
655
|
+
onOptions?: (payload: BlockSuggestionPayload) => OptionsResponse | Promise<OptionsResponse>;
|
|
656
|
+
/** Called whenever an input value changes, with the full `state.values`. */
|
|
657
|
+
onStateChange?: (state: StateValues) => void;
|
|
658
|
+
resolvers?: Resolvers;
|
|
659
|
+
emoji?: EmojiOptions;
|
|
660
|
+
errors?: Record<string, string>;
|
|
661
|
+
timeZone?: string;
|
|
662
|
+
/** Team/user/trigger_id/... stamped onto payloads built for `onPayload`/`onSubmit`/`onClose`. */
|
|
663
|
+
identity?: PayloadIdentity;
|
|
664
|
+
/** Sets `data-theme` on a wrapper div so Slack's dark-mode CSS variables (Message.css) apply. */
|
|
665
|
+
theme?: "light" | "dark";
|
|
666
|
+
}
|
|
667
|
+
declare function BlockKitProvider(props: BlockKitProviderProps): import("react").JSX.Element;
|
|
668
|
+
declare function useBlockKit(): BlockKitContextValue;
|
|
669
|
+
/**
|
|
670
|
+
* Registers the message/view a surface (`<Message>`, `<Modal>`, `<HomeTab>`) is rendering, so
|
|
671
|
+
* `dispatch` can build a full `block_actions` payload for the provider's `onPayload`. Call once
|
|
672
|
+
* near the top of a surface component; re-call (it's cheap) whenever the container's identity
|
|
673
|
+
* changes.
|
|
674
|
+
*/
|
|
675
|
+
declare function useContainer(container: Container | undefined): void;
|
|
676
|
+
interface SurfaceScopeProps extends SurfaceScopeValue {
|
|
677
|
+
/** Extra validation errors (by block_id) shown on top of the provider's. */
|
|
678
|
+
errors?: Record<string, string>;
|
|
679
|
+
children: ReactNode;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Binds the elements below it to one surface: their actions and options requests carry this
|
|
683
|
+
* container (and message handle), even when several surfaces share a provider. `<Message>`,
|
|
684
|
+
* `<Modal>` and `<HomeTab>` render one; custom surfaces can too.
|
|
685
|
+
*/
|
|
686
|
+
declare function SurfaceScope({ container, message, errors, children }: SurfaceScopeProps): import("react").JSX.Element;
|
|
687
|
+
/**
|
|
688
|
+
* The view a `<HomeTab>` or standalone `<Modal>` should show: its `view` prop, or what the app
|
|
689
|
+
* last sent with `views.update`/`views.publish`. A new `view` prop (by content) wins again.
|
|
690
|
+
*/
|
|
691
|
+
declare function useLiveView<V extends ViewLike>(view: V, enabled?: boolean): {
|
|
692
|
+
view: V;
|
|
693
|
+
update: (next: ViewLike) => void;
|
|
694
|
+
};
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region src/elements/Element.d.ts
|
|
697
|
+
/** Renders any interactive or image element. Unsupported types render a visible placeholder. */
|
|
698
|
+
declare function Element({ element, blockId }: {
|
|
699
|
+
element: Json;
|
|
700
|
+
blockId: string;
|
|
701
|
+
}): import("react").JSX.Element;
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/elements/index.d.ts
|
|
704
|
+
declare const elementComponents: Record<string, ComponentType<ElementProps<any>>>;
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/Message.d.ts
|
|
707
|
+
interface MessageApp {
|
|
708
|
+
name: string;
|
|
709
|
+
iconUrl?: string;
|
|
710
|
+
}
|
|
711
|
+
/** A reaction as Slack stores it on a message (`reactions[]` from conversations.history). */
|
|
712
|
+
interface SlackReaction {
|
|
713
|
+
name: string;
|
|
714
|
+
count: number;
|
|
715
|
+
users?: string[];
|
|
716
|
+
}
|
|
717
|
+
/** One field of a legacy attachment (`attachments[].fields[]`). */
|
|
718
|
+
interface SlackAttachmentField {
|
|
719
|
+
title: string;
|
|
720
|
+
value: string;
|
|
721
|
+
short?: boolean;
|
|
722
|
+
}
|
|
723
|
+
/** A legacy attachment, as Slack still renders it (colour bar, pretext, title, fields, footer). */
|
|
724
|
+
interface SlackAttachment {
|
|
725
|
+
color?: string;
|
|
726
|
+
pretext?: string;
|
|
727
|
+
author_name?: string;
|
|
728
|
+
author_icon?: string;
|
|
729
|
+
author_link?: string;
|
|
730
|
+
title?: string;
|
|
731
|
+
title_link?: string;
|
|
732
|
+
text?: string;
|
|
733
|
+
fields?: SlackAttachmentField[];
|
|
734
|
+
image_url?: string;
|
|
735
|
+
footer?: string;
|
|
736
|
+
footer_icon?: string;
|
|
737
|
+
ts?: string | number;
|
|
738
|
+
/** Slack also lets attachments carry Block Kit blocks directly. */
|
|
739
|
+
blocks?: AnyBlock[];
|
|
740
|
+
}
|
|
741
|
+
/** A message object as returned by `conversations.history` / stored by `@emulators/slack`. */
|
|
742
|
+
interface SlackMessageLike {
|
|
743
|
+
ts?: string;
|
|
744
|
+
channel?: string;
|
|
745
|
+
blocks?: AnyBlock[];
|
|
746
|
+
text?: string;
|
|
747
|
+
username?: string;
|
|
748
|
+
icon_url?: string;
|
|
749
|
+
icon_emoji?: string;
|
|
750
|
+
bot_profile?: {
|
|
751
|
+
name?: string;
|
|
752
|
+
icons?: {
|
|
753
|
+
image_72?: string;
|
|
754
|
+
image_48?: string;
|
|
755
|
+
};
|
|
756
|
+
};
|
|
757
|
+
edited?: {
|
|
758
|
+
ts?: string;
|
|
759
|
+
user?: string;
|
|
760
|
+
};
|
|
761
|
+
attachments?: SlackAttachment[];
|
|
762
|
+
reactions?: SlackReaction[];
|
|
763
|
+
reply_count?: number;
|
|
764
|
+
reply_users_count?: number;
|
|
765
|
+
latest_reply?: string;
|
|
766
|
+
subscribed?: boolean;
|
|
767
|
+
}
|
|
768
|
+
interface MessageProps {
|
|
769
|
+
blocks?: AnyBlock[];
|
|
770
|
+
/** Fallback text. Slack shows it only when there are no blocks. */
|
|
771
|
+
text?: string;
|
|
772
|
+
app?: MessageApp;
|
|
773
|
+
/** Message timestamp (Slack `ts`, seconds). Defaults to now. */
|
|
774
|
+
ts?: string | number;
|
|
775
|
+
/** IANA zone for the displayed time. Defaults to the viewer's zone, like Slack. */
|
|
776
|
+
timeZone?: string;
|
|
777
|
+
/**
|
|
778
|
+
* A Slack message object (e.g. from `conversations.history`, or as stored by
|
|
779
|
+
* `@emulators/slack`). When given, it supplies blocks/text/ts and the sender header
|
|
780
|
+
* (username/icon/bot_profile), plus attachments, reactions, thread summary and edited marker.
|
|
781
|
+
* `blocks`/`text`/`app`/`ts` above still work standalone for simple previews.
|
|
782
|
+
*/
|
|
783
|
+
message?: SlackMessageLike;
|
|
784
|
+
/** The channel the message is in. Used for the `block_actions` container Slack would send. */
|
|
785
|
+
channelId?: string;
|
|
786
|
+
/** Slack's "Only visible to you" marker, shown for ephemeral messages. */
|
|
787
|
+
isEphemeral?: boolean;
|
|
788
|
+
}
|
|
789
|
+
/** A message as it appears in a Slack channel: avatar, app name, APP badge, time and blocks. */
|
|
790
|
+
declare function Message({ blocks, text, app, ts, timeZone, message, channelId, isEphemeral }: MessageProps): import("react").JSX.Element | null;
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/Mrkdwn.d.ts
|
|
793
|
+
interface MrkdwnProps {
|
|
794
|
+
text: string;
|
|
795
|
+
/** Slack's `verbatim` flag. When false (the default), bare URLs are linked. */
|
|
796
|
+
verbatim?: boolean;
|
|
797
|
+
/** Pixel size for `:emoji:` images. Defaults to 22 (Slack's inline size at 15px text). */
|
|
798
|
+
emojiSize?: number;
|
|
799
|
+
}
|
|
800
|
+
/** Renders a Slack mrkdwn string. */
|
|
801
|
+
declare function Mrkdwn({ text, verbatim, emojiSize }: MrkdwnProps): import("react").JSX.Element;
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/surfaces/HomeTab.d.ts
|
|
804
|
+
interface HomeTabView extends ViewLike {
|
|
805
|
+
type: "home";
|
|
806
|
+
}
|
|
807
|
+
interface HomeTabProps {
|
|
808
|
+
view: HomeTabView;
|
|
809
|
+
}
|
|
810
|
+
/** A Slack Home tab: just its blocks, laid out full width like Slack's App Home. */
|
|
811
|
+
declare function HomeTab({ view: viewProp }: HomeTabProps): import("react").JSX.Element;
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region src/surfaces/Modal.d.ts
|
|
814
|
+
interface ModalView extends ViewLike {
|
|
815
|
+
type: "modal";
|
|
816
|
+
}
|
|
817
|
+
interface ModalProps {
|
|
818
|
+
view: ModalView;
|
|
819
|
+
/** App icon shown before the title, as in Slack's own modal chrome. */
|
|
820
|
+
icon?: string;
|
|
821
|
+
}
|
|
822
|
+
/** A Slack modal: header (icon + title + close), a scrollable body of blocks, and a close/submit footer. */
|
|
823
|
+
declare function Modal({ view: viewProp, icon }: ModalProps): import("react").JSX.Element;
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/surfaces/View.d.ts
|
|
826
|
+
type AnyView = ModalView | HomeTabView;
|
|
827
|
+
interface ViewProps {
|
|
828
|
+
view: AnyView;
|
|
829
|
+
/** App icon shown before the modal title. No effect on the Home tab (Slack doesn't show it there). */
|
|
830
|
+
icon?: string;
|
|
831
|
+
}
|
|
832
|
+
/** Dispatches a Slack `view` payload (as from `views.open`/`views.publish`) to `<Modal>` or `<HomeTab>`. */
|
|
833
|
+
declare function View({ view, icon }: ViewProps): import("react").JSX.Element;
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/Text.d.ts
|
|
836
|
+
type TextObject = PlainTextElement | MrkdwnElement;
|
|
837
|
+
interface TextProps {
|
|
838
|
+
text: TextObject;
|
|
839
|
+
/** Pixel size for `:emoji:` images. Defaults to 22 (Slack's inline size at 15px text). */
|
|
840
|
+
emojiSize?: number;
|
|
841
|
+
}
|
|
842
|
+
/** Renders a Block Kit text object. */
|
|
843
|
+
declare function Text({ text, emojiSize }: TextProps): import("react").JSX.Element;
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/Tooltip.d.ts
|
|
846
|
+
type Placement = "top" | "bottom";
|
|
847
|
+
type AnchorProps = {
|
|
848
|
+
onMouseEnter?: (e: MouseEvent) => void;
|
|
849
|
+
onMouseLeave?: (e: MouseEvent) => void;
|
|
850
|
+
onFocus?: (e: FocusEvent) => void;
|
|
851
|
+
onBlur?: (e: FocusEvent) => void;
|
|
852
|
+
"aria-describedby"?: string;
|
|
853
|
+
};
|
|
854
|
+
interface TooltipProps {
|
|
855
|
+
/** Tooltip content; nothing is rendered when empty. */
|
|
856
|
+
label: ReactNode;
|
|
857
|
+
/** A single element to anchor to; it receives the hover/focus handlers. */
|
|
858
|
+
children: ReactElement<AnchorProps>;
|
|
859
|
+
/** Preferred side; flips to the other one when there's no room. Defaults to `top`. */
|
|
860
|
+
placement?: Placement;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Slack's `c-tooltip`: a dark, bold 13px bubble with an arrow, shown above (or below) its anchor
|
|
864
|
+
* after a short hover or on keyboard focus. It appears and disappears without animation, as in
|
|
865
|
+
* Slack. Portalled to `<body>` so scroll containers and `overflow: hidden` can't clip it.
|
|
866
|
+
*/
|
|
867
|
+
declare function Tooltip({ label, children, placement }: TooltipProps): import("react").JSX.Element;
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/UserMention.d.ts
|
|
870
|
+
interface UserMentionProps {
|
|
871
|
+
/** Slack user id, e.g. `U0123ABC`. */
|
|
872
|
+
id: string;
|
|
873
|
+
/** Display name, rendered as `@name`. */
|
|
874
|
+
name: string;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* A resolved `@user` mention. Clicking it (or Enter/Space when focused) opens a profile card like
|
|
878
|
+
* Slack's `p-member_profile_card` popover: avatar, names, title, status and local time, filled from
|
|
879
|
+
* `resolvers.userProfile` and falling back to the display name alone.
|
|
880
|
+
*/
|
|
881
|
+
declare function UserMention({ id, name }: UserMentionProps): import("react").JSX.Element;
|
|
882
|
+
//#endregion
|
|
883
|
+
//#region src/validation.d.ts
|
|
884
|
+
/**
|
|
885
|
+
* The checks Slack's client runs on a modal before it sends `view_submission`: required inputs,
|
|
886
|
+
* text length, number format/range, and email/URL format. A failing field shows its message under
|
|
887
|
+
* the input and the submission never reaches the app.
|
|
888
|
+
*
|
|
889
|
+
* Slack doesn't document the exact wording; these follow its client's phrasing as closely as we
|
|
890
|
+
* know it and live here so they can be adjusted in one place.
|
|
891
|
+
*/
|
|
892
|
+
declare const VALIDATION_MESSAGES: {
|
|
893
|
+
required: string;
|
|
894
|
+
minLength: (n: number) => string;
|
|
895
|
+
maxLength: (n: number) => string;
|
|
896
|
+
number: string;
|
|
897
|
+
wholeNumber: string;
|
|
898
|
+
minValue: (min: string) => string;
|
|
899
|
+
maxValue: (max: string) => string;
|
|
900
|
+
email: string;
|
|
901
|
+
url: string;
|
|
902
|
+
};
|
|
903
|
+
/**
|
|
904
|
+
* Validates a view's `input` blocks against `state.values` the way Slack's client does before a
|
|
905
|
+
* submission. Returns errors keyed by block_id (the shape of `response_action: "errors"`); empty
|
|
906
|
+
* when the view may be submitted.
|
|
907
|
+
*/
|
|
908
|
+
declare function validateView(blocks: readonly Json[] | readonly unknown[], state: StateValues): Record<string, string>;
|
|
909
|
+
//#endregion
|
|
910
|
+
export { BlockSuggestionPayload as $, BlockAction as A, StackedView as B, SlackAttachment as C, BlockProps as Ct, elementComponents as D, SlackReaction as E, EmojiOptions as F, SurfaceScopeProps as G, SubmitResult as H, MessageApi as I, ViewsApi as J, SurfaceScopeValue as K, MessageUpdate as L, BlockKitProvider as M, BlockKitProviderProps as N, Element as O, ElementState as P, BlockActionsPayload as Q, PayloadContext as R, MessageProps as S, Blocks as St, SlackMessageLike as T, Json as Tt, Surface as U, StateValues as V, SurfaceScope as W, useContainer as X, useBlockKit as Y, useLiveView as Z, HomeTabView as _, buildBlockSuggestionPayload as _t, Tooltip as a, MessageBlockActionsPayload as at, Message as b, blockComponents as bt, TextObject as c, PayloadIdentity as ct, ViewProps as d, SuggestionOption as dt, BuildBlockActionsPayloadOptions as et, Modal as f, ViewBlockActionsPayload as ft, HomeTabProps as g, buildBlockActionsPayload as gt, HomeTab as h, ViewResponseAction as ht, UserMentionProps as i, Container as it, BlockKitContextValue as j, ActionContext as k, AnyView as l, PayloadTeam as lt, ModalView as m, ViewLike as mt, validateView as n, BuildViewClosedPayloadOptions as nt, TooltipProps as o, MessageContainer as ot, ModalProps as p, ViewContainer as pt, UserProfile as q, UserMention as r, BuildViewSubmissionPayloadOptions as rt, Text as s, OptionsResponse as st, VALIDATION_MESSAGES as t, BuildBlockSuggestionPayloadOptions as tt, View as u, PayloadUser as ut, Mrkdwn as v, buildViewClosedPayload as vt, SlackAttachmentField as w, ElementProps as wt, MessageApp as x, Block as xt, MrkdwnProps as y, buildViewSubmissionPayload as yt, Resolvers as z };
|
|
911
|
+
//# sourceMappingURL=index-FPjJcmn3.d.ts.map
|