@formepdf/react 0.1.4 → 0.2.1

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
@@ -525,6 +525,15 @@ export function mapStyle(style) {
525
525
  left: style.marginLeft ?? hl,
526
526
  };
527
527
  }
528
+ // Flex shorthand: flex: N → flexGrow: N, flexShrink: 1, flexBasis: 0
529
+ if (style.flex !== undefined) {
530
+ if (style.flexGrow === undefined)
531
+ result.flexGrow = style.flex;
532
+ if (style.flexShrink === undefined)
533
+ result.flexShrink = 1;
534
+ if (style.flexBasis === undefined)
535
+ result.flexBasis = { Pt: 0 };
536
+ }
528
537
  // Flex
529
538
  if (style.flexDirection !== undefined)
530
539
  result.flexDirection = FLEX_DIRECTION_MAP[style.flexDirection];
@@ -588,7 +597,8 @@ export function mapStyle(style) {
588
597
  };
589
598
  }
590
599
  if (style.borderColor !== undefined || style.borderTopColor !== undefined || style.borderRightColor !== undefined || style.borderBottomColor !== undefined || style.borderLeftColor !== undefined) {
591
- let base = {};
600
+ const defaultColor = parseColor('#000000');
601
+ let base = { top: defaultColor, right: defaultColor, bottom: defaultColor, left: defaultColor };
592
602
  if (typeof style.borderColor === 'string') {
593
603
  const c = parseColor(style.borderColor);
594
604
  base = { top: c, right: c, bottom: c, left: c };
@@ -602,10 +612,10 @@ export function mapStyle(style) {
602
612
  };
603
613
  }
604
614
  result.borderColor = {
605
- top: (style.borderTopColor ? parseColor(style.borderTopColor) : base.top),
606
- right: (style.borderRightColor ? parseColor(style.borderRightColor) : base.right),
607
- bottom: (style.borderBottomColor ? parseColor(style.borderBottomColor) : base.bottom),
608
- left: (style.borderLeftColor ? parseColor(style.borderLeftColor) : base.left),
615
+ top: style.borderTopColor ? parseColor(style.borderTopColor) : base.top,
616
+ right: style.borderRightColor ? parseColor(style.borderRightColor) : base.right,
617
+ bottom: style.borderBottomColor ? parseColor(style.borderBottomColor) : base.bottom,
618
+ left: style.borderLeftColor ? parseColor(style.borderLeftColor) : base.left,
609
619
  };
610
620
  }
611
621
  if (style.borderRadius !== undefined || style.borderTopLeftRadius !== undefined || style.borderTopRightRadius !== undefined || style.borderBottomRightRadius !== undefined || style.borderBottomLeftRadius !== undefined) {
package/dist/types.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface Style {
29
29
  maxWidth?: number | string;
30
30
  maxHeight?: number | string;
31
31
  flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
32
+ flex?: number;
32
33
  flexGrow?: number;
33
34
  flexShrink?: number;
34
35
  flexBasis?: number | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formepdf/react",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "JSX-to-JSON serializer for Forme PDF engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",