footprint-explainable-ui 0.11.3 → 0.11.4

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.cjs CHANGED
@@ -2456,7 +2456,29 @@ function StoryNarrative({
2456
2456
  }
2457
2457
  return entries.length;
2458
2458
  }, [entries, revealedStages]);
2459
- const revealed = entries.slice(0, revealedCount);
2459
+ const revealed = (0, import_react11.useMemo)(() => {
2460
+ const raw = entries.slice(0, revealedCount);
2461
+ const root = [];
2462
+ const groups = /* @__PURE__ */ new Map();
2463
+ const groupOrder = [];
2464
+ for (const e of raw) {
2465
+ const sfId = e.subflowId;
2466
+ if (sfId) {
2467
+ if (!groups.has(sfId)) {
2468
+ groups.set(sfId, []);
2469
+ groupOrder.push(sfId);
2470
+ }
2471
+ groups.get(sfId).push(e);
2472
+ } else {
2473
+ root.push(e);
2474
+ }
2475
+ }
2476
+ const result = [...root];
2477
+ for (const sfId of groupOrder) {
2478
+ result.push(...groups.get(sfId));
2479
+ }
2480
+ return result;
2481
+ }, [entries, revealedCount]);
2460
2482
  const future = entries.slice(revealedCount);
2461
2483
  const latestRef = (0, import_react11.useRef)(null);
2462
2484
  (0, import_react11.useEffect)(() => {
@@ -2486,52 +2508,65 @@ function StoryNarrative({
2486
2508
  const isDecision = entry.type === "condition";
2487
2509
  const isError = entry.type === "error";
2488
2510
  const isLast = i === revealed.length - 1;
2489
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2490
- "div",
2491
- {
2492
- ref: isLast ? latestRef : void 0,
2493
- style: {
2494
- display: "flex",
2495
- gap: 8,
2496
- padding: isStage ? `${pad - 4}px 0` : `2px 0`,
2497
- marginLeft: entry.depth * 16,
2498
- borderBottom: isStage ? `1px solid ${theme.border}` : void 0,
2499
- marginTop: isStage && i > 0 ? 8 : 0
2500
- },
2501
- children: [
2502
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2503
- "span",
2504
- {
2505
- style: {
2506
- color: meta.color,
2507
- fontWeight: 700,
2508
- fontSize: isStage ? fs.body : fs.small,
2509
- width: 16,
2510
- textAlign: "center",
2511
- flexShrink: 0
2512
- },
2513
- title: meta.label,
2514
- "aria-label": meta.label,
2515
- children: meta.icon
2516
- }
2517
- ),
2518
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2519
- "span",
2520
- {
2521
- style: {
2522
- fontSize: isStage ? fs.body : fs.small,
2523
- fontWeight: isStage ? 600 : 400,
2524
- color: isError ? theme.error : isDecision ? theme.warning : isStage ? theme.textPrimary : theme.textSecondary,
2525
- lineHeight: 1.6,
2526
- fontFamily: entry.type === "step" ? theme.fontMono : theme.fontSans
2527
- },
2528
- children: entry.text
2529
- }
2530
- )
2531
- ]
2532
- },
2533
- i
2534
- );
2511
+ const sfId = entry.subflowId;
2512
+ const prevSfId = i > 0 ? revealed[i - 1].subflowId : void 0;
2513
+ const subflowChanged = sfId && sfId !== prevSfId;
2514
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref: isLast ? latestRef : void 0, children: [
2515
+ subflowChanged && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: {
2516
+ fontSize: fs.small,
2517
+ fontWeight: 600,
2518
+ color: theme.textSecondary,
2519
+ padding: `6px 0 2px`,
2520
+ marginTop: 8,
2521
+ borderTop: `1px solid ${theme.border}`,
2522
+ textTransform: "uppercase",
2523
+ letterSpacing: "0.05em"
2524
+ }, children: sfId }),
2525
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2526
+ "div",
2527
+ {
2528
+ style: {
2529
+ display: "flex",
2530
+ gap: 8,
2531
+ padding: isStage ? `${pad - 4}px 0` : `2px 0`,
2532
+ marginLeft: sfId ? 12 : entry.depth * 16,
2533
+ borderBottom: isStage && !sfId ? `1px solid ${theme.border}` : void 0,
2534
+ marginTop: isStage && i > 0 && !subflowChanged ? 8 : 0
2535
+ },
2536
+ children: [
2537
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2538
+ "span",
2539
+ {
2540
+ style: {
2541
+ color: meta.color,
2542
+ fontWeight: 700,
2543
+ fontSize: isStage ? fs.body : fs.small,
2544
+ width: 16,
2545
+ textAlign: "center",
2546
+ flexShrink: 0
2547
+ },
2548
+ title: meta.label,
2549
+ "aria-label": meta.label,
2550
+ children: meta.icon
2551
+ }
2552
+ ),
2553
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2554
+ "span",
2555
+ {
2556
+ style: {
2557
+ fontSize: isStage ? fs.body : fs.small,
2558
+ fontWeight: isStage ? 600 : 400,
2559
+ color: isError ? theme.error : isDecision ? theme.warning : isStage ? theme.textPrimary : theme.textSecondary,
2560
+ lineHeight: 1.6,
2561
+ fontFamily: entry.type === "step" ? theme.fontMono : theme.fontSans
2562
+ },
2563
+ children: entry.text
2564
+ }
2565
+ )
2566
+ ]
2567
+ }
2568
+ )
2569
+ ] }, i);
2535
2570
  }),
2536
2571
  future.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: {
2537
2572
  opacity: 0.3,