react-pdf-builder
Version:
Build beautiful PDF documents in React.
46 lines (45 loc) • 2.62 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThemedLink = void 0;
const renderer_1 = require("@react-pdf/renderer");
const react_1 = __importDefault(require("react"));
const ThemeBuilder_1 = require("../../themes/ThemeBuilder");
const sanitizeChildren_1 = require("../children/sanitizeChildren");
const PDFThemeProvider_1 = require("../theme/PDFThemeProvider");
/**
* Read the [full documentation for ThemedLink](https://justinmahar.github.io/react-pdf-builder/?path=/docs/documentation-components-basics-themedlink--docs)
*/
const ThemedLink = (_a) => {
var _b;
var { children, className, style } = _a, props = __rest(_a, ["children", "className", "style"]);
const theme = (0, PDFThemeProvider_1.usePDFThemeContext)();
const themeProps = theme === null || theme === void 0 ? void 0 : theme.linkProps;
const mergedProps = Object.assign(Object.assign({}, themeProps), props);
const styleInnate = {
color: (_b = theme.colorScheme) === null || _b === void 0 ? void 0 : _b.colors.blue,
};
const styleOverride = {};
if (mergedProps.swatch) {
const swatchColor = ThemeBuilder_1.ThemeBuilder.getSwatchColor(mergedProps.swatch, theme.colorScheme);
styleOverride.color = swatchColor;
}
const themeClassName = themeProps.className;
const themeClassNameStyles = ThemeBuilder_1.ThemeBuilder.getStylesForClassName(themeClassName, theme.classNames);
const classNameStyles = ThemeBuilder_1.ThemeBuilder.getStylesForClassName(className, theme.classNames);
return (react_1.default.createElement(renderer_1.Link, Object.assign({}, mergedProps, { style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, styleInnate), themeClassNameStyles), themeProps === null || themeProps === void 0 ? void 0 : themeProps.style), styleOverride), classNameStyles), style) }), (0, sanitizeChildren_1.sanitizeChildren)(children)));
};
exports.ThemedLink = ThemedLink;
;