react-sharesheet 1.0.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.
@@ -0,0 +1,833 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/content.ts
21
+ var content_exports = {};
22
+ __export(content_exports, {
23
+ CSS_VARS: () => CSS_VARS,
24
+ CSS_VARS_UI: () => CSS_VARS_UI,
25
+ CSS_VAR_DEFAULTS: () => CSS_VAR_DEFAULTS,
26
+ CSS_VAR_UI_DEFAULTS: () => CSS_VAR_UI_DEFAULTS,
27
+ PLATFORM_COLORS: () => PLATFORM_COLORS,
28
+ PLATFORM_CSS_VARS: () => PLATFORM_CSS_VARS,
29
+ ShareMenuContent: () => ShareMenuContent,
30
+ ShareSheetContent: () => ShareSheetContent
31
+ });
32
+ module.exports = __toCommonJS(content_exports);
33
+
34
+ // src/ShareSheetContent.tsx
35
+ var import_react2 = require("react");
36
+ var import_lucide_react2 = require("lucide-react");
37
+
38
+ // src/utils.ts
39
+ var import_clsx = require("clsx");
40
+ var import_tailwind_merge = require("tailwind-merge");
41
+ function cn(...inputs) {
42
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
43
+ }
44
+ function openUrl(url) {
45
+ window.open(url, "_blank", "noopener,noreferrer");
46
+ }
47
+ function getSafeUrl(shareUrl) {
48
+ return shareUrl || (typeof window !== "undefined" ? window.location.href : "");
49
+ }
50
+
51
+ // src/hooks.ts
52
+ var import_react = require("react");
53
+
54
+ // src/share-functions.ts
55
+ function shareToWhatsApp(url, text) {
56
+ const encoded = encodeURIComponent(`${text}
57
+ ${url}`);
58
+ openUrl(`https://api.whatsapp.com/send?text=${encoded}`);
59
+ }
60
+ function shareToTelegram(url, text) {
61
+ const encodedText = encodeURIComponent(text);
62
+ const encodedUrl = encodeURIComponent(url);
63
+ openUrl(`https://t.me/share/url?url=${encodedUrl}&text=${encodedText}`);
64
+ }
65
+ function shareToX(url, text) {
66
+ const encodedText = encodeURIComponent(text);
67
+ const encodedUrl = encodeURIComponent(url);
68
+ openUrl(`https://x.com/intent/tweet?text=${encodedText}&url=${encodedUrl}`);
69
+ }
70
+ function shareToFacebook(url) {
71
+ const encodedUrl = encodeURIComponent(url);
72
+ openUrl(`https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}`);
73
+ }
74
+ function openInstagram() {
75
+ window.location.href = "instagram://";
76
+ }
77
+ function openTikTok() {
78
+ window.location.href = "tiktok://";
79
+ }
80
+ function openThreads() {
81
+ window.location.href = "threads://";
82
+ }
83
+ function shareToSnapchat(url) {
84
+ const encodedUrl = encodeURIComponent(url);
85
+ openUrl(`https://www.snapchat.com/scan?attachmentUrl=${encodedUrl}`);
86
+ }
87
+ function shareViaSMS(url, text) {
88
+ const body = encodeURIComponent(`${text}
89
+ ${url}`);
90
+ window.location.href = `sms:?body=${body}`;
91
+ }
92
+ function shareViaEmail(url, text, subject = "Share") {
93
+ const encodedSubject = encodeURIComponent(subject);
94
+ const body = encodeURIComponent(`${text}
95
+
96
+ ${url}`);
97
+ window.location.href = `mailto:?subject=${encodedSubject}&body=${body}`;
98
+ }
99
+ function shareToLinkedIn(url) {
100
+ const encodedUrl = encodeURIComponent(url);
101
+ openUrl(`https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl}`);
102
+ }
103
+ function shareToReddit(url, text) {
104
+ const encodedText = encodeURIComponent(text);
105
+ const encodedUrl = encodeURIComponent(url);
106
+ openUrl(`https://www.reddit.com/submit?url=${encodedUrl}&title=${encodedText}`);
107
+ }
108
+
109
+ // src/hooks.ts
110
+ function useShareSheet({
111
+ shareUrl,
112
+ shareText,
113
+ downloadUrl,
114
+ downloadFilename,
115
+ emailSubject = "Share",
116
+ onNativeShare,
117
+ onCopy,
118
+ onDownload
119
+ }) {
120
+ const [copied, setCopied] = (0, import_react.useState)(false);
121
+ const [downloading, setDownloading] = (0, import_react.useState)(false);
122
+ const canNativeShare = (0, import_react.useMemo)(() => {
123
+ return typeof navigator !== "undefined" && "share" in navigator;
124
+ }, []);
125
+ const safeUrl = getSafeUrl(shareUrl);
126
+ const copyLink = (0, import_react.useCallback)(async () => {
127
+ if (!safeUrl) return;
128
+ try {
129
+ await navigator.clipboard.writeText(safeUrl);
130
+ setCopied(true);
131
+ onCopy?.();
132
+ setTimeout(() => setCopied(false), 1200);
133
+ } catch {
134
+ }
135
+ }, [safeUrl, onCopy]);
136
+ const nativeShare = (0, import_react.useCallback)(async () => {
137
+ if (!safeUrl) return;
138
+ const nav = navigator;
139
+ if (!("share" in nav) || typeof nav.share !== "function") return;
140
+ try {
141
+ await nav.share({
142
+ title: shareText,
143
+ text: shareText,
144
+ url: safeUrl
145
+ });
146
+ onNativeShare?.();
147
+ } catch {
148
+ }
149
+ }, [safeUrl, shareText, onNativeShare]);
150
+ const downloadFile = (0, import_react.useCallback)(async () => {
151
+ const url = (downloadUrl ?? "").trim();
152
+ if (!url) return;
153
+ try {
154
+ setDownloading(true);
155
+ onDownload?.();
156
+ const res = await fetch(url);
157
+ if (!res.ok) throw new Error(`Failed to fetch file (${res.status})`);
158
+ const blob = await res.blob();
159
+ const href = URL.createObjectURL(blob);
160
+ const a = document.createElement("a");
161
+ a.href = href;
162
+ a.download = downloadFilename || "download";
163
+ document.body.appendChild(a);
164
+ a.click();
165
+ a.remove();
166
+ URL.revokeObjectURL(href);
167
+ } catch {
168
+ } finally {
169
+ setDownloading(false);
170
+ }
171
+ }, [downloadUrl, downloadFilename, onDownload]);
172
+ const shareWhatsApp = (0, import_react.useCallback)(() => {
173
+ shareToWhatsApp(safeUrl, shareText);
174
+ }, [safeUrl, shareText]);
175
+ const shareTelegram = (0, import_react.useCallback)(() => {
176
+ shareToTelegram(safeUrl, shareText);
177
+ }, [safeUrl, shareText]);
178
+ const shareX = (0, import_react.useCallback)(() => {
179
+ shareToX(safeUrl, shareText);
180
+ }, [safeUrl, shareText]);
181
+ const shareFacebook = (0, import_react.useCallback)(() => {
182
+ shareToFacebook(safeUrl);
183
+ }, [safeUrl]);
184
+ const shareInstagram = (0, import_react.useCallback)(() => {
185
+ openInstagram();
186
+ }, []);
187
+ const shareTikTok = (0, import_react.useCallback)(() => {
188
+ openTikTok();
189
+ }, []);
190
+ const shareThreads = (0, import_react.useCallback)(() => {
191
+ openThreads();
192
+ }, []);
193
+ const shareSnapchat = (0, import_react.useCallback)(() => {
194
+ shareToSnapchat(safeUrl);
195
+ }, [safeUrl]);
196
+ const shareSMS = (0, import_react.useCallback)(() => {
197
+ shareViaSMS(safeUrl, shareText);
198
+ }, [safeUrl, shareText]);
199
+ const shareEmail = (0, import_react.useCallback)(() => {
200
+ shareViaEmail(safeUrl, shareText, emailSubject);
201
+ }, [safeUrl, shareText, emailSubject]);
202
+ const shareLinkedIn = (0, import_react.useCallback)(() => {
203
+ shareToLinkedIn(safeUrl);
204
+ }, [safeUrl]);
205
+ const shareReddit = (0, import_react.useCallback)(() => {
206
+ shareToReddit(safeUrl, shareText);
207
+ }, [safeUrl, shareText]);
208
+ return {
209
+ canNativeShare,
210
+ copied,
211
+ downloading,
212
+ safeUrl,
213
+ copyLink,
214
+ nativeShare,
215
+ downloadFile,
216
+ shareWhatsApp,
217
+ shareTelegram,
218
+ shareX,
219
+ shareFacebook,
220
+ shareInstagram,
221
+ shareTikTok,
222
+ shareThreads,
223
+ shareSnapchat,
224
+ shareSMS,
225
+ shareEmail,
226
+ shareLinkedIn,
227
+ shareReddit
228
+ };
229
+ }
230
+
231
+ // src/platforms.tsx
232
+ var import_lucide_react = require("lucide-react");
233
+ var import_fa = require("react-icons/fa");
234
+ var import_fa6 = require("react-icons/fa6");
235
+ var import_jsx_runtime = require("react/jsx-runtime");
236
+ var PLATFORM_IDS = [
237
+ "native",
238
+ "copy",
239
+ "download",
240
+ "whatsapp",
241
+ "telegram",
242
+ "instagram",
243
+ "facebook",
244
+ "snapchat",
245
+ "sms",
246
+ "email",
247
+ "linkedin",
248
+ "reddit",
249
+ "x",
250
+ "tiktok",
251
+ "threads"
252
+ ];
253
+ var PLATFORM_COLORS = {
254
+ native: { bg: "#7c3aed", text: "#ffffff" },
255
+ copy: { bg: "#3b82f6", text: "#ffffff" },
256
+ download: { bg: "#ef4444", text: "#ffffff" },
257
+ whatsapp: { bg: "#25D366", text: "#ffffff" },
258
+ telegram: { bg: "#229ED9", text: "#ffffff" },
259
+ instagram: { bg: "#E1306C", text: "#ffffff" },
260
+ facebook: { bg: "#1877F2", text: "#ffffff" },
261
+ snapchat: { bg: "#FFFC00", text: "#000000" },
262
+ sms: { bg: "#22c55e", text: "#ffffff" },
263
+ email: { bg: "#f97316", text: "#ffffff" },
264
+ linkedin: { bg: "#0A66C2", text: "#ffffff" },
265
+ reddit: { bg: "#FF4500", text: "#ffffff" },
266
+ x: { bg: "#000000", text: "#ffffff" },
267
+ tiktok: { bg: "#000000", text: "#ffffff" },
268
+ threads: { bg: "#000000", text: "#ffffff" }
269
+ };
270
+ var PLATFORM_LABELS = {
271
+ native: "Share\u2026",
272
+ copy: "Copy",
273
+ download: "Download",
274
+ whatsapp: "WhatsApp",
275
+ telegram: "Telegram",
276
+ instagram: "Instagram",
277
+ facebook: "Facebook",
278
+ snapchat: "Snapchat",
279
+ sms: "SMS",
280
+ email: "Email",
281
+ linkedin: "LinkedIn",
282
+ reddit: "Reddit",
283
+ x: "X",
284
+ tiktok: "TikTok",
285
+ threads: "Threads"
286
+ };
287
+ var PLATFORM_ICONS = {
288
+ native: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Send, { size, className }),
289
+ copy: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Link, { size, className }),
290
+ download: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Download, { size, className }),
291
+ whatsapp: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaWhatsapp, { size, className }),
292
+ telegram: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaTelegramPlane, { size, className }),
293
+ instagram: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaInstagram, { size, className }),
294
+ facebook: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaFacebookF, { size, className }),
295
+ snapchat: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa6.FaSnapchat, { size, className }),
296
+ sms: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.MessageCircle, { size, className }),
297
+ email: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Mail, { size, className }),
298
+ linkedin: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaLinkedin, { size, className }),
299
+ reddit: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaReddit, { size, className }),
300
+ x: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa6.FaXTwitter, { size, className }),
301
+ tiktok: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaTiktok, { size, className }),
302
+ threads: ({ size = 22, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa6.FaThreads, { size, className })
303
+ };
304
+ var PLATFORM_CSS_VARS = {
305
+ native: "--sharesheet-native-bg",
306
+ copy: "--sharesheet-copy-bg",
307
+ download: "--sharesheet-download-bg",
308
+ whatsapp: "--sharesheet-whatsapp-bg",
309
+ telegram: "--sharesheet-telegram-bg",
310
+ instagram: "--sharesheet-instagram-bg",
311
+ facebook: "--sharesheet-facebook-bg",
312
+ snapchat: "--sharesheet-snapchat-bg",
313
+ sms: "--sharesheet-sms-bg",
314
+ email: "--sharesheet-email-bg",
315
+ linkedin: "--sharesheet-linkedin-bg",
316
+ reddit: "--sharesheet-reddit-bg",
317
+ x: "--sharesheet-x-bg",
318
+ tiktok: "--sharesheet-tiktok-bg",
319
+ threads: "--sharesheet-threads-bg"
320
+ };
321
+ var PLATFORMS = Object.fromEntries(
322
+ PLATFORM_IDS.map((id) => [
323
+ id,
324
+ {
325
+ id,
326
+ label: PLATFORM_LABELS[id],
327
+ colors: PLATFORM_COLORS[id],
328
+ Icon: PLATFORM_ICONS[id],
329
+ cssVar: PLATFORM_CSS_VARS[id]
330
+ }
331
+ ])
332
+ );
333
+
334
+ // src/types.ts
335
+ var CSS_VARS_UI = {
336
+ // Drawer
337
+ overlayBg: "--sharesheet-overlay-bg",
338
+ drawerBg: "--sharesheet-drawer-bg",
339
+ drawerBorder: "--sharesheet-drawer-border",
340
+ handleBg: "--sharesheet-handle-bg",
341
+ // Content
342
+ titleColor: "--sharesheet-title-color",
343
+ subtitleColor: "--sharesheet-subtitle-color",
344
+ buttonLabelColor: "--sharesheet-button-label-color",
345
+ // Preview
346
+ previewBg: "--sharesheet-preview-bg",
347
+ previewShimmer: "--sharesheet-preview-shimmer"
348
+ };
349
+ var CSS_VAR_UI_DEFAULTS = {
350
+ [CSS_VARS_UI.overlayBg]: "rgba(0, 0, 0, 0.7)",
351
+ [CSS_VARS_UI.drawerBg]: "#09090b",
352
+ [CSS_VARS_UI.drawerBorder]: "#27272a",
353
+ [CSS_VARS_UI.handleBg]: "#27272a",
354
+ [CSS_VARS_UI.titleColor]: "#ffffff",
355
+ [CSS_VARS_UI.subtitleColor]: "#a1a1aa",
356
+ [CSS_VARS_UI.buttonLabelColor]: "#ffffff",
357
+ [CSS_VARS_UI.previewBg]: "rgba(255, 255, 255, 0.05)",
358
+ [CSS_VARS_UI.previewShimmer]: "rgba(255, 255, 255, 0.1)"
359
+ };
360
+ var CSS_VARS = CSS_VARS_UI;
361
+ var CSS_VAR_DEFAULTS = CSS_VAR_UI_DEFAULTS;
362
+
363
+ // src/ShareSheetContent.tsx
364
+ var import_jsx_runtime2 = require("react/jsx-runtime");
365
+ var DEFAULT_BUTTON_SIZE = 45;
366
+ var DEFAULT_ICON_SIZE = 22;
367
+ var IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "ico", "avif"];
368
+ var VIDEO_EXTENSIONS = ["mp4", "webm", "mov", "avi", "mkv", "m4v", "ogv"];
369
+ var AUDIO_EXTENSIONS = ["mp3", "wav", "ogg", "m4a", "aac", "flac", "wma"];
370
+ function detectPreviewType(url) {
371
+ try {
372
+ const pathname = new URL(url, "http://localhost").pathname;
373
+ const ext = pathname.split(".").pop()?.toLowerCase() || "";
374
+ if (IMAGE_EXTENSIONS.includes(ext)) return "image";
375
+ if (VIDEO_EXTENSIONS.includes(ext)) return "video";
376
+ if (AUDIO_EXTENSIONS.includes(ext)) return "audio";
377
+ if (url.includes("/api/og") || url.includes("og-image")) return "image";
378
+ if (url.includes("youtube.com") || url.includes("vimeo.com")) return "video";
379
+ return "link";
380
+ } catch {
381
+ return "link";
382
+ }
383
+ }
384
+ function getFilenameFromUrl(url) {
385
+ try {
386
+ const pathname = new URL(url, "http://localhost").pathname;
387
+ const filename = pathname.split("/").pop() || "";
388
+ return decodeURIComponent(filename);
389
+ } catch {
390
+ return url;
391
+ }
392
+ }
393
+ var defaultClasses = {
394
+ root: "max-w-md mx-auto",
395
+ header: "text-center mb-2",
396
+ title: "text-2xl font-black",
397
+ subtitle: "mt-1 text-sm",
398
+ preview: "flex justify-center mb-4 px-4",
399
+ previewSkeleton: "rounded-xl overflow-hidden",
400
+ previewImage: "",
401
+ previewVideo: "",
402
+ previewFile: "",
403
+ previewFileIcon: "",
404
+ previewFilename: "truncate",
405
+ previewLink: "",
406
+ grid: "px-2 py-6 flex flex-row items-center gap-4 gap-y-6 flex-wrap justify-center",
407
+ button: "flex flex-col items-center gap-0 text-xs w-[60px] outline-none cursor-pointer group",
408
+ buttonIcon: "p-2 rounded-full transition-all flex items-center justify-center group-hover:scale-110 group-active:scale-95 mb-2",
409
+ buttonLabel: ""
410
+ };
411
+ var shimmerKeyframes = `
412
+ @keyframes sharesheet-shimmer {
413
+ 0% { transform: translateX(-100%); }
414
+ 100% { transform: translateX(100%); }
415
+ }
416
+ `;
417
+ function cssVar(name, fallback) {
418
+ return `var(${name}, ${fallback})`;
419
+ }
420
+ function normalizePreview(preview) {
421
+ if (!preview) return null;
422
+ if (typeof preview === "string") {
423
+ const type2 = detectPreviewType(preview);
424
+ return {
425
+ url: preview,
426
+ type: type2,
427
+ filename: getFilenameFromUrl(preview)
428
+ };
429
+ }
430
+ const type = preview.type === "auto" || !preview.type ? detectPreviewType(preview.url) : preview.type;
431
+ return {
432
+ ...preview,
433
+ type,
434
+ filename: preview.filename || getFilenameFromUrl(preview.url)
435
+ };
436
+ }
437
+ function ShareSheetContent({
438
+ title = "Share",
439
+ shareUrl,
440
+ shareText,
441
+ preview,
442
+ downloadUrl,
443
+ downloadFilename,
444
+ className,
445
+ classNames = {},
446
+ buttonSize = DEFAULT_BUTTON_SIZE,
447
+ iconSize = DEFAULT_ICON_SIZE,
448
+ onNativeShare,
449
+ onCopy,
450
+ onDownload,
451
+ hide = [],
452
+ show,
453
+ labels = {},
454
+ icons = {}
455
+ }) {
456
+ const [mediaLoaded, setMediaLoaded] = (0, import_react2.useState)(false);
457
+ const [mediaError, setMediaError] = (0, import_react2.useState)(false);
458
+ const handleMediaLoad = (0, import_react2.useCallback)(() => {
459
+ setMediaLoaded(true);
460
+ }, []);
461
+ const handleMediaError = (0, import_react2.useCallback)(() => {
462
+ setMediaError(true);
463
+ }, []);
464
+ const previewConfig = (0, import_react2.useMemo)(() => normalizePreview(preview), [preview]);
465
+ const shareSheet = useShareSheet({
466
+ shareUrl,
467
+ shareText,
468
+ downloadUrl,
469
+ downloadFilename,
470
+ emailSubject: title,
471
+ onNativeShare,
472
+ onCopy,
473
+ onDownload
474
+ });
475
+ const shareActions = (0, import_react2.useMemo)(() => ({
476
+ native: () => void shareSheet.nativeShare(),
477
+ copy: () => void shareSheet.copyLink(),
478
+ download: () => void shareSheet.downloadFile(),
479
+ whatsapp: shareSheet.shareWhatsApp,
480
+ telegram: shareSheet.shareTelegram,
481
+ instagram: shareSheet.shareInstagram,
482
+ facebook: shareSheet.shareFacebook,
483
+ snapchat: shareSheet.shareSnapchat,
484
+ sms: shareSheet.shareSMS,
485
+ email: shareSheet.shareEmail,
486
+ linkedin: shareSheet.shareLinkedIn,
487
+ reddit: shareSheet.shareReddit,
488
+ x: shareSheet.shareX,
489
+ tiktok: shareSheet.shareTikTok,
490
+ threads: shareSheet.shareThreads
491
+ }), [shareSheet]);
492
+ const dynamicLabels = (0, import_react2.useMemo)(() => ({
493
+ copy: shareSheet.copied ? "Copied!" : PLATFORM_LABELS.copy,
494
+ download: shareSheet.downloading ? "..." : PLATFORM_LABELS.download
495
+ }), [shareSheet.copied, shareSheet.downloading]);
496
+ const buttons = (0, import_react2.useMemo)(() => {
497
+ return PLATFORM_IDS.map((id) => {
498
+ const Icon = PLATFORM_ICONS[id];
499
+ const defaultLabel = dynamicLabels[id] ?? PLATFORM_LABELS[id];
500
+ return {
501
+ id,
502
+ label: labels[id] ?? defaultLabel,
503
+ icon: icons[id] ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { size: iconSize }),
504
+ // Use CSS var with fallback to platform color
505
+ bgColor: cssVar(PLATFORM_CSS_VARS[id], PLATFORM_COLORS[id].bg),
506
+ textColor: PLATFORM_COLORS[id].text,
507
+ onClick: shareActions[id],
508
+ // Conditions for showing certain buttons
509
+ condition: id === "native" ? shareSheet.canNativeShare : id === "download" ? !!downloadUrl : true
510
+ };
511
+ });
512
+ }, [iconSize, labels, icons, dynamicLabels, shareActions, shareSheet.canNativeShare, downloadUrl]);
513
+ const visibleButtons = (0, import_react2.useMemo)(() => {
514
+ return buttons.filter((btn) => {
515
+ if (btn.condition === false) return false;
516
+ if (show && show.length > 0) return show.includes(btn.id);
517
+ if (hide.includes(btn.id)) return false;
518
+ return true;
519
+ });
520
+ }, [buttons, show, hide]);
521
+ const showPreview = !!previewConfig;
522
+ const renderPreview = () => {
523
+ if (!previewConfig) return null;
524
+ const { type, url, filename, alt, poster } = previewConfig;
525
+ const bgColor = cssVar(CSS_VARS_UI.previewBg, CSS_VAR_UI_DEFAULTS[CSS_VARS_UI.previewBg]);
526
+ const shimmerColor = cssVar(CSS_VARS_UI.previewShimmer, CSS_VAR_UI_DEFAULTS[CSS_VARS_UI.previewShimmer]);
527
+ const textColor = cssVar(CSS_VARS_UI.subtitleColor, CSS_VAR_UI_DEFAULTS[CSS_VARS_UI.subtitleColor]);
528
+ const UrlLabel = ({ displayUrl = url }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
529
+ "div",
530
+ {
531
+ className: cn(defaultClasses.previewFilename, classNames.previewFilename),
532
+ style: {
533
+ color: textColor,
534
+ fontSize: "10px",
535
+ opacity: 0.5,
536
+ textAlign: "center",
537
+ marginTop: "6px"
538
+ },
539
+ children: displayUrl
540
+ }
541
+ );
542
+ const PlaceholderCard = ({
543
+ icon: IconComponent,
544
+ isLoading = false,
545
+ label,
546
+ displayUrl
547
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
548
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
549
+ "div",
550
+ {
551
+ className: cn(defaultClasses.previewSkeleton, classNames.previewSkeleton),
552
+ style: {
553
+ position: "relative",
554
+ backgroundColor: bgColor,
555
+ width: "200px",
556
+ height: "120px",
557
+ overflow: "hidden",
558
+ display: "flex",
559
+ alignItems: "center",
560
+ justifyContent: "center"
561
+ },
562
+ children: [
563
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", inset: 0, overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
564
+ "div",
565
+ {
566
+ style: {
567
+ position: "absolute",
568
+ inset: 0,
569
+ background: `linear-gradient(90deg, transparent, ${shimmerColor}, transparent)`,
570
+ animation: "sharesheet-shimmer 1.5s infinite"
571
+ }
572
+ }
573
+ ) }),
574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
575
+ "div",
576
+ {
577
+ style: {
578
+ display: "flex",
579
+ flexDirection: "column",
580
+ alignItems: "center",
581
+ justifyContent: "center",
582
+ gap: "8px"
583
+ },
584
+ children: [
585
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconComponent, { size: 32, style: { color: textColor, opacity: 0.4 } }),
586
+ label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { color: textColor, fontSize: "11px", opacity: 0.4 }, children: label })
587
+ ]
588
+ }
589
+ )
590
+ ]
591
+ }
592
+ ),
593
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UrlLabel, { displayUrl })
594
+ ] });
595
+ if (mediaError && (type === "image" || type === "video")) {
596
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlaceholderCard, { icon: import_lucide_react2.Link2, displayUrl: url });
597
+ }
598
+ switch (type) {
599
+ case "image":
600
+ if (!mediaLoaded) {
601
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
602
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
603
+ "div",
604
+ {
605
+ className: cn(defaultClasses.previewSkeleton, classNames.previewSkeleton),
606
+ style: {
607
+ position: "relative",
608
+ backgroundColor: bgColor,
609
+ width: "200px",
610
+ height: "120px",
611
+ overflow: "hidden",
612
+ display: "flex",
613
+ alignItems: "center",
614
+ justifyContent: "center"
615
+ },
616
+ children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", inset: 0, overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
618
+ "div",
619
+ {
620
+ style: {
621
+ position: "absolute",
622
+ inset: 0,
623
+ background: `linear-gradient(90deg, transparent, ${shimmerColor}, transparent)`,
624
+ animation: "sharesheet-shimmer 1.5s infinite"
625
+ }
626
+ }
627
+ ) }),
628
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Image, { size: 32, style: { color: textColor, opacity: 0.4 } })
629
+ ]
630
+ }
631
+ ),
632
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UrlLabel, {}),
633
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
634
+ "img",
635
+ {
636
+ src: url,
637
+ alt: alt || "Preview",
638
+ onLoad: handleMediaLoad,
639
+ onError: handleMediaError,
640
+ style: { display: "none" }
641
+ }
642
+ )
643
+ ] });
644
+ }
645
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
646
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
647
+ "img",
648
+ {
649
+ src: url,
650
+ alt: alt || "Preview",
651
+ className: cn(defaultClasses.previewImage, classNames.previewImage),
652
+ style: {
653
+ maxWidth: "100%",
654
+ maxHeight: "180px",
655
+ borderRadius: "12px",
656
+ opacity: 1,
657
+ transition: "opacity 0.3s ease-in-out"
658
+ }
659
+ }
660
+ ),
661
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UrlLabel, {})
662
+ ] });
663
+ case "video":
664
+ if (!mediaLoaded) {
665
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
666
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
667
+ "div",
668
+ {
669
+ className: cn(defaultClasses.previewSkeleton, classNames.previewSkeleton),
670
+ style: {
671
+ position: "relative",
672
+ backgroundColor: bgColor,
673
+ width: "200px",
674
+ height: "120px",
675
+ overflow: "hidden",
676
+ display: "flex",
677
+ alignItems: "center",
678
+ justifyContent: "center"
679
+ },
680
+ children: [
681
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", inset: 0, overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
682
+ "div",
683
+ {
684
+ style: {
685
+ position: "absolute",
686
+ inset: 0,
687
+ background: `linear-gradient(90deg, transparent, ${shimmerColor}, transparent)`,
688
+ animation: "sharesheet-shimmer 1.5s infinite"
689
+ }
690
+ }
691
+ ) }),
692
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Film, { size: 32, style: { color: textColor, opacity: 0.4 } })
693
+ ]
694
+ }
695
+ ),
696
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UrlLabel, {}),
697
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
698
+ "video",
699
+ {
700
+ src: url,
701
+ poster,
702
+ onLoadedData: handleMediaLoad,
703
+ onError: handleMediaError,
704
+ style: { display: "none" },
705
+ muted: true,
706
+ playsInline: true,
707
+ preload: "metadata"
708
+ }
709
+ )
710
+ ] });
711
+ }
712
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
713
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { position: "relative", borderRadius: "12px", overflow: "hidden" }, children: [
714
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
715
+ "video",
716
+ {
717
+ src: url,
718
+ poster,
719
+ className: cn(defaultClasses.previewVideo, classNames.previewVideo),
720
+ style: {
721
+ maxWidth: "100%",
722
+ maxHeight: "180px",
723
+ display: "block"
724
+ },
725
+ muted: true,
726
+ playsInline: true,
727
+ preload: "metadata"
728
+ }
729
+ ),
730
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
731
+ "div",
732
+ {
733
+ style: {
734
+ position: "absolute",
735
+ inset: 0,
736
+ display: "flex",
737
+ alignItems: "center",
738
+ justifyContent: "center",
739
+ pointerEvents: "none"
740
+ },
741
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
742
+ "div",
743
+ {
744
+ style: {
745
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
746
+ borderRadius: "50%",
747
+ padding: "10px"
748
+ },
749
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Play, { size: 20, fill: "white", color: "white" })
750
+ }
751
+ )
752
+ }
753
+ )
754
+ ] }),
755
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UrlLabel, {})
756
+ ] });
757
+ case "audio":
758
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlaceholderCard, { icon: import_lucide_react2.Music, label: filename || "Audio", displayUrl: url });
759
+ case "file":
760
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlaceholderCard, { icon: import_lucide_react2.FileText, label: filename || "File", displayUrl: url });
761
+ case "link":
762
+ default:
763
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlaceholderCard, { icon: import_lucide_react2.Link2, displayUrl: url });
764
+ }
765
+ };
766
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn(defaultClasses.root, classNames.root, className), children: [
767
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { dangerouslySetInnerHTML: { __html: shimmerKeyframes } }),
768
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn(defaultClasses.header, classNames.header), children: [
769
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
770
+ "div",
771
+ {
772
+ className: cn(defaultClasses.title, classNames.title),
773
+ style: { color: cssVar(CSS_VARS_UI.titleColor, CSS_VAR_UI_DEFAULTS[CSS_VARS_UI.titleColor]) },
774
+ children: title
775
+ }
776
+ ),
777
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
778
+ "div",
779
+ {
780
+ className: cn(defaultClasses.subtitle, classNames.subtitle),
781
+ style: { color: cssVar(CSS_VARS_UI.subtitleColor, CSS_VAR_UI_DEFAULTS[CSS_VARS_UI.subtitleColor]) },
782
+ children: shareText
783
+ }
784
+ )
785
+ ] }),
786
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: cn(defaultClasses.preview, classNames.preview), children: renderPreview() }),
787
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: cn(defaultClasses.grid, classNames.grid), children: visibleButtons.map((btn) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
788
+ "button",
789
+ {
790
+ type: "button",
791
+ className: cn(defaultClasses.button, classNames.button),
792
+ onClick: btn.onClick,
793
+ children: [
794
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
795
+ "div",
796
+ {
797
+ className: cn(defaultClasses.buttonIcon, classNames.buttonIcon),
798
+ style: {
799
+ width: buttonSize,
800
+ height: buttonSize,
801
+ backgroundColor: btn.bgColor,
802
+ color: btn.textColor
803
+ },
804
+ children: btn.icon
805
+ }
806
+ ),
807
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
808
+ "div",
809
+ {
810
+ className: cn(defaultClasses.buttonLabel, classNames.buttonLabel),
811
+ style: { color: cssVar(CSS_VARS_UI.buttonLabelColor, CSS_VAR_UI_DEFAULTS[CSS_VARS_UI.buttonLabelColor]) },
812
+ children: btn.label
813
+ }
814
+ )
815
+ ]
816
+ },
817
+ btn.id
818
+ )) })
819
+ ] });
820
+ }
821
+ var ShareMenuContent = ShareSheetContent;
822
+ // Annotate the CommonJS export names for ESM import in node:
823
+ 0 && (module.exports = {
824
+ CSS_VARS,
825
+ CSS_VARS_UI,
826
+ CSS_VAR_DEFAULTS,
827
+ CSS_VAR_UI_DEFAULTS,
828
+ PLATFORM_COLORS,
829
+ PLATFORM_CSS_VARS,
830
+ ShareMenuContent,
831
+ ShareSheetContent
832
+ });
833
+ //# sourceMappingURL=content.js.map