@select-org/post-components 2.1.3 → 2.1.5
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 +61 -31
- package/dist/index.js +39 -19
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,35 @@ export { FormatMentionData, ImageInfo, PostAuthor, PostDataMetaData } from './ty
|
|
|
4
4
|
import { ResolvedTextContent, PrimaryContent, EmbedContent, TextItemContent, SectionItem as SectionItem$1 } from './resolver.js';
|
|
5
5
|
export { LinkContent, MediaContent, PollContent, ResolvePostContentMode, ResolvedPostContent, SectionsContent, hasMeaningfulHtml, resolvePostContent } from './resolver.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* i18n seam. The design system stays string-agnostic — consumers inject
|
|
9
|
+
* already-localized copy. When omitted, English defaults are used so the
|
|
10
|
+
* component still renders standalone.
|
|
11
|
+
*/
|
|
12
|
+
interface EraseConfirmModalLabels {
|
|
13
|
+
/** First-step action row, e.g. "Erase post" / "Erase comment". */
|
|
14
|
+
erase?: string;
|
|
15
|
+
/** Cancel affordance (both steps). */
|
|
16
|
+
cancel?: string;
|
|
17
|
+
/** Confirmation heading, e.g. "Are you sure you want to erase this post?". */
|
|
18
|
+
confirmTitle?: string;
|
|
19
|
+
/** Confirmation body, e.g. "This action cannot be undone.". */
|
|
20
|
+
confirmBody?: string;
|
|
21
|
+
/** Destructive confirm button. */
|
|
22
|
+
confirmErase?: string;
|
|
23
|
+
}
|
|
24
|
+
interface Props$a {
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
onYesPress: (e?: React.MouseEvent) => void;
|
|
27
|
+
onNoPress: (e?: React.MouseEvent) => void;
|
|
28
|
+
fontColor?: string;
|
|
29
|
+
itemType?: string;
|
|
30
|
+
isOpen: boolean;
|
|
31
|
+
handleClose: () => void;
|
|
32
|
+
labels?: EraseConfirmModalLabels;
|
|
33
|
+
}
|
|
34
|
+
declare const EraseConfirmModal: React.FC<Props$a>;
|
|
35
|
+
|
|
7
36
|
interface PostCardProps {
|
|
8
37
|
post: {
|
|
9
38
|
context_id: string;
|
|
@@ -91,6 +120,8 @@ interface PostCardProps {
|
|
|
91
120
|
uploadingRemaining?: string;
|
|
92
121
|
uploadingDone?: string;
|
|
93
122
|
};
|
|
123
|
+
/** Localized copy for the erase-confirmation modal. English defaults when omitted. */
|
|
124
|
+
eraseLabels?: EraseConfirmModalLabels;
|
|
94
125
|
mode?: 'feed' | 'detail' | 'inbox' | 'draft';
|
|
95
126
|
commentCount?: number;
|
|
96
127
|
unreadCommentCount?: number;
|
|
@@ -135,6 +166,8 @@ interface PostHeaderProps {
|
|
|
135
166
|
isAdmin?: boolean;
|
|
136
167
|
isOwner?: boolean;
|
|
137
168
|
onErasePress?: () => void;
|
|
169
|
+
/** Accessible label for the built-in delete affordance. Defaults to "Delete post". */
|
|
170
|
+
deleteLabel?: string;
|
|
138
171
|
onCancelPost?: () => void;
|
|
139
172
|
renderActionsMenu?: () => React.ReactNode;
|
|
140
173
|
linkComponent?: React.ComponentType<{
|
|
@@ -157,7 +190,7 @@ interface PostHeaderProps {
|
|
|
157
190
|
}
|
|
158
191
|
declare const PostHeader: React.FC<PostHeaderProps>;
|
|
159
192
|
|
|
160
|
-
interface Props$
|
|
193
|
+
interface Props$9 {
|
|
161
194
|
textContent: ResolvedTextContent;
|
|
162
195
|
showFull?: boolean;
|
|
163
196
|
isPostDetail: boolean;
|
|
@@ -172,7 +205,7 @@ interface Props$a {
|
|
|
172
205
|
}>;
|
|
173
206
|
supportDeepviewDomain?: string | string[];
|
|
174
207
|
}
|
|
175
|
-
declare const PostBody: React.FC<Props$
|
|
208
|
+
declare const PostBody: React.FC<Props$9>;
|
|
176
209
|
|
|
177
210
|
interface PostFooterProps {
|
|
178
211
|
postHref?: string;
|
|
@@ -205,7 +238,7 @@ interface PostFooterProps {
|
|
|
205
238
|
}
|
|
206
239
|
declare const PostFooter: React.FC<PostFooterProps>;
|
|
207
240
|
|
|
208
|
-
interface Props$
|
|
241
|
+
interface Props$8 {
|
|
209
242
|
primaryContent: PrimaryContent;
|
|
210
243
|
isPostDetail: boolean;
|
|
211
244
|
onCardPress: () => void;
|
|
@@ -227,18 +260,18 @@ interface Props$9 {
|
|
|
227
260
|
}>;
|
|
228
261
|
supportDeepviewDomain?: string | string[];
|
|
229
262
|
}
|
|
230
|
-
declare const PostItemsView: React.FC<Props$
|
|
263
|
+
declare const PostItemsView: React.FC<Props$8>;
|
|
231
264
|
|
|
232
|
-
interface Props$
|
|
265
|
+
interface Props$7 {
|
|
233
266
|
embed: EmbedContent;
|
|
234
267
|
}
|
|
235
|
-
declare const PostEmbedView: React.FC<Props$
|
|
268
|
+
declare const PostEmbedView: React.FC<Props$7>;
|
|
236
269
|
|
|
237
270
|
declare const PostEmail: React.FC<{
|
|
238
271
|
html: string;
|
|
239
272
|
}>;
|
|
240
273
|
|
|
241
|
-
interface Props$
|
|
274
|
+
interface Props$6 {
|
|
242
275
|
items: PollItemData[];
|
|
243
276
|
voteResult: PollResult | null;
|
|
244
277
|
onVotePress: (item: PollItemData) => void;
|
|
@@ -247,9 +280,9 @@ interface Props$7 {
|
|
|
247
280
|
isInboxCard?: boolean;
|
|
248
281
|
isPostOwner?: boolean;
|
|
249
282
|
}
|
|
250
|
-
declare const PostPollView: React.FC<Props$
|
|
283
|
+
declare const PostPollView: React.FC<Props$6>;
|
|
251
284
|
|
|
252
|
-
interface Props$
|
|
285
|
+
interface Props$5 {
|
|
253
286
|
textItems: TextItemContent['items'];
|
|
254
287
|
showFullText: boolean;
|
|
255
288
|
isPostDetail: boolean;
|
|
@@ -261,9 +294,9 @@ interface Props$6 {
|
|
|
261
294
|
}>;
|
|
262
295
|
supportDeepviewDomain?: string | string[];
|
|
263
296
|
}
|
|
264
|
-
declare const PostTextItem: React.FC<Props$
|
|
297
|
+
declare const PostTextItem: React.FC<Props$5>;
|
|
265
298
|
|
|
266
|
-
interface Props$
|
|
299
|
+
interface Props$4 {
|
|
267
300
|
sections: SectionItem$1[];
|
|
268
301
|
isPostDetail: boolean;
|
|
269
302
|
onCardPress: () => void;
|
|
@@ -284,9 +317,9 @@ interface Props$5 {
|
|
|
284
317
|
className?: string;
|
|
285
318
|
}>;
|
|
286
319
|
}
|
|
287
|
-
declare const PostSectionsView: React.FC<Props$
|
|
320
|
+
declare const PostSectionsView: React.FC<Props$4>;
|
|
288
321
|
|
|
289
|
-
interface Props$
|
|
322
|
+
interface Props$3 {
|
|
290
323
|
sourceInfo?: {
|
|
291
324
|
avatar: string;
|
|
292
325
|
username: string;
|
|
@@ -302,14 +335,22 @@ interface Props$4 {
|
|
|
302
335
|
className?: string;
|
|
303
336
|
}>;
|
|
304
337
|
}
|
|
305
|
-
declare const PostSectionSourceInfoView: React.FC<Props$
|
|
338
|
+
declare const PostSectionSourceInfoView: React.FC<Props$3>;
|
|
306
339
|
|
|
307
|
-
interface Props$
|
|
340
|
+
interface Props$2 {
|
|
308
341
|
fontColor?: string;
|
|
309
342
|
sections: SectionItem$1[];
|
|
343
|
+
isPostDetail?: boolean;
|
|
310
344
|
onCardPress?: () => void;
|
|
345
|
+
onNavigate?: (href: string, isInternal: boolean) => void;
|
|
346
|
+
linkComponent?: React.ComponentType<{
|
|
347
|
+
href: string;
|
|
348
|
+
children: React.ReactNode;
|
|
349
|
+
className?: string;
|
|
350
|
+
}>;
|
|
351
|
+
supportDeepviewDomain?: string | string[];
|
|
311
352
|
}
|
|
312
|
-
declare const PostSectionsSummaryView: React.FC<Props$
|
|
353
|
+
declare const PostSectionsSummaryView: React.FC<Props$2>;
|
|
313
354
|
|
|
314
355
|
interface PostLinkItemProps {
|
|
315
356
|
linkItems: LinkItemMetaData[];
|
|
@@ -333,14 +374,14 @@ interface PostMediaLayoutProps {
|
|
|
333
374
|
}
|
|
334
375
|
declare const PostMediaLayoutCore: React.FC<PostMediaLayoutProps>;
|
|
335
376
|
|
|
336
|
-
interface Props$
|
|
377
|
+
interface Props$1 {
|
|
337
378
|
status?: MediaUploadStatus;
|
|
338
379
|
/** Tile width in px. Status text is hidden when < 100. */
|
|
339
380
|
tileWidth?: number;
|
|
340
381
|
}
|
|
341
|
-
declare const MediaUploadStatusOverlay: React.FC<Props$
|
|
382
|
+
declare const MediaUploadStatusOverlay: React.FC<Props$1>;
|
|
342
383
|
|
|
343
|
-
interface Props
|
|
384
|
+
interface Props {
|
|
344
385
|
statuses?: Record<string, MediaUploadStatus>;
|
|
345
386
|
labels?: {
|
|
346
387
|
/** Template with `{count}` replaced by the remaining in-flight number. */
|
|
@@ -349,7 +390,7 @@ interface Props$1 {
|
|
|
349
390
|
uploadingDone?: string;
|
|
350
391
|
};
|
|
351
392
|
}
|
|
352
|
-
declare const PostUploadStrip: React.FC<Props
|
|
393
|
+
declare const PostUploadStrip: React.FC<Props>;
|
|
353
394
|
|
|
354
395
|
/*!
|
|
355
396
|
* React Native Autolink
|
|
@@ -416,15 +457,4 @@ interface ReactionModalProps {
|
|
|
416
457
|
}
|
|
417
458
|
declare const ReactionModal: ({ isOpen, close, sendReaction, onAnalyticsEvent }: ReactionModalProps) => React.JSX.Element | null;
|
|
418
459
|
|
|
419
|
-
interface Props {
|
|
420
|
-
backgroundColor?: string;
|
|
421
|
-
onYesPress: (e?: React.MouseEvent) => void;
|
|
422
|
-
onNoPress: (e?: React.MouseEvent) => void;
|
|
423
|
-
fontColor?: string;
|
|
424
|
-
itemType?: string;
|
|
425
|
-
isOpen: boolean;
|
|
426
|
-
handleClose: () => void;
|
|
427
|
-
}
|
|
428
|
-
declare const EraseConfirmModal: React.FC<Props>;
|
|
429
|
-
|
|
430
460
|
export { AutoLink, EmbedContent, EraseConfirmModal, ItemData, LinkItemMetaData, MediaUploadStatus, MediaUploadStatusOverlay, MentionData, POST_TYPE_HINT_DEFAULTS, PollItemData, PollResult, PostBody, PostCard, type PostCardProps, PostEmail, PostEmbedView, PostFooter, PostHeader, type PostHeaderProps, PostItemsView, PostLinkItem, PostMediaLayoutCore, PostPollView, PostSectionSourceInfoView, PostSectionsSummaryView, PostSectionsView, PostTextItem, type PostTypeHint, type PostTypeHintContext, PostUploadStrip, PrimaryContent, ReactionModal, ResolvedTextContent, SectionItem, TextItemContent, TipTapDocument, getPostTypeHint };
|
package/dist/index.js
CHANGED
|
@@ -245,6 +245,7 @@ var PostHeader = ({
|
|
|
245
245
|
isAdmin = false,
|
|
246
246
|
isOwner = false,
|
|
247
247
|
onErasePress,
|
|
248
|
+
deleteLabel,
|
|
248
249
|
onCancelPost,
|
|
249
250
|
renderActionsMenu,
|
|
250
251
|
linkComponent: LinkComponent,
|
|
@@ -317,7 +318,7 @@ var PostHeader = ({
|
|
|
317
318
|
AvatarImage,
|
|
318
319
|
{
|
|
319
320
|
src: author.avatar,
|
|
320
|
-
alt: `${author.name}'s profile picture`,
|
|
321
|
+
alt: `${author.name}'s profile picture on Select App`,
|
|
321
322
|
placeholder: author.avatarPlaceholder,
|
|
322
323
|
imageComponent
|
|
323
324
|
}
|
|
@@ -347,7 +348,7 @@ var PostHeader = ({
|
|
|
347
348
|
/* @__PURE__ */ jsx2(
|
|
348
349
|
"time",
|
|
349
350
|
{
|
|
350
|
-
title: postedAt,
|
|
351
|
+
title: formatRelativeTime(postedAt, locale ?? "en"),
|
|
351
352
|
className: "text-xs text-muted-foreground whitespace-nowrap shrink-0",
|
|
352
353
|
dateTime: postedAt,
|
|
353
354
|
children: formatRelativeTime(postedAt, locale ?? "en")
|
|
@@ -411,7 +412,7 @@ var PostHeader = ({
|
|
|
411
412
|
e.stopPropagation();
|
|
412
413
|
onErasePress();
|
|
413
414
|
},
|
|
414
|
-
"aria-label": "Delete post",
|
|
415
|
+
"aria-label": deleteLabel ?? "Delete post",
|
|
415
416
|
className: "absolute right-4 top-4 leading-none rounded-full p-1.5 transition-colors hover:bg-feedback-danger/10 hover:text-feedback-danger",
|
|
416
417
|
children: /* @__PURE__ */ jsx2(AppIcon, { name: "chatErase", width: 16, height: 16, strokeWidth: 1.75 })
|
|
417
418
|
}
|
|
@@ -1100,7 +1101,7 @@ var PostBody = ({
|
|
|
1100
1101
|
};
|
|
1101
1102
|
if (isPostDetail) {
|
|
1102
1103
|
if (isEmailPost && html) {
|
|
1103
|
-
return /* @__PURE__ */ jsxs2("div", { className: "relative flex-1 max-h-
|
|
1104
|
+
return /* @__PURE__ */ jsxs2("div", { className: "relative flex-1 max-h-full w-full overflow-x-hidden overflow-y-auto xl:px-0 px-5", children: [
|
|
1104
1105
|
/* @__PURE__ */ jsx5("h1", { className: "text-2xl font-semibold text-gray-900 leading-snug mt-5 mb-3 px-5", children: subject }),
|
|
1105
1106
|
/* @__PURE__ */ jsx5(PostEmail_default, { html })
|
|
1106
1107
|
] });
|
|
@@ -2695,7 +2696,8 @@ var EraseConfirmModal = ({
|
|
|
2695
2696
|
onNoPress,
|
|
2696
2697
|
itemType = "comment",
|
|
2697
2698
|
isOpen,
|
|
2698
|
-
handleClose
|
|
2699
|
+
handleClose,
|
|
2700
|
+
labels
|
|
2699
2701
|
}) => {
|
|
2700
2702
|
const [first, setFirst] = useState4(true);
|
|
2701
2703
|
const [second, setSecond] = useState4(false);
|
|
@@ -2726,9 +2728,11 @@ var EraseConfirmModal = ({
|
|
|
2726
2728
|
setFirst(true);
|
|
2727
2729
|
setSecond(false);
|
|
2728
2730
|
};
|
|
2729
|
-
const eraseLabel = itemType === "Post" ? "Erase post" : "Erase comment";
|
|
2730
|
-
const
|
|
2731
|
-
const
|
|
2731
|
+
const eraseLabel = labels?.erase ?? (itemType === "Post" ? "Erase post" : "Erase comment");
|
|
2732
|
+
const cancelLabel = labels?.cancel ?? "Cancel";
|
|
2733
|
+
const confirmTitle = labels?.confirmTitle ?? (itemType === "Post" ? "Are you sure you want to erase this post?" : "Are you sure you want to erase this comment?");
|
|
2734
|
+
const confirmBody = labels?.confirmBody ?? "This action cannot be undone.";
|
|
2735
|
+
const confirmEraseLabel = labels?.confirmErase ?? "Erase";
|
|
2732
2736
|
return /* @__PURE__ */ jsxs15("div", { children: [
|
|
2733
2737
|
/* @__PURE__ */ jsx24("div", { className: "fixed left-0 top-0 z-50 h-screen w-full bg-black/50" }),
|
|
2734
2738
|
/* @__PURE__ */ jsx24(
|
|
@@ -2765,7 +2769,7 @@ var EraseConfirmModal = ({
|
|
|
2765
2769
|
onClick: handleNoPress,
|
|
2766
2770
|
children: [
|
|
2767
2771
|
/* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24(AppIcon, { name: "cancel", className: "cursor-pointer size-6" }) }),
|
|
2768
|
-
/* @__PURE__ */ jsx24("p", { className: "ml-3 text-lg", children:
|
|
2772
|
+
/* @__PURE__ */ jsx24("p", { className: "ml-3 text-lg", children: cancelLabel })
|
|
2769
2773
|
]
|
|
2770
2774
|
}
|
|
2771
2775
|
)
|
|
@@ -2788,7 +2792,7 @@ var EraseConfirmModal = ({
|
|
|
2788
2792
|
{
|
|
2789
2793
|
className: "mr-6 py-2 text-muted-foreground",
|
|
2790
2794
|
onClick: handleNoPress,
|
|
2791
|
-
children:
|
|
2795
|
+
children: cancelLabel
|
|
2792
2796
|
}
|
|
2793
2797
|
),
|
|
2794
2798
|
/* @__PURE__ */ jsx24(
|
|
@@ -2797,7 +2801,7 @@ var EraseConfirmModal = ({
|
|
|
2797
2801
|
className: "rounded-3xl bg-action-primary px-6 py-2 font-semibold text-white",
|
|
2798
2802
|
onClick: onYesPress,
|
|
2799
2803
|
"data-testid": "confirm-modal-erase",
|
|
2800
|
-
children:
|
|
2804
|
+
children: confirmEraseLabel
|
|
2801
2805
|
}
|
|
2802
2806
|
)
|
|
2803
2807
|
] })
|
|
@@ -2848,6 +2852,7 @@ var PostCard = ({
|
|
|
2848
2852
|
isSnoozed = false,
|
|
2849
2853
|
onSnoozeToggle,
|
|
2850
2854
|
mediaItemStatuses,
|
|
2855
|
+
eraseLabels,
|
|
2851
2856
|
showFooterLink = false,
|
|
2852
2857
|
footerLinkLabel,
|
|
2853
2858
|
footerLinkHref,
|
|
@@ -2931,9 +2936,10 @@ var PostCard = ({
|
|
|
2931
2936
|
"div",
|
|
2932
2937
|
{
|
|
2933
2938
|
className: "h-1 w-full overflow-hidden rounded bg-muted",
|
|
2939
|
+
role: "progressbar",
|
|
2934
2940
|
"aria-label": sendingLabel,
|
|
2935
2941
|
"data-testid": "post-loader",
|
|
2936
|
-
children: /* @__PURE__ */ jsx25("div", { className: "h-full
|
|
2942
|
+
children: /* @__PURE__ */ jsx25("div", { className: "animate-indeterminate h-full w-1/3 rounded bg-action-primary" })
|
|
2937
2943
|
}
|
|
2938
2944
|
) }),
|
|
2939
2945
|
!isPending && eraseModalOpen && /* @__PURE__ */ jsx25(
|
|
@@ -2943,7 +2949,8 @@ var PostCard = ({
|
|
|
2943
2949
|
itemType: "Post",
|
|
2944
2950
|
onYesPress: handleEraseConfirm,
|
|
2945
2951
|
onNoPress: handleEraseCancel,
|
|
2946
|
-
handleClose: handleEraseCancel
|
|
2952
|
+
handleClose: handleEraseCancel,
|
|
2953
|
+
labels: eraseLabels
|
|
2947
2954
|
}
|
|
2948
2955
|
),
|
|
2949
2956
|
/* @__PURE__ */ jsxs16("div", { className: cn(isPending && "opacity-50"), children: [
|
|
@@ -2971,7 +2978,8 @@ var PostCard = ({
|
|
|
2971
2978
|
renderActionsMenu,
|
|
2972
2979
|
linkComponent,
|
|
2973
2980
|
imageComponent,
|
|
2974
|
-
labels
|
|
2981
|
+
labels,
|
|
2982
|
+
deleteLabel: eraseLabels?.erase
|
|
2975
2983
|
}
|
|
2976
2984
|
),
|
|
2977
2985
|
/* @__PURE__ */ jsx25(
|
|
@@ -3060,7 +3068,11 @@ var BODY_SIZE = 80;
|
|
|
3060
3068
|
var PostSectionsSummaryView = ({
|
|
3061
3069
|
sections,
|
|
3062
3070
|
fontColor,
|
|
3063
|
-
|
|
3071
|
+
isPostDetail,
|
|
3072
|
+
onCardPress,
|
|
3073
|
+
onNavigate,
|
|
3074
|
+
linkComponent,
|
|
3075
|
+
supportDeepviewDomain
|
|
3064
3076
|
}) => {
|
|
3065
3077
|
const imageItems = useMemo8(() => {
|
|
3066
3078
|
if (!sections || sections.length === 0) return [];
|
|
@@ -3095,14 +3107,17 @@ var PostSectionsSummaryView = ({
|
|
|
3095
3107
|
whiteSpace: "pre-wrap",
|
|
3096
3108
|
wordBreak: "break-word"
|
|
3097
3109
|
},
|
|
3098
|
-
mentionData: data.mentionData
|
|
3110
|
+
mentionData: data.mentionData,
|
|
3111
|
+
onNavigate,
|
|
3112
|
+
linkComponent,
|
|
3113
|
+
supportDeepviewDomain
|
|
3099
3114
|
},
|
|
3100
3115
|
`${index} - ${data.body}`
|
|
3101
3116
|
);
|
|
3102
3117
|
}
|
|
3103
3118
|
return null;
|
|
3104
3119
|
},
|
|
3105
|
-
[fontColor]
|
|
3120
|
+
[fontColor, onNavigate, linkComponent, supportDeepviewDomain]
|
|
3106
3121
|
);
|
|
3107
3122
|
if (!sections || sections.length === 0) {
|
|
3108
3123
|
return null;
|
|
@@ -3121,14 +3136,19 @@ var PostSectionsSummaryView = ({
|
|
|
3121
3136
|
whiteSpace: "pre-wrap",
|
|
3122
3137
|
wordBreak: "break-word"
|
|
3123
3138
|
},
|
|
3124
|
-
mentionData: []
|
|
3139
|
+
mentionData: [],
|
|
3140
|
+
onNavigate,
|
|
3141
|
+
linkComponent,
|
|
3142
|
+
supportDeepviewDomain
|
|
3125
3143
|
},
|
|
3126
3144
|
"body"
|
|
3127
3145
|
),
|
|
3128
3146
|
/* @__PURE__ */ jsx26(
|
|
3129
3147
|
PostMediaLayoutCore_default,
|
|
3130
3148
|
{
|
|
3131
|
-
items: imageItems
|
|
3149
|
+
items: imageItems,
|
|
3150
|
+
isPostDetail,
|
|
3151
|
+
onCardPress
|
|
3132
3152
|
}
|
|
3133
3153
|
)
|
|
3134
3154
|
] });
|