UNPKG

kodama-ui

Version:

Kodama UI is a Vue 3 component library that provides a set of components & funcionality to build your application.

128 lines (127 loc) 4.05 kB
import { defineComponent as g, inject as k, ref as w, reactive as x, computed as V, onMounted as h, resolveComponent as m, openBlock as _, createBlock as $, withCtx as c, createElementVNode as o, createElementBlock as y, createTextVNode as p, createVNode as i, createCommentVNode as E, withModifiers as F } from "vue"; import { u as N, r as b } from "./index-3aaa06c4.mjs"; import { r as B } from "./virtual_pwa-register-ec3d18f2.mjs"; import { _ as C } from "./main-5627e7fd.mjs"; const L = g({ name: "Login", setup() { const e = k("$auth"), t = !1, d = w(!1); let u = null; const s = x({ username: "", password: "" }), n = N({ password: { required: b }, username: { required: b } }, s), r = V(() => !n.value.$invalid), f = async (a) => { r.value && (d.value = !0, e.login(s.username, s.password).then(() => { window.location.reload(); }).finally(() => { d.value = !1; })); }; return h(() => { "serviceWorker" in navigator && (u = B({ onNeedRefresh() { u && u(!0); }, onRegistered(a) { a && setInterval(() => { a.update(); }, 6e4); } })); }), { loading: d, submitLogin: f, // loginSchema, signupEnabled: t, state: s, v$: n, isValidForm: r }; } }); const S = { class: "p-1 sm:p-5 select-none" }, R = { class: "text-center mb-10" }, U = /* @__PURE__ */ o("h1", { class: "mb-3 sm:text-3xl text-2xl uppercase font-bold" }, " Iniciar Sesión ", -1), W = { key: 0, class: "text-gray-400 fw-bold fs-4" }, q = { class: "mb-4" }, D = { class: "mb-10" }, I = { class: "text-center" }; function M(e, t, d, u, s, v) { const n = m("router-link"), r = m("k-input"), f = m("k-button"), a = m("k-card"); return _(), $(a, { id: "k-login" }, { default: c(() => [ o("div", S, [ o("div", R, [ U, e.signupEnabled ? (_(), y("div", W, [ p(" ¿Nuevo aquí? "), i(n, { to: { name: "register" }, class: "link-primary fw-bolder" }, { default: c(() => [ p(" Regístrate ") ]), _: 1 }) ])) : E("", !0) ]), o("form", { onSubmit: t[2] || (t[2] = F((...l) => e.submitLogin && e.submitLogin(...l), ["prevent"])) }, [ o("div", q, [ i(r, { modelValue: e.state.username, "onUpdate:modelValue": t[0] || (t[0] = (l) => e.state.username = l), type: "text", placeholder: "", label: "Email / Usuario", tabindex: "1", errors: e.v$.username.$errors }, null, 8, ["modelValue", "errors"]) ]), o("div", D, [ i(r, { modelValue: e.state.password, "onUpdate:modelValue": t[1] || (t[1] = (l) => e.state.password = l), type: "password", name: "password", label: "Contraseña", tabindex: "2", errors: e.v$.password.$errors }, null, 8, ["modelValue", "errors"]) ]), o("div", I, [ i(f, { loading: e.loading, icon: "right-from-bracket", class: "w-full mb-4", disabled: !e.isValidForm, type: "submit" }, { default: c(() => [ p(" Acceder ") ]), _: 1 }, 8, ["loading", "disabled"]), i(n, { to: { name: "forgotPassword" }, class: "text-sm", tabindex: "3" }, { default: c(() => [ p(" ¿Olvidaste tu contraseña? ") ]), _: 1 }) ]) ], 32) ]) ]), _: 1 }); } const T = /* @__PURE__ */ C(L, [["render", M]]); export { T as default };