@nkootstra/block-kit 0.3.4 → 0.3.5
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-D139DZfD.d.ts → index-DXUlQCUq.d.ts} +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -7
- package/dist/index.js.map +1 -1
- package/dist/transport.d.ts +1 -1
- package/dist/web-api.d.ts +1 -1
- package/package.json +1 -1
|
@@ -63,6 +63,8 @@ interface PayloadIdentity {
|
|
|
63
63
|
token?: string;
|
|
64
64
|
triggerId?: string;
|
|
65
65
|
responseUrl?: string;
|
|
66
|
+
/** Whether the app is installed org-wide on an Enterprise Grid org (`is_enterprise_install`). */
|
|
67
|
+
isEnterpriseInstall?: boolean;
|
|
66
68
|
}
|
|
67
69
|
declare const DEFAULT_IDENTITY: {
|
|
68
70
|
team: PayloadTeam | null;
|
|
@@ -71,6 +73,7 @@ declare const DEFAULT_IDENTITY: {
|
|
|
71
73
|
token: string;
|
|
72
74
|
triggerId: string;
|
|
73
75
|
responseUrl: string;
|
|
76
|
+
isEnterpriseInstall: boolean;
|
|
74
77
|
};
|
|
75
78
|
type ResolvedIdentity = typeof DEFAULT_IDENTITY;
|
|
76
79
|
/** The `message` surface's container: the message the block_actions/actions came from. */
|
|
@@ -159,10 +162,18 @@ interface BuildBlockActionsPayloadOptions {
|
|
|
159
162
|
container: Container;
|
|
160
163
|
identity?: PayloadIdentity;
|
|
161
164
|
}
|
|
165
|
+
/** The Enterprise Grid org a payload came from, as Slack names it. */
|
|
166
|
+
interface PayloadEnterprise {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
}
|
|
162
170
|
interface BlockActionsPayloadBase {
|
|
163
171
|
type: "block_actions";
|
|
164
172
|
actions: BlockAction[];
|
|
165
173
|
team: PayloadTeam | null;
|
|
174
|
+
/** The team's Enterprise Grid org, or `null` outside one. */
|
|
175
|
+
enterprise: PayloadEnterprise | null;
|
|
176
|
+
is_enterprise_install: boolean;
|
|
166
177
|
user: PayloadUser;
|
|
167
178
|
token?: string;
|
|
168
179
|
response_url?: string;
|
|
@@ -940,4 +951,4 @@ declare const VALIDATION_MESSAGES: {
|
|
|
940
951
|
declare function validateView(blocks: readonly Json[] | readonly unknown[], state: StateValues): Record<string, string>;
|
|
941
952
|
//#endregion
|
|
942
953
|
export { useLiveView as $, BlockAction as A, PayloadContext as B, SlackAttachment as C, Block as Ct, elementComponents as D, Json as Dt, SlackReaction as E, ElementProps as Et, EmojiOptions as F, Surface as G, StackedView as H, LinkProps as I, SurfaceScopeValue as J, SurfaceScope as K, MentionRef as L, BlockKitProvider as M, BlockKitProviderProps as N, Element as O, ElementState as P, useContainer as Q, MessageApi as R, MessageProps as S, blockComponents as St, SlackMessageLike as T, BlockProps as Tt, StateValues as U, Resolvers as V, SubmitResult as W, ViewsApi as X, UserProfile as Y, useBlockKit as Z, HomeTabView as _, ViewResponseAction as _t, Tooltip as a, BuildViewSubmissionPayloadOptions as at, Message as b, buildViewClosedPayload as bt, TextObject as c, MessageContainer as ct, ViewProps as d, PayloadTeam as dt, BlockActionsPayload as et, Modal as f, PayloadUser as ft, HomeTabProps as g, ViewLike as gt, HomeTab as h, ViewContainer as ht, UserMentionProps as i, BuildViewClosedPayloadOptions as it, BlockKitContextValue as j, ActionContext as k, AnyView as l, OptionsResponse as lt, ModalView as m, ViewBlockActionsPayload as mt, validateView as n, BuildBlockActionsPayloadOptions as nt, TooltipProps as o, Container as ot, ModalProps as p, SuggestionOption as pt, SurfaceScopeProps as q, UserMention as r, BuildBlockSuggestionPayloadOptions as rt, Text as s, MessageBlockActionsPayload as st, VALIDATION_MESSAGES as t, BlockSuggestionPayload as tt, View as u, PayloadIdentity as ut, Mrkdwn as v, buildBlockActionsPayload as vt, SlackAttachmentField as w, Blocks as wt, MessageApp as x, buildViewSubmissionPayload as xt, MrkdwnProps as y, buildBlockSuggestionPayload as yt, MessageUpdate as z };
|
|
943
|
-
//# sourceMappingURL=index-
|
|
954
|
+
//# sourceMappingURL=index-DXUlQCUq.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as useLiveView, A as BlockAction, B as PayloadContext, C as SlackAttachment, Ct as Block, D as elementComponents, Dt as Json, E as SlackReaction, Et as ElementProps, F as EmojiOptions, G as Surface, H as StackedView, I as LinkProps, J as SurfaceScopeValue, K as SurfaceScope, L as MentionRef, M as BlockKitProvider, N as BlockKitProviderProps, O as Element, P as ElementState, Q as useContainer, R as MessageApi, S as MessageProps, St as blockComponents, T as SlackMessageLike, Tt as BlockProps, U as StateValues, V as Resolvers, W as SubmitResult, X as ViewsApi, Y as UserProfile, Z as useBlockKit, _ as HomeTabView, _t as ViewResponseAction, a as Tooltip, at as BuildViewSubmissionPayloadOptions, b as Message, bt as buildViewClosedPayload, c as TextObject, ct as MessageContainer, d as ViewProps, dt as PayloadTeam, et as BlockActionsPayload, f as Modal, ft as PayloadUser, g as HomeTabProps, gt as ViewLike, h as HomeTab, ht as ViewContainer, i as UserMentionProps, it as BuildViewClosedPayloadOptions, j as BlockKitContextValue, k as ActionContext, l as AnyView, lt as OptionsResponse, m as ModalView, mt as ViewBlockActionsPayload, n as validateView, nt as BuildBlockActionsPayloadOptions, o as TooltipProps, ot as Container, p as ModalProps, pt as SuggestionOption, q as SurfaceScopeProps, r as UserMention, rt as BuildBlockSuggestionPayloadOptions, s as Text, st as MessageBlockActionsPayload, t as VALIDATION_MESSAGES, tt as BlockSuggestionPayload, u as View, ut as PayloadIdentity, v as Mrkdwn, vt as buildBlockActionsPayload, w as SlackAttachmentField, wt as Blocks, x as MessageApp, xt as buildViewSubmissionPayload, y as MrkdwnProps, yt as buildBlockSuggestionPayload, z as MessageUpdate } from "./index-
|
|
2
|
+
import { $ as useLiveView, A as BlockAction, B as PayloadContext, C as SlackAttachment, Ct as Block, D as elementComponents, Dt as Json, E as SlackReaction, Et as ElementProps, F as EmojiOptions, G as Surface, H as StackedView, I as LinkProps, J as SurfaceScopeValue, K as SurfaceScope, L as MentionRef, M as BlockKitProvider, N as BlockKitProviderProps, O as Element, P as ElementState, Q as useContainer, R as MessageApi, S as MessageProps, St as blockComponents, T as SlackMessageLike, Tt as BlockProps, U as StateValues, V as Resolvers, W as SubmitResult, X as ViewsApi, Y as UserProfile, Z as useBlockKit, _ as HomeTabView, _t as ViewResponseAction, a as Tooltip, at as BuildViewSubmissionPayloadOptions, b as Message, bt as buildViewClosedPayload, c as TextObject, ct as MessageContainer, d as ViewProps, dt as PayloadTeam, et as BlockActionsPayload, f as Modal, ft as PayloadUser, g as HomeTabProps, gt as ViewLike, h as HomeTab, ht as ViewContainer, i as UserMentionProps, it as BuildViewClosedPayloadOptions, j as BlockKitContextValue, k as ActionContext, l as AnyView, lt as OptionsResponse, m as ModalView, mt as ViewBlockActionsPayload, n as validateView, nt as BuildBlockActionsPayloadOptions, o as TooltipProps, ot as Container, p as ModalProps, pt as SuggestionOption, q as SurfaceScopeProps, r as UserMention, rt as BuildBlockSuggestionPayloadOptions, s as Text, st as MessageBlockActionsPayload, t as VALIDATION_MESSAGES, tt as BlockSuggestionPayload, u as View, ut as PayloadIdentity, v as Mrkdwn, vt as buildBlockActionsPayload, w as SlackAttachmentField, wt as Blocks, x as MessageApp, xt as buildViewSubmissionPayload, y as MrkdwnProps, yt as buildBlockSuggestionPayload, z as MessageUpdate } from "./index-DXUlQCUq.js";
|
|
3
3
|
export { type ActionContext, type AnyView, Block, type BlockAction, type BlockActionsPayload, type BlockKitContextValue, BlockKitProvider, type BlockKitProviderProps, type BlockProps, type BlockSuggestionPayload, Blocks, type BuildBlockActionsPayloadOptions, type BuildBlockSuggestionPayloadOptions, type BuildViewClosedPayloadOptions, type BuildViewSubmissionPayloadOptions, type Container, Element, type ElementProps, type ElementState, type EmojiOptions, HomeTab, type HomeTabProps, type HomeTabView, type Json, type LinkProps, type MentionRef, Message, type MessageApi, type MessageApp, type MessageBlockActionsPayload, type MessageContainer, type MessageProps, type MessageUpdate, Modal, type ModalProps, type ModalView, Mrkdwn, type MrkdwnProps, type OptionsResponse, type PayloadContext, type PayloadIdentity, type PayloadTeam, type PayloadUser, type Resolvers, type SlackAttachment, type SlackAttachmentField, type SlackMessageLike, type SlackReaction, type StackedView, type StateValues, type SubmitResult, type SuggestionOption, type Surface, SurfaceScope, type SurfaceScopeProps, type SurfaceScopeValue, Text, type TextObject, Tooltip, type TooltipProps, UserMention, type UserMentionProps, type UserProfile, VALIDATION_MESSAGES, View, type ViewBlockActionsPayload, type ViewContainer, type ViewLike, type ViewProps, type ViewResponseAction, type ViewsApi, blockComponents, buildBlockActionsPayload, buildBlockSuggestionPayload, buildViewClosedPayload, buildViewSubmissionPayload, elementComponents, useBlockKit, useContainer, useLiveView, validateView };
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,8 @@ const DEFAULT_IDENTITY = {
|
|
|
31
31
|
apiAppId: "A00000000",
|
|
32
32
|
token: "verification-token",
|
|
33
33
|
triggerId: "000000000000.000000000000.deadbeefdeadbeefdeadbeefdeadbeef",
|
|
34
|
-
responseUrl: "https://hooks.slack.com/actions/T00000000/0000000000000/deadbeefdeadbeefdeadbeefdeadbeef"
|
|
34
|
+
responseUrl: "https://hooks.slack.com/actions/T00000000/0000000000000/deadbeefdeadbeefdeadbeefdeadbeef",
|
|
35
|
+
isEnterpriseInstall: false
|
|
35
36
|
};
|
|
36
37
|
function resolveIdentity(identity) {
|
|
37
38
|
return {
|
|
@@ -63,12 +64,66 @@ function toViewOutput(view, state, identity) {
|
|
|
63
64
|
external_id: view.external_id ?? ""
|
|
64
65
|
};
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* A text object as Slack echoes it back: `plain_text` gains `emoji: true` and `mrkdwn` gains
|
|
69
|
+
* `verbatim: false` unless the app set them.
|
|
70
|
+
*/
|
|
71
|
+
function normalizeText(text) {
|
|
72
|
+
if (typeof text !== "object" || text === null) return text;
|
|
73
|
+
const object = text;
|
|
74
|
+
if (object.type === "plain_text") return {
|
|
75
|
+
...text,
|
|
76
|
+
emoji: object.emoji ?? true
|
|
77
|
+
};
|
|
78
|
+
if (object.type === "mrkdwn") return {
|
|
79
|
+
...text,
|
|
80
|
+
verbatim: object.verbatim ?? false
|
|
81
|
+
};
|
|
82
|
+
return text;
|
|
83
|
+
}
|
|
84
|
+
function normalizeOption(option) {
|
|
85
|
+
if (typeof option !== "object" || option === null) return option;
|
|
86
|
+
const { text, description } = option;
|
|
87
|
+
return {
|
|
88
|
+
...option,
|
|
89
|
+
...text === void 0 ? {} : { text: normalizeText(text) },
|
|
90
|
+
...description === void 0 ? {} : { description: normalizeText(description) }
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** An action or state entry with every text object it echoes normalized like Slack's. */
|
|
94
|
+
function normalizeEchoes(entry) {
|
|
95
|
+
const out = { ...entry };
|
|
96
|
+
if (out.text !== void 0) out.text = normalizeText(out.text);
|
|
97
|
+
if (out.placeholder !== void 0) out.placeholder = normalizeText(out.placeholder);
|
|
98
|
+
if (out.selected_option) out.selected_option = normalizeOption(out.selected_option);
|
|
99
|
+
if (Array.isArray(out.selected_options)) out.selected_options = out.selected_options.map(normalizeOption);
|
|
100
|
+
if (typeof out.confirm === "object" && out.confirm !== null) {
|
|
101
|
+
const confirm = { ...out.confirm };
|
|
102
|
+
for (const key of [
|
|
103
|
+
"title",
|
|
104
|
+
"text",
|
|
105
|
+
"confirm",
|
|
106
|
+
"deny"
|
|
107
|
+
]) if (confirm[key] !== void 0) confirm[key] = normalizeText(confirm[key]);
|
|
108
|
+
out.confirm = confirm;
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
function normalizeState(state) {
|
|
113
|
+
return Object.fromEntries(Object.entries(state).map(([blockId, elements]) => [blockId, Object.fromEntries(Object.entries(elements).map(([actionId, value]) => [actionId, normalizeEchoes(value)]))]));
|
|
114
|
+
}
|
|
66
115
|
function buildBlockActionsPayload({ action, state, container, identity }) {
|
|
67
116
|
const id = resolveIdentity(identity);
|
|
117
|
+
state = normalizeState(state);
|
|
68
118
|
const base = {
|
|
69
119
|
type: "block_actions",
|
|
70
|
-
actions: [action],
|
|
120
|
+
actions: [normalizeEchoes(action)],
|
|
71
121
|
team: id.team,
|
|
122
|
+
enterprise: id.team?.enterprise_id ? {
|
|
123
|
+
id: id.team.enterprise_id,
|
|
124
|
+
name: id.team.enterprise_name ?? ""
|
|
125
|
+
} : null,
|
|
126
|
+
is_enterprise_install: id.isEnterpriseInstall,
|
|
72
127
|
user: id.user,
|
|
73
128
|
token: id.token,
|
|
74
129
|
response_url: id.responseUrl,
|
|
@@ -6017,7 +6072,8 @@ function Button({ element, blockId }) {
|
|
|
6017
6072
|
},
|
|
6018
6073
|
...element.value !== void 0 ? { value: element.value } : {},
|
|
6019
6074
|
...element.url !== void 0 ? { url: element.url } : {},
|
|
6020
|
-
...element.style !== void 0 ? { style: element.style } : {}
|
|
6075
|
+
...element.style !== void 0 ? { style: element.style } : {},
|
|
6076
|
+
...element.confirm ? { confirm: element.confirm } : {}
|
|
6021
6077
|
});
|
|
6022
6078
|
if (element.url) window.open(element.url, "_blank", "noopener,noreferrer");
|
|
6023
6079
|
};
|
|
@@ -6453,7 +6509,8 @@ function DatePicker({ element, blockId }) {
|
|
|
6453
6509
|
type: "datepicker",
|
|
6454
6510
|
action_id: actionId,
|
|
6455
6511
|
block_id: blockId,
|
|
6456
|
-
selected_date: next
|
|
6512
|
+
selected_date: next,
|
|
6513
|
+
...element.initial_date !== void 0 ? { initial_date: element.initial_date } : {}
|
|
6457
6514
|
});
|
|
6458
6515
|
}
|
|
6459
6516
|
async function clear() {
|
|
@@ -6468,7 +6525,8 @@ function DatePicker({ element, blockId }) {
|
|
|
6468
6525
|
type: "datepicker",
|
|
6469
6526
|
action_id: actionId,
|
|
6470
6527
|
block_id: blockId,
|
|
6471
|
-
selected_date: null
|
|
6528
|
+
selected_date: null,
|
|
6529
|
+
...element.initial_date !== void 0 ? { initial_date: element.initial_date } : {}
|
|
6472
6530
|
});
|
|
6473
6531
|
}
|
|
6474
6532
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -7378,7 +7436,8 @@ function Select({ element, blockId }) {
|
|
|
7378
7436
|
type: element.type,
|
|
7379
7437
|
action_id: actionId,
|
|
7380
7438
|
block_id: blockId,
|
|
7381
|
-
...fields
|
|
7439
|
+
...fields,
|
|
7440
|
+
...element.placeholder ? { placeholder: element.placeholder } : {}
|
|
7382
7441
|
});
|
|
7383
7442
|
}
|
|
7384
7443
|
function buildStateFor(next) {
|
|
@@ -7697,7 +7756,8 @@ function TimePicker({ element, blockId }) {
|
|
|
7697
7756
|
type: "timepicker",
|
|
7698
7757
|
action_id: actionId,
|
|
7699
7758
|
block_id: blockId,
|
|
7700
|
-
selected_time: next
|
|
7759
|
+
selected_time: next,
|
|
7760
|
+
...element.initial_time !== void 0 ? { initial_time: element.initial_time } : {}
|
|
7701
7761
|
});
|
|
7702
7762
|
}
|
|
7703
7763
|
const times = timeOptions();
|