@service_laboratory/auth 2.0.18 → 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8692,7 +8692,7 @@ const Yp = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], Bi =
8692
8692
  function vm(e) {
8693
8693
  const [t, r] = $r(!1);
8694
8694
  return /* @__PURE__ */ O.jsxs("div", { className: "flex flex-col gap-6", children: [
8695
- /* @__PURE__ */ O.jsx("h1", { children: "test local 132" }),
8695
+ /* @__PURE__ */ O.jsx("h1", { children: "test local 004" }),
8696
8696
  /* @__PURE__ */ O.jsxs(
8697
8697
  Hr,
8698
8698
  {
@@ -61,4 +61,4 @@ Defaulting to \`null\`.`}var _i="Dialog",[Ei,cm]=Ee(_i),[um,xe]=Ei(_i),ki="Dialo
61
61
 
62
62
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
63
63
 
64
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},fp="DialogDescriptionWarning",pp=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ti(fp).contentName}}.`;return f.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},mp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),gp="VisuallyHidden",Ni=f.forwardRef((e,t)=>b.jsx(J.span,{...e,ref:t,style:{...mp,...e.style}}));Ni.displayName=gp;var hp=Ni,[nr,pm]=Ee("Tooltip",[zt]),wn=zt(),yp="TooltipProvider",Di="tooltip.open",[mm,Ai]=nr(yp),Pi="Tooltip",[gm,or]=nr(Pi),xn="TooltipTrigger",vp=f.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=or(xn,r),a=Ai(xn,r),i=wn(r),s=f.useRef(null),u=Q(t,s,o.onTriggerChange),l=f.useRef(!1),p=f.useRef(!1),c=f.useCallback(()=>l.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",c),[c]),b.jsx(sa,{asChild:!0,...i,children:b.jsx(J.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...n,ref:u,onPointerMove:F(e.onPointerMove,d=>{d.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:F(e.onPointerDown,()=>{o.open&&o.onClose(),l.current=!0,document.addEventListener("pointerup",c,{once:!0})}),onFocus:F(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:F(e.onBlur,o.onClose),onClick:F(e.onClick,o.onClose)})})});vp.displayName=xn;var bp="TooltipPortal",[hm,wp]=nr(bp,{forceMount:void 0}),et="TooltipContent",xp=f.forwardRef((e,t)=>{const r=wp(et,e.__scopeTooltip),{forceMount:n=r.forceMount,side:o="top",...a}=e,i=or(et,e.__scopeTooltip);return b.jsx(je,{present:n||i.open,children:i.disableHoverableContent?b.jsx(Mi,{side:o,...a,ref:t}):b.jsx(_p,{side:o,...a,ref:t})})}),_p=f.forwardRef((e,t)=>{const r=or(et,e.__scopeTooltip),n=Ai(et,e.__scopeTooltip),o=f.useRef(null),a=Q(t,o),[i,s]=f.useState(null),{trigger:u,onClose:l}=r,p=o.current,{onPointerInTransitChange:c}=n,d=f.useCallback(()=>{s(null),c(!1)},[c]),m=f.useCallback((y,g)=>{const v=y.currentTarget,w={x:y.clientX,y:y.clientY},x=Cp(w,v.getBoundingClientRect()),E=Op(w,x),_=jp(g.getBoundingClientRect()),C=Np([...E,..._]);s(C),c(!0)},[c]);return f.useEffect(()=>()=>d(),[d]),f.useEffect(()=>{if(u&&p){const y=v=>m(v,p),g=v=>m(v,u);return u.addEventListener("pointerleave",y),p.addEventListener("pointerleave",g),()=>{u.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",g)}}},[u,p,m,d]),f.useEffect(()=>{if(i){const y=g=>{const v=g.target,w={x:g.clientX,y:g.clientY},x=u?.contains(v)||p?.contains(v),E=!Tp(w,i);x?d():E&&(d(),l())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,p,i,l,d]),b.jsx(Mi,{...e,ref:a})}),[Ep,kp]=nr(Pi,{isInside:!1}),Rp=$s("TooltipContent"),Mi=f.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...s}=e,u=or(et,r),l=wn(r),{onClose:p}=u;return f.useEffect(()=>(document.addEventListener(Di,p),()=>document.removeEventListener(Di,p)),[p]),f.useEffect(()=>{if(u.trigger){const c=d=>{d.target?.contains(u.trigger)&&p()};return window.addEventListener("scroll",c,{capture:!0}),()=>window.removeEventListener("scroll",c,{capture:!0})}},[u.trigger,p]),b.jsx(jt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:c=>c.preventDefault(),onDismiss:p,children:b.jsxs(la,{"data-state":u.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[b.jsx(Rp,{children:n}),b.jsx(Ep,{scope:r,isInside:!0,children:b.jsx(hp,{id:u.contentId,role:"tooltip",children:o||n})})]})})});xp.displayName=et;var Li="TooltipArrow",Sp=f.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=wn(r);return kp(Li,r).isInside?null:b.jsx(ca,{...o,...n,ref:t})});Sp.displayName=Li;function Cp(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(r,n,o,a)){case a:return"left";case o:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Op(e,t,r=5){const n=[];switch(t){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function jp(e){const{top:t,right:r,bottom:n,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:n},{x:o,y:n}]}function Tp(e,t){const{x:r,y:n}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const s=t[a],u=t[i],l=s.x,p=s.y,c=u.x,d=u.y;p>n!=d>n&&r<(c-l)*(n-p)/(d-p)+l&&(o=!o)}return o}function Np(e){const t=e.slice();return t.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),Dp(t)}function Dp(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const o=e[n];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const o=e[n];for(;r.length>=2;){const a=r[r.length-1],i=r[r.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}f.createContext(null);const Ap=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pp=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Ii=e=>{const t=Pp(e);return t.charAt(0).toUpperCase()+t.slice(1)},Fi=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Mp=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Lp={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ip=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:a,iconNode:i,...s},u)=>P.createElement("svg",{ref:u,...Lp,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Fi("lucide",o),...!a&&!Mp(s)&&{"aria-hidden":"true"},...s},[...i.map(([l,p])=>P.createElement(l,p)),...Array.isArray(a)?a:[a]]));const _n=(e,t)=>{const r=P.forwardRef(({className:n,...o},a)=>P.createElement(Ip,{ref:a,iconNode:t,className:Fi(`lucide-${Ap(Ii(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Ii(e),r};const Vi=_n("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const zi=_n("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const $i=_n("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function Fp(e){const[t,r]=P.useState(!1);return O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsx("h1",{children:"test local 132"}),O.jsxs(xr,{className:ue({"opacity-50":e.form.formState.isSubmitting}),children:[O.jsxs(_r,{children:[O.jsx(Er,{className:"text-2xl",children:e.loginFormTitle}),O.jsx(kr,{children:e.loginFormDescription})]}),O.jsx(Rr,{children:O.jsx(gn,{...e.form,children:O.jsx("form",{onSubmit:e.form.handleSubmit(e.submit),children:O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(ht,{htmlFor:"email",children:e.emailLabel}),O.jsx(vt,{control:e.form.control,name:"email",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{children:O.jsx(xt,{disabled:e.form.formState.isSubmitting,type:"email",placeholder:"m@example.com",required:!0,...n})})})})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsxs("div",{className:"flex items-center",children:[O.jsx(ht,{htmlFor:"password",children:e.passwordLabel}),e.resetPasswordLinkComponent?e.resetPasswordLinkComponent():null]}),O.jsx(vt,{control:e.form.control,name:"password",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{className:"relative",children:O.jsxs("div",{className:"relative",children:[t?O.jsx(Vi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!1)}}):O.jsx(zi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!0)}}),O.jsx(xt,{type:t?"text":"password",placeholder:"********",disabled:e.form.formState.isSubmitting,...n,className:"pr-10"})]})})})})]}),O.jsxs(wr,{type:"submit",className:"w-full cursor-pointer",disabled:e.form.formState.isSubmitting,children:[e.submitButtonLabel,e.form.formState.isSubmitting&&O.jsx($i,{className:"animate-spin"})]}),e.signUpLinkComponent?O.jsx(un,{className:"text-center",children:e.signUpLinkComponent()}):null]})})})})]})]})}function Vp(e){const[t,r]=P.useState(!1);return O.jsx("div",{className:"flex flex-col gap-6",children:O.jsxs(xr,{className:ue({"opacity-50":e.form.formState.isSubmitting}),children:[O.jsxs(_r,{children:[O.jsx(Er,{className:"text-2xl",children:e.signUpFormTitle}),O.jsx(kr,{children:e.signUpFormDescription})]}),O.jsx(Rr,{children:O.jsx(gn,{...e.form,children:O.jsx("form",{onSubmit:e.form.handleSubmit(e.submit),children:O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(ht,{children:e.emailLabel}),O.jsx(vt,{control:e.form.control,name:"email",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{children:O.jsx(xt,{disabled:e.form.formState.isSubmitting,type:"email",placeholder:"m@example.com",required:!0,...n})})})})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsxs("div",{className:"flex items-center",children:[O.jsx(ht,{children:e.passwordLabel}),e.resetPasswordLinkComponent?e.resetPasswordLinkComponent():null]}),O.jsx(vt,{control:e.form.control,name:"password",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{className:"relative",children:O.jsxs("div",{className:"relative",children:[t?O.jsx(Vi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!1)}}):O.jsx(zi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!0)}}),O.jsx(xt,{disabled:e.form.formState.isSubmitting,type:t?"text":"password",placeholder:"********",...n,className:"pr-10"})]})})})})]}),O.jsxs(wr,{type:"submit",className:"w-full cursor-pointer",disabled:e.form.formState.isSubmitting,children:[e.submitButtonLabel,e.form.formState.isSubmitting&&O.jsx($i,{className:"animate-spin"})]}),e.loginLinkComponent?O.jsx(un,{className:"text-center",children:e.loginLinkComponent()}):null]})})})})]})})}function zp(e){return O.jsx("div",{className:"flex flex-col gap-6",children:O.jsxs(xr,{children:[O.jsxs(_r,{children:[O.jsx(Er,{className:"text-2xl",children:e.activateAccountTitle}),O.jsx(kr,{children:e.activateAccountDescription})]}),O.jsx(Rr,{children:O.jsx(gn,{...e.form,children:O.jsx("form",{onSubmit:e.form.handleSubmit(e.submit),children:O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(ht,{children:e.codeLabel}),O.jsx(vt,{control:e.form.control,name:"code",render:({field:t})=>O.jsx(bt,{children:O.jsx(wt,{children:O.jsx(xt,{type:"text",placeholder:"00001234",required:!0,...t})})})})]}),O.jsx(wr,{type:"submit",className:"w-full cursor-pointer",children:e.submitButtonLabel}),e.loginLinkComponent?O.jsx(un,{className:"text-center",children:e.loginLinkComponent()}):null]})})})})]})})}const tt=new WeakMap,ar=new WeakMap,ir={current:[]};let En=!1;const sr=new Set,Wi=new Map;function Ui(e){const t=Array.from(e).sort((r,n)=>r instanceof Fe&&r.options.deps.includes(n)?1:n instanceof Fe&&n.options.deps.includes(r)?-1:0);for(const r of t){if(ir.current.includes(r))continue;ir.current.push(r),r.recompute();const n=ar.get(r);if(n)for(const o of n){const a=tt.get(o);a&&Ui(a)}}}function $p(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function Wp(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function Up(e){if(sr.add(e),!En)try{for(En=!0;sr.size>0;){const t=Array.from(sr);sr.clear();for(const r of t){const n=Wi.get(r)??r.prevState;r.prevState=n,$p(r)}for(const r of t){const n=tt.get(r);n&&(ir.current.push(r),Ui(n))}for(const r of t){const n=tt.get(r);if(n)for(const o of n)Wp(o)}}}finally{En=!1,ir.current=[],Wi.clear()}}function Bp(e){return typeof e=="function"}class kn{constructor(t,r){this.listeners=new Set,this.subscribe=n=>{var o,a;this.listeners.add(n);const i=(a=(o=this.options)==null?void 0:o.onSubscribe)==null?void 0:a.call(o,n,this);return()=>{this.listeners.delete(n),i?.()}},this.prevState=t,this.state=t,this.options=r}setState(t){var r,n,o;this.prevState=this.state,(r=this.options)!=null&&r.updateFn?this.state=this.options.updateFn(this.prevState)(t):Bp(t)?this.state=t(this.prevState):this.state=t,(o=(n=this.options)==null?void 0:n.onUpdate)==null||o.call(n),Up(this)}}class Fe{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const r=[],n=[];for(const o of this.options.deps)r.push(o.prevState),n.push(o.state);return this.lastSeenDepValues=n,{prevDepVals:r,currDepVals:n,prevVal:this.prevState??void 0}},this.recompute=()=>{var r,n;this.prevState=this.state;const{prevDepVals:o,currDepVals:a,prevVal:i}=this.getDepVals();this.state=this.options.fn({prevDepVals:o,currDepVals:a,prevVal:i}),(n=(r=this.options).onUpdate)==null||n.call(r)},this.checkIfRecalculationNeededDeeply=()=>{for(const a of this.options.deps)a instanceof Fe&&a.checkIfRecalculationNeededDeeply();let r=!1;const n=this.lastSeenDepValues,{currDepVals:o}=this.getDepVals();for(let a=0;a<o.length;a++)if(o[a]!==n[a]){r=!0;break}r&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const r of this._subscriptions)r()}),this.subscribe=r=>{var n,o;this.listeners.add(r);const a=(o=(n=this.options).onSubscribe)==null?void 0:o.call(n,r,this);return()=>{this.listeners.delete(r),a?.()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(const r of t)if(r instanceof Fe)r.registerOnGraph(),this.registerOnGraph(r.options.deps);else if(r instanceof kn){let n=tt.get(r);n||(n=new Set,tt.set(r,n)),n.add(this);let o=ar.get(this);o||(o=new Set,ar.set(this,o)),o.add(r)}}unregisterFromGraph(t=this.options.deps){for(const r of t)if(r instanceof Fe)this.unregisterFromGraph(r.options.deps);else if(r instanceof kn){const n=tt.get(r);n&&n.delete(this);const o=ar.get(this);o&&o.delete(r)}}}const Rn="Authorization",Bi=()=>({user:{id:null,email:null,roles:[],is_enabled:!1,is_email_verified:!1},sessionID:null,isAuthenticated:!1,isLoaded:!1}),Ve=new kn(Bi()),Gp=new Fe({fn:()=>!!Ve.state.user?.roles.find(e=>e.name==="admin"),deps:[Ve]});class Hp{accountStore;httpClient;constructor(t){this.httpClient=t,this.accountStore=Ve}initAuthData(){const t=localStorage.getItem("token");t&&(this.httpClient.defaults.headers.common[Rn]=t)}async load(){try{const{data:t}=await this.httpClient.get("/api/auth/account/me");Ve.setState(()=>({user:t.user,sessionID:t.session_id,isAuthenticated:!0,isLoaded:!0}))}catch{Ve.setState(t=>({...t,isLoaded:!0}))}}async login(t){const r=await this.httpClient.post("/api/auth/account/login",t),{user:n,token:o,session_id:a}=r.data;return this._initUserData({user:n,token:o,sessionID:a}),n}signup(t){return this.httpClient.post("/api/auth/account/signup",t)}async activate(t){const r=await this.httpClient.post("/api/auth/account/activate",t);this._initUserData(r.data)}logout(){Ve.setState(()=>({...Bi(),isLoaded:!0})),this._clearAuthData()}startResetPassword(t){return this.httpClient.post("/api/auth/account/start-reset-password",t)}async resetPassword(t){const r=await this.httpClient.post("/api/auth/account/reset-password",t);this._initUserData(r.data)}_initUserData({user:t,token:r,sessionID:n}){this._setAuthData(r),Ve.setState(()=>({user:t,isAuthenticated:!0,isLoaded:!0,sessionID:n}))}_setAuthData(t){localStorage.setItem("token",t),this.httpClient.defaults.headers.common[Rn]=t}_clearAuthData(){localStorage.removeItem("token"),delete this.httpClient.defaults.headers.common[Rn]}}pe.ActivateAccountForm=zp,pe.Auth=Hp,pe.LoginForm=Fp,pe.SignUpForm=Vp,pe.isAdmin=Gp,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})}));
64
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},fp="DialogDescriptionWarning",pp=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ti(fp).contentName}}.`;return f.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},mp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),gp="VisuallyHidden",Ni=f.forwardRef((e,t)=>b.jsx(J.span,{...e,ref:t,style:{...mp,...e.style}}));Ni.displayName=gp;var hp=Ni,[nr,pm]=Ee("Tooltip",[zt]),wn=zt(),yp="TooltipProvider",Di="tooltip.open",[mm,Ai]=nr(yp),Pi="Tooltip",[gm,or]=nr(Pi),xn="TooltipTrigger",vp=f.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=or(xn,r),a=Ai(xn,r),i=wn(r),s=f.useRef(null),u=Q(t,s,o.onTriggerChange),l=f.useRef(!1),p=f.useRef(!1),c=f.useCallback(()=>l.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",c),[c]),b.jsx(sa,{asChild:!0,...i,children:b.jsx(J.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...n,ref:u,onPointerMove:F(e.onPointerMove,d=>{d.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:F(e.onPointerDown,()=>{o.open&&o.onClose(),l.current=!0,document.addEventListener("pointerup",c,{once:!0})}),onFocus:F(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:F(e.onBlur,o.onClose),onClick:F(e.onClick,o.onClose)})})});vp.displayName=xn;var bp="TooltipPortal",[hm,wp]=nr(bp,{forceMount:void 0}),et="TooltipContent",xp=f.forwardRef((e,t)=>{const r=wp(et,e.__scopeTooltip),{forceMount:n=r.forceMount,side:o="top",...a}=e,i=or(et,e.__scopeTooltip);return b.jsx(je,{present:n||i.open,children:i.disableHoverableContent?b.jsx(Mi,{side:o,...a,ref:t}):b.jsx(_p,{side:o,...a,ref:t})})}),_p=f.forwardRef((e,t)=>{const r=or(et,e.__scopeTooltip),n=Ai(et,e.__scopeTooltip),o=f.useRef(null),a=Q(t,o),[i,s]=f.useState(null),{trigger:u,onClose:l}=r,p=o.current,{onPointerInTransitChange:c}=n,d=f.useCallback(()=>{s(null),c(!1)},[c]),m=f.useCallback((y,g)=>{const v=y.currentTarget,w={x:y.clientX,y:y.clientY},x=Cp(w,v.getBoundingClientRect()),E=Op(w,x),_=jp(g.getBoundingClientRect()),C=Np([...E,..._]);s(C),c(!0)},[c]);return f.useEffect(()=>()=>d(),[d]),f.useEffect(()=>{if(u&&p){const y=v=>m(v,p),g=v=>m(v,u);return u.addEventListener("pointerleave",y),p.addEventListener("pointerleave",g),()=>{u.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",g)}}},[u,p,m,d]),f.useEffect(()=>{if(i){const y=g=>{const v=g.target,w={x:g.clientX,y:g.clientY},x=u?.contains(v)||p?.contains(v),E=!Tp(w,i);x?d():E&&(d(),l())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,p,i,l,d]),b.jsx(Mi,{...e,ref:a})}),[Ep,kp]=nr(Pi,{isInside:!1}),Rp=$s("TooltipContent"),Mi=f.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...s}=e,u=or(et,r),l=wn(r),{onClose:p}=u;return f.useEffect(()=>(document.addEventListener(Di,p),()=>document.removeEventListener(Di,p)),[p]),f.useEffect(()=>{if(u.trigger){const c=d=>{d.target?.contains(u.trigger)&&p()};return window.addEventListener("scroll",c,{capture:!0}),()=>window.removeEventListener("scroll",c,{capture:!0})}},[u.trigger,p]),b.jsx(jt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:c=>c.preventDefault(),onDismiss:p,children:b.jsxs(la,{"data-state":u.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[b.jsx(Rp,{children:n}),b.jsx(Ep,{scope:r,isInside:!0,children:b.jsx(hp,{id:u.contentId,role:"tooltip",children:o||n})})]})})});xp.displayName=et;var Li="TooltipArrow",Sp=f.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=wn(r);return kp(Li,r).isInside?null:b.jsx(ca,{...o,...n,ref:t})});Sp.displayName=Li;function Cp(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(r,n,o,a)){case a:return"left";case o:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Op(e,t,r=5){const n=[];switch(t){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function jp(e){const{top:t,right:r,bottom:n,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:n},{x:o,y:n}]}function Tp(e,t){const{x:r,y:n}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const s=t[a],u=t[i],l=s.x,p=s.y,c=u.x,d=u.y;p>n!=d>n&&r<(c-l)*(n-p)/(d-p)+l&&(o=!o)}return o}function Np(e){const t=e.slice();return t.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),Dp(t)}function Dp(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const o=e[n];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const o=e[n];for(;r.length>=2;){const a=r[r.length-1],i=r[r.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}f.createContext(null);const Ap=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pp=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Ii=e=>{const t=Pp(e);return t.charAt(0).toUpperCase()+t.slice(1)},Fi=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Mp=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Lp={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ip=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:a,iconNode:i,...s},u)=>P.createElement("svg",{ref:u,...Lp,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Fi("lucide",o),...!a&&!Mp(s)&&{"aria-hidden":"true"},...s},[...i.map(([l,p])=>P.createElement(l,p)),...Array.isArray(a)?a:[a]]));const _n=(e,t)=>{const r=P.forwardRef(({className:n,...o},a)=>P.createElement(Ip,{ref:a,iconNode:t,className:Fi(`lucide-${Ap(Ii(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Ii(e),r};const Vi=_n("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const zi=_n("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const $i=_n("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function Fp(e){const[t,r]=P.useState(!1);return O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsx("h1",{children:"test local 004"}),O.jsxs(xr,{className:ue({"opacity-50":e.form.formState.isSubmitting}),children:[O.jsxs(_r,{children:[O.jsx(Er,{className:"text-2xl",children:e.loginFormTitle}),O.jsx(kr,{children:e.loginFormDescription})]}),O.jsx(Rr,{children:O.jsx(gn,{...e.form,children:O.jsx("form",{onSubmit:e.form.handleSubmit(e.submit),children:O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(ht,{htmlFor:"email",children:e.emailLabel}),O.jsx(vt,{control:e.form.control,name:"email",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{children:O.jsx(xt,{disabled:e.form.formState.isSubmitting,type:"email",placeholder:"m@example.com",required:!0,...n})})})})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsxs("div",{className:"flex items-center",children:[O.jsx(ht,{htmlFor:"password",children:e.passwordLabel}),e.resetPasswordLinkComponent?e.resetPasswordLinkComponent():null]}),O.jsx(vt,{control:e.form.control,name:"password",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{className:"relative",children:O.jsxs("div",{className:"relative",children:[t?O.jsx(Vi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!1)}}):O.jsx(zi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!0)}}),O.jsx(xt,{type:t?"text":"password",placeholder:"********",disabled:e.form.formState.isSubmitting,...n,className:"pr-10"})]})})})})]}),O.jsxs(wr,{type:"submit",className:"w-full cursor-pointer",disabled:e.form.formState.isSubmitting,children:[e.submitButtonLabel,e.form.formState.isSubmitting&&O.jsx($i,{className:"animate-spin"})]}),e.signUpLinkComponent?O.jsx(un,{className:"text-center",children:e.signUpLinkComponent()}):null]})})})})]})]})}function Vp(e){const[t,r]=P.useState(!1);return O.jsx("div",{className:"flex flex-col gap-6",children:O.jsxs(xr,{className:ue({"opacity-50":e.form.formState.isSubmitting}),children:[O.jsxs(_r,{children:[O.jsx(Er,{className:"text-2xl",children:e.signUpFormTitle}),O.jsx(kr,{children:e.signUpFormDescription})]}),O.jsx(Rr,{children:O.jsx(gn,{...e.form,children:O.jsx("form",{onSubmit:e.form.handleSubmit(e.submit),children:O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(ht,{children:e.emailLabel}),O.jsx(vt,{control:e.form.control,name:"email",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{children:O.jsx(xt,{disabled:e.form.formState.isSubmitting,type:"email",placeholder:"m@example.com",required:!0,...n})})})})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsxs("div",{className:"flex items-center",children:[O.jsx(ht,{children:e.passwordLabel}),e.resetPasswordLinkComponent?e.resetPasswordLinkComponent():null]}),O.jsx(vt,{control:e.form.control,name:"password",render:({field:n})=>O.jsx(bt,{children:O.jsx(wt,{className:"relative",children:O.jsxs("div",{className:"relative",children:[t?O.jsx(Vi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!1)}}):O.jsx(zi,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500 z-10 cursor-pointer",onClick:()=>{r(!0)}}),O.jsx(xt,{disabled:e.form.formState.isSubmitting,type:t?"text":"password",placeholder:"********",...n,className:"pr-10"})]})})})})]}),O.jsxs(wr,{type:"submit",className:"w-full cursor-pointer",disabled:e.form.formState.isSubmitting,children:[e.submitButtonLabel,e.form.formState.isSubmitting&&O.jsx($i,{className:"animate-spin"})]}),e.loginLinkComponent?O.jsx(un,{className:"text-center",children:e.loginLinkComponent()}):null]})})})})]})})}function zp(e){return O.jsx("div",{className:"flex flex-col gap-6",children:O.jsxs(xr,{children:[O.jsxs(_r,{children:[O.jsx(Er,{className:"text-2xl",children:e.activateAccountTitle}),O.jsx(kr,{children:e.activateAccountDescription})]}),O.jsx(Rr,{children:O.jsx(gn,{...e.form,children:O.jsx("form",{onSubmit:e.form.handleSubmit(e.submit),children:O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(ht,{children:e.codeLabel}),O.jsx(vt,{control:e.form.control,name:"code",render:({field:t})=>O.jsx(bt,{children:O.jsx(wt,{children:O.jsx(xt,{type:"text",placeholder:"00001234",required:!0,...t})})})})]}),O.jsx(wr,{type:"submit",className:"w-full cursor-pointer",children:e.submitButtonLabel}),e.loginLinkComponent?O.jsx(un,{className:"text-center",children:e.loginLinkComponent()}):null]})})})})]})})}const tt=new WeakMap,ar=new WeakMap,ir={current:[]};let En=!1;const sr=new Set,Wi=new Map;function Ui(e){const t=Array.from(e).sort((r,n)=>r instanceof Fe&&r.options.deps.includes(n)?1:n instanceof Fe&&n.options.deps.includes(r)?-1:0);for(const r of t){if(ir.current.includes(r))continue;ir.current.push(r),r.recompute();const n=ar.get(r);if(n)for(const o of n){const a=tt.get(o);a&&Ui(a)}}}function $p(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function Wp(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function Up(e){if(sr.add(e),!En)try{for(En=!0;sr.size>0;){const t=Array.from(sr);sr.clear();for(const r of t){const n=Wi.get(r)??r.prevState;r.prevState=n,$p(r)}for(const r of t){const n=tt.get(r);n&&(ir.current.push(r),Ui(n))}for(const r of t){const n=tt.get(r);if(n)for(const o of n)Wp(o)}}}finally{En=!1,ir.current=[],Wi.clear()}}function Bp(e){return typeof e=="function"}class kn{constructor(t,r){this.listeners=new Set,this.subscribe=n=>{var o,a;this.listeners.add(n);const i=(a=(o=this.options)==null?void 0:o.onSubscribe)==null?void 0:a.call(o,n,this);return()=>{this.listeners.delete(n),i?.()}},this.prevState=t,this.state=t,this.options=r}setState(t){var r,n,o;this.prevState=this.state,(r=this.options)!=null&&r.updateFn?this.state=this.options.updateFn(this.prevState)(t):Bp(t)?this.state=t(this.prevState):this.state=t,(o=(n=this.options)==null?void 0:n.onUpdate)==null||o.call(n),Up(this)}}class Fe{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const r=[],n=[];for(const o of this.options.deps)r.push(o.prevState),n.push(o.state);return this.lastSeenDepValues=n,{prevDepVals:r,currDepVals:n,prevVal:this.prevState??void 0}},this.recompute=()=>{var r,n;this.prevState=this.state;const{prevDepVals:o,currDepVals:a,prevVal:i}=this.getDepVals();this.state=this.options.fn({prevDepVals:o,currDepVals:a,prevVal:i}),(n=(r=this.options).onUpdate)==null||n.call(r)},this.checkIfRecalculationNeededDeeply=()=>{for(const a of this.options.deps)a instanceof Fe&&a.checkIfRecalculationNeededDeeply();let r=!1;const n=this.lastSeenDepValues,{currDepVals:o}=this.getDepVals();for(let a=0;a<o.length;a++)if(o[a]!==n[a]){r=!0;break}r&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const r of this._subscriptions)r()}),this.subscribe=r=>{var n,o;this.listeners.add(r);const a=(o=(n=this.options).onSubscribe)==null?void 0:o.call(n,r,this);return()=>{this.listeners.delete(r),a?.()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(const r of t)if(r instanceof Fe)r.registerOnGraph(),this.registerOnGraph(r.options.deps);else if(r instanceof kn){let n=tt.get(r);n||(n=new Set,tt.set(r,n)),n.add(this);let o=ar.get(this);o||(o=new Set,ar.set(this,o)),o.add(r)}}unregisterFromGraph(t=this.options.deps){for(const r of t)if(r instanceof Fe)this.unregisterFromGraph(r.options.deps);else if(r instanceof kn){const n=tt.get(r);n&&n.delete(this);const o=ar.get(this);o&&o.delete(r)}}}const Rn="Authorization",Bi=()=>({user:{id:null,email:null,roles:[],is_enabled:!1,is_email_verified:!1},sessionID:null,isAuthenticated:!1,isLoaded:!1}),Ve=new kn(Bi()),Gp=new Fe({fn:()=>!!Ve.state.user?.roles.find(e=>e.name==="admin"),deps:[Ve]});class Hp{accountStore;httpClient;constructor(t){this.httpClient=t,this.accountStore=Ve}initAuthData(){const t=localStorage.getItem("token");t&&(this.httpClient.defaults.headers.common[Rn]=t)}async load(){try{const{data:t}=await this.httpClient.get("/api/auth/account/me");Ve.setState(()=>({user:t.user,sessionID:t.session_id,isAuthenticated:!0,isLoaded:!0}))}catch{Ve.setState(t=>({...t,isLoaded:!0}))}}async login(t){const r=await this.httpClient.post("/api/auth/account/login",t),{user:n,token:o,session_id:a}=r.data;return this._initUserData({user:n,token:o,sessionID:a}),n}signup(t){return this.httpClient.post("/api/auth/account/signup",t)}async activate(t){const r=await this.httpClient.post("/api/auth/account/activate",t);this._initUserData(r.data)}logout(){Ve.setState(()=>({...Bi(),isLoaded:!0})),this._clearAuthData()}startResetPassword(t){return this.httpClient.post("/api/auth/account/start-reset-password",t)}async resetPassword(t){const r=await this.httpClient.post("/api/auth/account/reset-password",t);this._initUserData(r.data)}_initUserData({user:t,token:r,sessionID:n}){this._setAuthData(r),Ve.setState(()=>({user:t,isAuthenticated:!0,isLoaded:!0,sessionID:n}))}_setAuthData(t){localStorage.setItem("token",t),this.httpClient.defaults.headers.common[Rn]=t}_clearAuthData(){localStorage.removeItem("token"),delete this.httpClient.defaults.headers.common[Rn]}}pe.ActivateAccountForm=zp,pe.Auth=Hp,pe.LoginForm=Fp,pe.SignUpForm=Vp,pe.isAdmin=Gp,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@service_laboratory/auth",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",