groovinads-ui 1.2.50 → 1.2.51
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 +3 -3
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/Dropdowns/DropdownSimpleDatePicker.jsx +33 -11
- package/src/stories/DropdownComponent.stories.jsx +1 -1
- package/src/stories/DropdownSimpleDatePicker.stories.jsx +36 -13
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.51",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
7
7
|
"sass",
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import React, { useEffect, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
// HOOKS
|
|
5
|
-
import { useTextFormatter } from '../../hooks';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
6
3
|
|
|
7
4
|
// COMPONENTS
|
|
8
5
|
import { Dropdown } from 'react-bootstrap'
|
|
@@ -22,12 +19,22 @@ export default function DropdownSimpleDatePicker({
|
|
|
22
19
|
setDate,
|
|
23
20
|
handleClear,
|
|
24
21
|
}) {
|
|
25
|
-
|
|
22
|
+
|
|
26
23
|
const [internalShow, setInternalShow] = useState(!!show);
|
|
27
|
-
|
|
24
|
+
const dropdownRef = useRef(null);
|
|
25
|
+
|
|
26
|
+
const handleGlobalToggle = (event) => {
|
|
27
|
+
if (event.detail !== inputLabel) {
|
|
28
|
+
closeDropdown();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
28
31
|
|
|
29
32
|
const internalToggle = () => {
|
|
30
|
-
|
|
33
|
+
const newShowState = !internalShow;
|
|
34
|
+
setInternalShow(newShowState);
|
|
35
|
+
|
|
36
|
+
if (newShowState) window.dispatchEvent(new CustomEvent('dropdownToggle', { detail: inputLabel }));
|
|
37
|
+
|
|
31
38
|
try {
|
|
32
39
|
onToggle();
|
|
33
40
|
} catch (error) { }
|
|
@@ -41,22 +48,36 @@ export default function DropdownSimpleDatePicker({
|
|
|
41
48
|
};
|
|
42
49
|
|
|
43
50
|
const updateDateFilters = (newDate) => {
|
|
51
|
+
setDate(newDate?.toString());
|
|
44
52
|
setTimeout(() => {
|
|
45
|
-
setDate(newDate?.toString());
|
|
46
53
|
closeDropdown();
|
|
47
|
-
},
|
|
54
|
+
}, 200);
|
|
48
55
|
};
|
|
49
56
|
|
|
50
57
|
|
|
51
58
|
const clearDate = () => {
|
|
59
|
+
closeDropdown();
|
|
60
|
+
|
|
52
61
|
if (handleClear) {
|
|
53
62
|
handleClear()
|
|
54
63
|
return
|
|
55
64
|
}
|
|
56
65
|
setDate(null);
|
|
57
|
-
closeDropdown();
|
|
58
66
|
}
|
|
59
67
|
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const handleClickOutside = (event) => {
|
|
70
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
71
|
+
closeDropdown();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
document.addEventListener('click', handleClickOutside);
|
|
76
|
+
return () => {
|
|
77
|
+
document.removeEventListener('click', handleClickOutside);
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
60
81
|
useEffect(() => {
|
|
61
82
|
setInternalShow(!!show);
|
|
62
83
|
}, [show]);
|
|
@@ -65,6 +86,7 @@ export default function DropdownSimpleDatePicker({
|
|
|
65
86
|
<Dropdown
|
|
66
87
|
show={internalShow}
|
|
67
88
|
className={className}
|
|
89
|
+
ref={dropdownRef}
|
|
68
90
|
>
|
|
69
91
|
<Dropdown.Toggle
|
|
70
92
|
variant='toggle-filter'
|
|
@@ -76,7 +98,7 @@ export default function DropdownSimpleDatePicker({
|
|
|
76
98
|
{(date || '').toString().split('00')[0]}
|
|
77
99
|
</span>
|
|
78
100
|
|
|
79
|
-
<Icon iconName='angle-down' />
|
|
101
|
+
<Icon iconName='angle-down' className={'caret'} />
|
|
80
102
|
|
|
81
103
|
</Dropdown.Toggle>
|
|
82
104
|
|
|
@@ -9,22 +9,45 @@ export default {
|
|
|
9
9
|
const Template = (args) => {
|
|
10
10
|
const [show, setShow] = useState(false);
|
|
11
11
|
|
|
12
|
-
const [
|
|
13
|
-
|
|
14
|
-
const clearData = () => {
|
|
15
|
-
console.log('afuera');
|
|
16
|
-
}
|
|
12
|
+
const [startDate, setStartDate] = useState('');
|
|
13
|
+
const [endDate, setEndDate] = useState('');
|
|
17
14
|
|
|
18
15
|
return (
|
|
16
|
+
// <>
|
|
17
|
+
// <button onClick={() => setShow(!show)}>Toggle</button>
|
|
18
|
+
// <div className='col-2'>
|
|
19
|
+
// <DropdownSimpleDatePicker
|
|
20
|
+
// {...args}
|
|
21
|
+
// dateFrom={dateFrom}
|
|
22
|
+
// setDateFrom={setDateFrom}
|
|
23
|
+
// date={dateTo}
|
|
24
|
+
// setDate={setDateTo}
|
|
25
|
+
// />
|
|
26
|
+
// </div>
|
|
27
|
+
// </>
|
|
28
|
+
|
|
19
29
|
<>
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
<div className='d-flex justify-content-between mt-3'>
|
|
31
|
+
{/* DROPDOWN TO TEST THE handleGlobalToggle */}
|
|
32
|
+
|
|
33
|
+
<div className='col-3'>
|
|
34
|
+
<DropdownSimpleDatePicker
|
|
35
|
+
{...args}
|
|
36
|
+
inputLabel="Start Date"
|
|
37
|
+
date={startDate}
|
|
38
|
+
setDate={setStartDate}
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div className='col-3'>
|
|
43
|
+
<DropdownSimpleDatePicker
|
|
44
|
+
{...args}
|
|
45
|
+
inputLabel="End Date"
|
|
46
|
+
date={endDate}
|
|
47
|
+
setDate={setEndDate}
|
|
48
|
+
handleClear={() => {console.log('Aqui');}}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
28
51
|
</div>
|
|
29
52
|
</>
|
|
30
53
|
);
|