react-pdf-builder
Version:
Build beautiful PDF documents in React.
41 lines (40 loc) • 2.03 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.Box = void 0;
const react_1 = __importDefault(require("react"));
const ThemeBuilder_1 = require("../../themes/ThemeBuilder");
const Div_1 = require("../basics/Div");
const sanitizeChildren_1 = require("../children/sanitizeChildren");
const PDFThemeProvider_1 = require("../theme/PDFThemeProvider");
/**
* Read the [full documentation for Box](https://justinmahar.github.io/react-pdf-builder/?path=/docs/documentation-components-box--docs)
*/
const Box = (_a) => {
var { children, dir, grow, shrink, gap, padding, className, style } = _a, props = __rest(_a, ["children", "dir", "grow", "shrink", "gap", "padding", "className", "style"]);
const theme = (0, PDFThemeProvider_1.usePDFThemeContext)();
const styleInnate = {
display: 'flex',
flexDirection: dir === 'column' || dir === 'y' ? 'column' : 'row',
flexShrink: shrink ? 1 : undefined,
flexGrow: grow ? 1 : undefined,
gap,
padding,
};
const classNameStyles = ThemeBuilder_1.ThemeBuilder.getStylesForClassName(className, theme.classNames);
return (react_1.default.createElement(Div_1.Div, Object.assign({}, props, { style: Object.assign(Object.assign(Object.assign({}, styleInnate), classNameStyles), style) }), (0, sanitizeChildren_1.sanitizeChildren)(children)));
};
exports.Box = Box;