groovinads-ui 1.2.19 → 1.2.21

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.
@@ -11,7 +11,7 @@ import Icon from '../Labels/Icon';
11
11
  const Input = ({
12
12
  autoFocus = false,
13
13
  className = '',
14
- customRef,
14
+ focus=false,
15
15
  disabled,
16
16
  helpText,
17
17
  icon,
@@ -28,7 +28,7 @@ const Input = ({
28
28
  value,
29
29
  }) => {
30
30
  const { toCamelCase } = useTextFormatter();
31
- const searchInput = useRef(null);
31
+ const inputRef = useRef(null);
32
32
 
33
33
  const id = toCamelCase(label);
34
34
 
@@ -41,10 +41,10 @@ const Input = ({
41
41
  }, [showError]);
42
42
 
43
43
  useEffect(() => {
44
- if(searchInput.current && customRef) {
45
- searchInput.current.focus();
44
+ if(inputRef.current && focus) {
45
+ inputRef.current.focus();
46
46
  }
47
- }, [customRef])
47
+ }, [focus])
48
48
 
49
49
  return (
50
50
  <div className={`position-relative ${className}`}>
@@ -74,7 +74,7 @@ const Input = ({
74
74
  onChange={onChange}
75
75
  required={!!requiredText}
76
76
  autoFocus={autoFocus}
77
- ref={searchInput}
77
+ ref={inputRef}
78
78
  />
79
79
  <label htmlFor={id}>{label}</label>
80
80
  </div>
@@ -96,7 +96,7 @@ const Input = ({
96
96
  name={name}
97
97
  disabled={disabled}
98
98
  autoFocus={autoFocus}
99
- ref={searchInput}
99
+ ref={inputRef}
100
100
  />
101
101
  <label htmlFor={id}>{label}</label>
102
102
  </div>
@@ -108,7 +108,7 @@ const Input = ({
108
108
 
109
109
  Input.propTypes = {
110
110
  className: PropTypes.string,
111
- customRef: PropTypes.bool,
111
+ focus: PropTypes.bool,
112
112
  disabled: PropTypes.bool,
113
113
  helpText: PropTypes.string,
114
114
  icon: PropTypes.string,
@@ -8,42 +8,55 @@ import { Icon } from '../Labels';
8
8
  // HOOKS
9
9
  import useTextFormatter from '../../hooks/useTextFormatter';
10
10
 
11
- function Tabnav({ tabs = [], activeTab }) {
12
- const { toCamelCase } = useTextFormatter();
13
-
14
- const handleSelect = (k) => {
15
- const tabIndex = tabs.findIndex((tab) => toCamelCase(tab.tab) === k);
16
- console.log(tabs[tabIndex].url);
17
-
18
- window.location.href = tabs[tabIndex].url;
19
- };
20
-
21
- const formatTabsName = (tab) => {
22
- if (tab === 'api_keys') {
23
- return 'API Keys';
11
+ function Tabnav({ tabs = [], activeTab = 1, customFunction = false}) {
12
+ const { toCamelCase } = useTextFormatter();
13
+
14
+ const handleSelect = (k) => {
15
+ if (customFunction){
16
+ console.log('custom function');
17
+ }else{
18
+ const tabIndex = tabs.findIndex((tab) => toCamelCase(tab.tab) === k);
19
+ console.log(tabs[tabIndex].url);
20
+
21
+ window.location.href = tabs[tabIndex].url;
24
22
  }
25
- const tabReplace = tab.replace('_', ' ');
26
- return tabReplace.charAt(0).toUpperCase() + tabReplace.slice(1);
27
- };
28
- console.log(activeTab)
29
- return (
30
- <Nav variant='tabs' activeKey={activeTab} onSelect={handleSelect}>
31
- {tabs.map(({ tab, badgeNumber, warningIcon }, index) => (
32
- <Nav.Item key={index}>
33
- <Nav.Link eventKey={toCamelCase(tab)}>
34
- {warningIcon && <Icon iconName='triangle-exclamation' />}
35
- {formatTabsName(tab)}
36
- {badgeNumber && <span className='tab-badge'>{badgeNumber}</span>}
37
- </Nav.Link>
38
- </Nav.Item>
39
- ))}
40
- </Nav>
41
- );
23
+
24
+ };
25
+
26
+ const formatTabsName = (tab) => {
27
+ if (tab === 'api_keys') {
28
+ return 'API Keys';
29
+ }
30
+ const tabReplace = tab.replace('_', ' ');
31
+ return tabReplace.charAt(0).toUpperCase() + tabReplace.slice(1);
32
+ };
33
+
34
+ return (
35
+ <Nav
36
+ variant='tabs'
37
+ activeKey={toCamelCase(tabs[activeTab - 1].tab)}
38
+ onSelect={handleSelect}
39
+ >
40
+ {tabs.map(({ tab, badgeNumber, warningIcon }, index) => (
41
+ <Nav.Item key={index}>
42
+ <Nav.Link
43
+ eventKey={toCamelCase(tab)}
44
+ >
45
+ {/* Dia 1 => dia1 */}
46
+ {warningIcon && <Icon iconName='triangle-exclamation' />}
47
+ {formatTabsName(tab)}
48
+ {badgeNumber && <span className='tab-badge'>{badgeNumber}</span>}
49
+ </Nav.Link>
50
+ </Nav.Item>
51
+ ))}
52
+ </Nav>
53
+ );
42
54
  }
43
55
 
44
56
  Tabnav.propTypes = {
45
- tabs: PropTypes.array,
46
- activeTab: PropTypes.string,
57
+ tabs: PropTypes.array,
58
+ activeTab: PropTypes.number,
59
+ customFunction: PropTypes.bool
47
60
  };
48
61
 
49
62
  export default Tabnav;
@@ -16,6 +16,8 @@ const useTextFormatter = () => {
16
16
  return s;
17
17
  }, []);
18
18
 
19
+ const capitalice = (str) => (str ? `${str.charAt(0).toUpperCase()}${str.slice(1)}` : '');
20
+
19
21
  const highlightText = (text, query) => {
20
22
  if (!query) return text;
21
23
 
@@ -40,7 +42,7 @@ const useTextFormatter = () => {
40
42
 
41
43
  // Additional methods can be added here
42
44
 
43
- return { toCamelCase, highlightText };
45
+ return { toCamelCase, highlightText, capitalice };
44
46
  };
45
47
 
46
48
  export default useTextFormatter;
package/src/index.js CHANGED
@@ -4,7 +4,8 @@ import Button from "./components/Button/Button";
4
4
  // Dropdowns
5
5
  import DropdownComponent from './components/Dropdowns/DropdownComponent';
6
6
  import DropdownFilter from './components/Dropdowns/DropdownFilter';
7
- import DropdownInput from './components/Dropdowns/DropdownInput';
7
+ import DropdownMultiSelect from './components/Dropdowns/DropdownMultiSelect';
8
+ import DropdownDatePicker from './components/Dropdowns/DropdownsDatePicker/DropdownDatePicker';
8
9
 
9
10
  // Inputs
10
11
  import Checkbox from './components/Inputs/Checkbox';
@@ -30,4 +31,32 @@ import Navbar from './components/Navigation/Navbar';
30
31
  import Stepper from './components/Navigation/Stepper';
31
32
  import Tabnav from './components/Navigation/Tabnav';
32
33
 
33
- export { Button, DropdownComponent, DropdownFilter, DropdownInput, Checkbox, Input, Radio, Switch, Textarea, Alert, Icon, LoginSource, PillComponent, Spinner, StatusIcon, ToastComponent, ToastProgress, Navbar, Stepper, Tabnav }
34
+ export {
35
+ // Buttons
36
+ Button,
37
+ // Dropdowns
38
+ DropdownComponent,
39
+ DropdownFilter,
40
+ DropdownMultiSelect,
41
+ DropdownDatePicker,
42
+ // Inputs
43
+ Checkbox,
44
+ Input,
45
+ Radio,
46
+ Switch,
47
+ Textarea,
48
+ // Labels
49
+ Alert,
50
+ Icon,
51
+ LoginSource,
52
+ PillComponent,
53
+ Spinner,
54
+ StatusIcon,
55
+ // Toasts
56
+ ToastComponent,
57
+ ToastProgress,
58
+ // Navigation
59
+ Navbar,
60
+ Stepper,
61
+ Tabnav
62
+ }
@@ -0,0 +1,67 @@
1
+ import React, { useState } from 'react';
2
+ import { DropdownDatePicker } from '../components/Dropdowns';
3
+
4
+ export default {
5
+ title: 'Dropdown/DropdownDatePicker',
6
+ component: DropdownDatePicker,
7
+ };
8
+
9
+ const Template = (args) => {
10
+ const [show, setShow] = useState(false);
11
+
12
+ const [fromDate1, setFromDate1] = useState('');
13
+ const [toDate1, setToDate1] = useState('');
14
+
15
+ const [fromDate2, setFromDate2] = useState('');
16
+ const [toDate2, setToDate2] = useState('');
17
+
18
+ const handleToggle = () => setShow((prevShow) => !prevShow);
19
+
20
+ // const [dateFrom, setDateFrom] = useState();
21
+ // const [dateTo, setDateTo] = useState();
22
+
23
+ // const [datePicker1StartDate, setDatePicker1StartDate] = useState();
24
+ // const [datePicker1EndDate, setDatePicker1EndDate] = useState();
25
+ // const [datePicker2StartDate, setDatePicker2StartDate] = useState();
26
+ // const [datePicker2EndDate, setDatePicker2EndDate] = useState();
27
+ // const [tableQueryObj, setTableQueryObj] = useState();
28
+
29
+ return (
30
+ <>
31
+ <button onClick={() => setShow(!show)}>Toggle</button>
32
+ <div>
33
+ <DropdownDatePicker
34
+ {...args}
35
+ show={show}
36
+ setShow={setShow}
37
+ onToggle={handleToggle}
38
+ fromDate1={fromDate1}
39
+ setFromDate1={setFromDate1}
40
+ toDate1={toDate1}
41
+ setToDate1={setToDate1}
42
+ fromDate2={fromDate2}
43
+ setFromDate2={setFromDate2}
44
+ toDate2={toDate2}
45
+ setToDate2={setToDate2}
46
+ // dateFrom={dateFrom}
47
+ // setDateFrom={setDateFrom}
48
+ // dateTo={dateTo}
49
+ // setDateTo={setDateTo}
50
+ // datePicker1StartDate={datePicker1StartDate}
51
+ // setDatePicker1StartDate={setDatePicker1StartDate}
52
+ // datePicker1EndDate={datePicker1EndDate}
53
+ // setDatePicker1EndDate={setDatePicker1EndDate}
54
+ // datePicker2StartDate={datePicker2StartDate}
55
+ // setDatePicker2StartDate={setDatePicker2StartDate}
56
+ // datePicker2EndDate={datePicker2EndDate}
57
+ // setDatePicker2EndDate={setDatePicker2EndDate}
58
+ // tableQueryObj={tableQueryObj}
59
+ // setTableQueryObj={setTableQueryObj}
60
+ // fetchData={() => {}}
61
+ />
62
+ </div>
63
+ </>
64
+ );
65
+ };
66
+
67
+ export const Default = Template.bind({});
@@ -1,9 +1,9 @@
1
1
  import React, { useState } from "react";
2
- import DropdownInput from "../components/Dropdowns/DropdownInput";
2
+ import DropdownMultiSelect from "../components/Dropdowns/DropdownMultiSelect";
3
3
 
4
4
  export default {
5
- title: "Dropdown/DropdownInput",
6
- component: DropdownInput,
5
+ title: "Dropdown/DropdownMultiSelect",
6
+ component: DropdownMultiSelect,
7
7
  };
8
8
 
9
9
  const Template = (args) => {
@@ -24,7 +24,7 @@ const Template = (args) => {
24
24
  <>
25
25
  {/* <button onClick={() => setShow(false)}>Close</button>
26
26
  <button onClick={() => setShow(true)}>Open</button> */}
27
- <DropdownInput
27
+ <DropdownMultiSelect
28
28
  {...args}
29
29
  valuesSelected={selectedValues}
30
30
  setValuesSelected={setSelectedValues}
@@ -34,8 +34,10 @@ const Template = (args) => {
34
34
  object={true}
35
35
  nameKey="name"
36
36
  idKey={"id"}
37
- inputLabel='Filters'
38
- ></DropdownInput>
37
+ inputLabel={'Filters'}
38
+ focus={show}
39
+
40
+ ></DropdownMultiSelect>
39
41
  </>
40
42
  )
41
43
  };