react-pdf-levelup 3.0.34 → 3.1.7

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",
453
+ alignItems: "flex-start"
454
+ // Changed from "left" to "flex-start"
448
455
  },
449
456
  text: {
450
457
  fontSize: 10,
451
458
  fontFamily: "Helvetica",
452
- paddingTop: 4,
453
459
  paddingLeft: 8,
454
- paddingRight: 8
460
+ paddingRight: 8,
461
+ justifyContent: "center",
462
+ alignItems: "flex-start"
463
+ // Changed from "left" to "flex-start"
455
464
  },
456
465
  zebraOdd: {
457
466
  backgroundColor: "#eeeeee"
458
467
  }
459
468
  });
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);
469
+ 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));
470
+ var Thead = ({ children, style, textAlign = "left" }) => {
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;
@@ -490,16 +502,27 @@ var Th = ({
490
502
  height,
491
503
  colSpan,
492
504
  isLast = false,
493
- isLastRow = false
505
+ isLastRow = false,
506
+ textAlign: propTextAlign
494
507
  }) => {
508
+ const { cellHeight, textAlign: contextTextAlign } = (0, import_react5.useContext)(TableContext);
509
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
495
510
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
511
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
496
512
  const borders = {
497
513
  borderRightWidth: isLast ? 0 : 1,
498
514
  borderBottomWidth: isLastRow ? 0 : 1,
499
515
  borderColor: "#000",
500
- ...height !== void 0 && { height }
516
+ minHeight: cellHeightValue
501
517
  };
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));
518
+ return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [
519
+ styles5.textBold,
520
+ {
521
+ width: baseWidth
522
+ },
523
+ borders,
524
+ style
525
+ ] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, { style: { textAlign: finalTextAlign } }, children));
503
526
  };
504
527
  var Td = ({
505
528
  children,
@@ -509,22 +532,28 @@ var Td = ({
509
532
  colSpan,
510
533
  isLast = false,
511
534
  isLastRow = false,
512
- isOdd = false
535
+ isOdd = false,
536
+ textAlign: propTextAlign
513
537
  }) => {
538
+ const { cellHeight, textAlign: contextTextAlign } = (0, import_react5.useContext)(TableContext);
539
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
514
540
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
541
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
515
542
  const borders = {
516
543
  borderRightWidth: isLast ? 0 : 1,
517
544
  borderBottomWidth: isLastRow ? 0 : 1,
518
545
  borderColor: "#000",
519
- ...height !== void 0 && { height }
546
+ minHeight: cellHeightValue
520
547
  };
521
548
  return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [
522
549
  styles5.text,
523
550
  isOdd && styles5.zebraOdd,
524
- { width: baseWidth },
551
+ {
552
+ width: baseWidth
553
+ },
525
554
  borders,
526
555
  style
527
- ] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, null, children));
556
+ ] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, { style: { textAlign: finalTextAlign } }, children));
528
557
  };
529
558
 
530
559
  // 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';
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';
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';
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';
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",
366
+ alignItems: "flex-start"
367
+ // Changed from "left" to "flex-start"
361
368
  },
362
369
  text: {
363
370
  fontSize: 10,
364
371
  fontFamily: "Helvetica",
365
- paddingTop: 4,
366
372
  paddingLeft: 8,
367
- paddingRight: 8
373
+ paddingRight: 8,
374
+ justifyContent: "center",
375
+ alignItems: "flex-start"
376
+ // Changed from "left" to "flex-start"
368
377
  },
369
378
  zebraOdd: {
370
379
  backgroundColor: "#eeeeee"
371
380
  }
372
381
  });
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);
382
+ var Table = ({ children, style, cellHeight = 22 }) => /* @__PURE__ */ React5.createElement(TableContext.Provider, { value: { cellHeight, textAlign: "left" } }, /* @__PURE__ */ React5.createElement(View4, { style: [styles5.table, style] }, children));
383
+ var Thead = ({ children, style, textAlign = "left" }) => {
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;
@@ -403,16 +415,27 @@ var Th = ({
403
415
  height,
404
416
  colSpan,
405
417
  isLast = false,
406
- isLastRow = false
418
+ isLastRow = false,
419
+ textAlign: propTextAlign
407
420
  }) => {
421
+ const { cellHeight, textAlign: contextTextAlign } = useContext(TableContext);
422
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
408
423
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
424
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
409
425
  const borders = {
410
426
  borderRightWidth: isLast ? 0 : 1,
411
427
  borderBottomWidth: isLastRow ? 0 : 1,
412
428
  borderColor: "#000",
413
- ...height !== void 0 && { height }
429
+ minHeight: cellHeightValue
414
430
  };
415
- return /* @__PURE__ */ React5.createElement(View4, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
431
+ return /* @__PURE__ */ React5.createElement(View4, { style: [
432
+ styles5.textBold,
433
+ {
434
+ width: baseWidth
435
+ },
436
+ borders,
437
+ style
438
+ ] }, /* @__PURE__ */ React5.createElement(Text3, { style: { textAlign: finalTextAlign } }, children));
416
439
  };
417
440
  var Td = ({
418
441
  children,
@@ -422,22 +445,28 @@ var Td = ({
422
445
  colSpan,
423
446
  isLast = false,
424
447
  isLastRow = false,
425
- isOdd = false
448
+ isOdd = false,
449
+ textAlign: propTextAlign
426
450
  }) => {
451
+ const { cellHeight, textAlign: contextTextAlign } = useContext(TableContext);
452
+ const finalTextAlign = propTextAlign || contextTextAlign || "left";
427
453
  const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
454
+ const cellHeightValue = height !== void 0 ? height : cellHeight;
428
455
  const borders = {
429
456
  borderRightWidth: isLast ? 0 : 1,
430
457
  borderBottomWidth: isLastRow ? 0 : 1,
431
458
  borderColor: "#000",
432
- ...height !== void 0 && { height }
459
+ minHeight: cellHeightValue
433
460
  };
434
461
  return /* @__PURE__ */ React5.createElement(View4, { style: [
435
462
  styles5.text,
436
463
  isOdd && styles5.zebraOdd,
437
- { width: baseWidth },
464
+ {
465
+ width: baseWidth
466
+ },
438
467
  borders,
439
468
  style
440
- ] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
469
+ ] }, /* @__PURE__ */ React5.createElement(Text3, { style: { textAlign: finalTextAlign } }, children));
441
470
  };
442
471
 
443
472
  // src/components/core/Grid.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-pdf-levelup",
3
- "version": "3.0.34",
3
+ "version": "3.1.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",