siam-ui-utils 2.2.7 → 2.2.9

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/index.d.ts CHANGED
@@ -82,4 +82,7 @@ declare module 'siam-ui-utils' {
82
82
 
83
83
  //VIDEO CALL ROOM
84
84
  export function WhereByRoom(props);
85
+
86
+ //COPY LINK
87
+ export function CopyLink(props);
85
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siam-ui-utils",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
4
4
  "keywords": [
5
5
  "ampf-react",
6
6
  "ampf-utils",
package/src/App.jsx CHANGED
@@ -11,6 +11,7 @@ import './index.css';
11
11
  import './App.css';
12
12
  import './assets/css/vendor/bootstrap.min.css';
13
13
  import { WhereByRoom } from './where-by-room';
14
+ import CopyLink from './copy-link';
14
15
 
15
16
  const App = () => {
16
17
  const [open, setOpen] = useState('0');
@@ -110,6 +111,12 @@ const App = () => {
110
111
  />
111
112
  </AccordionBody>
112
113
  </AccordionItem>
114
+ <AccordionItem>
115
+ <AccordionHeader targetId="2">Copy-Link</AccordionHeader>
116
+ <AccordionBody accordionId="2">
117
+ <CopyLink link="https://linkdepruebaparaelcopylink.com" />
118
+ </AccordionBody>
119
+ </AccordionItem>
113
120
  </Accordion>
114
121
  </div>
115
122
  );
@@ -0,0 +1,61 @@
1
+ import { useState } from 'react';
2
+ import { Button } from 'reactstrap';
3
+ import './styles.scss';
4
+
5
+ const copyToClipboard = async (text) => {
6
+ try {
7
+ if (!text) return false;
8
+ if (navigator.clipboard?.writeText) {
9
+ await navigator.clipboard.writeText(text);
10
+ return true;
11
+ }
12
+ const ta = document.createElement('textarea');
13
+ ta.value = text;
14
+ ta.style.position = 'fixed';
15
+ ta.style.left = '-9999px';
16
+ document.body.appendChild(ta);
17
+ ta.select();
18
+ document.execCommand('copy');
19
+ document.body.removeChild(ta);
20
+ return true;
21
+ } catch {
22
+ return false;
23
+ }
24
+ };
25
+
26
+ const CopyLink = ({ link }) => {
27
+ const [copied, setCopied] = useState(false);
28
+
29
+ const handleCopy = async () => {
30
+ await copyToClipboard(link);
31
+ setCopied(true);
32
+ setTimeout(() => setCopied(false), 2000);
33
+ };
34
+ return (
35
+ <span className="copy-link-container">
36
+ <span
37
+ title={link}
38
+ className={`copy-link-text${copied ? ' copied' : ''}`}
39
+ onClick={handleCopy}
40
+ >
41
+ {link}
42
+ </span>
43
+ <Button
44
+ color="link"
45
+ size="sm"
46
+ onClick={handleCopy}
47
+ title="Copiar link"
48
+ className="copy-link-btn"
49
+ >
50
+ 📋
51
+ </Button>
52
+ {copied && (
53
+ <span className="copy-link-copied">
54
+ ¡Copiado!
55
+ </span>
56
+ )}
57
+ </span>
58
+ );
59
+ };
60
+
61
+ export default CopyLink;
@@ -0,0 +1,39 @@
1
+ .copy-link-container {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: 8px;
5
+ width: 100%;
6
+ position: relative;
7
+ }
8
+
9
+ .copy-link-text {
10
+ width: 90%;
11
+ overflow: hidden;
12
+ text-overflow: ellipsis;
13
+ white-space: nowrap;
14
+ display: inline-block;
15
+ vertical-align: middle;
16
+ cursor: pointer;
17
+ transition: color 0.2s;
18
+ font-weight: 500;
19
+ color: #007bff;
20
+
21
+ &.copied {
22
+ color: #28a745;
23
+ }
24
+ }
25
+
26
+ .copy-link-btn {
27
+ padding: 0;
28
+ font-size: 16px;
29
+ }
30
+
31
+ .copy-link-copied {
32
+ color: #28a745;
33
+ font-size: 13px;
34
+ margin-left: 8px;
35
+ position: absolute;
36
+ top: 100%;
37
+ left: 0;
38
+ white-space: nowrap;
39
+ }
package/src/index.js CHANGED
@@ -7,4 +7,4 @@ export * from './CustomSelectInput';
7
7
  export * from './tomar-foto';
8
8
  export * as IntlMessages from './IntlMessages';
9
9
  export * from './where-by-room';
10
-
10
+ export * from './copy-link';