@@ -3,7 +3,35 @@ import * as React from 'react';
33export type ContainerProps = Readonly < React . ComponentPropsWithoutRef < 'table' > > ;
44
55export const Container = React . forwardRef < HTMLTableElement , ContainerProps > (
6- ( { children, style, ...props } , ref ) => {
6+ ( { children, style = { } , ...props } , ref ) => {
7+ // Split padding styles to improve compatibility with Klavyio and Outlook,
8+ // while preserving user-provided style property order without allocating
9+ // entry arrays on each render.
10+ const tdStyle : React . CSSProperties = { } ;
11+ const tableStyle : React . CSSProperties = { } ;
12+
13+ const styleRecord = style as Record < string , unknown > ;
14+
15+ for ( const key in styleRecord ) {
16+ if ( ! Object . prototype . hasOwnProperty . call ( styleRecord , key ) ) {
17+ continue ;
18+ }
19+
20+ const value = styleRecord [ key ] ;
21+
22+ if (
23+ key === 'padding' ||
24+ key === 'paddingTop' ||
25+ key === 'paddingRight' ||
26+ key === 'paddingBottom' ||
27+ key === 'paddingLeft'
28+ ) {
29+ ( tdStyle as Record < string , unknown > ) [ key ] = value ;
30+ } else {
31+ ( tableStyle as Record < string , unknown > ) [ key ] = value ;
32+ }
33+ }
34+
735 return (
836 < table
937 align = "center"
@@ -14,11 +42,11 @@ export const Container = React.forwardRef<HTMLTableElement, ContainerProps>(
1442 cellSpacing = "0"
1543 ref = { ref }
1644 role = "presentation"
17- style = { { maxWidth : '37.5em' , ...style } }
45+ style = { { maxWidth : '37.5em' , ...tableStyle } }
1846 >
1947 < tbody >
2048 < tr style = { { width : '100%' } } >
21- < td > { children } </ td >
49+ < td style = { tdStyle } > { children } </ td >
2250 </ tr >
2351 </ tbody >
2452 </ table >
0 commit comments