@xyo-network/react-share 2.81.10 → 2.82.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/dist/browser/ShareButton.d.cts +1 -0
- package/dist/browser/ShareButton.d.cts.map +1 -1
- package/dist/browser/ShareButton.d.mts +1 -0
- package/dist/browser/ShareButton.d.mts.map +1 -1
- package/dist/browser/ShareButton.d.ts +1 -0
- package/dist/browser/ShareButton.d.ts.map +1 -1
- package/dist/browser/index.cjs +60 -46
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -1
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -1
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.mjs +65 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/neutral/ShareButton.d.cts +1 -0
- package/dist/neutral/ShareButton.d.cts.map +1 -1
- package/dist/neutral/ShareButton.d.mts +1 -0
- package/dist/neutral/ShareButton.d.mts.map +1 -1
- package/dist/neutral/ShareButton.d.ts +1 -0
- package/dist/neutral/ShareButton.d.ts.map +1 -1
- package/dist/neutral/index.cjs +60 -46
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +1 -1
- package/dist/neutral/index.d.cts.map +1 -1
- package/dist/neutral/index.d.mts +1 -1
- package/dist/neutral/index.d.mts.map +1 -1
- package/dist/neutral/index.d.ts +1 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +65 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/ShareButton.d.cts +1 -0
- package/dist/node/ShareButton.d.cts.map +1 -1
- package/dist/node/ShareButton.d.mts +1 -0
- package/dist/node/ShareButton.d.mts.map +1 -1
- package/dist/node/ShareButton.d.ts +1 -0
- package/dist/node/ShareButton.d.ts.map +1 -1
- package/dist/node/index.cjs +60 -46
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -1
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +65 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +10 -10
- package/src/ShareButton.stories.tsx +2 -2
- package/src/ShareButton.tsx +1 -1
- package/src/index.ts +1 -1
- package/dist/browser/index.js +0 -59
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js +0 -59
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js +0 -59
- package/dist/node/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
18
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
30
|
|
|
20
31
|
// src/index.ts
|
|
@@ -30,53 +41,56 @@ var import_material = require("@mui/material");
|
|
|
30
41
|
var import_react_button = require("@xylabs/react-button");
|
|
31
42
|
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
32
43
|
var import_react_link = require("@xylabs/react-link");
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
var
|
|
35
|
-
var ShareButton = ({ prepared = true, shareLink, ...props }) => {
|
|
44
|
+
var import_react = __toESM(require("react"), 1);
|
|
45
|
+
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
36
46
|
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
37
47
|
const anchorRef = (0, import_react.useRef)(null);
|
|
38
48
|
const link = shareLink ?? window.location.href;
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
49
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
50
|
+
gap: 1,
|
|
51
|
+
ref: anchorRef
|
|
52
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_button.ButtonEx, {
|
|
53
|
+
variant: "text",
|
|
54
|
+
minWidth: 32,
|
|
55
|
+
size: "small",
|
|
56
|
+
disabled: !prepared,
|
|
57
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
58
|
+
setExpanded(true);
|
|
59
|
+
}, "onClick"),
|
|
60
|
+
...props
|
|
61
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Share, {
|
|
62
|
+
htmlColor: "gray",
|
|
63
|
+
fontSize: "small"
|
|
64
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_material.Popover, {
|
|
65
|
+
open: prepared ? expanded : false,
|
|
66
|
+
anchorEl: anchorRef.current,
|
|
67
|
+
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
68
|
+
transitionDuration: 500
|
|
69
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
70
|
+
gap: 0.5,
|
|
71
|
+
padding: 0.5
|
|
72
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
73
|
+
lineHeight: 0,
|
|
74
|
+
style: {
|
|
75
|
+
color: "#1da1f2"
|
|
76
|
+
},
|
|
77
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
78
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
79
|
+
setExpanded(false);
|
|
80
|
+
}, "onClick")
|
|
81
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Twitter, {
|
|
82
|
+
fontSize: "small"
|
|
83
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
84
|
+
lineHeight: 0,
|
|
85
|
+
style: {
|
|
86
|
+
color: "#4267b2"
|
|
87
|
+
},
|
|
88
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
89
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
90
|
+
setExpanded(false);
|
|
91
|
+
}, "onClick")
|
|
92
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Facebook, {
|
|
93
|
+
fontSize: "small"
|
|
94
|
+
})))));
|
|
95
|
+
}, "ShareButton");
|
|
82
96
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ShareButton.tsx"],"sourcesContent":["export * from './ShareButton.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/ShareButton.tsx"],"sourcesContent":["export * from './ShareButton.tsx'\n","import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } 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> = ({ prepared = true, shareLink, ...props }) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,4BAAqF;AACrF,sBAAwB;AACxB,0BAAwC;AACxC,2BAAwB;AACxB,wBAAuB;AACvB,mBAAwC;AAOjC,IAAMA,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,QAAeC,uBAAS,KAAA;AACzC,QAAMC,gBAAYC,qBAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,6BAAAC,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAGC,KAAKT;KACpB,6BAAAM,QAAA,cAACI,8BAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACpB;IACXqB,SAAS,6BAAA;AACPjB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,6BAAAU,QAAA,cAACU,sBAAAA,OAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,6BAAAZ,QAAA,cAACa,yBAAAA;IAAQC,MAAM1B,WAAWG,WAAW;IAAOwB,UAAUrB,UAAUsB;IAASC,SAAS,6BAAMzB,YAAY,KAAA,GAAlB;IAA0B0B,oBAAoB;KAC9H,6BAAAlB,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,6BAAAnB,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,wCAAwCU,mBAAmB5B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAACyB,sBAAAA,SAAAA;IAAYb,UAAS;OAExB,6BAAAZ,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,gDAAgDU,mBAAmB5B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAAC0B,sBAAAA,UAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","names":["ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","React","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"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ShareButton.
|
|
1
|
+
export * from './ShareButton.tsx';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ShareButton.
|
|
1
|
+
export * from './ShareButton.tsx';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ShareButton.
|
|
1
|
+
export * from './ShareButton.tsx';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/ShareButton.tsx
|
|
5
|
+
import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from "@mui/icons-material";
|
|
6
|
+
import { Popover } from "@mui/material";
|
|
7
|
+
import { ButtonEx } from "@xylabs/react-button";
|
|
8
|
+
import { FlexRow } from "@xylabs/react-flexbox";
|
|
9
|
+
import { LinkEx } from "@xylabs/react-link";
|
|
10
|
+
import React, { useRef, useState } from "react";
|
|
11
|
+
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
12
|
+
const [expanded, setExpanded] = useState(false);
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const link = shareLink ?? window.location.href;
|
|
15
|
+
return /* @__PURE__ */ React.createElement(FlexRow, {
|
|
16
|
+
gap: 1,
|
|
17
|
+
ref: anchorRef
|
|
18
|
+
}, /* @__PURE__ */ React.createElement(ButtonEx, {
|
|
19
|
+
variant: "text",
|
|
20
|
+
minWidth: 32,
|
|
21
|
+
size: "small",
|
|
22
|
+
disabled: !prepared,
|
|
23
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
24
|
+
setExpanded(true);
|
|
25
|
+
}, "onClick"),
|
|
26
|
+
...props
|
|
27
|
+
}, /* @__PURE__ */ React.createElement(ShareIcon, {
|
|
28
|
+
htmlColor: "gray",
|
|
29
|
+
fontSize: "small"
|
|
30
|
+
})), /* @__PURE__ */ React.createElement(Popover, {
|
|
31
|
+
open: prepared ? expanded : false,
|
|
32
|
+
anchorEl: anchorRef.current,
|
|
33
|
+
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
34
|
+
transitionDuration: 500
|
|
35
|
+
}, /* @__PURE__ */ React.createElement(FlexRow, {
|
|
36
|
+
gap: 0.5,
|
|
37
|
+
padding: 0.5
|
|
38
|
+
}, /* @__PURE__ */ React.createElement(LinkEx, {
|
|
39
|
+
lineHeight: 0,
|
|
40
|
+
style: {
|
|
41
|
+
color: "#1da1f2"
|
|
42
|
+
},
|
|
43
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
44
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
45
|
+
setExpanded(false);
|
|
46
|
+
}, "onClick")
|
|
47
|
+
}, /* @__PURE__ */ React.createElement(TwitterIcon, {
|
|
48
|
+
fontSize: "small"
|
|
49
|
+
})), /* @__PURE__ */ React.createElement(LinkEx, {
|
|
50
|
+
lineHeight: 0,
|
|
51
|
+
style: {
|
|
52
|
+
color: "#4267b2"
|
|
53
|
+
},
|
|
54
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
55
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
56
|
+
setExpanded(false);
|
|
57
|
+
}, "onClick")
|
|
58
|
+
}, /* @__PURE__ */ React.createElement(FacebookIcon, {
|
|
59
|
+
fontSize: "small"
|
|
60
|
+
})))));
|
|
61
|
+
}, "ShareButton");
|
|
62
|
+
export {
|
|
63
|
+
ShareButton
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ShareButton.tsx"],"sourcesContent":["import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } 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> = ({ prepared = true, shareLink, ...props }) => {\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"],"mappings":";;;;AAAA,SAASA,YAAYC,cAAcC,SAASC,WAAWC,WAAWC,mBAAmB;AACrF,SAASC,eAAe;AACxB,SAASC,gBAA+B;AACxC,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,OAAOC,SAASC,QAAQC,gBAAgB;AAOjC,IAAMC,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,IAAeC,SAAS,KAAA;AACzC,QAAMC,YAAYC,OAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,sBAAA,cAACC,SAAAA;IAAQC,KAAK;IAAGC,KAAKR;KACpB,sBAAA,cAACS,UAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACnB;IACXoB,SAAS,6BAAA;AACPhB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,sBAAA,cAACmB,WAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,sBAAA,cAACC,SAAAA;IAAQC,MAAMzB,WAAWG,WAAW;IAAOuB,UAAUpB,UAAUqB;IAASC,SAAS,6BAAMxB,YAAY,KAAA,GAAlB;IAA0ByB,oBAAoB;KAC9H,sBAAA,cAACjB,SAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,sBAAA,cAACC,QAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPX,aAAOgB,KAAK,wCAAwCU,mBAAmB3B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,sBAAA,cAACgC,aAAAA;IAAYb,UAAS;OAExB,sBAAA,cAACQ,QAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPX,aAAOgB,KAAK,gDAAgDU,mBAAmB3B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,sBAAA,cAACiC,cAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
18
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
30
|
|
|
20
31
|
// src/index.ts
|
|
@@ -30,53 +41,56 @@ var import_material = require("@mui/material");
|
|
|
30
41
|
var import_react_button = require("@xylabs/react-button");
|
|
31
42
|
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
32
43
|
var import_react_link = require("@xylabs/react-link");
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
var
|
|
35
|
-
var ShareButton = ({ prepared = true, shareLink, ...props }) => {
|
|
44
|
+
var import_react = __toESM(require("react"), 1);
|
|
45
|
+
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
36
46
|
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
37
47
|
const anchorRef = (0, import_react.useRef)(null);
|
|
38
48
|
const link = shareLink ?? window.location.href;
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
49
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
50
|
+
gap: 1,
|
|
51
|
+
ref: anchorRef
|
|
52
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_button.ButtonEx, {
|
|
53
|
+
variant: "text",
|
|
54
|
+
minWidth: 32,
|
|
55
|
+
size: "small",
|
|
56
|
+
disabled: !prepared,
|
|
57
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
58
|
+
setExpanded(true);
|
|
59
|
+
}, "onClick"),
|
|
60
|
+
...props
|
|
61
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Share, {
|
|
62
|
+
htmlColor: "gray",
|
|
63
|
+
fontSize: "small"
|
|
64
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_material.Popover, {
|
|
65
|
+
open: prepared ? expanded : false,
|
|
66
|
+
anchorEl: anchorRef.current,
|
|
67
|
+
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
68
|
+
transitionDuration: 500
|
|
69
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
70
|
+
gap: 0.5,
|
|
71
|
+
padding: 0.5
|
|
72
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
73
|
+
lineHeight: 0,
|
|
74
|
+
style: {
|
|
75
|
+
color: "#1da1f2"
|
|
76
|
+
},
|
|
77
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
78
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
79
|
+
setExpanded(false);
|
|
80
|
+
}, "onClick")
|
|
81
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Twitter, {
|
|
82
|
+
fontSize: "small"
|
|
83
|
+
})), /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
84
|
+
lineHeight: 0,
|
|
85
|
+
style: {
|
|
86
|
+
color: "#4267b2"
|
|
87
|
+
},
|
|
88
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
89
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
90
|
+
setExpanded(false);
|
|
91
|
+
}, "onClick")
|
|
92
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Facebook, {
|
|
93
|
+
fontSize: "small"
|
|
94
|
+
})))));
|
|
95
|
+
}, "ShareButton");
|
|
82
96
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ShareButton.tsx"],"sourcesContent":["export * from './ShareButton.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/ShareButton.tsx"],"sourcesContent":["export * from './ShareButton.tsx'\n","import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } 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> = ({ prepared = true, shareLink, ...props }) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,4BAAqF;AACrF,sBAAwB;AACxB,0BAAwC;AACxC,2BAAwB;AACxB,wBAAuB;AACvB,mBAAwC;AAOjC,IAAMA,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,QAAeC,uBAAS,KAAA;AACzC,QAAMC,gBAAYC,qBAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,6BAAAC,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAGC,KAAKT;KACpB,6BAAAM,QAAA,cAACI,8BAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACpB;IACXqB,SAAS,6BAAA;AACPjB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,6BAAAU,QAAA,cAACU,sBAAAA,OAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,6BAAAZ,QAAA,cAACa,yBAAAA;IAAQC,MAAM1B,WAAWG,WAAW;IAAOwB,UAAUrB,UAAUsB;IAASC,SAAS,6BAAMzB,YAAY,KAAA,GAAlB;IAA0B0B,oBAAoB;KAC9H,6BAAAlB,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,6BAAAnB,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,wCAAwCU,mBAAmB5B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAACyB,sBAAAA,SAAAA;IAAYb,UAAS;OAExB,6BAAAZ,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,gDAAgDU,mBAAmB5B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAAC0B,sBAAAA,UAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","names":["ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","React","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"]}
|
package/dist/neutral/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ShareButton.
|
|
1
|
+
export * from './ShareButton.tsx';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/neutral/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ShareButton.
|
|
1
|
+
export * from './ShareButton.tsx';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ShareButton.
|
|
1
|
+
export * from './ShareButton.tsx';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/ShareButton.tsx
|
|
5
|
+
import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from "@mui/icons-material";
|
|
6
|
+
import { Popover } from "@mui/material";
|
|
7
|
+
import { ButtonEx } from "@xylabs/react-button";
|
|
8
|
+
import { FlexRow } from "@xylabs/react-flexbox";
|
|
9
|
+
import { LinkEx } from "@xylabs/react-link";
|
|
10
|
+
import React, { useRef, useState } from "react";
|
|
11
|
+
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
12
|
+
const [expanded, setExpanded] = useState(false);
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const link = shareLink ?? window.location.href;
|
|
15
|
+
return /* @__PURE__ */ React.createElement(FlexRow, {
|
|
16
|
+
gap: 1,
|
|
17
|
+
ref: anchorRef
|
|
18
|
+
}, /* @__PURE__ */ React.createElement(ButtonEx, {
|
|
19
|
+
variant: "text",
|
|
20
|
+
minWidth: 32,
|
|
21
|
+
size: "small",
|
|
22
|
+
disabled: !prepared,
|
|
23
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
24
|
+
setExpanded(true);
|
|
25
|
+
}, "onClick"),
|
|
26
|
+
...props
|
|
27
|
+
}, /* @__PURE__ */ React.createElement(ShareIcon, {
|
|
28
|
+
htmlColor: "gray",
|
|
29
|
+
fontSize: "small"
|
|
30
|
+
})), /* @__PURE__ */ React.createElement(Popover, {
|
|
31
|
+
open: prepared ? expanded : false,
|
|
32
|
+
anchorEl: anchorRef.current,
|
|
33
|
+
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
34
|
+
transitionDuration: 500
|
|
35
|
+
}, /* @__PURE__ */ React.createElement(FlexRow, {
|
|
36
|
+
gap: 0.5,
|
|
37
|
+
padding: 0.5
|
|
38
|
+
}, /* @__PURE__ */ React.createElement(LinkEx, {
|
|
39
|
+
lineHeight: 0,
|
|
40
|
+
style: {
|
|
41
|
+
color: "#1da1f2"
|
|
42
|
+
},
|
|
43
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
44
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
45
|
+
setExpanded(false);
|
|
46
|
+
}, "onClick")
|
|
47
|
+
}, /* @__PURE__ */ React.createElement(TwitterIcon, {
|
|
48
|
+
fontSize: "small"
|
|
49
|
+
})), /* @__PURE__ */ React.createElement(LinkEx, {
|
|
50
|
+
lineHeight: 0,
|
|
51
|
+
style: {
|
|
52
|
+
color: "#4267b2"
|
|
53
|
+
},
|
|
54
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
55
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
56
|
+
setExpanded(false);
|
|
57
|
+
}, "onClick")
|
|
58
|
+
}, /* @__PURE__ */ React.createElement(FacebookIcon, {
|
|
59
|
+
fontSize: "small"
|
|
60
|
+
})))));
|
|
61
|
+
}, "ShareButton");
|
|
62
|
+
export {
|
|
63
|
+
ShareButton
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ShareButton.tsx"],"sourcesContent":["import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } 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> = ({ prepared = true, shareLink, ...props }) => {\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"],"mappings":";;;;AAAA,SAASA,YAAYC,cAAcC,SAASC,WAAWC,WAAWC,mBAAmB;AACrF,SAASC,eAAe;AACxB,SAASC,gBAA+B;AACxC,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,OAAOC,SAASC,QAAQC,gBAAgB;AAOjC,IAAMC,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,IAAeC,SAAS,KAAA;AACzC,QAAMC,YAAYC,OAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,sBAAA,cAACC,SAAAA;IAAQC,KAAK;IAAGC,KAAKR;KACpB,sBAAA,cAACS,UAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACnB;IACXoB,SAAS,6BAAA;AACPhB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,sBAAA,cAACmB,WAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,sBAAA,cAACC,SAAAA;IAAQC,MAAMzB,WAAWG,WAAW;IAAOuB,UAAUpB,UAAUqB;IAASC,SAAS,6BAAMxB,YAAY,KAAA,GAAlB;IAA0ByB,oBAAoB;KAC9H,sBAAA,cAACjB,SAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,sBAAA,cAACC,QAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPX,aAAOgB,KAAK,wCAAwCU,mBAAmB3B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,sBAAA,cAACgC,aAAAA;IAAYb,UAAS;OAExB,sBAAA,cAACQ,QAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPX,aAAOgB,KAAK,gDAAgDU,mBAAmB3B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,sBAAA,cAACiC,cAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","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"]}
|