@scalar/api-client
Version:
the open source API testing client
53 lines (52 loc) • 1.58 kB
JavaScript
import { defineComponent as c, ref as p, computed as m, onMounted as f, nextTick as h, withDirectives as b, createElementBlock as g, openBlock as v, mergeProps as w, withKeys as u, vModelText as y } from "vue";
const x = ["placeholder"], E = {
name: "CommandActionInput"
}, _ = /* @__PURE__ */ c({
...E,
inheritAttrs: !1,
props: {
modelValue: {},
placeholder: {},
autofocus: { type: Boolean, default: !0 }
},
emits: ["update:modelValue", "delete"],
setup(l, { emit: s }) {
const a = s, r = p(null), o = m({
get: () => l.modelValue ?? "",
set: (e) => a("update:modelValue", e)
});
f(() => {
h(() => {
l.autofocus && r.value?.focus();
});
});
const d = (e) => {
if (e.shiftKey || !e.target)
return;
e.preventDefault();
const t = e.target, n = new Event("submit", { cancelable: !0 });
t.form?.dispatchEvent(n);
}, i = (e) => {
o.value === "" && (e.preventDefault(), e.stopPropagation(), a("delete", e));
};
return (e, t) => b((v(), g("textarea", w({
id: "command-action-input",
ref_key: "input",
ref: r,
"onUpdate:modelValue": t[0] || (t[0] = (n) => o.value = n),
class: "min-h-8 w-full flex-1 resize-none border border-transparent py-1.5 pl-8.5 text-sm outline-none focus:border-b-1",
placeholder: e.placeholder ?? "",
wrap: "hard"
}, e.$attrs, {
onKeydown: [
u(i, ["delete"]),
u(d, ["enter"])
]
}), null, 16, x)), [
[y, o.value]
]);
}
});
export {
_ as default
};