UNPKG

@scalar/api-client

Version:

the open source API testing client

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