@insforge/react 0.6.10 → 0.7.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.cjs +23 -8
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +26 -1
- package/dist/components.d.ts +26 -1
- package/dist/components.js +23 -9
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/components.d.cts
CHANGED
|
@@ -321,4 +321,29 @@ interface SignUpButtonProps {
|
|
|
321
321
|
*/
|
|
322
322
|
declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
|
|
323
323
|
|
|
324
|
-
|
|
324
|
+
interface SignOutButtonProps {
|
|
325
|
+
children?: React.ReactNode;
|
|
326
|
+
className?: string;
|
|
327
|
+
afterSignOutUrl?: string;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* SignOutButton Component
|
|
331
|
+
*
|
|
332
|
+
* A simple unstyled button that signs out the current user.
|
|
333
|
+
* If children is a valid React element, it will be rendered with the sign-out logic attached.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```tsx
|
|
337
|
+
* <SignOutButton />
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```tsx
|
|
342
|
+
* <SignOutButton afterSignOutUrl="/goodbye">
|
|
343
|
+
* <button className="custom-button">Logout</button>
|
|
344
|
+
* </SignOutButton>
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
declare function SignOutButton({ children, className, afterSignOutUrl }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
|
|
348
|
+
|
|
349
|
+
export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, SignInButton, type SignInButtonProps, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, SignUpButton, type SignUpButtonProps, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
|
package/dist/components.d.ts
CHANGED
|
@@ -321,4 +321,29 @@ interface SignUpButtonProps {
|
|
|
321
321
|
*/
|
|
322
322
|
declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
|
|
323
323
|
|
|
324
|
-
|
|
324
|
+
interface SignOutButtonProps {
|
|
325
|
+
children?: React.ReactNode;
|
|
326
|
+
className?: string;
|
|
327
|
+
afterSignOutUrl?: string;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* SignOutButton Component
|
|
331
|
+
*
|
|
332
|
+
* A simple unstyled button that signs out the current user.
|
|
333
|
+
* If children is a valid React element, it will be rendered with the sign-out logic attached.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```tsx
|
|
337
|
+
* <SignOutButton />
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```tsx
|
|
342
|
+
* <SignOutButton afterSignOutUrl="/goodbye">
|
|
343
|
+
* <button className="custom-button">Logout</button>
|
|
344
|
+
* </SignOutButton>
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
declare function SignOutButton({ children, className, afterSignOutUrl }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
|
|
348
|
+
|
|
349
|
+
export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, SignInButton, type SignInButtonProps, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, SignUpButton, type SignUpButtonProps, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
|
package/dist/components.js
CHANGED
|
@@ -2521,6 +2521,25 @@ function VerifyEmail({ token, onSuccess, onError, ...uiProps }) {
|
|
|
2521
2521
|
}, [token, verifyEmail, onSuccess, onError]);
|
|
2522
2522
|
return /* @__PURE__ */ jsx(VerifyEmailStatus, { status, error, ...uiProps });
|
|
2523
2523
|
}
|
|
2524
|
+
function SignOutButton({ children, className, afterSignOutUrl = "/" }) {
|
|
2525
|
+
const { signOut } = useInsforge();
|
|
2526
|
+
const handleClick = async () => {
|
|
2527
|
+
await signOut();
|
|
2528
|
+
window.location.href = afterSignOutUrl;
|
|
2529
|
+
};
|
|
2530
|
+
if (children && isValidElement(children)) {
|
|
2531
|
+
const originalOnClick = children.props?.onClick;
|
|
2532
|
+
return cloneElement(children, {
|
|
2533
|
+
onClick: async (e) => {
|
|
2534
|
+
await handleClick();
|
|
2535
|
+
if (originalOnClick) {
|
|
2536
|
+
originalOnClick(e);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: () => void handleClick(), children: children || "Sign out" });
|
|
2542
|
+
}
|
|
2524
2543
|
var UserButtonContainer = styled.div`
|
|
2525
2544
|
position: relative;
|
|
2526
2545
|
display: inline-block;
|
|
@@ -2636,7 +2655,7 @@ var UserButtonMenuItemIcon = styled.div`
|
|
|
2636
2655
|
}
|
|
2637
2656
|
`;
|
|
2638
2657
|
function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
2639
|
-
const { user
|
|
2658
|
+
const { user } = useInsforge();
|
|
2640
2659
|
const [isOpen, setIsOpen] = useState(false);
|
|
2641
2660
|
const [imageError, setImageError] = useState(false);
|
|
2642
2661
|
const dropdownRef = useRef(null);
|
|
@@ -2677,11 +2696,6 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
2677
2696
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
2678
2697
|
};
|
|
2679
2698
|
}, [isOpen]);
|
|
2680
|
-
async function handleSignOut() {
|
|
2681
|
-
await signOut();
|
|
2682
|
-
setIsOpen(false);
|
|
2683
|
-
window.location.href = afterSignOutUrl;
|
|
2684
|
-
}
|
|
2685
2699
|
if (!user) {
|
|
2686
2700
|
return null;
|
|
2687
2701
|
}
|
|
@@ -2710,10 +2724,10 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
2710
2724
|
]
|
|
2711
2725
|
}
|
|
2712
2726
|
),
|
|
2713
|
-
isOpen && /* @__PURE__ */ jsx(UserButtonMenu, { children: /* @__PURE__ */ jsxs(UserButtonMenuItem, { $signout: true, onClick: () =>
|
|
2727
|
+
isOpen && /* @__PURE__ */ jsx(UserButtonMenu, { children: /* @__PURE__ */ jsx(SignOutButton, { afterSignOutUrl, children: /* @__PURE__ */ jsxs(UserButtonMenuItem, { $signout: true, onClick: () => setIsOpen(false), children: [
|
|
2714
2728
|
/* @__PURE__ */ jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsx(LogOut, {}) }),
|
|
2715
2729
|
"Sign out"
|
|
2716
|
-
] }) })
|
|
2730
|
+
] }) }) })
|
|
2717
2731
|
] });
|
|
2718
2732
|
}
|
|
2719
2733
|
function Protect({
|
|
@@ -2810,6 +2824,6 @@ function SignUpButton({ children, className }) {
|
|
|
2810
2824
|
return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: handleClick, children: children || "Sign up" });
|
|
2811
2825
|
}
|
|
2812
2826
|
|
|
2813
|
-
export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, ForgotPassword, ForgotPasswordForm, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, UserButton, VerifyEmail, VerifyEmailStatus };
|
|
2827
|
+
export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, ForgotPassword, ForgotPasswordForm, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignOutButton, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, UserButton, VerifyEmail, VerifyEmailStatus };
|
|
2814
2828
|
//# sourceMappingURL=components.js.map
|
|
2815
2829
|
//# sourceMappingURL=components.js.map
|