@protobase/ui 0.46.14 → 0.46.15

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.
@@ -22,6 +22,7 @@ const useOptionalAuth = () => useContext(AuthContext);
22
22
  const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
23
23
  const [state, setState] = useState({ kind: "loading" });
24
24
  const [signInMethods, setSignInMethods] = useState(["password"]);
25
+ const [signInFirst, setSignInFirst] = useState("password");
25
26
  const [passwordReset, setPasswordReset] = useState(false);
26
27
  const [changeEmail, setChangeEmail] = useState(false);
27
28
  const [mcp, setMcp] = useState(false);
@@ -106,6 +107,7 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
106
107
  setState({ kind: "loading" });
107
108
  session.status().then(async (status) => {
108
109
  setSignInMethods(status.signInMethods);
110
+ setSignInFirst(status.signInFirst ?? "password");
109
111
  setPasswordReset(status.passwordReset && !nativeBridge);
110
112
  setChangeEmail(Boolean(status.changeEmail));
111
113
  setMcp(Boolean(status.mcp));
@@ -136,6 +138,7 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
136
138
  state,
137
139
  session,
138
140
  signInMethods,
141
+ signInFirst,
139
142
  passwordReset,
140
143
  changeEmail,
141
144
  mcp,
@@ -193,6 +196,7 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
193
196
  state,
194
197
  session,
195
198
  signInMethods,
199
+ signInFirst,
196
200
  passwordReset,
197
201
  changeEmail,
198
202
  mcp,
@@ -61,6 +61,7 @@ const text = defineMessages({
61
61
  passkeyFor: (domain) => `Use a passkey made for ${domain}`,
62
62
  or: "or",
63
63
  emailSignInCode: "Email me a sign-in code",
64
+ usePassword: "Use a password",
64
65
  forgotPassword: "Forgot password?",
65
66
  newHere: "New here?",
66
67
  haveAccount: "Have an account?",
@@ -158,6 +159,7 @@ const text = defineMessages({
158
159
  passkeyFor: (domain) => `Een passkey voor ${domain} gebruiken`,
159
160
  or: "of",
160
161
  emailSignInCode: "Mail me een inlogcode",
162
+ usePassword: "Een wachtwoord gebruiken",
161
163
  forgotPassword: "Wachtwoord vergeten?",
162
164
  newHere: "Nieuw hier?",
163
165
  haveAccount: "Heb je een account?",
@@ -16,14 +16,17 @@ const Divider = () => /* @__PURE__ */ jsxs("div", {
16
16
  /* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-border" })
17
17
  ]
18
18
  });
19
- const SignInForm = ({ onSubmit, busy, error, workspace, notice, methods = ["password"], onSendCode, onPasskey, passkeyDomains = [], forgotPassword, providers = [], onContinueWith, signUp, onBrowse }) => {
19
+ const SignInForm = ({ onSubmit, busy, error, workspace, notice, methods = ["password"], first = "password", onSendCode, onPasskey, passkeyDomains = [], forgotPassword, providers = [], onContinueWith, signUp, onBrowse }) => {
20
20
  const [email, setEmail] = useState("");
21
21
  const [password, setPassword] = useState("");
22
+ const [passwordChosen, setPasswordChosen] = useState(false);
22
23
  const emailInput = useRef(null);
23
24
  const withPassword = methods.includes("password");
24
25
  const withCode = methods.includes("emailCode") && onSendCode !== void 0;
25
26
  const withPasskey = methods.includes("passkey") && onPasskey !== void 0;
26
27
  const offered = onContinueWith ? providers : [];
28
+ const leadsWithCode = first === "emailCode" && withPassword && withCode && !passwordChosen;
29
+ const asksPassword = withPassword && !leadsWithCode;
27
30
  const sendCode = () => {
28
31
  if (!emailInput.current?.reportValidity()) return;
29
32
  onSendCode?.(email.trim());
@@ -70,7 +73,7 @@ const SignInForm = ({ onSubmit, busy, error, workspace, notice, methods = ["pass
70
73
  className: "flex flex-col gap-4",
71
74
  onSubmit: (event) => {
72
75
  event.preventDefault();
73
- if (withPassword) onSubmit(email.trim(), password);
76
+ if (asksPassword) onSubmit(email.trim(), password);
74
77
  else sendCode();
75
78
  },
76
79
  children: [
@@ -89,7 +92,7 @@ const SignInForm = ({ onSubmit, busy, error, workspace, notice, methods = ["pass
89
92
  className: "min-h-6"
90
93
  })]
91
94
  }),
92
- withPassword && /* @__PURE__ */ jsxs("label", {
95
+ asksPassword && /* @__PURE__ */ jsxs("label", {
93
96
  className: "flex flex-col gap-1.5 font-medium",
94
97
  children: [text("password"), /* @__PURE__ */ jsx(Input, {
95
98
  type: "password",
@@ -107,7 +110,7 @@ const SignInForm = ({ onSubmit, busy, error, workspace, notice, methods = ["pass
107
110
  className: "text-body font-medium text-danger-text",
108
111
  children: error
109
112
  }),
110
- withPassword && /* @__PURE__ */ jsx(Button, {
113
+ asksPassword && /* @__PURE__ */ jsx(Button, {
111
114
  variant: "primary",
112
115
  type: "submit",
113
116
  loading: busy,
@@ -115,15 +118,22 @@ const SignInForm = ({ onSubmit, busy, error, workspace, notice, methods = ["pass
115
118
  children: text("signIn")
116
119
  }),
117
120
  withCode && /* @__PURE__ */ jsxs(Button, {
118
- variant: withPassword ? "secondary" : "primary",
119
- type: withPassword ? "button" : "submit",
120
- onClick: withPassword ? sendCode : void 0,
121
- loading: busy && !withPassword,
121
+ variant: asksPassword ? "secondary" : "primary",
122
+ type: asksPassword ? "button" : "submit",
123
+ onClick: asksPassword ? sendCode : void 0,
124
+ loading: busy && !asksPassword,
122
125
  disabled: busy,
123
126
  className: "min-h-10",
124
127
  children: [/* @__PURE__ */ jsx(Mail, { className: "size-4" }), text("emailSignInCode")]
125
128
  }),
126
- withPassword && forgotPassword && /* @__PURE__ */ jsx(RouteLink, {
129
+ leadsWithCode && /* @__PURE__ */ jsx(Button, {
130
+ variant: "ghost",
131
+ onClick: () => setPasswordChosen(true),
132
+ disabled: busy,
133
+ className: "min-h-10",
134
+ children: text("usePassword")
135
+ }),
136
+ asksPassword && forgotPassword && /* @__PURE__ */ jsx(RouteLink, {
127
137
  to: forgotPassword,
128
138
  className: "self-center font-medium text-primary-text hover:underline",
129
139
  children: text("forgotPassword")
@@ -6,7 +6,7 @@ import { AuthError } from "@protobase/client";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  //#region src/auth/sign-in-page.tsx
8
8
  const SignInPage = ({ workspace, notice, forgotPassword, signUp, onBrowse, onCodeSent, error: initialError }) => {
9
- const { signIn, signInSocial, signInProviders, signInMethods, passkeyDomains, sendSignInCode, signInWithPasskey } = useAuth();
9
+ const { signIn, signInSocial, signInProviders, signInMethods, signInFirst, passkeyDomains, sendSignInCode, signInWithPasskey } = useAuth();
10
10
  const [busy, setBusy] = useState(false);
11
11
  const [error, setError] = useState(initialError);
12
12
  const attempt = async (start, message) => {
@@ -26,6 +26,7 @@ const SignInPage = ({ workspace, notice, forgotPassword, signUp, onBrowse, onCod
26
26
  workspace,
27
27
  notice,
28
28
  methods: signInMethods,
29
+ first: signInFirst,
29
30
  forgotPassword,
30
31
  signUp,
31
32
  onBrowse,
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.46.14";
2
+ var version = "0.46.15";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };