@scalar/api-client
Version:
the open source API testing client
89 lines (88 loc) • 2.94 kB
JavaScript
import { defineComponent as V, ref as c, watch as x, createBlock as b, openBlock as k, unref as C, withCtx as m, createVNode as t, createElementVNode as i, createTextVNode as l } from "vue";
import { ScalarModal as g } from "@scalar/components";
import { useToasts as N } from "@scalar/use-toasts";
import S from "../../components/CommandPalette/CommandActionForm.vue.js";
import n from "../../components/CommandPalette/CommandActionInput.vue.js";
const U = { class: "flex h-8 items-start gap-2 text-sm" }, $ = { class: "flex h-8 items-start gap-2 text-sm" }, w = { class: "flex h-8 items-start gap-2 text-sm" }, _ = /* @__PURE__ */ V({
__name: "CookieModal",
props: {
state: {}
},
emits: ["cancel", "submit"],
setup(r, { emit: p }) {
const u = r, d = p, a = c({
name: "",
value: "",
domain: ""
}), { toast: f } = N(), v = () => {
if (!a.value.name || !a.value.value) {
f("Please fill in all fields before adding a cookie.", "error");
return;
}
d("submit", a.value), u.state.hide();
};
return x(
() => u.state.open,
(s) => {
s && (a.value = {
name: "",
value: "",
domain: ""
});
}
), (s, e) => (k(), b(C(g), {
size: "xs",
state: s.state,
title: "Add Cookie"
}, {
default: m(() => [
t(S, {
disabled: !a.value.name || !a.value.value,
onCancel: e[3] || (e[3] = (o) => d("cancel")),
onSubmit: v
}, {
submit: m(() => [...e[7] || (e[7] = [
l("Add Cookie", -1)
])]),
default: m(() => [
i("div", U, [
e[4] || (e[4] = l(" Name: ", -1)),
t(n, {
modelValue: a.value.name,
"onUpdate:modelValue": e[0] || (e[0] = (o) => a.value.name = o),
autofocus: "",
class: "!p-0",
placeholder: "session_id"
}, null, 8, ["modelValue"])
]),
i("div", $, [
e[5] || (e[5] = l(" Value: ", -1)),
t(n, {
modelValue: a.value.value,
"onUpdate:modelValue": e[1] || (e[1] = (o) => a.value.value = o),
autofocus: "",
class: "!p-0",
placeholder: "my-cookie-session-id"
}, null, 8, ["modelValue"])
]),
i("div", w, [
e[6] || (e[6] = l(" Domain: ", -1)),
t(n, {
modelValue: a.value.domain,
"onUpdate:modelValue": e[2] || (e[2] = (o) => a.value.domain = o),
autofocus: "",
class: "!p-0",
placeholder: "example.com"
}, null, 8, ["modelValue"])
])
]),
_: 1
}, 8, ["disabled"])
]),
_: 1
}, 8, ["state"]));
}
});
export {
_ as default
};