import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { useFormikContext } from 'formik';
import { useTranslation } from 'react-i18next';
import { c as cn } from '../utils-BJnb9o5c.js';
import { FormikButton } from './Button.js';
import { b as Button } from '../Button-C4c_dj-f.js';
import 'ramda';
import 'react-router-dom';
import '../renderIcon-C6twJSqH.js';
import '../primitives/Button.js';
import '../button-CePY5zne.js';
import '../index-Bo3AAQJp.js';
import '../index-CfriMyrd.js';
import '../index-BtkPdosV.js';
import '../primitives/Spinner.js';
import '../loader-circle-DycHUAWN.js';
import '../createLucideIcon-C8ycilSN.js';
import '../primitives/Tooltip.js';
import '../tooltip-0DecQ06t.js';
import '../index-DNzunGHb.js';
import '../index-CiyxEyB0.js';
import '../index-BNPynZWM.js';
import '../index-DhnfW8wQ.js';
import 'react-dom';
import '../index-CSUSJzOJ.js';
import '../index-zW4GjM5L.js';
import '../index-DOzu5J1s.js';
import '../index-XvwNqU74.js';
import '../floating-ui.react-dom-BtFUJRfb.js';
import '../floating-ui.utils.dom-Bw_Rc4bg.js';
import '../index-BYZaLNq1.js';
import '../index-fV_U4ZJM.js';
import '../index-yFgkK_AM.js';
import '../index-Cor698lu.js';
import '../index-CSggBaQF.js';

const FormikActionBlock = forwardRef(
  ({
    className,
    submitButtonProps,
    cancelButtonProps,
    isSubmitting: isSubmittingProp,
    position = "left"
  }, ref) => {
    const { t } = useTranslation();
    const {
      handleReset,
      isSubmitting: isFormikSubmitting,
      dirty
    } = useFormikContext();
    const isSubmitting = isSubmittingProp ?? isFormikSubmitting;
    const cancelButton = /* @__PURE__ */ jsx(
      Button,
      {
        "data-testid": "cancel-button",
        disabled: isSubmitting,
        label: t("neetoui.actionBlock.cancel", "Cancel"),
        variant: "ghost",
        onClick: handleReset,
        onMouseDown: (e) => e.preventDefault(),
        ...cancelButtonProps
      }
    );
    const submitButton = /* @__PURE__ */ jsx(
      FormikButton,
      {
        "data-testid": "save-changes-button",
        disabled: isSubmitting || !dirty,
        label: t("neetoui.actionBlock.saveChanges", "Save changes"),
        type: "submit",
        ...submitButtonProps
      }
    );
    return /* @__PURE__ */ jsx(
      "div",
      {
        ref,
        className: cn(
          "flex items-center gap-2",
          position === "right" && "justify-end",
          className
        ),
        children: position === "right" ? /* @__PURE__ */ jsxs(Fragment, { children: [
          cancelButton,
          submitButton
        ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
          submitButton,
          cancelButton
        ] })
      }
    );
  }
);
FormikActionBlock.displayName = "FormikActionBlock";

export { FormikActionBlock };
//# sourceMappingURL=ActionBlock.js.map
