Skip to documentation
Design system / Sources & standards
Current repository source
member-invitation-field.tsx
src/components/members/member-invitation-field.tsx
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
import { Button } from "@/components/ui/button";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { Text } from "@/components/ui/text";
import type { MemberManagerConfig } from "./types";
import type { ReactNode } from "react";
export function MemberFeedback({ error, notice, errorId }: { error?: string | null; notice?: string | null; errorId?: string }) {
return <>
{error && <Text id={errorId} role="alert" variant="supporting" className="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive">{error}</Text>}
{notice && <Text role="status" variant="supporting">{notice}</Text>}
</>;
}
/** One controlled email-entry concern; intentionally not a form (may be nested in one). */
export function MemberInvitationField({ id, config, value, disabled, saving, error, inputInvalid = false, notice, onChange, onAdd, children }: {
id: string; config: MemberManagerConfig; value: string; disabled: boolean; saving: boolean;
error: string | null; notice?: string | null; onChange: (value: string) => void; onAdd: () => void | Promise<void>;
children?: ReactNode;
inputInvalid?: boolean;
}) {
return <div className="flex min-w-0 flex-1 flex-col gap-4" aria-busy={saving}>
<div className="space-y-2">
<Label htmlFor={`${id}-input`}>{config.inputLabel ?? `Add ${config.memberTypeLabel}(s)`}</Label>
<Textarea id={`${id}-input`} aria-describedby={`${id}-help${inputInvalid && error ? ` ${id}-error` : ""}`}
aria-invalid={inputInvalid} value={value} onChange={(event) => onChange(event.target.value)} disabled={disabled}
placeholder={config.addPlaceholder} rows={config.inputRows ?? 3} />
<Text id={`${id}-help`} variant="supporting" className="text-text-muted">{config.addHelpText}</Text>
</div>
<MemberFeedback error={error} notice={notice} errorId={`${id}-error`} />
{children}
<div className="mt-auto pt-2">
<Button type="button" variant={config.addButtonVariant ?? "default"} onClick={onAdd} disabled={disabled || !value.trim()}>
{saving ? (config.savingLabel ?? "Inviting...") : (config.addButtonLabel ?? `Invite ${config.memberTypeLabelPlural}`)}
</Button>
</div>
</div>;
}
All sources and standards