Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -1,4 +1,10 @@
"use client";
// @subframe/sync-disable -- local fix: render `label`, `value`, `percentage` and
// `comparisonText` whenever they are present instead of when they are truthy. The
// generated `{value ? … : null}` guards drop the number `0` and the empty string,
// so every card whose metric was legitimately zero rendered as a headline with a
// bare trend arrow and no figure at all (admin audit 2026-07-26: /health,
// /system, /sales/tasks/today, /sales/contacts, /sales/calls, /sales/bookings,
// /accounts/billing).
/*
* Documentation:
* Stats Card — https://app.subframe.com/f023064a5ca0/library?component=Stats+Card_63f809c7-22ef-47f8-9fb9-0f33b252be3f
@@ -12,6 +18,16 @@ import { FeatherTrendingUp } from "@subframe/core";
import * as SubframeCore from "@subframe/core";
import * as SubframeUtils from "../../utils";
/**
* A slot is rendered when it carries visible content. The number `0` does — it
* is a legitimate metric — while `undefined`, `null`, `false` and the empty
* string do not. Call sites pass `percentage=""` to opt out of that slot, so an
* empty string must stay unrendered rather than produce an empty element.
*/
function hasContent(node: React.ReactNode): boolean {
return node !== undefined && node !== null && node !== false && node !== "";
}
export interface StatsCardRootProps
extends React.HTMLAttributes<HTMLDivElement> {
trend?: "positive" | "negative" | "neutral";
@@ -20,6 +36,7 @@ export interface StatsCardRootProps
percentage?: React.ReactNode;
comparisonText?: React.ReactNode;
icon?: React.ReactNode;
highContrastText?: boolean;
className?: string;
}
@@ -32,6 +49,7 @@ const StatsCardRoot = React.forwardRef<HTMLDivElement, StatsCardRootProps>(
percentage,
comparisonText,
icon = <FeatherDollarSign />,
highContrastText = false,
className,
...otherProps
}: StatsCardRootProps,
@@ -48,8 +66,13 @@ const StatsCardRoot = React.forwardRef<HTMLDivElement, StatsCardRootProps>(
>
<div className="flex w-full flex-col items-start gap-5">
<div className="flex w-full items-center justify-between">
{label ? (
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{hasContent(label) ? (
<span
className={SubframeUtils.twClassNames(
"text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary",
{ "text-text-neutral-primary": highContrastText }
)}
>
{label}
</span>
) : null}
@@ -59,7 +82,7 @@ const StatsCardRoot = React.forwardRef<HTMLDivElement, StatsCardRootProps>(
</SubframeCore.IconWrapper>
) : null}
</div>
{value ? (
{hasContent(value) ? (
<span className="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">
{value}
</span>
@@ -84,7 +107,7 @@ const StatsCardRoot = React.forwardRef<HTMLDivElement, StatsCardRootProps>(
{ hidden: trend === "neutral" || trend === "negative" }
)}
/>
{percentage ? (
{hasContent(percentage) ? (
<span
className={SubframeUtils.twClassNames(
"text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-positive",
@@ -98,8 +121,13 @@ const StatsCardRoot = React.forwardRef<HTMLDivElement, StatsCardRootProps>(
</span>
) : null}
</div>
{comparisonText ? (
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{hasContent(comparisonText) ? (
<span
className={SubframeUtils.twClassNames(
"text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary",
{ "text-text-neutral-secondary": highContrastText }
)}
>
{comparisonText}
</span>
) : null}
@@ -0,0 +1,47 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { StatsCard } from ".";
describe("StatsCard slot rendering", () => {
it("renders a zero metric instead of dropping it", () => {
// Regression guard: the generated `{value ? … : null}` guard treated the
// number 0 as absent, so cards such as "Kritisch" or "Überfällig" showed a
// heading and a trend arrow with no figure at all.
render(<StatsCard label="Kritisch" value={0} />);
expect(screen.getByText("Kritisch")).toBeInTheDocument();
expect(screen.getByText("0")).toBeInTheDocument();
});
it("renders zero percentages and zero comparison text", () => {
render(<StatsCard label="Überfällig" value={0} percentage={0} comparisonText={0} />);
expect(screen.getAllByText("0")).toHaveLength(3);
});
it("still omits slots that carry no content", () => {
const { container } = render(<StatsCard label="Unklar" value={undefined} percentage={null} comparisonText={false} />);
expect(screen.getByText("Unklar")).toBeInTheDocument();
expect(container.textContent).toBe("Unklar");
});
it("treats an empty string as an opt-out, not as content", () => {
// Call sites pass `percentage=""` to hide that slot; rendering it would add
// empty elements to every card.
const { container } = render(<StatsCard label="Kritisch" value={0} percentage="" comparisonText="" />);
expect(container.querySelectorAll("span:empty")).toHaveLength(0);
expect(container.textContent).toBe("Kritisch0");
});
it("keeps rendering formatted string values", () => {
render(<StatsCard label="Umsatz" value="19,99 €" />);
expect(screen.getByText("19,99 €")).toBeInTheDocument();
});
});