Alpenwerk HR — HR-Stammdatenverwaltung Mitarbeiter:innen, Organisationsstruktur, Planstellen, Eintritt, Austritt, Versetzung, Beförderung, Karenz, On- und Offboarding, Berichte, Exporte, Massenimport und ein lückenloser Nachweis jeder Änderung. Next.js 16, React 19 und TypeScript; PostgreSQL über Kysely; Anmeldung ausschliesslich über Microsoft Entra ID. Die Fachlogik liegt in der Datenbank, die Zugriffsschranke ist Row Level Security. Betrieb auf Windows Server: siehe deploy/windows/README.md. Sicherheitskonzept: docs/sicherheitskonzept.md.
56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
"use client";
|
|
|
|
import { X } from "lucide-react";
|
|
import { useId, useRef, type ReactNode } from "react";
|
|
import { Button } from "./Button";
|
|
import { useDialogFocus } from "./useDialogFocus";
|
|
|
|
type ModalProps = {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
title: string;
|
|
children: ReactNode;
|
|
footer?: ReactNode;
|
|
widthClassName?: string;
|
|
};
|
|
|
|
export function Modal({ open, onClose, title, children, footer, widthClassName = "max-w-lg" }: ModalProps) {
|
|
const dialogRef = useRef<HTMLDivElement>(null);
|
|
const titleId = useId();
|
|
useDialogFocus(open, onClose, dialogRef);
|
|
|
|
if (!open) return null;
|
|
|
|
return (
|
|
// Bottom-aligned on a phone (thumb reach, and it clears the keyboard when
|
|
// a field is focused), centred from sm up.
|
|
<div className="fixed inset-0 z-50 flex items-end justify-center bg-black/40 p-0 sm:items-center sm:p-4">
|
|
<div
|
|
ref={dialogRef}
|
|
role="dialog"
|
|
aria-modal="true"
|
|
// Points at the real heading rather than duplicating the string, so
|
|
// the accessible name cannot drift from what is on screen.
|
|
aria-labelledby={titleId}
|
|
tabIndex={-1}
|
|
className={`flex max-h-[92dvh] w-full flex-col rounded-t-xl bg-white shadow-[var(--shadow-overlay)] outline-none sm:max-h-[85dvh] sm:rounded ${widthClassName}`}
|
|
>
|
|
<div className="flex shrink-0 items-center justify-between border-b border-border px-4 py-3 sm:px-6 sm:py-4">
|
|
<h2 id={titleId} className="text-lg font-bold text-ink">
|
|
{title}
|
|
</h2>
|
|
<Button variant="icon" onClick={onClose} aria-label="Schließen" className="-mr-1">
|
|
<X className="h-5 w-5" />
|
|
</Button>
|
|
</div>
|
|
<div className="flex-1 overflow-y-auto overscroll-contain px-4 py-4 sm:px-6">{children}</div>
|
|
{footer && (
|
|
<div className="flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6 sm:py-4">
|
|
{footer}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|