@postrun/react 2.4.0 → 2.5.0
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/index.cjs +180 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +180 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1342,6 +1342,111 @@ function useIsDark(theme) {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
return theme === "dark";
|
|
1344
1344
|
}
|
|
1345
|
+
function domainOf(source) {
|
|
1346
|
+
try {
|
|
1347
|
+
return new URL(source).hostname.replace(/^www\./, "");
|
|
1348
|
+
} catch {
|
|
1349
|
+
return source;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
function ArticleCard({ article, thumbnail }) {
|
|
1353
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle, children: [
|
|
1354
|
+
thumbnail ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: thumbnail.src, alt: thumbnail.alt ?? "", style: thumbStyle }) : null,
|
|
1355
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: metaStyle, children: [
|
|
1356
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: domainStyle, children: domainOf(article.source) }),
|
|
1357
|
+
article.title ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: titleStyle, children: article.title }) : null,
|
|
1358
|
+
article.description ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: descStyle, children: article.description }) : null
|
|
1359
|
+
] })
|
|
1360
|
+
] });
|
|
1361
|
+
}
|
|
1362
|
+
var cardStyle = {
|
|
1363
|
+
border: `1px solid ${varRef(LI_VAR.border)}`,
|
|
1364
|
+
borderRadius: 8,
|
|
1365
|
+
overflow: "hidden"
|
|
1366
|
+
};
|
|
1367
|
+
var thumbStyle = {
|
|
1368
|
+
width: "100%",
|
|
1369
|
+
display: "block",
|
|
1370
|
+
aspectRatio: "1.91 / 1",
|
|
1371
|
+
objectFit: "cover"
|
|
1372
|
+
};
|
|
1373
|
+
var metaStyle = {
|
|
1374
|
+
padding: "8px 12px",
|
|
1375
|
+
display: "flex",
|
|
1376
|
+
flexDirection: "column",
|
|
1377
|
+
gap: 2
|
|
1378
|
+
};
|
|
1379
|
+
var domainStyle = {
|
|
1380
|
+
fontSize: 12,
|
|
1381
|
+
color: varRef(LI_VAR.muted)
|
|
1382
|
+
};
|
|
1383
|
+
var titleStyle = {
|
|
1384
|
+
fontSize: 14,
|
|
1385
|
+
fontWeight: 600,
|
|
1386
|
+
color: varRef(LI_VAR.text),
|
|
1387
|
+
lineHeight: 1.3,
|
|
1388
|
+
display: "-webkit-box",
|
|
1389
|
+
WebkitLineClamp: 2,
|
|
1390
|
+
WebkitBoxOrient: "vertical",
|
|
1391
|
+
overflow: "hidden"
|
|
1392
|
+
};
|
|
1393
|
+
var descStyle = {
|
|
1394
|
+
fontSize: 12,
|
|
1395
|
+
color: varRef(LI_VAR.muted),
|
|
1396
|
+
lineHeight: 1.3,
|
|
1397
|
+
display: "-webkit-box",
|
|
1398
|
+
WebkitLineClamp: 1,
|
|
1399
|
+
WebkitBoxOrient: "vertical",
|
|
1400
|
+
overflow: "hidden"
|
|
1401
|
+
};
|
|
1402
|
+
function DocumentCard({ document, cover }) {
|
|
1403
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle2, children: [
|
|
1404
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: pageStyle, children: cover ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: cover.src, alt: cover.alt ?? "", style: coverStyle }) : /* @__PURE__ */ jsxRuntime.jsx(fi.FiFileText, { size: 56, "aria-hidden": true, style: { opacity: 0.5 } }) }),
|
|
1405
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: barStyle, children: [
|
|
1406
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: titleStyle2, children: document.title }),
|
|
1407
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: kindStyle, children: "Document" })
|
|
1408
|
+
] })
|
|
1409
|
+
] });
|
|
1410
|
+
}
|
|
1411
|
+
var cardStyle2 = {
|
|
1412
|
+
border: `1px solid ${varRef(LI_VAR.border)}`,
|
|
1413
|
+
borderRadius: 8,
|
|
1414
|
+
overflow: "hidden"
|
|
1415
|
+
};
|
|
1416
|
+
var pageStyle = {
|
|
1417
|
+
position: "relative",
|
|
1418
|
+
aspectRatio: "4 / 3",
|
|
1419
|
+
background: "rgba(127,127,127,0.12)",
|
|
1420
|
+
display: "grid",
|
|
1421
|
+
placeItems: "center",
|
|
1422
|
+
color: varRef(LI_VAR.muted)
|
|
1423
|
+
};
|
|
1424
|
+
var coverStyle = {
|
|
1425
|
+
width: "100%",
|
|
1426
|
+
height: "100%",
|
|
1427
|
+
objectFit: "cover"
|
|
1428
|
+
};
|
|
1429
|
+
var barStyle = {
|
|
1430
|
+
background: "rgba(0,0,0,0.85)",
|
|
1431
|
+
color: "#fff",
|
|
1432
|
+
padding: "10px 14px",
|
|
1433
|
+
display: "flex",
|
|
1434
|
+
flexDirection: "column",
|
|
1435
|
+
gap: 1
|
|
1436
|
+
};
|
|
1437
|
+
var titleStyle2 = {
|
|
1438
|
+
fontSize: 14,
|
|
1439
|
+
fontWeight: 600,
|
|
1440
|
+
lineHeight: 1.3,
|
|
1441
|
+
display: "-webkit-box",
|
|
1442
|
+
WebkitLineClamp: 2,
|
|
1443
|
+
WebkitBoxOrient: "vertical",
|
|
1444
|
+
overflow: "hidden"
|
|
1445
|
+
};
|
|
1446
|
+
var kindStyle = {
|
|
1447
|
+
fontSize: 12,
|
|
1448
|
+
color: "rgba(255,255,255,0.7)"
|
|
1449
|
+
};
|
|
1345
1450
|
var ROW2 = {
|
|
1346
1451
|
display: "flex",
|
|
1347
1452
|
justifyContent: "space-around",
|
|
@@ -1495,11 +1600,11 @@ function Tile({
|
|
|
1495
1600
|
] });
|
|
1496
1601
|
}
|
|
1497
1602
|
function ImageMosaic({ media }) {
|
|
1498
|
-
|
|
1603
|
+
const [only] = media;
|
|
1604
|
+
if (!only) {
|
|
1499
1605
|
return null;
|
|
1500
1606
|
}
|
|
1501
1607
|
if (media.length === 1) {
|
|
1502
|
-
const only = media[0];
|
|
1503
1608
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1504
1609
|
"img",
|
|
1505
1610
|
{
|
|
@@ -1545,6 +1650,48 @@ function Media({ media }) {
|
|
|
1545
1650
|
const images = media.filter((item) => item.kind === "image");
|
|
1546
1651
|
return /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { media: images });
|
|
1547
1652
|
}
|
|
1653
|
+
function Poll({ poll }) {
|
|
1654
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle, children: [
|
|
1655
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: questionStyle, children: poll.question }),
|
|
1656
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: optionsStyle, children: poll.options.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: optionStyle, children: option }, `${option}-${i}`)) }),
|
|
1657
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: footerStyle, children: [
|
|
1658
|
+
"0 votes \u2022 ",
|
|
1659
|
+
js.linkedinPollDurationLabel(poll.duration)
|
|
1660
|
+
] })
|
|
1661
|
+
] });
|
|
1662
|
+
}
|
|
1663
|
+
var wrapStyle = {
|
|
1664
|
+
border: `1px solid ${varRef(LI_VAR.border)}`,
|
|
1665
|
+
borderRadius: 8,
|
|
1666
|
+
padding: 12,
|
|
1667
|
+
display: "flex",
|
|
1668
|
+
flexDirection: "column",
|
|
1669
|
+
gap: 10
|
|
1670
|
+
};
|
|
1671
|
+
var questionStyle = {
|
|
1672
|
+
fontSize: 14,
|
|
1673
|
+
fontWeight: 600,
|
|
1674
|
+
color: varRef(LI_VAR.text),
|
|
1675
|
+
lineHeight: 1.35
|
|
1676
|
+
};
|
|
1677
|
+
var optionsStyle = {
|
|
1678
|
+
display: "flex",
|
|
1679
|
+
flexDirection: "column",
|
|
1680
|
+
gap: 8
|
|
1681
|
+
};
|
|
1682
|
+
var optionStyle = {
|
|
1683
|
+
border: `1px solid ${varRef(LI_VAR.accent)}`,
|
|
1684
|
+
borderRadius: 999,
|
|
1685
|
+
padding: "8px 16px",
|
|
1686
|
+
textAlign: "center",
|
|
1687
|
+
fontSize: 14,
|
|
1688
|
+
fontWeight: 600,
|
|
1689
|
+
color: varRef(LI_VAR.accent)
|
|
1690
|
+
};
|
|
1691
|
+
var footerStyle = {
|
|
1692
|
+
fontSize: 12,
|
|
1693
|
+
color: varRef(LI_VAR.muted)
|
|
1694
|
+
};
|
|
1548
1695
|
var FOLD_CHARS = 200;
|
|
1549
1696
|
var BODY_STYLE = {
|
|
1550
1697
|
whiteSpace: "pre-wrap",
|
|
@@ -1672,7 +1819,7 @@ function LinkedInPostPreviewImpl({
|
|
|
1672
1819
|
accent: varRef(LI_VAR.accent),
|
|
1673
1820
|
muted: varRef(LI_VAR.muted)
|
|
1674
1821
|
};
|
|
1675
|
-
const
|
|
1822
|
+
const cardStyle4 = {
|
|
1676
1823
|
...paletteVars(dark),
|
|
1677
1824
|
background: varRef(LI_VAR.bg),
|
|
1678
1825
|
color: varRef(LI_VAR.text),
|
|
@@ -1683,7 +1830,7 @@ function LinkedInPostPreviewImpl({
|
|
|
1683
1830
|
fontFamily: FONT_STACK,
|
|
1684
1831
|
...style
|
|
1685
1832
|
};
|
|
1686
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style:
|
|
1833
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: cardStyle4, children: [
|
|
1687
1834
|
/* @__PURE__ */ jsxRuntime.jsx(Header, { author, visibility, time }),
|
|
1688
1835
|
variant.body ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "8px 16px 0" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1689
1836
|
PostBody,
|
|
@@ -1693,10 +1840,26 @@ function LinkedInPostPreviewImpl({
|
|
|
1693
1840
|
colors: bodyColors
|
|
1694
1841
|
}
|
|
1695
1842
|
) }) : null,
|
|
1696
|
-
|
|
1843
|
+
renderContent(variant, resolvedMedia),
|
|
1697
1844
|
showActions ? /* @__PURE__ */ jsxRuntime.jsx(EngagementBar, {}) : null
|
|
1698
1845
|
] });
|
|
1699
1846
|
}
|
|
1847
|
+
function renderContent(variant, media) {
|
|
1848
|
+
const settings = variant.settings;
|
|
1849
|
+
const kind = settings?.content_kind;
|
|
1850
|
+
const [firstMedia] = media;
|
|
1851
|
+
if (kind === "article" && settings?.article) {
|
|
1852
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: INSET, children: /* @__PURE__ */ jsxRuntime.jsx(ArticleCard, { article: settings.article, thumbnail: firstMedia }) });
|
|
1853
|
+
}
|
|
1854
|
+
if (kind === "poll" && settings?.poll) {
|
|
1855
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: INSET, children: /* @__PURE__ */ jsxRuntime.jsx(Poll, { poll: settings.poll }) });
|
|
1856
|
+
}
|
|
1857
|
+
if (kind === "document" && settings?.document) {
|
|
1858
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: INSET, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentCard, { document: settings.document, cover: firstMedia }) });
|
|
1859
|
+
}
|
|
1860
|
+
return media.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(Media, { media }) }) : null;
|
|
1861
|
+
}
|
|
1862
|
+
var INSET = { padding: "12px 16px 0" };
|
|
1700
1863
|
var LinkedInPostPreview = react.memo(LinkedInPostPreviewImpl);
|
|
1701
1864
|
var LINK_COLOR = "#8ab4ff";
|
|
1702
1865
|
var TOKEN = /([#@][\p{L}\p{N}_.]+)/gu;
|
|
@@ -1713,7 +1876,7 @@ function Caption({ body }) {
|
|
|
1713
1876
|
setOverflowing(el.scrollHeight > el.clientHeight + 1);
|
|
1714
1877
|
}, [body, expanded]);
|
|
1715
1878
|
const parts = body.split(TOKEN);
|
|
1716
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style:
|
|
1879
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle2, children: [
|
|
1717
1880
|
/* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: expanded ? expandedTextStyle : clampedTextStyle, children: parts.map(
|
|
1718
1881
|
(part, i) => IS_TOKEN.test(part) ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: LINK_COLOR }, children: part }, i) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: part }, i)
|
|
1719
1882
|
) }),
|
|
@@ -1730,7 +1893,7 @@ function Caption({ body }) {
|
|
|
1730
1893
|
) : null
|
|
1731
1894
|
] });
|
|
1732
1895
|
}
|
|
1733
|
-
var
|
|
1896
|
+
var wrapStyle2 = {
|
|
1734
1897
|
fontSize: 14,
|
|
1735
1898
|
lineHeight: 1.35
|
|
1736
1899
|
};
|
|
@@ -1779,7 +1942,7 @@ function Media2({
|
|
|
1779
1942
|
muted: true,
|
|
1780
1943
|
loop: true,
|
|
1781
1944
|
playsInline: true,
|
|
1782
|
-
style:
|
|
1945
|
+
style: coverStyle2
|
|
1783
1946
|
}
|
|
1784
1947
|
);
|
|
1785
1948
|
}
|
|
@@ -1806,7 +1969,7 @@ function PhotoCarousel({ media }) {
|
|
|
1806
1969
|
};
|
|
1807
1970
|
}, [emblaApi, sync]);
|
|
1808
1971
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "absolute", inset: 0 }, children: [
|
|
1809
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: emblaRef, style: viewportStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: slideStyle, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: m.src, alt: m.alt ?? "", style:
|
|
1972
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: emblaRef, style: viewportStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: slideStyle, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: m.src, alt: m.alt ?? "", style: coverStyle2 }) }, `${m.src}-${i}`)) }) }),
|
|
1810
1973
|
media.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: dotsStyle, children: media.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1811
1974
|
"span",
|
|
1812
1975
|
{
|
|
@@ -1825,7 +1988,7 @@ function ProcessingMedia() {
|
|
|
1825
1988
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { position: "relative", zIndex: 1 }, children: "Processing media\u2026" })
|
|
1826
1989
|
] });
|
|
1827
1990
|
}
|
|
1828
|
-
var
|
|
1991
|
+
var coverStyle2 = {
|
|
1829
1992
|
position: "absolute",
|
|
1830
1993
|
inset: 0,
|
|
1831
1994
|
width: "100%",
|
|
@@ -1951,7 +2114,7 @@ function TikTokPostPreviewImpl({
|
|
|
1951
2114
|
const label = commercialLabel(variant.settings);
|
|
1952
2115
|
const isAigc = Boolean(variant.settings?.is_aigc);
|
|
1953
2116
|
const pending = (media?.length ?? 0) > 0 && resolvedMedia.length === 0;
|
|
1954
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...
|
|
2117
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...cardStyle3, ...style }, children: [
|
|
1955
2118
|
/* @__PURE__ */ jsxRuntime.jsx("style", { children: KEYFRAMES }),
|
|
1956
2119
|
/* @__PURE__ */ jsxRuntime.jsx(Media2, { media: resolvedMedia, pending }),
|
|
1957
2120
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: scrimStyle }),
|
|
@@ -1998,7 +2161,7 @@ function Avatar({ url, name }) {
|
|
|
1998
2161
|
function Disc({ url }) {
|
|
1999
2162
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: discStyle, children: url ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: "", style: discImgStyle }) : null });
|
|
2000
2163
|
}
|
|
2001
|
-
var
|
|
2164
|
+
var cardStyle3 = {
|
|
2002
2165
|
position: "relative",
|
|
2003
2166
|
width: "100%",
|
|
2004
2167
|
maxWidth: 320,
|
|
@@ -2373,7 +2536,7 @@ function TikTokCaptionField({
|
|
|
2373
2536
|
const max = js.captionMaxFor(postType);
|
|
2374
2537
|
const count = value.length;
|
|
2375
2538
|
const over = count > max;
|
|
2376
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...
|
|
2539
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...wrapStyle3, ...style }, children: [
|
|
2377
2540
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: labelRowStyle, children: [
|
|
2378
2541
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, style: labelStyle, children: "Caption" }),
|
|
2379
2542
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2407,7 +2570,7 @@ function TikTokCaptionField({
|
|
|
2407
2570
|
)
|
|
2408
2571
|
] });
|
|
2409
2572
|
}
|
|
2410
|
-
var
|
|
2573
|
+
var wrapStyle3 = {
|
|
2411
2574
|
display: "flex",
|
|
2412
2575
|
flexDirection: "column",
|
|
2413
2576
|
gap: 6,
|
|
@@ -2674,12 +2837,15 @@ Object.defineProperty(exports, "captionMaxFor", {
|
|
|
2674
2837
|
enumerable: true,
|
|
2675
2838
|
get: function () { return js.captionMaxFor; }
|
|
2676
2839
|
});
|
|
2840
|
+
exports.ArticleCard = ArticleCard;
|
|
2677
2841
|
exports.AudienceSelect = AudienceSelect;
|
|
2678
2842
|
exports.CommercialDisclosure = CommercialDisclosure;
|
|
2679
2843
|
exports.Connect = Connect;
|
|
2680
2844
|
exports.Declaration = Declaration;
|
|
2845
|
+
exports.DocumentCard = DocumentCard;
|
|
2681
2846
|
exports.InteractionToggles = InteractionToggles;
|
|
2682
2847
|
exports.LinkedInPostPreview = LinkedInPostPreview;
|
|
2848
|
+
exports.Poll = Poll;
|
|
2683
2849
|
exports.PostrunProvider = PostrunProvider;
|
|
2684
2850
|
exports.TikTokCaptionField = TikTokCaptionField;
|
|
2685
2851
|
exports.TikTokPostPreview = TikTokPostPreview;
|