@pagenflow/email 1.3.2 → 1.3.4
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/components/Row.d.ts +5 -0
- package/dist/index.cjs.js +306 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +307 -25
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,4 +24,6 @@ export { default as Spacer } from './components/Spacer';
|
|
|
24
24
|
export type { SpacerProps, SpacerConfig } from './components/Spacer';
|
|
25
25
|
export { default as Text } from './components/Text';
|
|
26
26
|
export type { TextProps, TextConfig } from './components/Text';
|
|
27
|
+
export { default as Icon } from './components/Icon';
|
|
28
|
+
export type { IconProps, IconConfig } from './components/Icon';
|
|
27
29
|
export * from "./types";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import React, { memo, Fragment } from 'react';
|
|
3
3
|
|
|
4
4
|
function Body({ children, config = {} }) {
|
|
@@ -1524,7 +1524,7 @@ function arePropsEqual(prevProps, nextProps) {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
|
|
1526
1526
|
// Map alignment to HTML 'align' attribute
|
|
1527
|
-
const justifyMap$
|
|
1527
|
+
const justifyMap$3 = {
|
|
1528
1528
|
start: "left",
|
|
1529
1529
|
center: "center",
|
|
1530
1530
|
end: "right",
|
|
@@ -1547,7 +1547,7 @@ function Button({ config, devMode }) {
|
|
|
1547
1547
|
const vmlFillColor = backgroundColor.startsWith("#")
|
|
1548
1548
|
? backgroundColor
|
|
1549
1549
|
: `#${backgroundColor}`;
|
|
1550
|
-
const align = justifyMap$
|
|
1550
|
+
const align = justifyMap$3[justifyContent];
|
|
1551
1551
|
// Build VML font styles
|
|
1552
1552
|
const vmlFontWeight = fontWeight || "bold";
|
|
1553
1553
|
const vmlFontStyle = fontStyle === "italic" ? "font-style:italic;" : "";
|
|
@@ -1710,7 +1710,7 @@ const alignMap$1 = {
|
|
|
1710
1710
|
center: "middle",
|
|
1711
1711
|
end: "bottom",
|
|
1712
1712
|
};
|
|
1713
|
-
const justifyMap$
|
|
1713
|
+
const justifyMap$2 = {
|
|
1714
1714
|
start: "left",
|
|
1715
1715
|
center: "center",
|
|
1716
1716
|
end: "right",
|
|
@@ -1814,7 +1814,7 @@ function Container({ children, config, devMode, devNode }) {
|
|
|
1814
1814
|
fontSize: "1px",
|
|
1815
1815
|
};
|
|
1816
1816
|
const justifyAlign = config.justifyContent
|
|
1817
|
-
? justifyMap$
|
|
1817
|
+
? justifyMap$2[config.justifyContent]
|
|
1818
1818
|
: "center";
|
|
1819
1819
|
const containerWidthAttr = widthType === "fixed" ? containerWidthPx : undefined;
|
|
1820
1820
|
const isStacking = config.shouldWrap && numChildren > 1;
|
|
@@ -1924,14 +1924,14 @@ function Head({ children, backgroundColor = "#ffffff", title = "Email Preview",
|
|
|
1924
1924
|
}
|
|
1925
1925
|
`;
|
|
1926
1926
|
const globalStyles = `
|
|
1927
|
-
@media screen and (max-width:
|
|
1927
|
+
@media screen and (max-width: 768px) {
|
|
1928
1928
|
.container-fixed-width {
|
|
1929
1929
|
width: 100% !important;
|
|
1930
1930
|
max-width: 100% !important;
|
|
1931
1931
|
}
|
|
1932
1932
|
}
|
|
1933
1933
|
|
|
1934
|
-
@media screen and (max-width:
|
|
1934
|
+
@media screen and (max-width: 768px) {
|
|
1935
1935
|
.stack-td {
|
|
1936
1936
|
width: 100% !important;
|
|
1937
1937
|
display: block !important;
|
|
@@ -1954,6 +1954,122 @@ function Head({ children, backgroundColor = "#ffffff", title = "Email Preview",
|
|
|
1954
1954
|
mso-line-height-rule: exactly;
|
|
1955
1955
|
}
|
|
1956
1956
|
}
|
|
1957
|
+
|
|
1958
|
+
@media only screen and (max-width: 768px) {
|
|
1959
|
+
/* 1. Handling Mobile Alignment (Justify) - Works for both wrapped and non-wrapped */
|
|
1960
|
+
/* We target the inner table alignment */
|
|
1961
|
+
.responsive-row[data-mobile-justify="center"] .content-table {
|
|
1962
|
+
margin: 0 auto !important;
|
|
1963
|
+
float: none !important;
|
|
1964
|
+
}
|
|
1965
|
+
.responsive-row[data-mobile-justify="start"] .content-table {
|
|
1966
|
+
margin: 0 !important;
|
|
1967
|
+
float: left !important;
|
|
1968
|
+
}
|
|
1969
|
+
.responsive-row[data-mobile-justify="end"] .content-table {
|
|
1970
|
+
margin: 0 0 0 auto !important;
|
|
1971
|
+
float: right !important;
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
/* Mobile justify for wrapped children - we need to target the outer wrapper td */
|
|
1975
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-justify="center"] td[align] {
|
|
1976
|
+
text-align: center !important;
|
|
1977
|
+
}
|
|
1978
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-justify="start"] td[align] {
|
|
1979
|
+
text-align: left !important;
|
|
1980
|
+
}
|
|
1981
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-justify="end"] td[align] {
|
|
1982
|
+
text-align: right !important;
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
/* Also apply to child content tables for better support */
|
|
1986
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-justify="center"] .child-cell table {
|
|
1987
|
+
margin-left: auto !important;
|
|
1988
|
+
margin-right: auto !important;
|
|
1989
|
+
}
|
|
1990
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-justify="start"] .child-cell table {
|
|
1991
|
+
margin-left: 0 !important;
|
|
1992
|
+
margin-right: auto !important;
|
|
1993
|
+
}
|
|
1994
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-justify="end"] .child-cell table {
|
|
1995
|
+
margin-left: auto !important;
|
|
1996
|
+
margin-right: 0 !important;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
/* 2. Handling Mobile Vertical Alignment (Align Items) */
|
|
2000
|
+
/* For non-wrapped rows - controls vertical alignment when cells are side-by-side */
|
|
2001
|
+
.responsive-row[data-mobile-align="center"]:not([data-mobile-wrap="true"]) .child-cell {
|
|
2002
|
+
vertical-align: middle !important;
|
|
2003
|
+
}
|
|
2004
|
+
.responsive-row[data-mobile-align="start"]:not([data-mobile-wrap="true"]) .child-cell {
|
|
2005
|
+
vertical-align: top !important;
|
|
2006
|
+
}
|
|
2007
|
+
.responsive-row[data-mobile-align="end"]:not([data-mobile-wrap="true"]) .child-cell {
|
|
2008
|
+
vertical-align: bottom !important;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
/* For wrapped rows - alignItems controls vertical alignment of content within each child cell */
|
|
2012
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-align="center"] .child-cell {
|
|
2013
|
+
vertical-align: middle !important;
|
|
2014
|
+
}
|
|
2015
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-align="start"] .child-cell {
|
|
2016
|
+
vertical-align: top !important;
|
|
2017
|
+
}
|
|
2018
|
+
.responsive-row[data-mobile-wrap="true"][data-mobile-align="end"] .child-cell {
|
|
2019
|
+
vertical-align: bottom !important;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
/* 3. Handling Mobile Wrap - Pure CSS Solution */
|
|
2023
|
+
/* Force table to act like block container */
|
|
2024
|
+
.responsive-row[data-mobile-wrap="true"] .content-table {
|
|
2025
|
+
width: 100% !important;
|
|
2026
|
+
max-width: 100% !important;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
/* Force table row to stack cells */
|
|
2030
|
+
.responsive-row[data-mobile-wrap="true"] .content-tr {
|
|
2031
|
+
display: block !important;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/* Force each child cell to be full width block */
|
|
2035
|
+
.responsive-row[data-mobile-wrap="true"] .child-cell {
|
|
2036
|
+
display: block !important;
|
|
2037
|
+
width: 100% !important;
|
|
2038
|
+
box-sizing: border-box !important;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
/* Hide horizontal gap cells and create vertical spacing with padding */
|
|
2042
|
+
.responsive-row[data-mobile-wrap="true"] .row-gap-td {
|
|
2043
|
+
display: none !important;
|
|
2044
|
+
width: 0 !important;
|
|
2045
|
+
height: 0 !important;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
/* Add vertical spacing between stacked cells using margin */
|
|
2049
|
+
.responsive-row[data-mobile-wrap="true"] .child-cell:not(:last-child) {
|
|
2050
|
+
margin-bottom: 20px !important;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
/* Dynamic gap support - common values */
|
|
2054
|
+
.responsive-row[data-mobile-wrap="true"][data-gap="10px"] .child-cell:not(:last-child) {
|
|
2055
|
+
margin-bottom: 10px !important;
|
|
2056
|
+
}
|
|
2057
|
+
.responsive-row[data-mobile-wrap="true"][data-gap="15px"] .child-cell:not(:last-child) {
|
|
2058
|
+
margin-bottom: 15px !important;
|
|
2059
|
+
}
|
|
2060
|
+
.responsive-row[data-mobile-wrap="true"][data-gap="20px"] .child-cell:not(:last-child) {
|
|
2061
|
+
margin-bottom: 20px !important;
|
|
2062
|
+
}
|
|
2063
|
+
.responsive-row[data-mobile-wrap="true"][data-gap="24px"] .child-cell:not(:last-child) {
|
|
2064
|
+
margin-bottom: 24px !important;
|
|
2065
|
+
}
|
|
2066
|
+
.responsive-row[data-mobile-wrap="true"][data-gap="30px"] .child-cell:not(:last-child) {
|
|
2067
|
+
margin-bottom: 30px !important;
|
|
2068
|
+
}
|
|
2069
|
+
.responsive-row[data-mobile-wrap="true"][data-gap="40px"] .child-cell:not(:last-child) {
|
|
2070
|
+
margin-bottom: 40px !important;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
1957
2073
|
|
|
1958
2074
|
/* ================================================= */
|
|
1959
2075
|
/* 🔒 UNIVERSAL LINK RESET */
|
|
@@ -2150,7 +2266,7 @@ function Image({ config, devNode, devMode }) {
|
|
|
2150
2266
|
}
|
|
2151
2267
|
var Image_default = memo(Image, arePropsEqual);
|
|
2152
2268
|
|
|
2153
|
-
const justifyMap = {
|
|
2269
|
+
const justifyMap$1 = {
|
|
2154
2270
|
start: "left",
|
|
2155
2271
|
center: "center",
|
|
2156
2272
|
end: "right",
|
|
@@ -2182,7 +2298,7 @@ function getBorderStyle$1(border) {
|
|
|
2182
2298
|
return style;
|
|
2183
2299
|
}
|
|
2184
2300
|
function Row({ children, config, devNode }) {
|
|
2185
|
-
var _a, _b, _c;
|
|
2301
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2186
2302
|
const childrenArray = (Array.isArray(children) ? children : [children]).filter((child) => child != null);
|
|
2187
2303
|
const numChildren = childrenArray.length;
|
|
2188
2304
|
// 1. Outer TD for Background and Border Radius (no border here)
|
|
@@ -2215,7 +2331,7 @@ function Row({ children, config, devNode }) {
|
|
|
2215
2331
|
fontSize: "1px",
|
|
2216
2332
|
};
|
|
2217
2333
|
const tdAlign = config.justifyContent
|
|
2218
|
-
? justifyMap[config.justifyContent]
|
|
2334
|
+
? justifyMap$1[config.justifyContent]
|
|
2219
2335
|
: "left";
|
|
2220
2336
|
const tdValign = config.alignItems ? alignMap[config.alignItems] : "top";
|
|
2221
2337
|
return (jsxs("table", Object.assign({ "aria-label": "Row Outer", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: {
|
|
@@ -2223,17 +2339,17 @@ function Row({ children, config, devNode }) {
|
|
|
2223
2339
|
width: config.width || "100%",
|
|
2224
2340
|
height: config.height,
|
|
2225
2341
|
borderCollapse: "collapse",
|
|
2226
|
-
} }, (config.height && { height: config.height }), { children: [jsx("tbody", { children: jsx("tr", { children: jsx("td", Object.assign({ style: backgroundTdStyle }, (config.height && { height: config.height }), { children: jsx("table", { "aria-label": "Row Border Wrapper", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: borderTableStyle, children: jsx("tbody", { children: jsx("tr", { children: jsx("td", { style: paddingTdStyle, children: jsx("table", { "aria-label": "Row Justification Wrapper", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: {
|
|
2342
|
+
} }, (config.height && { height: config.height }), { "data-mobile-justify": (_d = config.mobile) === null || _d === void 0 ? void 0 : _d.justifyContent, "data-mobile-align": (_e = config.mobile) === null || _e === void 0 ? void 0 : _e.alignItems, "data-mobile-wrap": ((_f = config.mobile) === null || _f === void 0 ? void 0 : _f.wrap) ? "true" : undefined, "data-gap": config.gap, className: "responsive-row", children: [jsx("tbody", { children: jsx("tr", { children: jsx("td", Object.assign({ style: backgroundTdStyle }, (config.height && { height: config.height }), { children: jsx("table", { "aria-label": "Row Border Wrapper", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: borderTableStyle, children: jsx("tbody", { children: jsx("tr", { children: jsx("td", { style: paddingTdStyle, children: jsx("table", { "aria-label": "Row Justification Wrapper", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: {
|
|
2227
2343
|
width: "100%",
|
|
2228
2344
|
height: "100%",
|
|
2229
2345
|
borderCollapse: "collapse",
|
|
2230
|
-
}, children: jsx("tbody", { children: jsx("tr", { children: jsx("td", { align: tdAlign, children: jsx("table", Object.assign({ "aria-label": "Row Content", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: contentTableStyle }, (config.height && { height: config.height }), { children: jsx("tbody", { children: jsx("tr", { children: childrenArray.map((child, index) => (jsxs(Fragment, { children: [jsx("td", { valign: tdValign, style: {
|
|
2346
|
+
}, children: jsx("tbody", { children: jsx("tr", { children: jsx("td", { align: tdAlign, children: jsx("table", Object.assign({ "aria-label": "Row Content", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: contentTableStyle }, (config.height && { height: config.height }), { className: "content-table", children: jsx("tbody", { children: jsx("tr", { className: "content-tr", children: childrenArray.map((child, index) => (jsxs(Fragment, { children: [jsx("td", { valign: tdValign, style: {
|
|
2231
2347
|
verticalAlign: tdValign,
|
|
2232
2348
|
textAlign: "left",
|
|
2233
2349
|
padding: "0",
|
|
2234
2350
|
margin: "0",
|
|
2235
|
-
}, children: child }), index < numChildren - 1 &&
|
|
2236
|
-
config.gap && (jsx("td", { width: config.gap, style: gapTdStyle, children: "\u00A0" }, `row-gap-${index}`))] }, `row-child-${index}`))) }) }) })) }) }) }) }) }) }) }) }) })) }) }), devNode && (jsx("tfoot", { children: jsx("tr", { children: jsx("td", { children: devNode }) }) }))] })));
|
|
2351
|
+
}, className: "child-cell", children: child }), index < numChildren - 1 &&
|
|
2352
|
+
config.gap && (jsx("td", { width: config.gap, style: gapTdStyle, className: "row-gap-td", children: "\u00A0" }, `row-gap-${index}`))] }, `row-child-${index}`))) }) }) })) }) }) }) }) }) }) }) }) })) }) }), devNode && (jsx("tfoot", { children: jsx("tr", { children: jsx("td", { children: devNode }) }) }))] })));
|
|
2237
2353
|
}
|
|
2238
2354
|
var Row_default = memo(Row, arePropsEqual);
|
|
2239
2355
|
|
|
@@ -2314,7 +2430,6 @@ function Spacer({ config, devNode }) {
|
|
|
2314
2430
|
var Spacer_default = memo(Spacer, arePropsEqual);
|
|
2315
2431
|
|
|
2316
2432
|
function Text({ config, devMode, children }) {
|
|
2317
|
-
var _a;
|
|
2318
2433
|
const { text, padding, color, textAlign, fontSize, fontWeight, fontStyle, lineHeight, letterSpacing, textTransform, textDecoration, direction, verticalAlign, backgroundColor, opacity, whiteSpace, } = config;
|
|
2319
2434
|
// 1. TD Style: Where padding and background are reliably applied.
|
|
2320
2435
|
const tdStyle = {
|
|
@@ -2323,9 +2438,7 @@ function Text({ config, devMode, children }) {
|
|
|
2323
2438
|
width: "100%",
|
|
2324
2439
|
verticalAlign: "top",
|
|
2325
2440
|
};
|
|
2326
|
-
// 2. Content Style: Applied directly to a wrapper element
|
|
2327
|
-
// or inherited by the children. For max compatibility, we apply core styles
|
|
2328
|
-
// directly to the TD or a wrapper <p> (if children is just a string).
|
|
2441
|
+
// 2. Content Style: Applied directly to a wrapper element
|
|
2329
2442
|
const contentStyle = {
|
|
2330
2443
|
color: color,
|
|
2331
2444
|
textAlign: textAlign,
|
|
@@ -2340,18 +2453,187 @@ function Text({ config, devMode, children }) {
|
|
|
2340
2453
|
verticalAlign: verticalAlign,
|
|
2341
2454
|
opacity: opacity,
|
|
2342
2455
|
whiteSpace: whiteSpace,
|
|
2343
|
-
margin: "0",
|
|
2456
|
+
margin: "0",
|
|
2344
2457
|
padding: "0",
|
|
2345
|
-
fontFamily: "Arial, Helvetica, sans-serif",
|
|
2458
|
+
fontFamily: "Arial, Helvetica, sans-serif",
|
|
2346
2459
|
};
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2460
|
+
// Determine content to render
|
|
2461
|
+
const content = text !== null && text !== void 0 ? text : children;
|
|
2462
|
+
const isString = typeof content === "string";
|
|
2463
|
+
return (jsx("table", { "aria-label": "Text Block Wrapper", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, style: {
|
|
2350
2464
|
width: "100%",
|
|
2351
2465
|
borderCollapse: "collapse",
|
|
2352
|
-
}, children: jsx("tbody", { children: jsx("tr", { children: jsx("td", { style: tdStyle, align: textAlign, children: jsx("div", { style: contentStyle, dangerouslySetInnerHTML: { __html:
|
|
2466
|
+
}, children: jsx("tbody", { children: jsx("tr", { children: jsx("td", { style: tdStyle, align: textAlign, children: isString ? (jsx("div", { style: contentStyle, dangerouslySetInnerHTML: { __html: content } })) : (jsx("div", { style: contentStyle, children: content })) }) }) }) }));
|
|
2353
2467
|
}
|
|
2354
2468
|
var Text_default = memo(Text, arePropsEqual);
|
|
2355
2469
|
|
|
2356
|
-
|
|
2470
|
+
// Map alignment to HTML 'align' attribute
|
|
2471
|
+
const justifyMap = {
|
|
2472
|
+
start: "left",
|
|
2473
|
+
center: "center",
|
|
2474
|
+
end: "right",
|
|
2475
|
+
};
|
|
2476
|
+
// Helper to build Iconify API URL
|
|
2477
|
+
function buildIconifyUrl(config) {
|
|
2478
|
+
const { iconIdentifier, height = 24, color = "000000", rotate = 0, rotateOrientation = "cw", } = config;
|
|
2479
|
+
if (!iconIdentifier)
|
|
2480
|
+
return null;
|
|
2481
|
+
// Remove # from color if present
|
|
2482
|
+
const cleanColor = color.replace("#", "");
|
|
2483
|
+
// Build URL from template
|
|
2484
|
+
const template = process.env.ICONIFY_API_IMAGE_URI ||
|
|
2485
|
+
"https://iconify.pagenflow.com/api/image/{{height}}/{{color}}/{{rotate}}-{{rotate-orientation}}/{{icon-full-name}}.png";
|
|
2486
|
+
return template
|
|
2487
|
+
.replace("{{height}}", String(Number(height) * Number(2)))
|
|
2488
|
+
.replace("{{color}}", cleanColor)
|
|
2489
|
+
.replace("{{rotate}}", String(rotate))
|
|
2490
|
+
.replace("{{rotate-orientation}}", rotateOrientation)
|
|
2491
|
+
.replace("{{icon-full-name}}", iconIdentifier);
|
|
2492
|
+
}
|
|
2493
|
+
// Helper to build link href based on innerLink type
|
|
2494
|
+
function buildLinkHref(innerLink) {
|
|
2495
|
+
if (!innerLink || innerLink.type === "none")
|
|
2496
|
+
return null;
|
|
2497
|
+
switch (innerLink.type) {
|
|
2498
|
+
case "url":
|
|
2499
|
+
return innerLink.url || null;
|
|
2500
|
+
case "email":
|
|
2501
|
+
return innerLink.email ? `mailto:${innerLink.email}` : null;
|
|
2502
|
+
case "phone":
|
|
2503
|
+
return innerLink.phone ? `tel:${innerLink.phone}` : null;
|
|
2504
|
+
case "anchor":
|
|
2505
|
+
return innerLink.anchor ? `#${innerLink.anchor}` : null;
|
|
2506
|
+
case "page_top":
|
|
2507
|
+
return "#top";
|
|
2508
|
+
case "page_bottom":
|
|
2509
|
+
return "#bottom";
|
|
2510
|
+
default:
|
|
2511
|
+
return null;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
function Icon({ config, devNode, devMode, children }) {
|
|
2515
|
+
const {
|
|
2516
|
+
// base64Source,
|
|
2517
|
+
width, height, backgroundColor, padding = "0", borderRadius = "0", innerLink, justifyContent = "center", } = config;
|
|
2518
|
+
// Determine icon source
|
|
2519
|
+
const iconSrc = buildIconifyUrl(config);
|
|
2520
|
+
const href = buildLinkHref(innerLink);
|
|
2521
|
+
const target = (innerLink === null || innerLink === void 0 ? void 0 : innerLink.target) || "_self";
|
|
2522
|
+
const align = justifyMap[justifyContent];
|
|
2523
|
+
// Convert width/height to string with px if number
|
|
2524
|
+
const widthStr = typeof width === "number" ? `${width}px` : width;
|
|
2525
|
+
const heightStr = typeof height === "number" ? `${height}px` : height;
|
|
2526
|
+
// Parse numeric values for HTML attributes
|
|
2527
|
+
const widthNum = typeof width === "number"
|
|
2528
|
+
? width
|
|
2529
|
+
: typeof width === "string" && width.endsWith("px")
|
|
2530
|
+
? parseInt(width, 10)
|
|
2531
|
+
: undefined;
|
|
2532
|
+
const heightNum = typeof height === "number"
|
|
2533
|
+
? height
|
|
2534
|
+
: typeof height === "string" && height.endsWith("px")
|
|
2535
|
+
? parseInt(height, 10)
|
|
2536
|
+
: undefined;
|
|
2537
|
+
// 1. Image Style: Critical for compatibility
|
|
2538
|
+
const imgStyle = {
|
|
2539
|
+
display: "block", // Prevents extra vertical space
|
|
2540
|
+
border: 0, // No default border
|
|
2541
|
+
width: widthStr || "auto",
|
|
2542
|
+
height: heightStr || "auto",
|
|
2543
|
+
};
|
|
2544
|
+
// 2. Link Style: No underline or color changes
|
|
2545
|
+
const linkStyle = {
|
|
2546
|
+
display: "block",
|
|
2547
|
+
textDecoration: "none",
|
|
2548
|
+
border: 0,
|
|
2549
|
+
outline: "none",
|
|
2550
|
+
};
|
|
2551
|
+
// 3. TD Style: Padding and background
|
|
2552
|
+
const tdStyle = {
|
|
2553
|
+
padding: padding,
|
|
2554
|
+
backgroundColor: backgroundColor,
|
|
2555
|
+
fontSize: "0", // CRITICAL: Collapses extra space
|
|
2556
|
+
lineHeight: "0", // CRITICAL: Collapses extra space7
|
|
2557
|
+
borderRadius: borderRadius,
|
|
2558
|
+
overflow: "hidden",
|
|
2559
|
+
};
|
|
2560
|
+
// --- VML Calculation for Outlook Compatibility ---
|
|
2561
|
+
const numericPadding = parseInt(padding.split(" ")[0] || "0", 10);
|
|
2562
|
+
const vmlWidth = (widthNum || 24) + numericPadding * 2;
|
|
2563
|
+
const vmlHeight = (heightNum || 24) + numericPadding * 2;
|
|
2564
|
+
// VML colors must use full hex format
|
|
2565
|
+
const vmlFillColor = (backgroundColor === null || backgroundColor === void 0 ? void 0 : backgroundColor.startsWith("#"))
|
|
2566
|
+
? backgroundColor
|
|
2567
|
+
: backgroundColor
|
|
2568
|
+
? `#${backgroundColor}`
|
|
2569
|
+
: "#ffffff";
|
|
2570
|
+
// Calculate arcsize percentage for VML
|
|
2571
|
+
const numericBorderRadius = parseInt(borderRadius || "0", 10);
|
|
2572
|
+
const arcsize = numericBorderRadius > 0
|
|
2573
|
+
? Math.min((numericBorderRadius / Math.min(vmlWidth, vmlHeight)) * 100, 100)
|
|
2574
|
+
: 0;
|
|
2575
|
+
// Build VML code for Outlook
|
|
2576
|
+
const vmlIcon = backgroundColor && numericBorderRadius > 0
|
|
2577
|
+
? `
|
|
2578
|
+
<!--[if mso]>
|
|
2579
|
+
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" ${href && !devMode ? `href="${href}"` : ""} style="height:${vmlHeight}px;width:${vmlWidth}px;v-text-anchor:middle;" arcsize="${arcsize}%" stroke="false" fillcolor="${vmlFillColor}">
|
|
2580
|
+
<w:anchorlock/>
|
|
2581
|
+
<v:textbox inset="0,0,0,0" style="text-align: center;">
|
|
2582
|
+
<center style="padding:${padding};">
|
|
2583
|
+
<img src="${iconSrc || ""}" alt="" width="${widthNum || 24}" height="${heightNum || 24}" border="0" style="display:block;border:0;" />
|
|
2584
|
+
</center>
|
|
2585
|
+
</v:textbox>
|
|
2586
|
+
</v:roundrect>
|
|
2587
|
+
<![endif]-->
|
|
2588
|
+
`
|
|
2589
|
+
: "";
|
|
2590
|
+
// If no icon source, return empty
|
|
2591
|
+
if (!iconSrc && !devMode) {
|
|
2592
|
+
return null;
|
|
2593
|
+
}
|
|
2594
|
+
// Icon image element
|
|
2595
|
+
const iconElement = devMode && !!children ? (children) : iconSrc ? (jsx("img", { draggable: false, src: iconSrc, alt: "" // Icons are decorative, empty alt is appropriate
|
|
2596
|
+
, style: imgStyle, width: widthNum, height: heightNum, border: 0 })) : (jsx(Fragment$1, {}));
|
|
2597
|
+
// Wrap in link if href exists and not in dev mode
|
|
2598
|
+
const content = href && !devMode ? (jsx("a", Object.assign({ href: href, target: target, style: linkStyle }, (target === "_blank" ? { rel: "noopener noreferrer" } : {}), { children: iconElement }))) : (iconElement);
|
|
2599
|
+
// Build the HTML content with VML support (only when NOT in dev mode)
|
|
2600
|
+
const useVML = !devMode && backgroundColor && numericBorderRadius > 0;
|
|
2601
|
+
const htmlContent = useVML
|
|
2602
|
+
? `
|
|
2603
|
+
${vmlIcon}
|
|
2604
|
+
<!--[if !mso]><!-->
|
|
2605
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse; width: 100%;">
|
|
2606
|
+
<tbody>
|
|
2607
|
+
<tr>
|
|
2608
|
+
<td style="background-color: ${backgroundColor}; border-radius: ${borderRadius}; padding: ${padding}; font-size: 0; line-height: 0; overflow: hidden;">
|
|
2609
|
+
${href
|
|
2610
|
+
? `<a href="${href}" target="${target}" style="display:block;text-decoration:none;border:0;outline:none;" ${target === "_blank" ? 'rel="noopener noreferrer"' : ""}>
|
|
2611
|
+
<img draggable="false" src="${iconSrc}" alt="" width="${widthNum || 24}" height="${heightNum || 24}" border="0" style="display:block;border:0;width:${widthStr || "auto"};height:${heightStr || "auto"};" />
|
|
2612
|
+
</a>`
|
|
2613
|
+
: `<img draggable="false" src="${iconSrc}" alt="" width="${widthNum || 24}" height="${heightNum || 24}" border="0" style="display:block;border:0;width:${widthStr || "auto"};height:${heightStr || "auto"};" />`}
|
|
2614
|
+
</td>
|
|
2615
|
+
</tr>
|
|
2616
|
+
</tbody>
|
|
2617
|
+
</table>
|
|
2618
|
+
<!--<![endif]-->
|
|
2619
|
+
`
|
|
2620
|
+
: null;
|
|
2621
|
+
return (jsxs("table", { "aria-label": "Icon", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, align: align, style: {
|
|
2622
|
+
// --- Start dev
|
|
2623
|
+
position: "relative",
|
|
2624
|
+
// --- End dev
|
|
2625
|
+
width: widthStr || "auto",
|
|
2626
|
+
borderCollapse: "collapse",
|
|
2627
|
+
// base
|
|
2628
|
+
boxSizing: "border-box",
|
|
2629
|
+
border: 0,
|
|
2630
|
+
margin: 0,
|
|
2631
|
+
padding: 0,
|
|
2632
|
+
}, onClick: devMode ? (e) => e.preventDefault() : undefined, children: [jsx("tbody", { children: jsx("tr", { children: useVML ? (jsx("td", { dangerouslySetInnerHTML: {
|
|
2633
|
+
__html: htmlContent !== null && htmlContent !== void 0 ? htmlContent : "",
|
|
2634
|
+
} })) : (jsx("td", { style: tdStyle, align: align, children: content })) }) }), devMode && !!devNode && (jsx("tfoot", { children: jsx("tr", { children: jsx("td", { children: devNode }) }) }))] }));
|
|
2635
|
+
}
|
|
2636
|
+
var Icon_default = memo(Icon, arePropsEqual);
|
|
2637
|
+
|
|
2638
|
+
export { Body, Button_default as Button, Column_default as Column, Container_default as Container, Divider_default as Divider, Head, Heading_default as Heading, Html, Icon_default as Icon, Image_default as Image, Row_default as Row, Section_default as Section, Spacer_default as Spacer, Text_default as Text };
|
|
2357
2639
|
//# sourceMappingURL=index.esm.js.map
|