@growy/strapi-plugin-encrypted-field 2.0.8 → 2.0.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { Field, IconButton } from '@strapi/design-system';
|
|
4
|
+
import { useNotification } from '@strapi/strapi/admin';
|
|
4
5
|
import { Eye, EyeStriked, Duplicate } from '@strapi/icons';
|
|
5
6
|
|
|
6
7
|
const Input = (props) => {
|
|
@@ -19,6 +20,7 @@ const Input = (props) => {
|
|
|
19
20
|
} = props;
|
|
20
21
|
|
|
21
22
|
const { formatMessage } = useIntl();
|
|
23
|
+
const { toggleNotification } = useNotification();
|
|
22
24
|
const [isVisible, setIsVisible] = useState(false);
|
|
23
25
|
|
|
24
26
|
const handleChange = (e) => {
|
|
@@ -33,7 +35,18 @@ const Input = (props) => {
|
|
|
33
35
|
|
|
34
36
|
const handleCopy = async () => {
|
|
35
37
|
if (value) {
|
|
36
|
-
|
|
38
|
+
try {
|
|
39
|
+
await navigator.clipboard.writeText(value);
|
|
40
|
+
toggleNotification({
|
|
41
|
+
type: 'success',
|
|
42
|
+
message: 'Copiado al portapapeles',
|
|
43
|
+
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
toggleNotification({
|
|
46
|
+
type: 'danger',
|
|
47
|
+
message: 'Error al copiar',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
};
|
|
39
52
|
|
|
@@ -76,6 +89,7 @@ const Input = (props) => {
|
|
|
76
89
|
onClick={toggleVisibility}
|
|
77
90
|
label={isVisible ? 'Ocultar' : 'Mostrar'}
|
|
78
91
|
disabled={disabled}
|
|
92
|
+
variant="ghost"
|
|
79
93
|
>
|
|
80
94
|
{isVisible ? <EyeStriked /> : <Eye />}
|
|
81
95
|
</IconButton>
|
|
@@ -83,6 +97,7 @@ const Input = (props) => {
|
|
|
83
97
|
onClick={handleCopy}
|
|
84
98
|
label="Copiar"
|
|
85
99
|
disabled={disabled || !value}
|
|
100
|
+
variant="ghost"
|
|
86
101
|
>
|
|
87
102
|
<Duplicate />
|
|
88
103
|
</IconButton>
|