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