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,53 @@
// The strip that appears above a table once rows are checked, in the shape the
// project list and the plantafel established: a count badge, the actions, and
// the way out of the selection.
//
// Pure/presentational. It renders nothing while the selection is empty, so a
// screen cannot end up reserving room for a bar that has nothing to act on.
// Captions come in resolved, keeping this free of i18n lookups.
import type { ReactNode } from "react";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
export type BulkActionBarProps = {
/** How many rows are checked. Zero renders nothing at all. */
selectedCount: number;
/** Resolved caption stating the count, e.g. "3 Kontakte ausgewählt". */
countLabel: string;
/**
* Resolved note about the part of the selection that is not on screen. A
* selection spanning pages is otherwise unreviewable: the reader cannot see
* what the action would touch.
*/
offPageLabel?: string | null;
/** The actions themselves — buttons, in the order they should be offered. */
children: ReactNode;
/** Resolved caption of the button that drops the selection. */
clearLabel: string;
onClear: () => void;
disabled?: boolean;
uiId: string;
};
export function BulkActionBar(props: BulkActionBarProps) {
if (props.selectedCount <= 0) return null;
return (
<div className="flex w-full min-w-0 flex-wrap items-center gap-3" data-ui-id={props.uiId}>
<BadgeFeedback farbe="subtle-neutral" size="small" data-ui-id={`${props.uiId}.count`}>
{props.countLabel}
</BadgeFeedback>
{props.offPageLabel ? (
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary" data-ui-id={`${props.uiId}.offPage`}>
{props.offPageLabel}
</span>
) : null}
{props.children}
<Button variant="neutral" size="small" disabled={props.disabled} onClick={props.onClear} data-ui-id={`${props.uiId}.clear`}>
{props.clearLabel}
</Button>
</div>
);
}
export default BulkActionBar;
@@ -0,0 +1,172 @@
// Davids `FilterBar` + `DropdownMenuMultiSelect` for screens whose facets are
// evaluated on the client (small, fully loaded collections such as the board
// list). The server-filtered boards use `BoardFilterBar` instead, which renders
// a loader-built view model.
//
// Pure/presentational: it renders the facets it is handed and reports every
// interaction as a callback. Chips are derived from the selected options, so a
// screen cannot end up with a filter that is active but has no way back.
import type { ComponentProps, ReactNode } from "react";
import { FeatherX } from "@subframe/core";
import { DropdownMenuMultiSelect } from "~/ui/components/DropdownMenuMultiSelect";
import { FilterBar } from "~/ui/components/FilterBar";
import { Tag_Label } from "~/ui/components/Tag_Label";
/** Whatever the kit chip accepts — no second, drifting copy of that union. */
type ChipTone = NonNullable<ComponentProps<typeof Tag_Label>["tone"]>;
export type ClientFacetOption = {
readonly value: string;
readonly label: string;
/** Overrides the facet tone for this option (board types carry their own). */
readonly tone?: ChipTone;
};
export type ClientFacet = {
readonly key: string;
readonly label: string;
readonly icon: ReactNode;
readonly options: readonly ClientFacetOption[];
readonly selected: ReadonlySet<string>;
/** Chip colour of this facet's selections. */
readonly tone?: ChipTone;
};
export type FacetFilterBarProps = {
facets: readonly ClientFacet[];
onToggle: (facetKey: string, value: string) => void;
search: string;
onSearchChange: (value: string) => void;
searchPlaceholder: string;
onReset: () => void;
/** Captions the caller resolves, so this stays free of i18n lookups. */
labels: { reset: string; removeChip: string };
/** Prefix of every data-ui-id, e.g. "ui.projects.boards.filter". */
uiId: string;
/**
* Controls that sit right behind the facet buttons, in the same row and not
* pushed to the edge — a view control such as sorting belongs next to the
* filters it orders, not across the bar from them.
*/
afterFacets?: ReactNode;
/** Extra controls pushed to the right of the facet row. */
trailing?: ReactNode;
/**
* Drop the free-text box for a screen whose current view has no rows to
* narrow — the plantafel's week grid navigates by date, not by term.
*/
hideSearch?: boolean;
/**
* Shape of the bar. "page" is the full-bleed strip a list screen wears under
* its header; "inline" keeps the kit's rounded card for a bar that sits
* inside a body — the settings hubs own their chrome, so a full-bleed strip
* would cut across their tab bar.
*/
variant?: "page" | "inline";
};
/**
* The full-bleed strip a list screen wears under its header. Exported because a
* screen may need the same chrome around a bar that is not a facet filter — the
* availability editor carries its timezone pill in one — and a second hand-typed
* copy of these classes would drift away from the lists.
*/
export const FULL_BLEED_BAR_CLASS =
"rounded-none border-b border-solid border-border-default px-6 py-2.5 mobile:rounded-none mobile:px-4";
const VARIANT_CLASS = {
page: FULL_BLEED_BAR_CLASS,
inline: "",
} as const;
export function FacetFilterBar(props: FacetFilterBarProps) {
const chips = props.facets.flatMap((facet) =>
facet.options
.filter((option) => facet.selected.has(option.value))
.map((option) => ({ facet, option }))
);
// A hidden search box cannot be reset, so its term must not keep the reset
// pill alive either.
const hasActiveFilters = chips.length > 0 || (!props.hideSearch && props.search.trim().length > 0);
return (
<FilterBar
className={VARIANT_CLASS[props.variant ?? "page"]}
data-ui-id={props.uiId}
hideSearch={props.hideSearch ?? false}
// The kit hides the box with a class rather than dropping it. Withholding
// the id and the term keeps a hidden box from answering as a live search
// control or carrying a leftover term.
searchValue={props.hideSearch ? "" : props.search}
searchPlaceholder={props.searchPlaceholder}
searchUiId={props.hideSearch ? undefined : `${props.uiId}.search`}
onSearchChange={props.hideSearch ? undefined : props.onSearchChange}
showActiveFilters={hasActiveFilters}
onReset={hasActiveFilters ? props.onReset : undefined}
resetLabel={props.labels.reset}
activeFilters={chips.map(({ facet, option }) => (
<Tag_Label
key={`${facet.key}:${option.value}`}
tone={option.tone ?? facet.tone ?? "neutral-subtle"}
size="small"
data-ui-id={`${props.uiId}.chip.${facet.key}.${option.value}`}
actionChildren={
<Tag_Label.Action
icon={<FeatherX />}
onClick={() => props.onToggle(facet.key, option.value)}
// The kit renders the action as a div, so the chip carries the
// button semantics itself and stays keyboard-reachable.
role="button"
tabIndex={0}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
props.onToggle(facet.key, option.value);
}
}}
aria-label={props.labels.removeChip}
data-ui-id={`${props.uiId}.chip.${facet.key}.${option.value}.remove`}
/>
}
>
{option.label}
</Tag_Label>
))}
>
{props.facets.map((facet) => (
<FilterBar.StatusFilterButton
key={facet.key}
icon={facet.icon}
label={facet.label}
showCount={facet.selected.size > 0}
count={facet.selected.size > 0 ? String(facet.selected.size) : ""}
data-ui-id={`${props.uiId}.${facet.key}`}
dropdown={
<DropdownMenuMultiSelect>
{facet.options.map((option) => (
<DropdownMenuMultiSelect.DropdownItem
key={option.value}
showCheckbox
selected={facet.selected.has(option.value)}
onClick={() => props.onToggle(facet.key, option.value)}
data-ui-id={`${props.uiId}.${facet.key}.${option.value}`}
>
{option.label}
</DropdownMenuMultiSelect.DropdownItem>
))}
</DropdownMenuMultiSelect>
}
/>
))}
{props.afterFacets}
{props.trailing ? (
<div className="flex grow shrink-0 basis-0 items-center justify-end gap-2 mobile:grow-0 mobile:justify-start">
{props.trailing}
</div>
) : null}
</FilterBar>
);
}
export default FacetFilterBar;
@@ -0,0 +1,86 @@
// Shared chrome for the app's form popups.
//
// The shape is the one TaskNewDialog established for "Neue Aufgabe": a header
// bar carrying title, subtitle and close button, a scrollable body, and a footer
// bar for the actions — all three on the secondary surface with a hairline
// border, so a dialog reads like page chrome rather than a floating card. Before
// this every screen re-implemented that layout (or skipped it), which is why the
// role, group and member popups all looked slightly different from each other.
//
// Presentational only: no loader/fetcher access, callers own the form and its
// submit handling.
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { FeatherX } from "@subframe/core";
import { Dialog } from "~/ui/components/Dialog";
import { IconButton } from "~/ui/components/IconButton";
import { cn } from "~/lib/utils";
/** Dialog widths in use across the app — S for forms, L for the permission editor. */
export const FORM_DIALOG_SIZE = {
xs: "w-[420px] max-w-[92vw]",
small: "w-[560px] max-w-[92vw]",
medium: "w-[720px] max-w-[92vw]",
large: "w-[1200px] max-w-[95vw]",
} as const;
export type FormDialogSize = keyof typeof FORM_DIALOG_SIZE;
export function FormDialog({
open,
onOpenChange,
title,
subtitle,
size = "small",
footer,
uiId,
bodyClassName,
children,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
title: ReactNode;
subtitle?: ReactNode;
size?: FormDialogSize;
/** Action row; rendered in the footer bar. Omit for a dialog without actions. */
footer?: ReactNode;
uiId?: string;
bodyClassName?: string;
children: ReactNode;
}): React.JSX.Element {
const { t } = useTranslation();
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<Dialog.Content className={cn(FORM_DIALOG_SIZE[size], "p-0")} data-ui-id={uiId}>
<div className="flex w-full flex-col">
<div className="flex w-full items-start justify-between gap-3 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
<div className="flex flex-col items-start gap-1">
<span className="text-heading- font-heading- text-text-neutral-primary">{title}</span>
{subtitle ? (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{subtitle}</span>
) : null}
</div>
<IconButton
type="button"
variant="ghost"
size="small"
icon={<FeatherX />}
aria-label={t("shared.close")}
onClick={() => onOpenChange(false)}
data-ui-id={uiId ? `${uiId}.close` : undefined}
/>
</div>
<div className={cn("flex w-full flex-col gap-4 max-h-[65vh] overflow-y-auto px-6 py-5 mobile:px-4", bodyClassName)}>{children}</div>
{footer ? (
<div className="flex w-full items-center justify-end gap-2 border-t border-solid border-border-default bg-surface-neutral-secondary px-6 py-4 mobile:flex-col-reverse mobile:items-stretch mobile:px-4">
{footer}
</div>
) : null}
</div>
</Dialog.Content>
</Dialog>
);
}
@@ -0,0 +1,55 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { PageBody, PageHeader, PageShell } from "./PageShell";
describe("PageShell", () => {
it("renders the title as the page's single h1", () => {
render(<PageHeader title="Aufgaben" />);
const headings = screen.getAllByRole("heading", { level: 1 });
expect(headings).toHaveLength(1);
expect(headings[0]).toHaveTextContent("Aufgaben");
});
it("omits subtitle, icon and actions when not supplied", () => {
const { container } = render(<PageHeader title="Aufgaben" />);
expect(container.querySelector("p")).toBeNull();
expect(screen.queryByRole("button")).toBeNull();
});
it("renders subtitle, icon and actions when supplied", () => {
render(
<PageHeader
icon={<span data-testid="icon" />}
title="Aufgaben"
subtitle="Alle offenen Aufgaben"
actions={<button type="button">Neu</button>}
/>,
);
expect(screen.getByTestId("icon")).toBeInTheDocument();
expect(screen.getByText("Alle offenen Aufgaben")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Neu" })).toBeInTheDocument();
});
it("keeps the e2e anchor on the shell so header and body stay inside it", () => {
const { container } = render(
<PageShell uiId="ui.tasks.list">
<PageHeader title="Aufgaben" />
<PageBody>
<span data-ui-id="ui.tasks.list.table" />
</PageBody>
</PageShell>,
);
const shell = container.querySelector('[data-ui-id="ui.tasks.list"]');
expect(shell).not.toBeNull();
expect(shell?.querySelector("h1")).toHaveTextContent("Aufgaben");
expect(shell?.querySelector('[data-ui-id="ui.tasks.list.table"]')).not.toBeNull();
});
});
@@ -0,0 +1,219 @@
import type { ReactNode } from "react";
import { Link } from "react-router";
import { FeatherArrowLeft } from "@subframe/core";
import { Button } from "~/ui/components/Button";
import { cn } from "~/lib/utils";
/**
* Shared page chrome for the HiveGrid app screens.
*
* The header bar markup is the one shipped with the Subframe screens for
* /automations and /forms: a full-bleed bar (own padding + bottom border) that
* carries icon, heading and optional actions. Every app screen composes the same
* three primitives so the pages stay visually aligned and each page renders
* exactly one <h1>.
*
* Layout constraint (see screens/subframe-layout-boundary.test.ts): never combine
* `h-full`+`overflow-hidden` or `basis-0`+`overflow-y-auto` in here — the app
* shell's <main> has no definite height and such a screen collapses to 0px.
*/
/** Canonical icon styling for PageHeader icons — keeps icon size/tone aligned across screens. */
export const PAGE_HEADER_ICON_CLASS = "text-heading- font-heading- text-icon-neutral-tertiary";
export function PageShell({
uiId,
className,
sseHref,
children,
}: {
uiId?: string;
className?: string;
/** Optional realtime hint mirrored onto the root as `data-sse-href` (SSE-backed screens). */
sseHref?: string | null;
/** Optional so not-ready/empty screen states can render a bare shell. */
children?: ReactNode;
}): React.JSX.Element {
return (
<div
className={cn("flex w-full flex-col items-start", className)}
data-ui-id={uiId}
data-sse-href={sseHref ?? undefined}
>
{children}
</div>
);
}
export function PageHeader({
icon,
title,
subtitle,
subtitleClassName,
subtitleTone = "tertiary",
actions,
dense = false,
titleTrailing,
uiId,
}: {
icon?: ReactNode;
title: ReactNode;
subtitle?: ReactNode;
subtitleClassName?: string;
subtitleTone?: "secondary" | "tertiary";
actions?: ReactNode;
/**
* Compact header bar: smaller bar height and a smaller heading, for a screen
* whose own controls (not a description) say what is being shown. A subtitle
* still fits — it sits directly under the heading and keeps the bar to two
* short lines.
*/
dense?: boolean;
/** Controls that belong to the heading itself, split off by a vertical rule (dense only). */
titleTrailing?: ReactNode;
uiId?: string;
}): React.JSX.Element {
const heading = (
<div className="flex items-center gap-2">
{icon}
<h1
className={
dense
? "text-body-large font-body-large text-text-neutral-primary"
: "text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-"
}
>
{title}
</h1>
</div>
);
if (dense) {
return (
<div
className="flex w-full items-center gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-3 mobile:flex-col mobile:items-start mobile:px-4"
data-ui-id={uiId}
>
{/* `gap-1.5`: the subtitle of a dense header is a chip, not a text line —
without air between the two it reads as part of the heading. */}
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1.5">
<div className="flex w-full items-center gap-3">
{heading}
{titleTrailing ? (
<>
<div className="flex h-6 w-px flex-none flex-col items-center bg-border-default mobile:hidden" />
{titleTrailing}
</>
) : null}
</div>
{subtitle ? (
<p
className={`text-body-small-regular-0 font-body-small-regular-0 ${
subtitleClassName ?? (subtitleTone === "secondary" ? "text-text-neutral-secondary" : "text-text-neutral-tertiary")
}`}
>
{subtitle}
</p>
) : null}
</div>
{actions ? <div className="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap">{actions}</div> : null}
</div>
);
}
return (
<div
className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"
data-ui-id={uiId}
>
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
{heading}
{subtitle ? (
<p
className={`text-body-small-regular-150 font-body-small-regular-150 ${
subtitleClassName ?? (subtitleTone === "secondary" ? "text-text-neutral-secondary" : "text-text-neutral-tertiary")
}`}
>
{subtitle}
</p>
) : null}
</div>
{actions ? <div className="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap">{actions}</div> : null}
</div>
);
}
/**
* Full-bleed filter/toolbar strip directly below the PageHeader.
*
* Same chrome as the header bar (own padding, bottom border, secondary surface)
* so filter controls read as page chrome rather than as content. Must be a
* sibling of PageHeader, NOT nested in PageBody — PageBody adds the 24px content
* padding and would break the full-bleed edge.
*/
export function PageToolbar({
className,
uiId,
children,
}: {
className?: string;
uiId?: string;
children: ReactNode;
}): React.JSX.Element {
return (
<div
className={cn(
"flex w-full flex-wrap items-end gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-3 mobile:px-4",
className
)}
data-ui-id={uiId}
>
{children}
</div>
);
}
/** Canonical back navigation for subpages: tertiary button with a left arrow, placed at the top of PageBody. */
export function PageBackLink({ to, label, uiId }: { to: string; label: ReactNode; uiId?: string }): React.JSX.Element {
return (
<div>
<Link to={to} className="contents no-underline" data-ui-id={uiId}>
<Button variant="tertiary" size="small" icon={<FeatherArrowLeft />}>
{label}
</Button>
</Link>
</div>
);
}
/**
* Description line for a screen that renders inside a settings hub (AK-SET-01).
*
* A hub already owns the page's single <h1> and its tab bar names the section,
* so an embedded screen must not render a second PageHeader. Its description is
* still worth keeping — this is where it goes.
*/
export function PageIntro({ children, uiId }: { children: ReactNode; uiId?: string }): React.JSX.Element {
return (
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary" data-ui-id={uiId}>
{children}
</p>
);
}
/** Content area below the header bar: 24px page padding (16px on mobile, matching the header edge). */
export function PageBody({
className,
uiId,
children,
}: {
className?: string;
uiId?: string;
children: ReactNode;
}): React.JSX.Element {
return (
<div className={cn("flex w-full flex-col gap-6 p-6 mobile:p-4", className)} data-ui-id={uiId}>
{children}
</div>
);
}
@@ -0,0 +1,79 @@
// Shared chrome of the quick-action modals (header with icon/title/subtitle and
// close, body slot, footer with cancel + one primary action). Extracted from the
// project quick actions so any screen that offers the same kind of "one small
// thing, right here" action gets the same dialog instead of a lookalike.
//
// Pure/presentational: it owns no draft state and performs no navigation — the
// caller passes the body and decides what submitting means.
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { FeatherCheck, FeatherX } from "@subframe/core";
import { Button } from "~/ui/components/Button";
import { Dialog } from "~/ui/components/Dialog";
import { IconButton } from "~/ui/components/IconButton";
import { IconWithBackground } from "~/ui/components/IconWithBackground";
export type QuickActionDialogProps = {
open: boolean;
onOpenChange: (open: boolean) => void;
icon: ReactNode;
iconVariant: "warning" | "information" | "success" | "neutral";
title: string;
subtitle: string;
submitLabel: string;
/** Defaults to the check the "erstellen" dialogs use. */
submitIcon?: ReactNode;
submitting: boolean;
submitDisabled?: boolean;
onSubmit: () => void;
uiId: string;
children: ReactNode;
};
export function QuickActionDialog(props: QuickActionDialogProps) {
const { t } = useTranslation();
return (
<Dialog open={props.open} onOpenChange={props.onOpenChange}>
{/* w-112 like every one of Davids four exports. */}
<Dialog.Content className="w-112 max-w-[92vw] p-4" data-ui-id={props.uiId}>
<div className="flex w-full flex-col items-start gap-5">
<div className="flex w-full items-start justify-between gap-3">
<div className="flex items-start gap-3">
<IconWithBackground variant={props.iconVariant} size="medium" icon={props.icon} />
<div className="flex flex-col items-start gap-1">
<span className="text-heading-0 font-heading-0 text-text-neutral-primary">{props.title}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{props.subtitle}</span>
</div>
</div>
<IconButton
variant="tertiary"
size="small"
icon={<FeatherX />}
onClick={() => props.onOpenChange(false)}
data-ui-id={`${props.uiId}.close`}
/>
</div>
<div className="flex w-full flex-col items-start gap-4">{props.children}</div>
<div className="flex w-full items-center justify-end gap-2">
<Button variant="tertiary" onClick={() => props.onOpenChange(false)} data-ui-id={`${props.uiId}.cancel`}>
{t("shared.cancel")}
</Button>
<Button
variant="primary"
icon={props.submitIcon ?? <FeatherCheck />}
loading={props.submitting}
disabled={props.submitDisabled}
onClick={props.onSubmit}
data-ui-id={`${props.uiId}.submit`}
>
{props.submitLabel}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
);
}
export default QuickActionDialog;
@@ -0,0 +1,68 @@
// Shared refresh affordance for list screens. The plain IconButton `loading`
// state hides the icon behind the generic loader, which reads as "the button
// vanished" rather than "the list is reloading" — so this keeps the refresh
// arrows and rotates them instead.
import { useEffect, useRef, useState } from "react";
import { FeatherRefreshCw } from "@subframe/core";
import { IconButton } from "~/ui/components/IconButton";
/**
* Keeps a transient busy flag on for at least `minMs`. A revalidation that
* returns in 80ms would otherwise make the spinner flicker once, which reads as
* a glitch rather than as feedback.
*/
export function useMinimumDuration(active: boolean, minMs = 600): boolean {
const [held, setHeld] = useState(active);
const startedAt = useRef(0);
useEffect(() => {
if (active) {
if (!held) startedAt.current = Date.now();
setHeld(true);
return;
}
if (!held) return;
const remaining = Math.max(0, minMs - (Date.now() - startedAt.current));
if (remaining === 0) {
setHeld(false);
return;
}
const timer = setTimeout(() => setHeld(false), remaining);
return () => clearTimeout(timer);
}, [active, held, minMs]);
return held;
}
export type RefreshIconButtonProps = {
/** True while the underlying data is reloading (e.g. `revalidator.state !== "idle"`). */
readonly busy: boolean;
readonly onRefresh: () => void;
/** Translated label, used for both the accessible name and the tooltip. */
readonly label: string;
readonly dataUiId?: string;
};
export function RefreshIconButton({ busy, onRefresh, label, dataUiId }: RefreshIconButtonProps): React.JSX.Element {
const spinning = useMinimumDuration(busy);
return (
<IconButton
variant="ghost"
size="small"
icon={
// The hover tilt makes the button answer the pointer before the click;
// while reloading the arrows spin instead.
<FeatherRefreshCw
className={spinning ? "animate-spin" : "transition-transform duration-200 group-hover/af9405b1:rotate-45"}
/>
}
disabled={spinning}
data-busy={spinning ? "true" : undefined}
onClick={onRefresh}
aria-label={label}
title={label}
data-ui-id={dataUiId}
/>
);
}