groovinads-ui 1.2.51 → 1.2.53
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/README.md +26 -20
- package/dist/index.es.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -1
- package/src/components/Dropdowns/DropdownSimpleDatePicker.jsx +18 -23
- package/src/components/Toasts/Toast/ToastCardComponent.jsx +49 -0
- package/src/components/Toasts/ToastComponent.jsx +21 -58
- package/src/stories/ToastComponent.stories.jsx +55 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groovinads-ui",
|
|
3
3
|
"description": "Groovinads UI is a React component library designed exclusively for Groovinads applications. It provides ready-to-use UI elements styled according to Groovinads design guidelines to facilitate rapid development.",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.53",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
7
7
|
"sass",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"build-lib": "rollup -c"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
+
"date-fns": "^4.1.0",
|
|
77
78
|
"react-datepicker": "^7.3.0",
|
|
78
79
|
"react-responsive": "^10.0.0"
|
|
79
80
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react'
|
|
3
|
+
import { format } from 'date-fns';
|
|
3
4
|
|
|
4
5
|
// COMPONENTS
|
|
5
6
|
import { Dropdown } from 'react-bootstrap'
|
|
@@ -17,24 +18,18 @@ export default function DropdownSimpleDatePicker({
|
|
|
17
18
|
overflow = false,
|
|
18
19
|
date,
|
|
19
20
|
setDate,
|
|
20
|
-
|
|
21
|
+
handleClear,
|
|
21
22
|
}) {
|
|
22
|
-
|
|
23
|
+
|
|
23
24
|
const [internalShow, setInternalShow] = useState(!!show);
|
|
24
25
|
const dropdownRef = useRef(null);
|
|
25
|
-
|
|
26
|
-
const handleGlobalToggle = (event) => {
|
|
27
|
-
if (event.detail !== inputLabel) {
|
|
28
|
-
closeDropdown();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
26
|
|
|
32
27
|
const internalToggle = () => {
|
|
33
28
|
const newShowState = !internalShow;
|
|
34
29
|
setInternalShow(newShowState);
|
|
35
30
|
|
|
36
|
-
if (newShowState)
|
|
37
|
-
|
|
31
|
+
if (newShowState) window.dispatchEvent(new CustomEvent('dropdownToggle', { detail: inputLabel }));
|
|
32
|
+
|
|
38
33
|
try {
|
|
39
34
|
onToggle();
|
|
40
35
|
} catch (error) { }
|
|
@@ -54,8 +49,8 @@ export default function DropdownSimpleDatePicker({
|
|
|
54
49
|
}, 200);
|
|
55
50
|
};
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
|
|
53
|
+
const clearDate = () => {
|
|
59
54
|
closeDropdown();
|
|
60
55
|
|
|
61
56
|
if (handleClear) {
|
|
@@ -95,7 +90,7 @@ export default function DropdownSimpleDatePicker({
|
|
|
95
90
|
>
|
|
96
91
|
<span className='dropdown-label'>{inputLabel}</span>
|
|
97
92
|
<span>
|
|
98
|
-
{(date
|
|
93
|
+
{date ? format(new Date(date), 'EEE MMM dd yyyy') : ''}
|
|
99
94
|
</span>
|
|
100
95
|
|
|
101
96
|
<Icon iconName='angle-down' className={'caret'} />
|
|
@@ -142,14 +137,14 @@ export default function DropdownSimpleDatePicker({
|
|
|
142
137
|
}
|
|
143
138
|
|
|
144
139
|
DropdownSimpleDatePicker.propTypes = {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
className: PropTypes.string,
|
|
141
|
+
show: PropTypes.bool,
|
|
142
|
+
setShow: PropTypes.func,
|
|
143
|
+
onToggle: PropTypes.func,
|
|
144
|
+
inputLabel: PropTypes.string,
|
|
145
|
+
overflow: PropTypes.bool,
|
|
146
|
+
date: PropTypes.string,
|
|
147
|
+
setDate: PropTypes.func,
|
|
148
|
+
clearDate: PropTypes.func,
|
|
149
|
+
handleClear: PropTypes.func,
|
|
155
150
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { children, useState } from 'react';
|
|
2
|
+
import Toast from 'react-bootstrap/Toast';
|
|
3
|
+
import { Icon } from '../../Labels';
|
|
4
|
+
|
|
5
|
+
function ToastCardComponent({ variant, autoClose, children, className, position }) {
|
|
6
|
+
const [show, setShow] = useState(true);
|
|
7
|
+
|
|
8
|
+
const toggleShow = () => setShow(!show);
|
|
9
|
+
|
|
10
|
+
const variantIcons = {
|
|
11
|
+
info: 'circle-info',
|
|
12
|
+
success: 'circle-check',
|
|
13
|
+
warning: 'triangle-exclamation',
|
|
14
|
+
error: 'circle-xmark',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
console.log('Hola');
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Toast
|
|
21
|
+
onClose={toggleShow}
|
|
22
|
+
show={show}
|
|
23
|
+
delay={autoClose ? 3500 : null}
|
|
24
|
+
autohide={autoClose}
|
|
25
|
+
className={`${position} ${variant} ${className ? className : ''}`}
|
|
26
|
+
>
|
|
27
|
+
<Toast.Body>
|
|
28
|
+
<div className='toast-wrapper'>
|
|
29
|
+
<div className='toast-type'>
|
|
30
|
+
<Icon
|
|
31
|
+
style={'solid'}
|
|
32
|
+
iconName={variantIcons[variant]}
|
|
33
|
+
scale={1}
|
|
34
|
+
className={'icon'}
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
<span>{children}</span>
|
|
38
|
+
</div>
|
|
39
|
+
{!autoClose && (
|
|
40
|
+
<button className='btn-close' onClick={toggleShow}>
|
|
41
|
+
<Icon style={'solid'} iconName={'xmark'} scale={1} />
|
|
42
|
+
</button>
|
|
43
|
+
)}
|
|
44
|
+
</Toast.Body>
|
|
45
|
+
</Toast>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default ToastCardComponent;
|
|
@@ -1,82 +1,45 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
// BOOTSTRAP
|
|
5
|
-
import Toast from 'react-bootstrap/Toast';
|
|
6
5
|
import { ToastContainer } from 'react-bootstrap';
|
|
7
6
|
|
|
8
7
|
// COMPONENTS
|
|
9
|
-
import
|
|
8
|
+
import ToastCardComponent from './Toast/ToastCardComponent';
|
|
10
9
|
|
|
11
|
-
const ToastComponent = ({
|
|
12
|
-
|
|
13
|
-
autoClose = true,
|
|
14
|
-
position = 'bottom-start',
|
|
15
|
-
children,
|
|
16
|
-
className,
|
|
17
|
-
}) => {
|
|
18
|
-
const [show, setShow] = useState(true);
|
|
10
|
+
const ToastComponent = ({ toast, position = 'bottom-end' }) => {
|
|
11
|
+
const [toastsHistory, setToastsHistory] = useState([]);
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const autohide = autoClose ? true : false;
|
|
24
|
-
|
|
25
|
-
const variantIcons = {
|
|
26
|
-
info: 'circle-info',
|
|
27
|
-
success: 'circle-check',
|
|
28
|
-
warning: 'triangle-exclamation',
|
|
29
|
-
error: 'circle-xmark',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const iconClass = variantIcons[variant];
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (toast) setToastsHistory([...toastsHistory, toast]);
|
|
15
|
+
}, [toast]);
|
|
33
16
|
|
|
34
17
|
return (
|
|
35
18
|
<ToastContainer position={position}>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
iconName={iconClass}
|
|
49
|
-
scale={1}
|
|
50
|
-
className={'icon'}
|
|
51
|
-
/>
|
|
52
|
-
</div>
|
|
53
|
-
<span>{children}</span>
|
|
54
|
-
</div>
|
|
55
|
-
{!autoClose && (
|
|
56
|
-
<button className='btn-close' onClick={toggleShow}>
|
|
57
|
-
<Icon
|
|
58
|
-
style={'solid'}
|
|
59
|
-
iconName={'xmark'}
|
|
60
|
-
scale={1}
|
|
61
|
-
/>
|
|
62
|
-
</button>
|
|
63
|
-
)}
|
|
64
|
-
</Toast.Body>
|
|
65
|
-
</Toast>
|
|
19
|
+
{toastsHistory.map(
|
|
20
|
+
({ variant = 'info', autoClose = true, children, className }, i) => (
|
|
21
|
+
<ToastCardComponent
|
|
22
|
+
variant={variant}
|
|
23
|
+
autoClose={autoClose}
|
|
24
|
+
children={children}
|
|
25
|
+
className={className}
|
|
26
|
+
position={position}
|
|
27
|
+
key={children + variant + i}
|
|
28
|
+
/>
|
|
29
|
+
),
|
|
30
|
+
)}
|
|
66
31
|
</ToastContainer>
|
|
67
32
|
);
|
|
68
33
|
};
|
|
69
34
|
|
|
70
35
|
ToastComponent.propTypes = {
|
|
71
|
-
|
|
72
|
-
autoClose: PropTypes.bool,
|
|
36
|
+
toast: PropTypes.object,
|
|
73
37
|
position: PropTypes.oneOf([
|
|
74
38
|
'top-start',
|
|
75
39
|
'top-end',
|
|
76
40
|
'bottom-start',
|
|
77
41
|
'bottom-end',
|
|
78
42
|
]),
|
|
79
|
-
className: PropTypes.string,
|
|
80
43
|
};
|
|
81
44
|
|
|
82
|
-
export default ToastComponent;
|
|
45
|
+
export default ToastComponent;
|
|
@@ -1,11 +1,62 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import ToastComponent from '../components/Toasts/ToastComponent';
|
|
3
3
|
|
|
4
|
+
import Button from '../components/Button/Button';
|
|
5
|
+
|
|
4
6
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
title: 'Toasts/ToastComponent',
|
|
8
|
+
component: ToastComponent,
|
|
7
9
|
};
|
|
8
10
|
|
|
9
|
-
const Template = (args) =>
|
|
11
|
+
const Template = (args) => {
|
|
12
|
+
|
|
13
|
+
const [selected, setSelected] = useState(null);
|
|
14
|
+
|
|
15
|
+
const toasts = [
|
|
16
|
+
{
|
|
17
|
+
variant: 'info',
|
|
18
|
+
autoClose: true,
|
|
19
|
+
children: 'Se eliminó',
|
|
20
|
+
// className,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
variant: 'success',
|
|
24
|
+
autoClose: true,
|
|
25
|
+
children: 'Se guardó',
|
|
26
|
+
// className,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
variant: 'warning',
|
|
30
|
+
autoClose: true,
|
|
31
|
+
children: 'Se modificó',
|
|
32
|
+
// className,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
variant: 'error',
|
|
36
|
+
autoClose: true,
|
|
37
|
+
children: 'Error',
|
|
38
|
+
// className,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
variant: 'info',
|
|
42
|
+
autoClose: false,
|
|
43
|
+
children: 'No se puede eliminar',
|
|
44
|
+
// className,
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
const pushToast = () => {
|
|
49
|
+
setSelected(toasts[Math.floor(Math.random() * toasts.length)]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<Button onClick={pushToast}>Nuevo toast</Button>
|
|
55
|
+
<ToastComponent toast={selected} {...args}>
|
|
56
|
+
ToastComponent
|
|
57
|
+
</ToastComponent>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
10
61
|
|
|
11
|
-
export const Default = Template.bind({});
|
|
62
|
+
export const Default = Template.bind({});
|