@growy/strapi-plugin-encrypted-field 2.0.7 → 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
- import { Field, Flex, IconButton } from '@strapi/design-system';
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
- await navigator.clipboard.writeText(value);
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
 
@@ -55,30 +68,41 @@ const Input = (props) => {
55
68
  <Field.Label action={labelAction}>
56
69
  {label}
57
70
  </Field.Label>
58
- <Flex gap={2}>
71
+ <div style={{ position: 'relative' }}>
59
72
  <Field.Input
60
73
  type={isVisible ? 'text' : 'password'}
61
74
  placeholder={placeholder}
62
75
  value={value}
63
76
  onChange={handleChange}
64
77
  disabled={disabled}
65
- style={{ flex: 1 }}
78
+ style={{ paddingRight: '80px' }}
66
79
  />
67
- <IconButton
68
- onClick={toggleVisibility}
69
- label={isVisible ? 'Ocultar' : 'Mostrar'}
70
- disabled={disabled}
71
- >
72
- {isVisible ? <EyeStriked /> : <Eye />}
73
- </IconButton>
74
- <IconButton
75
- onClick={handleCopy}
76
- label="Copiar"
77
- disabled={disabled || !value}
78
- >
79
- <Duplicate />
80
- </IconButton>
81
- </Flex>
80
+ <div style={{
81
+ position: 'absolute',
82
+ right: '8px',
83
+ top: '50%',
84
+ transform: 'translateY(-50%)',
85
+ display: 'flex',
86
+ gap: '4px'
87
+ }}>
88
+ <IconButton
89
+ onClick={toggleVisibility}
90
+ label={isVisible ? 'Ocultar' : 'Mostrar'}
91
+ disabled={disabled}
92
+ variant="ghost"
93
+ >
94
+ {isVisible ? <EyeStriked /> : <Eye />}
95
+ </IconButton>
96
+ <IconButton
97
+ onClick={handleCopy}
98
+ label="Copiar"
99
+ disabled={disabled || !value}
100
+ variant="ghost"
101
+ >
102
+ <Duplicate />
103
+ </IconButton>
104
+ </div>
105
+ </div>
82
106
  <Field.Hint />
83
107
  <Field.Error />
84
108
  </Field.Root>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growy/strapi-plugin-encrypted-field",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "Campo personalizado de texto cifrado para Strapi",
5
5
  "strapi": {
6
6
  "name": "encrypted-field",