@formepdf/react 0.7.8 → 0.7.10

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/serialize.js CHANGED
@@ -670,7 +670,7 @@ export function mapStyle(style) {
670
670
  };
671
671
  }
672
672
  if (style.margin !== undefined || style.marginTop !== undefined || style.marginRight !== undefined || style.marginBottom !== undefined || style.marginLeft !== undefined || style.marginHorizontal !== undefined || style.marginVertical !== undefined) {
673
- const base = style.margin !== undefined ? expandEdges(style.margin) : { top: 0, right: 0, bottom: 0, left: 0 };
673
+ const base = style.margin !== undefined ? expandMarginEdges(style.margin) : { top: 0, right: 0, bottom: 0, left: 0 };
674
674
  const vt = style.marginVertical ?? base.top;
675
675
  const vb = style.marginVertical ?? base.bottom;
676
676
  const hl = style.marginHorizontal ?? base.left;
@@ -1060,6 +1060,23 @@ export function expandEdges(val) {
1060
1060
  }
1061
1061
  return { top: val.top, right: val.right, bottom: val.bottom, left: val.left };
1062
1062
  }
1063
+ /** Expand margin edges, preserving 'auto' string values. */
1064
+ function expandMarginEdges(val) {
1065
+ if (typeof val === 'number') {
1066
+ return { top: val, right: val, bottom: val, left: val };
1067
+ }
1068
+ if (typeof val === 'string') {
1069
+ if (val === 'auto') {
1070
+ return { top: 'auto', right: 'auto', bottom: 'auto', left: 'auto' };
1071
+ }
1072
+ const edges = parseCSSEdges(val);
1073
+ return edges;
1074
+ }
1075
+ if (Array.isArray(val)) {
1076
+ return parseCSSEdges(val);
1077
+ }
1078
+ return { top: val.top, right: val.right, bottom: val.bottom, left: val.left };
1079
+ }
1063
1080
  function expandEdgeValues(val) {
1064
1081
  if (typeof val === 'number') {
1065
1082
  return { top: val, right: val, bottom: val, left: val };
package/dist/types.d.ts CHANGED
@@ -76,12 +76,12 @@ export interface Style {
76
76
  paddingHorizontal?: number;
77
77
  paddingVertical?: number;
78
78
  margin?: number | string | number[] | Edges;
79
- marginTop?: number;
80
- marginRight?: number;
81
- marginBottom?: number;
82
- marginLeft?: number;
83
- marginHorizontal?: number;
84
- marginVertical?: number;
79
+ marginTop?: number | 'auto';
80
+ marginRight?: number | 'auto';
81
+ marginBottom?: number | 'auto';
82
+ marginLeft?: number | 'auto';
83
+ marginHorizontal?: number | 'auto';
84
+ marginVertical?: number | 'auto';
85
85
  fontSize?: number;
86
86
  fontFamily?: string;
87
87
  fontWeight?: number | 'normal' | 'bold';
@@ -469,6 +469,13 @@ export interface FormeEdges {
469
469
  bottom: number;
470
470
  left: number;
471
471
  }
472
+ /** Margin edges that support auto values (for centering). */
473
+ export interface FormeMarginEdges {
474
+ top: number | 'auto';
475
+ right: number | 'auto';
476
+ bottom: number | 'auto';
477
+ left: number | 'auto';
478
+ }
472
479
  export interface FormeNode {
473
480
  kind: FormeNodeKind;
474
481
  style: FormeStyle;
@@ -597,7 +604,7 @@ export interface FormeStyle {
597
604
  maxWidth?: FormeDimension;
598
605
  maxHeight?: FormeDimension;
599
606
  padding?: FormeEdges;
600
- margin?: FormeEdges;
607
+ margin?: FormeMarginEdges;
601
608
  flexDirection?: string;
602
609
  justifyContent?: string;
603
610
  alignItems?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formepdf/react",
3
- "version": "0.7.8",
3
+ "version": "0.7.10",
4
4
  "description": "JSX-to-JSON serializer for Forme PDF engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",