@nkootstra/block-kit 0.1.0 → 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/dist/{index-BV_5_J_Q.d.ts → index-FPjJcmn3.d.ts} +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -37
- package/dist/index.js.map +1 -1
- package/dist/styles.css +67 -27
- package/dist/transport.d.ts +1 -1
- package/dist/web-api.d.ts +1 -1
- package/package.json +2 -3
|
@@ -582,6 +582,8 @@ interface PayloadContext {
|
|
|
582
582
|
type SubmitResult = ViewResponseAction | undefined | void;
|
|
583
583
|
interface BlockKitContextValue {
|
|
584
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";
|
|
585
587
|
onAction?: (action: BlockAction, context: ActionContext) => void;
|
|
586
588
|
/** Same actions as `onAction`, wrapped in the full Slack `block_actions` payload (team/user/container/...). */
|
|
587
589
|
onPayload?: (payload: ReturnType<typeof buildBlockActionsPayload>, context: PayloadContext) => void;
|
|
@@ -906,4 +908,4 @@ declare const VALIDATION_MESSAGES: {
|
|
|
906
908
|
declare function validateView(blocks: readonly Json[] | readonly unknown[], state: StateValues): Record<string, string>;
|
|
907
909
|
//#endregion
|
|
908
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 };
|
|
909
|
-
//# sourceMappingURL=index-
|
|
911
|
+
//# sourceMappingURL=index-FPjJcmn3.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as BlockSuggestionPayload, A as BlockAction, B as StackedView, C as SlackAttachment, Ct as BlockProps, D as elementComponents, E as SlackReaction, F as EmojiOptions, G as SurfaceScopeProps, H as SubmitResult, I as MessageApi, J as ViewsApi, K as SurfaceScopeValue, L as MessageUpdate, M as BlockKitProvider, N as BlockKitProviderProps, O as Element, P as ElementState, Q as BlockActionsPayload, R as PayloadContext, S as MessageProps, St as Blocks, T as SlackMessageLike, Tt as Json, U as Surface, V as StateValues, W as SurfaceScope, X as useContainer, Y as useBlockKit, Z as useLiveView, _ as HomeTabView, _t as buildBlockSuggestionPayload, a as Tooltip, at as MessageBlockActionsPayload, b as Message, bt as blockComponents, c as TextObject, ct as PayloadIdentity, d as ViewProps, dt as SuggestionOption, et as BuildBlockActionsPayloadOptions, f as Modal, ft as ViewBlockActionsPayload, g as HomeTabProps, gt as buildBlockActionsPayload, h as HomeTab, ht as ViewResponseAction, i as UserMentionProps, it as Container, j as BlockKitContextValue, k as ActionContext, l as AnyView, lt as PayloadTeam, m as ModalView, mt as ViewLike, n as validateView, nt as BuildViewClosedPayloadOptions, o as TooltipProps, ot as MessageContainer, p as ModalProps, pt as ViewContainer, q as UserProfile, r as UserMention, rt as BuildViewSubmissionPayloadOptions, s as Text, st as OptionsResponse, t as VALIDATION_MESSAGES, tt as BuildBlockSuggestionPayloadOptions, u as View, ut as PayloadUser, v as Mrkdwn, vt as buildViewClosedPayload, w as SlackAttachmentField, wt as ElementProps, x as MessageApp, xt as Block, y as MrkdwnProps, yt as buildViewSubmissionPayload, z as Resolvers } from "./index-
|
|
2
|
+
import { $ as BlockSuggestionPayload, A as BlockAction, B as StackedView, C as SlackAttachment, Ct as BlockProps, D as elementComponents, E as SlackReaction, F as EmojiOptions, G as SurfaceScopeProps, H as SubmitResult, I as MessageApi, J as ViewsApi, K as SurfaceScopeValue, L as MessageUpdate, M as BlockKitProvider, N as BlockKitProviderProps, O as Element, P as ElementState, Q as BlockActionsPayload, R as PayloadContext, S as MessageProps, St as Blocks, T as SlackMessageLike, Tt as Json, U as Surface, V as StateValues, W as SurfaceScope, X as useContainer, Y as useBlockKit, Z as useLiveView, _ as HomeTabView, _t as buildBlockSuggestionPayload, a as Tooltip, at as MessageBlockActionsPayload, b as Message, bt as blockComponents, c as TextObject, ct as PayloadIdentity, d as ViewProps, dt as SuggestionOption, et as BuildBlockActionsPayloadOptions, f as Modal, ft as ViewBlockActionsPayload, g as HomeTabProps, gt as buildBlockActionsPayload, h as HomeTab, ht as ViewResponseAction, i as UserMentionProps, it as Container, j as BlockKitContextValue, k as ActionContext, l as AnyView, lt as PayloadTeam, m as ModalView, mt as ViewLike, n as validateView, nt as BuildViewClosedPayloadOptions, o as TooltipProps, ot as MessageContainer, p as ModalProps, pt as ViewContainer, q as UserProfile, r as UserMention, rt as BuildViewSubmissionPayloadOptions, s as Text, st as OptionsResponse, t as VALIDATION_MESSAGES, tt as BuildBlockSuggestionPayloadOptions, u as View, ut as PayloadUser, v as Mrkdwn, vt as buildViewClosedPayload, w as SlackAttachmentField, wt as ElementProps, x as MessageApp, xt as Block, y as MrkdwnProps, yt as buildViewSubmissionPayload, z as Resolvers } from "./index-FPjJcmn3.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, 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
|
@@ -1035,6 +1035,7 @@ function BlockKitProvider(props) {
|
|
|
1035
1035
|
const stackedView = useContext(StackEntryContext);
|
|
1036
1036
|
const value = useMemo(() => ({
|
|
1037
1037
|
surface,
|
|
1038
|
+
theme,
|
|
1038
1039
|
onAction,
|
|
1039
1040
|
onPayload,
|
|
1040
1041
|
onSubmit,
|
|
@@ -1054,6 +1055,7 @@ function BlockKitProvider(props) {
|
|
|
1054
1055
|
respond
|
|
1055
1056
|
}), [
|
|
1056
1057
|
surface,
|
|
1058
|
+
theme,
|
|
1057
1059
|
onAction,
|
|
1058
1060
|
onPayload,
|
|
1059
1061
|
onSubmit,
|
|
@@ -1235,6 +1237,7 @@ const SHOW_DELAY_MS = 300;
|
|
|
1235
1237
|
* Slack. Portalled to `<body>` so scroll containers and `overflow: hidden` can't clip it.
|
|
1236
1238
|
*/
|
|
1237
1239
|
function Tooltip({ label, children, placement = "top" }) {
|
|
1240
|
+
const { theme } = useBlockKit();
|
|
1238
1241
|
const id = useId();
|
|
1239
1242
|
const [open, setOpen] = useState(false);
|
|
1240
1243
|
const [position, setPosition] = useState(null);
|
|
@@ -1298,6 +1301,7 @@ function Tooltip({ label, children, placement = "top" }) {
|
|
|
1298
1301
|
ref: tipRef,
|
|
1299
1302
|
id,
|
|
1300
1303
|
role: "tooltip",
|
|
1304
|
+
"data-theme": theme,
|
|
1301
1305
|
className: `sbk-tooltip sbk-tooltip--${position?.side ?? placement}`,
|
|
1302
1306
|
style: position ? {
|
|
1303
1307
|
top: position.top,
|
|
@@ -5613,7 +5617,7 @@ function localTime(timeZone) {
|
|
|
5613
5617
|
* `resolvers.userProfile` and falling back to the display name alone.
|
|
5614
5618
|
*/
|
|
5615
5619
|
function UserMention({ id, name }) {
|
|
5616
|
-
const { resolvers } = useBlockKit();
|
|
5620
|
+
const { resolvers, theme } = useBlockKit();
|
|
5617
5621
|
const [open, setOpen] = useState(false);
|
|
5618
5622
|
const [position, setPosition] = useState(null);
|
|
5619
5623
|
const anchorRef = useRef(null);
|
|
@@ -5681,6 +5685,7 @@ function UserMention({ id, name }) {
|
|
|
5681
5685
|
role: "dialog",
|
|
5682
5686
|
"aria-label": profile.name,
|
|
5683
5687
|
className: "sbk-root sbk-profile-card",
|
|
5688
|
+
"data-theme": theme,
|
|
5684
5689
|
style: position ? {
|
|
5685
5690
|
top: position.top,
|
|
5686
5691
|
left: position.left
|
|
@@ -5865,10 +5870,12 @@ function Text({ text, emojiSize = 22 }) {
|
|
|
5865
5870
|
//#region src/confirm/ConfirmDialog.tsx
|
|
5866
5871
|
/** Slack's confirmation dialog: blocks the triggering action until the user picks confirm/deny. */
|
|
5867
5872
|
function ConfirmDialog({ confirm, onConfirm, onDeny }) {
|
|
5873
|
+
const { theme } = useBlockKit();
|
|
5868
5874
|
const confirmStyle = confirm.style ?? "primary";
|
|
5869
5875
|
const node = /* @__PURE__ */ jsx("div", {
|
|
5870
5876
|
className: "sbk-confirm__overlay",
|
|
5871
5877
|
role: "presentation",
|
|
5878
|
+
"data-theme": theme,
|
|
5872
5879
|
onClick: onDeny,
|
|
5873
5880
|
children: /* @__PURE__ */ jsxs("div", {
|
|
5874
5881
|
className: "sbk-confirm",
|
|
@@ -6236,6 +6243,7 @@ const DEFAULT_GAP = 4;
|
|
|
6236
6243
|
* from.
|
|
6237
6244
|
*/
|
|
6238
6245
|
function Popover({ anchorRef, onDismiss, gap = DEFAULT_GAP, children }) {
|
|
6246
|
+
const { theme } = useBlockKit();
|
|
6239
6247
|
const layerRef = useRef(null);
|
|
6240
6248
|
const [position, setPosition] = useState(null);
|
|
6241
6249
|
const dismiss = useRef(onDismiss);
|
|
@@ -6286,6 +6294,7 @@ function Popover({ anchorRef, onDismiss, gap = DEFAULT_GAP, children }) {
|
|
|
6286
6294
|
return createPortal(/* @__PURE__ */ jsx("div", {
|
|
6287
6295
|
ref: layerRef,
|
|
6288
6296
|
className: "sbk-root sbk-popover",
|
|
6297
|
+
"data-theme": theme,
|
|
6289
6298
|
style: position ?? {
|
|
6290
6299
|
top: 0,
|
|
6291
6300
|
left: 0,
|
|
@@ -7733,24 +7742,20 @@ function Alert({ block }) {
|
|
|
7733
7742
|
}
|
|
7734
7743
|
//#endregion
|
|
7735
7744
|
//#region src/blocks/Callout.tsx
|
|
7736
|
-
/**
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
yellow: "#fff8db",
|
|
7746
|
-
purple: "#f3ecff",
|
|
7747
|
-
gray: "#f4f4f4",
|
|
7748
|
-
grey: "#f4f4f4"
|
|
7749
|
-
};
|
|
7745
|
+
/** Callout colours; each has a token per theme (Callout.css, and Message.css for dark). */
|
|
7746
|
+
const BACKGROUND_COLORS = /* @__PURE__ */ new Set([
|
|
7747
|
+
"green",
|
|
7748
|
+
"blue",
|
|
7749
|
+
"red",
|
|
7750
|
+
"yellow",
|
|
7751
|
+
"purple",
|
|
7752
|
+
"gray"
|
|
7753
|
+
]);
|
|
7750
7754
|
function Callout({ block }) {
|
|
7751
7755
|
const json = block;
|
|
7752
7756
|
const color = typeof json.background_color === "string" ? json.background_color : void 0;
|
|
7753
|
-
const
|
|
7757
|
+
const key = color === "grey" ? "gray" : color;
|
|
7758
|
+
const background = `var(--sbk-callout-${key && BACKGROUND_COLORS.has(key) ? key : "gray"}-bg)`;
|
|
7754
7759
|
const children = json.child_blocks ?? [];
|
|
7755
7760
|
return /* @__PURE__ */ jsx("div", {
|
|
7756
7761
|
className: "sbk-callout",
|
|
@@ -8666,26 +8671,12 @@ const CHART_COLORS = [
|
|
|
8666
8671
|
"#c474d3",
|
|
8667
8672
|
"#0e9dd3"
|
|
8668
8673
|
];
|
|
8669
|
-
/**
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
const n = Number.parseInt(hex.slice(1), 16);
|
|
8676
|
-
return [
|
|
8677
|
-
n >> 16 & 255,
|
|
8678
|
-
n >> 8 & 255,
|
|
8679
|
-
n & 255
|
|
8680
|
-
];
|
|
8681
|
-
}
|
|
8682
|
-
/** Fill colour for a series' area, tinted ~88% toward white when not one of the measured pairs. */
|
|
8683
|
-
function areaFillFor(color) {
|
|
8684
|
-
const known = AREA_FILLS[color.toLowerCase()];
|
|
8685
|
-
if (known) return known;
|
|
8686
|
-
const [r, g, b] = hexToRgb(color);
|
|
8687
|
-
const mix = (c) => Math.round(c + (255 - c) * .88);
|
|
8688
|
-
return `rgb(${mix(r)},${mix(g)},${mix(b)})`;
|
|
8674
|
+
/**
|
|
8675
|
+
* Fill of a series' area, as a token per theme (DataVisualization.css, and Message.css for dark):
|
|
8676
|
+
* a light tint of the series colour, or a dark one.
|
|
8677
|
+
*/
|
|
8678
|
+
function areaFillForIndex(i) {
|
|
8679
|
+
return `var(--sbk-chart-area-${i % CHART_COLORS.length + 1})`;
|
|
8689
8680
|
}
|
|
8690
8681
|
function colorForIndex(i) {
|
|
8691
8682
|
return CHART_COLORS[i % CHART_COLORS.length] ?? "#e96825";
|
|
@@ -8898,7 +8889,7 @@ function CartesianChart({ type, series, categories }) {
|
|
|
8898
8889
|
const color = colorForIndex(si);
|
|
8899
8890
|
return /* @__PURE__ */ jsxs("g", { children: [type === "area" ? /* @__PURE__ */ jsx("path", {
|
|
8900
8891
|
d: `${smoothLinePath(points)}L${points[points.length - 1]?.x ?? 0} ${zeroY}L${points[0]?.x ?? 0} ${zeroY}Z`,
|
|
8901
|
-
fill:
|
|
8892
|
+
style: { fill: areaFillForIndex(si) },
|
|
8902
8893
|
fillOpacity: .7
|
|
8903
8894
|
}) : null, /* @__PURE__ */ jsx("path", {
|
|
8904
8895
|
d: smoothLinePath(points),
|