import { defineComponent as y, reactive as _, computed as b, ref as k, createElementBlock as l, openBlock as n, normalizeClass as C, toDisplayString as V, unref as g } from "vue";
import { call as B } from "@milaboratories/helpers";
const T = ["value"], R = { key: 1 }, F = /* @__PURE__ */ y({
  __name: "BaseCellComponent",
  props: {
    modelValue: {},
    valueType: {},
    editable: { type: Boolean }
  },
  emits: ["update:modelValue"],
  setup(r, { emit: p }) {
    const c = p, s = r, a = _({
      edit: !1
    }), d = b(() => s.valueType), m = (t) => {
      var i;
      const e = (i = t.target) == null ? void 0 : i.value, o = g(d), v = B(() => o === "integer" ? parseInt(e, 10) : o === "float" ? Number(e) : e);
      c("update:modelValue", v), a.edit = !1;
    }, u = k(), f = (t) => {
      !t.metaKey && s.editable && (a.edit = !0, requestAnimationFrame(() => {
        var e, o;
        (o = (e = u.value) == null ? void 0 : e.querySelector("input")) == null || o.focus();
      }));
    };
    return (t, e) => (n(), l("div", {
      ref_key: "baseRef",
      ref: u,
      class: C(["base-cell", { "base-cell__edit": a.edit }]),
      onClick: f
    }, [
      a.edit ? (n(), l("input", {
        key: 0,
        value: t.modelValue,
        onFocusout: e[0] || (e[0] = (o) => a.edit = !1),
        onChange: m
      }, null, 40, T)) : (n(), l("div", R, V(t.modelValue), 1))
    ], 2));
  }
});
export {
  F as default
};
//# sourceMappingURL=BaseCellComponent.vue.js.map
