"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Check, X } from "lucide-react";
import { IconButton } from "../../primitives/icon-button.js";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function NewViewForm({ name, onNameChange, onSubmit, onCancel, saving }) {
  const t = useT();
  const trimmed = name.trim();
  return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
    /* @__PURE__ */ jsx(
      "input",
      {
        value: name,
        onChange: (e) => onNameChange(e.target.value),
        placeholder: t("ui.perspectives.form.namePlaceholder", "View name..."),
        autoFocus: true,
        className: "w-full h-9 rounded border border-primary pl-2 pr-16 text-sm",
        onKeyDown: (e) => {
          if (e.key === "Enter" && trimmed) onSubmit();
          if (e.key === "Escape") onCancel();
        }
      }
    ),
    /* @__PURE__ */ jsxs("div", { className: "absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5", children: [
      /* @__PURE__ */ jsx(
        IconButton,
        {
          type: "button",
          variant: "ghost",
          size: "xs",
          onClick: () => {
            if (trimmed) onSubmit();
          },
          disabled: !trimmed || saving,
          "aria-label": t("ui.perspectives.form.confirmCreate", "Create view"),
          children: /* @__PURE__ */ jsx(Check, { className: `size-4 ${trimmed ? "text-brand-violet" : "text-muted-foreground opacity-50"}` })
        }
      ),
      /* @__PURE__ */ jsx(
        IconButton,
        {
          type: "button",
          variant: "ghost",
          size: "xs",
          onClick: onCancel,
          "aria-label": t("ui.perspectives.form.cancelCreate", "Cancel"),
          children: /* @__PURE__ */ jsx(X, { className: "size-4 text-muted-foreground hover:text-destructive" })
        }
      )
    ] })
  ] });
}
export {
  NewViewForm
};
//# sourceMappingURL=NewViewForm.js.map
