Skip to content

armgit / pibot

Public Imported from GitHub
0

Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.

1.0 KB
Raw Blame
import { useSettingsDialog, useT } from "@pibot/renderer-kit";
import { CloseButton } from "@pibot/ui";
import { type ReactNode, useId } from "react";
import styles from "./connectors.module.css";

export function ConnectorPanel({
  title,
  children,
  close,
  busy = false,
}: {
  title: string;
  children: ReactNode;
  close(): void;
  busy?: boolean;
}) {
  const t = useT();
  const id = useId();
  const modal = useSettingsDialog(close);
  const requestClose = () => {
    if (!busy) modal.close();
  };
  return (
    <dialog
      ref={modal.dialog}
      className={styles.panel}
      data-closing={modal.closing || undefined}
      aria-labelledby={id}
      onKeyDown={modal.trapFocus}
      onCancel={(event) => {
        event.preventDefault();
        requestClose();
      }}
    >
      <header className={styles.panelHeader}>
        <h2 id={id}>{title}</h2>
        <CloseButton label={t("common.cancel")} disabled={busy} onClick={requestClose} />
      </header>
      <div className={styles.panelBody}>{children}</div>
    </dialog>
  );
}