@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/index.cjs
CHANGED
|
@@ -3135,6 +3135,25 @@ function VerifyEmail({ token, onSuccess, onError, ...uiProps }) {
|
|
|
3135
3135
|
}, [token, verifyEmail, onSuccess, onError]);
|
|
3136
3136
|
return /* @__PURE__ */ jsxRuntime.jsx(VerifyEmailStatus, { status, error, ...uiProps });
|
|
3137
3137
|
}
|
|
3138
|
+
function SignOutButton({ children, className, afterSignOutUrl = "/" }) {
|
|
3139
|
+
const { signOut } = useInsforge();
|
|
3140
|
+
const handleClick = async () => {
|
|
3141
|
+
await signOut();
|
|
3142
|
+
window.location.href = afterSignOutUrl;
|
|
3143
|
+
};
|
|
3144
|
+
if (children && react.isValidElement(children)) {
|
|
3145
|
+
const originalOnClick = children.props?.onClick;
|
|
3146
|
+
return react.cloneElement(children, {
|
|
3147
|
+
onClick: async (e) => {
|
|
3148
|
+
await handleClick();
|
|
3149
|
+
if (originalOnClick) {
|
|
3150
|
+
originalOnClick(e);
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3155
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className, onClick: () => void handleClick(), children: children || "Sign out" });
|
|
3156
|
+
}
|
|
3138
3157
|
var UserButtonContainer = styled__default.default.div`
|
|
3139
3158
|
position: relative;
|
|
3140
3159
|
display: inline-block;
|
|
@@ -3250,7 +3269,7 @@ var UserButtonMenuItemIcon = styled__default.default.div`
|
|
|
3250
3269
|
}
|
|
3251
3270
|
`;
|
|
3252
3271
|
function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
3253
|
-
const { user
|
|
3272
|
+
const { user } = useInsforge();
|
|
3254
3273
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
3255
3274
|
const [imageError, setImageError] = react.useState(false);
|
|
3256
3275
|
const dropdownRef = react.useRef(null);
|
|
@@ -3291,11 +3310,6 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
3291
3310
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
3292
3311
|
};
|
|
3293
3312
|
}, [isOpen]);
|
|
3294
|
-
async function handleSignOut() {
|
|
3295
|
-
await signOut();
|
|
3296
|
-
setIsOpen(false);
|
|
3297
|
-
window.location.href = afterSignOutUrl;
|
|
3298
|
-
}
|
|
3299
3313
|
if (!user) {
|
|
3300
3314
|
return null;
|
|
3301
3315
|
}
|
|
@@ -3324,10 +3338,10 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
3324
3338
|
]
|
|
3325
3339
|
}
|
|
3326
3340
|
),
|
|
3327
|
-
isOpen && /* @__PURE__ */ jsxRuntime.jsx(UserButtonMenu, { children: /* @__PURE__ */ jsxRuntime.jsxs(UserButtonMenuItem, { $signout: true, onClick: () =>
|
|
3341
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(UserButtonMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SignOutButton, { afterSignOutUrl, children: /* @__PURE__ */ jsxRuntime.jsxs(UserButtonMenuItem, { $signout: true, onClick: () => setIsOpen(false), children: [
|
|
3328
3342
|
/* @__PURE__ */ jsxRuntime.jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, {}) }),
|
|
3329
3343
|
"Sign out"
|
|
3330
|
-
] }) })
|
|
3344
|
+
] }) }) })
|
|
3331
3345
|
] });
|
|
3332
3346
|
}
|
|
3333
3347
|
function Protect({
|
|
@@ -3464,6 +3478,7 @@ exports.ResetPasswordForm = ResetPasswordForm;
|
|
|
3464
3478
|
exports.SignIn = SignIn;
|
|
3465
3479
|
exports.SignInButton = SignInButton;
|
|
3466
3480
|
exports.SignInForm = SignInForm;
|
|
3481
|
+
exports.SignOutButton = SignOutButton;
|
|
3467
3482
|
exports.SignUp = SignUp;
|
|
3468
3483
|
exports.SignUpButton = SignUpButton;
|
|
3469
3484
|
exports.SignUpForm = SignUpForm;
|