UNPKG

@clerk/clerk-react

Version:

Clerk.dev React library

32 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.safeExecute = exports.normalizeWithDefaultValue = exports.assertSingleChild = void 0; const tslib_1 = require("tslib"); const react_1 = (0, tslib_1.__importDefault)(require("react")); const errors_1 = require("../errors"); const assertSingleChild = (children) => (name) => { try { return react_1.default.Children.only(children); } catch (e) { throw new Error((0, errors_1.multipleChildrenInButtonComponent)(name)); } }; exports.assertSingleChild = assertSingleChild; const normalizeWithDefaultValue = (children, defaultText) => { if (!children) { children = defaultText; } if (typeof children === 'string') { children = react_1.default.createElement("button", null, children); } return children; }; exports.normalizeWithDefaultValue = normalizeWithDefaultValue; const safeExecute = (cb) => (...args) => { if (cb && typeof cb === 'function') { return cb(...args); } }; exports.safeExecute = safeExecute; //# sourceMappingURL=childrenUtils.js.map