@postrun/react 2.5.0 → 2.7.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 CHANGED
@@ -10,8 +10,8 @@ var pLimit = require('p-limit');
10
10
  var pRetry = require('p-retry');
11
11
  var axios = require('axios');
12
12
  var reactTweet = require('react-tweet');
13
- var fi = require('react-icons/fi');
14
13
  var jsxRuntime = require('react/jsx-runtime');
14
+ var fi = require('react-icons/fi');
15
15
  var twitterText = require('twitter-text');
16
16
  var lu = require('react-icons/lu');
17
17
  var useEmblaCarousel = require('embla-carousel-react');
@@ -984,6 +984,42 @@ function useTikTokCreatorInfo(connectionId) {
984
984
  queryClient
985
985
  );
986
986
  }
987
+
988
+ // src/preview/from-upload.ts
989
+ function previewKind(item) {
990
+ const detected = item.media?.kind;
991
+ if (detected) {
992
+ return detected === "document" ? null : detected;
993
+ }
994
+ const mime = item.file.type;
995
+ if (mime === "image/gif") {
996
+ return "gif";
997
+ }
998
+ if (mime.startsWith("video/")) {
999
+ return "video";
1000
+ }
1001
+ if (mime.startsWith("image/")) {
1002
+ return "image";
1003
+ }
1004
+ return null;
1005
+ }
1006
+ function toPreviewMedia(items) {
1007
+ return items.flatMap((item) => {
1008
+ const kind = previewKind(item);
1009
+ if (!kind) {
1010
+ return [];
1011
+ }
1012
+ return [
1013
+ {
1014
+ kind,
1015
+ file: item.file,
1016
+ width: item.media?.source?.width ?? void 0,
1017
+ height: item.media?.source?.height ?? void 0,
1018
+ alt: item.media?.alt_text ?? void 0
1019
+ }
1020
+ ];
1021
+ });
1022
+ }
987
1023
  function fileKey(file) {
988
1024
  return file ? `${file.name}:${file.size}:${file.lastModified}` : "";
989
1025
  }
@@ -1040,6 +1076,37 @@ function useResolvedMedia(media, altFallbacks, altSignature) {
1040
1076
  [signature, altSignature, objectUrls]
1041
1077
  );
1042
1078
  }
1079
+ function XPoll({ poll }) {
1080
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle, children: [
1081
+ poll.options.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: optionStyle, children: option }, `${option}-${i}`)),
1082
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: footerStyle, children: [
1083
+ "0 votes \xB7 ",
1084
+ js.xPollDurationLabel(poll.duration_minutes)
1085
+ ] })
1086
+ ] });
1087
+ }
1088
+ var BLUE = "var(--tweet-color-blue-primary, #1d9bf0)";
1089
+ var MUTED = "var(--tweet-color-gray-secondary, #536471)";
1090
+ var wrapStyle = {
1091
+ display: "flex",
1092
+ flexDirection: "column",
1093
+ gap: 8,
1094
+ marginTop: 12
1095
+ };
1096
+ var optionStyle = {
1097
+ border: `1px solid ${BLUE}`,
1098
+ color: BLUE,
1099
+ borderRadius: 999,
1100
+ padding: "8px 16px",
1101
+ textAlign: "center",
1102
+ fontSize: 15,
1103
+ fontWeight: 700
1104
+ };
1105
+ var footerStyle = {
1106
+ fontSize: 13,
1107
+ color: MUTED,
1108
+ marginTop: 2
1109
+ };
1043
1110
  var ROW = {
1044
1111
  display: "flex",
1045
1112
  justifyContent: "space-between",
@@ -1280,6 +1347,7 @@ function XPostPreviewImpl({
1280
1347
  tweet.in_reply_to_screen_name ? /* @__PURE__ */ jsxRuntime.jsx(reactTweet.TweetInReplyTo, { tweet }) : null,
1281
1348
  /* @__PURE__ */ jsxRuntime.jsx(reactTweet.TweetBody, { tweet }),
1282
1349
  tweet.mediaDetails?.length ? /* @__PURE__ */ jsxRuntime.jsx(reactTweet.TweetMedia, { tweet, components }) : null,
1350
+ variant.settings?.poll ? /* @__PURE__ */ jsxRuntime.jsx(XPoll, { poll: variant.settings.poll }) : null,
1283
1351
  tweet.quoted_tweet ? /* @__PURE__ */ jsxRuntime.jsx(reactTweet.QuotedTweet, { tweet: tweet.quoted_tweet }) : null,
1284
1352
  showActions ? /* @__PURE__ */ jsxRuntime.jsx(XPreviewActions, {}) : null
1285
1353
  ] })
@@ -1651,16 +1719,16 @@ function Media({ media }) {
1651
1719
  return /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { media: images });
1652
1720
  }
1653
1721
  function Poll({ poll }) {
1654
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle, children: [
1722
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle2, children: [
1655
1723
  /* @__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: [
1724
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: optionsStyle, children: poll.options.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: optionStyle2, children: option }, `${option}-${i}`)) }),
1725
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: footerStyle2, children: [
1658
1726
  "0 votes \u2022 ",
1659
1727
  js.linkedinPollDurationLabel(poll.duration)
1660
1728
  ] })
1661
1729
  ] });
1662
1730
  }
1663
- var wrapStyle = {
1731
+ var wrapStyle2 = {
1664
1732
  border: `1px solid ${varRef(LI_VAR.border)}`,
1665
1733
  borderRadius: 8,
1666
1734
  padding: 12,
@@ -1679,7 +1747,7 @@ var optionsStyle = {
1679
1747
  flexDirection: "column",
1680
1748
  gap: 8
1681
1749
  };
1682
- var optionStyle = {
1750
+ var optionStyle2 = {
1683
1751
  border: `1px solid ${varRef(LI_VAR.accent)}`,
1684
1752
  borderRadius: 999,
1685
1753
  padding: "8px 16px",
@@ -1688,7 +1756,7 @@ var optionStyle = {
1688
1756
  fontWeight: 600,
1689
1757
  color: varRef(LI_VAR.accent)
1690
1758
  };
1691
- var footerStyle = {
1759
+ var footerStyle2 = {
1692
1760
  fontSize: 12,
1693
1761
  color: varRef(LI_VAR.muted)
1694
1762
  };
@@ -1876,7 +1944,7 @@ function Caption({ body }) {
1876
1944
  setOverflowing(el.scrollHeight > el.clientHeight + 1);
1877
1945
  }, [body, expanded]);
1878
1946
  const parts = body.split(TOKEN);
1879
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle2, children: [
1947
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: wrapStyle3, children: [
1880
1948
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: expanded ? expandedTextStyle : clampedTextStyle, children: parts.map(
1881
1949
  (part, i) => IS_TOKEN.test(part) ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: LINK_COLOR }, children: part }, i) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: part }, i)
1882
1950
  ) }),
@@ -1893,7 +1961,7 @@ function Caption({ body }) {
1893
1961
  ) : null
1894
1962
  ] });
1895
1963
  }
1896
- var wrapStyle2 = {
1964
+ var wrapStyle3 = {
1897
1965
  fontSize: 14,
1898
1966
  lineHeight: 1.35
1899
1967
  };
@@ -2348,7 +2416,7 @@ function useIsDark2(theme) {
2348
2416
  }
2349
2417
  return theme === "dark";
2350
2418
  }
2351
- var MUTED = varRef2(TT_VAR.muted);
2419
+ var MUTED2 = varRef2(TT_VAR.muted);
2352
2420
  var BORDER = varRef2(TT_VAR.border);
2353
2421
  var ACCENT = varRef2(TT_VAR.accent);
2354
2422
  var SWITCH_OFF = varRef2(TT_VAR.switchOff);
@@ -2362,7 +2430,7 @@ function Row({
2362
2430
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: rowStyle, children: [
2363
2431
  /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor, style: { display: "flex", flexDirection: "column", gap: 2 }, children: [
2364
2432
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14 }, children: label }),
2365
- sublabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: MUTED }, children: sublabel }) : null
2433
+ sublabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: MUTED2 }, children: sublabel }) : null
2366
2434
  ] }),
2367
2435
  control
2368
2436
  ] });
@@ -2470,7 +2538,7 @@ var hintStyle = {
2470
2538
  var noticeStyle = {
2471
2539
  margin: 0,
2472
2540
  fontSize: 12,
2473
- color: MUTED,
2541
+ color: MUTED2,
2474
2542
  lineHeight: 1.4
2475
2543
  };
2476
2544
  var checkRowStyle = {
@@ -2479,7 +2547,7 @@ var checkRowStyle = {
2479
2547
  gap: 10,
2480
2548
  cursor: "pointer"
2481
2549
  };
2482
- var TOKENS = { MUTED, BORDER, ACCENT};
2550
+ var TOKENS = { MUTED: MUTED2, BORDER, ACCENT};
2483
2551
  function AudienceSelect({
2484
2552
  creatorInfo,
2485
2553
  value,
@@ -2536,7 +2604,7 @@ function TikTokCaptionField({
2536
2604
  const max = js.captionMaxFor(postType);
2537
2605
  const count = value.length;
2538
2606
  const over = count > max;
2539
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...wrapStyle3, ...style }, children: [
2607
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...wrapStyle4, ...style }, children: [
2540
2608
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: labelRowStyle, children: [
2541
2609
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, style: labelStyle, children: "Caption" }),
2542
2610
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2570,7 +2638,7 @@ function TikTokCaptionField({
2570
2638
  )
2571
2639
  ] });
2572
2640
  }
2573
- var wrapStyle3 = {
2641
+ var wrapStyle4 = {
2574
2642
  display: "flex",
2575
2643
  flexDirection: "column",
2576
2644
  gap: 6,
@@ -2851,12 +2919,14 @@ exports.TikTokCaptionField = TikTokCaptionField;
2851
2919
  exports.TikTokPostPreview = TikTokPostPreview;
2852
2920
  exports.TikTokPublishPanel = TikTokPublishPanel;
2853
2921
  exports.UploadError = UploadError;
2922
+ exports.XPoll = XPoll;
2854
2923
  exports.XPostPreview = XPostPreview;
2855
2924
  exports.connectionKeys = connectionKeys;
2856
2925
  exports.mediaKeys = mediaKeys;
2857
2926
  exports.postKeys = postKeys;
2858
2927
  exports.profileKeys = profileKeys;
2859
2928
  exports.tiktokKeys = tiktokKeys;
2929
+ exports.toPreviewMedia = toPreviewMedia;
2860
2930
  exports.useCalendar = useCalendar;
2861
2931
  exports.useConnect = useConnect;
2862
2932
  exports.useConnection = useConnection;