executable-stories-react 0.17.1 → 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
@@ -342,11 +342,11 @@ function formatValue(value) {
342
342
  return String(value);
343
343
  }
344
344
  }
345
- function DocKv({ entry }) {
346
- return /* @__PURE__ */ jsxs2("dl", { className: "my-2 flex flex-wrap items-baseline gap-x-2 text-sm", children: [
345
+ function DocKv({ entries }) {
346
+ return /* @__PURE__ */ jsx6("dl", { className: "my-2 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-sm", children: entries.map((entry, i) => /* @__PURE__ */ jsxs2("div", { className: "contents", children: [
347
347
  /* @__PURE__ */ jsx6("dt", { className: "font-semibold text-muted-foreground", children: entry.label }),
348
348
  /* @__PURE__ */ jsx6("dd", { className: "min-w-0 break-words font-mono text-foreground", children: formatValue(entry.value) })
349
- ] });
349
+ ] }, i)) });
350
350
  }
351
351
 
352
352
  // src/hooks/useRenderers.ts
@@ -433,7 +433,7 @@ function DocSection({ entry }) {
433
433
  if (renderers.section) {
434
434
  return /* @__PURE__ */ jsx10(Fragment2, { children: renderers.section(entry) });
435
435
  }
436
- const html = safeMarkdownHtml(entry.markdown);
436
+ const html = safeMarkdownHtml(dedent(entry.markdown));
437
437
  return /* @__PURE__ */ jsxs5("section", { className: "my-3 text-sm", "aria-label": entry.title, children: [
438
438
  entry.title ? /* @__PURE__ */ jsx10("h4", { className: "mb-1 font-semibold text-foreground", children: entry.title }) : null,
439
439
  /* @__PURE__ */ jsx10(
@@ -619,7 +619,7 @@ function DocEntry({ entry }) {
619
619
  case "tag":
620
620
  return /* @__PURE__ */ jsx17(DocTag, { entry });
621
621
  case "kv":
622
- return /* @__PURE__ */ jsx17(DocKv, { entry });
622
+ return /* @__PURE__ */ jsx17(DocKv, { entries: [entry] });
623
623
  case "code":
624
624
  return /* @__PURE__ */ jsx17(DocCode, { entry });
625
625
  case "table":
@@ -647,7 +647,15 @@ function DocEntry({ entry }) {
647
647
  import { Fragment as Fragment5, jsx as jsx18 } from "react/jsx-runtime";
648
648
  function ReportDocEntries({ entries }) {
649
649
  if (entries.length === 0) return null;
650
- return /* @__PURE__ */ jsx18(Fragment5, { children: entries.map((entry, i) => /* @__PURE__ */ jsx18(DocEntry, { entry }, i)) });
650
+ const groups = [];
651
+ for (const entry of entries) {
652
+ const last = groups[groups.length - 1];
653
+ if (entry.kind === "kv" && Array.isArray(last)) last.push(entry);
654
+ else groups.push(entry.kind === "kv" ? [entry] : entry);
655
+ }
656
+ return /* @__PURE__ */ jsx18(Fragment5, { children: groups.map(
657
+ (g, i) => Array.isArray(g) ? /* @__PURE__ */ jsx18(DocKv, { entries: g }, i) : /* @__PURE__ */ jsx18(DocEntry, { entry: g }, i)
658
+ ) });
651
659
  }
652
660
 
653
661
  // src/components/ReportSteps.tsx
@@ -852,42 +860,76 @@ function StateCardView({ card }) {
852
860
 
853
861
  // src/components/ReportAttachments.tsx
854
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
+ }
855
892
  function ReportAttachments({ attachments }) {
856
893
  if (attachments.length === 0) return null;
857
894
  return (
858
895
  // role="group" (not a labelled <section>) so multiple scenarios' attachment
859
896
  // blocks don't create duplicate "Attachments" region landmarks.
860
897
  /* @__PURE__ */ jsx21("div", { role: "group", "aria-label": "Attachments", className: "mt-3 flex flex-col gap-2", children: attachments.map((att, i) => {
861
- const dataUri = att.contentEncoding === "BASE64" ? `data:${att.mediaType};base64,${att.body}` : `data:${att.mediaType},${encodeURIComponent(att.body)}`;
862
- 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;
863
902
  return /* @__PURE__ */ jsx21("figure", { className: "m-0", children: isImage ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
864
903
  /* @__PURE__ */ jsx21(
865
904
  "img",
866
905
  {
867
- src: dataUri,
906
+ src: imageSrc,
868
907
  alt: att.name,
869
908
  loading: "lazy",
870
909
  className: "max-w-full rounded-md border border-border"
871
910
  }
872
911
  ),
873
912
  /* @__PURE__ */ jsx21("figcaption", { className: "mt-1 text-xs text-muted-foreground", children: att.name })
874
- ] }) : /* @__PURE__ */ jsxs13(
875
- "a",
876
- {
877
- href: dataUri,
878
- download: att.name,
879
- className: "text-xs text-link underline underline-offset-2",
880
- children: [
881
- att.name,
882
- " ",
883
- /* @__PURE__ */ jsxs13("span", { className: "text-muted-foreground", children: [
884
- "(",
885
- att.mediaType,
886
- ")"
887
- ] })
888
- ]
889
- }
890
- ) }, `${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}`);
891
933
  }) })
892
934
  );
893
935
  }
@@ -1428,10 +1470,17 @@ function ReportFeatureIntro({ feature }) {
1428
1470
  dangerouslySetInnerHTML: { __html: safeMarkdownHtml(dedent(feature.narrative)) }
1429
1471
  }
1430
1472
  ) : null,
1431
- hasGlossary ? /* @__PURE__ */ jsx28("dl", { className: "grid gap-1.5", "aria-label": "Glossary", children: feature.glossary.map((entry) => /* @__PURE__ */ jsxs19("div", { className: "flex flex-wrap gap-x-2 text-xs", children: [
1432
- /* @__PURE__ */ jsx28("dt", { className: "font-medium text-foreground", children: entry.term }),
1433
- /* @__PURE__ */ jsx28("dd", { className: "flex-1 text-muted-foreground", children: entry.definition })
1434
- ] }, entry.term)) }) : null
1473
+ hasGlossary ? /* @__PURE__ */ jsx28(
1474
+ "dl",
1475
+ {
1476
+ className: "grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1.5 text-xs",
1477
+ "aria-label": "Glossary",
1478
+ children: feature.glossary.map((entry) => /* @__PURE__ */ jsxs19("div", { className: "contents", children: [
1479
+ /* @__PURE__ */ jsx28("dt", { className: "font-medium text-foreground", children: entry.term }),
1480
+ /* @__PURE__ */ jsx28("dd", { className: "text-muted-foreground", children: entry.definition })
1481
+ ] }, entry.term))
1482
+ }
1483
+ ) : null
1435
1484
  ] });
1436
1485
  }
1437
1486
  function featureKindLabel(kind) {
@@ -1447,7 +1496,6 @@ function ReportFeature({ feature }) {
1447
1496
  const titleId = `${feature.id}-title`;
1448
1497
  const bodyId = `${feature.id}-body`;
1449
1498
  const s = feature.summary;
1450
- const skipped = s.skipped + s.pending;
1451
1499
  const collapse = useCollapse();
1452
1500
  const collapsed = collapse?.isCollapsed(feature.id) ?? false;
1453
1501
  const kindLabel = featureKindLabel(feature.kind);
@@ -1487,7 +1535,12 @@ function ReportFeature({ feature }) {
1487
1535
  "p",
1488
1536
  {
1489
1537
  className: "flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground",
1490
- "aria-label": `${s.passed} passed, ${s.failed} failed, ${skipped} skipped`,
1538
+ "aria-label": [
1539
+ `${s.passed} passed`,
1540
+ `${s.failed} failed`,
1541
+ s.skipped > 0 && `${s.skipped} skipped`,
1542
+ s.pending > 0 && `${s.pending} pending`
1543
+ ].filter(Boolean).join(", "),
1491
1544
  children: [
1492
1545
  /* @__PURE__ */ jsxs20("span", { children: [
1493
1546
  s.passed,
@@ -1498,12 +1551,19 @@ function ReportFeature({ feature }) {
1498
1551
  s.failed,
1499
1552
  " failed"
1500
1553
  ] }),
1501
- skipped > 0 ? /* @__PURE__ */ jsxs20(Fragment9, { children: [
1554
+ s.skipped > 0 ? /* @__PURE__ */ jsxs20(Fragment9, { children: [
1502
1555
  /* @__PURE__ */ jsx29("span", { "aria-hidden": true, children: "\xB7" }),
1503
1556
  /* @__PURE__ */ jsxs20("span", { children: [
1504
- skipped,
1557
+ s.skipped,
1505
1558
  " skipped"
1506
1559
  ] })
1560
+ ] }) : null,
1561
+ s.pending > 0 ? /* @__PURE__ */ jsxs20(Fragment9, { children: [
1562
+ /* @__PURE__ */ jsx29("span", { "aria-hidden": true, children: "\xB7" }),
1563
+ /* @__PURE__ */ jsxs20("span", { children: [
1564
+ s.pending,
1565
+ " pending"
1566
+ ] })
1507
1567
  ] }) : null
1508
1568
  ]
1509
1569
  }