executable-stories-react 0.18.0 → 0.19.0

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/ssr.js CHANGED
@@ -860,42 +860,76 @@ function StateCardView({ card }) {
860
860
 
861
861
  // src/components/ReportAttachments.tsx
862
862
  import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
863
+ function attachmentText(att) {
864
+ if (att.contentEncoding !== "BASE64") return att.body;
865
+ try {
866
+ return new TextDecoder().decode(Uint8Array.from(atob(att.body), (c) => c.charCodeAt(0)));
867
+ } catch {
868
+ return void 0;
869
+ }
870
+ }
871
+ function preview(att) {
872
+ const type = att.mediaType.split(";")[0].trim().toLowerCase();
873
+ const text = attachmentText(att);
874
+ if (text === void 0) return null;
875
+ if (type === "text/plain") {
876
+ return /* @__PURE__ */ jsx21("pre", { className: "max-h-96 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs whitespace-pre-wrap", children: text });
877
+ }
878
+ if (type === "text/markdown") {
879
+ return /* @__PURE__ */ jsx21(
880
+ "div",
881
+ {
882
+ className: "es-doc-prose prose prose-sm max-w-none rounded-md border border-border p-3",
883
+ dangerouslySetInnerHTML: { __html: safeMarkdownHtml(text) }
884
+ }
885
+ );
886
+ }
887
+ if (type === "text/html") {
888
+ return /* @__PURE__ */ jsx21(DocHtml, { entry: { kind: "html", content: text, title: att.name, phase: "runtime" } });
889
+ }
890
+ return null;
891
+ }
863
892
  function ReportAttachments({ attachments }) {
864
893
  if (attachments.length === 0) return null;
865
894
  return (
866
895
  // role="group" (not a labelled <section>) so multiple scenarios' attachment
867
896
  // blocks don't create duplicate "Attachments" region landmarks.
868
897
  /* @__PURE__ */ jsx21("div", { role: "group", "aria-label": "Attachments", className: "mt-3 flex flex-col gap-2", children: attachments.map((att, i) => {
869
- const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
870
- const isImage = att.mediaType.startsWith("image/");
898
+ const dataUri = att.external ? void 0 : att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
899
+ const href = dataUri ?? safeUrl(att.body);
900
+ const imageSrc = dataUri ?? safeImageUrl(att.body);
901
+ const isImage = att.mediaType.startsWith("image/") && imageSrc !== void 0;
871
902
  return /* @__PURE__ */ jsx21("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
872
903
  /* @__PURE__ */ jsx21(
873
904
  "img",
874
905
  {
875
- src: dataUri,
906
+ src: imageSrc,
876
907
  alt: att.name,
877
908
  loading: "lazy",
878
909
  className: "max-w-full rounded-md border border-border"
879
910
  }
880
911
  ),
881
912
  /* @__PURE__ */ jsx21("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
882
- ] }) : /* @__PURE__ */ jsxs13(
883
- "a",
884
- {
885
- href: dataUri,
886
- download: att.name,
887
- className: "text-xs text-link underline underline-offset-2",
888
- children: [
889
- att.name,
890
- " ",
891
- /* @__PURE__ */ jsxs13("span", { className: "text-muted-foreground", children: [
892
- "(",
893
- att.mediaType,
894
- ")"
895
- ] })
896
- ]
897
- }
898
- ) }, `${att.name}-${i}`);
913
+ ] }) : /* @__PURE__ */ jsxs13(Fragment6, { children: [
914
+ att.external ? null : preview(att),
915
+ /* @__PURE__ */ jsxs13(
916
+ "a",
917
+ {
918
+ href,
919
+ download: att.name,
920
+ className: "text-xs text-link underline underline-offset-2",
921
+ children: [
922
+ att.name,
923
+ " ",
924
+ /* @__PURE__ */ jsxs13("span", { className: "text-muted-foreground", children: [
925
+ "(",
926
+ att.mediaType,
927
+ ")"
928
+ ] })
929
+ ]
930
+ }
931
+ )
932
+ ] }) }, `${att.name}-${i}`);
899
933
  }) })
900
934
  );
901
935
  }