@stokr/components-library 3.0.72 → 3.0.74
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/components/Button/Button.styles.js +17 -1
- package/dist/components/Chips/Chip.js +1 -1
- package/dist/components/CopyToClipboardTooltip/CopyToClipboardTooltip.js +47 -0
- package/dist/components/CopyToClipboardTooltip/CopyToClipboardTooltip.styles.js +16 -0
- package/dist/components/CryptoAddress/CryptoAddress.js +9 -33
- package/dist/components/InfoIcon/InfoIcon.js +60 -49
- package/dist/components/InfoIcon/InfoIcon.styles.js +10 -42
- package/dist/components/Payment/PaymentDisplay.js +4 -26
- package/dist/components/StatusTag/StatusTag.js +1 -1
- package/dist/components/ToDoList/ToDoList.js +4 -9
- package/dist/components/ToDoList/ToDoListTask.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +143 -0
- package/dist/components/Tooltip/Tooltip.styles.js +32 -0
- package/dist/index.js +110 -103
- package/dist/styles/global.js +0 -3
- package/dist/styles/reactTippy.js +1 -36
- package/dist/utils/copy-text-to-clipboard.js +42 -0
- package/dist/utils/copyToClipboard.js +5 -49
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const copyViaTextarea = (text) => {
|
|
2
|
+
const previouslyFocused = document.activeElement;
|
|
3
|
+
const textArea = document.createElement("textarea");
|
|
4
|
+
textArea.value = text;
|
|
5
|
+
textArea.setAttribute("readonly", "");
|
|
6
|
+
textArea.style.position = "fixed";
|
|
7
|
+
textArea.style.left = "-999999px";
|
|
8
|
+
textArea.style.top = "-999999px";
|
|
9
|
+
document.body.appendChild(textArea);
|
|
10
|
+
try {
|
|
11
|
+
textArea.focus();
|
|
12
|
+
textArea.select();
|
|
13
|
+
return document.execCommand("copy");
|
|
14
|
+
} finally {
|
|
15
|
+
textArea.remove();
|
|
16
|
+
previouslyFocused?.focus?.();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const copyTextToClipboard = async (text, onCopy, onError) => {
|
|
20
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
21
|
+
try {
|
|
22
|
+
await navigator.clipboard.writeText(text);
|
|
23
|
+
onCopy?.(text, true);
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
if (copyViaTextarea(text)) {
|
|
30
|
+
onCopy?.(text, true);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
onError?.(new Error("Failed to copy text"));
|
|
34
|
+
return false;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
onError?.(error);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
copyTextToClipboard
|
|
42
|
+
};
|
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React__default
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import { CopyToClipboard } from "react-copy-to-clipboard";
|
|
4
4
|
import { CopyToClipboard as CopyToClipboard2 } from "react-copy-to-clipboard";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
const copyTextToClipboard = async (text, onCopy, onError) => {
|
|
8
|
-
try {
|
|
9
|
-
if (navigator.clipboard && window.isSecureContext) {
|
|
10
|
-
await navigator.clipboard.writeText(text);
|
|
11
|
-
if (onCopy) onCopy(text, true);
|
|
12
|
-
return true;
|
|
13
|
-
} else {
|
|
14
|
-
const textArea = document.createElement("textarea");
|
|
15
|
-
textArea.value = text;
|
|
16
|
-
textArea.style.position = "fixed";
|
|
17
|
-
textArea.style.left = "-999999px";
|
|
18
|
-
textArea.style.top = "-999999px";
|
|
19
|
-
document.body.appendChild(textArea);
|
|
20
|
-
textArea.focus();
|
|
21
|
-
textArea.select();
|
|
22
|
-
const successful = document.execCommand("copy");
|
|
23
|
-
document.body.removeChild(textArea);
|
|
24
|
-
if (successful) {
|
|
25
|
-
if (onCopy) onCopy(text, true);
|
|
26
|
-
return true;
|
|
27
|
-
} else {
|
|
28
|
-
if (onError) onError(new Error("Failed to copy text"));
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (onError) onError(error);
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
5
|
+
import { copyTextToClipboard } from "./copy-text-to-clipboard.js";
|
|
6
|
+
import { CopyToClipboardTooltip } from "../components/CopyToClipboardTooltip/CopyToClipboardTooltip.js";
|
|
37
7
|
const withCopyToClipboard = (WrappedComponent, options = {}) => {
|
|
38
8
|
const { textProp = "text", onCopyProp = "onCopy", onErrorProp = "onError" } = options;
|
|
39
9
|
return function CopyToClipboardWrapper(props) {
|
|
@@ -67,25 +37,11 @@ const useCopyToClipboard = (text) => {
|
|
|
67
37
|
);
|
|
68
38
|
return { copy, copied };
|
|
69
39
|
};
|
|
70
|
-
const CopyToClipBoardTooltip =
|
|
71
|
-
const [copied, setCopied] = useState(false);
|
|
72
|
-
return /* @__PURE__ */ jsx(
|
|
73
|
-
Tooltip,
|
|
74
|
-
{
|
|
75
|
-
position: "top",
|
|
76
|
-
title: copied ? "Copied to clipboard!" : "Click to copy to clipboard.",
|
|
77
|
-
theme: "light",
|
|
78
|
-
arrow: true,
|
|
79
|
-
hideOnClick: false,
|
|
80
|
-
onHidden: () => setCopied(false),
|
|
81
|
-
duration: 200,
|
|
82
|
-
children: /* @__PURE__ */ jsx(CopyToClipboard, { text: value, onCopy: () => setCopied(true), children: /* @__PURE__ */ jsx(CopyToClipboardButton, { style: buttonStyle }) })
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
};
|
|
40
|
+
const CopyToClipBoardTooltip = CopyToClipboardTooltip;
|
|
86
41
|
export {
|
|
87
42
|
CopyToClipBoardTooltip,
|
|
88
43
|
CopyToClipboard2 as CopyToClipboard,
|
|
44
|
+
CopyToClipboardTooltip,
|
|
89
45
|
copyTextToClipboard,
|
|
90
46
|
useCopyToClipboard,
|
|
91
47
|
withCopyToClipboard
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stokr/components-library",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.74",
|
|
4
4
|
"description": "STOKR - Components Library",
|
|
5
5
|
"author": "Bilal Hodzic <bilal@stokr.io>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"serve": "npx http-server ./storybook-static -p 9009"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
+
"@floating-ui/react": "^0.27.20",
|
|
57
58
|
"@lottiefiles/dotlottie-react": "^0.19.4",
|
|
58
59
|
"axios": "^1.13.5",
|
|
59
60
|
"country-flag-icons": "^1.6.17",
|
|
@@ -81,7 +82,6 @@
|
|
|
81
82
|
"react-select": "^5.7.0",
|
|
82
83
|
"react-slick": "^0.31.0",
|
|
83
84
|
"react-table": "^7.8.0",
|
|
84
|
-
"react-tippy": "^1.4.0",
|
|
85
85
|
"slick-carousel": "^1.8.1",
|
|
86
86
|
"yup": "^1.0.0"
|
|
87
87
|
},
|