import { defineComponent as f, ref as u, openBlock as d, createElementBlock as y, createVNode as a, unref as e, withCtx as n, createTextVNode as r, toDisplayString as m } from "vue";
import { Flex as x, Button as p } from "@aplus-frontend/antdv";
import { ApForm as C } from "../../../../ap-form/index.mjs";
import "../../../../config-provider/index.mjs";
import { useLocale as b } from "../../../../config-provider/hooks/use-locale.mjs";
import { ApFormItemText as g } from "../../../../ap-form/items/text/index.mjs";
const B = /* @__PURE__ */ f({
  __name: "edit-form",
  props: {
    onConfirm: { type: Function },
    onCancel: { type: Function },
    initialValues: {},
    isEdit: { type: Boolean }
  },
  setup(l) {
    const c = l, { t } = b(), o = u();
    async function s() {
      const i = await o.value?.validateFields();
      c.onConfirm(i?.label);
    }
    return (i, h) => (d(), y("div", null, [
      a(e(C), {
        ref_key: "formRef",
        ref: o,
        colon: !1,
        "label-col": { span: 24 },
        "initial-values": l.initialValues
      }, {
        default: n(() => [
          a(e(g), {
            rules: [
              {
                required: !0,
                message: e(t)("ap.apTable.setting.templateNamePlaceholder")
              }
            ],
            name: "label",
            label: l.isEdit ? e(t)("ap.apTable.setting.templateName") : e(t)("ap.apTable.setting.newTemplateName")
          }, null, 8, ["rules", "label"])
        ]),
        _: 1
      }, 8, ["initial-values"]),
      a(e(x), {
        justify: "end",
        gap: 8
      }, {
        default: n(() => [
          a(e(p), {
            style: { height: "24px" },
            onClick: l.onCancel
          }, {
            default: n(() => [
              r(m(e(t)("ap.common.cancelText")), 1)
            ]),
            _: 1
          }, 8, ["onClick"]),
          a(e(p), {
            style: { height: "24px" },
            type: "primary",
            onClick: s
          }, {
            default: n(() => [
              r(m(e(t)("ap.common.save")), 1)
            ]),
            _: 1
          })
        ]),
        _: 1
      })
    ]));
  }
});
export {
  B as default
};
