@instincthub/react-ui 0.1.11 → 0.1.12

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.
@@ -331,3 +331,95 @@
331
331
  justify-content: flex-end;
332
332
  }
333
333
 
334
+ .ihub-align-items-center{
335
+ align-items: center;
336
+ }
337
+ .ihub-align-items-start {
338
+ align-items: flex-start;
339
+ }
340
+ .ihub-align-items-end {
341
+ align-items: flex-end;
342
+ }
343
+ .ihub-align-items-baseline {
344
+ align-items: baseline;
345
+ }
346
+ .ihub-align-items-stretch {
347
+ align-items: stretch;
348
+ }
349
+ .ihub-flex-column {
350
+ flex-direction: column;
351
+ }
352
+ .ihub-flex-column-reverse {
353
+ flex-direction: column-reverse;
354
+ }
355
+ .ihub-flex-row {
356
+ flex-direction: row;
357
+ }
358
+ .ihub-flex-row-reverse {
359
+ flex-direction: row-reverse;
360
+ }
361
+ .ihub-flex-wrap {
362
+ flex-wrap: wrap;
363
+ }
364
+ .ihub-flex-nowrap {
365
+ flex-wrap: nowrap;
366
+ }
367
+ .ihub-flex-wrap-reverse {
368
+ flex-wrap: wrap-reverse;
369
+ }
370
+ .ihub-flex-grow {
371
+ flex-grow: 1;
372
+ }
373
+ .ihub-flex-shrink {
374
+ flex-shrink: 1;
375
+ }
376
+ .ihub-flex-basis {
377
+ flex-basis: auto;
378
+ }
379
+ .ihub-flex-auto {
380
+ flex: 1 1 auto;
381
+ }
382
+ .ihub-flex-none {
383
+ flex: none;
384
+ }
385
+ .ihub-flex-fill {
386
+ flex: 1 1 100%;
387
+ }
388
+ .ihub-flex-1 {
389
+ flex: 1;
390
+ }
391
+ .ihub-flex-2 {
392
+ flex: 2;
393
+ }
394
+ .ihub-flex-3 {
395
+ flex: 3;
396
+ }
397
+ .ihub-flex-4 {
398
+ flex: 4;
399
+ }
400
+ .ihub-flex-5 {
401
+ flex: 5;
402
+ }
403
+ .ihub-flex-6 {
404
+ flex: 6;
405
+ }
406
+ .ihub-flex-7 {
407
+ flex: 7;
408
+ }
409
+ .ihub-flex-8 {
410
+ flex: 8;
411
+ }
412
+ .ihub-flex-9 {
413
+ flex: 9;
414
+ }
415
+ .ihub-flex-10 {
416
+ flex: 10;
417
+ }
418
+ .ihub-flex-11 {
419
+ flex: 11;
420
+ }
421
+ .ihub-flex-12 {
422
+ flex: 12;
423
+ }
424
+
425
+
@@ -12,3 +12,4 @@
12
12
  @import url("./radio-button.css");
13
13
  @import url("./time-picker.css");
14
14
  @import url("./datetime-picker.css");
15
+ @import url("./icon-btn.css");
@@ -0,0 +1,60 @@
1
+ /* Action buttons */
2
+ .ihub-action-controls {
3
+ display: flex;
4
+ gap: 0.5rem;
5
+ align-items: center;
6
+ }
7
+
8
+ .ihub-action-buttons {
9
+ display: flex;
10
+ gap: 0.25rem;
11
+ }
12
+
13
+ .ihub-icon-btn {
14
+ padding: 0.25rem;
15
+ border: none;
16
+ background: transparent;
17
+ cursor: pointer;
18
+ border-radius: 4px;
19
+ transition: all 0.2s;
20
+ }
21
+
22
+ .ihub-icon-btn:hover {
23
+ opacity: 0.8;
24
+ }
25
+
26
+ .ihub-icon-btn-info {
27
+ color: #0fabbc;
28
+ }
29
+
30
+ .ihub-icon-btn-info:hover {
31
+ background: #0fabbc;
32
+ color: white;
33
+ }
34
+
35
+ .ihub-icon-btn-primary {
36
+ color: #00838f;
37
+ }
38
+
39
+ .ihub-icon-btn-primary:hover {
40
+ background: #00838f;
41
+ color: white;
42
+ }
43
+
44
+ .ihub-icon-btn-secondary {
45
+ color: #009ba2;
46
+ }
47
+
48
+ .ihub-icon-btn-secondary:hover {
49
+ background: #009ba2;
50
+ color: white;
51
+ }
52
+
53
+ .ihub-icon-btn-danger {
54
+ color: #ea5f5e;
55
+ }
56
+
57
+ .ihub-icon-btn-danger:hover {
58
+ background: #ea5f5e;
59
+ color: white;
60
+ }
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,typeof as t,asyncToGenerator as r,regeneratorRuntime as n,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as i,jsxs as o,Fragment as u}from"react/jsx-runtime";import{useState as s,useRef as l,useCallback as c,useEffect as d,useMemo as m}from"react";import{signOut as h,signIn as b}from"../../../node_modules/next-auth/react.js";import{useRouter as f}from"next/navigation";import{getData as v}from"../lib/auth/dbRequestst.js";import{getCookie as p,setCookie as k,handleResendOTP as g,reqOptions as w}from"../lib/helpFunction.js";import{openConfirmModal as y,openToast as x}from"../lib/modals/modals.js";import"../lib/utils.js";import N from"../forms/PasswordField.js";import C from"../forms/InputText.js";import T from"../ui/OrDivider.js";import S from"./FromInstinctHub.js";import P from"../forms/SubmitButton.js";var A=function(e){return e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").trim()};function j(t,r){var n=s(t),a=e(n,2),i=a[0],o=a[1];return d((function(){var e=setTimeout((function(){o(t)}),r);return function(){clearTimeout(e)}}),[t,r]),i}var L="loginForm_preservedData",R=function(){try{localStorage.removeItem(L)}catch(e){console.warn("Failed to clear form data:",e)}},O=function(){return o("div",{className:"ihub-loading-skeleton",children:[i("div",{className:"ihub-skeleton-line ihub-skeleton-title"}),i("div",{className:"ihub-skeleton-line ihub-skeleton-input"}),i("div",{className:"ihub-skeleton-line ihub-skeleton-input"}),i("div",{className:"ihub-skeleton-line ihub-skeleton-button"})]})},E=function(E){var F=E.session;E.params;var I=E.searchParams,U=E.endpointPath,M=E.verificationPath,V=E.redirectPath,q=E.hideResetPassword,D=void 0!==q&&q,_=E.hideSignup,H=void 0!==_&&_,Y=E.type,B=E.channelUsername,W=void 0===B?"skills":B,J=E.isLoading,X=void 0!==J&&J,z=E.onSubmitStart,G=E.onSubmitComplete,K=E.loadingText,Z=void 0===K?"Loading...":K,$=E.preserveFormData,Q=void 0!==$&&$,ee=E.onSuccessRedirect,te=E.onFailureRedirect,re=E.customValidationHandler,ne=E.autoRedirectOnSession,ae=void 0===ne||ne,ie=E.title,oe=void 0===ie?"Login Form":ie,ue=E.subtitle,se=E.showTitle,le=void 0===se||se,ce=E.className,de=E.formClassName,me=E.enableClientValidation,he=void 0!==me&&me,be=E.customValidationRules,fe=E.onError,ve=E.sessionCheckInterval,pe=void 0===ve?3e4:ve,ke=E.clearCallbackAfterUse,ge=void 0===ke||ke,we=E.submitButtonText,ye=void 0===we?"Login":we,xe=E.submitButtonVariant,Ne=void 0===xe?"primary":xe,Ce=E.showRememberMe,Te=void 0!==Ce&&Ce,Se=E.rememberMeText,Pe=void 0===Se?"Remember me":Se,Ae=E.enableOAuth,je=void 0!==Ae&&Ae,Le=E.oauthProviders,Re=void 0===Le?[]:Le,Oe=E.oauthConfig,Ee=void 0===Oe?{}:Oe,Fe=E.enableCaptcha,Ie=void 0!==Fe&&Fe;E.captchaProvider;var Ue=E.enableRateLimiting,Me=void 0!==Ue&&Ue,Ve=E.maxAttempts,qe=void 0===Ve?5:Ve,De=E.lockoutDuration,_e=void 0===De?3e5:De,He=E.trackingEnabled,Ye=void 0!==He&&He,Be=E.onLoginAttempt,We=E.onLoginSuccess,Je=E.onLoginFailure,Xe=E.ariaLabel,ze=E.ariaDescribedBy,Ge=E.focusOnMount,Ke=void 0!==Ge&&Ge;E.autoComplete;var Ze=E.validateOnBlur,$e=void 0!==Ze&&Ze,Qe=E.debounceValidation,et=void 0===Qe?300:Qe,tt=E.showPasswordStrength,rt=void 0!==tt&&tt,nt=E.enableFormReset,at=void 0!==nt&&nt,it=E.autoSave,ot=void 0!==it&&it,ut=E.autoSaveInterval,st=void 0===ut?5e3:ut,lt=E.offlineSupport,ct=void 0!==lt&&lt,dt=E.retryAttempts,mt=void 0===dt?3:dt,ht=E.retryDelay,bt=void 0===ht?1e3:ht,ft=E.sessionTimeoutWarning,vt=void 0!==ft&&ft,pt=E.sessionTimeoutDuration,kt=void 0===pt?18e5:pt,gt=E.csrfToken,wt=E.sanitizeInputs,yt=void 0===wt||wt,xt=E.highContrastMode,Nt=void 0!==xt&&xt,Ct=E.showLoadingSkeleton,Tt=void 0!==Ct&&Ct,St=E.preventMultipleSubmissions,Pt=void 0===St||St,At=f(),jt=I.error,Lt=I.callbackUrl,Rt=Lt?decodeURIComponent(Lt):void 0,Ot=s(""),Et=e(Ot,2),Ft=Et[0],It=Et[1],Ut=s(1),Mt=e(Ut,2),Vt=Mt[0],qt=Mt[1],Dt=s(""),_t=e(Dt,2),Ht=_t[0],Yt=_t[1],Bt=s(""),Wt=e(Bt,2),Jt=Wt[0],Xt=Wt[1],zt=s(!1),Gt=e(zt,2),Kt=Gt[0],Zt=Gt[1],$t=s(!1),Qt=e($t,2),er=Qt[0],tr=Qt[1],rr=s(0),nr=e(rr,2),ar=nr[0],ir=nr[1],or=s(!1),ur=e(or,2),sr=ur[0],lr=ur[1],cr=s({}),dr=e(cr,2),mr=dr[0],hr=dr[1],br=s(!1),fr=e(br,2),vr=fr[0],pr=fr[1],kr=s({score:0,feedback:[]}),gr=e(kr,2),wr=gr[0],yr=gr[1],xr=s(!1),Nr=e(xr,2),Cr=Nr[0],Tr=Nr[1],Sr=s(!1),Pr=e(Sr,2),Ar=Pr[0],jr=Pr[1],Lr=s(!1),Rr=e(Lr,2),Or=Rr[0],Er=Rr[1],Fr=s(""),Ir=e(Fr,2),Ur=Ir[0],Mr=Ir[1],Vr=s((function(){return Math.random().toString(36).substr(2,9)})),qr=e(Vr,1)[0],Dr=l(null),_r=l(null),Hr=l(null),Yr=l(null),Br=l(null),Wr=l(!0),Jr=l(null),Xr=l(0),zr=F,Gr=j(Ht,et),Kr=j(Jt,et),Zr=X||Kt||Cr,$r=c((function(){Dr.current&&Dr.current.abort(),[_r,Hr,Yr,Br].forEach((function(e){e.current&&clearTimeout(e.current)}))}),[]);d((function(){if(Q){var e=function(){try{var e=localStorage.getItem(L);return e?JSON.parse(e):null}catch(e){return console.warn("Failed to load form data:",e),null}}();e&&(Yt(e.username),tr(e.rememberMe))}}),[Q]),d((function(){if(ot&&Or)return Yr.current=setTimeout((function(){Q&&function(e){try{localStorage.setItem(L,JSON.stringify(e))}catch(e){console.warn("Failed to save form data:",e)}}({username:Ht,rememberMe:er})}),st),function(){Yr.current&&clearTimeout(Yr.current)}}),[ot,st,Ht,er,Or,Q]),d((function(){if(ct){var e=function(){return pr(!1)},t=function(){return pr(!0)};return window.addEventListener("online",e),window.addEventListener("offline",t),pr(!navigator.onLine),function(){window.removeEventListener("online",e),window.removeEventListener("offline",t)}}}),[ct]);var Qr=m((function(){return function(e){return e&&"object"===t(e)&&"token"in e}(zr)?zr:null}),[zr]),en=m((function(){var e,r,n,a,i;return{handle:"object"===t(null==Qr?void 0:Qr.channels)?null==Qr||null===(e=Qr.channels)||void 0===e||null===(e=e.active)||void 0===e?void 0:e.username:"",token:null==Qr?void 0:Qr.accessToken,uuid:null==Qr||null===(r=Qr.user)||void 0===r?void 0:r.uuid,email:(null==Qr||null===(n=Qr.user)||void 0===n?void 0:n.email)||(null==Qr||null===(a=Qr.user)||void 0===a?void 0:a.email),verifyEmail:null==Qr||null===(i=Qr.user)||void 0===i?void 0:i.emailVerified}}),[Qr,F]),tn=en.handle,rn=en.token,nn=en.uuid,an=en.email,on=en.verifyEmail;d((function(){if(vt&&rn&&!Ar)return Br.current=setTimeout((function(){Wr.current&&y("Your session will expire in 5 minutes. Do you want to extend it?").then((function(e){jr(!0)}))}),kt-3e5),function(){Br.current&&clearTimeout(Br.current)}}),[vt,kt,rn,Ar]),d((function(){rt&&Jt&&yr(function(e){var t={score:0,feedback:[]};return e.length>=8?t.score+=1:t.feedback.push("At least 8 characters"),/[A-Z]/.test(e)?t.score+=1:t.feedback.push("Include uppercase letter"),/[a-z]/.test(e)?t.score+=1:t.feedback.push("Include lowercase letter"),/\d/.test(e)?t.score+=1:t.feedback.push("Include number"),/[!@#$%^&*(),.?":{}|<>]/.test(e)?t.score+=1:t.feedback.push("Include special character"),t}(Jt))}),[Jt,rt]);var un=c((function(){if(!he)return!0;var e={},t=yt?A(Ht):Ht,r=yt?A(Jt):Jt;if(null!=be&&be.username){var n=be.username(t);n&&(e.username=n)}else t.trim()?t.length<3&&(e.username="Username must be at least 3 characters"):e.username="Username is required";if(null!=be&&be.password){var a=be.password(r);a&&(e.password=a)}else r.trim()?r.length<6&&(e.password="Password must be at least 6 characters"):e.password="Password is required";if(hr(e),Object.keys(e).length>0){var i=Object.values(e).join(". "),o=document.createElement("div");o.setAttribute("aria-live","polite"),o.setAttribute("aria-atomic","true"),o.style.position="absolute",o.style.left="-10000px",o.textContent="Form validation errors: ".concat(i),document.body.appendChild(o),setTimeout((function(){document.body.contains(o)&&document.body.removeChild(o)}),1e3)}return 0===Object.keys(e).length}),[he,be,Ht,Jt,yt]);d((function(){$e&&Or&&he&&un()}),[Gr,Kr,$e,Or,he,un]);var sn=c((function(){return!Me||(!(ar>=qe)||(lr(!0),_r.current=setTimeout((function(){Wr.current&&(lr(!1),ir(0))}),_e),!1))}),[Me,ar,qe,_e]),ln=c(function(){var e=r(n().mark((function e(t){var r,a,i;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n().mark((function e(r){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t();case 3:return e.t0=e.sent,e.abrupt("return",{v:e.t0});case 7:if(e.prev=7,e.t1=e.catch(0),r!==mt&&"AbortError"!==e.t1.name){e.next=11;break}throw e.t1;case 11:return e.next=13,new Promise((function(e){return setTimeout(e,bt*Math.pow(2,r))}));case 13:case"end":return e.stop()}}),e,null,[[0,7]])})),i=0;case 2:if(!(i<=mt)){e.next=10;break}return e.delegateYield(r(i),"t0",4);case 4:if(!(a=e.t0)){e.next=7;break}return e.abrupt("return",a.v);case 7:i++,e.next=2;break;case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[mt,bt]),cn=c(function(){var e=r(n().mark((function e(t){var i,o,u,s,l,c,d,m,h,f,v,p,g;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),!Pt||!Cr){e.next=3;break}return e.abrupt("return");case 3:if(Er(!0),un()){e.next=7;break}return null==fe||fe("Validation failed","validation"),e.abrupt("return");case 7:if(!ct||!vr){e.next=11;break}return It("You are offline. Please check your connection and try again."),null==fe||fe("Offline","network"),e.abrupt("return");case 11:if(sn()){e.next=16;break}return o="Too many attempts. Please wait ".concat(Math.ceil(_e/6e4)," minutes."),It(o),null==fe||fe(o,"auth"),e.abrupt("return");case 16:if(!Ie||Ur){e.next=20;break}return It("Please complete the CAPTCHA verification."),null==fe||fe("CAPTCHA required","validation"),e.abrupt("return");case 20:return $r(),Dr.current=new AbortController,qt(0),It(""),Zt(!0),Tr(!0),hr({}),Xr.current=0,null==z||z(),Ye&&(null==Be||Be(Ht)),Me&&ir((function(e){return e+1})),u=yt?A(Ht):Ht,s=yt?A(Jt):Jt,l={username:u,password:s,provider:"credentials",channel:W,formId:qr},Te&&(l.rememberMe=er),gt&&(l._token=gt),Ie&&Ur&&(l.captchaToken=Ur),(c=w("POST",JSON.stringify(l),null,"json")).signal=null===(i=Dr.current)||void 0===i?void 0:i.signal,c.headers=a(a({},c.headers),{},{"X-Requested-With":"XMLHttpRequest","X-Form-ID":qr}),gt&&(c.headers["X-CSRF-Token"]=gt),d=function(){var e=r(n().mark((function e(){var t;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(U||"/api/auth/login",c);case 2:return t=e.sent,e.t0=t,e.next=6,t.json();case 6:return e.t1=e.sent,e.abrupt("return",{req:e.t0,res:e.t1});case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),e.prev=42,e.next=45,ln(d);case 45:if(m=e.sent,h=m.req,f=m.res,200!==h.status&&!h.ok){e.next=60;break}return v={username:JSON.stringify(f),password:"instincthub",redirect:!1},Rt&&(v.callbackUrl=Rt,k("callbackUrl",Rt,30)),null==G||G(!0),Ye&&(null==We||We(f)),Me&&ir(0),Q||R(),e.next=57,b("credentials",v);case 57:qt(1),e.next=66;break;case 60:p=f.message||f.detail||"An error occurred",It(p),qt(f.status),null==fe||fe(p,"auth"),null==G||G(!1),Ye&&(null==Je||Je(p,Ht));case 66:e.next=78;break;case 68:if(e.prev=68,e.t0=e.catch(42),"AbortError"!==e.t0.name){e.next=72;break}return e.abrupt("return");case 72:x(g="Couldn't login. Please try again.",400),qt(3),null==fe||fe(g,"network"),null==G||G(!1),Ye&&(null==Je||Je(g,Ht));case 78:return e.prev=78,Wr.current&&(Zt(!1),Tr(!1)),e.finish(78);case 81:case"end":return e.stop()}}),e,null,[[42,68,78,81]])})));return function(t){return e.apply(this,arguments)}}(),[Ht,Jt,W,Rt,U,un,sn,$r,z,Be,G,We,fe,Je,Me,Te,er,yt,gt,Ie,Ur,qr,Pt,Cr,ct,vr,ln,Q,Ye]),dn=c((function(){at&&(Yt(""),Xt(""),tr(!1),It(""),hr({}),yr({score:0,feedback:[]}),Er(!1),Q&&R(),setTimeout((function(){var e,t=null===(e=Jr.current)||void 0===e?void 0:e.querySelector('input[name="username"]');t&&t.focus()}),100))}),[at,Q]),mn=c((function(e,t){if(ee)ee(e,t);else{var r=p("callbackUrl"),n=t||r;if(n)ge&&k("callbackUrl","",-1),At.push(n);else if(V)At.push(V);else if("skills"===Y)At.push("/library");else if("lms"===Y)if(tn){var a="You are currently logged in with ".concat(tn," channel. Would you like to proceed to the dashboard?");y(a).then((function(e){e&&At.push("/".concat(tn))}))}else{y("You do not have an active channel for this account. Would you like to create one?").then((function(e){e?At.push("/auth/create-channel"):h()}))}else At.push("/")}}),[ee,ge,V,Y,tn,At]),hn=c(r(n().mark((function e(){var t,r,a;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rn&&Qr){e.next=2;break}return e.abrupt("return");case 2:if(!re){e.next=17;break}return e.prev=3,e.next=6,re(Qr);case 6:if(e.sent){e.next=10;break}return null==te||te("Custom validation failed"),e.abrupt("return");case 10:e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(3),console.error("Custom validation error:",e.t0),null==te||te("Validation error occurred"),e.abrupt("return");case 17:return $r(),Dr.current=new AbortController,e.prev=19,t={path:"auth/skills/validate-user-token/?access_token=".concat(rn,"&user_uuid=").concat(nn),token:rn},e.next=23,v(t);case 23:if("Unauthorized"!==(null==(r=e.sent)?void 0:r.detail)&&"Not found."!==(null==r?void 0:r.detail)){e.next=30;break}return x("Couldn't login. Please try again.",400),null==te||te("Token validation failed"),e.abrupt("return");case 30:!1===on?(a="".concat(M||"/auth/verify-email","?email=").concat(an),y("You need to verify your email address, click okay to request for a one time password (OTP).").then((function(e){e&&an?(g(an),At.push(a)):h()}))):mn(Qr,Rt);case 31:e.next=40;break;case 33:if(e.prev=33,e.t1=e.catch(19),"AbortError"!==e.t1.name){e.next=37;break}return e.abrupt("return");case 37:console.error("Validation error:",e.t1),x("Validation failed. Please try again.",400),null==te||te("Network error during validation");case 40:case"end":return e.stop()}}),e,null,[[3,12],[19,33]])}))),[rn,nn,Qr,re,te,$r,M,an,on,mn,Rt,At]),bn=c((function(e){Er(!0);var t=e.target.value;Yt(t),mr.username&&hr((function(e){return a(a({},e),{},{username:void 0})}))}),[mr.username]),fn=c((function(e){Er(!0);var t=e.target.value;Xt(t),mr.password&&hr((function(e){return a(a({},e),{},{password:void 0})}))}),[mr.password]);c((function(e){$e&&he&&setTimeout((function(){return un()}),100)}),[$e,he,un]);var vn=c((function(e){var t=Ee[e]||{},r=a({callbackUrl:Rt},t);Ye&&(null==Be||Be("oauth_".concat(e))),b(e,r)}),[Ee,Rt,Ye,Be]);return d((function(){Rt&&k("callbackUrl",Rt,30)}),[Rt]),d((function(){if(ae&&!Zr&&F)if(Qr&&rn)re||nn?hn():mn(Qr,Rt);else if(null!=F&&F.user){var e={name:F.user};mn(e,Rt)}}),[F,Qr,rn,nn,ae,Zr,re,hn,mn,Rt]),d((function(){if(pe>0&&rn){var e=function(){Hr.current=setTimeout((function(){Wr.current&&rn&&(hn(),e())}),pe)};return e(),function(){Hr.current&&clearTimeout(Hr.current)}}}),[pe,rn,hn]),d((function(){if(Ke){var e=document.querySelector('input[name="username"]');e&&e.focus()}}),[Ke]),d((function(){return function(){Wr.current=!1,$r()}}),[$r]),d((function(){return Nt?document.body.classList.add("ihub-high-contrast"):document.body.classList.remove("ihub-high-contrast"),function(){document.body.classList.remove("ihub-high-contrast")}}),[Nt]),i("div",Tt&&Zr?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:i(O,{})}:Zr&&Tt?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:i("div",{className:"ihub-loading-state",children:i("p",{children:Z})})}:sr?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:o("div",{className:"ihub-error-state",children:[o("p",{children:["Too many login attempts. Please wait"," ",Math.ceil(_e/6e4)," minutes before trying again."]}),at&&i("button",{onClick:dn,className:"ihub-reset-btn ihub-mt-3",type:"button",children:"Reset Form"})]})}:ct&&vr?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:o("div",{className:"ihub-offline-state",children:[i("p",{children:"You are currently offline. Please check your internet connection and try again."}),i("button",{onClick:function(){return window.location.reload()},className:"ihub-retry-btn ihub-mt-3",type:"button",children:"Retry"})]})}:{className:"".concat(ce||""," ").concat(Nt?"ihub-high-contrast":""),children:o("form",{ref:Jr,onSubmit:cn,className:"ihub-max-w-500 ihub-mx-auto ".concat(de||""),"aria-label":Xe||"Login form","aria-describedby":ze,noValidate:he,children:[le&&o(u,{children:[i("h1",{className:"ihub-fs-32",children:oe}),ue&&i("p",{className:"ihub-subtitle",children:ue})]}),jt&&i("div",{className:"err",role:"alert","aria-live":"polite",children:"Sign in failed. Check the details you provided are correct."}),i(C,{name:"username",type:"text",label:"Email or Username",required:!0,textTransform:"lowercase",value:Ht,onChange:bn}),mr.username&&i("p",{className:"err",id:"username-error",role:"alert",children:mr.username}),i(N,{name:"password",label:"Password",required:!0,id:"password",value:Jt,onChange:fn}),mr.password&&i("p",{className:"err",id:"password-error",role:"alert",children:mr.password}),rt&&Jt&&o("div",{className:"ihub-password-strength ihub-mt-2",id:"password-strength",children:[i("div",{className:"ihub-strength-meter",children:i("div",{className:"ihub-strength-bar ihub-strength-".concat(wr.score),style:{width:"".concat(wr.score/5*100,"%")}})}),o("p",{className:"ihub-strength-text",children:["Password strength:"," ",["Very Weak","Weak","Fair","Good","Strong"][wr.score]]}),wr.feedback.length>0&&i("ul",{className:"ihub-strength-feedback",children:wr.feedback.map((function(e,t){return i("li",{children:e},t)}))})]}),Te&&o("div",{className:"ihub-remember-me ihub-mt-3",children:[o("label",{className:"ihub-checkbox-label",children:[i("input",{type:"checkbox",checked:er,onChange:function(e){tr(e.target.checked),Er(!0)},"aria-describedby":"remember-me-help"}),Pe]}),i("small",{id:"remember-me-help",className:"ihub-help-text",children:"Keep me signed in on this device"})]}),Ie&&i("div",{className:"ihub-captcha ihub-mt-3",children:o("div",{className:"ihub-captcha-placeholder",children:[i("p",{children:"CAPTCHA verification would be loaded here"}),i("button",{type:"button",onClick:function(){return Mr("mock-captcha-token")},className:"ihub-verify-btn",children:"Verify (Mock)"})]})}),Ft&&i("div",{className:"err",role:"alert","aria-live":"polite",children:Ft}),o("div",{className:"action ihub-mt-4 ihub-mb-5",children:[i(P,{label:ye,type:"submit",status:Vt,disabled:Zr||sr||Pt&&Cr,variant:Ne}),at&&i("button",{type:"button",onClick:dn,className:"ihub-reset-btn ihub-ml-3",disabled:Zr,children:"Reset"}),(!D||!H||je)&&i(T,{labels:"or sign with"}),je&&Re.length>0&&i("div",{className:"ihub-oauth-buttons ihub-mt-3",role:"group","aria-label":"Social login options",children:Re.map((function(e){return o("button",{type:"button",className:"ihub-oauth-btn ihub-oauth-".concat(e),onClick:function(){return vn(e)},disabled:Zr,"aria-label":"Continue with ".concat(e),children:["Continue with"," ",e.charAt(0).toUpperCase()+e.slice(1)]},e)}))}),!D&&o("p",{className:"ihub-text-center ihub-fs-14",children:["Can't remember password?"," ",i("a",{href:"/auth/reset-password",children:"Reset Password"})]}),!H&&o("p",{className:"ihub-text-center ihub-fs-14",children:["New user? ",i("a",{href:"/auth/signup",children:"Create an account."})]})]}),i(S,{showText:!0}),"development"===process.env.NODE_ENV&&o("details",{className:"ihub-dev-info ihub-mt-4",children:[i("summary",{children:"Development Info"}),i("pre",{className:"ihub-dev-details",children:JSON.stringify({formTouched:Or,isOffline:ct?vr:"disabled",passwordStrength:rt?wr:"disabled",attemptCount:Me?ar:"disabled",validationErrors:mr,formId:qr},null,2)})]})]})})};export{E as default};
1
+ import{slicedToArray as e,typeof as t,asyncToGenerator as r,regeneratorRuntime as n,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as i,jsxs as o,Fragment as u}from"react/jsx-runtime";import{useState as s,useRef as l,useCallback as c,useEffect as d,useMemo as m}from"react";import{signOut as h,signIn as b}from"../../../node_modules/next-auth/react.js";import{useRouter as f}from"next/navigation";import{getData as v}from"../lib/auth/dbRequestst.js";import{getCookie as p,setCookie as k,handleResendOTP as g,reqOptions as w}from"../lib/helpFunction.js";import{openConfirmModal as y,openToast as x}from"../lib/modals/modals.js";import"../lib/utils.js";import N from"../forms/PasswordField.js";import C from"../forms/InputText.js";import T from"../ui/OrDivider.js";import S from"./FromInstinctHub.js";import P from"../forms/SubmitButton.js";var A=function(e){return e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").trim()};function j(t,r){var n=s(t),a=e(n,2),i=a[0],o=a[1];return d((function(){var e=setTimeout((function(){o(t)}),r);return function(){clearTimeout(e)}}),[t,r]),i}var L="loginForm_preservedData",R=function(){try{localStorage.removeItem(L)}catch(e){console.warn("Failed to clear form data:",e)}},O=function(){return o("div",{className:"ihub-loading-skeleton",children:[i("div",{className:"ihub-skeleton-line ihub-skeleton-title"}),i("div",{className:"ihub-skeleton-line ihub-skeleton-input"}),i("div",{className:"ihub-skeleton-line ihub-skeleton-input"}),i("div",{className:"ihub-skeleton-line ihub-skeleton-button"})]})},E=function(E){var F=E.session;E.params;var I=E.searchParams,U=E.endpointPath,M=E.verificationPath,V=E.redirectPath,q=E.hideResetPassword,D=void 0!==q&&q,_=E.hideSignup,H=void 0!==_&&_,Y=E.type,B=E.channelUsername,W=void 0===B?"skills":B,J=E.isLoading,X=void 0!==J&&J,z=E.onSubmitStart,G=E.onSubmitComplete,K=E.loadingText,Z=void 0===K?"Loading...":K,$=E.preserveFormData,Q=void 0!==$&&$,ee=E.onSuccessRedirect,te=E.onFailureRedirect,re=E.customValidationHandler,ne=E.autoRedirectOnSession,ae=void 0===ne||ne,ie=E.title,oe=void 0===ie?"Login Form":ie,ue=E.subtitle,se=E.showTitle,le=void 0===se||se,ce=E.className,de=E.formClassName,me=E.enableClientValidation,he=void 0!==me&&me,be=E.customValidationRules,fe=E.onError,ve=E.sessionCheckInterval,pe=void 0===ve?3e4:ve,ke=E.clearCallbackAfterUse,ge=void 0===ke||ke,we=E.submitButtonText,ye=void 0===we?"Login":we,xe=E.submitButtonVariant,Ne=void 0===xe?"primary":xe,Ce=E.showRememberMe,Te=void 0!==Ce&&Ce,Se=E.rememberMeText,Pe=void 0===Se?"Remember me":Se,Ae=E.enableOAuth,je=void 0!==Ae&&Ae,Le=E.oauthProviders,Re=void 0===Le?[]:Le,Oe=E.oauthConfig,Ee=void 0===Oe?{}:Oe,Fe=E.enableCaptcha,Ie=void 0!==Fe&&Fe;E.captchaProvider;var Ue=E.enableRateLimiting,Me=void 0!==Ue&&Ue,Ve=E.maxAttempts,qe=void 0===Ve?5:Ve,De=E.lockoutDuration,_e=void 0===De?3e5:De,He=E.trackingEnabled,Ye=void 0!==He&&He,Be=E.onLoginAttempt,We=E.onLoginSuccess,Je=E.onLoginFailure,Xe=E.ariaLabel,ze=E.ariaDescribedBy,Ge=E.focusOnMount,Ke=void 0!==Ge&&Ge;E.autoComplete;var Ze=E.validateOnBlur,$e=void 0!==Ze&&Ze,Qe=E.debounceValidation,et=void 0===Qe?300:Qe,tt=E.showPasswordStrength,rt=void 0!==tt&&tt,nt=E.enableFormReset,at=void 0!==nt&&nt,it=E.autoSave,ot=void 0!==it&&it,ut=E.autoSaveInterval,st=void 0===ut?5e3:ut,lt=E.offlineSupport,ct=void 0!==lt&&lt,dt=E.retryAttempts,mt=void 0===dt?3:dt,ht=E.retryDelay,bt=void 0===ht?1e3:ht,ft=E.sessionTimeoutWarning,vt=void 0!==ft&&ft,pt=E.sessionTimeoutDuration,kt=void 0===pt?18e5:pt,gt=E.csrfToken,wt=E.sanitizeInputs,yt=void 0===wt||wt,xt=E.highContrastMode,Nt=void 0!==xt&&xt,Ct=E.showLoadingSkeleton,Tt=void 0!==Ct&&Ct,St=E.preventMultipleSubmissions,Pt=void 0===St||St,At=f(),jt=I.error,Lt=I.callbackUrl,Rt=Lt?decodeURIComponent(Lt):void 0,Ot=s(""),Et=e(Ot,2),Ft=Et[0],It=Et[1],Ut=s(1),Mt=e(Ut,2),Vt=Mt[0],qt=Mt[1],Dt=s(""),_t=e(Dt,2),Ht=_t[0],Yt=_t[1],Bt=s(""),Wt=e(Bt,2),Jt=Wt[0],Xt=Wt[1],zt=s(!1),Gt=e(zt,2),Kt=Gt[0],Zt=Gt[1],$t=s(!1),Qt=e($t,2),er=Qt[0],tr=Qt[1],rr=s(0),nr=e(rr,2),ar=nr[0],ir=nr[1],or=s(!1),ur=e(or,2),sr=ur[0],lr=ur[1],cr=s({}),dr=e(cr,2),mr=dr[0],hr=dr[1],br=s(!1),fr=e(br,2),vr=fr[0],pr=fr[1],kr=s({score:0,feedback:[]}),gr=e(kr,2),wr=gr[0],yr=gr[1],xr=s(!1),Nr=e(xr,2),Cr=Nr[0],Tr=Nr[1],Sr=s(!1),Pr=e(Sr,2),Ar=Pr[0],jr=Pr[1],Lr=s(!1),Rr=e(Lr,2),Or=Rr[0],Er=Rr[1],Fr=s(""),Ir=e(Fr,2),Ur=Ir[0],Mr=Ir[1],Vr=s((function(){return Math.random().toString(36).substr(2,9)})),qr=e(Vr,1)[0],Dr=l(null),_r=l(null),Hr=l(null),Yr=l(null),Br=l(null),Wr=l(!0),Jr=l(null),Xr=l(0),zr=F,Gr=j(Ht,et),Kr=j(Jt,et),Zr=X||Kt||Cr,$r=c((function(){Dr.current&&Dr.current.abort(),[_r,Hr,Yr,Br].forEach((function(e){e.current&&clearTimeout(e.current)}))}),[]);d((function(){if(Q){var e=function(){try{var e=localStorage.getItem(L);return e?JSON.parse(e):null}catch(e){return console.warn("Failed to load form data:",e),null}}();e&&(Yt(e.username),tr(e.rememberMe))}}),[Q]),d((function(){if(ot&&Or)return Yr.current=setTimeout((function(){Q&&function(e){try{localStorage.setItem(L,JSON.stringify(e))}catch(e){console.warn("Failed to save form data:",e)}}({username:Ht,rememberMe:er})}),st),function(){Yr.current&&clearTimeout(Yr.current)}}),[ot,st,Ht,er,Or,Q]),d((function(){if(ct){var e=function(){return pr(!1)},t=function(){return pr(!0)};return window.addEventListener("online",e),window.addEventListener("offline",t),pr(!navigator.onLine),function(){window.removeEventListener("online",e),window.removeEventListener("offline",t)}}}),[ct]);var Qr=m((function(){return function(e){return e&&"object"===t(e)&&"token"in e}(zr)?zr:null}),[zr]),en=m((function(){var e,r,n,a,i;return{handle:"object"===t(null==Qr?void 0:Qr.channels)?null==Qr||null===(e=Qr.channels)||void 0===e||null===(e=e.active)||void 0===e?void 0:e.username:"",token:null==Qr?void 0:Qr.accessToken,uuid:null==Qr||null===(r=Qr.user)||void 0===r?void 0:r.uuid,email:(null==Qr||null===(n=Qr.user)||void 0===n?void 0:n.email)||(null==Qr||null===(a=Qr.user)||void 0===a?void 0:a.email),verifyEmail:null==Qr||null===(i=Qr.user)||void 0===i?void 0:i.emailVerified}}),[Qr,F]),tn=en.handle,rn=en.token,nn=en.uuid,an=en.email,on=en.verifyEmail;d((function(){if(vt&&rn&&!Ar)return Br.current=setTimeout((function(){Wr.current&&y("Your session will expire in 5 minutes. Do you want to extend it?").then((function(e){jr(!0)}))}),kt-3e5),function(){Br.current&&clearTimeout(Br.current)}}),[vt,kt,rn,Ar]),d((function(){rt&&Jt&&yr(function(e){var t={score:0,feedback:[]};return e.length>=8?t.score+=1:t.feedback.push("At least 8 characters"),/[A-Z]/.test(e)?t.score+=1:t.feedback.push("Include uppercase letter"),/[a-z]/.test(e)?t.score+=1:t.feedback.push("Include lowercase letter"),/\d/.test(e)?t.score+=1:t.feedback.push("Include number"),/[!@#$%^&*(),.?":{}|<>]/.test(e)?t.score+=1:t.feedback.push("Include special character"),t}(Jt))}),[Jt,rt]);var un=c((function(){if(!he)return!0;var e={},t=yt?A(Ht):Ht,r=yt?A(Jt):Jt;if(null!=be&&be.username){var n=be.username(t);n&&(e.username=n)}else t.trim()?t.length<3&&(e.username="Username must be at least 3 characters"):e.username="Username is required";if(null!=be&&be.password){var a=be.password(r);a&&(e.password=a)}else r.trim()?r.length<6&&(e.password="Password must be at least 6 characters"):e.password="Password is required";if(hr(e),Object.keys(e).length>0){var i=Object.values(e).join(". "),o=document.createElement("div");o.setAttribute("aria-live","polite"),o.setAttribute("aria-atomic","true"),o.style.position="absolute",o.style.left="-10000px",o.textContent="Form validation errors: ".concat(i),document.body.appendChild(o),setTimeout((function(){document.body.contains(o)&&document.body.removeChild(o)}),1e3)}return 0===Object.keys(e).length}),[he,be,Ht,Jt,yt]);d((function(){$e&&Or&&he&&un()}),[Gr,Kr,$e,Or,he,un]);var sn=c((function(){return!Me||(!(ar>=qe)||(lr(!0),_r.current=setTimeout((function(){Wr.current&&(lr(!1),ir(0))}),_e),!1))}),[Me,ar,qe,_e]),ln=c(function(){var e=r(n().mark((function e(t){var r,a,i;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n().mark((function e(r){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t();case 3:return e.t0=e.sent,e.abrupt("return",{v:e.t0});case 7:if(e.prev=7,e.t1=e.catch(0),r!==mt&&"AbortError"!==e.t1.name){e.next=11;break}throw e.t1;case 11:return e.next=13,new Promise((function(e){return setTimeout(e,bt*Math.pow(2,r))}));case 13:case"end":return e.stop()}}),e,null,[[0,7]])})),i=0;case 2:if(!(i<=mt)){e.next=10;break}return e.delegateYield(r(i),"t0",4);case 4:if(!(a=e.t0)){e.next=7;break}return e.abrupt("return",a.v);case 7:i++,e.next=2;break;case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[mt,bt]),cn=c(function(){var e=r(n().mark((function e(t){var i,o,u,s,l,c,d,m,h,f,v,p,g;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),!Pt||!Cr){e.next=3;break}return e.abrupt("return");case 3:if(Er(!0),un()){e.next=7;break}return null==fe||fe("Validation failed","validation"),e.abrupt("return");case 7:if(!ct||!vr){e.next=11;break}return It("You are offline. Please check your connection and try again."),null==fe||fe("Offline","network"),e.abrupt("return");case 11:if(sn()){e.next=16;break}return o="Too many attempts. Please wait ".concat(Math.ceil(_e/6e4)," minutes."),It(o),null==fe||fe(o,"auth"),e.abrupt("return");case 16:if(!Ie||Ur){e.next=20;break}return It("Please complete the CAPTCHA verification."),null==fe||fe("CAPTCHA required","validation"),e.abrupt("return");case 20:return $r(),Dr.current=new AbortController,qt(0),It(""),Zt(!0),Tr(!0),hr({}),Xr.current=0,null==z||z(),Ye&&(null==Be||Be(Ht)),Me&&ir((function(e){return e+1})),u=yt?A(Ht):Ht,s=yt?A(Jt):Jt,l={username:u,password:s,provider:"credentials",channel:W,formId:qr},Te&&(l.rememberMe=er),gt&&(l._token=gt),Ie&&Ur&&(l.captchaToken=Ur),(c=w("POST",JSON.stringify(l),null,"json")).signal=null===(i=Dr.current)||void 0===i?void 0:i.signal,c.headers=a(a({},c.headers),{},{"X-Requested-With":"XMLHttpRequest","X-Form-ID":qr}),gt&&(c.headers["X-CSRF-Token"]=gt),d=function(){var e=r(n().mark((function e(){var t;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(U||"/api/auth/login",c);case 2:return t=e.sent,e.t0=t,e.next=6,t.json();case 6:return e.t1=e.sent,e.abrupt("return",{req:e.t0,res:e.t1});case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),e.prev=42,e.next=45,ln(d);case 45:if(m=e.sent,h=m.req,f=m.res,200!==h.status&&!h.ok){e.next=61;break}return v={username:JSON.stringify(f),password:"instincthub",redirect:!1},Rt&&(v.callbackUrl=Rt,k("callbackUrl",Rt,30)),null==G||G(!0),Ye&&(null==We||We(f)),Me&&ir(0),Q||R(),e.next=57,b("credentials",v);case 57:qt(1),At.refresh(),e.next=67;break;case 61:p=f.message||f.detail||"An error occurred",It(p),qt(f.status),null==fe||fe(p,"auth"),null==G||G(!1),Ye&&(null==Je||Je(p,Ht));case 67:e.next=79;break;case 69:if(e.prev=69,e.t0=e.catch(42),"AbortError"!==e.t0.name){e.next=73;break}return e.abrupt("return");case 73:x(g="Couldn't login. Please try again.",400),qt(3),null==fe||fe(g,"network"),null==G||G(!1),Ye&&(null==Je||Je(g,Ht));case 79:return e.prev=79,Wr.current&&(Zt(!1),Tr(!1)),e.finish(79);case 82:case"end":return e.stop()}}),e,null,[[42,69,79,82]])})));return function(t){return e.apply(this,arguments)}}(),[Ht,Jt,W,Rt,U,un,sn,$r,z,Be,G,We,fe,Je,Me,Te,er,yt,gt,Ie,Ur,qr,Pt,Cr,ct,vr,ln,Q,Ye]),dn=c((function(){at&&(Yt(""),Xt(""),tr(!1),It(""),hr({}),yr({score:0,feedback:[]}),Er(!1),Q&&R(),setTimeout((function(){var e,t=null===(e=Jr.current)||void 0===e?void 0:e.querySelector('input[name="username"]');t&&t.focus()}),100))}),[at,Q]),mn=c((function(e,t){if(ee)ee(e,t);else{var r=p("callbackUrl"),n=t||r;if(n)ge&&k("callbackUrl","",-1),At.push(n);else if(V)At.push(V);else if("skills"===Y)At.push("/library");else if("lms"===Y)if(tn){var a="You are currently logged in with ".concat(tn," channel. Would you like to proceed to the dashboard?");y(a).then((function(e){e&&At.push("/".concat(tn))}))}else{y("You do not have an active channel for this account. Would you like to create one?").then((function(e){e?At.push("/auth/create-channel"):h()}))}else At.push("/")}}),[ee,ge,V,Y,tn,At]),hn=c(r(n().mark((function e(){var t,r,a;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rn&&Qr){e.next=2;break}return e.abrupt("return");case 2:if(!re){e.next=17;break}return e.prev=3,e.next=6,re(Qr);case 6:if(e.sent){e.next=10;break}return null==te||te("Custom validation failed"),e.abrupt("return");case 10:e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(3),console.error("Custom validation error:",e.t0),null==te||te("Validation error occurred"),e.abrupt("return");case 17:return $r(),Dr.current=new AbortController,e.prev=19,t={path:"auth/skills/validate-user-token/?access_token=".concat(rn,"&user_uuid=").concat(nn),token:rn},e.next=23,v(t);case 23:if("Unauthorized"!==(null==(r=e.sent)?void 0:r.detail)&&"Not found."!==(null==r?void 0:r.detail)){e.next=30;break}return x("Couldn't login. Please try again.",400),null==te||te("Token validation failed"),e.abrupt("return");case 30:!1===on?(a="".concat(M||"/auth/verify-email","?email=").concat(an),y("You need to verify your email address, click okay to request for a one time password (OTP).").then((function(e){e&&an?(g(an),At.push(a)):h()}))):mn(Qr,Rt);case 31:e.next=40;break;case 33:if(e.prev=33,e.t1=e.catch(19),"AbortError"!==e.t1.name){e.next=37;break}return e.abrupt("return");case 37:console.error("Validation error:",e.t1),x("Validation failed. Please try again.",400),null==te||te("Network error during validation");case 40:case"end":return e.stop()}}),e,null,[[3,12],[19,33]])}))),[rn,nn,Qr,re,te,$r,M,an,on,mn,Rt,At]),bn=c((function(e){Er(!0);var t=e.target.value;Yt(t),mr.username&&hr((function(e){return a(a({},e),{},{username:void 0})}))}),[mr.username]),fn=c((function(e){Er(!0);var t=e.target.value;Xt(t),mr.password&&hr((function(e){return a(a({},e),{},{password:void 0})}))}),[mr.password]);c((function(e){$e&&he&&setTimeout((function(){return un()}),100)}),[$e,he,un]);var vn=c((function(e){var t=Ee[e]||{},r=a({callbackUrl:Rt},t);Ye&&(null==Be||Be("oauth_".concat(e))),b(e,r)}),[Ee,Rt,Ye,Be]);return d((function(){Rt&&k("callbackUrl",Rt,30)}),[Rt]),d((function(){if(ae&&!Zr&&F)if(Qr&&rn)re||nn?hn():mn(Qr,Rt);else if(null!=F&&F.user){var e={name:F.user};mn(e,Rt)}}),[F,Qr,rn,nn,ae,Zr,re,hn,mn,Rt]),d((function(){if(pe>0&&rn){var e=function(){Hr.current=setTimeout((function(){Wr.current&&rn&&(hn(),e())}),pe)};return e(),function(){Hr.current&&clearTimeout(Hr.current)}}}),[pe,rn,hn]),d((function(){if(Ke){var e=document.querySelector('input[name="username"]');e&&e.focus()}}),[Ke]),d((function(){return function(){Wr.current=!1,$r()}}),[$r]),d((function(){return Nt?document.body.classList.add("ihub-high-contrast"):document.body.classList.remove("ihub-high-contrast"),function(){document.body.classList.remove("ihub-high-contrast")}}),[Nt]),i("div",Tt&&Zr?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:i(O,{})}:Zr&&Tt?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:i("div",{className:"ihub-loading-state",children:i("p",{children:Z})})}:sr?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:o("div",{className:"ihub-error-state",children:[o("p",{children:["Too many login attempts. Please wait"," ",Math.ceil(_e/6e4)," minutes before trying again."]}),at&&i("button",{onClick:dn,className:"ihub-reset-btn ihub-mt-3",type:"button",children:"Reset Form"})]})}:ct&&vr?{className:"ihub-max-w-500 ihub-mx-auto ".concat(ce||""),children:o("div",{className:"ihub-offline-state",children:[i("p",{children:"You are currently offline. Please check your internet connection and try again."}),i("button",{onClick:function(){return window.location.reload()},className:"ihub-retry-btn ihub-mt-3",type:"button",children:"Retry"})]})}:{className:"".concat(ce||""," ").concat(Nt?"ihub-high-contrast":""),children:o("form",{ref:Jr,onSubmit:cn,className:"ihub-max-w-500 ihub-mx-auto ".concat(de||""),"aria-label":Xe||"Login form","aria-describedby":ze,noValidate:he,children:[le&&o(u,{children:[i("h1",{className:"ihub-fs-32",children:oe}),ue&&i("p",{className:"ihub-subtitle",children:ue})]}),jt&&i("div",{className:"err",role:"alert","aria-live":"polite",children:"Sign in failed. Check the details you provided are correct."}),i(C,{name:"username",type:"text",label:"Email or Username",required:!0,textTransform:"lowercase",value:Ht,onChange:bn}),mr.username&&i("p",{className:"err",id:"username-error",role:"alert",children:mr.username}),i(N,{name:"password",label:"Password",required:!0,id:"password",value:Jt,onChange:fn}),mr.password&&i("p",{className:"err",id:"password-error",role:"alert",children:mr.password}),rt&&Jt&&o("div",{className:"ihub-password-strength ihub-mt-2",id:"password-strength",children:[i("div",{className:"ihub-strength-meter",children:i("div",{className:"ihub-strength-bar ihub-strength-".concat(wr.score),style:{width:"".concat(wr.score/5*100,"%")}})}),o("p",{className:"ihub-strength-text",children:["Password strength:"," ",["Very Weak","Weak","Fair","Good","Strong"][wr.score]]}),wr.feedback.length>0&&i("ul",{className:"ihub-strength-feedback",children:wr.feedback.map((function(e,t){return i("li",{children:e},t)}))})]}),Te&&o("div",{className:"ihub-remember-me ihub-mt-3",children:[o("label",{className:"ihub-checkbox-label",children:[i("input",{type:"checkbox",checked:er,onChange:function(e){tr(e.target.checked),Er(!0)},"aria-describedby":"remember-me-help"}),Pe]}),i("small",{id:"remember-me-help",className:"ihub-help-text",children:"Keep me signed in on this device"})]}),Ie&&i("div",{className:"ihub-captcha ihub-mt-3",children:o("div",{className:"ihub-captcha-placeholder",children:[i("p",{children:"CAPTCHA verification would be loaded here"}),i("button",{type:"button",onClick:function(){return Mr("mock-captcha-token")},className:"ihub-verify-btn",children:"Verify (Mock)"})]})}),Ft&&i("div",{className:"err",role:"alert","aria-live":"polite",children:Ft}),o("div",{className:"action ihub-mt-4 ihub-mb-5",children:[i(P,{label:ye,type:"submit",status:Vt,disabled:Zr||sr||Pt&&Cr,variant:Ne}),at&&i("button",{type:"button",onClick:dn,className:"ihub-reset-btn ihub-ml-3",disabled:Zr,children:"Reset"}),(!D||!H||je)&&i(T,{labels:"or sign with"}),je&&Re.length>0&&i("div",{className:"ihub-oauth-buttons ihub-mt-3",role:"group","aria-label":"Social login options",children:Re.map((function(e){return o("button",{type:"button",className:"ihub-oauth-btn ihub-oauth-".concat(e),onClick:function(){return vn(e)},disabled:Zr,"aria-label":"Continue with ".concat(e),children:["Continue with"," ",e.charAt(0).toUpperCase()+e.slice(1)]},e)}))}),!D&&o("p",{className:"ihub-text-center ihub-fs-14",children:["Can't remember password?"," ",i("a",{href:"/auth/reset-password",children:"Reset Password"})]}),!H&&o("p",{className:"ihub-text-center ihub-fs-14",children:["New user? ",i("a",{href:"/auth/signup",children:"Create an account."})]})]}),i(S,{showText:!0}),"development"===process.env.NODE_ENV&&o("details",{className:"ihub-dev-info ihub-mt-4",children:[i("summary",{children:"Development Info"}),i("pre",{className:"ihub-dev-details",children:JSON.stringify({formTouched:Or,isOffline:ct?vr:"disabled",passwordStrength:rt?wr:"disabled",attemptCount:Me?ar:"disabled",validationErrors:mr,formId:qr},null,2)})]})]})})};export{E as default};
2
2
  //# sourceMappingURL=LoginForm.js.map
@@ -1,16 +1,77 @@
1
1
  import React from "react";
2
+ /**
3
+ * Props for the FileField component
4
+ */
2
5
  interface FileFieldProps {
6
+ /**
7
+ * Callback function triggered when a file is selected
8
+ * @param file - The selected File object
9
+ */
3
10
  onChange?: (file: File) => void;
11
+ /**
12
+ * Default image URL to display as preview
13
+ */
4
14
  defaultImageUrl?: string;
15
+ /**
16
+ * Label text displayed above the file input
17
+ */
5
18
  label?: string;
19
+ /**
20
+ * Name attribute for the file input element
21
+ */
6
22
  name?: string;
23
+ /**
24
+ * Whether the file input is required
25
+ * @default false
26
+ */
7
27
  required?: boolean;
28
+ /**
29
+ * Data name attribute for the file input
30
+ */
8
31
  dataName?: string;
32
+ /**
33
+ * Maximum file size limit in megabytes
34
+ * @default 10
35
+ */
9
36
  maxLimit?: number;
37
+ /**
38
+ * ID attribute for the file input element
39
+ */
10
40
  id?: string;
41
+ /**
42
+ * Additional CSS classes to apply to the file input
43
+ */
11
44
  className?: string;
45
+ /**
46
+ * Accepted file types (MIME types and extensions)
47
+ * @default "image/*, .pdf, .doc, .docx, .txt"
48
+ */
12
49
  acceptedTypes?: string;
50
+ /**
51
+ * Helper text displayed below the input (currently unused in implementation)
52
+ */
13
53
  helperText?: string;
14
54
  }
55
+ /**
56
+ * FileField component for file upload with preview functionality
57
+ *
58
+ * Provides a file input field with automatic preview generation for images
59
+ * and file size validation. Supports various file types and displays
60
+ * appropriate previews based on file type.
61
+ *
62
+ * @param props - The component props
63
+ * @returns A file input component with preview capabilities
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * <FileField
68
+ * label="Upload Document"
69
+ * onChange={(file) => console.log('Selected file:', file)}
70
+ * maxLimit={5}
71
+ * acceptedTypes="image/*, .pdf"
72
+ * required
73
+ * />
74
+ * ```
75
+ */
15
76
  declare const FileField: React.FC<FileFieldProps>;
16
77
  export default FileField;
@@ -182,7 +182,7 @@ export interface SearchObjectItemType {
182
182
  }
183
183
  export interface TableColumnType<T> {
184
184
  header: string;
185
- accessor: keyof T | ((row: T) => React.ReactNode);
185
+ accessor: keyof T | ((row: T, index?: number) => React.ReactNode);
186
186
  sortable?: boolean;
187
187
  filterable?: boolean;
188
188
  width?: string;