@stackframe/stack 1.2.1 → 2.1.0
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/components/card-frame.d.ts +7 -0
- package/dist/components/card-frame.d.ts.map +1 -0
- package/dist/components/card-frame.js +24 -0
- package/dist/{elements/CardHeader.d.ts → components/card-header.d.ts} +1 -1
- package/dist/components/card-header.d.ts.map +1 -0
- package/dist/components/card-header.js +5 -0
- package/dist/components/credential-sign-in.d.ts +2 -0
- package/dist/components/credential-sign-in.d.ts.map +1 -0
- package/dist/components/credential-sign-in.js +56 -0
- package/dist/components/credential-sign-up.d.ts +2 -0
- package/dist/components/credential-sign-up.d.ts.map +1 -0
- package/dist/components/credential-sign-up.js +73 -0
- package/dist/{elements/DividerWithText.d.ts → components/divider-with-text.d.ts} +1 -1
- package/dist/components/divider-with-text.d.ts.map +1 -0
- package/dist/components/divider-with-text.js +6 -0
- package/dist/components/email-verification.d.ts +5 -0
- package/dist/components/email-verification.d.ts.map +1 -0
- package/dist/components/{EmailVerification.js → email-verification.js} +2 -2
- package/dist/{elements/ForgotPassword.d.ts → components/forgot-password.d.ts} +1 -1
- package/dist/components/forgot-password.d.ts.map +1 -0
- package/dist/components/forgot-password.js +32 -0
- package/dist/components/form-warning.d.ts +4 -0
- package/dist/components/form-warning.d.ts.map +1 -0
- package/dist/components/form-warning.js +9 -0
- package/dist/{elements/MessageCard.d.ts → components/message-card.d.ts} +1 -1
- package/dist/components/message-card.d.ts.map +1 -0
- package/dist/components/message-card.js +7 -0
- package/dist/components/oauth-button.d.ts +5 -0
- package/dist/components/oauth-button.d.ts.map +1 -0
- package/dist/components/oauth-button.js +66 -0
- package/dist/components/oauth-callback.d.ts +2 -0
- package/dist/components/oauth-callback.d.ts.map +1 -0
- package/dist/components/oauth-callback.js +17 -0
- package/dist/components/oauth-group.d.ts +4 -0
- package/dist/components/oauth-group.d.ts.map +1 -0
- package/dist/components/oauth-group.js +9 -0
- package/dist/components/password-field.d.ts +4 -0
- package/dist/components/password-field.d.ts.map +1 -0
- package/dist/components/password-field.js +41 -0
- package/dist/{elements/PasswordResetInner.d.ts → components/password-reset-inner.d.ts} +1 -1
- package/dist/components/password-reset-inner.d.ts.map +1 -0
- package/dist/{elements/PasswordResetInner.js → components/password-reset-inner.js} +18 -16
- package/dist/components/password-reset.d.ts +5 -0
- package/dist/components/password-reset.d.ts.map +1 -0
- package/dist/components/{PasswordReset.js → password-reset.js} +6 -5
- package/dist/{elements/RedirectMessageCard.d.ts → components/redirect-message-card.d.ts} +1 -1
- package/dist/components/redirect-message-card.d.ts.map +1 -0
- package/dist/{elements/RedirectMessageCard.js → components/redirect-message-card.js} +19 -15
- package/dist/components/sign-in.d.ts +4 -0
- package/dist/components/sign-in.d.ts.map +1 -0
- package/dist/components/sign-in.js +20 -0
- package/dist/components/sign-out.d.ts +2 -0
- package/dist/components/sign-out.d.ts.map +1 -0
- package/dist/components/{SignOut.js → sign-out.js} +5 -4
- package/dist/components/sign-up.d.ts +4 -0
- package/dist/components/sign-up.d.ts.map +1 -0
- package/dist/components/sign-up.js +20 -0
- package/dist/components/stack-handler.d.ts +9 -0
- package/dist/components/stack-handler.d.ts.map +1 -0
- package/dist/components/stack-handler.js +58 -0
- package/dist/components-core/button.d.ts +10 -0
- package/dist/components-core/button.d.ts.map +1 -0
- package/dist/components-core/button.js +115 -0
- package/dist/components-core/container.d.ts +6 -0
- package/dist/components-core/container.d.ts.map +1 -0
- package/dist/components-core/container.js +19 -0
- package/dist/components-core/divider.d.ts +7 -0
- package/dist/components-core/divider.d.ts.map +1 -0
- package/dist/components-core/divider.js +17 -0
- package/dist/components-core/index.d.ts +17 -0
- package/dist/components-core/index.d.ts.map +1 -0
- package/dist/components-core/index.js +32 -0
- package/dist/components-core/input.d.ts +5 -0
- package/dist/components-core/input.d.ts.map +1 -0
- package/dist/components-core/input.js +45 -0
- package/dist/components-core/label.d.ts +6 -0
- package/dist/components-core/label.d.ts.map +1 -0
- package/dist/components-core/label.js +22 -0
- package/dist/components-core/link.d.ts +9 -0
- package/dist/components-core/link.d.ts.map +1 -0
- package/dist/components-core/link.js +18 -0
- package/dist/components-core/text.d.ts +9 -0
- package/dist/components-core/text.d.ts.map +1 -0
- package/dist/components-core/text.js +42 -0
- package/dist/components-core-joy/button.d.ts +3 -0
- package/dist/components-core-joy/button.d.ts.map +1 -0
- package/dist/components-core-joy/button.js +26 -0
- package/dist/components-core-joy/divider.d.ts +3 -0
- package/dist/components-core-joy/divider.d.ts.map +1 -0
- package/dist/components-core-joy/divider.js +7 -0
- package/dist/components-core-joy/input.d.ts +3 -0
- package/dist/components-core-joy/input.d.ts.map +1 -0
- package/dist/components-core-joy/input.js +7 -0
- package/dist/components-core-joy/text.d.ts +3 -0
- package/dist/components-core-joy/text.d.ts.map +1 -0
- package/dist/components-core-joy/text.js +28 -0
- package/dist/{components/EmailVerification.d.ts → components-page/email-verification.d.ts} +1 -2
- package/dist/components-page/email-verification.d.ts.map +1 -0
- package/dist/components-page/email-verification.js +29 -0
- package/dist/{components/ForgotPassword.d.ts → components-page/forgot-password.d.ts} +1 -1
- package/dist/components-page/forgot-password.d.ts.map +1 -0
- package/dist/{components/ForgotPassword.js → components-page/forgot-password.js} +6 -6
- package/dist/{components/OAuthCallback.d.ts → components-page/oauth-callback.d.ts} +1 -1
- package/dist/components-page/oauth-callback.d.ts.map +1 -0
- package/dist/{components/OAuthCallback.js → components-page/oauth-callback.js} +1 -4
- package/dist/{components/PasswordReset.d.ts → components-page/password-reset.d.ts} +1 -1
- package/dist/components-page/password-reset.d.ts.map +1 -0
- package/dist/components-page/password-reset.js +37 -0
- package/dist/components-page/sign-in.d.ts +4 -0
- package/dist/components-page/sign-in.d.ts.map +1 -0
- package/dist/components-page/sign-in.js +20 -0
- package/dist/components-page/sign-out.d.ts +2 -0
- package/dist/components-page/sign-out.d.ts.map +1 -0
- package/dist/components-page/sign-out.js +13 -0
- package/dist/components-page/sign-up.d.ts +4 -0
- package/dist/components-page/sign-up.d.ts.map +1 -0
- package/dist/components-page/sign-up.js +20 -0
- package/dist/{components/StackHandler.d.ts → components-page/stack-handler.d.ts} +1 -1
- package/dist/components-page/stack-handler.d.ts.map +1 -0
- package/dist/{components/StackHandler.js → components-page/stack-handler.js} +11 -11
- package/dist/elements/card-frame.d.ts +7 -0
- package/dist/elements/card-frame.d.ts.map +1 -0
- package/dist/elements/card-frame.js +24 -0
- package/dist/elements/card-header.d.ts +6 -0
- package/dist/elements/card-header.d.ts.map +1 -0
- package/dist/elements/card-header.js +5 -0
- package/dist/elements/credential-sign-in.d.ts +2 -0
- package/dist/elements/credential-sign-in.d.ts.map +1 -0
- package/dist/elements/credential-sign-in.js +56 -0
- package/dist/elements/credential-sign-up.d.ts +2 -0
- package/dist/elements/credential-sign-up.d.ts.map +1 -0
- package/dist/elements/credential-sign-up.js +73 -0
- package/dist/elements/divider-with-text.d.ts +4 -0
- package/dist/elements/divider-with-text.d.ts.map +1 -0
- package/dist/elements/divider-with-text.js +6 -0
- package/dist/elements/forgot-password.d.ts +4 -0
- package/dist/elements/forgot-password.d.ts.map +1 -0
- package/dist/elements/forgot-password.js +32 -0
- package/dist/elements/{FormWarning.d.ts → form-warning.d.ts} +1 -1
- package/dist/elements/form-warning.d.ts.map +1 -0
- package/dist/elements/{FormWarning.js → form-warning.js} +2 -1
- package/dist/elements/message-card.d.ts +7 -0
- package/dist/elements/message-card.d.ts.map +1 -0
- package/dist/elements/message-card.js +7 -0
- package/dist/elements/oauth-button.d.ts +5 -0
- package/dist/elements/oauth-button.d.ts.map +1 -0
- package/dist/elements/{OAuthButton.js → oauth-button.js} +8 -10
- package/dist/elements/oauth-group.d.ts +4 -0
- package/dist/elements/oauth-group.d.ts.map +1 -0
- package/dist/elements/oauth-group.js +8 -0
- package/dist/elements/{PasswordField.d.ts → password-field.d.ts} +1 -1
- package/dist/elements/password-field.d.ts.map +1 -0
- package/dist/elements/password-field.js +38 -0
- package/dist/elements/password-reset-inner.d.ts +5 -0
- package/dist/elements/password-reset-inner.d.ts.map +1 -0
- package/dist/elements/password-reset-inner.js +63 -0
- package/dist/elements/redirect-message-card.d.ts +5 -0
- package/dist/elements/redirect-message-card.d.ts.map +1 -0
- package/dist/elements/redirect-message-card.js +54 -0
- package/dist/index.d.ts +17 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/lib/auth.d.ts +1 -13
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +6 -30
- package/dist/lib/hooks.js +1 -1
- package/dist/lib/stack-app.d.ts +6 -8
- package/dist/lib/stack-app.d.ts.map +1 -1
- package/dist/lib/stack-app.js +43 -35
- package/dist/providers/component-provider.d.ts +25 -0
- package/dist/providers/component-provider.d.ts.map +1 -0
- package/dist/providers/component-provider.js +29 -0
- package/dist/providers/design-provider.d.ts +41 -0
- package/dist/providers/design-provider.d.ts.map +1 -0
- package/dist/providers/design-provider.js +65 -0
- package/dist/providers/joy-provider.d.ts +17 -0
- package/dist/providers/joy-provider.d.ts.map +1 -0
- package/dist/providers/joy-provider.js +27 -0
- package/dist/providers/{StackProviderClient.d.ts → stack-provider-client.d.ts} +1 -1
- package/dist/providers/stack-provider-client.d.ts.map +1 -0
- package/dist/providers/{StackProvider.d.ts → stack-provider.d.ts} +3 -3
- package/dist/providers/stack-provider.d.ts.map +1 -0
- package/dist/providers/{StackProvider.js → stack-provider.js} +1 -1
- package/dist/providers/styled-components-registry.d.ts +5 -0
- package/dist/providers/styled-components-registry.d.ts.map +1 -0
- package/dist/providers/styled-components-registry.js +18 -0
- package/dist/providers/theme-provider.d.ts +11 -0
- package/dist/providers/theme-provider.d.ts.map +1 -0
- package/dist/providers/theme-provider.js +20 -0
- package/dist/providers/ui-provider.d.ts +10 -0
- package/dist/providers/ui-provider.js +20 -0
- package/dist/utils/constants.d.ts +41 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +22 -0
- package/dist/utils/email.d.ts.map +1 -1
- package/dist/utils/next.d.ts.map +1 -1
- package/dist/utils/react.d.ts.map +1 -1
- package/dist/utils/results.d.ts.map +1 -1
- package/dist/utils/url.d.ts.map +1 -1
- package/package.json +22 -27
- package/dist/components/EmailVerification.d.ts.map +0 -1
- package/dist/components/ForgotPassword.d.ts.map +0 -1
- package/dist/components/OAuthCallback.d.ts.map +0 -1
- package/dist/components/PasswordReset.d.ts.map +0 -1
- package/dist/components/SignIn.d.ts +0 -5
- package/dist/components/SignIn.d.ts.map +0 -1
- package/dist/components/SignIn.js +0 -20
- package/dist/components/SignOut.d.ts +0 -4
- package/dist/components/SignOut.d.ts.map +0 -1
- package/dist/components/SignUp.d.ts +0 -5
- package/dist/components/SignUp.d.ts.map +0 -1
- package/dist/components/SignUp.js +0 -19
- package/dist/components/StackHandler.d.ts.map +0 -1
- package/dist/elements/Button.d.ts +0 -11
- package/dist/elements/Button.d.ts.map +0 -1
- package/dist/elements/Button.js +0 -18
- package/dist/elements/CardFrame.d.ts +0 -6
- package/dist/elements/CardFrame.d.ts.map +0 -1
- package/dist/elements/CardFrame.js +0 -10
- package/dist/elements/CardHeader.d.ts.map +0 -1
- package/dist/elements/CardHeader.js +0 -4
- package/dist/elements/CredentialSignIn.d.ts +0 -4
- package/dist/elements/CredentialSignIn.d.ts.map +0 -1
- package/dist/elements/CredentialSignIn.js +0 -57
- package/dist/elements/CredentialSignUp.d.ts +0 -4
- package/dist/elements/CredentialSignUp.d.ts.map +0 -1
- package/dist/elements/CredentialSignUp.js +0 -73
- package/dist/elements/DividerWithText.d.ts.map +0 -1
- package/dist/elements/DividerWithText.js +0 -5
- package/dist/elements/ForgotPassword.d.ts.map +0 -1
- package/dist/elements/ForgotPassword.js +0 -32
- package/dist/elements/FormWarning.d.ts.map +0 -1
- package/dist/elements/MessageCard.d.ts.map +0 -1
- package/dist/elements/MessageCard.js +0 -5
- package/dist/elements/OAuthButton.d.ts +0 -6
- package/dist/elements/OAuthButton.d.ts.map +0 -1
- package/dist/elements/OAuthGroup.d.ts +0 -5
- package/dist/elements/OAuthGroup.d.ts.map +0 -1
- package/dist/elements/OAuthGroup.js +0 -8
- package/dist/elements/PasswordField.d.ts.map +0 -1
- package/dist/elements/PasswordField.js +0 -27
- package/dist/elements/PasswordResetInner.d.ts.map +0 -1
- package/dist/elements/RedirectMessageCard.d.ts.map +0 -1
- package/dist/providers/StackProvider.d.ts.map +0 -1
- package/dist/providers/StackProviderClient.d.ts.map +0 -1
- package/dist/tailwind.css +0 -1293
- package/dist/utils/types.d.ts +0 -4
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -1
- /package/dist/providers/{StackProviderClient.js → stack-provider-client.js} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { FONT_FAMILY, FONT_SIZES, LINE_HEIGHTS, PRIMARY_FONT_COLORS, SECONDARY_FONT_COLORS } from "../utils/constants";
|
|
5
|
+
import { useDesign } from "../providers/design-provider";
|
|
6
|
+
const Text = React.forwardRef(({ variant = 'primary', size = 'md', as = 'p', style, ...props }, ref) => {
|
|
7
|
+
const { colorMode } = useDesign();
|
|
8
|
+
let textColor;
|
|
9
|
+
switch (variant) {
|
|
10
|
+
case 'primary': {
|
|
11
|
+
textColor = PRIMARY_FONT_COLORS[colorMode];
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
case 'secondary': {
|
|
15
|
+
textColor = SECONDARY_FONT_COLORS[colorMode];
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case 'warning': {
|
|
19
|
+
textColor = '#ff4500';
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case 'success': {
|
|
23
|
+
textColor = '#32cd32';
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return createElement(as, {
|
|
28
|
+
style: {
|
|
29
|
+
fontSize: FONT_SIZES[size],
|
|
30
|
+
lineHeight: LINE_HEIGHTS[size],
|
|
31
|
+
fontFamily: FONT_FAMILY,
|
|
32
|
+
color: textColor,
|
|
33
|
+
padding: 0,
|
|
34
|
+
margin: 0,
|
|
35
|
+
...style
|
|
36
|
+
},
|
|
37
|
+
ref,
|
|
38
|
+
...props
|
|
39
|
+
}, props.children);
|
|
40
|
+
});
|
|
41
|
+
Text.displayName = 'Typography';
|
|
42
|
+
export default Text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/components-core-joy/button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,OAAmB,EACnB,KAAK,EACL,IAAW,EACX,OAAe,EACf,GAAG,KAAK,EACT,EAAG,WAAW,2CAmCd"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Button as JoyButton } from '@mui/joy';
|
|
4
|
+
import Color from "color";
|
|
5
|
+
export default function Button({ variant = "primary", color, size = "md", loading = false, ...props }) {
|
|
6
|
+
const muiVariant = {
|
|
7
|
+
primary: "primary",
|
|
8
|
+
secondary: "neutral",
|
|
9
|
+
warning: "danger",
|
|
10
|
+
}[variant] || "primary";
|
|
11
|
+
const { children, action, ref, ...validProps } = props;
|
|
12
|
+
const c = Color(color);
|
|
13
|
+
const changeColor = (value) => {
|
|
14
|
+
return c.hsl(c.hue(), c.saturationl(), c.lightness() + (c.isDark() ? value : -value)).toString();
|
|
15
|
+
};
|
|
16
|
+
return _jsx(JoyButton, { color: muiVariant, sx: color ? {
|
|
17
|
+
backgroundColor: color,
|
|
18
|
+
color: c.isDark() ? 'white' : 'black',
|
|
19
|
+
'&:hover': {
|
|
20
|
+
backgroundColor: changeColor(10)
|
|
21
|
+
},
|
|
22
|
+
'&:active': {
|
|
23
|
+
backgroundColor: changeColor(20)
|
|
24
|
+
},
|
|
25
|
+
} : {}, size: size, loading: loading, ...validProps, children: children });
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.d.ts","sourceRoot":"","sources":["../../src/components-core-joy/divider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAG,YAAY,2CAGnD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Divider as JoyDivider } from '@mui/joy';
|
|
4
|
+
export default function Divider(props) {
|
|
5
|
+
const { direction, ref, ...validProps } = props;
|
|
6
|
+
return _jsx(JoyDivider, { ...validProps, orientation: direction });
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/components-core-joy/input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,KAAK,EAAG,UAAU,2CAG/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/components-core-joy/text.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,KAAK,EAAG,SAAS,2CAyB7C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Typography as JoyText } from '@mui/joy';
|
|
4
|
+
export default function Text(props) {
|
|
5
|
+
const { color, size, as, variant, ref, ...validProps } = props;
|
|
6
|
+
const muiLevel = {
|
|
7
|
+
h1: 'h1',
|
|
8
|
+
h2: 'h2',
|
|
9
|
+
h3: 'h3',
|
|
10
|
+
h4: 'h4',
|
|
11
|
+
h5: 'h4',
|
|
12
|
+
h6: 'h4',
|
|
13
|
+
p: {
|
|
14
|
+
xl: 'body-lg',
|
|
15
|
+
lg: 'body-lg',
|
|
16
|
+
md: 'body-md',
|
|
17
|
+
sm: 'body-sm',
|
|
18
|
+
xs: 'body-xs'
|
|
19
|
+
}[size || 'md']
|
|
20
|
+
}[as || 'p'];
|
|
21
|
+
const muiColor = {
|
|
22
|
+
primary: undefined,
|
|
23
|
+
secondary: 'neutral',
|
|
24
|
+
success: 'success',
|
|
25
|
+
warning: 'danger',
|
|
26
|
+
}[variant || 'primary'];
|
|
27
|
+
return _jsx(JoyText, { level: muiLevel, color: muiColor, ...validProps });
|
|
28
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export default function EmailVerification({ searchParams: { code, }, fullPage, }: {
|
|
2
2
|
searchParams?: Record<string, string>;
|
|
3
3
|
fullPage?: boolean;
|
|
4
|
-
redirectUrl?: string;
|
|
5
4
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=email-verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-verification.d.ts","sourceRoot":"","sources":["../../src/components-page/email-verification.tsx"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,YAAY,EAAE,EACZ,IAAS,GACL,EACN,QAAgB,GACjB,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,kDAkCA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { useStackApp } from "..";
|
|
5
|
+
import MessageCard from "../components/message-card";
|
|
6
|
+
import RedirectMessageCard from "../components/redirect-message-card";
|
|
7
|
+
import { EmailVerificationLinkExpiredErrorCode, EmailVerificationLinkInvalidErrorCode, EmailVerificationLinkUsedErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
8
|
+
export default function EmailVerification({ searchParams: { code = "", } = {}, fullPage = false, }) {
|
|
9
|
+
const stackApp = useStackApp();
|
|
10
|
+
const invalidJsx = (_jsx(MessageCard, { title: "Invalid Verification Link", fullPage: fullPage, children: _jsx("p", { children: "Please check if you have the correct link. If you continue to have issues, please contact support." }) }));
|
|
11
|
+
const expiredJsx = (_jsx(MessageCard, { title: "Expired Verification Link", fullPage: fullPage, children: _jsx("p", { children: "Your email verification link has expired. Please request a new verification link from your account settings." }) }));
|
|
12
|
+
if (!code) {
|
|
13
|
+
return invalidJsx;
|
|
14
|
+
}
|
|
15
|
+
const errorCode = use(stackApp.verifyEmail(code));
|
|
16
|
+
switch (errorCode) {
|
|
17
|
+
case EmailVerificationLinkInvalidErrorCode: {
|
|
18
|
+
return invalidJsx;
|
|
19
|
+
}
|
|
20
|
+
case EmailVerificationLinkExpiredErrorCode: {
|
|
21
|
+
return expiredJsx;
|
|
22
|
+
}
|
|
23
|
+
case EmailVerificationLinkUsedErrorCode:
|
|
24
|
+
case undefined: {
|
|
25
|
+
return _jsx(RedirectMessageCard, { type: 'emailVerified', fullPage: fullPage });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forgot-password.d.ts","sourceRoot":"","sources":["../../src/components-page/forgot-password.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,QAAc,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA0BhF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import ForgotPasswordElement from "../
|
|
4
|
-
import CardFrame from "../
|
|
5
|
-
import CardHeader from "../
|
|
3
|
+
import ForgotPasswordElement from "../components/forgot-password";
|
|
4
|
+
import CardFrame from "../components/card-frame";
|
|
5
|
+
import CardHeader from "../components/card-header";
|
|
6
6
|
import { useUser, useStackApp } from "..";
|
|
7
|
-
import RedirectMessageCard from "../
|
|
8
|
-
import NextLink from 'next/link';
|
|
7
|
+
import RedirectMessageCard from "../components/redirect-message-card";
|
|
9
8
|
import { useState } from "react";
|
|
9
|
+
import { Link, Text } from "../components-core";
|
|
10
10
|
export default function ForgotPassword({ fullPage = false }) {
|
|
11
11
|
const stackApp = useStackApp();
|
|
12
12
|
const user = useUser();
|
|
@@ -17,6 +17,6 @@ export default function ForgotPassword({ fullPage = false }) {
|
|
|
17
17
|
if (sent) {
|
|
18
18
|
return _jsx(RedirectMessageCard, { type: 'emailSent', fullPage: fullPage });
|
|
19
19
|
}
|
|
20
|
-
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Reset Your Password", children: _jsxs(
|
|
20
|
+
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Reset Your Password", children: _jsxs(Text, { children: ["Don't need to reset? ", _jsx(Link, { href: stackApp.urls['signUp'], children: "Sign In" })] }) }), _jsx(ForgotPasswordElement, { onSent: () => setSent(true) })] }));
|
|
21
21
|
}
|
|
22
22
|
;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export default function OAuthCallback(): import("react/jsx-runtime").JSX.Element;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=oauth-callback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-callback.d.ts","sourceRoot":"","sources":["../../src/components-page/oauth-callback.tsx"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,aAAa,4CAWpC"}
|
|
@@ -3,18 +3,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useRef, useEffect } from "react";
|
|
4
4
|
import { useStackApp } from "..";
|
|
5
5
|
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
6
|
-
import MessageCard from "../
|
|
7
|
-
import { useRouter } from "next/navigation";
|
|
6
|
+
import MessageCard from "../components/message-card";
|
|
8
7
|
export default function OAuthCallback() {
|
|
9
8
|
const app = useStackApp();
|
|
10
|
-
const router = useRouter();
|
|
11
9
|
const called = useRef(false);
|
|
12
10
|
useEffect(() => runAsynchronously(async () => {
|
|
13
11
|
if (called.current)
|
|
14
12
|
return;
|
|
15
13
|
called.current = true;
|
|
16
14
|
await app.callOAuthCallback();
|
|
17
|
-
router.push(app.urls.userHome);
|
|
18
15
|
}), []);
|
|
19
16
|
return _jsx(MessageCard, { title: 'Redirecting...', fullPage: true });
|
|
20
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reset.d.ts","sourceRoot":"","sources":["../../src/components-page/password-reset.tsx"],"names":[],"mappings":"AAcA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,YAAY,EACZ,QAAgB,GACjB,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,2CA0CA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import MessageCard from "../components/message-card";
|
|
4
|
+
import { useStackApp } from "..";
|
|
5
|
+
import { use } from "react";
|
|
6
|
+
import PasswordResetInner from "../components/password-reset-inner";
|
|
7
|
+
import { PasswordResetLinkExpiredErrorCode, PasswordResetLinkInvalidErrorCode, PasswordResetLinkUsedErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
8
|
+
import { cacheFunction } from "@stackframe/stack-shared/dist/utils/caches";
|
|
9
|
+
import { Text } from "../components-core";
|
|
10
|
+
const cachedVerifyPasswordResetCode = cacheFunction(async (stackApp, code) => {
|
|
11
|
+
return await stackApp.verifyPasswordResetCode(code);
|
|
12
|
+
});
|
|
13
|
+
export default function PasswordReset({ searchParams, fullPage = false, }) {
|
|
14
|
+
const stackApp = useStackApp();
|
|
15
|
+
const invalidJsx = (_jsx(MessageCard, { title: "Invalid Password Reset Link", fullPage: fullPage, children: _jsx(Text, { children: "Please double check if you have the correct password reset link." }) }));
|
|
16
|
+
const expiredJsx = (_jsx(MessageCard, { title: "Expired Password Reset Link", fullPage: fullPage, children: _jsx(Text, { children: "Your password reset link has expired. Please request a new password reset link from the login page." }) }));
|
|
17
|
+
const usedJsx = (_jsx(MessageCard, { title: "Used Password Reset Link", fullPage: fullPage, children: _jsx(Text, { children: "This password reset link has already been used. If you need to reset your password again, please request a new password reset link from the login page." }) }));
|
|
18
|
+
const code = searchParams?.code;
|
|
19
|
+
if (!code) {
|
|
20
|
+
return invalidJsx;
|
|
21
|
+
}
|
|
22
|
+
const errorCode = use(cachedVerifyPasswordResetCode(stackApp, code));
|
|
23
|
+
switch (errorCode) {
|
|
24
|
+
case PasswordResetLinkInvalidErrorCode: {
|
|
25
|
+
return invalidJsx;
|
|
26
|
+
}
|
|
27
|
+
case PasswordResetLinkExpiredErrorCode: {
|
|
28
|
+
return expiredJsx;
|
|
29
|
+
}
|
|
30
|
+
case PasswordResetLinkUsedErrorCode: {
|
|
31
|
+
return usedJsx;
|
|
32
|
+
}
|
|
33
|
+
case undefined: {
|
|
34
|
+
return _jsx(PasswordResetInner, { code: code, fullPage: fullPage });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../../src/components-page/sign-in.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAc,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA0BxE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import CredentialSignIn from '../components/credential-sign-in';
|
|
4
|
+
import DividerWithText from '../components/divider-with-text';
|
|
5
|
+
import OAuthGroup from '../components/oauth-group';
|
|
6
|
+
import CardFrame from '../components/card-frame';
|
|
7
|
+
import CardHeader from '../components/card-header';
|
|
8
|
+
import { useUser, useStackApp } from '..';
|
|
9
|
+
import RedirectMessageCard from '../components/redirect-message-card';
|
|
10
|
+
import { Link, Text } from "../components-core";
|
|
11
|
+
export default function SignIn({ fullPage = false }) {
|
|
12
|
+
const stackApp = useStackApp();
|
|
13
|
+
const user = useUser();
|
|
14
|
+
const project = stackApp.useProject();
|
|
15
|
+
if (user) {
|
|
16
|
+
return _jsx(RedirectMessageCard, { type: 'signedIn', fullPage: fullPage });
|
|
17
|
+
}
|
|
18
|
+
const enableDivider = project.credentialEnabled && project.oauthProviders.filter(p => p.enabled).length > 0;
|
|
19
|
+
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Sign In to Your Account", children: _jsxs(Text, { children: ["Don't have an account? ", _jsx(Link, { href: stackApp.urls['signUp'], children: "Sign up" })] }) }), _jsx(OAuthGroup, { type: 'signin' }), enableDivider && _jsx(DividerWithText, { text: 'OR' }), project.credentialEnabled && _jsx(CredentialSignIn, {})] }));
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-out.d.ts","sourceRoot":"","sources":["../../src/components-page/sign-out.tsx"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,OAAO,4CAS9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { useStackApp, useUser } from "..";
|
|
5
|
+
import GoHomeMessageCard from "../components/redirect-message-card";
|
|
6
|
+
export default function Signout() {
|
|
7
|
+
const user = useUser();
|
|
8
|
+
const app = useStackApp();
|
|
9
|
+
if (user) {
|
|
10
|
+
use(user.signOut());
|
|
11
|
+
}
|
|
12
|
+
return _jsx(GoHomeMessageCard, { type: 'signedOut', fullPage: true });
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-up.d.ts","sourceRoot":"","sources":["../../src/components-page/sign-up.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAc,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA0BxE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import DividerWithText from '../components/divider-with-text';
|
|
4
|
+
import OAuthGroup from '../components/oauth-group';
|
|
5
|
+
import CardFrame from '../components/card-frame';
|
|
6
|
+
import CredentialSignUp from '../components/credential-sign-up';
|
|
7
|
+
import CardHeader from '../components/card-header';
|
|
8
|
+
import { useUser, useStackApp } from '..';
|
|
9
|
+
import RedirectMessageCard from '../components/redirect-message-card';
|
|
10
|
+
import { Link, Text } from "../components-core";
|
|
11
|
+
export default function SignUp({ fullPage = false }) {
|
|
12
|
+
const stackApp = useStackApp();
|
|
13
|
+
const user = useUser();
|
|
14
|
+
const project = stackApp.useProject();
|
|
15
|
+
if (user) {
|
|
16
|
+
return _jsx(RedirectMessageCard, { type: 'signedIn', fullPage: fullPage });
|
|
17
|
+
}
|
|
18
|
+
const enableDivider = project.credentialEnabled && project.oauthProviders.filter(p => p.enabled).length > 0;
|
|
19
|
+
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Create a New Account", children: _jsxs(Text, { children: ["Already have an account? ", _jsx(Link, { href: stackApp.urls['signIn'], children: "Sign in" })] }) }), _jsx(OAuthGroup, { type: 'signup' }), enableDivider && _jsx(DividerWithText, { text: 'OR' }), project.credentialEnabled && _jsx(CredentialSignUp, {})] }));
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-handler.d.ts","sourceRoot":"","sources":["../../src/components-page/stack-handler.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAiB,cAAc,EAAE,MAAM,IAAI,CAAC;AAOnD,wBAA8B,YAAY,CAAC,aAAa,SAAS,OAAO,EAAE,EACxE,GAAG,EACH,MAAM,EAAE,EAAE,KAAK,EAAO,EACtB,YAAiB,GAClB,EAAE;IACD,GAAG,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,oDAuDA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import SignUp from "./
|
|
3
|
-
import SignIn from "./
|
|
2
|
+
import SignUp from "./sign-up";
|
|
3
|
+
import SignIn from "./sign-in";
|
|
4
4
|
import { RedirectType, notFound, redirect } from 'next/navigation';
|
|
5
|
-
import EmailVerification from "./
|
|
5
|
+
import EmailVerification from "./email-verification";
|
|
6
6
|
import { PasswordReset } from "..";
|
|
7
|
-
import MessageCard from "../
|
|
8
|
-
import Signout from "./
|
|
9
|
-
import ForgotPassword from "./
|
|
10
|
-
import OAuthCallback from "./
|
|
7
|
+
import MessageCard from "../components/message-card";
|
|
8
|
+
import Signout from "./sign-out";
|
|
9
|
+
import ForgotPassword from "./forgot-password";
|
|
10
|
+
import OAuthCallback from "./oauth-callback";
|
|
11
11
|
export default async function StackHandler({ app, params: { stack } = {}, searchParams = {}, }) {
|
|
12
12
|
if (!stack) {
|
|
13
13
|
return (_jsx(MessageCard, { title: "Invalid Stack Handler Setup", fullPage: true, children: _jsx("p", { children: "Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack]." }) }));
|
|
@@ -25,15 +25,15 @@ export default async function StackHandler({ app, params: { stack } = {}, search
|
|
|
25
25
|
switch (path) {
|
|
26
26
|
case 'signin': {
|
|
27
27
|
redirectIfNotHandler('signIn');
|
|
28
|
-
return _jsx(SignIn, { fullPage: true
|
|
28
|
+
return _jsx(SignIn, { fullPage: true });
|
|
29
29
|
}
|
|
30
30
|
case 'signup': {
|
|
31
31
|
redirectIfNotHandler('signUp');
|
|
32
|
-
return _jsx(SignUp, { fullPage: true
|
|
32
|
+
return _jsx(SignUp, { fullPage: true });
|
|
33
33
|
}
|
|
34
34
|
case 'email-verification': {
|
|
35
35
|
redirectIfNotHandler('emailVerification');
|
|
36
|
-
return _jsx(EmailVerification, { searchParams: searchParams, fullPage: true
|
|
36
|
+
return _jsx(EmailVerification, { searchParams: searchParams, fullPage: true });
|
|
37
37
|
}
|
|
38
38
|
case 'password-reset': {
|
|
39
39
|
redirectIfNotHandler('passwordReset');
|
|
@@ -45,7 +45,7 @@ export default async function StackHandler({ app, params: { stack } = {}, search
|
|
|
45
45
|
}
|
|
46
46
|
case 'signout': {
|
|
47
47
|
redirectIfNotHandler('signOut');
|
|
48
|
-
return _jsx(Signout, {
|
|
48
|
+
return _jsx(Signout, {});
|
|
49
49
|
}
|
|
50
50
|
case 'oauth-callback': {
|
|
51
51
|
redirectIfNotHandler('oauthCallback');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react/experimental" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
export default function CardFrame({ children, fullPage }: {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
fullPage?: boolean;
|
|
6
|
+
}): string | number | boolean | Iterable<React.ReactNode> | Promise<React.AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
7
|
+
//# sourceMappingURL=card-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-frame.d.ts","sourceRoot":"","sources":["../../src/elements/card-frame.tsx"],"names":[],"mappings":";AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,QAAQ,EACR,QAAa,EACd,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,wJA4BA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Container } from "@stackframe/stack-ui";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
export default function CardFrame({ children, fullPage = true }) {
|
|
6
|
+
const [hasNoParent, setHasNoParent] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const component = document.getElementById('stack-card-frame');
|
|
9
|
+
setHasNoParent(!component?.parentElement ||
|
|
10
|
+
component?.parentElement === document.body ||
|
|
11
|
+
component?.parentElement === document.documentElement);
|
|
12
|
+
}, []);
|
|
13
|
+
if (fullPage) {
|
|
14
|
+
return (_jsx("div", { id: 'stack-card-frame', style: {
|
|
15
|
+
height: hasNoParent ? '100vh' : '100%',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center'
|
|
19
|
+
}, children: _jsx(Container, { size: 360, children: children }) }));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return children;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-header.d.ts","sourceRoot":"","sources":["../../src/elements/card-header.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,EAAE,QAAQ,EAAE,KAAK,EAAE,EACnB;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,2CAQ9C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "@stackframe/stack-ui";
|
|
3
|
+
export default function CardHeader({ children, title }) {
|
|
4
|
+
return (_jsxs("div", { style: { textAlign: 'center', marginBottom: '24px' }, children: [_jsx(Text, { size: "xl", as: 'h2', style: { marginBottom: '5px' }, children: title }), children] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-sign-in.d.ts","sourceRoot":"","sources":["../../src/elements/credential-sign-in.tsx"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,gBAAgB,4CAkFvC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { FormWarningText } from "./form-warning";
|
|
4
|
+
import { PasswordField } from "./password-field";
|
|
5
|
+
import { validateEmail } from "../utils/email";
|
|
6
|
+
import { useStackApp } from "..";
|
|
7
|
+
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
8
|
+
import { EmailPasswordMissMatchErrorCode, UserNotExistErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
9
|
+
import { Button, Input, Label, Link } from "@stackframe/stack-ui";
|
|
10
|
+
// Import or define the PasswordField, FormWarningText, and validateEmail utilities if they're custom components or functions.
|
|
11
|
+
export default function CredentialSignIn() {
|
|
12
|
+
const [email, setEmail] = useState('');
|
|
13
|
+
const [emailError, setEmailError] = useState('');
|
|
14
|
+
const [password, setPassword] = useState('');
|
|
15
|
+
const [passwordError, setPasswordError] = useState('');
|
|
16
|
+
const [loading, setLoading] = useState(false);
|
|
17
|
+
const app = useStackApp();
|
|
18
|
+
const onSubmit = async () => {
|
|
19
|
+
if (!email) {
|
|
20
|
+
setEmailError('Please enter your email');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!validateEmail(email)) {
|
|
24
|
+
setEmailError('Please enter a valid email');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!password) {
|
|
28
|
+
setPasswordError('Please enter your password');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setLoading(true);
|
|
32
|
+
const errorCode = await app.signInWithCredential({ email, password });
|
|
33
|
+
setLoading(false);
|
|
34
|
+
switch (errorCode) {
|
|
35
|
+
case UserNotExistErrorCode: {
|
|
36
|
+
setEmailError('User does not exist');
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case EmailPasswordMissMatchErrorCode: {
|
|
40
|
+
setPasswordError('Wrong email or password');
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case undefined: {
|
|
44
|
+
// success
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'stretch' }, children: [_jsx(Label, { htmlFor: "email", children: "Email" }), _jsx(Input, { id: "email", type: "email", name: "email", value: email, onChange: (e) => {
|
|
50
|
+
setEmail(e.target.value);
|
|
51
|
+
setEmailError('');
|
|
52
|
+
} }), _jsx(FormWarningText, { text: emailError }), _jsx(Label, { htmlFor: "password", style: { marginTop: '1rem' }, children: "Password" }), _jsx(PasswordField, { id: "password", name: "password", value: password, onChange: (e) => {
|
|
53
|
+
setPassword(e.target.value);
|
|
54
|
+
setPasswordError('');
|
|
55
|
+
} }), _jsx(FormWarningText, { text: passwordError }), _jsx(Link, { href: app.urls.forgotPassword, size: 'sm', style: { marginTop: '0.5rem' }, children: "Forgot password?" }), _jsx(Button, { style: { marginTop: '1.5rem' }, onClick: () => runAsynchronously(onSubmit), loading: loading, children: "Sign In" })] }));
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-sign-up.d.ts","sourceRoot":"","sources":["../../src/elements/credential-sign-up.tsx"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,UAAU,gBAAgB,4CAwGvC"}
|