groovinads-ui 1.2.49 → 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 +32 -27
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/Dropdowns/DropdownSimpleDatePicker.jsx +131 -112
- package/src/components/index.js +49 -0
- package/src/index.js +5 -22
- package/src/stories/DropdownComponent.stories.jsx +1 -1
- package/src/stories/DropdownSimpleDatePicker.stories.jsx +36 -12
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'
|
|
@@ -12,116 +9,136 @@ import DatePicker from 'react-datepicker';
|
|
|
12
9
|
|
|
13
10
|
|
|
14
11
|
export default function DropdownSimpleDatePicker({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
className = '',
|
|
13
|
+
show,
|
|
14
|
+
setShow,
|
|
15
|
+
onToggle,
|
|
16
|
+
inputLabel = 'period',
|
|
17
|
+
overflow = false,
|
|
18
|
+
date,
|
|
19
|
+
setDate,
|
|
20
|
+
handleClear,
|
|
23
21
|
}) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
|
|
23
|
+
const [internalShow, setInternalShow] = useState(!!show);
|
|
24
|
+
const dropdownRef = useRef(null);
|
|
25
|
+
|
|
26
|
+
const handleGlobalToggle = (event) => {
|
|
27
|
+
if (event.detail !== inputLabel) {
|
|
28
|
+
closeDropdown();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const internalToggle = () => {
|
|
33
|
+
const newShowState = !internalShow;
|
|
34
|
+
setInternalShow(newShowState);
|
|
35
|
+
|
|
36
|
+
if (newShowState) window.dispatchEvent(new CustomEvent('dropdownToggle', { detail: inputLabel }));
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
onToggle();
|
|
40
|
+
} catch (error) { }
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const closeDropdown = () => {
|
|
44
|
+
setInternalShow(false);
|
|
45
|
+
try {
|
|
46
|
+
setShow(false);
|
|
47
|
+
} catch (error) { }
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const updateDateFilters = (newDate) => {
|
|
51
|
+
setDate(newDate?.toString());
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
closeDropdown();
|
|
54
|
+
}, 200);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
|
|
56
58
|
const clearDate = () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
59
|
+
closeDropdown();
|
|
60
|
+
|
|
61
|
+
if (handleClear) {
|
|
62
|
+
handleClear()
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
setDate(null);
|
|
66
|
+
}
|
|
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
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
setInternalShow(!!show);
|
|
83
|
+
}, [show]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Dropdown
|
|
87
|
+
show={internalShow}
|
|
88
|
+
className={className}
|
|
89
|
+
ref={dropdownRef}
|
|
90
|
+
>
|
|
91
|
+
<Dropdown.Toggle
|
|
92
|
+
variant='toggle-filter'
|
|
93
|
+
onClick={internalToggle}
|
|
94
|
+
className={`btn-input w-100`}
|
|
95
|
+
>
|
|
96
|
+
<span className='dropdown-label'>{inputLabel}</span>
|
|
97
|
+
<span>
|
|
98
|
+
{(date || '').toString().split('00')[0]}
|
|
99
|
+
</span>
|
|
100
|
+
|
|
101
|
+
<Icon iconName='angle-down' className={'caret'} />
|
|
102
|
+
|
|
103
|
+
</Dropdown.Toggle>
|
|
104
|
+
|
|
105
|
+
<Dropdown.Menu
|
|
106
|
+
popperConfig={
|
|
107
|
+
overflow
|
|
108
|
+
? {
|
|
109
|
+
strategy: 'fixed',
|
|
110
|
+
onFirstUpdate: () =>
|
|
111
|
+
window.dispatchEvent(new CustomEvent('scroll')),
|
|
112
|
+
}
|
|
113
|
+
: undefined
|
|
114
|
+
}
|
|
115
|
+
>
|
|
116
|
+
<Dropdown.Item as={'div'}>
|
|
117
|
+
|
|
118
|
+
<DatePicker
|
|
119
|
+
className='form-control form-search'
|
|
120
|
+
selected={date || ''}
|
|
121
|
+
onChange={updateDateFilters}
|
|
122
|
+
startDate={date || ''}
|
|
123
|
+
monthsShown={1}
|
|
124
|
+
inline
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<div className='px-2 w-100'>
|
|
128
|
+
<Button
|
|
129
|
+
onClick={clearDate}
|
|
130
|
+
icon='calendar-circle-minus'
|
|
131
|
+
size='xs'
|
|
132
|
+
variant='terciary'
|
|
133
|
+
className='w-100'
|
|
134
|
+
>
|
|
135
|
+
Clear
|
|
136
|
+
</Button>
|
|
137
|
+
</div>
|
|
138
|
+
</Dropdown.Item>
|
|
139
|
+
</Dropdown.Menu>
|
|
140
|
+
</Dropdown>
|
|
141
|
+
)
|
|
125
142
|
}
|
|
126
143
|
|
|
127
144
|
DropdownSimpleDatePicker.propTypes = {
|
|
@@ -133,4 +150,6 @@ DropdownSimpleDatePicker.propTypes = {
|
|
|
133
150
|
overflow: PropTypes.bool,
|
|
134
151
|
date: PropTypes.string,
|
|
135
152
|
setDate: PropTypes.func,
|
|
153
|
+
clearDate: PropTypes.func,
|
|
154
|
+
handleClear: PropTypes.func,
|
|
136
155
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Buttons
|
|
2
|
+
import Button from "./Button/Button";
|
|
3
|
+
|
|
4
|
+
// Dropdowns
|
|
5
|
+
import { DropdownComponent, DropdownMultiSelect, DropdownDatePicker, DropdownFilter, DropdownSimpleDatePicker } from './Dropdowns';
|
|
6
|
+
|
|
7
|
+
// Inputs
|
|
8
|
+
import { Checkbox, Input, Radio, Switch, Textarea } from './Inputs';
|
|
9
|
+
|
|
10
|
+
// Labels
|
|
11
|
+
import { Alert, Icon, LoginSource, PillComponent, Spinner, StatusIcon } from './Labels';
|
|
12
|
+
|
|
13
|
+
// Toasts
|
|
14
|
+
import {ToastComponent, ToastProgress} from './Toasts';
|
|
15
|
+
|
|
16
|
+
// Navigation
|
|
17
|
+
import {Navbar, Stepper, Tabnav, Sidebar} from './Navigation';
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
// Buttons
|
|
21
|
+
Button,
|
|
22
|
+
// Dropdowns
|
|
23
|
+
DropdownComponent,
|
|
24
|
+
DropdownFilter,
|
|
25
|
+
DropdownMultiSelect,
|
|
26
|
+
DropdownSimpleDatePicker,
|
|
27
|
+
DropdownDatePicker,
|
|
28
|
+
// Inputs
|
|
29
|
+
Checkbox,
|
|
30
|
+
Input,
|
|
31
|
+
Radio,
|
|
32
|
+
Switch,
|
|
33
|
+
Textarea,
|
|
34
|
+
// Labels
|
|
35
|
+
Alert,
|
|
36
|
+
Icon,
|
|
37
|
+
LoginSource,
|
|
38
|
+
PillComponent,
|
|
39
|
+
Spinner,
|
|
40
|
+
StatusIcon,
|
|
41
|
+
// Toasts
|
|
42
|
+
ToastComponent,
|
|
43
|
+
ToastProgress,
|
|
44
|
+
// Navigation
|
|
45
|
+
Navbar,
|
|
46
|
+
Stepper,
|
|
47
|
+
Tabnav,
|
|
48
|
+
Sidebar
|
|
49
|
+
}
|
package/src/index.js
CHANGED
|
@@ -2,36 +2,19 @@
|
|
|
2
2
|
import Button from "./components/Button/Button";
|
|
3
3
|
|
|
4
4
|
// Dropdowns
|
|
5
|
-
import DropdownComponent from './components/Dropdowns
|
|
6
|
-
import DropdownFilter from './components/Dropdowns/DropdownFilter';
|
|
7
|
-
import DropdownMultiSelect from './components/Dropdowns/DropdownMultiSelect';
|
|
8
|
-
import DropdownDatePicker from './components/Dropdowns/DropdownsDatePicker/DropdownDatePicker';
|
|
9
|
-
import DropdownSimpleDatePicker from './components/Dropdowns/DropdownSimpleDatePicker';
|
|
5
|
+
import {DropdownComponent, DropdownFilter, DropdownMultiSelect, DropdownDatePicker, DropdownSimpleDatePicker} from './components/Dropdowns';
|
|
10
6
|
|
|
11
7
|
// Inputs
|
|
12
|
-
import Checkbox from './components/Inputs
|
|
13
|
-
import Input from './components/Inputs/Input';
|
|
14
|
-
import Radio from './components/Inputs/Radio';
|
|
15
|
-
import Switch from './components/Inputs/Switch';
|
|
16
|
-
import Textarea from './components/Inputs/Textarea';
|
|
8
|
+
import {Checkbox, Input, Radio, Switch, Textarea} from './components/Inputs';
|
|
17
9
|
|
|
18
10
|
// Labels
|
|
19
|
-
import Alert from './components/Labels
|
|
20
|
-
import Icon from './components/Labels/Icon';
|
|
21
|
-
import LoginSource from './components/Labels/LoginSource';
|
|
22
|
-
import PillComponent from './components/Labels/PillComponent';
|
|
23
|
-
import Spinner from './components/Labels/Spinner';
|
|
24
|
-
import StatusIcon from './components/Labels/StatusIcon';
|
|
11
|
+
import {Alert, Icon, LoginSource, PillComponent, Spinner, StatusIcon} from './components/Labels';
|
|
25
12
|
|
|
26
13
|
// Toasts
|
|
27
|
-
import ToastComponent from './components/Toasts
|
|
28
|
-
import ToastProgress from './components/Toasts/ToastProgress';
|
|
14
|
+
import {ToastComponent, ToastProgress} from './components/Toasts';
|
|
29
15
|
|
|
30
16
|
// Navigation
|
|
31
|
-
import Navbar from './components/Navigation
|
|
32
|
-
import Stepper from './components/Navigation/Stepper';
|
|
33
|
-
import Tabnav from './components/Navigation/Tabnav';
|
|
34
|
-
import Sidebar from './components/Navigation/Sidebar';
|
|
17
|
+
import {Navbar, Stepper, Tabnav, Sidebar} from './components/Navigation';
|
|
35
18
|
|
|
36
19
|
export {
|
|
37
20
|
// Buttons
|
|
@@ -9,21 +9,45 @@ export default {
|
|
|
9
9
|
const Template = (args) => {
|
|
10
10
|
const [show, setShow] = useState(false);
|
|
11
11
|
|
|
12
|
-
const [
|
|
13
|
-
const [
|
|
14
|
-
|
|
12
|
+
const [startDate, setStartDate] = useState('');
|
|
13
|
+
const [endDate, setEndDate] = useState('');
|
|
15
14
|
|
|
16
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
|
+
|
|
17
29
|
<>
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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>
|
|
27
51
|
</div>
|
|
28
52
|
</>
|
|
29
53
|
);
|