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.
- package/README.md +581 -0
- package/dist/content.d.mts +10 -0
- package/dist/content.d.ts +10 -0
- package/dist/content.js +833 -0
- package/dist/content.js.map +1 -0
- package/dist/content.mjs +813 -0
- package/dist/content.mjs.map +1 -0
- package/dist/drawer.d.mts +10 -0
- package/dist/drawer.d.ts +10 -0
- package/dist/drawer.js +960 -0
- package/dist/drawer.js.map +1 -0
- package/dist/drawer.mjs +940 -0
- package/dist/drawer.mjs.map +1 -0
- package/dist/headless.d.mts +51 -0
- package/dist/headless.d.ts +51 -0
- package/dist/headless.js +405 -0
- package/dist/headless.js.map +1 -0
- package/dist/headless.mjs +364 -0
- package/dist/headless.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1040 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +991 -0
- package/dist/index.mjs.map +1 -0
- package/dist/platforms-DU1DVDFq.d.mts +280 -0
- package/dist/platforms-DU1DVDFq.d.ts +280 -0
- package/package.json +88 -0
- package/src/ShareSheetContent.tsx +538 -0
- package/src/ShareSheetDrawer.tsx +128 -0
- package/src/content.ts +4 -0
- package/src/drawer.ts +4 -0
- package/src/headless.ts +45 -0
- package/src/hooks.ts +192 -0
- package/src/index.ts +68 -0
- package/src/platforms.tsx +186 -0
- package/src/share-functions.ts +63 -0
- package/src/types.ts +236 -0
- package/src/utils.ts +15 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/** CSS variable names for UI elements (non-platform specific) */
|
|
4
|
+
declare const CSS_VARS_UI: {
|
|
5
|
+
readonly overlayBg: "--sharesheet-overlay-bg";
|
|
6
|
+
readonly drawerBg: "--sharesheet-drawer-bg";
|
|
7
|
+
readonly drawerBorder: "--sharesheet-drawer-border";
|
|
8
|
+
readonly handleBg: "--sharesheet-handle-bg";
|
|
9
|
+
readonly titleColor: "--sharesheet-title-color";
|
|
10
|
+
readonly subtitleColor: "--sharesheet-subtitle-color";
|
|
11
|
+
readonly buttonLabelColor: "--sharesheet-button-label-color";
|
|
12
|
+
readonly previewBg: "--sharesheet-preview-bg";
|
|
13
|
+
readonly previewShimmer: "--sharesheet-preview-shimmer";
|
|
14
|
+
};
|
|
15
|
+
/** Default values for UI CSS variables */
|
|
16
|
+
declare const CSS_VAR_UI_DEFAULTS: {
|
|
17
|
+
readonly "--sharesheet-overlay-bg": "rgba(0, 0, 0, 0.7)";
|
|
18
|
+
readonly "--sharesheet-drawer-bg": "#09090b";
|
|
19
|
+
readonly "--sharesheet-drawer-border": "#27272a";
|
|
20
|
+
readonly "--sharesheet-handle-bg": "#27272a";
|
|
21
|
+
readonly "--sharesheet-title-color": "#ffffff";
|
|
22
|
+
readonly "--sharesheet-subtitle-color": "#a1a1aa";
|
|
23
|
+
readonly "--sharesheet-button-label-color": "#ffffff";
|
|
24
|
+
readonly "--sharesheet-preview-bg": "rgba(255, 255, 255, 0.05)";
|
|
25
|
+
readonly "--sharesheet-preview-shimmer": "rgba(255, 255, 255, 0.1)";
|
|
26
|
+
};
|
|
27
|
+
/** Available share options */
|
|
28
|
+
type ShareOption = "native" | "copy" | "download" | "whatsapp" | "telegram" | "instagram" | "facebook" | "snapchat" | "sms" | "email" | "linkedin" | "reddit" | "x" | "tiktok" | "threads";
|
|
29
|
+
/** Class name overrides for ShareSheetContent */
|
|
30
|
+
interface ShareSheetContentClassNames {
|
|
31
|
+
/** Root container */
|
|
32
|
+
root?: string;
|
|
33
|
+
/** Title container */
|
|
34
|
+
header?: string;
|
|
35
|
+
/** Main title text */
|
|
36
|
+
title?: string;
|
|
37
|
+
/** Subtitle/share text */
|
|
38
|
+
subtitle?: string;
|
|
39
|
+
/** Preview container */
|
|
40
|
+
preview?: string;
|
|
41
|
+
/** Preview skeleton/loading wrapper */
|
|
42
|
+
previewSkeleton?: string;
|
|
43
|
+
/** Preview image element */
|
|
44
|
+
previewImage?: string;
|
|
45
|
+
/** Preview video element */
|
|
46
|
+
previewVideo?: string;
|
|
47
|
+
/** Preview file/audio container */
|
|
48
|
+
previewFile?: string;
|
|
49
|
+
/** Preview file icon */
|
|
50
|
+
previewFileIcon?: string;
|
|
51
|
+
/** Preview filename text */
|
|
52
|
+
previewFilename?: string;
|
|
53
|
+
/** Preview link container */
|
|
54
|
+
previewLink?: string;
|
|
55
|
+
/** Buttons grid container */
|
|
56
|
+
grid?: string;
|
|
57
|
+
/** Individual button wrapper */
|
|
58
|
+
button?: string;
|
|
59
|
+
/** Button icon container */
|
|
60
|
+
buttonIcon?: string;
|
|
61
|
+
/** Button label text */
|
|
62
|
+
buttonLabel?: string;
|
|
63
|
+
}
|
|
64
|
+
/** Class name overrides for ShareSheetDrawer */
|
|
65
|
+
interface ShareSheetDrawerClassNames extends ShareSheetContentClassNames {
|
|
66
|
+
/** Drawer overlay */
|
|
67
|
+
overlay?: string;
|
|
68
|
+
/** Drawer content panel */
|
|
69
|
+
drawer?: string;
|
|
70
|
+
/** Drawer inner content wrapper */
|
|
71
|
+
drawerInner?: string;
|
|
72
|
+
/** Drawer handle */
|
|
73
|
+
handle?: string;
|
|
74
|
+
/** Trigger wrapper */
|
|
75
|
+
trigger?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Preview content type */
|
|
78
|
+
type PreviewType = "image" | "video" | "audio" | "file" | "link" | "auto";
|
|
79
|
+
/** Preview configuration */
|
|
80
|
+
interface PreviewConfig {
|
|
81
|
+
/** URL of the content to preview */
|
|
82
|
+
url: string;
|
|
83
|
+
/** Type of content (auto-detected if not provided) */
|
|
84
|
+
type?: PreviewType;
|
|
85
|
+
/** Filename to display (for file/audio types) */
|
|
86
|
+
filename?: string;
|
|
87
|
+
/** Alt text for images */
|
|
88
|
+
alt?: string;
|
|
89
|
+
/** Poster image for videos */
|
|
90
|
+
poster?: string;
|
|
91
|
+
}
|
|
92
|
+
interface ShareSheetContentProps {
|
|
93
|
+
/** Title displayed at the top of the sheet */
|
|
94
|
+
title?: string;
|
|
95
|
+
/** URL to share */
|
|
96
|
+
shareUrl: string;
|
|
97
|
+
/** Text to share alongside the URL */
|
|
98
|
+
shareText: string;
|
|
99
|
+
/** Preview of content being shared (string URL or config object) */
|
|
100
|
+
preview?: string | PreviewConfig | null;
|
|
101
|
+
/** Optional URL for download functionality */
|
|
102
|
+
downloadUrl?: string | null;
|
|
103
|
+
/** Filename for downloaded file */
|
|
104
|
+
downloadFilename?: string;
|
|
105
|
+
/** Custom class name for the container (shorthand for classNames.root) */
|
|
106
|
+
className?: string;
|
|
107
|
+
/** Override class names for sub-components */
|
|
108
|
+
classNames?: ShareSheetContentClassNames;
|
|
109
|
+
/** Button size in pixels */
|
|
110
|
+
buttonSize?: number;
|
|
111
|
+
/** Icon size in pixels */
|
|
112
|
+
iconSize?: number;
|
|
113
|
+
/** Called when native share is triggered */
|
|
114
|
+
onNativeShare?: () => void;
|
|
115
|
+
/** Called when link is copied */
|
|
116
|
+
onCopy?: () => void;
|
|
117
|
+
/** Called when download starts */
|
|
118
|
+
onDownload?: () => void;
|
|
119
|
+
/** Hide specific share options */
|
|
120
|
+
hide?: ShareOption[];
|
|
121
|
+
/** Show only specific share options */
|
|
122
|
+
show?: ShareOption[];
|
|
123
|
+
/** Custom labels for buttons */
|
|
124
|
+
labels?: Partial<Record<ShareOption, string>>;
|
|
125
|
+
/** Custom icons for buttons */
|
|
126
|
+
icons?: Partial<Record<ShareOption, ReactNode>>;
|
|
127
|
+
}
|
|
128
|
+
interface ShareSheetDrawerProps extends ShareSheetContentProps {
|
|
129
|
+
/** Whether the drawer is disabled */
|
|
130
|
+
disabled?: boolean;
|
|
131
|
+
/** Trigger element for the drawer */
|
|
132
|
+
children: React.ReactNode;
|
|
133
|
+
/** Controlled open state */
|
|
134
|
+
open?: boolean;
|
|
135
|
+
/** Callback when open state changes */
|
|
136
|
+
onOpenChange?: (open: boolean) => void;
|
|
137
|
+
/** Override class names for sub-components */
|
|
138
|
+
classNames?: ShareSheetDrawerClassNames;
|
|
139
|
+
}
|
|
140
|
+
/** Share button configuration (internal) */
|
|
141
|
+
interface ShareButtonConfig {
|
|
142
|
+
id: ShareOption;
|
|
143
|
+
label: string;
|
|
144
|
+
icon: ReactNode;
|
|
145
|
+
bgColor: string;
|
|
146
|
+
textColor?: string;
|
|
147
|
+
onClick: () => void;
|
|
148
|
+
condition?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** Return type of useShareSheet hook */
|
|
151
|
+
interface UseShareSheetReturn {
|
|
152
|
+
/** Whether the browser supports native share */
|
|
153
|
+
canNativeShare: boolean;
|
|
154
|
+
/** Whether the link was recently copied */
|
|
155
|
+
copied: boolean;
|
|
156
|
+
/** Whether a download is in progress */
|
|
157
|
+
downloading: boolean;
|
|
158
|
+
/** The safe URL (falls back to current page URL) */
|
|
159
|
+
safeUrl: string;
|
|
160
|
+
/** Copy the share URL to clipboard */
|
|
161
|
+
copyLink: () => Promise<void>;
|
|
162
|
+
/** Trigger native share dialog */
|
|
163
|
+
nativeShare: () => Promise<void>;
|
|
164
|
+
/** Download the file from downloadUrl */
|
|
165
|
+
downloadFile: () => Promise<void>;
|
|
166
|
+
/** Share to WhatsApp */
|
|
167
|
+
shareWhatsApp: () => void;
|
|
168
|
+
/** Share to Telegram */
|
|
169
|
+
shareTelegram: () => void;
|
|
170
|
+
/** Share to X (Twitter) */
|
|
171
|
+
shareX: () => void;
|
|
172
|
+
/** Share to Facebook */
|
|
173
|
+
shareFacebook: () => void;
|
|
174
|
+
/** Open Instagram app */
|
|
175
|
+
shareInstagram: () => void;
|
|
176
|
+
/** Open TikTok app */
|
|
177
|
+
shareTikTok: () => void;
|
|
178
|
+
/** Open Threads app */
|
|
179
|
+
shareThreads: () => void;
|
|
180
|
+
/** Share to Snapchat */
|
|
181
|
+
shareSnapchat: () => void;
|
|
182
|
+
/** Share via SMS */
|
|
183
|
+
shareSMS: () => void;
|
|
184
|
+
/** Share via Email */
|
|
185
|
+
shareEmail: () => void;
|
|
186
|
+
/** Share to LinkedIn */
|
|
187
|
+
shareLinkedIn: () => void;
|
|
188
|
+
/** Share to Reddit */
|
|
189
|
+
shareReddit: () => void;
|
|
190
|
+
}
|
|
191
|
+
/** @deprecated Use CSS_VARS_UI instead */
|
|
192
|
+
declare const CSS_VARS: {
|
|
193
|
+
readonly overlayBg: "--sharesheet-overlay-bg";
|
|
194
|
+
readonly drawerBg: "--sharesheet-drawer-bg";
|
|
195
|
+
readonly drawerBorder: "--sharesheet-drawer-border";
|
|
196
|
+
readonly handleBg: "--sharesheet-handle-bg";
|
|
197
|
+
readonly titleColor: "--sharesheet-title-color";
|
|
198
|
+
readonly subtitleColor: "--sharesheet-subtitle-color";
|
|
199
|
+
readonly buttonLabelColor: "--sharesheet-button-label-color";
|
|
200
|
+
readonly previewBg: "--sharesheet-preview-bg";
|
|
201
|
+
readonly previewShimmer: "--sharesheet-preview-shimmer";
|
|
202
|
+
};
|
|
203
|
+
/** @deprecated Use CSS_VAR_UI_DEFAULTS instead */
|
|
204
|
+
declare const CSS_VAR_DEFAULTS: {
|
|
205
|
+
readonly "--sharesheet-overlay-bg": "rgba(0, 0, 0, 0.7)";
|
|
206
|
+
readonly "--sharesheet-drawer-bg": "#09090b";
|
|
207
|
+
readonly "--sharesheet-drawer-border": "#27272a";
|
|
208
|
+
readonly "--sharesheet-handle-bg": "#27272a";
|
|
209
|
+
readonly "--sharesheet-title-color": "#ffffff";
|
|
210
|
+
readonly "--sharesheet-subtitle-color": "#a1a1aa";
|
|
211
|
+
readonly "--sharesheet-button-label-color": "#ffffff";
|
|
212
|
+
readonly "--sharesheet-preview-bg": "rgba(255, 255, 255, 0.05)";
|
|
213
|
+
readonly "--sharesheet-preview-shimmer": "rgba(255, 255, 255, 0.1)";
|
|
214
|
+
};
|
|
215
|
+
/** @deprecated Use ShareSheetContentClassNames instead */
|
|
216
|
+
type ShareMenuContentClassNames = ShareSheetContentClassNames;
|
|
217
|
+
/** @deprecated Use ShareSheetDrawerClassNames instead */
|
|
218
|
+
type ShareMenuDrawerClassNames = ShareSheetDrawerClassNames;
|
|
219
|
+
/** @deprecated Use ShareSheetContentProps instead */
|
|
220
|
+
type ShareMenuContentProps = ShareSheetContentProps;
|
|
221
|
+
/** @deprecated Use ShareSheetDrawerProps instead */
|
|
222
|
+
type ShareMenuDrawerProps = ShareSheetDrawerProps;
|
|
223
|
+
/** @deprecated Use UseShareSheetReturn instead */
|
|
224
|
+
type UseShareMenuReturn = UseShareSheetReturn;
|
|
225
|
+
|
|
226
|
+
/** Platform color configuration */
|
|
227
|
+
interface PlatformColor {
|
|
228
|
+
/** Background color (hex) */
|
|
229
|
+
bg: string;
|
|
230
|
+
/** Text/icon color (hex) */
|
|
231
|
+
text: string;
|
|
232
|
+
}
|
|
233
|
+
/** Platform configuration */
|
|
234
|
+
interface PlatformConfig {
|
|
235
|
+
/** Platform identifier */
|
|
236
|
+
id: ShareOption;
|
|
237
|
+
/** Display label */
|
|
238
|
+
label: string;
|
|
239
|
+
/** Colors */
|
|
240
|
+
colors: PlatformColor;
|
|
241
|
+
/** Icon component (accepts size prop) */
|
|
242
|
+
Icon: (props: {
|
|
243
|
+
size?: number;
|
|
244
|
+
className?: string;
|
|
245
|
+
}) => ReactNode;
|
|
246
|
+
/** CSS variable name for background */
|
|
247
|
+
cssVar: string;
|
|
248
|
+
}
|
|
249
|
+
/** All platform IDs in default order */
|
|
250
|
+
declare const PLATFORM_IDS: readonly ShareOption[];
|
|
251
|
+
/** Platform colors - hex values for each platform (SOURCE OF TRUTH) */
|
|
252
|
+
declare const PLATFORM_COLORS: Record<ShareOption, PlatformColor>;
|
|
253
|
+
/** Platform labels (SOURCE OF TRUTH) */
|
|
254
|
+
declare const PLATFORM_LABELS: Record<ShareOption, string>;
|
|
255
|
+
/** Platform icons - React components (SOURCE OF TRUTH) */
|
|
256
|
+
declare const PLATFORM_ICONS: Record<ShareOption, (props: {
|
|
257
|
+
size?: number;
|
|
258
|
+
className?: string;
|
|
259
|
+
}) => ReactNode>;
|
|
260
|
+
/** CSS variable names for platform backgrounds */
|
|
261
|
+
declare const PLATFORM_CSS_VARS: Record<ShareOption, string>;
|
|
262
|
+
/** Full platform configurations */
|
|
263
|
+
declare const PLATFORMS: Record<ShareOption, PlatformConfig>;
|
|
264
|
+
/** Get platform config by id */
|
|
265
|
+
declare function getPlatform(id: ShareOption): PlatformConfig;
|
|
266
|
+
/** Get all platform configs as array */
|
|
267
|
+
declare function getAllPlatforms(): PlatformConfig[];
|
|
268
|
+
/** Get platform color */
|
|
269
|
+
declare function getPlatformColor(id: ShareOption): PlatformColor;
|
|
270
|
+
/** Get platform icon component */
|
|
271
|
+
declare function getPlatformIcon(id: ShareOption): (props: {
|
|
272
|
+
size?: number;
|
|
273
|
+
className?: string;
|
|
274
|
+
}) => ReactNode;
|
|
275
|
+
/** Get platform label */
|
|
276
|
+
declare function getPlatformLabel(id: ShareOption): string;
|
|
277
|
+
/** Generate CSS variable defaults from platform colors */
|
|
278
|
+
declare function generateCssVarDefaults(): Record<string, string>;
|
|
279
|
+
|
|
280
|
+
export { type PlatformConfig as A, type PlatformColor as B, CSS_VARS_UI as C, type PreviewType as P, type ShareSheetContentProps as S, type UseShareSheetReturn as U, type ShareSheetDrawerProps as a, type ShareSheetContentClassNames as b, type ShareSheetDrawerClassNames as c, type ShareMenuContentProps as d, type ShareMenuDrawerProps as e, type ShareMenuContentClassNames as f, type ShareMenuDrawerClassNames as g, type ShareOption as h, type ShareButtonConfig as i, type UseShareMenuReturn as j, type PreviewConfig as k, CSS_VAR_UI_DEFAULTS as l, CSS_VARS as m, CSS_VAR_DEFAULTS as n, PLATFORMS as o, PLATFORM_IDS as p, PLATFORM_COLORS as q, PLATFORM_ICONS as r, PLATFORM_LABELS as s, PLATFORM_CSS_VARS as t, getPlatform as u, getAllPlatforms as v, getPlatformColor as w, getPlatformIcon as x, getPlatformLabel as y, generateCssVarDefaults as z };
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-sharesheet",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A beautiful share sheet component for React with social media integrations",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/gwendall/react-sharesheet#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/gwendall/react-sharesheet/issues"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./content": {
|
|
23
|
+
"types": "./dist/content.d.ts",
|
|
24
|
+
"import": "./dist/content.mjs",
|
|
25
|
+
"require": "./dist/content.js"
|
|
26
|
+
},
|
|
27
|
+
"./drawer": {
|
|
28
|
+
"types": "./dist/drawer.d.ts",
|
|
29
|
+
"import": "./dist/drawer.mjs",
|
|
30
|
+
"require": "./dist/drawer.js"
|
|
31
|
+
},
|
|
32
|
+
"./headless": {
|
|
33
|
+
"types": "./dist/headless.d.ts",
|
|
34
|
+
"import": "./dist/headless.mjs",
|
|
35
|
+
"require": "./dist/headless.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"dev": "tsup --watch",
|
|
41
|
+
"prepack": "npm run clean && npm run build",
|
|
42
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
43
|
+
"publish-patch": "npm version patch && npm publish",
|
|
44
|
+
"publish-minor": "npm version minor && npm publish",
|
|
45
|
+
"publish-major": "npm version major && npm publish",
|
|
46
|
+
"release": "npm publish",
|
|
47
|
+
"type-check": "tsc --noEmit",
|
|
48
|
+
"clean": "rm -rf dist"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/gwendall/react-sharesheet.git"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"share",
|
|
56
|
+
"sharesheet",
|
|
57
|
+
"menu",
|
|
58
|
+
"social",
|
|
59
|
+
"react",
|
|
60
|
+
"drawer",
|
|
61
|
+
"vaul",
|
|
62
|
+
"tailwind"
|
|
63
|
+
],
|
|
64
|
+
"author": "Gwendall",
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"react": ">=18.0.0",
|
|
68
|
+
"react-dom": ">=18.0.0"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"clsx": "^2.1.0",
|
|
72
|
+
"lucide-react": "^0.400.0",
|
|
73
|
+
"react-icons": "^5.0.0",
|
|
74
|
+
"tailwind-merge": "^2.2.0",
|
|
75
|
+
"vaul": "^1.0.0"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/react": "^18.2.0",
|
|
79
|
+
"@types/react-dom": "^18.2.0",
|
|
80
|
+
"tsup": "^8.0.1",
|
|
81
|
+
"typescript": "^5.3.3"
|
|
82
|
+
},
|
|
83
|
+
"files": [
|
|
84
|
+
"dist",
|
|
85
|
+
"src",
|
|
86
|
+
"README.md"
|
|
87
|
+
]
|
|
88
|
+
}
|