groovinads-ui 1.2.63 → 1.2.65

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/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.63",
4
+ "version": "1.2.65",
5
5
  "keywords": [
6
6
  "css",
7
7
  "sass",
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Dropdown from 'react-bootstrap/Dropdown';
4
- import { DropdownItem } from 'react-bootstrap';
5
4
 
6
5
  const DropdownComponent = ({
7
6
  autoClose = false,
@@ -25,7 +24,7 @@ const DropdownComponent = ({
25
24
  // Cierra el dropdown solo si autoClose es 'true' o 'inside'
26
25
  if (autoClose === true || autoClose === 'inside') {
27
26
  setInnerShow(false);
28
- setShow(false);
27
+ if (setShow) setShow(false);
29
28
  }
30
29
  };
31
30
 
@@ -40,8 +39,7 @@ const DropdownComponent = ({
40
39
  },
41
40
  });
42
41
 
43
- const modifiedMenu = React.cloneElement(Menu,
44
- {
42
+ const modifiedMenu = React.cloneElement(Menu, {
45
43
  as: 'ul',
46
44
  align,
47
45
  className: fullWidth ? 'w-100' : '',
@@ -65,19 +63,21 @@ const DropdownComponent = ({
65
63
  },
66
64
  }),
67
65
  )
68
- : React.cloneElement(Menu.props.children, {
69
- as: 'li',
70
- key: `${child}${i}`,
71
- onClick: () => {
72
- if (
73
- Menu.props.children.props &&
74
- Menu.props.children.props.onClick
75
- ) {
76
- Menu.props.children.props.onClick();
77
- }
78
- onAutoclose();
79
- },
80
- }),
66
+ : Menu.props.children.map((child, i) =>
67
+ React.cloneElement(Menu.props.children, {
68
+ as: 'li',
69
+ key: `${child}${i}`,
70
+ onClick: () => {
71
+ if (
72
+ Menu.props.children.props &&
73
+ Menu.props.children.props.onClick
74
+ ) {
75
+ Menu.props.children.props.onClick();
76
+ }
77
+ onAutoclose();
78
+ },
79
+ }),
80
+ ),
81
81
  });
82
82
 
83
83
  useEffect(() => {
@@ -24,6 +24,18 @@ export default function DropdownSimpleDatePicker({
24
24
  const [internalShow, setInternalShow] = useState(!!show);
25
25
  const dropdownRef = useRef(null);
26
26
 
27
+ const formatDate = (date) => {
28
+ if (!date) return null;
29
+
30
+ if (date instanceof Date) return date;
31
+
32
+ if (typeof date === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(date)) {
33
+ return new Date(`${date}T00:00:00`);
34
+ }
35
+
36
+ return new Date(date);
37
+ };
38
+
27
39
  const internalToggle = () => {
28
40
  const newShowState = !internalShow;
29
41
  setInternalShow(newShowState);
@@ -78,7 +90,6 @@ export default function DropdownSimpleDatePicker({
78
90
  useEffect(() => {
79
91
  setInternalShow(!!show);
80
92
  }, [show]);
81
-
82
93
  return (
83
94
  <Dropdown show={internalShow} className={className} ref={dropdownRef}>
84
95
  <Dropdown.Toggle
@@ -111,8 +122,14 @@ export default function DropdownSimpleDatePicker({
111
122
  startDate={date || ''}
112
123
  monthsShown={1}
113
124
  inline
114
- minDate={minDate}
115
- maxDate={maxDate}
125
+ minDate={formatDate(minDate)}
126
+ maxDate={formatDate(maxDate)}
127
+ dayClassName={(date) =>
128
+ (minDate && date < minDate) ||
129
+ (maxDate && date > maxDate && date !== formatDate(maxDate))
130
+ ? 'react-datepicker__day--disabled'
131
+ : ''
132
+ }
116
133
  />
117
134
 
118
135
  <div className='px-2 w-100'>
@@ -143,6 +160,6 @@ DropdownSimpleDatePicker.propTypes = {
143
160
  setDate: PropTypes.func,
144
161
  clearDate: PropTypes.func,
145
162
  handleClear: PropTypes.func,
146
- minDate: PropTypes.object,
147
- maxDate: PropTypes.object,
163
+ minDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
164
+ maxDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
148
165
  };
@@ -33,6 +33,7 @@ const InputEmail = ({
33
33
  const fetchNotifications = async () => {
34
34
  const resp = await ComponentsService.getInfo(apiGetEmail);
35
35
  setNotifications(resp || []);
36
+
36
37
  };
37
38
 
38
39
  // POST, Receives a list of emails
@@ -92,7 +93,11 @@ const InputEmail = ({
92
93
  };
93
94
 
94
95
  useEffect(() => {
95
- if (showModal) fetchNotifications();
96
+ if (showModal) {
97
+ fetchNotifications();
98
+ } else if(notifications.length){
99
+ setNotifications([]);
100
+ }
96
101
  }, [showModal]);
97
102
  return (
98
103
  <>
@@ -157,7 +162,7 @@ InputEmail.propTypes = {
157
162
  apiGetEmail: PropTypes.string.isRequired,
158
163
  apiPostEmail: PropTypes.string.isRequired,
159
164
  apiDeleteEmail: PropTypes.string.isRequired,
160
- titleList: PropTypes.string.isRequired,
165
+ titleList: PropTypes.string,
161
166
  label: PropTypes.string,
162
167
  textButton: PropTypes.string,
163
168
  textError: PropTypes.string,
@@ -1,6 +1,7 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import DropdownSimpleDatePicker from '../components/Dropdowns/DropdownSimpleDatePicker';
3
3
 
4
+
4
5
  export default {
5
6
  title: 'Dropdown/DropdownSimpleDatePicker',
6
7
  component: DropdownSimpleDatePicker,
@@ -15,30 +16,35 @@ const Template = (args) => {
15
16
  return (
16
17
  <>
17
18
  <div className='d-flex justify-content-between mt-3'>
18
- {/* DROPDOWN TO TEST THE handleGlobalToggle */}
19
- <div className='col-3'>
19
+ <div className='col-3 mb-3'>
20
+ {/* MAX Y MIN POR PARAMS STATE */}
20
21
  <DropdownSimpleDatePicker
21
22
  {...args}
22
23
  inputLabel='Start Date'
23
24
  date={startDate}
24
25
  setDate={setStartDate}
26
+ maxDate={endDate}
25
27
  />
26
- </div>
27
-
28
- <div className='col-3'>
29
28
  <DropdownSimpleDatePicker
30
29
  {...args}
31
30
  inputLabel='End Date'
32
31
  date={endDate}
33
32
  setDate={setEndDate}
33
+ minDate={startDate}
34
+ />
35
+ </div>
36
+ {/* PRUEBA CON MAXN Y MIN HARCODEADO */}
37
+ <div className='col-3 mb-3'>
38
+ <DropdownSimpleDatePicker
39
+ {...args}
40
+ inputLabel='Start Date'
41
+ date={startDate}
42
+ setDate={setStartDate}
34
43
  handleClear={() => {
35
44
  console.log('Aqui');
36
45
  }}
46
+ maxDate={'2025-01-20'}
37
47
  />
38
- </div>
39
-
40
- <div className='col-3'>
41
- <p>minmax</p>
42
48
  <DropdownSimpleDatePicker
43
49
  {...args}
44
50
  inputLabel='End Date'
@@ -47,8 +53,7 @@ const Template = (args) => {
47
53
  handleClear={() => {
48
54
  console.log('Aqui');
49
55
  }}
50
- minDate={new Date('2025-01-01')}
51
- maxDate={new Date('2025-01-31')}
56
+ minDate={'2025-01-15'}
52
57
  />
53
58
  </div>
54
59
  </div>
@@ -1,7 +1,8 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
 
3
3
  // COMPONENTS
4
4
  import { InputEmail } from '../components';
5
+ import { Button } from 'react-bootstrap';
5
6
 
6
7
  export default {
7
8
  title: 'Inputs/InputEmail',
@@ -12,7 +13,7 @@ const Template = (args) => {
12
13
  // const [showModal, setShowModal] = useState(false);
13
14
  return (
14
15
  <>
15
- {/* <Button onClick={() => setShowModal(!showModal)}>Cambiar show</Button> */}
16
+ {/* <Button size='lg' onClick={() => setShowModal(!showModal)}>Cambiar</Button> */}
16
17
  <InputEmail
17
18
  {...args}
18
19
  apiGetEmail={'v2/retail-media/retailers/settings/notifications'}