@react-email/section
Advanced tools
+8
-1
@@ -47,2 +47,9 @@ "use strict"; | ||
| }; | ||
| const arrayChildren = React.Children.toArray(children); | ||
| const hasTdElement = (child) => { | ||
| return React.isValidElement(child) && child.type === "td"; | ||
| }; | ||
| const finalChildren = arrayChildren.map((child, index) => { | ||
| return hasTdElement(child) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: child }, index); | ||
| }); | ||
| return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
@@ -59,3 +66,3 @@ "table", | ||
| ...props, | ||
| children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { style: styleDefaultTr, children }) }) | ||
| children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { style: styleDefaultTr, children: finalChildren }) }) | ||
| } | ||
@@ -62,0 +69,0 @@ ); |
+8
-1
@@ -15,2 +15,9 @@ // src/section.tsx | ||
| }; | ||
| const arrayChildren = React.Children.toArray(children); | ||
| const hasTdElement = (child) => { | ||
| return React.isValidElement(child) && child.type === "td"; | ||
| }; | ||
| const finalChildren = arrayChildren.map((child, index) => { | ||
| return hasTdElement(child) ? child : /* @__PURE__ */ jsx("td", { children: child }, index); | ||
| }); | ||
| return /* @__PURE__ */ jsx( | ||
@@ -27,3 +34,3 @@ "table", | ||
| ...props, | ||
| children: /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx("tr", { style: styleDefaultTr, children }) }) | ||
| children: /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx("tr", { style: styleDefaultTr, children: finalChildren }) }) | ||
| } | ||
@@ -30,0 +37,0 @@ ); |
+1
-1
| { | ||
| "name": "@react-email/section", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "description": "Display a section that can be formatted using columns", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
+4
-1
@@ -36,6 +36,9 @@  | ||
| import { Section } from '@react-email/section'; | ||
| import { Text } from '@react-email/text'; | ||
| const Section = () => { | ||
| return ( | ||
| <Section>{/* Any column. */}<Section /> | ||
| <Section> | ||
| <Text>Hello World</Text> | ||
| <Section /> | ||
| ); | ||
@@ -42,0 +45,0 @@ }; |
9628
8.98%120
13.21%58
5.45%