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