footprint-explainable-ui 0.14.5 → 0.14.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.cjs CHANGED
@@ -4105,9 +4105,11 @@ function detectKeyedSteps(data) {
4105
4105
  }
4106
4106
  return null;
4107
4107
  }
4108
- function findNumericField(entry) {
4109
- for (const [k, v2] of Object.entries(entry)) {
4110
- if (typeof v2 === "number") return { key: k, value: v2 };
4108
+ function extractRenderHints(data) {
4109
+ if (!data || typeof data !== "object") return null;
4110
+ const obj = data;
4111
+ if (typeof obj.numericField === "string" && typeof obj.grandTotal === "number") {
4112
+ return { numericField: obj.numericField, grandTotal: obj.grandTotal };
4111
4113
  }
4112
4114
  return null;
4113
4115
  }
@@ -4138,22 +4140,17 @@ function KeyedRecorderView({
4138
4140
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { padding: 12, fontFamily: theme.fontMono, fontSize: 11, whiteSpace: "pre-wrap", overflow: "auto", height: "100%" }, children: typeof data === "string" ? data : JSON.stringify(data, null, 2) });
4139
4141
  }
4140
4142
  const steps = detected.steps;
4143
+ const hints = extractRenderHints(data);
4144
+ const numFieldKey = hints?.numericField ?? "";
4141
4145
  const allKeys = Object.keys(steps);
4142
4146
  const visibleEntries = allKeys.filter((k) => visibleKeys.has(k));
4143
- const numField = allKeys.length > 0 ? findNumericField(steps[allKeys[0]]) : null;
4144
- const numFieldKey = numField?.key ?? "";
4145
4147
  let runningTotal = 0;
4146
4148
  if (numFieldKey) {
4147
4149
  for (const k of visibleEntries) {
4148
4150
  runningTotal += steps[k][numFieldKey] ?? 0;
4149
4151
  }
4150
4152
  }
4151
- let grandTotal = 0;
4152
- if (numFieldKey) {
4153
- for (const entry of Object.values(steps)) {
4154
- grandTotal += entry[numFieldKey] ?? 0;
4155
- }
4156
- }
4153
+ const grandTotal = hints?.grandTotal ?? 0;
4157
4154
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { overflow: "auto", height: "100%", display: "flex", flexDirection: "column" }, children: [
4158
4155
  description && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { padding: "6px 12px", fontSize: 11, color: theme.textMuted, fontStyle: "italic", borderBottom: `1px solid ${theme.border}`, flexShrink: 0 }, children: description }),
4159
4156
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { padding: 12, flex: 1, overflow: "auto" }, children: [