@tempots/beatui 1.0.0 → 1.0.1
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/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +1 -1
- package/dist/{auth-divider-BQIhr3-R.js → auth-divider-CbME_yVQ.js} +13 -13
- package/dist/auth-divider-MMhfmLBu.cjs +1 -0
- package/dist/beatui.css +4 -8
- package/dist/beatui.tailwind.css +4 -8
- package/dist/better-auth/index.cjs.js +1 -1
- package/dist/better-auth/index.es.js +5 -5
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +11 -11
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +3 -3
- package/dist/notice-B5wTXoTq.cjs +1 -0
- package/dist/{notice-E19wu9lA.js → notice-BKcyJD5w.js} +44 -44
- package/dist/types/components/form/input/bigint-input.d.ts +3 -3
- package/dist/types/components/form/input/create-nullable-string-input.d.ts +2 -2
- package/dist/types/components/form/input/date-time-input.d.ts +4 -4
- package/dist/types/components/form/input/email-input.d.ts +4 -4
- package/dist/types/components/form/input/nullable-bigint-input.d.ts +3 -3
- package/dist/types/components/form/input/nullable-date-time-input.d.ts +2 -2
- package/dist/types/components/form/input/nullable-email-input.d.ts +3 -3
- package/dist/widget-customization-B49MeU4E.cjs +1 -0
- package/dist/{widget-customization-Dkx7kNSe.js → widget-customization-DEiQ_31d.js} +327 -321
- package/package.json +1 -1
- package/dist/auth-divider-DvnUModP.cjs +0 -1
- package/dist/notice-_9XhdrFw.cjs +0 -1
- package/dist/widget-customization-DgW1SXN6.cjs +0 -1
package/dist/auth/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../auth-divider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../auth-divider-MMhfmLBu.cjs");exports.AmazonLoginButton=o.AmazonLoginButton;exports.AppleLoginButton=o.AppleLoginButton;exports.AuthContainer=o.AuthContainer;exports.AuthDivider=o.AuthDivider;exports.AuthModal=o.AuthModal;exports.DiscordLoginButton=o.DiscordLoginButton;exports.EpicLoginButton=o.EpicLoginButton;exports.FacebookLoginButton=o.FacebookLoginButton;exports.GitHubLoginButton=o.GitHubLoginButton;exports.GoogleLoginButton=o.GoogleLoginButton;exports.InstagramLoginButton=o.InstagramLoginButton;exports.LinkedInLoginButton=o.LinkedInLoginButton;exports.MicrosoftLoginButton=o.MicrosoftLoginButton;exports.PasswordStrengthBar=o.PasswordStrengthBar;exports.PasswordStrengthIndicator=o.PasswordStrengthIndicator;exports.PasswordStrengthText=o.PasswordStrengthText;exports.PayPalLoginButton=o.PayPalLoginButton;exports.PinterestLoginButton=o.PinterestLoginButton;exports.PlayStationLoginButton=o.PlayStationLoginButton;exports.RedditLoginButton=o.RedditLoginButton;exports.ResetPasswordForm=o.ResetPasswordForm;exports.SignInForm=o.SignInForm;exports.SignUpForm=o.SignUpForm;exports.SnapchatLoginButton=o.SnapchatLoginButton;exports.SocialLoginButton=o.SocialLoginButton;exports.SocialLoginButtons=o.SocialLoginButtons;exports.SocialProviders=o.SocialProviders;exports.SteamLoginButton=o.SteamLoginButton;exports.TiktokLoginButton=o.TiktokLoginButton;exports.TwitchLoginButton=o.TwitchLoginButton;exports.TwitterLoginButton=o.TwitterLoginButton;exports.WeChatLoginButton=o.WeChatLoginButton;exports.WhatsAppLoginButton=o.WhatsAppLoginButton;exports.XLoginButtin=o.XLoginButtin;exports.XboxLoginButton=o.XboxLoginButton;exports.YahooLoginButton=o.YahooLoginButton;exports.authSchemas=o.authSchemas;exports.calculatePasswordStrength=o.calculatePasswordStrength;exports.createEmailSchema=o.createEmailSchema;exports.createPasswordSchema=o.createPasswordSchema;exports.createSignInSchema=o.createSignInSchema;exports.createSignUpSchema=o.createSignUpSchema;exports.createSocialLoginUrl=o.createSocialLoginUrl;exports.defaultPasswordRules=o.defaultPasswordRules;exports.defaultSignInSchema=o.defaultSignInSchema;exports.defaultSignUpSchema=o.defaultSignUpSchema;exports.emailSchema=o.emailSchema;exports.formatAuthError=o.formatAuthError;exports.formatProviderName=o.formatProviderName;exports.formatSocialLoginText=o.formatSocialLoginText;exports.generateRandomString=o.generateRandomString;exports.getProviderColor=o.getProviderColor;exports.getProviderIcon=o.getProviderIcon;exports.isBrowser=o.isBrowser;exports.isValidEmail=o.isValidEmail;exports.openSocialLoginPopup=o.openSocialLoginPopup;exports.providerInfo=o.providerInfo;exports.requestToControllerValidation=o.requestToControllerValidation;exports.resetPasswordSchema=o.resetPasswordSchema;exports.socialProviderInfo=o.socialProviderInfo;exports.useAuthEmailProp=o.useAuthEmailProp;exports.validateEmail=o.validateEmail;exports.validatePassword=o.validatePassword;
|
package/dist/auth/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as t, a as s, b as n, c as i, d as e, D as r, E as g, F as u, G as c, e as l, I as d, L, M as S, P as B, f as m, g as h, h as P, i as p, j as w, R as f, k as v, S as I, l as A, m as E, n as T, o as k, p as x, q as C, T as F, r as R, s as U, W as b, t as y, X as D, u as G, Y as M, v as V, w as W, x as X, y as q, z, B as H, C as N, H as Y, J as j, K as J, N as K, O, Q, U as Z, V as _, Z as $, _ as aa, $ as oa, a0 as ta, a1 as sa, a2 as na, a3 as ia, a4 as ea, a5 as ra, a6 as ga, a7 as ua, a8 as ca } from "../auth-divider-
|
|
1
|
+
import { A as t, a as s, b as n, c as i, d as e, D as r, E as g, F as u, G as c, e as l, I as d, L, M as S, P as B, f as m, g as h, h as P, i as p, j as w, R as f, k as v, S as I, l as A, m as E, n as T, o as k, p as x, q as C, T as F, r as R, s as U, W as b, t as y, X as D, u as G, Y as M, v as V, w as W, x as X, y as q, z, B as H, C as N, H as Y, J as j, K as J, N as K, O, Q, U as Z, V as _, Z as $, _ as aa, $ as oa, a0 as ta, a1 as sa, a2 as na, a3 as ia, a4 as ea, a5 as ra, a6 as ga, a7 as ua, a8 as ca } from "../auth-divider-CbME_yVQ.js";
|
|
2
2
|
export {
|
|
3
3
|
t as AmazonLoginButton,
|
|
4
4
|
s as AppleLoginButton,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { localStorageProp as le, prop as U, Use as q, html as l, attr as t, on as z, When as _, coalesce as g, Ensure as W, computedOf as b, bind as me, ForEach as ue, Value as oe, OneOfValue as pe, Fragment as
|
|
1
|
+
import { localStorageProp as le, prop as U, Use as q, html as l, attr as t, on as z, When as _, coalesce as g, Ensure as W, computedOf as b, bind as me, ForEach as ue, Value as oe, OneOfValue as pe, Fragment as R } from "@tempots/dom";
|
|
2
2
|
import { S as T } from "./stack-BLMteGTn.js";
|
|
3
3
|
import { t as de, u as G, a as ne, b as A } from "./use-form-Dn6v2tEh.js";
|
|
4
4
|
import { o as H, b as F, s as C, M as he } from "./modal-DBguyX-b.js";
|
|
5
5
|
import { Validation as te } from "@tempots/std";
|
|
6
6
|
import { d as f, A as x } from "./translations-A4kR7CW8.js";
|
|
7
|
-
import { P as O,
|
|
7
|
+
import { P as O, E as j, N as X } from "./notice-BKcyJD5w.js";
|
|
8
8
|
import { B as M } from "./input-container-BvEcp7FU.js";
|
|
9
9
|
import { T as ge } from "./text-input-DfqXolVe.js";
|
|
10
10
|
import { I as fe } from "./translations-B1_yyDUK.js";
|
|
@@ -654,7 +654,7 @@ function ke({
|
|
|
654
654
|
}
|
|
655
655
|
}), { controller: S, submit: V } = k;
|
|
656
656
|
h.on(S.setDisabled);
|
|
657
|
-
const B = S.field("name"), P = S.field("email"),
|
|
657
|
+
const B = S.field("name"), P = S.field("email"), E = S.field("password"), D = S.field("confirmPassword"), I = S.field("acceptTerms");
|
|
658
658
|
return q(
|
|
659
659
|
x,
|
|
660
660
|
(w) => (
|
|
@@ -689,14 +689,14 @@ function ke({
|
|
|
689
689
|
}),
|
|
690
690
|
// Password field
|
|
691
691
|
A(O, {
|
|
692
|
-
controller:
|
|
692
|
+
controller: E,
|
|
693
693
|
label: g(o?.passwordLabel, w.$.passwordLabel)
|
|
694
694
|
}),
|
|
695
695
|
// Password strength indicator
|
|
696
696
|
_(
|
|
697
697
|
c ?? !1,
|
|
698
698
|
() => ve({
|
|
699
|
-
password:
|
|
699
|
+
password: E.signal,
|
|
700
700
|
rules: L,
|
|
701
701
|
showLabel: !0
|
|
702
702
|
})
|
|
@@ -1156,7 +1156,7 @@ function Pe({
|
|
|
1156
1156
|
}, ...V) {
|
|
1157
1157
|
const B = e != null ? oe.deriveProp(e) : U("signin");
|
|
1158
1158
|
return B.on((P) => v?.(P)), q(x, (P) => {
|
|
1159
|
-
function
|
|
1159
|
+
function E() {
|
|
1160
1160
|
const w = g(m?.hasAccountLink, P.$.hasAccountLink);
|
|
1161
1161
|
return l.button(
|
|
1162
1162
|
t.type("button"),
|
|
@@ -1189,12 +1189,12 @@ function Pe({
|
|
|
1189
1189
|
t.class(B.map((w) => `bc-auth-container--${w}`)),
|
|
1190
1190
|
t.class("bc-auth-form"),
|
|
1191
1191
|
pe(B, {
|
|
1192
|
-
signin: () =>
|
|
1192
|
+
signin: () => R(
|
|
1193
1193
|
l.h2(
|
|
1194
1194
|
t.class("bc-auth-form__title"),
|
|
1195
1195
|
g(m?.signInTitle, P.$.signInTitle)
|
|
1196
1196
|
),
|
|
1197
|
-
o != null ?
|
|
1197
|
+
o != null ? R(
|
|
1198
1198
|
ae({
|
|
1199
1199
|
providers: o,
|
|
1200
1200
|
onSocialLogin: k
|
|
@@ -1220,12 +1220,12 @@ function Pe({
|
|
|
1220
1220
|
I()
|
|
1221
1221
|
)
|
|
1222
1222
|
),
|
|
1223
|
-
signup: () =>
|
|
1223
|
+
signup: () => R(
|
|
1224
1224
|
l.h2(
|
|
1225
1225
|
t.class("bc-auth-form__title"),
|
|
1226
1226
|
g(m?.signUpTitle, P.$.signUpTitle)
|
|
1227
1227
|
),
|
|
1228
|
-
o != null ?
|
|
1228
|
+
o != null ? R(
|
|
1229
1229
|
ae({
|
|
1230
1230
|
providers: o,
|
|
1231
1231
|
onSocialLogin: k
|
|
@@ -1248,9 +1248,9 @@ function Pe({
|
|
|
1248
1248
|
passwordRules: c,
|
|
1249
1249
|
showPasswordStrength: n
|
|
1250
1250
|
}),
|
|
1251
|
-
T(t.class("bc-auth-form__footer"),
|
|
1251
|
+
T(t.class("bc-auth-form__footer"), E())
|
|
1252
1252
|
),
|
|
1253
|
-
"reset-password": () =>
|
|
1253
|
+
"reset-password": () => R(
|
|
1254
1254
|
l.h2(
|
|
1255
1255
|
t.class("bc-auth-form__title"),
|
|
1256
1256
|
g(m?.resetPasswordTitle, P.$.resetPasswordTitle)
|
|
@@ -1264,7 +1264,7 @@ function Pe({
|
|
|
1264
1264
|
},
|
|
1265
1265
|
onResetPassword: L
|
|
1266
1266
|
}),
|
|
1267
|
-
T(t.class("bc-auth-form__footer"),
|
|
1267
|
+
T(t.class("bc-auth-form__footer"), E())
|
|
1268
1268
|
)
|
|
1269
1269
|
}),
|
|
1270
1270
|
...V
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("@tempots/dom"),q=require("./stack-dwLevGa2.cjs"),L=require("./use-form-CaW192gw.cjs"),f=require("./modal-BT0jjDqX.cjs"),G=require("@tempots/std"),m=require("./translations-C81buKAw.cjs"),P=require("./notice-B5wTXoTq.cjs"),C=require("./input-container-Di1YvVB_.cjs"),ee=require("./text-input-X_q01NsY.cjs"),te=require("./translations-Dbx7L7Q1.cjs"),oe=require("@tempots/ui"),T={google:{name:"Google",icon:"logos:google-icon",color:"#4285f4"},github:{name:"GitHub",icon:"logos:github-icon",color:"#333"},apple:{name:"Apple",icon:"logos:apple",color:"#000"},facebook:{name:"Facebook",icon:"logos:facebook",color:"#1877f2"},twitter:{name:"Twitter",icon:"logos:twitter",color:"#1da1f2"},microsoft:{name:"Microsoft",icon:"logos:microsoft-icon",color:"#00a4ef"},discord:{name:"Discord",icon:"logos:discord-icon",color:"#5865f2"},linkedin:{name:"LinkedIn",icon:"logos:linkedin-icon",color:"#0077b5"},instagram:{name:"Instagram",icon:"logos:instagram-icon",color:"#e4405f"},tiktok:{name:"TikTok",icon:"logos:tiktok-icon",color:"#000"},snapchat:{name:"Snapchat",icon:"logos:snapchat-icon",color:"#fffc00"},reddit:{name:"Reddit",icon:"logos:reddit-icon",color:"#ff4500"},pinterest:{name:"Pinterest",icon:"logos:pinterest-icon",color:"#bd081c"},twitch:{name:"Twitch",icon:"logos:twitch",color:"#9146ff"},steam:{name:"Steam",icon:"logos:steam-icon",color:"#000"},epic:{name:"Epic Games",icon:"simple-icons:epicgames",color:"#313131"},playstation:{name:"PlayStation",icon:"logos:playstation-icon",color:"#003791"},xbox:{name:"Xbox",icon:"logos:xbox-icon",color:"#107c10"},whatsapp:{name:"WhatsApp",icon:"logos:whatsapp-icon",color:"#25d366"},wechat:{name:"WeChat",icon:"logos:wechat-icon",color:"#1aad19"},amazon:{name:"Amazon",icon:"logos:amazon-icon",color:"#ff9900"},yahoo:{name:"Yahoo",icon:"logos:yahoo-icon",color:"#720e9e"},paypal:{name:"PayPal",icon:"logos:paypal",color:"#0070ba"},x:{name:"X",icon:"simple-icons:x",color:"#000"}};function j(t){return T[t]?.name||t}function ae(t){return T[t]?.icon||"mdi:account"}function ne(t){return T[t]?.color||"#666"}function re(t,o="Continue with {provider}"){return o.replace("{provider}",j(t))}const y={minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSymbols:!1};function se(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function H(t=32){const o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let a=0;a<t;a++)n+=o.charAt(Math.floor(Math.random()*o.length));return n}function ie(t,o,n,a=[],c={}){const s={google:"https://accounts.google.com/oauth/authorize",github:"https://github.com/login/oauth/authorize",apple:"https://appleid.apple.com/auth/authorize",facebook:"https://www.facebook.com/v18.0/dialog/oauth",twitter:"https://twitter.com/i/oauth2/authorize",microsoft:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",discord:"https://discord.com/api/oauth2/authorize",linkedin:"https://www.linkedin.com/oauth/v2/authorization",instagram:"https://api.instagram.com/oauth/authorize",tiktok:"https://www.tiktok.com/v2/auth/authorize",snapchat:"https://accounts.snapchat.com/accounts/oauth2/authorize",reddit:"https://www.reddit.com/api/v1/authorize",pinterest:"https://api.pinterest.com/oauth/",twitch:"https://id.twitch.tv/oauth2/authorize",steam:"https://steamcommunity.com/oauth/authorize",epic:"https://auth.epicgames.com/authorize",playstation:"https://auth.api.sonyentertainmentnetwork.com/oauth/authorize",xbox:"https://login.live.com/oauth20_authorize.srf",whatsapp:"https://web.whatsapp.com/oauth/authorize",wechat:"https://open.weixin.qq.com/connect/qrconnect",amazon:"https://www.amazon.com/ap/oa",yahoo:"https://api.login.yahoo.com/oauth2/request_auth",paypal:"https://www.paypal.com/signin/authorize",x:"https://api.twitter.com/oauth2/authorize"},u={google:["openid","email","profile"],github:["user:email"],apple:["email","name"],facebook:["email"],twitter:["users.read"],microsoft:["openid","email","profile"],discord:["identify","email"],linkedin:["r_liteprofile","r_emailaddress"],instagram:["user_profile","user_media"],tiktok:["user.info.basic","user.external.id"],snapchat:["user.info.basic","user.external.id"],reddit:["identity","email"],pinterest:["read_public","read_relationships"],twitch:["openid","email","profile"],steam:["openid","email","profile"],epic:["openid","email","profile"],playstation:["openid","email","profile"],xbox:["openid","email","profile"],whatsapp:["openid","email","profile"],wechat:["openid","email","profile"],amazon:["openid","email","profile"],yahoo:["openid","email","profile"],paypal:["openid","email","profile"],x:["openid","email","profile"]},r=s[t];if(!r)throw new Error(`Unsupported provider: ${t}`);const l=a.length>0?a:u[t],i=H(),h=new URLSearchParams({client_id:o,redirect_uri:n,scope:l.join(" "),state:i,response_type:"code",...c});return`${r}?${h.toString()}`}function ce(t,o,n,a){const c=window.open(t,`${o}_login`,"width=500,height=600,scrollbars=yes,resizable=yes");if(!c){a?.(new Error("Failed to open popup window"));return}const s=setInterval(()=>{c.closed&&(clearInterval(s),a?.(new Error("Login cancelled")))},1e3),u=r=>{r.origin===window.location.origin&&(r.data.type==="SOCIAL_LOGIN_SUCCESS"?(clearInterval(s),c.close(),window.removeEventListener("message",u),n?.(r.data.result)):r.data.type==="SOCIAL_LOGIN_ERROR"&&(clearInterval(s),c.close(),window.removeEventListener("message",u),a?.(new Error(r.data.error))))};window.addEventListener("message",u)}function le(t){return t instanceof Error?t.message:typeof t=="string"?t:t&&typeof t=="object"&&"message"in t?String(t.message):"An unexpected error occurred"}function ue(){return typeof window<"u"&&typeof document<"u"}function $({task:t,message:o,onStart:n,onEnd:a}){return async c=>{n?.();const s=await L.taskToValidation({task:t!=null?()=>t(c):async()=>null,errorMessage:o,errorPath:["root"],validation:u=>u!=null?G.Validation.invalid({message:u}):G.Validation.valid});return a?.(),s}}function E(t=y,o){const n=o??m.defaultMessages;let a=f.string();return t.minLength&&(a=a.min(t.minLength,(n.passwordMinLength??m.defaultMessages.passwordMinLength)(t.minLength))),t.requireUppercase&&(a=a.regex(/[A-Z]/,n.passwordRequireUppercase??m.defaultMessages.passwordRequireUppercase)),t.requireLowercase&&(a=a.regex(/[a-z]/,n.passwordRequireLowercase??m.defaultMessages.passwordRequireLowercase)),t.requireNumbers&&(a=a.regex(/[0-9]/,n.passwordRequireNumber??m.defaultMessages.passwordRequireNumber)),t.requireSymbols&&(a=a.regex(/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,n.passwordRequireSpecialChar??m.defaultMessages.passwordRequireSpecialChar)),t.customValidation&&(a=a.refine(c=>t.customValidation(c))),a}function A(t){const o=t??m.defaultMessages;return f.string().min(1,o.emailRequired??m.defaultMessages.emailRequired).email(o.invalidEmail??m.defaultMessages.invalidEmail)}const V=A();function M(t,o){const n=o??m.defaultMessages,a=t?E(t,o):f.string().refine(c=>c.length>0?null:n.passwordRequired??m.defaultMessages.passwordRequired);return f.object({email:A(o),password:a,rememberMe:f.boolean().default(!1)}).schema()}function z(t=y,o,n){const a=n??m.defaultMessages,c=E(t,n),s=o?.showNameField!==!1,u=o?.showConfirmPassword!==!1,r=o?.showAcceptTermsAndConditions!==!1,l={name:s?f.string().min(1,a.nameRequired??m.defaultMessages.nameRequired).optional():f.string().optional(),email:A(n),password:c,confirmPassword:u?f.string().min(1,a.confirmPasswordRequired??m.defaultMessages.confirmPasswordRequired):f.string(),acceptTerms:r?f.boolean().refine(h=>h===!0,a.acceptTermsRequired??m.defaultMessages.acceptTermsRequired):f.boolean().default(!0)},i=f.object(l);return u?i.refine(h=>h.password===h.confirmPassword?null:a.passwordsDoNotMatch??m.defaultMessages.passwordsDoNotMatch,{path:["confirmPassword"]}).schema():i.schema()}const N=f.object({email:V}).schema(),me=M(),de=z(),pe={signIn:M,signUp:z,resetPassword:()=>N};function he(t,o){const n=o??m.defaultMessages,c=(o?A(o):V).validate(t);return c.success?null:c.errors[0]?.message||(n.invalidEmailAddress??m.defaultMessages.invalidEmailAddress)}function ge(t,o=y,n){const a=n??m.defaultMessages,s=E(o,n).validate(t);return s.success?null:s.errors[0]?.message||(a.invalidPassword??m.defaultMessages.invalidPassword)}function R(t,o=y){const n={length:t.length>=(o.minLength||8),uppercase:/[A-Z]/.test(t),lowercase:/[a-z]/.test(t),numbers:/[0-9]/.test(t),symbols:/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(t),custom:o.customValidation?o.customValidation(t)===null:t.length>0},a=[!0,o.requireUppercase,o.requireLowercase,o.requireNumbers,o.requireSymbols,!!o.customValidation].filter(Boolean).length,c=[n.length,o.requireUppercase?n.uppercase:null,o.requireLowercase?n.lowercase:null,o.requireNumbers?n.numbers:null,o.requireSymbols?n.symbols:null,o.customValidation?n.custom:null].filter(r=>r===!0).length,s=a>0?Math.round(c/a*100):0;let u;return s<40?u="weak":s<60?u="fair":s<80?u="good":u="strong",{strength:u,score:s,checks:n}}const D=()=>e.localStorageProp({key:"bui_auth_email",defaultValue:null});function X({onSignIn:t,passwordRules:o,labels:n,showRememberMe:a}){const c=e.prop(!1),s=D(),u=M(o),r=L.useForm({schema:u,onSubmit:$({task:t,message:"Reset password failed",onStart:()=>{c.set(!0),r.controller.disable()},onEnd:()=>{c.set(!1),r.controller.enable()}}),initialValue:{email:"",password:""}}),{controller:l,submit:i}=r;c.on(l.setDisabled);const h=l.field("email"),w=l.field("password");return s.on(b=>{b!=null&&h.change(b)}),h.signal.on(b=>{s.value!=null&&(s.value=b)}),e.Use(m.AuthI18n,b=>e.html.form(e.attr.class("bc-auth-form__form"),e.on.submit(i),q.Stack(e.attr.class("bc-auth-form__fields"),e.Ensure(l.error,_=>P.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(_))),L.Control(P.EmailInput,{controller:h,label:e.coalesce(n?.emailLabel,b.$.emailLabel)}),L.Control(P.PasswordInput,{controller:w,label:e.coalesce(n?.passwordLabel,b.$.passwordLabel)}),e.When(a??!0,()=>e.html.div(e.attr.class("bc-auth-form__remember-me"),e.html.label(e.attr.class("bc-auth-form__checkbox-label"),L.CheckboxInput({value:s.map(_=>_!=null),after:e.html.span(e.coalesce(n?.rememberMeLabel,b.$.rememberMeLabel)),onChange:_=>{_?s.value=h.signal.value??"":s.value=null}}))))),C.Button({type:"submit",variant:"filled",color:"primary",loading:c,disabled:l.disabledOrHasErrors},e.attr.class("bc-auth-form__submit"),e.coalesce(n?.signInButton,b.$.signInButton))))}function Y({password:t,rules:o=y,showLabel:n=!0,className:a}){const c=e.computedOf(t)(i=>!i||i.length===0?{strength:"weak",score:0,checks:{length:!1,uppercase:!1,lowercase:!1,numbers:!1,symbols:!1,custom:!1}}:R(i,o)),s=c.map(i=>i.strength),u=c.map(i=>i.score),r=c.map(i=>i.checks),l=e.computedOf(s,a)((i,h)=>["bc-password-strength",`bc-password-strength--${i}`,h].filter(Boolean).join(" "));return e.html.div(e.attr.class(l),e.html.div(e.attr.class("bc-password-strength__bar"),e.html.div(e.attr.class("bc-password-strength__fill"),e.attr.style(u.map(i=>`width: ${i}%`)))),e.When(n,()=>e.Use(m.AuthI18n,i=>e.html.div(e.attr.class("bc-password-strength__label"),e.computedOf(s,i)((h,w)=>{switch(h){case"weak":return w.passwordStrengthWeak;case"fair":return w.passwordStrengthFair;case"good":return w.passwordStrengthGood;case"strong":return w.passwordStrengthStrong;default:return w.passwordStrengthWeak}})))),e.html.div(e.attr.class("bc-password-strength__requirements"),e.When(o.minLength!==void 0,()=>e.html.div(e.attr.class("bc-password-strength__requirement"),e.attr.class(e.computedOf(r)(i=>i.length?"bc-password-strength__requirement--met":"")),e.html.span(e.attr.class("bc-password-strength__requirement-icon"),e.computedOf(r)(i=>i.length?"✓":"○")),e.html.span(e.attr.class("bc-password-strength__requirement-text"),`At least ${o.minLength} characters`))),e.When(o.requireUppercase===!0,()=>e.html.div(e.attr.class("bc-password-strength__requirement"),e.attr.class(e.computedOf(r)(i=>i.uppercase?"bc-password-strength__requirement--met":"")),e.html.span(e.attr.class("bc-password-strength__requirement-icon"),e.computedOf(r)(i=>i.uppercase?"✓":"○")),e.html.span(e.attr.class("bc-password-strength__requirement-text"),"One uppercase letter"))),e.When(o.requireLowercase===!0,()=>e.html.div(e.attr.class("bc-password-strength__requirement"),e.attr.class(e.computedOf(r)(i=>i.lowercase?"bc-password-strength__requirement--met":"")),e.html.span(e.attr.class("bc-password-strength__requirement-icon"),e.computedOf(r)(i=>i.lowercase?"✓":"○")),e.html.span(e.attr.class("bc-password-strength__requirement-text"),"One lowercase letter"))),e.When(o.requireNumbers===!0,()=>e.html.div(e.attr.class("bc-password-strength__requirement"),e.attr.class(e.computedOf(r)(i=>i.numbers?"bc-password-strength__requirement--met":"")),e.html.span(e.attr.class("bc-password-strength__requirement-icon"),e.computedOf(r)(i=>i.numbers?"✓":"○")),e.html.span(e.attr.class("bc-password-strength__requirement-text"),"One number"))),e.When(o.requireSymbols===!0,()=>e.html.div(e.attr.class("bc-password-strength__requirement"),e.attr.class(e.computedOf(r)(i=>i.symbols?"bc-password-strength__requirement--met":"")),e.html.span(e.attr.class("bc-password-strength__requirement-icon"),e.computedOf(r)(i=>i.symbols?"✓":"○")),e.html.span(e.attr.class("bc-password-strength__requirement-text"),"One special character")))))}function fe({password:t,rules:o=y,className:n}){const a=e.computedOf(t)(r=>!r||r.length===0?{strength:"weak",score:0}:R(r,o)),c=a.map(r=>r.strength),s=a.map(r=>r.score),u=e.computedOf(c,n)((r,l)=>["bc-password-strength-bar",`bc-password-strength-bar--${r}`,l].filter(Boolean).join(" "));return e.html.div(e.attr.class(u),e.html.div(e.attr.class("bc-password-strength-bar__fill"),e.attr.style(s.map(r=>`width: ${r}%`))))}function we({password:t,rules:o=y,className:n}){const a=e.computedOf(t)(s=>!s||s.length===0?"weak":R(s,o).strength),c=e.computedOf(a,n)((s,u)=>["bc-password-strength-text",`bc-password-strength-text--${s}`,u].filter(Boolean).join(" "));return e.Use(m.AuthI18n,s=>e.html.span(e.attr.class(c),e.computedOf(a,s)((u,r)=>{switch(u){case"weak":return r.passwordStrengthWeak;case"fair":return r.passwordStrengthFair;case"good":return r.passwordStrengthGood;case"strong":return r.passwordStrengthStrong;default:return r.passwordStrengthWeak}})))}function Z({passwordRules:t,labels:o,initialEmail:n,initialName:a,showPasswordStrength:c,onSignUp:s,showNameField:u,showConfirmPassword:r,showAcceptTermsAndConditions:l,termsAndConditions:i}){const h=e.prop(!1),w=t||y,b=z(w,{showNameField:u!==!1,showConfirmPassword:r!==!1,showAcceptTermsAndConditions:l!==!1}),_=L.useForm({schema:b,onSubmit:$({task:s!=null?g=>s({email:g.email,password:g.password,name:g.name,acceptTerms:g.acceptTerms}):void 0,message:"Reset password failed",onStart:()=>{h.set(!0),_.controller.disable()},onEnd:()=>{h.set(!1),_.controller.enable()}}),initialValue:{name:a??"",email:n??"",password:"",confirmPassword:"",acceptTerms:!1}}),{controller:v,submit:U}=_;h.on(v.setDisabled);const B=v.field("name"),S=v.field("email"),x=v.field("password"),O=v.field("confirmPassword"),I=v.field("acceptTerms");return e.Use(m.AuthI18n,g=>e.html.form(e.attr.class("bc-auth-form__form"),e.on.submit(U),q.Stack(e.attr.class("bc-auth-form__fields"),e.Ensure(v.error,k=>P.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(k))),e.When(u!==!1,()=>L.Control(ee.TextInput,{controller:B.transform(k=>k??"",k=>k===""?void 0:k),label:e.coalesce(o?.nameLabel,g.$.nameLabel)})),L.Control(P.EmailInput,{controller:S,label:e.coalesce(o?.emailLabel,g.$.emailLabel)}),L.Control(P.PasswordInput,{controller:x,label:e.coalesce(o?.passwordLabel,g.$.passwordLabel)}),e.When(c??!1,()=>Y({password:x.signal,rules:w,showLabel:!0})),e.When(r??!1,()=>L.Control(P.PasswordInput,{controller:O,label:e.coalesce(o?.confirmPasswordLabel,g.$.confirmPasswordLabel)})),e.When(l??!1,()=>e.html.div(e.attr.class("bc-auth-form__terms"),e.html.label(e.attr.class("bc-auth-form__checkbox-label"),L.CheckboxInput({value:I.signal.map(k=>k??!1),onChange:k=>I.change(k)}),e.html.span(i||e.coalesce(o?.acceptTermsLabel,g.$.acceptTermsLabel))),e.When(I.errorVisible,()=>e.html.div(e.attr.class("bc-auth-form__field-error"),I.error.map(k=>k||"")))))),C.Button({type:"submit",variant:"filled",color:"primary",loading:h,disabled:v.disabledOrHasErrors},e.attr.class("bc-auth-form__submit"),e.coalesce(o?.signUpButton,g.$.signUpButton))))}function J({onResetPassword:t,labels:o={}}){const n=D(),a=e.prop(!1),c=L.useForm({schema:N,onSubmit:$({task:t,message:"Reset password failed",onStart:()=>{a.set(!0),c.controller.disable()},onEnd:()=>{a.set(!1),c.controller.enable()}}),initialValue:{email:""}}),{controller:s,submit:u}=c;a.on(s.setDisabled);const r=s.field("email");return n.on(l=>{l!=null&&r.change(l)}),e.Use(m.AuthI18n,l=>e.html.form(e.attr.class("bc-auth-form__form"),e.Ensure(s.error,i=>P.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(i))),e.html.p(e.attr.class("bc-auth-form__description"),e.coalesce(o?.resetPasswordDescription,l.$.resetPasswordDescription)),e.on.submit(u),q.Stack(e.attr.class("bc-auth-form__fields"),L.Control(P.EmailInput,{controller:r,label:e.coalesce(o?.emailLabel,l.$.emailLabel)})),C.Button({loading:a,type:"submit",variant:"filled",color:"primary",disabled:s.disabledOrHasErrors},e.attr.class("bc-auth-form__submit"),e.coalesce(o?.resetPasswordButton,l.$.resetPasswordButton))))}function p({provider:t,onClick:o,size:n="md",name:a,icon:c,color:s,flow:u,labels:r}){const l=async()=>{if(o)try{u==="popup"?await o():await o()}catch(i){console.error(`Social login error for ${t} (${u||"redirect"} flow):`,i)}};return C.Button({type:"button",variant:"filled",size:n,color:s,onClick:l,roundedness:"full"},e.attr.class("bc-social-login-button"),e.attr.class(e.computedOf(t)(i=>`bc-social-login-button--${i}`)),e.html.span(e.attr.class("bc-social-login-button__inner"),e.html.span(e.attr.class("bc-social-login-button__icon"),te.Icon({icon:c,size:n},e.attr.class("bc-social-login-button__icon-inner"))),e.Use(m.AuthI18n,i=>e.html.span(e.attr.class("bc-social-login-button__label"),e.bind(e.coalesce(r?.continueWithProvider,i.$.continueWithProvider))(a)))))}function K({providers:t,onProviderClick:o,size:n="md",className:a}){return q.Stack(e.attr.class("bc-social-login-buttons"),e.attr.class(a),e.ForEach(t,c=>p({provider:c.$.provider,flow:c.$.flow,color:c.map(({provider:s})=>d[s].color),name:c.map(({provider:s})=>d[s].name),icon:c.map(({provider:s})=>d[s].icon),onClick:async()=>{o&&await o(c.$.provider.value)},size:n})))}const d={google:{name:"Google",icon:"logos:google-icon",color:"red"},github:{name:"GitHub",icon:"logos:github-icon",color:"black"},apple:{name:"Apple",icon:"logos:apple",color:"stone"},facebook:{name:"Facebook",icon:"logos:facebook",color:"blue"},twitter:{name:"Twitter",icon:"logos:twitter",color:"sky"},x:{name:"X",icon:"logos:x",color:"zinc"},microsoft:{name:"Microsoft",icon:"logos:microsoft-icon",color:"amber"},discord:{name:"Discord",icon:"logos:discord-icon",color:"indigo"},linkedin:{name:"LinkedIn",icon:"logos:linkedin-icon",color:"cyan"},instagram:{name:"Instagram",icon:"logos:instagram-icon",color:"fuchsia"},tiktok:{name:"TikTok",icon:"logos:tiktok-icon",color:"teal"},snapchat:{name:"Snapchat",icon:"simple-icons:snapchat",color:"yellow"},reddit:{name:"Reddit",icon:"logos:reddit-icon",color:"orange"},pinterest:{name:"Pinterest",icon:"logos:pinterest",color:"rose"},twitch:{name:"Twitch",icon:"logos:twitch",color:"purple"},steam:{name:"Steam",icon:"logos:steam",color:"slate"},epic:{name:"Epic Games",icon:"simple-icons:epicgames",color:"neutral"},playstation:{name:"PlayStation",icon:"simple-icons:playstation",color:"violet"},xbox:{name:"Xbox",icon:"simple-icons:xbox",color:"green"},whatsapp:{name:"WhatsApp",icon:"logos:whatsapp-icon",color:"emerald"},wechat:{name:"WeChat",icon:"simple-icons:wechat",color:"lime"},amazon:{name:"Amazon",icon:"simple-icons:amazon",color:"red"},yahoo:{name:"Yahoo",icon:"logos:yahoo",color:"rose"},paypal:{name:"PayPal",icon:"logos:paypal",color:"blue"}},be=t=>p({...t,...d.google,provider:"google"}),Le=t=>p({...t,...d.github,provider:"github"}),_e=t=>p({...t,...d.apple,provider:"apple"}),ke=t=>p({...t,...d.facebook,provider:"facebook"}),ve=t=>p({...t,...d.x,provider:"x"}),Se=t=>p({...t,...d.twitter,provider:"twitter"}),Pe=t=>p({...t,...d.microsoft,provider:"microsoft"}),ye=t=>p({...t,...d.discord,provider:"discord"}),Be=t=>p({...t,...d.linkedin,provider:"linkedin"}),qe=t=>p({...t,...d.instagram,provider:"instagram"}),Ie=t=>p({...t,...d.tiktok,provider:"tiktok"}),xe=t=>p({...t,...d.snapchat,provider:"snapchat"}),Ae=t=>p({...t,...d.reddit,provider:"reddit"}),Ce=t=>p({...t,...d.pinterest,provider:"pinterest"}),Te=t=>p({...t,...d.twitch,provider:"twitch"}),$e=t=>p({...t,...d.steam,provider:"steam"}),Ee=t=>p({...t,...d.epic,provider:"epic"}),Me=t=>p({...t,...d.playstation,provider:"playstation"}),ze=t=>p({...t,...d.xbox,provider:"xbox"}),Re=t=>p({...t,...d.whatsapp,provider:"whatsapp"}),Ue=t=>p({...t,...d.wechat,provider:"wechat"}),Oe=t=>p({...t,...d.amazon,provider:"amazon"}),We=t=>p({...t,...d.yahoo,provider:"yahoo"}),Fe=t=>p({...t,...d.paypal,provider:"paypal"});function W({providers:t,onSocialLogin:o}){return q.Stack(K({providers:t,onProviderClick:o}))}function Q({mode:t,socialProviders:o,initialName:n,initialEmail:a,passwordRules:c,showRememberMe:s,showSocialDivider:u,showPasswordStrength:r,labels:l,onSignIn:i,onSignUp:h,onResetPassword:w,onModeChange:b,onSocialLogin:_,showContainer:v},...U){const B=t!=null?e.Value.deriveProp(t):e.prop("signin");return B.on(S=>b?.(S)),e.Use(m.AuthI18n,S=>{function x(){const g=e.coalesce(l?.hasAccountLink,S.$.hasAccountLink);return e.html.button(e.attr.type("button"),e.attr.class("bc-auth-form__link"),e.on.click(()=>B.set("signin")),g)}function O(){return e.html.button(e.attr.type("button"),e.attr.class("bc-auth-form__link"),e.on.click(()=>B.set("signup")),e.coalesce(l?.noAccountLink,S.$.noAccountLink))}function I(){return e.html.button(e.attr.type("button"),e.attr.class("bc-auth-form__link"),e.on.click(()=>B.set("reset-password")),e.coalesce(l?.forgotPasswordLink,S.$.forgotPasswordLink))}return e.html.div(oe.classes({"bc-auth-container":!0,"bc-auth-container--styled":e.Value.map(v??!0,g=>g)}),e.attr.class(B.map(g=>`bc-auth-container--${g}`)),e.attr.class("bc-auth-form"),e.OneOfValue(B,{signin:()=>e.Fragment(e.html.h2(e.attr.class("bc-auth-form__title"),e.coalesce(l?.signInTitle,S.$.signInTitle)),o!=null?e.Fragment(W({providers:o,onSocialLogin:_}),e.When(u??!1,F)):null,X({onSignIn:i,showRememberMe:s,passwordRules:c,labels:{emailLabel:l?.emailLabel,passwordLabel:l?.passwordLabel,rememberMeLabel:l?.rememberMeLabel,signInButton:l?.signInButton,forgotPasswordLink:l?.forgotPasswordLink,noAccountLink:l?.noAccountLink}}),q.Stack(e.attr.class("bc-auth-form__footer"),O(),I())),signup:()=>e.Fragment(e.html.h2(e.attr.class("bc-auth-form__title"),e.coalesce(l?.signUpTitle,S.$.signUpTitle)),o!=null?e.Fragment(W({providers:o,onSocialLogin:_}),e.When(u??!1,F)):null,Z({labels:{nameLabel:l?.nameLabel,emailLabel:l?.emailLabel,passwordLabel:l?.passwordLabel,confirmPasswordLabel:l?.confirmPasswordLabel,acceptTermsLabel:l?.acceptTermsLabel,signUpButton:l?.signUpButton,hasAccountLink:l?.hasAccountLink},initialEmail:a,initialName:n,onSignUp:h,passwordRules:c,showPasswordStrength:r}),q.Stack(e.attr.class("bc-auth-form__footer"),x())),"reset-password":()=>e.Fragment(e.html.h2(e.attr.class("bc-auth-form__title"),e.coalesce(l?.resetPasswordTitle,S.$.resetPasswordTitle)),J({labels:{backToSignInLink:l?.backToSignInLink,emailLabel:l?.emailLabel,resetPasswordButton:l?.resetPasswordButton,resetPasswordDescription:l?.resetPasswordDescription},onResetPassword:w}),q.Stack(e.attr.class("bc-auth-form__footer"),x()))}),...U)})}function Ve(t){return f.Modal({size:"sm",dismissable:!0,showCloseButton:!0},(o,n)=>t(a=>o({body:Q({showContainer:!1,...a}),header:e.Use(m.AuthI18n,c=>e.coalesce(a.modalTitle,c.$.authenticationTitle))})))}function F({labels:t,className:o}={}){return e.html.div(e.attr.class("bc-auth-divider"),e.attr.class(o),e.html.div(e.attr.class("bc-auth-divider__line")),e.Use(m.AuthI18n,n=>e.html.span(e.attr.class("bc-auth-divider__text"),e.coalesce(t?.text,n.$.orDivider))),e.html.div(e.attr.class("bc-auth-divider__line")))}exports.AmazonLoginButton=Oe;exports.AppleLoginButton=_e;exports.AuthContainer=Q;exports.AuthDivider=F;exports.AuthModal=Ve;exports.DiscordLoginButton=ye;exports.EpicLoginButton=Ee;exports.FacebookLoginButton=ke;exports.GitHubLoginButton=Le;exports.GoogleLoginButton=be;exports.InstagramLoginButton=qe;exports.LinkedInLoginButton=Be;exports.MicrosoftLoginButton=Pe;exports.PasswordStrengthBar=fe;exports.PasswordStrengthIndicator=Y;exports.PasswordStrengthText=we;exports.PayPalLoginButton=Fe;exports.PinterestLoginButton=Ce;exports.PlayStationLoginButton=Me;exports.RedditLoginButton=Ae;exports.ResetPasswordForm=J;exports.SignInForm=X;exports.SignUpForm=Z;exports.SnapchatLoginButton=xe;exports.SocialLoginButton=p;exports.SocialLoginButtons=K;exports.SocialProviders=W;exports.SteamLoginButton=$e;exports.TiktokLoginButton=Ie;exports.TwitchLoginButton=Te;exports.TwitterLoginButton=Se;exports.WeChatLoginButton=Ue;exports.WhatsAppLoginButton=Re;exports.XLoginButtin=ve;exports.XboxLoginButton=ze;exports.YahooLoginButton=We;exports.authSchemas=pe;exports.calculatePasswordStrength=R;exports.createEmailSchema=A;exports.createPasswordSchema=E;exports.createSignInSchema=M;exports.createSignUpSchema=z;exports.createSocialLoginUrl=ie;exports.defaultPasswordRules=y;exports.defaultSignInSchema=me;exports.defaultSignUpSchema=de;exports.emailSchema=V;exports.formatAuthError=le;exports.formatProviderName=j;exports.formatSocialLoginText=re;exports.generateRandomString=H;exports.getProviderColor=ne;exports.getProviderIcon=ae;exports.isBrowser=ue;exports.isValidEmail=se;exports.openSocialLoginPopup=ce;exports.providerInfo=T;exports.requestToControllerValidation=$;exports.resetPasswordSchema=N;exports.socialProviderInfo=d;exports.useAuthEmailProp=D;exports.validateEmail=he;exports.validatePassword=ge;
|
package/dist/beatui.css
CHANGED
|
@@ -3357,7 +3357,10 @@ a:focus-visible {
|
|
|
3357
3357
|
|
|
3358
3358
|
.bc-color-swatch-input__control {
|
|
3359
3359
|
position: relative;
|
|
3360
|
-
display: inline-
|
|
3360
|
+
display: inline-flex;
|
|
3361
|
+
align-items: center;
|
|
3362
|
+
justify-content: center;
|
|
3363
|
+
flex: 0 0 auto;
|
|
3361
3364
|
border-radius: var(--radius-control, var(--radius-md));
|
|
3362
3365
|
overflow: visible;
|
|
3363
3366
|
cursor: pointer;
|
|
@@ -3472,13 +3475,6 @@ a:focus-visible {
|
|
|
3472
3475
|
outline: var(--outline-width-focus) solid var(--color-danger-400);
|
|
3473
3476
|
}
|
|
3474
3477
|
|
|
3475
|
-
/* Responsive styles */
|
|
3476
|
-
@media (width >= 40rem) {
|
|
3477
|
-
.bc-color-swatch-input__control {
|
|
3478
|
-
width: calc(var(--spacing-base) * 11);
|
|
3479
|
-
height: calc(var(--spacing-base) * 9);
|
|
3480
|
-
}
|
|
3481
|
-
}
|
|
3482
3478
|
|
|
3483
3479
|
.bc-command-palette {
|
|
3484
3480
|
display: flex;
|
package/dist/beatui.tailwind.css
CHANGED
|
@@ -3023,7 +3023,10 @@ a:focus-visible {
|
|
|
3023
3023
|
|
|
3024
3024
|
.bc-color-swatch-input__control {
|
|
3025
3025
|
position: relative;
|
|
3026
|
-
display: inline-
|
|
3026
|
+
display: inline-flex;
|
|
3027
|
+
align-items: center;
|
|
3028
|
+
justify-content: center;
|
|
3029
|
+
flex: 0 0 auto;
|
|
3027
3030
|
border-radius: var(--radius-control, var(--radius-md));
|
|
3028
3031
|
overflow: visible;
|
|
3029
3032
|
cursor: pointer;
|
|
@@ -3138,13 +3141,6 @@ a:focus-visible {
|
|
|
3138
3141
|
outline: var(--outline-width-focus) solid var(--color-danger-400);
|
|
3139
3142
|
}
|
|
3140
3143
|
|
|
3141
|
-
/* Responsive styles */
|
|
3142
|
-
@media (width >= 40rem) {
|
|
3143
|
-
.bc-color-swatch-input__control {
|
|
3144
|
-
width: calc(var(--spacing-base) * 11);
|
|
3145
|
-
height: calc(var(--spacing-base) * 9);
|
|
3146
|
-
}
|
|
3147
|
-
}
|
|
3148
3144
|
|
|
3149
3145
|
.bc-command-palette {
|
|
3150
3146
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@tempots/dom"),L=require("../auth-divider-DvnUModP.cjs"),I=require("../translations-Dbx7L7Q1.cjs"),w=require("../notice-_9XhdrFw.cjs"),y=require("../stack-dwLevGa2.cjs"),b=require("../input-container-Di1YvVB_.cjs"),v=require("../text-input-X_q01NsY.cjs");function g(a,t){return a.error?(t.onError?.({message:a.error.message,status:a.error.status}),a.error.message):null}function F(a,t,s){return async n=>{const i=await a.signIn.email({email:n.email,password:n.password,callbackURL:t.callbackURL}),o=g(i,t);return o||(await s(),null)}}function A(a,t,s){return async n=>{const i=await a.signUp.email({name:n.name,email:n.email,password:n.password,callbackURL:t.callbackURL}),o=g(i,t);return o||(await s(),null)}}function U(a,t){return async s=>{const n=await a.requestPasswordReset({email:s.email,redirectTo:t.callbackURL});return g(n,t)}}function $(a,t){return async s=>{const n=await a.signIn.social({provider:s,callbackURL:t.callbackURL,errorCallbackURL:t.errorCallbackURL});g(n,t)}}function P(a,t={}){const s=e.prop(null),n=e.prop(!0),i=e.computedOf(s)(h=>h?.user??null),o=e.computedOf(s)(h=>h!=null);let u;async function d(){try{const h=await a.getSession();h.error||!h.data?s.set(null):s.set({user:h.data.user,session:h.data.session})}catch{s.set(null)}finally{n.set(!1)}}t.onSessionChange&&s.on(t.onSessionChange),d(),t.refreshInterval&&t.refreshInterval>0&&(u=setInterval(d,t.refreshInterval));function p(){u!=null&&(clearInterval(u),u=void 0),s.dispose(),n.dispose(),i.dispose(),o.dispose()}return{session:s,isPending:n,user:i,isAuthenticated:o,refresh:d,dispose:p}}function _(a){return a.map(t=>({provider:t}))}function C(a,t={}){const s=P(a,{refreshInterval:t.refreshInterval,onSessionChange:t.onSessionChange}),n=()=>s.refresh(),i=F(a,t,n),o=A(a,t,n),u=U(a,t),d=$(a,t),p=t.socialProviders?_(t.socialProviders):[],h={onSignIn:i,passwordRules:t.passwordRules,showRememberMe:t.showRememberMe,labels:t.labels?{emailLabel:t.labels.emailLabel,passwordLabel:t.labels.passwordLabel,rememberMeLabel:t.labels.rememberMeLabel,signInButton:t.labels.signInButton,forgotPasswordLink:t.labels.forgotPasswordLink,noAccountLink:t.labels.noAccountLink}:void 0},c={onSignUp:o,passwordRules:t.passwordRules,showPasswordStrength:t.showPasswordStrength,showNameField:t.showNameField,showConfirmPassword:t.showConfirmPassword,labels:t.labels?{nameLabel:t.labels.nameLabel,emailLabel:t.labels.emailLabel,passwordLabel:t.labels.passwordLabel,confirmPasswordLabel:t.labels.confirmPasswordLabel,acceptTermsLabel:t.labels.acceptTermsLabel,signUpButton:t.labels.signUpButton,hasAccountLink:t.labels.hasAccountLink}:void 0},m={onResetPassword:u,labels:t.labels?{resetPasswordButton:t.labels.resetPasswordButton,resetPasswordDescription:t.labels.resetPasswordDescription,emailLabel:t.labels.emailLabel,backToSignInLink:t.labels.backToSignInLink}:void 0},l={onSignIn:i,onSignUp:o,onResetPassword:u,onSocialLogin:d,socialProviders:p.length>0?p:void 0,showSocialDivider:p.length>0,passwordRules:t.passwordRules,showRememberMe:t.showRememberMe,showPasswordStrength:t.showPasswordStrength,showNameField:t.showNameField,showConfirmPassword:t.showConfirmPassword,labels:t.labels};async function r(){await a.signOut(),await n()}function f(){s.dispose()}return{session:s.session,isPending:s.isPending,user:s.user,isAuthenticated:s.isAuthenticated,containerOptions:l,signInOptions:h,signUpOptions:c,resetOptions:m,socialProviders:p,signOut:r,refreshSession:n,dispose:f}}const R={mark:e.makeProviderMark("BetterAuth"),create:a=>{if(!a)throw new Error("BetterAuth provider requires a client option");const t=C(a.client,a);return{value:t,dispose:()=>t.dispose()}}};function E(a,t,...s){return L.AuthContainer({...a.containerOptions,...t},...s)}function O(a,t){return L.AuthModal(s=>t(n=>s({...a.containerOptions,...n})))}function M(a,t){return e.When(a.isAuthenticated,t)}function D(a,t){return e.Unless(a.isAuthenticated,t)}const T={twoFactorSetupDescription:"Enter your password to enable two-factor authentication.",twoFactorEnableButton:"Enable 2FA",twoFactorVerifyButton:"Verify",twoFactorScanDescription:"Scan the code below with your authenticator app, then enter the verification code.",twoFactorBackupCodesDescription:"Save these backup codes in a safe place. You can use them to sign in if you lose access to your authenticator.",twoFactorCodePlaceholder:"Enter 6-digit code",twoFactorBackupCodePlaceholder:"Enter backup code",twoFactorEnabled:"Two-factor authentication has been enabled.",twoFactorTotpDescription:"Enter the code from your authenticator app.",twoFactorOtpDescription:"Enter the one-time code sent to you.",twoFactorBackupDescription:"Enter one of your backup codes.",twoFactorSendOtpButton:"Send Code",twoFactorMethodLabel:a=>{switch(a){case"totp":return"Authenticator";case"otp":return"Email/SMS";case"backup":return"Backup Code";default:return a}},passwordPlaceholder:"Enter your password",magicLinkDescription:"Enter your email to receive a sign-in link.",magicLinkSendButton:"Send Magic Link",magicLinkSent:"A sign-in link has been sent to your email.",passkeySignInButton:"Sign in with Passkey",passkeyAddButton:"Add Passkey",passkeyDeleteButton:"Delete",passkeyRenameButton:"Rename",passkeySaveButton:"Save",passkeyCancelButton:"Cancel",passkeyNamePlaceholder:"Passkey name (optional)",passkeyUnnamed:"Unnamed passkey"},B=T,S="en",N=Object.assign({}),k=I.makeI18nProvider({defaultLocale:S,defaultMessages:B,localeLoader:async a=>{if(a===S)return B;const t=N[`./locales/${a}.ts`];return t?await t():B},providerName:"BetterAuthI18n"});function q({twoFactor:a,issuer:t,onComplete:s}){const n=e.prop(""),i=e.prop(null),o=e.prop([]),u=e.prop(""),d=e.prop(null),p=e.prop(!1),h=e.prop("password");async function c(l){l.preventDefault(),p.set(!0),d.set(null);const r=await a.enable({password:n.value,issuer:t});if(p.set(!1),r.error){d.set(r.error.message);return}r.data&&(i.set(r.data.totpURI),o.set(r.data.backupCodes),h.set("verify"))}async function m(l){l.preventDefault(),p.set(!0),d.set(null);const r=await a.verifyTotp({code:u.value});if(p.set(!1),r.error){d.set(r.error.message);return}h.set("complete"),s?.()}return e.Use(k,l=>e.html.div(e.attr.class("bc-two-factor"),e.Ensure(d,r=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(r))),e.OneOfValue(h,{password:()=>e.html.form(e.attr.class("bc-two-factor__form"),e.on.submit(c),y.Stack(e.html.p(e.attr.class("bc-auth-form__description"),l.$.twoFactorSetupDescription),w.PasswordInput({value:n,onChange:r=>n.set(r),placeholder:l.$.passwordPlaceholder}),b.Button({type:"submit",variant:"filled",color:"primary",loading:p},e.attr.class("bc-auth-form__submit"),l.$.twoFactorEnableButton))),verify:()=>e.Fragment(e.Ensure(i,r=>e.html.div(e.attr.class("bc-two-factor__totp-uri"),e.html.p(l.$.twoFactorScanDescription),e.html.code(e.attr.class("bc-two-factor__code-display"),r))),e.NotEmpty(o,()=>e.html.div(e.attr.class("bc-two-factor__backup-codes"),e.html.p(l.$.twoFactorBackupCodesDescription),e.html.ul(e.ForEach(o,r=>e.html.li(r))))),e.html.form(e.attr.class("bc-two-factor__form"),e.on.submit(m),y.Stack(v.TextInput({value:u,onChange:r=>u.set(r),placeholder:l.$.twoFactorCodePlaceholder}),b.Button({type:"submit",variant:"filled",color:"primary",loading:p},e.attr.class("bc-auth-form__submit"),l.$.twoFactorVerifyButton)))),complete:()=>e.html.div(e.attr.class("bc-two-factor__complete"),w.Notice({variant:"success",tone:"prominent"},e.html.div(l.$.twoFactorEnabled)))})))}function x({twoFactor:a,methods:t=["totp","backup"],trustDevice:s,onVerified:n}){const i=e.prop(""),o=e.prop(null),u=e.prop(!1),d=e.prop(t[0]??"totp");async function p(c){c.preventDefault(),u.set(!0),o.set(null);const m=d.value;let l;if(m==="totp")l=await a.verifyTotp({code:i.value,trustDevice:s});else if(m==="otp"&&a.verifyOtp)l=await a.verifyOtp({code:i.value,trustDevice:s});else if(m==="backup")l=await a.verifyBackupCode({code:i.value});else{o.set("Unsupported verification method"),u.set(!1);return}if(u.set(!1),l.error){o.set(l.error.message);return}n?.()}async function h(){if(!a.sendOtp)return;u.set(!0),o.set(null);const c=await a.sendOtp({trustDevice:s});u.set(!1),c.error&&o.set(c.error.message)}return e.Use(k,c=>{const m=e.computedOf(d,c)((r,f)=>r==="totp"?f.twoFactorTotpDescription:r==="otp"?f.twoFactorOtpDescription:f.twoFactorBackupDescription),l=e.computedOf(d,c)((r,f)=>r==="backup"?f.twoFactorBackupCodePlaceholder:f.twoFactorCodePlaceholder);return e.html.div(e.attr.class("bc-two-factor"),e.Ensure(o,r=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(r))),e.When(t.length>1,()=>e.html.div(e.attr.class("bc-two-factor__methods"),...t.map(r=>e.html.button(e.attr.type("button"),e.attr.class("bc-two-factor__method-button"),e.attr.class(d.map(f=>f===r?"bc-two-factor__method-button--active":"")),e.on.click(()=>{d.set(r),i.set(""),o.set(null)}),c.$.twoFactorMethodLabel.map(f=>f(r)))))),e.html.form(e.attr.class("bc-two-factor__form"),e.on.submit(p),y.Stack(e.html.p(e.attr.class("bc-auth-form__description"),m),e.When(d.map(r=>r==="otp"&&a.sendOtp!=null),()=>b.Button({type:"button",variant:"outline",color:"primary",onClick:h,loading:u},c.$.twoFactorSendOtpButton)),v.TextInput({value:i,onChange:r=>i.set(r),placeholder:l}),b.Button({type:"submit",variant:"filled",color:"primary",loading:u},e.attr.class("bc-auth-form__submit"),c.$.twoFactorVerifyButton))))})}function V({client:a,callbackURL:t}){const s=e.prop(""),n=e.prop(null),i=e.prop(!1),o=e.prop(!1);async function u(d){if(d.preventDefault(),!a.signIn.magicLink){n.set("Magic link sign-in is not configured");return}i.set(!0),n.set(null);const p=await a.signIn.magicLink({email:s.value,callbackURL:t});if(i.set(!1),p.error){n.set(p.error.message);return}o.set(!0)}return e.Use(k,d=>e.html.div(e.attr.class("bc-auth-form"),e.Ensure(n,p=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(p))),e.Unless(o,()=>e.html.form(e.attr.class("bc-auth-form__form"),e.on.submit(u),y.Stack(e.attr.class("bc-auth-form__fields"),e.html.p(e.attr.class("bc-auth-form__description"),d.$.magicLinkDescription),w.NativeEmailInput({value:s,onChange:p=>s.set(p)}),b.Button({type:"submit",variant:"filled",color:"primary",loading:i},e.attr.class("bc-auth-form__submit"),d.$.magicLinkSendButton)))),e.When(o,()=>w.Notice({variant:"success",tone:"prominent"},e.html.div(d.$.magicLinkSent)))))}function W({client:a,autoFill:t,onSuccess:s,onError:n}){const i=e.prop(!1);async function o(){if(!a.signIn.passkey)return;i.set(!0);const u=await a.signIn.passkey({autoFill:t});if(i.set(!1),u.error){n?.({message:u.error.message,status:u.error.status});return}s?.()}return e.Use(k,u=>b.Button({type:"button",variant:"outline",color:"primary",onClick:o,loading:i},e.attr.class("bc-passkey-signin"),u.$.passkeySignInButton))}function z({passkey:a}){const t=e.prop([]),s=e.prop(null),n=e.prop(!1),i=e.prop("");async function o(c,m){n.set(!0),s.set(null);const l=await c();if(n.set(!1),l.error){s.set(l.error.message);return}await m?.(l.data)}async function u(){await o(()=>a.listUserPasskeys(),c=>t.set(c??[]))}async function d(){const c=i.value||void 0;await o(()=>a.addPasskey({name:c}),async()=>{i.set(""),await u()})}async function p(c){await o(()=>a.deletePasskey({id:c}),()=>u())}async function h(c,m){await o(()=>a.updatePasskey({id:c,name:m}),()=>u())}return u(),e.Use(k,c=>e.html.div(e.attr.class("bc-passkey-management"),e.Ensure(s,m=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(m))),e.html.div(e.attr.class("bc-passkey-list"),e.ForEach(t,m=>{const l=e.prop(!1),r=e.prop(m.$.name?.value??"");return e.html.div(e.attr.class("bc-passkey-item"),e.Unless(l,()=>e.html.div(e.attr.class("bc-passkey-item__info"),e.html.span(e.attr.class("bc-passkey-item__name"),m.$.name?.map(f=>f??c.$.passkeyUnnamed.value)??c.$.passkeyUnnamed),e.html.span(e.attr.class("bc-passkey-item__date"),m.$.createdAt))),e.When(l,()=>e.html.div(e.attr.class("bc-passkey-item__edit"),v.TextInput({value:r,onChange:f=>r.set(f)}))),e.html.div(e.attr.class("bc-passkey-item__actions"),e.Unless(l,()=>e.html.div(b.Button({type:"button",variant:"text",size:"sm",onClick:()=>{r.set(m.$.name?.value??""),l.set(!0)}},c.$.passkeyRenameButton),b.Button({type:"button",variant:"text",size:"sm",color:"danger",onClick:()=>p(m.$.id.value)},c.$.passkeyDeleteButton))),e.When(l,()=>e.html.div(b.Button({type:"button",variant:"text",size:"sm",onClick:async()=>{await h(m.$.id.value,r.value),l.set(!1)}},c.$.passkeySaveButton),b.Button({type:"button",variant:"text",size:"sm",onClick:()=>l.set(!1)},c.$.passkeyCancelButton)))))})),e.html.div(e.attr.class("bc-passkey-add"),y.Stack(v.TextInput({value:i,onChange:m=>i.set(m),placeholder:c.$.passkeyNamePlaceholder}),b.Button({type:"button",variant:"filled",color:"primary",onClick:d,loading:n},c.$.passkeyAddButton)))))}exports.Authenticated=M;exports.BetterAuth=R;exports.BetterAuthContainer=E;exports.BetterAuthI18n=k;exports.BetterAuthModal=O;exports.MagicLinkForm=V;exports.PasskeyManagement=z;exports.PasskeySignIn=W;exports.TwoFactorSetup=q;exports.TwoFactorVerify=x;exports.Unauthenticated=D;exports.createBetterAuthBridge=C;exports.createSessionManager=P;exports.mapSocialProviders=_;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@tempots/dom"),L=require("../auth-divider-MMhfmLBu.cjs"),I=require("../translations-Dbx7L7Q1.cjs"),w=require("../notice-B5wTXoTq.cjs"),y=require("../stack-dwLevGa2.cjs"),b=require("../input-container-Di1YvVB_.cjs"),v=require("../text-input-X_q01NsY.cjs");function g(a,t){return a.error?(t.onError?.({message:a.error.message,status:a.error.status}),a.error.message):null}function F(a,t,s){return async n=>{const i=await a.signIn.email({email:n.email,password:n.password,callbackURL:t.callbackURL}),o=g(i,t);return o||(await s(),null)}}function A(a,t,s){return async n=>{const i=await a.signUp.email({name:n.name,email:n.email,password:n.password,callbackURL:t.callbackURL}),o=g(i,t);return o||(await s(),null)}}function U(a,t){return async s=>{const n=await a.requestPasswordReset({email:s.email,redirectTo:t.callbackURL});return g(n,t)}}function $(a,t){return async s=>{const n=await a.signIn.social({provider:s,callbackURL:t.callbackURL,errorCallbackURL:t.errorCallbackURL});g(n,t)}}function P(a,t={}){const s=e.prop(null),n=e.prop(!0),i=e.computedOf(s)(h=>h?.user??null),o=e.computedOf(s)(h=>h!=null);let u;async function d(){try{const h=await a.getSession();h.error||!h.data?s.set(null):s.set({user:h.data.user,session:h.data.session})}catch{s.set(null)}finally{n.set(!1)}}t.onSessionChange&&s.on(t.onSessionChange),d(),t.refreshInterval&&t.refreshInterval>0&&(u=setInterval(d,t.refreshInterval));function p(){u!=null&&(clearInterval(u),u=void 0),s.dispose(),n.dispose(),i.dispose(),o.dispose()}return{session:s,isPending:n,user:i,isAuthenticated:o,refresh:d,dispose:p}}function _(a){return a.map(t=>({provider:t}))}function C(a,t={}){const s=P(a,{refreshInterval:t.refreshInterval,onSessionChange:t.onSessionChange}),n=()=>s.refresh(),i=F(a,t,n),o=A(a,t,n),u=U(a,t),d=$(a,t),p=t.socialProviders?_(t.socialProviders):[],h={onSignIn:i,passwordRules:t.passwordRules,showRememberMe:t.showRememberMe,labels:t.labels?{emailLabel:t.labels.emailLabel,passwordLabel:t.labels.passwordLabel,rememberMeLabel:t.labels.rememberMeLabel,signInButton:t.labels.signInButton,forgotPasswordLink:t.labels.forgotPasswordLink,noAccountLink:t.labels.noAccountLink}:void 0},c={onSignUp:o,passwordRules:t.passwordRules,showPasswordStrength:t.showPasswordStrength,showNameField:t.showNameField,showConfirmPassword:t.showConfirmPassword,labels:t.labels?{nameLabel:t.labels.nameLabel,emailLabel:t.labels.emailLabel,passwordLabel:t.labels.passwordLabel,confirmPasswordLabel:t.labels.confirmPasswordLabel,acceptTermsLabel:t.labels.acceptTermsLabel,signUpButton:t.labels.signUpButton,hasAccountLink:t.labels.hasAccountLink}:void 0},m={onResetPassword:u,labels:t.labels?{resetPasswordButton:t.labels.resetPasswordButton,resetPasswordDescription:t.labels.resetPasswordDescription,emailLabel:t.labels.emailLabel,backToSignInLink:t.labels.backToSignInLink}:void 0},l={onSignIn:i,onSignUp:o,onResetPassword:u,onSocialLogin:d,socialProviders:p.length>0?p:void 0,showSocialDivider:p.length>0,passwordRules:t.passwordRules,showRememberMe:t.showRememberMe,showPasswordStrength:t.showPasswordStrength,showNameField:t.showNameField,showConfirmPassword:t.showConfirmPassword,labels:t.labels};async function r(){await a.signOut(),await n()}function f(){s.dispose()}return{session:s.session,isPending:s.isPending,user:s.user,isAuthenticated:s.isAuthenticated,containerOptions:l,signInOptions:h,signUpOptions:c,resetOptions:m,socialProviders:p,signOut:r,refreshSession:n,dispose:f}}const R={mark:e.makeProviderMark("BetterAuth"),create:a=>{if(!a)throw new Error("BetterAuth provider requires a client option");const t=C(a.client,a);return{value:t,dispose:()=>t.dispose()}}};function E(a,t,...s){return L.AuthContainer({...a.containerOptions,...t},...s)}function O(a,t){return L.AuthModal(s=>t(n=>s({...a.containerOptions,...n})))}function M(a,t){return e.When(a.isAuthenticated,t)}function D(a,t){return e.Unless(a.isAuthenticated,t)}const T={twoFactorSetupDescription:"Enter your password to enable two-factor authentication.",twoFactorEnableButton:"Enable 2FA",twoFactorVerifyButton:"Verify",twoFactorScanDescription:"Scan the code below with your authenticator app, then enter the verification code.",twoFactorBackupCodesDescription:"Save these backup codes in a safe place. You can use them to sign in if you lose access to your authenticator.",twoFactorCodePlaceholder:"Enter 6-digit code",twoFactorBackupCodePlaceholder:"Enter backup code",twoFactorEnabled:"Two-factor authentication has been enabled.",twoFactorTotpDescription:"Enter the code from your authenticator app.",twoFactorOtpDescription:"Enter the one-time code sent to you.",twoFactorBackupDescription:"Enter one of your backup codes.",twoFactorSendOtpButton:"Send Code",twoFactorMethodLabel:a=>{switch(a){case"totp":return"Authenticator";case"otp":return"Email/SMS";case"backup":return"Backup Code";default:return a}},passwordPlaceholder:"Enter your password",magicLinkDescription:"Enter your email to receive a sign-in link.",magicLinkSendButton:"Send Magic Link",magicLinkSent:"A sign-in link has been sent to your email.",passkeySignInButton:"Sign in with Passkey",passkeyAddButton:"Add Passkey",passkeyDeleteButton:"Delete",passkeyRenameButton:"Rename",passkeySaveButton:"Save",passkeyCancelButton:"Cancel",passkeyNamePlaceholder:"Passkey name (optional)",passkeyUnnamed:"Unnamed passkey"},B=T,S="en",N=Object.assign({}),k=I.makeI18nProvider({defaultLocale:S,defaultMessages:B,localeLoader:async a=>{if(a===S)return B;const t=N[`./locales/${a}.ts`];return t?await t():B},providerName:"BetterAuthI18n"});function q({twoFactor:a,issuer:t,onComplete:s}){const n=e.prop(""),i=e.prop(null),o=e.prop([]),u=e.prop(""),d=e.prop(null),p=e.prop(!1),h=e.prop("password");async function c(l){l.preventDefault(),p.set(!0),d.set(null);const r=await a.enable({password:n.value,issuer:t});if(p.set(!1),r.error){d.set(r.error.message);return}r.data&&(i.set(r.data.totpURI),o.set(r.data.backupCodes),h.set("verify"))}async function m(l){l.preventDefault(),p.set(!0),d.set(null);const r=await a.verifyTotp({code:u.value});if(p.set(!1),r.error){d.set(r.error.message);return}h.set("complete"),s?.()}return e.Use(k,l=>e.html.div(e.attr.class("bc-two-factor"),e.Ensure(d,r=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(r))),e.OneOfValue(h,{password:()=>e.html.form(e.attr.class("bc-two-factor__form"),e.on.submit(c),y.Stack(e.html.p(e.attr.class("bc-auth-form__description"),l.$.twoFactorSetupDescription),w.PasswordInput({value:n,onChange:r=>n.set(r),placeholder:l.$.passwordPlaceholder}),b.Button({type:"submit",variant:"filled",color:"primary",loading:p},e.attr.class("bc-auth-form__submit"),l.$.twoFactorEnableButton))),verify:()=>e.Fragment(e.Ensure(i,r=>e.html.div(e.attr.class("bc-two-factor__totp-uri"),e.html.p(l.$.twoFactorScanDescription),e.html.code(e.attr.class("bc-two-factor__code-display"),r))),e.NotEmpty(o,()=>e.html.div(e.attr.class("bc-two-factor__backup-codes"),e.html.p(l.$.twoFactorBackupCodesDescription),e.html.ul(e.ForEach(o,r=>e.html.li(r))))),e.html.form(e.attr.class("bc-two-factor__form"),e.on.submit(m),y.Stack(v.TextInput({value:u,onChange:r=>u.set(r),placeholder:l.$.twoFactorCodePlaceholder}),b.Button({type:"submit",variant:"filled",color:"primary",loading:p},e.attr.class("bc-auth-form__submit"),l.$.twoFactorVerifyButton)))),complete:()=>e.html.div(e.attr.class("bc-two-factor__complete"),w.Notice({variant:"success",tone:"prominent"},e.html.div(l.$.twoFactorEnabled)))})))}function x({twoFactor:a,methods:t=["totp","backup"],trustDevice:s,onVerified:n}){const i=e.prop(""),o=e.prop(null),u=e.prop(!1),d=e.prop(t[0]??"totp");async function p(c){c.preventDefault(),u.set(!0),o.set(null);const m=d.value;let l;if(m==="totp")l=await a.verifyTotp({code:i.value,trustDevice:s});else if(m==="otp"&&a.verifyOtp)l=await a.verifyOtp({code:i.value,trustDevice:s});else if(m==="backup")l=await a.verifyBackupCode({code:i.value});else{o.set("Unsupported verification method"),u.set(!1);return}if(u.set(!1),l.error){o.set(l.error.message);return}n?.()}async function h(){if(!a.sendOtp)return;u.set(!0),o.set(null);const c=await a.sendOtp({trustDevice:s});u.set(!1),c.error&&o.set(c.error.message)}return e.Use(k,c=>{const m=e.computedOf(d,c)((r,f)=>r==="totp"?f.twoFactorTotpDescription:r==="otp"?f.twoFactorOtpDescription:f.twoFactorBackupDescription),l=e.computedOf(d,c)((r,f)=>r==="backup"?f.twoFactorBackupCodePlaceholder:f.twoFactorCodePlaceholder);return e.html.div(e.attr.class("bc-two-factor"),e.Ensure(o,r=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(r))),e.When(t.length>1,()=>e.html.div(e.attr.class("bc-two-factor__methods"),...t.map(r=>e.html.button(e.attr.type("button"),e.attr.class("bc-two-factor__method-button"),e.attr.class(d.map(f=>f===r?"bc-two-factor__method-button--active":"")),e.on.click(()=>{d.set(r),i.set(""),o.set(null)}),c.$.twoFactorMethodLabel.map(f=>f(r)))))),e.html.form(e.attr.class("bc-two-factor__form"),e.on.submit(p),y.Stack(e.html.p(e.attr.class("bc-auth-form__description"),m),e.When(d.map(r=>r==="otp"&&a.sendOtp!=null),()=>b.Button({type:"button",variant:"outline",color:"primary",onClick:h,loading:u},c.$.twoFactorSendOtpButton)),v.TextInput({value:i,onChange:r=>i.set(r),placeholder:l}),b.Button({type:"submit",variant:"filled",color:"primary",loading:u},e.attr.class("bc-auth-form__submit"),c.$.twoFactorVerifyButton))))})}function V({client:a,callbackURL:t}){const s=e.prop(""),n=e.prop(null),i=e.prop(!1),o=e.prop(!1);async function u(d){if(d.preventDefault(),!a.signIn.magicLink){n.set("Magic link sign-in is not configured");return}i.set(!0),n.set(null);const p=await a.signIn.magicLink({email:s.value,callbackURL:t});if(i.set(!1),p.error){n.set(p.error.message);return}o.set(!0)}return e.Use(k,d=>e.html.div(e.attr.class("bc-auth-form"),e.Ensure(n,p=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(p))),e.Unless(o,()=>e.html.form(e.attr.class("bc-auth-form__form"),e.on.submit(u),y.Stack(e.attr.class("bc-auth-form__fields"),e.html.p(e.attr.class("bc-auth-form__description"),d.$.magicLinkDescription),w.EmailInput({value:s,onChange:p=>s.set(p)}),b.Button({type:"submit",variant:"filled",color:"primary",loading:i},e.attr.class("bc-auth-form__submit"),d.$.magicLinkSendButton)))),e.When(o,()=>w.Notice({variant:"success",tone:"prominent"},e.html.div(d.$.magicLinkSent)))))}function W({client:a,autoFill:t,onSuccess:s,onError:n}){const i=e.prop(!1);async function o(){if(!a.signIn.passkey)return;i.set(!0);const u=await a.signIn.passkey({autoFill:t});if(i.set(!1),u.error){n?.({message:u.error.message,status:u.error.status});return}s?.()}return e.Use(k,u=>b.Button({type:"button",variant:"outline",color:"primary",onClick:o,loading:i},e.attr.class("bc-passkey-signin"),u.$.passkeySignInButton))}function z({passkey:a}){const t=e.prop([]),s=e.prop(null),n=e.prop(!1),i=e.prop("");async function o(c,m){n.set(!0),s.set(null);const l=await c();if(n.set(!1),l.error){s.set(l.error.message);return}await m?.(l.data)}async function u(){await o(()=>a.listUserPasskeys(),c=>t.set(c??[]))}async function d(){const c=i.value||void 0;await o(()=>a.addPasskey({name:c}),async()=>{i.set(""),await u()})}async function p(c){await o(()=>a.deletePasskey({id:c}),()=>u())}async function h(c,m){await o(()=>a.updatePasskey({id:c,name:m}),()=>u())}return u(),e.Use(k,c=>e.html.div(e.attr.class("bc-passkey-management"),e.Ensure(s,m=>w.Notice({variant:"danger",tone:"prominent",role:"alert"},e.html.div(m))),e.html.div(e.attr.class("bc-passkey-list"),e.ForEach(t,m=>{const l=e.prop(!1),r=e.prop(m.$.name?.value??"");return e.html.div(e.attr.class("bc-passkey-item"),e.Unless(l,()=>e.html.div(e.attr.class("bc-passkey-item__info"),e.html.span(e.attr.class("bc-passkey-item__name"),m.$.name?.map(f=>f??c.$.passkeyUnnamed.value)??c.$.passkeyUnnamed),e.html.span(e.attr.class("bc-passkey-item__date"),m.$.createdAt))),e.When(l,()=>e.html.div(e.attr.class("bc-passkey-item__edit"),v.TextInput({value:r,onChange:f=>r.set(f)}))),e.html.div(e.attr.class("bc-passkey-item__actions"),e.Unless(l,()=>e.html.div(b.Button({type:"button",variant:"text",size:"sm",onClick:()=>{r.set(m.$.name?.value??""),l.set(!0)}},c.$.passkeyRenameButton),b.Button({type:"button",variant:"text",size:"sm",color:"danger",onClick:()=>p(m.$.id.value)},c.$.passkeyDeleteButton))),e.When(l,()=>e.html.div(b.Button({type:"button",variant:"text",size:"sm",onClick:async()=>{await h(m.$.id.value,r.value),l.set(!1)}},c.$.passkeySaveButton),b.Button({type:"button",variant:"text",size:"sm",onClick:()=>l.set(!1)},c.$.passkeyCancelButton)))))})),e.html.div(e.attr.class("bc-passkey-add"),y.Stack(v.TextInput({value:i,onChange:m=>i.set(m),placeholder:c.$.passkeyNamePlaceholder}),b.Button({type:"button",variant:"filled",color:"primary",onClick:d,loading:n},c.$.passkeyAddButton)))))}exports.Authenticated=M;exports.BetterAuth=R;exports.BetterAuthContainer=E;exports.BetterAuthI18n=k;exports.BetterAuthModal=O;exports.MagicLinkForm=V;exports.PasskeyManagement=z;exports.PasskeySignIn=W;exports.TwoFactorSetup=q;exports.TwoFactorVerify=x;exports.Unauthenticated=D;exports.createBetterAuthBridge=C;exports.createSessionManager=P;exports.mapSocialProviders=_;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { prop as b, computedOf as B, makeProviderMark as U, When as y, Unless as C, Use as S, html as r, attr as l, Ensure as g, OneOfValue as D, Fragment as
|
|
2
|
-
import { b as M, d as T } from "../auth-divider-
|
|
1
|
+
import { prop as b, computedOf as B, makeProviderMark as U, When as y, Unless as C, Use as S, html as r, attr as l, Ensure as g, OneOfValue as D, Fragment as E, NotEmpty as O, ForEach as A, on as L } from "@tempots/dom";
|
|
2
|
+
import { b as M, d as T } from "../auth-divider-CbME_yVQ.js";
|
|
3
3
|
import { m as N } from "../translations-B1_yyDUK.js";
|
|
4
|
-
import {
|
|
4
|
+
import { N as v, P as V, E as x } from "../notice-BKcyJD5w.js";
|
|
5
5
|
import { S as P } from "../stack-BLMteGTn.js";
|
|
6
6
|
import { B as k } from "../input-container-BvEcp7FU.js";
|
|
7
7
|
import { T as I } from "../text-input-DfqXolVe.js";
|
|
@@ -294,7 +294,7 @@ function le({
|
|
|
294
294
|
)
|
|
295
295
|
)
|
|
296
296
|
),
|
|
297
|
-
verify: () =>
|
|
297
|
+
verify: () => E(
|
|
298
298
|
g(
|
|
299
299
|
u,
|
|
300
300
|
(s) => r.div(
|
|
@@ -303,7 +303,7 @@ function le({
|
|
|
303
303
|
r.code(l.class("bc-two-factor__code-display"), s)
|
|
304
304
|
)
|
|
305
305
|
),
|
|
306
|
-
|
|
306
|
+
O(
|
|
307
307
|
o,
|
|
308
308
|
() => r.div(
|
|
309
309
|
l.class("bc-two-factor__backup-codes"),
|