react-pdf-levelup 3.1.3 → 3.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -426,6 +426,10 @@ var Header = ({ children, style, fixed = false }) => {
426
426
  // src/components/core/Tablet.tsx
427
427
  var import_react5 = __toESM(require("react"), 1);
428
428
  var import_renderer5 = require("@react-pdf/renderer");
429
+ var TableContext = (0, import_react5.createContext)({
430
+ cellHeight: 22,
431
+ textAlign: "left"
432
+ });
429
433
  var styles5 = import_renderer5.StyleSheet.create({
430
434
  table: {
431
435
  width: "100%",
@@ -443,22 +447,30 @@ var styles5 = import_renderer5.StyleSheet.create({
443
447
  fontSize: 10,
444
448
  fontFamily: "Helvetica",
445
449
  fontWeight: "bold",
446
- textAlign: "center",
447
- paddingTop: 4
450
+ paddingLeft: 8,
451
+ paddingRight: 8,
452
+ justifyContent: "center"
448
453
  },
449
454
  text: {
450
455
  fontSize: 10,
451
456
  fontFamily: "Helvetica",
452
- paddingTop: 8,
453
457
  paddingLeft: 8,
454
- paddingRight: 8
458
+ paddingRight: 8,
459
+ justifyContent: "center"
455
460
  },
456
461
  zebraOdd: {
457
462
  backgroundColor: "#eeeeee"
458
463
  }
459
464
  });
460
- var Table = ({ children, style }) => /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.table, style] }, children);
461
- var Thead = ({ children, style }) => /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.thead, style] }, children);
465
+ var Table = ({ children, style, cellHeight = 22 }) => /* @__PURE__ */ import_react5.default.createElement(TableContext.Provider, { value: { cellHeight, textAlign: "left" } }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.table, style] }, children));
466
+ var Thead = ({
467
+ children,
468
+ style,
469
+ textAlign = "left"
470
+ }) => {
471
+ const { cellHeight } = (0, import_react5.useContext)(TableContext);
472
+ return /* @__PURE__ */ import_react5.default.createElement(TableContext.Provider, { value: { cellHeight, textAlign } }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.thead, style] }, children));
473
+ };
462
474
  var Tbody = ({ children, style }) => {
463
475
  const rows = import_react5.default.Children.toArray(children);
464
476
  const count = rows.length;
@@ -475,7 +487,9 @@ var Tr = ({
475
487
  isLastRow = false,
476
488
  isOdd = false
477
489
  }) => {
478
- const elements = import_react5.default.Children.toArray(children);
490
+ const elements = import_react5.default.Children.toArray(
491
+ children
492
+ );
479
493
  const count = elements.length;
480
494
  return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.tr, style] }, elements.map((child, idx) => {
481
495
  const isLast = idx === count - 1;
@@ -490,16 +504,33 @@ var Th = ({
490
504
  height,
491
505
  colSpan,
492
506
  isLast = false,
493
- isLastRow = false
507
+ isLastRow = false,
508
+ textAlign: propTextAlign
494
509
  }) => {
510
+ const { cellHeight, textAlign: contextTextAlign } = (0, import_react5.useContext)(TableContext);
511
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
495
512
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
513
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
496
514
  const borders = {
497
515
  borderRightWidth: isLast ? 0 : 1,
498
516
  borderBottomWidth: isLastRow ? 0 : 1,
499
517
  borderColor: "#000",
500
- ...height !== void 0 && { height }
518
+ minHeight: cellHeightValue
501
519
  };
502
- return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, null, children));
520
+ return /* @__PURE__ */ import_react5.default.createElement(
521
+ import_renderer5.View,
522
+ {
523
+ style: [
524
+ styles5.textBold,
525
+ {
526
+ width: baseWidth
527
+ },
528
+ borders,
529
+ style
530
+ ]
531
+ },
532
+ /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, { style: { textAlign: finalTextAlign } }, children)
533
+ );
503
534
  };
504
535
  var Td = ({
505
536
  children,
@@ -509,22 +540,34 @@ var Td = ({
509
540
  colSpan,
510
541
  isLast = false,
511
542
  isLastRow = false,
512
- isOdd = false
543
+ isOdd = false,
544
+ textAlign: propTextAlign
513
545
  }) => {
546
+ const { cellHeight, textAlign: contextTextAlign } = (0, import_react5.useContext)(TableContext);
547
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
514
548
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
549
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
515
550
  const borders = {
516
551
  borderRightWidth: isLast ? 0 : 1,
517
552
  borderBottomWidth: isLastRow ? 0 : 1,
518
553
  borderColor: "#000",
519
- ...height !== void 0 && { height }
554
+ minHeight: cellHeightValue
520
555
  };
521
- return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [
522
- styles5.text,
523
- isOdd && styles5.zebraOdd,
524
- { width: baseWidth },
525
- borders,
526
- style
527
- ] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, null, children));
556
+ return /* @__PURE__ */ import_react5.default.createElement(
557
+ import_renderer5.View,
558
+ {
559
+ style: [
560
+ styles5.text,
561
+ isOdd && styles5.zebraOdd,
562
+ {
563
+ width: baseWidth
564
+ },
565
+ borders,
566
+ style
567
+ ]
568
+ },
569
+ /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, { style: { textAlign: finalTextAlign } }, children)
570
+ );
528
571
  };
529
572
 
530
573
  // src/components/core/Grid.tsx
package/dist/index.d.cts CHANGED
@@ -61,6 +61,12 @@ declare const Header: React$1.FC<HeaderProps>;
61
61
  interface TableProps {
62
62
  children: React$1.ReactNode;
63
63
  style?: any;
64
+ cellHeight?: number;
65
+ }
66
+ interface TheadProps {
67
+ children: React$1.ReactNode;
68
+ style?: any;
69
+ textAlign?: "left" | "center" | "right" | any;
64
70
  }
65
71
  interface CellProps {
66
72
  children?: React$1.ReactNode;
@@ -71,9 +77,10 @@ interface CellProps {
71
77
  isLast?: boolean;
72
78
  isLastRow?: boolean;
73
79
  isOdd?: boolean;
80
+ textAlign?: "left" | "center" | "right" | any;
74
81
  }
75
82
  declare const Table: React$1.FC<TableProps>;
76
- declare const Thead: React$1.FC<TableProps>;
83
+ declare const Thead: React$1.FC<TheadProps>;
77
84
  declare const Tbody: React$1.FC<TableProps>;
78
85
  declare const Tr: React$1.FC<TableProps & {
79
86
  isLastRow?: boolean;
package/dist/index.d.ts CHANGED
@@ -61,6 +61,12 @@ declare const Header: React$1.FC<HeaderProps>;
61
61
  interface TableProps {
62
62
  children: React$1.ReactNode;
63
63
  style?: any;
64
+ cellHeight?: number;
65
+ }
66
+ interface TheadProps {
67
+ children: React$1.ReactNode;
68
+ style?: any;
69
+ textAlign?: "left" | "center" | "right" | any;
64
70
  }
65
71
  interface CellProps {
66
72
  children?: React$1.ReactNode;
@@ -71,9 +77,10 @@ interface CellProps {
71
77
  isLast?: boolean;
72
78
  isLastRow?: boolean;
73
79
  isOdd?: boolean;
80
+ textAlign?: "left" | "center" | "right" | any;
74
81
  }
75
82
  declare const Table: React$1.FC<TableProps>;
76
- declare const Thead: React$1.FC<TableProps>;
83
+ declare const Thead: React$1.FC<TheadProps>;
77
84
  declare const Tbody: React$1.FC<TableProps>;
78
85
  declare const Tr: React$1.FC<TableProps & {
79
86
  isLastRow?: boolean;
package/dist/index.js CHANGED
@@ -337,8 +337,12 @@ var Header = ({ children, style, fixed = false }) => {
337
337
  };
338
338
 
339
339
  // src/components/core/Tablet.tsx
340
- import React5 from "react";
340
+ import React5, { createContext, useContext } from "react";
341
341
  import { View as View4, Text as Text3, StyleSheet as StyleSheet5 } from "@react-pdf/renderer";
342
+ var TableContext = createContext({
343
+ cellHeight: 22,
344
+ textAlign: "left"
345
+ });
342
346
  var styles5 = StyleSheet5.create({
343
347
  table: {
344
348
  width: "100%",
@@ -356,22 +360,30 @@ var styles5 = StyleSheet5.create({
356
360
  fontSize: 10,
357
361
  fontFamily: "Helvetica",
358
362
  fontWeight: "bold",
359
- textAlign: "center",
360
- paddingTop: 4
363
+ paddingLeft: 8,
364
+ paddingRight: 8,
365
+ justifyContent: "center"
361
366
  },
362
367
  text: {
363
368
  fontSize: 10,
364
369
  fontFamily: "Helvetica",
365
- paddingTop: 8,
366
370
  paddingLeft: 8,
367
- paddingRight: 8
371
+ paddingRight: 8,
372
+ justifyContent: "center"
368
373
  },
369
374
  zebraOdd: {
370
375
  backgroundColor: "#eeeeee"
371
376
  }
372
377
  });
373
- var Table = ({ children, style }) => /* @__PURE__ */ React5.createElement(View4, { style: [styles5.table, style] }, children);
374
- var Thead = ({ children, style }) => /* @__PURE__ */ React5.createElement(View4, { style: [styles5.thead, style] }, children);
378
+ var Table = ({ children, style, cellHeight = 22 }) => /* @__PURE__ */ React5.createElement(TableContext.Provider, { value: { cellHeight, textAlign: "left" } }, /* @__PURE__ */ React5.createElement(View4, { style: [styles5.table, style] }, children));
379
+ var Thead = ({
380
+ children,
381
+ style,
382
+ textAlign = "left"
383
+ }) => {
384
+ const { cellHeight } = useContext(TableContext);
385
+ return /* @__PURE__ */ React5.createElement(TableContext.Provider, { value: { cellHeight, textAlign } }, /* @__PURE__ */ React5.createElement(View4, { style: [styles5.thead, style] }, children));
386
+ };
375
387
  var Tbody = ({ children, style }) => {
376
388
  const rows = React5.Children.toArray(children);
377
389
  const count = rows.length;
@@ -388,7 +400,9 @@ var Tr = ({
388
400
  isLastRow = false,
389
401
  isOdd = false
390
402
  }) => {
391
- const elements = React5.Children.toArray(children);
403
+ const elements = React5.Children.toArray(
404
+ children
405
+ );
392
406
  const count = elements.length;
393
407
  return /* @__PURE__ */ React5.createElement(View4, { style: [styles5.tr, style] }, elements.map((child, idx) => {
394
408
  const isLast = idx === count - 1;
@@ -403,16 +417,33 @@ var Th = ({
403
417
  height,
404
418
  colSpan,
405
419
  isLast = false,
406
- isLastRow = false
420
+ isLastRow = false,
421
+ textAlign: propTextAlign
407
422
  }) => {
423
+ const { cellHeight, textAlign: contextTextAlign } = useContext(TableContext);
424
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
408
425
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
426
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
409
427
  const borders = {
410
428
  borderRightWidth: isLast ? 0 : 1,
411
429
  borderBottomWidth: isLastRow ? 0 : 1,
412
430
  borderColor: "#000",
413
- ...height !== void 0 && { height }
431
+ minHeight: cellHeightValue
414
432
  };
415
- return /* @__PURE__ */ React5.createElement(View4, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
433
+ return /* @__PURE__ */ React5.createElement(
434
+ View4,
435
+ {
436
+ style: [
437
+ styles5.textBold,
438
+ {
439
+ width: baseWidth
440
+ },
441
+ borders,
442
+ style
443
+ ]
444
+ },
445
+ /* @__PURE__ */ React5.createElement(Text3, { style: { textAlign: finalTextAlign } }, children)
446
+ );
416
447
  };
417
448
  var Td = ({
418
449
  children,
@@ -422,22 +453,34 @@ var Td = ({
422
453
  colSpan,
423
454
  isLast = false,
424
455
  isLastRow = false,
425
- isOdd = false
456
+ isOdd = false,
457
+ textAlign: propTextAlign
426
458
  }) => {
459
+ const { cellHeight, textAlign: contextTextAlign } = useContext(TableContext);
460
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
427
461
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
462
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
428
463
  const borders = {
429
464
  borderRightWidth: isLast ? 0 : 1,
430
465
  borderBottomWidth: isLastRow ? 0 : 1,
431
466
  borderColor: "#000",
432
- ...height !== void 0 && { height }
467
+ minHeight: cellHeightValue
433
468
  };
434
- return /* @__PURE__ */ React5.createElement(View4, { style: [
435
- styles5.text,
436
- isOdd && styles5.zebraOdd,
437
- { width: baseWidth },
438
- borders,
439
- style
440
- ] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
469
+ return /* @__PURE__ */ React5.createElement(
470
+ View4,
471
+ {
472
+ style: [
473
+ styles5.text,
474
+ isOdd && styles5.zebraOdd,
475
+ {
476
+ width: baseWidth
477
+ },
478
+ borders,
479
+ style
480
+ ]
481
+ },
482
+ /* @__PURE__ */ React5.createElement(Text3, { style: { textAlign: finalTextAlign } }, children)
483
+ );
441
484
  };
442
485
 
443
486
  // src/components/core/Grid.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-pdf-levelup",
3
- "version": "3.1.3",
3
+ "version": "3.1.16",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",