UNPKG

react-pdf-builder

Version:
47 lines (46 loc) 3.15 kB
"use strict"; 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.Heading4 = void 0; const react_1 = __importDefault(require("react")); const ThemeBuilder_1 = require("../../themes/ThemeBuilder"); const ThemedText_1 = require("../basics/ThemedText"); const sanitizeChildren_1 = require("../children/sanitizeChildren"); const PDFThemeProvider_1 = require("../theme/PDFThemeProvider"); /** * Read the [full documentation for Heading4](https://justinmahar.github.io/react-pdf-builder/?path=/docs/documentation-components-typography-heading4--docs) */ const Heading4 = (_a) => { var _b, _c, _d, _e; var { children, className, style } = _a, props = __rest(_a, ["children", "className", "style"]); const theme = (0, PDFThemeProvider_1.usePDFThemeContext)(); const mergedProps = Object.assign(Object.assign(Object.assign({}, theme === null || theme === void 0 ? void 0 : theme.headingProps), theme === null || theme === void 0 ? void 0 : theme.heading4Props), props); const mergedThemeStyles = Object.assign(Object.assign({}, (_b = theme === null || theme === void 0 ? void 0 : theme.headingProps) === null || _b === void 0 ? void 0 : _b.style), (_c = theme === null || theme === void 0 ? void 0 : theme.heading4Props) === null || _c === void 0 ? void 0 : _c.style); const styleOverride = {}; if (!mergedProps.rule) { styleOverride.borderBottom = 0; } if (mergedProps.swatch) { const swatchColor = ThemeBuilder_1.ThemeBuilder.getSwatchColor(mergedProps.swatch, theme.colorScheme); styleOverride.color = swatchColor; styleOverride.borderColor = swatchColor; } const themeClassName = `${(_d = theme === null || theme === void 0 ? void 0 : theme.headingProps.className) !== null && _d !== void 0 ? _d : ''} ${(_e = theme === null || theme === void 0 ? void 0 : theme.heading4Props.className) !== null && _e !== void 0 ? _e : ''}`.trim(); const themeClassNameStyles = ThemeBuilder_1.ThemeBuilder.getStylesForClassName(themeClassName, theme.classNames); const classNameStyles = ThemeBuilder_1.ThemeBuilder.getStylesForClassName(className, theme.classNames); return (react_1.default.createElement(ThemedText_1.ThemedText, Object.assign({}, mergedProps, { style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, themeClassNameStyles), mergedThemeStyles), styleOverride), classNameStyles), style) }), (0, sanitizeChildren_1.sanitizeChildren)(children, undefined, true))); }; exports.Heading4 = Heading4;