@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 2.69 kB
JavaScript
import{fn as e,o as t,r as n}from"./ErrorBlock-CuwX01Wv.js";import{D as r,F as i,S as a,c as o,j as s,m as c,s as l}from"./web-BWdORzMO.js";import{A as u,F as d,M as f,_ as p,v as m}from"./Form-Cbz3dIAq.js";var h=c(`<div>`),g=c(`<div class="flex gap-2.5">`),_=c(`<form class=w-full><div class="p-4 md:p-6"><div class=mb-4><h2 class="text-base font-semibold text-title"></h2><p class="mt-1 text-sm text-body"></p></div><div class="grid grid-cols-1 md:grid-cols-2 gap-4">`),v=c=>{let[v,y]=i(``),[b,x]=i(``),[S,C]=i(``),w=t.account.useUpdateMe({onSuccess:()=>{y(``),x(``),C(``),c.callbacks?.onSuccess?.(),c.state.setOpen(!1)}}),T=s(()=>c.options?.forced===!0),E=s(()=>{let e=v().length>0&&b().length>=1&&S().length>=1,t=b()===S();return!e||!t});return r(m,{get state(){return{open:c.state.open,setOpen:c.state.setOpen}},get options(){return{noPadding:!0,preventDismiss:T()}},get children(){var t=_(),i=t.firstChild,s=i.firstChild,m=s.firstChild,D=m.nextSibling,O=s.nextSibling;return t.addEventListener(`submit`,e=>{e.preventDefault(),w.action.mutate({currentPassword:v(),newPassword:b(),passwordConfirmation:S()})}),l(m,(()=>{var t=o(()=>!!T());return()=>t()?e()(`auth.password.reset.required.title`):e()(`actions.update.password`)})()),l(D,(()=>{var t=o(()=>!!T());return()=>t()?e()(`auth.password.reset.required.message`):e()(`auth.password.description`)})()),l(i,r(u,{id:`currentPassword`,name:`currentPassword`,type:`password`,get value(){return v()},onChange:y,get copy(){return{label:e()(`common.current.password`)}},get errors(){return d(`currentPassword`,w.errors)},hideOptionalText:!0}),O),l(O,r(u,{id:`newPassword`,name:`newPassword`,type:`password`,get value(){return b()},onChange:x,get copy(){return{label:e()(`common.new.password`)}},get errors(){return d(`newPassword`,w.errors)},hideOptionalText:!0,noMargin:!0}),null),l(O,r(u,{id:`passwordConfirmation`,name:`passwordConfirmation`,type:`password`,get value(){return S()},onChange:C,get copy(){return{label:e()(`common.confirm.password`)}},get errors(){return d(`passwordConfirmation`,w.errors)},hideOptionalText:!0,noMargin:!0}),null),l(i,r(f,{theme:`basic`,get message(){return w.errors()?.message},classes:`mt-4`}),null),l(t,r(p,{get children(){return[h(),(()=>{var t=g();return l(t,r(a,{get when(){return!T()},get children(){return r(n,{type:`button`,theme:`border-outline`,size:`medium`,get disabled(){return w.action.isPending},onClick:()=>c.state.setOpen(!1),get children(){return e()(`common.cancel`)}})}}),null),l(t,r(n,{type:`submit`,theme:`primary`,size:`medium`,get loading(){return w.action.isPending},get disabled(){return E()},get children(){return e()(`common.update`)}}),null),t})()]}}),null),t}})};export{v as t};