@xyo-network/react-share 3.0.22 → 3.0.23

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.
@@ -143,24 +143,28 @@ import React7, { useCallback, useMemo, useState as useState3 } from "react";
143
143
 
144
144
  // src/out/CopyIconButton.tsx
145
145
  import { CopyAllRounded } from "@mui/icons-material";
146
- import { IconButton, Tooltip } from "@mui/material";
146
+ import { CircularProgress, IconButton, Tooltip } from "@mui/material";
147
147
  import { forget } from "@xylabs/forget";
148
148
  import React6, { useState as useState2 } from "react";
149
- var CopyLink = "Copy Link";
150
- var Copied = "Copied!";
151
- var CopyIconButton = /* @__PURE__ */ __name(({ onCopyToClipboard, shareLinkName, shareUrl, ...props }) => {
149
+ var CopyIconButton = /* @__PURE__ */ __name(({ copyLinkText, copiedLinkText, onClickError, shareLinkName, shareUrl, uploadPayloads, ...props }) => {
150
+ const CopyLink = copyLinkText ?? "Copy Link";
151
+ const Copied = copiedLinkText ?? "Copied!";
152
152
  const [copyTooltipTitle, setCopyToolTipTitle] = useState2(CopyLink);
153
+ const [loading, setLoading] = useState2(false);
153
154
  const copyToClipboard = /* @__PURE__ */ __name(async (link) => {
154
155
  if (link) {
155
156
  try {
157
+ setLoading(true);
158
+ await uploadPayloads?.();
156
159
  await navigator.clipboard.writeText(link);
157
- onCopyToClipboard?.();
158
160
  setCopyToolTipTitle(Copied);
159
161
  setTimeout(() => setCopyToolTipTitle(CopyLink), 2e3);
162
+ setLoading(false);
160
163
  } catch (e) {
164
+ setLoading(false);
161
165
  const message = "Error copying shareUrl to clipboard";
162
166
  console.error(message, e, link);
163
- onCopyToClipboard?.(new Error(message));
167
+ onClickError?.(new Error(message));
164
168
  }
165
169
  } else {
166
170
  console.warn("tried to copy shareUrl before it was generated");
@@ -168,7 +172,9 @@ var CopyIconButton = /* @__PURE__ */ __name(({ onCopyToClipboard, shareLinkName,
168
172
  }, "copyToClipboard");
169
173
  return /* @__PURE__ */ React6.createElement(Tooltip, {
170
174
  title: copyTooltipTitle
171
- }, /* @__PURE__ */ React6.createElement(IconButton, {
175
+ }, loading ? /* @__PURE__ */ React6.createElement(IconButton, null, /* @__PURE__ */ React6.createElement(CircularProgress, {
176
+ size: "24px"
177
+ })) : /* @__PURE__ */ React6.createElement(IconButton, {
172
178
  "aria-label": `copy ${shareLinkName} link`,
173
179
  onClick: /* @__PURE__ */ __name(() => forget(copyToClipboard(shareUrl)), "onClick"),
174
180
  edge: "end",
@@ -239,9 +245,9 @@ var splitAroundSubstring = /* @__PURE__ */ __name((path, substring) => {
239
245
  }, "splitAroundSubstring");
240
246
 
241
247
  // src/out/CopyLinkStack.tsx
242
- var CopyLinkStack = /* @__PURE__ */ __name(({ addToXnsName, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, xnsStartColor, ...props }) => {
248
+ var CopyLinkStack = /* @__PURE__ */ __name(({ addToXnsName, copiedLinkText, copyLinkText, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, uploadPayloads, xnsStartColor, ...props }) => {
243
249
  const [error, setError] = useState3();
244
- const onCopyToClipboard = useCallback((error2) => {
250
+ const onClickError = useCallback((error2) => {
245
251
  setError(error2);
246
252
  }, []);
247
253
  const parsedXnsName = useMemo(() => {
@@ -287,12 +293,15 @@ var CopyLinkStack = /* @__PURE__ */ __name(({ addToXnsName, shareLinkName, share
287
293
  overflow: "auto"
288
294
  }
289
295
  }, shareUrl), /* @__PURE__ */ React7.createElement(CopyIconButton, {
290
- onCopyToClipboard,
296
+ copiedLinkText,
297
+ copyLinkText,
298
+ onClickError,
291
299
  shareLinkName,
292
300
  shareUrl,
293
301
  sx: {
294
302
  display: "inline-flex"
295
- }
303
+ },
304
+ uploadPayloads
296
305
  }), error ? /* @__PURE__ */ React7.createElement(Tooltip2, {
297
306
  title: error.message
298
307
  }, /* @__PURE__ */ React7.createElement(Cancel, {
@@ -308,7 +317,7 @@ import { InputAdornment, TextField } from "@mui/material";
308
317
  import React8, { useCallback as useCallback2, useState as useState4 } from "react";
309
318
  var CopyLinkTextField = /* @__PURE__ */ __name(({ shareLinkName, shareUrl, ...props }) => {
310
319
  const [error, setError] = useState4();
311
- const onCopyToClipboard = useCallback2((error2) => {
320
+ const onClickError = useCallback2((error2) => {
312
321
  setError(error2);
313
322
  }, []);
314
323
  return /* @__PURE__ */ React8.createElement(TextField, {
@@ -327,7 +336,7 @@ var CopyLinkTextField = /* @__PURE__ */ __name(({ shareLinkName, shareUrl, ...pr
327
336
  }, /* @__PURE__ */ React8.createElement(CopyIconButton, {
328
337
  shareLinkName,
329
338
  shareUrl,
330
- onCopyToClipboard
339
+ onClickError
331
340
  }))
332
341
  },
333
342
  value: shareUrl,
@@ -392,7 +401,7 @@ var ShareOutExplanation = /* @__PURE__ */ __name(({ toolTipTitle }) => {
392
401
  }, "ShareOutExplanation");
393
402
 
394
403
  // src/out/GenerateShareLinkButton.tsx
395
- import { Button, CircularProgress, styled as styled2 } from "@mui/material";
404
+ import { Button, CircularProgress as CircularProgress2, styled as styled2 } from "@mui/material";
396
405
  import React11 from "react";
397
406
  var GenerateShareLinkButton = /* @__PURE__ */ __name(({ children = "Generate My Share Link", loading, ...props }) => {
398
407
  return /* @__PURE__ */ React11.createElement(Button, {
@@ -403,7 +412,7 @@ var GenerateShareLinkButton = /* @__PURE__ */ __name(({ children = "Generate My
403
412
  ...props
404
413
  }, children);
405
414
  }, "GenerateShareLinkButton");
406
- var StyledCircularProgress = styled2(CircularProgress, {
415
+ var StyledCircularProgress = styled2(CircularProgress2, {
407
416
  name: "StyledCircularProgress"
408
417
  })(({ theme }) => ({
409
418
  // ensure the color of the spinner is the same as the button color
@@ -435,8 +444,25 @@ var ShareOutHeadingFlexbox = /* @__PURE__ */ __name(({ children, shareLinkName,
435
444
  import { Typography as Typography6 } from "@mui/material";
436
445
  import { ButtonEx as ButtonEx2 } from "@xylabs/react-button";
437
446
  import { FlexGrowCol as FlexGrowCol3, FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
438
- import React13 from "react";
439
- var SocialButtonsFlexbox = /* @__PURE__ */ __name(({ shareUrl, ...props }) => {
447
+ import { ErrorRender } from "@xyo-network/react-error";
448
+ import React13, { useState as useState5 } from "react";
449
+ var SocialButtonsFlexbox = /* @__PURE__ */ __name(({ shareUrl, uploadPayloads, ...props }) => {
450
+ const [error, setError] = useState5();
451
+ const [xLoading, setXLoading] = useState5(false);
452
+ const [fbLoading, setFbLoading] = useState5(false);
453
+ const handleClick = /* @__PURE__ */ __name(async (openUrl, buttonName) => {
454
+ const setLoading = buttonName === "x" ? setXLoading : setFbLoading;
455
+ try {
456
+ setLoading(true);
457
+ await uploadPayloads?.();
458
+ setLoading(false);
459
+ openUrl();
460
+ } catch (e) {
461
+ setLoading(false);
462
+ console.error("Error uploading payloads", e);
463
+ setError(e);
464
+ }
465
+ }, "handleClick");
440
466
  return /* @__PURE__ */ React13.createElement(FlexGrowCol3, {
441
467
  alignItems: "stretch",
442
468
  paddingTop: 2,
@@ -458,23 +484,30 @@ var SocialButtonsFlexbox = /* @__PURE__ */ __name(({ shareUrl, ...props }) => {
458
484
  backgroundColor: "#000",
459
485
  color: "#fff"
460
486
  },
461
- onClick: /* @__PURE__ */ __name(() => {
462
- window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`);
487
+ busy: xLoading,
488
+ onClick: /* @__PURE__ */ __name(async () => {
489
+ const openUrl = /* @__PURE__ */ __name(() => window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`), "openUrl");
490
+ await handleClick(openUrl, "x");
463
491
  }, "onClick"),
464
492
  startIcon: /* @__PURE__ */ React13.createElement(XTwitterSvgIcon, {
465
493
  width: "20px"
466
494
  })
467
495
  }, "Share on X (Twitter)"), /* @__PURE__ */ React13.createElement(ButtonEx2, {
496
+ busy: fbLoading,
468
497
  variant: "contained",
469
498
  style: {
470
499
  backgroundColor: "#4267b2",
471
500
  color: "#fff"
472
501
  },
473
- onClick: /* @__PURE__ */ __name(() => {
474
- window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`);
502
+ onClick: /* @__PURE__ */ __name(async () => {
503
+ const openUrl = /* @__PURE__ */ __name(() => window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`), "openUrl");
504
+ await handleClick(openUrl, "fb");
475
505
  }, "onClick"),
476
506
  startIcon: /* @__PURE__ */ React13.createElement(FacebookSvgIcon, null)
477
- }, "Share on Facebook")) : null));
507
+ }, "Share on Facebook")) : null), /* @__PURE__ */ React13.createElement(ErrorRender, {
508
+ error,
509
+ scope: "SocialButtonsFlexbox"
510
+ }));
478
511
  }, "SocialButtonsFlexbox");
479
512
  export {
480
513
  CopyLinkStack,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/button/ShareButton.tsx","../../src/icons/social/Facebook.tsx","../../src/icons/social/XTwitter.tsx","../../src/meta-server/dynamic-share/DynamicShareImage.tsx","../../src/meta-server/live-share/HideParentsFlexbox.tsx","../../src/out/CopyLinkStack.tsx","../../src/out/CopyIconButton.tsx","../../src/out/lib/AnimatedGradientTypography.tsx","../../src/out/lib/splitAroundSubstring.ts","../../src/out/CopyLinkTextField.tsx","../../src/out/Dialog.tsx","../../src/out/Explanation.tsx","../../src/out/GenerateShareLinkButton.tsx","../../src/out/HeadingFlexbox.tsx","../../src/out/SocialButtonsFlexbox.tsx"],"sourcesContent":["import {\n Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon,\n} from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport type { ButtonExProps } from '@xylabs/react-button'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport React, { useRef, useState } from 'react'\n\nexport interface ShareButtonProps extends ButtonExProps {\n prepared?: boolean\n shareLink?: string\n}\n\nexport const ShareButton: React.FC<ShareButtonProps> = ({\n prepared = true, shareLink, ...props\n}) => {\n const [expanded, setExpanded] = useState(false)\n const anchorRef = useRef(null)\n const link = shareLink ?? window.location.href\n\n return (\n <FlexRow gap={1} ref={anchorRef}>\n <ButtonEx\n variant=\"text\"\n minWidth={32}\n size=\"small\"\n disabled={!prepared}\n onClick={() => {\n setExpanded(true)\n }}\n {...props}\n >\n <ShareIcon htmlColor=\"gray\" fontSize=\"small\" />\n </ButtonEx>\n <Popover open={prepared ? expanded : false} anchorEl={anchorRef.current} onClose={() => setExpanded(false)} transitionDuration={500}>\n <FlexRow gap={0.5} padding={0.5}>\n <LinkEx\n lineHeight={0}\n style={{ color: '#1da1f2' }}\n onClick={() => {\n window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <TwitterIcon fontSize=\"small\" />\n </LinkEx>\n <LinkEx\n lineHeight={0}\n style={{ color: '#4267b2' }}\n onClick={() => {\n window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <FacebookIcon fontSize=\"small\" />\n </LinkEx>\n </FlexRow>\n </Popover>\n </FlexRow>\n )\n}\n","/* eslint-disable @stylistic/max-len */\nimport { createSvgIcon } from '@mui/material'\nimport React from 'react'\n\nexport const FacebookSvgIcon = createSvgIcon(\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"800\" width=\"1200\" viewBox=\"-204.79995 -341.33325 1774.9329 2047.9995\">\n <path d=\"M1365.333 682.667C1365.333 305.64 1059.693 0 682.667 0 305.64 0 0 305.64 0 682.667c0 340.738 249.641 623.16 576 674.373V880H402.667V682.667H576v-150.4c0-171.094 101.917-265.6 257.853-265.6 74.69 0 152.814 13.333 152.814 13.333v168h-86.083c-84.804 0-111.25 52.623-111.25 106.61v128.057h189.333L948.4 880H789.333v477.04c326.359-51.213 576-333.635 576-674.373\" fill=\"#1877f2\" />\n <path d=\"M948.4 880l30.267-197.333H789.333V554.609C789.333 500.623 815.78 448 900.584 448h86.083V280s-78.124-13.333-152.814-13.333c-155.936 0-257.853 94.506-257.853 265.6v150.4H402.667V880H576v477.04a687.805 687.805 0 00106.667 8.293c36.288 0 71.91-2.84 106.666-8.293V880H948.4\" fill=\"#fff\" />\n </svg>\n , 'Facebook',\n)\n","/* eslint-disable @stylistic/max-len */\nimport { createSvgIcon } from '@mui/material'\nimport React from 'react'\n\nexport const XTwitterSvgIcon = createSvgIcon(\n <svg viewBox=\"0 0 1200 1227\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z\" fill=\"white\" />\n </svg>\n , 'XTwitterSvgIcon',\n)\n","import React from 'react'\nimport { Helmet } from 'react-helmet'\n\n/**\n * The props for the DynamicShareImage component.\n */\nexport interface DynamicShareImageProps {\n /**\n * The URL of the share image for the page.\n */\n image: string\n}\n\n/**\n * Used in conjunction with the XY Meta Server to dynamically set the share image for a page.\n */\nexport const DynamicShareImage: React.FC<DynamicShareImageProps> = ({ image }) => {\n return (\n <Helmet>\n <meta property=\"xyo:og:image\" content={image} />\n </Helmet>\n )\n}\n","import type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect } from 'react'\n\nexport const HideParentsFlexbox: React.FC<WithChildren & FlexBoxProps> = ({ children, ...props }) => {\n useEffect(() => {\n const style = document.createElement('style')\n document.head.append(style)\n style.innerHTML = `\n /** make all elements hidden */\n * {\n visibility: hidden;\n }\n\n /** move the preview area to the top of the page */\n #preview-area {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n z-index: 9999;\n }\n\n /** make the preview area and all its children visible */\n #preview-area * {\n visibility: visible;\n }`\n\n return () => {\n style.remove()\n }\n }, [])\n\n return (\n <FlexGrowRow alignItems=\"stretch\" id=\"preview-area\" justifyContent=\"start\" {...props}>\n {children}\n </FlexGrowRow>\n )\n}\n","import { Cancel } from '@mui/icons-material'\nimport type { StackProps } from '@mui/material'\nimport {\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport React, {\n useCallback, useMemo, useState,\n} from 'react'\n\nimport { CopyIconButton } from './CopyIconButton.tsx'\nimport {\n AnimatedGradientTypography, type ShareLinkProps, splitAroundSubstring,\n} from './lib/index.ts'\n\nexport interface CopyLinkStackProps extends ShareLinkProps, StackProps {\n addToXnsName?: boolean\n xnsEndColor?: string\n xnsStartColor?: string\n}\n\nexport const CopyLinkStack: React.FC<CopyLinkStackProps> = ({\n addToXnsName, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, xnsStartColor, ...props\n}) => {\n const [error, setError] = useState<Error>()\n\n const onCopyToClipboard = useCallback((error?: Error) => {\n setError(error)\n }, [])\n\n const parsedXnsName = useMemo(() => {\n if (shareUrl && xnsNameProp && addToXnsName) {\n try {\n const parts = splitAroundSubstring(shareUrl, xnsNameProp)\n return parts\n } catch (e) {\n setError(e as Error)\n }\n }\n }, [])\n\n const [part1, xnsName, part3] = parsedXnsName || []\n\n return (\n <Stack direction=\"row\" alignItems=\"center\" gap={0.25} {...props}>\n {xnsName && addToXnsName\n ? (\n <Stack direction=\"row\" maxWidth=\"100%\" sx={{ overflowX: 'auto' }}>\n <Typography sx={{ display: 'inline-flex' }}>{part1}</Typography>\n <AnimatedGradientTypography color1={xnsStartColor} color2={xnsEndColor} sx={{ display: 'inline-flex' }}>{xnsName}</AnimatedGradientTypography>\n <Typography sx={{ display: 'inline-flex' }}>{part3}</Typography>\n </Stack>\n )\n : (\n <Typography sx={{\n display: 'inline-flex', maxWidth: '100%', overflow: 'auto',\n }}\n >\n {shareUrl}\n </Typography>\n )}\n <CopyIconButton onCopyToClipboard={onCopyToClipboard} shareLinkName={shareLinkName} shareUrl={shareUrl} sx={{ display: 'inline-flex' }} />\n {error ? <Tooltip title={error.message}><Cancel color=\"error\" sx={{ display: 'inline-flex' }} /></Tooltip> : null}\n </Stack>\n )\n}\n","import { CopyAllRounded } from '@mui/icons-material'\nimport {\n type ButtonProps, IconButton, Tooltip,\n} from '@mui/material'\nimport { forget } from '@xylabs/forget'\nimport React, { useState } from 'react'\n\nimport type { ShareLinkProps } from './lib/index.ts'\n\nexport interface CopyIconButtonProps extends ButtonProps, ShareLinkProps {\n onCopyToClipboard?: (error?: Error) => void\n}\n\nconst CopyLink = 'Copy Link'\nconst Copied = 'Copied!'\n\nexport const CopyIconButton: React.FC<CopyIconButtonProps> = ({\n onCopyToClipboard, shareLinkName, shareUrl, ...props\n}) => {\n const [copyTooltipTitle, setCopyToolTipTitle] = useState(CopyLink)\n\n const copyToClipboard = async (link?: string) => {\n if (link) {\n try {\n await navigator.clipboard.writeText(link)\n onCopyToClipboard?.()\n setCopyToolTipTitle(Copied)\n setTimeout(() => setCopyToolTipTitle(CopyLink), 2000)\n } catch (e) {\n const message = 'Error copying shareUrl to clipboard'\n console.error(message, e, link)\n onCopyToClipboard?.(new Error(message))\n }\n } else {\n console.warn('tried to copy shareUrl before it was generated')\n }\n }\n\n return (\n <Tooltip title={copyTooltipTitle}>\n <IconButton aria-label={`copy ${shareLinkName} link`} onClick={() => forget(copyToClipboard(shareUrl))} edge=\"end\" {...props}>\n <CopyAllRounded />\n </IconButton>\n </Tooltip>\n )\n}\n","import {\n keyframes, styled, Typography,\n} from '@mui/material'\n\n/**\n * Start the animation at 100% to give the gradient a left to right effect\n */\nconst moveBg = keyframes(`\n 0% {\n background-position: 100% 0%;\n }\n 100% {\n background-position: 0% 0%;\n }\n`)\n\n/**\n * Adapted from - https://codepen.io/web-dot-dev/pen/vYrGPNE\n */\nexport const AnimatedGradientTypography = styled(Typography, { name: 'AnimatedGradientTypography' })<{ color1?: string; color2?: string }>(({\n theme, color1, color2,\n}) => {\n return {\n // Set the color variables for the gradient\n '--color-one': color1 ?? theme.palette.secondary.dark,\n '--color-two': color2 ?? theme.palette.primary.light,\n // set the gradient so it has the same start and end color for looping effect\n 'background': `linear-gradient(\n .25turn,\n var(--color-one),\n var(--color-two),\n var(--color-one)\n )`,\n // Set the text color to transparent so the gradient shows through\n 'color': 'transparent',\n // Clip the background to the text shape\n 'backgroundClip': 'text',\n // Set the background size to 800% so we don't see the third color initially creating the looping effect\n 'backgroundSize': '800%',\n // Set the text to bold so the gradient is more visible\n 'fontWeight': 'bold',\n // Set the animation\n '@media (prefers-reduced-motion: no-preference)': {\n animationName: moveBg,\n animationDuration: '2s',\n animationIterationCount: 'infinite',\n },\n // reset for users that prefer reduced motion\n '@media (prefers-reduced-motion)': {\n background: 'none',\n color: theme.palette.text.primary,\n },\n }\n})\n","export const splitAroundSubstring = (path: string, substring: string): [string, string, string] => {\n // Find the index of the substring\n const index = path.indexOf(substring)\n\n if (index === -1) {\n throw new Error(`XNS name \"${substring}\" not found in path.`)\n }\n\n // Extract the part before the substring\n const part1 = path.slice(0, index)\n\n // The substring itself is part2\n const part2 = substring\n\n // Extract the part after the substring\n const part3 = path.slice(index + substring.length)\n\n return [part1, part2, part3]\n}\n","import type { StandardTextFieldProps } from '@mui/material'\nimport { InputAdornment, TextField } from '@mui/material'\nimport React, { useCallback, useState } from 'react'\n\nimport { CopyIconButton } from './CopyIconButton.tsx'\n\nexport interface CopyLinkTextFieldProps extends StandardTextFieldProps {\n shareLinkName?: string\n shareUrl?: string\n}\n\nexport const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({\n shareLinkName, shareUrl, ...props\n}) => {\n const [error, setError] = useState<Error>()\n\n const onCopyToClipboard = useCallback((error?: Error) => {\n setError(error)\n }, [])\n\n return (\n <TextField\n disabled\n error={!!error}\n helperText={error?.message}\n // to override the color that appears when it's a text field, only on dark mode\n sx={{ input: { WebkitTextFillColor: 'lightgray !important' } }}\n InputProps={{\n endAdornment: (\n <InputAdornment position=\"end\">\n <CopyIconButton shareLinkName={shareLinkName} shareUrl={shareUrl} onCopyToClipboard={onCopyToClipboard} />\n </InputAdornment>\n ),\n }}\n value={shareUrl}\n {...props}\n />\n )\n}\n","import type { DialogProps } from '@mui/material'\nimport {\n Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography,\n} from '@mui/material'\nimport { FlexCol, FlexGrowCol } from '@xylabs/react-flexbox'\nimport type { ComponentType, ReactNode } from 'react'\nimport React from 'react'\n\nexport interface ShareOutDialogProps extends DialogProps {\n ShareOutDialogActions?: ComponentType<{ onClose?: () => void }>\n cardImg?: ReactNode\n shareOutDialogContent?: ReactNode\n subtitle?: string\n title?: string\n}\n\nexport const ShareOutDialog: React.FC<ShareOutDialogProps> = ({\n ShareOutDialogActions, cardImg, open, onClose, shareOutDialogContent, subtitle, title, ...props\n}) => {\n const handleClose = () => {\n onClose?.('', 'backdropClick')\n }\n\n return (\n <Dialog onClose={onClose} open={open} {...props}>\n <DialogTitle>\n <Stack direction=\"row\" spacing={2}>\n <FlexGrowCol alignItems=\"flex-start\" width=\"60%\">\n <Typography variant=\"h5\">{title}</Typography>\n <Typography variant=\"body1\">\n {' '}\n {subtitle}\n </Typography>\n </FlexGrowCol>\n <FlexGrowCol alignItems=\"flex-end\" width=\"40%\">\n {cardImg}\n </FlexGrowCol>\n </Stack>\n </DialogTitle>\n <DialogContent>\n {shareOutDialogContent}\n <FlexCol alignItems=\"stretch\">\n </FlexCol>\n </DialogContent>\n {ShareOutDialogActions ? <DialogActions><ShareOutDialogActions onClose={handleClose} /></DialogActions> : null}\n </Dialog>\n )\n}\n","import { InfoOutlined } from '@mui/icons-material'\nimport {\n Tooltip, Typography, useTheme,\n} from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport React from 'react'\n\nexport interface ShareOutExplanationProps {\n toolTipTitle?: string\n}\n\nexport const ShareOutExplanation: React.FC<ShareOutExplanationProps> = ({ toolTipTitle }) => {\n const theme = useTheme()\n // eslint-disable-next-line @stylistic/max-len\n const title = toolTipTitle ?? 'In order for your data to be publicly viewable, it needs to be saved to the XYO Network Public Archivist. Public data can be seen by your friends, and XYO can generate preview images for easier sharing on social media.'\n return (\n <>\n <FlexGrowRow alignItems=\"center\">\n <Typography variant=\"body2\" paddingRight={0.5}>\n What am I sharing?\n </Typography>\n <Tooltip\n title={title}\n placement=\"bottom\"\n >\n <InfoOutlined fontSize=\"small\" sx={{ fontSize: theme.typography.caption.fontSize }} />\n </Tooltip>\n </FlexGrowRow>\n </>\n )\n}\n","import type { ButtonProps } from '@mui/material'\nimport {\n Button, CircularProgress, styled,\n} from '@mui/material'\nimport React from 'react'\n\nexport interface GenerateShareLinkButtonProps extends ButtonProps {\n loading?: boolean\n}\n\nexport const GenerateShareLinkButton: React.FC<GenerateShareLinkButtonProps> = ({\n children = 'Generate My Share Link', loading, ...props\n}) => {\n return (\n <Button\n variant=\"contained\"\n startIcon={loading ? <StyledCircularProgress size=\"small\" /> : null}\n {...props}\n >\n {children}\n </Button>\n )\n}\n\nconst StyledCircularProgress = styled(CircularProgress, { name: 'StyledCircularProgress' })(({ theme }) => ({\n // ensure the color of the spinner is the same as the button color\n color: theme.palette.getContrastText(theme.palette.primary.main),\n height: '20px',\n opacity: '.87',\n width: '20px',\n}))\n","import { Typography } from '@mui/material'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexGrowCol } from '@xylabs/react-flexbox'\nimport React from 'react'\n\nexport interface ShareOutHeadingFlexboxProps extends FlexBoxProps {\n shareLinkName?: string\n shareUrl?: string\n}\n\nexport const ShareOutHeadingFlexbox: React.FC<ShareOutHeadingFlexboxProps> = ({\n children, shareLinkName, shareUrl, ...props\n}) => {\n const GenerateShareLinkExplanation = \"When you generate your share link, we'll make a small amount of your data public so friends can check it out!\"\n\n return (\n <FlexGrowCol alignItems=\"flex-start\" paddingBottom={1} {...props}>\n <Typography variant=\"body1\" gutterBottom>\n <strong>Your Share Link</strong>\n </Typography>\n <Typography variant=\"body1\">\n {shareUrl ? `Use this link or the buttons below to share ${shareLinkName}` : GenerateShareLinkExplanation}\n </Typography>\n {children}\n </FlexGrowCol>\n )\n}\n","import { Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexGrowCol, FlexRow } from '@xylabs/react-flexbox'\nimport React from 'react'\n\nimport { FacebookSvgIcon, XTwitterSvgIcon } from '../icons/index.ts'\n\nexport interface SocialButtonsFlexboxProps extends FlexBoxProps {\n shareUrl?: string\n}\n\nexport const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({ shareUrl, ...props }) => {\n return (\n <FlexGrowCol alignItems=\"stretch\" paddingTop={2} {...props}>\n <Typography variant=\"body1\" gutterBottom>\n <strong>Share on Social Media</strong>\n </Typography>\n <FlexRow\n gap={0.5}\n sx={{ flexDirection: { md: 'row', xs: 'column' } }}\n >\n {shareUrl\n ? (\n <>\n <ButtonEx\n variant=\"contained\"\n style={{ backgroundColor: '#000', color: '#fff' }}\n onClick={() => {\n window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`)\n }}\n startIcon={<XTwitterSvgIcon width=\"20px\" />}\n >\n Share on X (Twitter)\n </ButtonEx>\n <ButtonEx\n variant=\"contained\"\n style={{ backgroundColor: '#4267b2', color: '#fff' }}\n onClick={() => {\n window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`)\n }}\n startIcon={<FacebookSvgIcon />}\n >\n Share on Facebook\n </ButtonEx>\n </>\n )\n : null}\n </FlexRow>\n </FlexGrowCol>\n )\n}\n"],"mappings":";;;;AAAA,SACEA,YAAYC,cAAcC,SAASC,WAAWC,WAAWC,mBACpD;AACP,SAASC,eAAe;AAExB,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,OAAOC,SAASC,QAAQC,gBAAgB;AAOjC,IAAMC,cAA0C,wBAAC,EACtDC,WAAW,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facebook","FacebookIcon","Share","ShareIcon","Twitter","TwitterIcon","Popover","ButtonEx","FlexRow","LinkEx","React","useRef","useState","ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","FlexRow","gap","ref","ButtonEx","variant","minWidth","size","disabled","onClick","ShareIcon","htmlColor","fontSize","Popover","open","anchorEl","current","onClose","transitionDuration","padding","LinkEx","lineHeight","style","color","encodeURIComponent","TwitterIcon","FacebookIcon","createSvgIcon","React","FacebookSvgIcon","svg","xmlns","height","width","viewBox","path","d","fill","createSvgIcon","React","XTwitterSvgIcon","svg","viewBox","fill","xmlns","path","d","React","Helmet","DynamicShareImage","image","React","Helmet","meta","property","content","FlexGrowRow","React","useEffect","HideParentsFlexbox","children","props","useEffect","style","document","createElement","head","append","innerHTML","remove","React","FlexGrowRow","alignItems","id","justifyContent","Cancel","Stack","Tooltip","Typography","React","useCallback","useMemo","useState","CopyAllRounded","IconButton","Tooltip","forget","React","useState","CopyLink","Copied","CopyIconButton","onCopyToClipboard","shareLinkName","shareUrl","props","copyTooltipTitle","setCopyToolTipTitle","useState","copyToClipboard","link","navigator","clipboard","writeText","setTimeout","e","message","console","error","Error","warn","React","Tooltip","title","IconButton","aria-label","onClick","forget","edge","CopyAllRounded","keyframes","styled","Typography","moveBg","AnimatedGradientTypography","name","theme","color1","color2","palette","secondary","dark","primary","light","animationName","animationDuration","animationIterationCount","background","color","text","splitAroundSubstring","path","substring","index","indexOf","Error","part1","slice","part2","part3","length","CopyLinkStack","addToXnsName","shareLinkName","shareUrl","xnsName","xnsNameProp","xnsEndColor","xnsStartColor","props","error","setError","useState","onCopyToClipboard","useCallback","parsedXnsName","useMemo","parts","splitAroundSubstring","e","part1","part3","React","Stack","direction","alignItems","gap","maxWidth","sx","overflowX","Typography","display","AnimatedGradientTypography","color1","color2","overflow","CopyIconButton","Tooltip","title","message","Cancel","color","InputAdornment","TextField","React","useCallback","useState","CopyLinkTextField","shareLinkName","shareUrl","props","error","setError","useState","onCopyToClipboard","useCallback","React","TextField","disabled","helperText","message","sx","input","WebkitTextFillColor","InputProps","endAdornment","InputAdornment","position","CopyIconButton","value","Dialog","DialogActions","DialogContent","DialogTitle","Stack","Typography","FlexCol","FlexGrowCol","React","ShareOutDialog","ShareOutDialogActions","cardImg","open","onClose","shareOutDialogContent","subtitle","title","props","handleClose","React","Dialog","DialogTitle","Stack","direction","spacing","FlexGrowCol","alignItems","width","Typography","variant","DialogContent","FlexCol","DialogActions","InfoOutlined","Tooltip","Typography","useTheme","FlexGrowRow","React","ShareOutExplanation","toolTipTitle","theme","useTheme","title","React","FlexGrowRow","alignItems","Typography","variant","paddingRight","Tooltip","placement","InfoOutlined","fontSize","sx","typography","caption","Button","CircularProgress","styled","React","GenerateShareLinkButton","children","loading","props","React","Button","variant","startIcon","StyledCircularProgress","size","styled","CircularProgress","name","theme","color","palette","getContrastText","primary","main","height","opacity","width","Typography","FlexGrowCol","React","ShareOutHeadingFlexbox","children","shareLinkName","shareUrl","props","GenerateShareLinkExplanation","React","FlexGrowCol","alignItems","paddingBottom","Typography","variant","gutterBottom","strong","Typography","ButtonEx","FlexGrowCol","FlexRow","React","SocialButtonsFlexbox","shareUrl","props","React","FlexGrowCol","alignItems","paddingTop","Typography","variant","gutterBottom","strong","FlexRow","gap","sx","flexDirection","md","xs","ButtonEx","style","backgroundColor","color","onClick","window","open","encodeURIComponent","startIcon","XTwitterSvgIcon","width","FacebookSvgIcon"]}
1
+ {"version":3,"sources":["../../src/button/ShareButton.tsx","../../src/icons/social/Facebook.tsx","../../src/icons/social/XTwitter.tsx","../../src/meta-server/dynamic-share/DynamicShareImage.tsx","../../src/meta-server/live-share/HideParentsFlexbox.tsx","../../src/out/CopyLinkStack.tsx","../../src/out/CopyIconButton.tsx","../../src/out/lib/AnimatedGradientTypography.tsx","../../src/out/lib/splitAroundSubstring.ts","../../src/out/CopyLinkTextField.tsx","../../src/out/Dialog.tsx","../../src/out/Explanation.tsx","../../src/out/GenerateShareLinkButton.tsx","../../src/out/HeadingFlexbox.tsx","../../src/out/SocialButtonsFlexbox.tsx"],"sourcesContent":["import {\n Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon,\n} from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport type { ButtonExProps } from '@xylabs/react-button'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport React, { useRef, useState } from 'react'\n\nexport interface ShareButtonProps extends ButtonExProps {\n prepared?: boolean\n shareLink?: string\n}\n\nexport const ShareButton: React.FC<ShareButtonProps> = ({\n prepared = true, shareLink, ...props\n}) => {\n const [expanded, setExpanded] = useState(false)\n const anchorRef = useRef(null)\n const link = shareLink ?? window.location.href\n\n return (\n <FlexRow gap={1} ref={anchorRef}>\n <ButtonEx\n variant=\"text\"\n minWidth={32}\n size=\"small\"\n disabled={!prepared}\n onClick={() => {\n setExpanded(true)\n }}\n {...props}\n >\n <ShareIcon htmlColor=\"gray\" fontSize=\"small\" />\n </ButtonEx>\n <Popover open={prepared ? expanded : false} anchorEl={anchorRef.current} onClose={() => setExpanded(false)} transitionDuration={500}>\n <FlexRow gap={0.5} padding={0.5}>\n <LinkEx\n lineHeight={0}\n style={{ color: '#1da1f2' }}\n onClick={() => {\n window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <TwitterIcon fontSize=\"small\" />\n </LinkEx>\n <LinkEx\n lineHeight={0}\n style={{ color: '#4267b2' }}\n onClick={() => {\n window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <FacebookIcon fontSize=\"small\" />\n </LinkEx>\n </FlexRow>\n </Popover>\n </FlexRow>\n )\n}\n","/* eslint-disable @stylistic/max-len */\nimport { createSvgIcon } from '@mui/material'\nimport React from 'react'\n\nexport const FacebookSvgIcon = createSvgIcon(\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"800\" width=\"1200\" viewBox=\"-204.79995 -341.33325 1774.9329 2047.9995\">\n <path d=\"M1365.333 682.667C1365.333 305.64 1059.693 0 682.667 0 305.64 0 0 305.64 0 682.667c0 340.738 249.641 623.16 576 674.373V880H402.667V682.667H576v-150.4c0-171.094 101.917-265.6 257.853-265.6 74.69 0 152.814 13.333 152.814 13.333v168h-86.083c-84.804 0-111.25 52.623-111.25 106.61v128.057h189.333L948.4 880H789.333v477.04c326.359-51.213 576-333.635 576-674.373\" fill=\"#1877f2\" />\n <path d=\"M948.4 880l30.267-197.333H789.333V554.609C789.333 500.623 815.78 448 900.584 448h86.083V280s-78.124-13.333-152.814-13.333c-155.936 0-257.853 94.506-257.853 265.6v150.4H402.667V880H576v477.04a687.805 687.805 0 00106.667 8.293c36.288 0 71.91-2.84 106.666-8.293V880H948.4\" fill=\"#fff\" />\n </svg>\n , 'Facebook',\n)\n","/* eslint-disable @stylistic/max-len */\nimport { createSvgIcon } from '@mui/material'\nimport React from 'react'\n\nexport const XTwitterSvgIcon = createSvgIcon(\n <svg viewBox=\"0 0 1200 1227\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z\" fill=\"white\" />\n </svg>\n , 'XTwitterSvgIcon',\n)\n","import React from 'react'\nimport { Helmet } from 'react-helmet'\n\n/**\n * The props for the DynamicShareImage component.\n */\nexport interface DynamicShareImageProps {\n /**\n * The URL of the share image for the page.\n */\n image: string\n}\n\n/**\n * Used in conjunction with the XY Meta Server to dynamically set the share image for a page.\n */\nexport const DynamicShareImage: React.FC<DynamicShareImageProps> = ({ image }) => {\n return (\n <Helmet>\n <meta property=\"xyo:og:image\" content={image} />\n </Helmet>\n )\n}\n","import type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect } from 'react'\n\nexport const HideParentsFlexbox: React.FC<WithChildren & FlexBoxProps> = ({ children, ...props }) => {\n useEffect(() => {\n const style = document.createElement('style')\n document.head.append(style)\n style.innerHTML = `\n /** make all elements hidden */\n * {\n visibility: hidden;\n }\n\n /** move the preview area to the top of the page */\n #preview-area {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n z-index: 9999;\n }\n\n /** make the preview area and all its children visible */\n #preview-area * {\n visibility: visible;\n }`\n\n return () => {\n style.remove()\n }\n }, [])\n\n return (\n <FlexGrowRow alignItems=\"stretch\" id=\"preview-area\" justifyContent=\"start\" {...props}>\n {children}\n </FlexGrowRow>\n )\n}\n","import { Cancel } from '@mui/icons-material'\nimport type { StackProps } from '@mui/material'\nimport {\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport React, {\n useCallback, useMemo, useState,\n} from 'react'\n\nimport { CopyIconButton } from './CopyIconButton.tsx'\nimport {\n AnimatedGradientTypography, type ShareLinkProps, splitAroundSubstring,\n} from './lib/index.ts'\n\nexport interface CopyLinkStackProps extends ShareLinkProps, StackProps {\n addToXnsName?: boolean\n copiedLinkText?: string\n copyLinkText?: string\n xnsEndColor?: string\n xnsStartColor?: string\n}\n\nexport const CopyLinkStack: React.FC<CopyLinkStackProps> = ({\n addToXnsName, copiedLinkText, copyLinkText, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, uploadPayloads, xnsStartColor, ...props\n}) => {\n const [error, setError] = useState<Error>()\n\n const onClickError = useCallback((error: Error) => {\n setError(error)\n }, [])\n\n const parsedXnsName = useMemo(() => {\n if (shareUrl && xnsNameProp && addToXnsName) {\n try {\n const parts = splitAroundSubstring(shareUrl, xnsNameProp)\n return parts\n } catch (e) {\n setError(e as Error)\n }\n }\n }, [])\n\n const [part1, xnsName, part3] = parsedXnsName || []\n\n return (\n <Stack direction=\"row\" alignItems=\"center\" gap={0.25} {...props}>\n {xnsName && addToXnsName\n ? (\n <Stack direction=\"row\" maxWidth=\"100%\" sx={{ overflowX: 'auto' }}>\n <Typography sx={{ display: 'inline-flex' }}>{part1}</Typography>\n <AnimatedGradientTypography color1={xnsStartColor} color2={xnsEndColor} sx={{ display: 'inline-flex' }}>{xnsName}</AnimatedGradientTypography>\n <Typography sx={{ display: 'inline-flex' }}>{part3}</Typography>\n </Stack>\n )\n : (\n <Typography sx={{\n display: 'inline-flex', maxWidth: '100%', overflow: 'auto',\n }}\n >\n {shareUrl}\n </Typography>\n )}\n <CopyIconButton\n copiedLinkText={copiedLinkText}\n copyLinkText={copyLinkText}\n onClickError={onClickError}\n shareLinkName={shareLinkName}\n shareUrl={shareUrl}\n sx={{ display: 'inline-flex' }}\n uploadPayloads={uploadPayloads}\n />\n {error ? <Tooltip title={error.message}><Cancel color=\"error\" sx={{ display: 'inline-flex' }} /></Tooltip> : null}\n </Stack>\n )\n}\n","import { CopyAllRounded } from '@mui/icons-material'\nimport {\n type ButtonProps, CircularProgress, IconButton, Tooltip,\n} from '@mui/material'\nimport { forget } from '@xylabs/forget'\nimport React, { useState } from 'react'\n\nimport type { ShareLinkProps } from './lib/index.ts'\n\nexport interface CopyIconButtonProps extends ButtonProps, ShareLinkProps {\n onClickError?: (error: Error) => void\n}\n\nexport const CopyIconButton: React.FC<CopyIconButtonProps> = ({\n copyLinkText, copiedLinkText, onClickError, shareLinkName, shareUrl, uploadPayloads, ...props\n}) => {\n const CopyLink = copyLinkText ?? 'Copy Link'\n const Copied = copiedLinkText ?? 'Copied!'\n\n const [copyTooltipTitle, setCopyToolTipTitle] = useState(CopyLink)\n const [loading, setLoading] = useState(false)\n\n const copyToClipboard = async (link?: string) => {\n if (link) {\n try {\n setLoading(true)\n await uploadPayloads?.()\n await navigator.clipboard.writeText(link)\n setCopyToolTipTitle(Copied)\n setTimeout(() => setCopyToolTipTitle(CopyLink), 2000)\n setLoading(false)\n } catch (e) {\n setLoading(false)\n const message = 'Error copying shareUrl to clipboard'\n console.error(message, e, link)\n onClickError?.(new Error(message))\n }\n } else {\n console.warn('tried to copy shareUrl before it was generated')\n }\n }\n\n return (\n <Tooltip title={copyTooltipTitle}>\n {loading\n ? (\n <IconButton>\n <CircularProgress size=\"24px\" />\n </IconButton>\n )\n : (\n <IconButton aria-label={`copy ${shareLinkName} link`} onClick={() => forget(copyToClipboard(shareUrl))} edge=\"end\" {...props}>\n <CopyAllRounded />\n </IconButton>\n )}\n </Tooltip>\n )\n}\n","import {\n keyframes, styled, Typography,\n} from '@mui/material'\n\n/**\n * Start the animation at 100% to give the gradient a left to right effect\n */\nconst moveBg = keyframes(`\n 0% {\n background-position: 100% 0%;\n }\n 100% {\n background-position: 0% 0%;\n }\n`)\n\n/**\n * Adapted from - https://codepen.io/web-dot-dev/pen/vYrGPNE\n */\nexport const AnimatedGradientTypography = styled(Typography, { name: 'AnimatedGradientTypography' })<{ color1?: string; color2?: string }>(({\n theme, color1, color2,\n}) => {\n return {\n // Set the color variables for the gradient\n '--color-one': color1 ?? theme.palette.secondary.dark,\n '--color-two': color2 ?? theme.palette.primary.light,\n // set the gradient so it has the same start and end color for looping effect\n 'background': `linear-gradient(\n .25turn,\n var(--color-one),\n var(--color-two),\n var(--color-one)\n )`,\n // Set the text color to transparent so the gradient shows through\n 'color': 'transparent',\n // Clip the background to the text shape\n 'backgroundClip': 'text',\n // Set the background size to 800% so we don't see the third color initially creating the looping effect\n 'backgroundSize': '800%',\n // Set the text to bold so the gradient is more visible\n 'fontWeight': 'bold',\n // Set the animation\n '@media (prefers-reduced-motion: no-preference)': {\n animationName: moveBg,\n animationDuration: '2s',\n animationIterationCount: 'infinite',\n },\n // reset for users that prefer reduced motion\n '@media (prefers-reduced-motion)': {\n background: 'none',\n color: theme.palette.text.primary,\n },\n }\n})\n","export const splitAroundSubstring = (path: string, substring: string): [string, string, string] => {\n // Find the index of the substring\n const index = path.indexOf(substring)\n\n if (index === -1) {\n throw new Error(`XNS name \"${substring}\" not found in path.`)\n }\n\n // Extract the part before the substring\n const part1 = path.slice(0, index)\n\n // The substring itself is part2\n const part2 = substring\n\n // Extract the part after the substring\n const part3 = path.slice(index + substring.length)\n\n return [part1, part2, part3]\n}\n","import type { StandardTextFieldProps } from '@mui/material'\nimport { InputAdornment, TextField } from '@mui/material'\nimport React, { useCallback, useState } from 'react'\n\nimport { CopyIconButton } from './CopyIconButton.tsx'\n\nexport interface CopyLinkTextFieldProps extends StandardTextFieldProps {\n shareLinkName?: string\n shareUrl?: string\n}\n\nexport const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({\n shareLinkName, shareUrl, ...props\n}) => {\n const [error, setError] = useState<Error>()\n\n const onClickError = useCallback((error?: Error) => {\n setError(error)\n }, [])\n\n return (\n <TextField\n disabled\n error={!!error}\n helperText={error?.message}\n // to override the color that appears when it's a text field, only on dark mode\n sx={{ input: { WebkitTextFillColor: 'lightgray !important' } }}\n InputProps={{\n endAdornment: (\n <InputAdornment position=\"end\">\n <CopyIconButton shareLinkName={shareLinkName} shareUrl={shareUrl} onClickError={onClickError} />\n </InputAdornment>\n ),\n }}\n value={shareUrl}\n {...props}\n />\n )\n}\n","import type { DialogProps } from '@mui/material'\nimport {\n Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography,\n} from '@mui/material'\nimport { FlexCol, FlexGrowCol } from '@xylabs/react-flexbox'\nimport type { ComponentType, ReactNode } from 'react'\nimport React from 'react'\n\nexport interface ShareOutDialogProps extends DialogProps {\n ShareOutDialogActions?: ComponentType<{ onClose?: () => void }>\n cardImg?: ReactNode\n shareOutDialogContent?: ReactNode\n subtitle?: string\n title?: string\n}\n\nexport const ShareOutDialog: React.FC<ShareOutDialogProps> = ({\n ShareOutDialogActions, cardImg, open, onClose, shareOutDialogContent, subtitle, title, ...props\n}) => {\n const handleClose = () => {\n onClose?.('', 'backdropClick')\n }\n\n return (\n <Dialog onClose={onClose} open={open} {...props}>\n <DialogTitle>\n <Stack direction=\"row\" spacing={2}>\n <FlexGrowCol alignItems=\"flex-start\" width=\"60%\">\n <Typography variant=\"h5\">{title}</Typography>\n <Typography variant=\"body1\">\n {' '}\n {subtitle}\n </Typography>\n </FlexGrowCol>\n <FlexGrowCol alignItems=\"flex-end\" width=\"40%\">\n {cardImg}\n </FlexGrowCol>\n </Stack>\n </DialogTitle>\n <DialogContent>\n {shareOutDialogContent}\n <FlexCol alignItems=\"stretch\">\n </FlexCol>\n </DialogContent>\n {ShareOutDialogActions ? <DialogActions><ShareOutDialogActions onClose={handleClose} /></DialogActions> : null}\n </Dialog>\n )\n}\n","import { InfoOutlined } from '@mui/icons-material'\nimport {\n Tooltip, Typography, useTheme,\n} from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport React from 'react'\n\nexport interface ShareOutExplanationProps {\n toolTipTitle?: string\n}\n\nexport const ShareOutExplanation: React.FC<ShareOutExplanationProps> = ({ toolTipTitle }) => {\n const theme = useTheme()\n // eslint-disable-next-line @stylistic/max-len\n const title = toolTipTitle ?? 'In order for your data to be publicly viewable, it needs to be saved to the XYO Network Public Archivist. Public data can be seen by your friends, and XYO can generate preview images for easier sharing on social media.'\n return (\n <>\n <FlexGrowRow alignItems=\"center\">\n <Typography variant=\"body2\" paddingRight={0.5}>\n What am I sharing?\n </Typography>\n <Tooltip\n title={title}\n placement=\"bottom\"\n >\n <InfoOutlined fontSize=\"small\" sx={{ fontSize: theme.typography.caption.fontSize }} />\n </Tooltip>\n </FlexGrowRow>\n </>\n )\n}\n","import type { ButtonProps } from '@mui/material'\nimport {\n Button, CircularProgress, styled,\n} from '@mui/material'\nimport React from 'react'\n\nexport interface GenerateShareLinkButtonProps extends ButtonProps {\n loading?: boolean\n}\n\nexport const GenerateShareLinkButton: React.FC<GenerateShareLinkButtonProps> = ({\n children = 'Generate My Share Link', loading, ...props\n}) => {\n return (\n <Button\n variant=\"contained\"\n startIcon={loading ? <StyledCircularProgress size=\"small\" /> : null}\n {...props}\n >\n {children}\n </Button>\n )\n}\n\nconst StyledCircularProgress = styled(CircularProgress, { name: 'StyledCircularProgress' })(({ theme }) => ({\n // ensure the color of the spinner is the same as the button color\n color: theme.palette.getContrastText(theme.palette.primary.main),\n height: '20px',\n opacity: '.87',\n width: '20px',\n}))\n","import { Typography } from '@mui/material'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexGrowCol } from '@xylabs/react-flexbox'\nimport React from 'react'\n\nexport interface ShareOutHeadingFlexboxProps extends FlexBoxProps {\n shareLinkName?: string\n shareUrl?: string\n}\n\nexport const ShareOutHeadingFlexbox: React.FC<ShareOutHeadingFlexboxProps> = ({\n children, shareLinkName, shareUrl, ...props\n}) => {\n const GenerateShareLinkExplanation = \"When you generate your share link, we'll make a small amount of your data public so friends can check it out!\"\n\n return (\n <FlexGrowCol alignItems=\"flex-start\" paddingBottom={1} {...props}>\n <Typography variant=\"body1\" gutterBottom>\n <strong>Your Share Link</strong>\n </Typography>\n <Typography variant=\"body1\">\n {shareUrl ? `Use this link or the buttons below to share ${shareLinkName}` : GenerateShareLinkExplanation}\n </Typography>\n {children}\n </FlexGrowCol>\n )\n}\n","import { Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexGrowCol, FlexRow } from '@xylabs/react-flexbox'\nimport { ErrorRender } from '@xyo-network/react-error'\nimport React, { useState } from 'react'\n\nimport { FacebookSvgIcon, XTwitterSvgIcon } from '../icons/index.ts'\n\nexport interface SocialButtonsFlexboxProps extends FlexBoxProps {\n shareUrl?: string\n uploadPayloads?: () => Promise<void>\n}\n\nexport const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({\n shareUrl, uploadPayloads, ...props\n}) => {\n const [error, setError] = useState<Error>()\n const [xLoading, setXLoading] = useState(false)\n const [fbLoading, setFbLoading] = useState(false)\n\n const handleClick = async (openUrl: () => void, buttonName: 'x' | 'fb') => {\n const setLoading = buttonName === 'x' ? setXLoading : setFbLoading\n try {\n setLoading(true)\n await uploadPayloads?.()\n setLoading(false)\n openUrl()\n } catch (e) {\n setLoading(false)\n console.error('Error uploading payloads', e)\n setError(e as Error)\n }\n }\n\n return (\n <FlexGrowCol alignItems=\"stretch\" paddingTop={2} {...props}>\n <Typography variant=\"body1\" gutterBottom>\n <strong>Share on Social Media</strong>\n </Typography>\n <FlexRow\n gap={0.5}\n sx={{ flexDirection: { md: 'row', xs: 'column' } }}\n >\n {shareUrl\n ? (\n <>\n <ButtonEx\n variant=\"contained\"\n style={{ backgroundColor: '#000', color: '#fff' }}\n busy={xLoading}\n onClick={async () => {\n const openUrl = () => window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`)\n await handleClick(openUrl, 'x')\n }}\n startIcon={<XTwitterSvgIcon width=\"20px\" />}\n >\n Share on X (Twitter)\n </ButtonEx>\n <ButtonEx\n busy={fbLoading}\n variant=\"contained\"\n style={{ backgroundColor: '#4267b2', color: '#fff' }}\n onClick={async () => {\n const openUrl = () => window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`)\n await handleClick(openUrl, 'fb')\n }}\n startIcon={<FacebookSvgIcon />}\n >\n Share on Facebook\n </ButtonEx>\n </>\n )\n : null}\n </FlexRow>\n <ErrorRender error={error} scope=\"SocialButtonsFlexbox\" />\n </FlexGrowCol>\n )\n}\n"],"mappings":";;;;AAAA,SACEA,YAAYC,cAAcC,SAASC,WAAWC,WAAWC,mBACpD;AACP,SAASC,eAAe;AAExB,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,OAAOC,SAASC,QAAQC,gBAAgB;AAOjC,IAAMC,cAA0C,wBAAC,EACtDC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAChC;AACC,QAAM,CAACC,UAAUC,WAAAA,IAAeC,SAAS,KAAA;AACzC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A,cAACQ,UAAAA;IACCC,KAAK;IACLC,IAAI;MAAEC,eAAe;QAAEC,IAAI;QAAOC,IAAI;MAAS;IAAE;KAEhD7B,WAEK,gBAAAgB,QAAA,cAAAA,QAAA,UAAA,MACE,gBAAAA,QAAA,cAACc,WAAAA;IACCT,SAAQ;IACRU,OAAO;MAAEC,iBAAiB;MAAQC,OAAO;IAAO;IAChDC,MAAM5B;IACN6B,SAAS,mCAAA;AACP,YAAMxB,UAAU,6BAAMyB,OAAOC,KAAK,wCAAwCC,mBAAmBtC,QAAAA,CAAAA,EAAW,GAAxF;AAChB,YAAMU,YAAYC,SAAS,GAAA;IAC7B,GAHS;IAIT4B,WAAW,gBAAAvB,QAAA,cAACwB,iBAAAA;MAAgBC,OAAM;;KACnC,sBAAA,GAGD,gBAAAzB,QAAA,cAACc,WAAAA;IACCI,MAAM1B;IACNa,SAAQ;IACRU,OAAO;MAAEC,iBAAiB;MAAWC,OAAO;IAAO;IACnDE,SAAS,mCAAA;AACP,YAAMxB,UAAU,6BAAMyB,OAAOC,KAAK,gDAAgDC,mBAAmBtC,QAAAA,CAAAA,EAAW,GAAhG;AAChB,YAAMU,YAAYC,SAAS,IAAA;IAC7B,GAHS;IAIT4B,WAAW,gBAAAvB,QAAA,cAAC0B,iBAAAA,IAAAA;KACb,mBAAA,CAAA,IAKL,IAAA,GAEN,gBAAA1B,QAAA,cAAC2B,aAAAA;IAAYxC;IAAcyC,OAAM;;AAGvC,GAhEyE;","names":["Facebook","FacebookIcon","Share","ShareIcon","Twitter","TwitterIcon","Popover","ButtonEx","FlexRow","LinkEx","React","useRef","useState","ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","FlexRow","gap","ref","ButtonEx","variant","minWidth","size","disabled","onClick","ShareIcon","htmlColor","fontSize","Popover","open","anchorEl","current","onClose","transitionDuration","padding","LinkEx","lineHeight","style","color","encodeURIComponent","TwitterIcon","FacebookIcon","createSvgIcon","React","FacebookSvgIcon","svg","xmlns","height","width","viewBox","path","d","fill","createSvgIcon","React","XTwitterSvgIcon","svg","viewBox","fill","xmlns","path","d","React","Helmet","DynamicShareImage","image","React","Helmet","meta","property","content","FlexGrowRow","React","useEffect","HideParentsFlexbox","children","props","useEffect","style","document","createElement","head","append","innerHTML","remove","React","FlexGrowRow","alignItems","id","justifyContent","Cancel","Stack","Tooltip","Typography","React","useCallback","useMemo","useState","CopyAllRounded","CircularProgress","IconButton","Tooltip","forget","React","useState","CopyIconButton","copyLinkText","copiedLinkText","onClickError","shareLinkName","shareUrl","uploadPayloads","props","CopyLink","Copied","copyTooltipTitle","setCopyToolTipTitle","useState","loading","setLoading","copyToClipboard","link","navigator","clipboard","writeText","setTimeout","e","message","console","error","Error","warn","React","Tooltip","title","IconButton","CircularProgress","size","aria-label","onClick","forget","edge","CopyAllRounded","keyframes","styled","Typography","moveBg","AnimatedGradientTypography","name","theme","color1","color2","palette","secondary","dark","primary","light","animationName","animationDuration","animationIterationCount","background","color","text","splitAroundSubstring","path","substring","index","indexOf","Error","part1","slice","part2","part3","length","CopyLinkStack","addToXnsName","copiedLinkText","copyLinkText","shareLinkName","shareUrl","xnsName","xnsNameProp","xnsEndColor","uploadPayloads","xnsStartColor","props","error","setError","useState","onClickError","useCallback","parsedXnsName","useMemo","parts","splitAroundSubstring","e","part1","part3","React","Stack","direction","alignItems","gap","maxWidth","sx","overflowX","Typography","display","AnimatedGradientTypography","color1","color2","overflow","CopyIconButton","Tooltip","title","message","Cancel","color","InputAdornment","TextField","React","useCallback","useState","CopyLinkTextField","shareLinkName","shareUrl","props","error","setError","useState","onClickError","useCallback","React","TextField","disabled","helperText","message","sx","input","WebkitTextFillColor","InputProps","endAdornment","InputAdornment","position","CopyIconButton","value","Dialog","DialogActions","DialogContent","DialogTitle","Stack","Typography","FlexCol","FlexGrowCol","React","ShareOutDialog","ShareOutDialogActions","cardImg","open","onClose","shareOutDialogContent","subtitle","title","props","handleClose","React","Dialog","DialogTitle","Stack","direction","spacing","FlexGrowCol","alignItems","width","Typography","variant","DialogContent","FlexCol","DialogActions","InfoOutlined","Tooltip","Typography","useTheme","FlexGrowRow","React","ShareOutExplanation","toolTipTitle","theme","useTheme","title","React","FlexGrowRow","alignItems","Typography","variant","paddingRight","Tooltip","placement","InfoOutlined","fontSize","sx","typography","caption","Button","CircularProgress","styled","React","GenerateShareLinkButton","children","loading","props","React","Button","variant","startIcon","StyledCircularProgress","size","styled","CircularProgress","name","theme","color","palette","getContrastText","primary","main","height","opacity","width","Typography","FlexGrowCol","React","ShareOutHeadingFlexbox","children","shareLinkName","shareUrl","props","GenerateShareLinkExplanation","React","FlexGrowCol","alignItems","paddingBottom","Typography","variant","gutterBottom","strong","Typography","ButtonEx","FlexGrowCol","FlexRow","ErrorRender","React","useState","SocialButtonsFlexbox","shareUrl","uploadPayloads","props","error","setError","useState","xLoading","setXLoading","fbLoading","setFbLoading","handleClick","openUrl","buttonName","setLoading","e","console","React","FlexGrowCol","alignItems","paddingTop","Typography","variant","gutterBottom","strong","FlexRow","gap","sx","flexDirection","md","xs","ButtonEx","style","backgroundColor","color","busy","onClick","window","open","encodeURIComponent","startIcon","XTwitterSvgIcon","width","FacebookSvgIcon","ErrorRender","scope"]}
@@ -2,7 +2,7 @@ import { type ButtonProps } from '@mui/material';
2
2
  import React from 'react';
3
3
  import type { ShareLinkProps } from './lib/index.ts';
4
4
  export interface CopyIconButtonProps extends ButtonProps, ShareLinkProps {
5
- onCopyToClipboard?: (error?: Error) => void;
5
+ onClickError?: (error: Error) => void;
6
6
  }
7
7
  export declare const CopyIconButton: React.FC<CopyIconButtonProps>;
8
8
  //# sourceMappingURL=CopyIconButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyIconButton.d.ts","sourceRoot":"","sources":["../../../src/out/CopyIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,mBAAoB,SAAQ,WAAW,EAAE,cAAc;IACtE,iBAAiB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;CAC5C;AAKD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA6BxD,CAAA"}
1
+ {"version":3,"file":"CopyIconButton.d.ts","sourceRoot":"","sources":["../../../src/out/CopyIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,mBAAoB,SAAQ,WAAW,EAAE,cAAc;IACtE,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACtC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4CxD,CAAA"}
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  import { type ShareLinkProps } from './lib/index.ts';
4
4
  export interface CopyLinkStackProps extends ShareLinkProps, StackProps {
5
5
  addToXnsName?: boolean;
6
+ copiedLinkText?: string;
7
+ copyLinkText?: string;
6
8
  xnsEndColor?: string;
7
9
  xnsStartColor?: string;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CopyLinkStack.d.ts","sourceRoot":"","sources":["../../../src/out/CopyLinkStack.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/C,OAAO,KAEN,MAAM,OAAO,CAAA;AAGd,OAAO,EACuB,KAAK,cAAc,EAChD,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,kBAAmB,SAAQ,cAAc,EAAE,UAAU;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA4CtD,CAAA"}
1
+ {"version":3,"file":"CopyLinkStack.d.ts","sourceRoot":"","sources":["../../../src/out/CopyLinkStack.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/C,OAAO,KAEN,MAAM,OAAO,CAAA;AAGd,OAAO,EACuB,KAAK,cAAc,EAChD,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,kBAAmB,SAAQ,cAAc,EAAE,UAAU;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoDtD,CAAA"}
@@ -2,6 +2,7 @@ import type { FlexBoxProps } from '@xylabs/react-flexbox';
2
2
  import React from 'react';
3
3
  export interface SocialButtonsFlexboxProps extends FlexBoxProps {
4
4
  shareUrl?: string;
5
+ uploadPayloads?: () => Promise<void>;
5
6
  }
6
7
  export declare const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps>;
7
8
  //# sourceMappingURL=SocialButtonsFlexbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialButtonsFlexbox.d.ts","sourceRoot":"","sources":["../../../src/out/SocialButtonsFlexbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,WAAW,yBAA0B,SAAQ,YAAY;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAuCpE,CAAA"}
1
+ {"version":3,"file":"SocialButtonsFlexbox.d.ts","sourceRoot":"","sources":["../../../src/out/SocialButtonsFlexbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGzD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,MAAM,WAAW,yBAA0B,SAAQ,YAAY;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAgEpE,CAAA"}
@@ -1,6 +1,9 @@
1
1
  export interface ShareLinkProps {
2
+ copiedLinkText?: string;
3
+ copyLinkText?: string;
2
4
  shareLinkName?: string;
3
5
  shareUrl?: string;
6
+ uploadPayloads?: () => Promise<void>;
4
7
  xnsName?: string;
5
8
  }
6
9
  //# sourceMappingURL=ShareLinkProps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ShareLinkProps.d.ts","sourceRoot":"","sources":["../../../../src/out/lib/ShareLinkProps.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
1
+ {"version":3,"file":"ShareLinkProps.d.ts","sourceRoot":"","sources":["../../../../src/out/lib/ShareLinkProps.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/react-share",
3
- "version": "3.0.22",
3
+ "version": "3.0.23",
4
4
  "description": "Common React library for all XYO projects that use React",
5
5
  "keywords": [
6
6
  "xyo",
@@ -48,18 +48,19 @@
48
48
  "@xylabs/react-flexbox": "^4.2.13",
49
49
  "@xylabs/react-link": "^4.2.13",
50
50
  "@xylabs/react-shared": "^4.2.13",
51
+ "@xyo-network/react-error": "^3.0.23",
51
52
  "react-helmet": "^6.1.0"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@mui/icons-material": "^5.16.7",
55
56
  "@mui/material": "^5.16.7",
56
57
  "@mui/styles": "^5.16.7",
57
- "@storybook/react": "^8.3.0",
58
+ "@storybook/react": "^8.3.2",
58
59
  "@types/react-helmet": "^6.1.11",
59
60
  "@xylabs/ts-scripts-yarn3": "^4.0.7",
60
61
  "react": "^18.3.1",
61
62
  "react-dom": "^18.3.1",
62
- "storybook": "^8.3.0",
63
+ "storybook": "^8.3.2",
63
64
  "typescript": "^5.6.2"
64
65
  },
65
66
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  import { CopyAllRounded } from '@mui/icons-material'
2
2
  import {
3
- type ButtonProps, IconButton, Tooltip,
3
+ type ButtonProps, CircularProgress, IconButton, Tooltip,
4
4
  } from '@mui/material'
5
5
  import { forget } from '@xylabs/forget'
6
6
  import React, { useState } from 'react'
@@ -8,28 +8,32 @@ import React, { useState } from 'react'
8
8
  import type { ShareLinkProps } from './lib/index.ts'
9
9
 
10
10
  export interface CopyIconButtonProps extends ButtonProps, ShareLinkProps {
11
- onCopyToClipboard?: (error?: Error) => void
11
+ onClickError?: (error: Error) => void
12
12
  }
13
13
 
14
- const CopyLink = 'Copy Link'
15
- const Copied = 'Copied!'
16
-
17
14
  export const CopyIconButton: React.FC<CopyIconButtonProps> = ({
18
- onCopyToClipboard, shareLinkName, shareUrl, ...props
15
+ copyLinkText, copiedLinkText, onClickError, shareLinkName, shareUrl, uploadPayloads, ...props
19
16
  }) => {
17
+ const CopyLink = copyLinkText ?? 'Copy Link'
18
+ const Copied = copiedLinkText ?? 'Copied!'
19
+
20
20
  const [copyTooltipTitle, setCopyToolTipTitle] = useState(CopyLink)
21
+ const [loading, setLoading] = useState(false)
21
22
 
22
23
  const copyToClipboard = async (link?: string) => {
23
24
  if (link) {
24
25
  try {
26
+ setLoading(true)
27
+ await uploadPayloads?.()
25
28
  await navigator.clipboard.writeText(link)
26
- onCopyToClipboard?.()
27
29
  setCopyToolTipTitle(Copied)
28
30
  setTimeout(() => setCopyToolTipTitle(CopyLink), 2000)
31
+ setLoading(false)
29
32
  } catch (e) {
33
+ setLoading(false)
30
34
  const message = 'Error copying shareUrl to clipboard'
31
35
  console.error(message, e, link)
32
- onCopyToClipboard?.(new Error(message))
36
+ onClickError?.(new Error(message))
33
37
  }
34
38
  } else {
35
39
  console.warn('tried to copy shareUrl before it was generated')
@@ -38,9 +42,17 @@ export const CopyIconButton: React.FC<CopyIconButtonProps> = ({
38
42
 
39
43
  return (
40
44
  <Tooltip title={copyTooltipTitle}>
41
- <IconButton aria-label={`copy ${shareLinkName} link`} onClick={() => forget(copyToClipboard(shareUrl))} edge="end" {...props}>
42
- <CopyAllRounded />
43
- </IconButton>
45
+ {loading
46
+ ? (
47
+ <IconButton>
48
+ <CircularProgress size="24px" />
49
+ </IconButton>
50
+ )
51
+ : (
52
+ <IconButton aria-label={`copy ${shareLinkName} link`} onClick={() => forget(copyToClipboard(shareUrl))} edge="end" {...props}>
53
+ <CopyAllRounded />
54
+ </IconButton>
55
+ )}
44
56
  </Tooltip>
45
57
  )
46
58
  }
@@ -45,9 +45,25 @@ WithError.args = {
45
45
  shareUrl: 'https://google.com', xnsName: 'foo.xyo', addToXnsName: true,
46
46
  }
47
47
 
48
+ const WithUploadPayloads = Template.bind({})
49
+ WithUploadPayloads.args = {
50
+ shareUrl: 'https://beta.node.xyo.network.com/view/arietrouw.xyo/profile',
51
+ xnsName: 'arietrouw.xyo',
52
+ addToXnsName: true,
53
+ copiedLinkText: 'Copied and data uploaded!',
54
+ copyLinkText: 'Copy link and upload data',
55
+ uploadPayloads: () => new Promise((resolve) => {
56
+ setTimeout(() => {
57
+ alert('uploaded payloads')
58
+ resolve()
59
+ }, 1000)
60
+ }),
61
+ }
62
+
48
63
  export {
49
64
  Default, WithError,
50
65
  WithNoAddToXnsName,
51
- WithShareUrl, WithXnsName, WithXnsNameCustomColors,
66
+ WithShareUrl, WithUploadPayloads,
67
+ WithXnsName, WithXnsNameCustomColors,
52
68
  WithXnsNameInSubdomain, WithXnsNameShortened,
53
69
  }
@@ -16,16 +16,18 @@ import {
16
16
 
17
17
  export interface CopyLinkStackProps extends ShareLinkProps, StackProps {
18
18
  addToXnsName?: boolean
19
+ copiedLinkText?: string
20
+ copyLinkText?: string
19
21
  xnsEndColor?: string
20
22
  xnsStartColor?: string
21
23
  }
22
24
 
23
25
  export const CopyLinkStack: React.FC<CopyLinkStackProps> = ({
24
- addToXnsName, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, xnsStartColor, ...props
26
+ addToXnsName, copiedLinkText, copyLinkText, shareLinkName, shareUrl, xnsName: xnsNameProp, xnsEndColor, uploadPayloads, xnsStartColor, ...props
25
27
  }) => {
26
28
  const [error, setError] = useState<Error>()
27
29
 
28
- const onCopyToClipboard = useCallback((error?: Error) => {
30
+ const onClickError = useCallback((error: Error) => {
29
31
  setError(error)
30
32
  }, [])
31
33
 
@@ -60,7 +62,15 @@ export const CopyLinkStack: React.FC<CopyLinkStackProps> = ({
60
62
  {shareUrl}
61
63
  </Typography>
62
64
  )}
63
- <CopyIconButton onCopyToClipboard={onCopyToClipboard} shareLinkName={shareLinkName} shareUrl={shareUrl} sx={{ display: 'inline-flex' }} />
65
+ <CopyIconButton
66
+ copiedLinkText={copiedLinkText}
67
+ copyLinkText={copyLinkText}
68
+ onClickError={onClickError}
69
+ shareLinkName={shareLinkName}
70
+ shareUrl={shareUrl}
71
+ sx={{ display: 'inline-flex' }}
72
+ uploadPayloads={uploadPayloads}
73
+ />
64
74
  {error ? <Tooltip title={error.message}><Cancel color="error" sx={{ display: 'inline-flex' }} /></Tooltip> : null}
65
75
  </Stack>
66
76
  )
@@ -14,7 +14,7 @@ export const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({
14
14
  }) => {
15
15
  const [error, setError] = useState<Error>()
16
16
 
17
- const onCopyToClipboard = useCallback((error?: Error) => {
17
+ const onClickError = useCallback((error?: Error) => {
18
18
  setError(error)
19
19
  }, [])
20
20
 
@@ -28,7 +28,7 @@ export const CopyLinkTextField: React.FC<CopyLinkTextFieldProps> = ({
28
28
  InputProps={{
29
29
  endAdornment: (
30
30
  <InputAdornment position="end">
31
- <CopyIconButton shareLinkName={shareLinkName} shareUrl={shareUrl} onCopyToClipboard={onCopyToClipboard} />
31
+ <CopyIconButton shareLinkName={shareLinkName} shareUrl={shareUrl} onClickError={onClickError} />
32
32
  </InputAdornment>
33
33
  ),
34
34
  }}
@@ -15,4 +15,27 @@ Default.args = {}
15
15
  const WithShareUrl = Template.bind({})
16
16
  WithShareUrl.args = { shareUrl: 'https://google.com' }
17
17
 
18
- export { Default, WithShareUrl }
18
+ const WithUploadPayloads = Template.bind({})
19
+ WithUploadPayloads.args = {
20
+ shareUrl: 'https://google.com',
21
+ uploadPayloads: () => new Promise((resolve) => {
22
+ setTimeout(() => {
23
+ alert('uploaded payloads')
24
+ resolve()
25
+ }, 1000)
26
+ }),
27
+ }
28
+
29
+ const WithUploadPayloadsError = Template.bind({})
30
+ WithUploadPayloadsError.args = {
31
+ shareUrl: 'https://google.com',
32
+ uploadPayloads: () => new Promise((_resolve, reject) => {
33
+ setTimeout(() => {
34
+ reject(new Error('Error uploading payloads'))
35
+ }, 1000)
36
+ }),
37
+ }
38
+
39
+ export {
40
+ Default, WithShareUrl, WithUploadPayloads, WithUploadPayloadsError,
41
+ }
@@ -2,15 +2,37 @@ import { Typography } from '@mui/material'
2
2
  import { ButtonEx } from '@xylabs/react-button'
3
3
  import type { FlexBoxProps } from '@xylabs/react-flexbox'
4
4
  import { FlexGrowCol, FlexRow } from '@xylabs/react-flexbox'
5
- import React from 'react'
5
+ import { ErrorRender } from '@xyo-network/react-error'
6
+ import React, { useState } from 'react'
6
7
 
7
8
  import { FacebookSvgIcon, XTwitterSvgIcon } from '../icons/index.ts'
8
9
 
9
10
  export interface SocialButtonsFlexboxProps extends FlexBoxProps {
10
11
  shareUrl?: string
12
+ uploadPayloads?: () => Promise<void>
11
13
  }
12
14
 
13
- export const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({ shareUrl, ...props }) => {
15
+ export const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({
16
+ shareUrl, uploadPayloads, ...props
17
+ }) => {
18
+ const [error, setError] = useState<Error>()
19
+ const [xLoading, setXLoading] = useState(false)
20
+ const [fbLoading, setFbLoading] = useState(false)
21
+
22
+ const handleClick = async (openUrl: () => void, buttonName: 'x' | 'fb') => {
23
+ const setLoading = buttonName === 'x' ? setXLoading : setFbLoading
24
+ try {
25
+ setLoading(true)
26
+ await uploadPayloads?.()
27
+ setLoading(false)
28
+ openUrl()
29
+ } catch (e) {
30
+ setLoading(false)
31
+ console.error('Error uploading payloads', e)
32
+ setError(e as Error)
33
+ }
34
+ }
35
+
14
36
  return (
15
37
  <FlexGrowCol alignItems="stretch" paddingTop={2} {...props}>
16
38
  <Typography variant="body1" gutterBottom>
@@ -26,18 +48,22 @@ export const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({ shar
26
48
  <ButtonEx
27
49
  variant="contained"
28
50
  style={{ backgroundColor: '#000', color: '#fff' }}
29
- onClick={() => {
30
- window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`)
51
+ busy={xLoading}
52
+ onClick={async () => {
53
+ const openUrl = () => window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`)
54
+ await handleClick(openUrl, 'x')
31
55
  }}
32
56
  startIcon={<XTwitterSvgIcon width="20px" />}
33
57
  >
34
58
  Share on X (Twitter)
35
59
  </ButtonEx>
36
60
  <ButtonEx
61
+ busy={fbLoading}
37
62
  variant="contained"
38
63
  style={{ backgroundColor: '#4267b2', color: '#fff' }}
39
- onClick={() => {
40
- window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`)
64
+ onClick={async () => {
65
+ const openUrl = () => window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`)
66
+ await handleClick(openUrl, 'fb')
41
67
  }}
42
68
  startIcon={<FacebookSvgIcon />}
43
69
  >
@@ -47,6 +73,7 @@ export const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({ shar
47
73
  )
48
74
  : null}
49
75
  </FlexRow>
76
+ <ErrorRender error={error} scope="SocialButtonsFlexbox" />
50
77
  </FlexGrowCol>
51
78
  )
52
79
  }
@@ -1,5 +1,8 @@
1
1
  export interface ShareLinkProps {
2
+ copiedLinkText?: string
3
+ copyLinkText?: string
2
4
  shareLinkName?: string
3
5
  shareUrl?: string
6
+ uploadPayloads?: () => Promise<void>
4
7
  xnsName?: string
5
8
  }