@clerk/clerk-react
Version:
Clerk.dev React library
27 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignUpButton = void 0;
const tslib_1 = require("tslib");
const react_1 = (0, tslib_1.__importDefault)(require("react"));
const contexts_1 = require("../contexts");
const utils_1 = require("../utils");
exports.SignUpButton = (0, contexts_1.withClerk)((_a) => {
var { clerk, children } = _a, props = (0, tslib_1.__rest)(_a, ["clerk", "children"]);
const { afterSignInUrl, afterSignUpUrl, redirectUrl, mode } = props, rest = (0, tslib_1.__rest)(props, ["afterSignInUrl", "afterSignUpUrl", "redirectUrl", "mode"]);
children = (0, utils_1.normalizeWithDefaultValue)(children, 'Sign up');
const child = (0, utils_1.assertSingleChild)(children)('SignUpButton');
const clickHandler = () => {
const opts = { afterSignInUrl, afterSignUpUrl, redirectUrl };
if (mode === 'modal') {
return clerk.openSignUp(opts);
}
return clerk.redirectToSignUp(opts);
};
const wrappedChildClickHandler = async (e) => {
await (0, utils_1.safeExecute)(child.props.onClick)(e);
return clickHandler();
};
const childProps = Object.assign(Object.assign({}, rest), { onClick: wrappedChildClickHandler });
return react_1.default.cloneElement(child, childProps);
}, 'SignUpButton');
//# sourceMappingURL=Sign.js.map