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

@@ -0,0 +1,27 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { NumberInput } from "./NumberInput";
describe("NumberInput accessibility", () => {
it("associates its visible label with the spinbutton", () => {
render(
<NumberInput showLabel label="Seats">
<NumberInput.Input name="seats" />
</NumberInput>
);
expect(screen.getByRole("spinbutton", { name: "Seats" })).toBeVisible();
});
it("preserves an explicit accessible name", () => {
render(
<NumberInput showLabel label="Seats">
<NumberInput.Input name="seats" aria-label="Licensed seats" />
</NumberInput>
);
expect(screen.getByRole("spinbutton", { name: "Licensed seats" })).toBeVisible();
});
});
@@ -2,6 +2,13 @@
// so it can be driven controlled (value) OR uncontrolled (defaultValue). The generated
// `value=""` (before {...otherProps}) forced controlled-empty whenever no `value` was
// passed, breaking defaultValue-only call sites (Phase 0 Subframe migration).
// Second local fix (AK-P19): with `showLabel` the root kept its fixed h-9 while label +
// gap + input need ~72px, so the input box overflowed the card below (TextInput already
// uses the flexible-root/fixed-box pattern). With a label the root is now h-auto and the
// input box a fixed h-9 flex item.
// Third local fix (AK-P19): the generated stepper chevrons were purely decorative. They
// now call stepUp()/stepDown() on the contained input and emit a native `input` event so
// React onChange handlers fire.
"use client";
/*
* Documentation:
@@ -113,6 +120,21 @@ const NumberInputRoot = React.forwardRef<HTMLDivElement, NumberInputRootProps>(
}: NumberInputRootProps,
ref
) {
const boxRef = React.useRef<HTMLDivElement>(null);
const generatedLabelId = React.useId();
const inputLabelId = showLabel && label ? generatedLabelId : undefined;
// Steps the contained native number input and notifies React listeners.
const stepBy = (direction: "up" | "down") => {
if (disabled) return;
const input = boxRef.current?.querySelector("input");
if (!input || input.disabled || input.readOnly) return;
if (direction === "up") input.stepUp();
else input.stepDown();
input.dispatchEvent(new Event("input", { bubbles: true }));
input.focus();
};
return (
<div
className={SubframeUtils.twClassNames(
@@ -120,7 +142,7 @@ const NumberInputRoot = React.forwardRef<HTMLDivElement, NumberInputRootProps>(
{
"h-12": size === "large",
"h-8": size === "small",
"h-auto": noPadding,
"h-auto": noPadding || showLabel,
},
className
)}
@@ -135,6 +157,7 @@ const NumberInputRoot = React.forwardRef<HTMLDivElement, NumberInputRootProps>(
>
{label ? (
<span
id={inputLabelId}
className={SubframeUtils.twClassNames(
"text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary",
{
@@ -158,9 +181,13 @@ const NumberInputRoot = React.forwardRef<HTMLDivElement, NumberInputRootProps>(
) : null}
</div>
<div
ref={boxRef}
className={SubframeUtils.twClassNames(
"flex w-full grow shrink-0 basis-0 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary items-stretch group-hover/06ebc0c5:bg-surface-neutral-secondary group-hover/06ebc0c5:border-brand-brand-border-solid-hover group-focus-within/06ebc0c5:bg-surface-neutral-secondary group-focus-within/06ebc0c5:shadow-focus",
{
"h-9 grow-0 shrink-0 basis-auto": showLabel,
"h-8": showLabel && size === "small",
"h-12": showLabel && size === "large",
"flex-none [&_input]:px-0": noPadding,
"[&]:border-none group-hover/06ebc0c5:border-none group-focus-within/06ebc0c5:shadow-none group-focus-within/06ebc0c5:border-none":
borderless,
@@ -179,13 +206,17 @@ const NumberInputRoot = React.forwardRef<HTMLDivElement, NumberInputRootProps>(
{ "[&_input]:px-2.5": size === "small" }
)}
>
{children}
{React.Children.map(children, (child) => {
if (!inputLabelId || !React.isValidElement<InputProps>(child)) return child;
if (child.props["aria-label"] || child.props["aria-labelledby"]) return child;
return React.cloneElement(child, { "aria-labelledby": inputLabelId });
})}
</div>
) : null}
<div className="flex w-9 flex-none flex-col self-stretch overflow-hidden rounded-r-md border-l border-solid border-border-default items-stretch justify-center">
<Stepper className="rounded-none" />
<Stepper className="rounded-none" disabled={disabled} aria-hidden onClick={() => stepBy("up")} />
<div className="flex h-px w-full flex-none flex-col items-center gap-2 bg-border-default" />
<Stepper className="rounded-none" down={true} />
<Stepper className="rounded-none" disabled={disabled} aria-hidden down={true} onClick={() => stepBy("down")} />
</div>
</div>
</div>