@growy/strapi-plugin-encrypted-field 1.2.0 → 1.2.2
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,7 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import { Field,
|
|
4
|
-
import { Eye, EyeStriked, Duplicate, Check } from '@strapi/icons';
|
|
3
|
+
import { Field, Typography } from '@strapi/design-system';
|
|
5
4
|
|
|
6
5
|
const Input = (props) => {
|
|
7
6
|
const {
|
|
@@ -18,27 +17,13 @@ const Input = (props) => {
|
|
|
18
17
|
} = props;
|
|
19
18
|
|
|
20
19
|
const { formatMessage } = useIntl();
|
|
21
|
-
const [showValue, setShowValue] = useState(false);
|
|
22
|
-
const [copied, setCopied] = useState(false);
|
|
23
|
-
|
|
24
|
-
const handleCopy = async () => {
|
|
25
|
-
if (value) {
|
|
26
|
-
try {
|
|
27
|
-
await navigator.clipboard.writeText(value);
|
|
28
|
-
setCopied(true);
|
|
29
|
-
setTimeout(() => setCopied(false), 2000);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.error('Error al copiar:', err);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
20
|
|
|
36
21
|
const handleChange = (e) => {
|
|
37
22
|
onChange({
|
|
38
23
|
target: {
|
|
39
24
|
name,
|
|
40
25
|
value: e.target.value,
|
|
41
|
-
type: attribute?.type || '
|
|
26
|
+
type: attribute?.type || 'string',
|
|
42
27
|
},
|
|
43
28
|
});
|
|
44
29
|
};
|
|
@@ -53,29 +38,11 @@ const Input = (props) => {
|
|
|
53
38
|
hint={description?.id ? formatMessage(description) : description}
|
|
54
39
|
required={required}
|
|
55
40
|
>
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
</Field.Label>
|
|
60
|
-
<Flex gap={2}>
|
|
61
|
-
<IconButton
|
|
62
|
-
label={showValue ? 'Ocultar valor' : 'Mostrar valor'}
|
|
63
|
-
icon={showValue ? <EyeStriked /> : <Eye />}
|
|
64
|
-
onClick={() => setShowValue(!showValue)}
|
|
65
|
-
variant="ghost"
|
|
66
|
-
disabled={!value}
|
|
67
|
-
/>
|
|
68
|
-
<IconButton
|
|
69
|
-
label={copied ? 'Copiado' : 'Copiar valor'}
|
|
70
|
-
icon={copied ? <Check /> : <Duplicate />}
|
|
71
|
-
onClick={handleCopy}
|
|
72
|
-
variant="ghost"
|
|
73
|
-
disabled={!value}
|
|
74
|
-
/>
|
|
75
|
-
</Flex>
|
|
76
|
-
</Flex>
|
|
41
|
+
<Field.Label action={labelAction}>
|
|
42
|
+
{intlLabel?.id ? formatMessage(intlLabel) : intlLabel} 🔒
|
|
43
|
+
</Field.Label>
|
|
77
44
|
<Field.Input
|
|
78
|
-
type=
|
|
45
|
+
type="password"
|
|
79
46
|
placeholder={formatMessage({
|
|
80
47
|
id: 'encrypted-field.placeholder',
|
|
81
48
|
defaultMessage: 'Ingresa el texto a cifrar...',
|
|
@@ -84,14 +51,12 @@ const Input = (props) => {
|
|
|
84
51
|
onChange={handleChange}
|
|
85
52
|
disabled={disabled}
|
|
86
53
|
/>
|
|
87
|
-
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)}
|
|
94
|
-
</Flex>
|
|
54
|
+
{charCount > 0 && (
|
|
55
|
+
<Typography variant="pi" textColor="neutral600" marginTop={1}>
|
|
56
|
+
{charCount} {charCount === 1 ? 'carácter' : 'caracteres'}
|
|
57
|
+
</Typography>
|
|
58
|
+
)}
|
|
59
|
+
<Field.Hint />
|
|
95
60
|
<Field.Error />
|
|
96
61
|
</Field.Root>
|
|
97
62
|
);
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
const EncryptedIcon = () => (
|
|
4
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="16" height="16">
|
|
5
|
-
<rect width="31" height="23" x="0.5" y="4.5" fill="#EAFBE7" stroke="#C6F0C2" rx="2.5" />
|
|
6
|
-
<path fill="#328048" d="M13.679 11.18a.75.75 0 0 0-1.358 0l-4 8.5a.75.75 0 0 0 1.357.64l.974-2.07h4.695l.974 2.07a.75.75 0 1 0 1.358-.64zm-2.32 5.57 1.64-3.489 1.643 3.489zm9.14-3c-.865 0-1.547.241-2.027.717a.749.749 0 1 0 1.056 1.063c.188-.187.516-.283.972-.283.584 0 1.074.323 1.21.757a3 3 0 0 0-1.21-.254c-1.516 0-2.75 1.121-2.75 2.5s1.234 2.5 2.75 2.5c.479.001.95-.114 1.375-.336A.75.75 0 0 0 23.25 20v-3.75c0-1.379-1.234-2.5-2.75-2.5m0 5.5c-.687 0-1.25-.449-1.25-1s.563-1 1.25-1 1.25.449 1.25 1-.562 1-1.25 1" />
|
|
7
|
-
</svg>
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
export default EncryptedIcon;
|