@select-org/post-components 2.1.0 → 2.1.2

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.d.ts CHANGED
@@ -165,6 +165,11 @@ interface Props$a {
165
165
  hideEmailDescription?: boolean;
166
166
  isEmailPost?: boolean;
167
167
  onNavigate?: (href: string, isInternal: boolean) => void;
168
+ linkComponent?: React.ComponentType<{
169
+ href: string;
170
+ children: React.ReactNode;
171
+ className?: string;
172
+ }>;
168
173
  supportDeepviewDomain?: string | string[];
169
174
  }
170
175
  declare const PostBody: React.FC<Props$a>;
@@ -215,6 +220,11 @@ interface Props$9 {
215
220
  }>;
216
221
  mediaItemStatuses?: Record<string, MediaUploadStatus>;
217
222
  onNavigate?: (href: string, isInternal: boolean) => void;
223
+ linkComponent?: React.ComponentType<{
224
+ href: string;
225
+ children: React.ReactNode;
226
+ className?: string;
227
+ }>;
218
228
  supportDeepviewDomain?: string | string[];
219
229
  }
220
230
  declare const PostItemsView: React.FC<Props$9>;
@@ -244,6 +254,11 @@ interface Props$6 {
244
254
  showFullText: boolean;
245
255
  isPostDetail: boolean;
246
256
  onNavigate?: (href: string, isInternal: boolean) => void;
257
+ linkComponent?: React.ComponentType<{
258
+ href: string;
259
+ children: React.ReactNode;
260
+ className?: string;
261
+ }>;
247
262
  supportDeepviewDomain?: string | string[];
248
263
  }
249
264
  declare const PostTextItem: React.FC<Props$6>;
@@ -253,6 +268,11 @@ interface Props$5 {
253
268
  isPostDetail: boolean;
254
269
  onCardPress: () => void;
255
270
  onNavigate?: (href: string, isInternal: boolean) => void;
271
+ linkComponent?: React.ComponentType<{
272
+ href: string;
273
+ children: React.ReactNode;
274
+ className?: string;
275
+ }>;
256
276
  supportDeepviewDomain?: string | string[];
257
277
  imageComponent?: React.ComponentType<{
258
278
  src: string;
@@ -351,6 +371,11 @@ interface AutoLinkProps {
351
371
  text: string;
352
372
  mentionData?: MentionData[];
353
373
  onNavigate?: (href: string, isInternal: boolean) => void;
374
+ linkComponent?: React.ComponentType<{
375
+ href: string;
376
+ children: React.ReactNode;
377
+ className?: string;
378
+ }>;
354
379
  supportDeepviewDomain?: string | string[];
355
380
  phone?: any;
356
381
  email?: any;
@@ -360,7 +385,7 @@ interface AutoLinkProps {
360
385
  className?: string;
361
386
  }
362
387
  declare const AutoLink: {
363
- ({ text: textProp, mentionData, onNavigate, supportDeepviewDomain, phone, email, stripPrefix, style, mentionClassName: mentionClassNameProp, className, }: AutoLinkProps): React.JSX.Element | null;
388
+ ({ text: textProp, mentionData, onNavigate, linkComponent, supportDeepviewDomain, phone, email, stripPrefix, style, mentionClassName: mentionClassNameProp, className, }: AutoLinkProps): React.JSX.Element | null;
364
389
  truncate: (text: string, { truncate: len, truncateChars, truncateLocation }?: TruncateOptions) => string;
365
390
  };
366
391
 
package/dist/index.js CHANGED
@@ -284,7 +284,7 @@ var PostHeader = ({
284
284
  LinkComponent,
285
285
  {
286
286
  href: groupHref,
287
- className: "text-action-primary font-medium hover:underline cursor-pointer bg-transparent border-none p-0",
287
+ className: "text-action-primary font-medium no-underline hover:underline cursor-pointer bg-transparent border-none p-0",
288
288
  children: [
289
289
  "#",
290
290
  group.name
@@ -295,7 +295,7 @@ var PostHeader = ({
295
295
  {
296
296
  href: groupHref,
297
297
  onClick: (e) => e.stopPropagation(),
298
- className: "text-action-primary font-medium hover:underline cursor-pointer bg-transparent border-none p-0",
298
+ className: "text-action-primary font-medium no-underline hover:underline cursor-pointer bg-transparent border-none p-0",
299
299
  title: group.name,
300
300
  "aria-label": `View group ${group.name}`,
301
301
  children: [
@@ -525,6 +525,7 @@ var AutoLink = ({
525
525
  text: textProp,
526
526
  mentionData = [],
527
527
  onNavigate,
528
+ linkComponent,
528
529
  supportDeepviewDomain = "",
529
530
  phone = true,
530
531
  email = true,
@@ -598,10 +599,25 @@ var AutoLink = ({
598
599
  const renderMentionData = useCallback(
599
600
  (fmData, key) => {
600
601
  const href = fmData.type === MENTION_TYPE.HASHTAG ? `/groups/${fmData.data.selectId}` : `/users/${fmData.data.selectId || fmData.data.id}`;
602
+ const className2 = `no-underline hover:underline context-menu-ios-disable cursor-pointer ${mentionClassName}`;
603
+ if (linkComponent) {
604
+ const LinkComponent = linkComponent;
605
+ return /* @__PURE__ */ jsx3(
606
+ "span",
607
+ {
608
+ onClick: (e) => {
609
+ e.stopPropagation();
610
+ e.nativeEvent.stopImmediatePropagation();
611
+ },
612
+ children: /* @__PURE__ */ jsx3(LinkComponent, { href, className: className2, children: fmData.name })
613
+ },
614
+ key + fmData.index
615
+ );
616
+ }
601
617
  return /* @__PURE__ */ jsx3(
602
618
  "a",
603
619
  {
604
- className: `context-menu-ios-disable cursor-pointer ${mentionClassName}`,
620
+ className: className2,
605
621
  href,
606
622
  onClick: (e) => {
607
623
  e.stopPropagation();
@@ -613,7 +629,7 @@ var AutoLink = ({
613
629
  key + fmData.index
614
630
  );
615
631
  },
616
- [mentionClassName, handleNavigate]
632
+ [mentionClassName, handleNavigate, linkComponent]
617
633
  );
618
634
  const renderTextNodes = useCallback(() => {
619
635
  let text = textProp;
@@ -1011,6 +1027,7 @@ var PostBody = ({
1011
1027
  hideEmailDescription = false,
1012
1028
  isEmailPost = false,
1013
1029
  onNavigate,
1030
+ linkComponent,
1014
1031
  supportDeepviewDomain
1015
1032
  }) => {
1016
1033
  const { plain, html, truncatedPlain, mentionData } = textContent;
@@ -1071,6 +1088,7 @@ var PostBody = ({
1071
1088
  text: displayText,
1072
1089
  mentionData,
1073
1090
  onNavigate,
1091
+ linkComponent,
1074
1092
  supportDeepviewDomain,
1075
1093
  className: "whitespace-normal px-4 pb-4 leading-relaxed text-gray-800",
1076
1094
  style: {
@@ -1104,6 +1122,7 @@ var PostBody = ({
1104
1122
  text: displayText,
1105
1123
  mentionData,
1106
1124
  onNavigate,
1125
+ linkComponent,
1107
1126
  supportDeepviewDomain,
1108
1127
  className: "whitespace-normal leading-relaxed text-gray-600 line-clamp-3",
1109
1128
  style: { whiteSpace: "pre-wrap", wordBreak: "break-word" }
@@ -1834,6 +1853,7 @@ var PostTextItem = ({
1834
1853
  textItems,
1835
1854
  showFullText,
1836
1855
  onNavigate,
1856
+ linkComponent,
1837
1857
  supportDeepviewDomain
1838
1858
  }) => {
1839
1859
  return /* @__PURE__ */ jsx14("div", { className: "flex-1", children: /* @__PURE__ */ jsx14("div", { children: textItems.map((item, index) => {
@@ -1846,6 +1866,7 @@ var PostTextItem = ({
1846
1866
  text: showFullText ? text : TruncateText(text, 300),
1847
1867
  mentionData,
1848
1868
  onNavigate,
1869
+ linkComponent,
1849
1870
  supportDeepviewDomain,
1850
1871
  className: "whitespace-normal px-4 pb-4 leading-relaxed text-gray-800",
1851
1872
  style: {
@@ -2238,6 +2259,7 @@ var PostItemsView = ({
2238
2259
  imageComponent,
2239
2260
  mediaItemStatuses,
2240
2261
  onNavigate,
2262
+ linkComponent,
2241
2263
  supportDeepviewDomain
2242
2264
  }) => {
2243
2265
  if (!primaryContent) return null;
@@ -2293,6 +2315,7 @@ var PostItemsView = ({
2293
2315
  showFullText: isPostDetail,
2294
2316
  isPostDetail,
2295
2317
  onNavigate,
2318
+ linkComponent,
2296
2319
  supportDeepviewDomain
2297
2320
  }
2298
2321
  );
@@ -2405,6 +2428,7 @@ var PostSectionsView = ({
2405
2428
  isPostDetail,
2406
2429
  onCardPress,
2407
2430
  onNavigate,
2431
+ linkComponent,
2408
2432
  supportDeepviewDomain,
2409
2433
  imageComponent
2410
2434
  }) => {
@@ -2423,6 +2447,7 @@ var PostSectionsView = ({
2423
2447
  },
2424
2448
  mentionData: data.mentionData,
2425
2449
  onNavigate,
2450
+ linkComponent,
2426
2451
  supportDeepviewDomain
2427
2452
  },
2428
2453
  `${index} - ${data.body}`
@@ -2448,6 +2473,7 @@ var PostSectionsView = ({
2448
2473
  },
2449
2474
  mentionData: data.mentionData,
2450
2475
  onNavigate,
2476
+ linkComponent,
2451
2477
  supportDeepviewDomain
2452
2478
  },
2453
2479
  `${index} - ${data.body}`
@@ -2961,6 +2987,7 @@ var PostCard = ({
2961
2987
  isEmailPost,
2962
2988
  hideEmailDescription: isEmailPost && !isPostDetail && resolvedContent.primaryContent?.type === "media",
2963
2989
  onNavigate,
2990
+ linkComponent,
2964
2991
  supportDeepviewDomain
2965
2992
  }
2966
2993
  ),
@@ -2972,6 +2999,7 @@ var PostCard = ({
2972
2999
  onCardPress: onCardPress ?? (() => {
2973
3000
  }),
2974
3001
  onNavigate,
3002
+ linkComponent,
2975
3003
  supportDeepviewDomain,
2976
3004
  imageComponent
2977
3005
  }
@@ -2991,6 +3019,7 @@ var PostCard = ({
2991
3019
  imageComponent,
2992
3020
  mediaItemStatuses,
2993
3021
  onNavigate,
3022
+ linkComponent,
2994
3023
  supportDeepviewDomain
2995
3024
  }
2996
3025
  ),