@tightknitai/block-kitchen 0.8.5 → 0.8.6

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,6 @@
1
1
  import * as react from 'react';
2
- import { B as BlockKitchenProps, E as Template, q as PreviewSurface, r as PreviewTheme } from './palette-Dco-CVMi.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 ChannelOption, h as ContextActionsBlock, i as ContextActionsElement, j as CustomEmoji, F as FeedbackButtonSubobject, k as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, l as IconButtonIcon, m as InputBlock, M as MarkdownBlock, P as PaletteSection, n as PaletteVariant, o as PlanBlock, p as PreviewHooks, S as SendAsUserStatus, s as SendPayload, t as SendResult, u as SupportedBlock, v as SupportedBlockType, w as SupportedHeaderBlock, T as TableBlock, x as TableCell, y as TableColumnSetting, z as TaskCardBlock, D as TaskCardStatus, U as UrlSourceElement, V as VideoBlock, J as defaultPalette, K as extraAlertVariant, L as legacyInputVariants } from './palette-Dco-CVMi.cjs';
2
+ import { B as BlockKitchenProps, E as Template, q as PreviewSurface, r as PreviewTheme } from './palette-DToUE_3J.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 ChannelOption, h as ContextActionsBlock, i as ContextActionsElement, j as CustomEmoji, F as FeedbackButtonSubobject, k as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, l as IconButtonIcon, m as InputBlock, M as MarkdownBlock, P as PaletteSection, n as PaletteVariant, o as PlanBlock, p as PreviewHooks, S as SendAsUserStatus, s as SendPayload, t as SendResult, u as SupportedBlock, v as SupportedBlockType, w as SupportedHeaderBlock, T as TableBlock, x as TableCell, y as TableColumnSetting, z as TaskCardBlock, D as TaskCardStatus, U as UrlSourceElement, V as VideoBlock, J as defaultPalette, K as extraAlertVariant, L as legacyInputVariants } from './palette-DToUE_3J.cjs';
4
4
  export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.cjs';
5
5
  import 'slack-web-api-client';
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { B as BlockKitchenProps, E as Template, q as PreviewSurface, r as PreviewTheme } from './palette-Dco-CVMi.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 ChannelOption, h as ContextActionsBlock, i as ContextActionsElement, j as CustomEmoji, F as FeedbackButtonSubobject, k as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, l as IconButtonIcon, m as InputBlock, M as MarkdownBlock, P as PaletteSection, n as PaletteVariant, o as PlanBlock, p as PreviewHooks, S as SendAsUserStatus, s as SendPayload, t as SendResult, u as SupportedBlock, v as SupportedBlockType, w as SupportedHeaderBlock, T as TableBlock, x as TableCell, y as TableColumnSetting, z as TaskCardBlock, D as TaskCardStatus, U as UrlSourceElement, V as VideoBlock, J as defaultPalette, K as extraAlertVariant, L as legacyInputVariants } from './palette-Dco-CVMi.js';
2
+ import { B as BlockKitchenProps, E as Template, q as PreviewSurface, r as PreviewTheme } from './palette-DToUE_3J.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 ChannelOption, h as ContextActionsBlock, i as ContextActionsElement, j as CustomEmoji, F as FeedbackButtonSubobject, k as FeedbackButtonsElement, H as HeaderLevel, I as IconButtonElement, l as IconButtonIcon, m as InputBlock, M as MarkdownBlock, P as PaletteSection, n as PaletteVariant, o as PlanBlock, p as PreviewHooks, S as SendAsUserStatus, s as SendPayload, t as SendResult, u as SupportedBlock, v as SupportedBlockType, w as SupportedHeaderBlock, T as TableBlock, x as TableCell, y as TableColumnSetting, z as TaskCardBlock, D as TaskCardStatus, U as UrlSourceElement, V as VideoBlock, J as defaultPalette, K as extraAlertVariant, L as legacyInputVariants } from './palette-DToUE_3J.js';
4
4
  export { decodeBlocksFromString, encodeBlocksToString, toSlackBlocks } from './helpers.js';
5
5
  import 'slack-web-api-client';
6
6
 
package/dist/index.js CHANGED
@@ -2244,6 +2244,18 @@ function IssuesSheet({
2244
2244
  ] })
2245
2245
  ] }) });
2246
2246
  }
2247
+
2248
+ // src/lib/parse-blocks-input.ts
2249
+ var BLOCKS_INPUT_SHAPE_ERROR = "Expected an array of blocks, or an object with a `blocks` array.";
2250
+ function unwrapBlocksInput(parsed) {
2251
+ if (Array.isArray(parsed)) {
2252
+ return parsed;
2253
+ }
2254
+ if (parsed && typeof parsed === "object" && Array.isArray(parsed.blocks)) {
2255
+ return parsed.blocks;
2256
+ }
2257
+ return null;
2258
+ }
2247
2259
  var MAX_JSON_BYTES = 1024 * 1024;
2248
2260
  function JsonDrawer({
2249
2261
  open,
@@ -2282,14 +2294,15 @@ function JsonDrawer({
2282
2294
  setValidationErrors([]);
2283
2295
  return;
2284
2296
  }
2285
- if (!Array.isArray(parsed)) {
2286
- setParseError("Top-level value must be an array of blocks.");
2297
+ const blocks2 = unwrapBlocksInput(parsed);
2298
+ if (!blocks2) {
2299
+ setParseError(BLOCKS_INPUT_SHAPE_ERROR);
2287
2300
  setValidationErrors([]);
2288
2301
  return;
2289
2302
  }
2290
2303
  setParseError(null);
2291
- onApply(parsed);
2292
- const result = validateBlockKit(parsed, {
2304
+ onApply(blocks2);
2305
+ const result = validateBlockKit(blocks2, {
2293
2306
  target: "blocks",
2294
2307
  surface: "message"
2295
2308
  });
@@ -2667,6 +2680,7 @@ function SendDialog({
2667
2680
  loadChannels,
2668
2681
  loadSendAsUserStatus,
2669
2682
  onSend,
2683
+ confirmSendLabel = "Send",
2670
2684
  errorCount,
2671
2685
  onShowIssues
2672
2686
  }) {
@@ -2840,7 +2854,7 @@ function SendDialog({
2840
2854
  type: "button",
2841
2855
  onClick: handleSubmit,
2842
2856
  disabled: status.kind === "sending" || !channelId || blocks.length === 0 || errorCount > 0,
2843
- children: status.kind === "sending" ? "Sending\u2026" : "Send"
2857
+ children: status.kind === "sending" ? "Sending\u2026" : confirmSendLabel
2844
2858
  }
2845
2859
  )
2846
2860
  ] })
@@ -7914,7 +7928,8 @@ function Toolbar2({
7914
7928
  allowedSurfaces,
7915
7929
  showThemeControl = true,
7916
7930
  docsLink,
7917
- errorCount
7931
+ errorCount,
7932
+ sendButtonLabel = "Send"
7918
7933
  }) {
7919
7934
  const activeTheme = THEME_OPTIONS.find((t) => t.value === previewTheme) ?? THEME_OPTIONS[0];
7920
7935
  const activeSurface = SURFACE_OPTIONS.find((s) => s.value === previewSurface) ?? SURFACE_OPTIONS[0];
@@ -8004,7 +8019,7 @@ function Toolbar2({
8004
8019
  variant: "ghost",
8005
8020
  size: "sm",
8006
8021
  onClick: onOpenIssues,
8007
- className: "text-destructive hover:text-destructive",
8022
+ className: "border border-red-200! bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-700",
8008
8023
  "aria-label": `${errorCount} ${errorCount === 1 ? "issue" : "issues"}`,
8009
8024
  children: [
8010
8025
  /* @__PURE__ */ jsx(AlertTriangle, { className: "h-3.5 w-3.5" }),
@@ -8097,9 +8112,9 @@ function Toolbar2({
8097
8112
  ) : null
8098
8113
  ] }) })
8099
8114
  ] }),
8100
- /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", onClick: onOpenSend, disabled: !canSend, "aria-label": "Send", children: [
8115
+ /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", onClick: onOpenSend, disabled: !canSend, "aria-label": sendButtonLabel, children: [
8101
8116
  /* @__PURE__ */ jsx(Send, { className: "h-3.5 w-3.5" }),
8102
- /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Send" })
8117
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: sendButtonLabel })
8103
8118
  ] })
8104
8119
  ] })
8105
8120
  ] });
@@ -8225,6 +8240,9 @@ function BlockKitchen(props) {
8225
8240
  showThemeControl = true,
8226
8241
  docsLink,
8227
8242
  defaultPreviewTheme = "light",
8243
+ previewTheme: controlledPreviewTheme,
8244
+ sendButtonLabel,
8245
+ confirmSendLabel,
8228
8246
  theme
8229
8247
  } = props;
8230
8248
  const paletteSections = useMemo(() => {
@@ -8252,7 +8270,9 @@ function BlockKitchen(props) {
8252
8270
  const [issuesOpen, setIssuesOpen] = useState(false);
8253
8271
  const [paletteOpen, setPaletteOpen] = useState(false);
8254
8272
  const [openBlockId, setOpenBlockId] = useState(null);
8255
- const [previewTheme, setPreviewTheme] = useState(defaultPreviewTheme);
8273
+ const [uncontrolledPreviewTheme, setUncontrolledPreviewTheme] = useState(defaultPreviewTheme);
8274
+ const isPreviewThemeControlled = controlledPreviewTheme !== void 0;
8275
+ const previewTheme = controlledPreviewTheme ?? uncontrolledPreviewTheme;
8256
8276
  const [previewSurface, setPreviewSurface] = useState(allowedSurfaces[0]);
8257
8277
  const [activePaletteVariantId, setActivePaletteVariantId] = useState(null);
8258
8278
  const isMobile = useIsMobile();
@@ -8334,12 +8354,13 @@ function BlockKitchen(props) {
8334
8354
  canClear: blocks.length > 0,
8335
8355
  errorCount: validation.total,
8336
8356
  previewTheme,
8337
- onPreviewThemeChange: setPreviewTheme,
8357
+ onPreviewThemeChange: setUncontrolledPreviewTheme,
8338
8358
  previewSurface,
8339
8359
  onPreviewSurfaceChange: setPreviewSurface,
8340
8360
  allowedSurfaces,
8341
- showThemeControl,
8342
- docsLink
8361
+ showThemeControl: isPreviewThemeControlled ? false : showThemeControl,
8362
+ docsLink,
8363
+ sendButtonLabel
8343
8364
  }
8344
8365
  ),
8345
8366
  /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 items-stretch", children: [
@@ -8415,6 +8436,7 @@ function BlockKitchen(props) {
8415
8436
  loadChannels,
8416
8437
  loadSendAsUserStatus,
8417
8438
  onSend,
8439
+ confirmSendLabel,
8418
8440
  errorCount: validation.total,
8419
8441
  onShowIssues: () => {
8420
8442
  setSendOpen(false);