imbric-theme 0.3.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- package/.storybook/main.js +1 -1
- package/atoms/AlertModal/AlertModal.js +77 -0
- package/atoms/AlertModal/AlertModal.module.css +3 -0
- package/atoms/AlertModal/AlertModal.stories.js +30 -0
- package/atoms/AlertModal/constants.js +4 -0
- package/atoms/AlertModal/index.js +3 -0
- package/atoms/Button/Button.js +5 -2
- package/atoms/Button/Button.module.css +6 -3
- package/atoms/Checkbox/Checkbox.js +49 -0
- package/atoms/Checkbox/Checkbox.module.css +3 -0
- package/atoms/Checkbox/Checkbox.stories.js +28 -0
- package/atoms/Checkbox/constants.js +1 -0
- package/atoms/Checkbox/index.js +3 -0
- package/atoms/Heading/Heading.js +1 -1
- package/atoms/Heading/Heading.module.css +4 -0
- package/atoms/Heading/constants.js +1 -1
- package/atoms/Icon/constants.js +30 -6
- package/atoms/Icon/file-download-svgrepo-com.svg +13 -0
- package/atoms/Input/Input.js +21 -5
- package/atoms/Input/Input.module.css +26 -6
- package/atoms/Input/Input.stories.js +8 -2
- package/atoms/Input/__snapshots__/Input.stories.js.snap +5 -5
- package/atoms/Input/constants.js +1 -1
- package/atoms/Label/Label.js +31 -0
- package/atoms/Label/Label.module.css +38 -0
- package/atoms/Label/Label.stories.js +26 -0
- package/atoms/Label/constants.js +1 -0
- package/atoms/Label/index.js +3 -0
- package/atoms/Paragraph/Paragraph.module.css +4 -0
- package/index.js +20 -1
- package/jest.config.js +1 -1
- package/layout/DynamicTable/DynamicTable.js +207 -0
- package/layout/DynamicTable/DynamicTable.module.css +62 -0
- package/layout/DynamicTable/DynamicTable.stories.js +30 -0
- package/layout/DynamicTable/constants.js +840 -0
- package/layout/DynamicTable/index.js +3 -0
- package/layout/Navbar/Navbar.js +19 -11
- package/layout/Navbar/Navbar.module.css +4 -2
- package/layout/Navbar/Navbar.stories.js +2 -1
- package/layout/Sidebar/Sidebar.js +5 -3
- package/layout/Sidebar/Sidebar.module.css +1 -10
- package/layout/Sidebar/Sidebar.stories.js +1 -1
- package/layout/Sidebar/constants.js +228 -205
- package/molecules/CheckList/CheckList.js +135 -0
- package/molecules/CheckList/CheckList.module.css +94 -0
- package/molecules/CheckList/CheckList.stories.js +25 -0
- package/molecules/CheckList/constants.js +23 -0
- package/molecules/CheckList/index.js +3 -0
- package/molecules/ColumnTable/ColumnTable.js +123 -0
- package/molecules/ColumnTable/ColumnTable.module.css +9 -0
- package/molecules/ColumnTable/ColumnTable.stories.js +29 -0
- package/molecules/ColumnTable/constants.js +1 -0
- package/molecules/ColumnTable/index.js +3 -0
- package/molecules/DatePicker/DatePicker.js +223 -0
- package/molecules/DatePicker/DatePicker.module.css +38 -0
- package/molecules/DatePicker/DatePicker.stories.js +23 -0
- package/molecules/DatePicker/constants.js +3 -0
- package/molecules/DatePicker/index.js +3 -0
- package/molecules/Dropdown/Dropdown.js +25 -22
- package/molecules/Dropdown/Dropdown.module.css +21 -3
- package/molecules/DynamicSelect/DynamicSelect.js +109 -0
- package/molecules/DynamicSelect/DynamicSelect.module.css +10 -0
- package/molecules/DynamicSelect/DynamicSelect.stories.js +32 -0
- package/molecules/DynamicSelect/constants.js +7 -0
- package/molecules/DynamicSelect/index.js +3 -0
- package/molecules/Error/Error.js +2 -2
- package/molecules/Error/Error.module.css +3 -2
- package/molecules/ItemMenu/ItemMenu.js +34 -31
- package/molecules/ItemMenu/ItemMenu.module.css +13 -4
- package/molecules/ItemMenu/ItemMenu.stories.js +2 -1
- package/molecules/ItemMenu/constants.js +3 -0
- package/molecules/RowTable/RowTable.js +22 -0
- package/molecules/RowTable/RowTable.module.css +3 -0
- package/molecules/RowTable/RowTable.stories.js +23 -0
- package/molecules/RowTable/constants.js +1 -0
- package/molecules/RowTable/index.js +3 -0
- package/package.json +11 -2
- package/pages/Login/Login.js +102 -0
- package/pages/Login/Login.module.css +5 -0
- package/pages/Login/Login.stories.js +23 -0
- package/pages/Login/constants.js +1 -0
- package/pages/Login/index.js +3 -0
- package/pages/Login/validation/loginSchema.js +5 -0
- package/public/static/logologin.svg +16 -0
- package/scripts/create-component.js +2 -1
- package/storybook-static/0.263f852f.iframe.bundle.js +1 -0
- package/storybook-static/0.91dbd3f3aa2099d25061.manager.bundle.js +1 -0
- package/storybook-static/1.17e9ac7e.iframe.bundle.js +3 -0
- package/storybook-static/1.17e9ac7e.iframe.bundle.js.LICENSE.txt +8 -0
- package/storybook-static/1.17e9ac7e.iframe.bundle.js.map +1 -0
- package/storybook-static/2.cc4000c2.iframe.bundle.js +1 -0
- package/storybook-static/3.e9f95d01.iframe.bundle.js +1 -0
- package/storybook-static/4.be0a752c9f5176d6eec1.manager.bundle.js +2 -0
- package/storybook-static/4.be0a752c9f5176d6eec1.manager.bundle.js.LICENSE.txt +8 -0
- package/storybook-static/5.8efdde123acaf8fbb100.manager.bundle.js +1 -0
- package/storybook-static/6.2f82294ae0b087aecb24.manager.bundle.js +2 -0
- package/storybook-static/6.2f82294ae0b087aecb24.manager.bundle.js.LICENSE.txt +12 -0
- package/storybook-static/7.97068037.iframe.bundle.js +1 -0
- package/storybook-static/7.fa9452d2609e8a00f314.manager.bundle.js +1 -0
- package/storybook-static/8.66f5ef1c66fc4628f127.manager.bundle.js +1 -0
- package/storybook-static/8.b545d602.iframe.bundle.js +3 -0
- package/storybook-static/8.b545d602.iframe.bundle.js.LICENSE.txt +12 -0
- package/storybook-static/8.b545d602.iframe.bundle.js.map +1 -0
- package/storybook-static/9.269ed917.iframe.bundle.js +1 -0
- package/storybook-static/favicon.ico +0 -0
- package/storybook-static/iframe.html +348 -0
- package/storybook-static/index.html +59 -0
- package/storybook-static/main.157061c9.iframe.bundle.js +1 -0
- package/storybook-static/main.5a07347846ccf2d7e5dc.manager.bundle.js +1 -0
- package/storybook-static/runtime~main.a14e6e62.iframe.bundle.js +1 -0
- package/storybook-static/runtime~main.f78c3fae275fc212c109.manager.bundle.js +1 -0
- package/storybook-static/static/logo.svg +19 -0
- package/storybook-static/static/logologin.svg +16 -0
- package/storybook-static/static/logotipo.svg +50 -0
- package/storybook-static/static/logotipoS.svg +26 -0
- package/storybook-static/vendors~main.720e76f4.iframe.bundle.js +3 -0
- package/storybook-static/vendors~main.720e76f4.iframe.bundle.js.LICENSE.txt +110 -0
- package/storybook-static/vendors~main.720e76f4.iframe.bundle.js.map +1 -0
- package/storybook-static/vendors~main.fcd0b2a3431ddf75f5f7.manager.bundle.js +2 -0
- package/storybook-static/vendors~main.fcd0b2a3431ddf75f5f7.manager.bundle.js.LICENSE.txt +101 -0
- package/styles/globals.css +590 -3
- package/styles/tokens.css +2 -1
- package/tokens/index.js +2 -1
@@ -0,0 +1,135 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
|
4
|
+
import Icon from '../../atoms/Icon'
|
5
|
+
import Paragraph from '../../atoms/Paragraph'
|
6
|
+
|
7
|
+
import styles from './CheckList.module.css'
|
8
|
+
import withStyles from '../../hocs/withStyles'
|
9
|
+
|
10
|
+
|
11
|
+
// export const handleChange = e => {
|
12
|
+
// const { name, value } = e.target;
|
13
|
+
|
14
|
+
// this.setState({
|
15
|
+
// [name]: value
|
16
|
+
// });
|
17
|
+
// }
|
18
|
+
|
19
|
+
// const handleChange = ({ onChange }) => () => {
|
20
|
+
// // onChange()
|
21
|
+
|
22
|
+
// const { name, value } = e.target;
|
23
|
+
|
24
|
+
// this.setState({
|
25
|
+
// [name]: value
|
26
|
+
// });
|
27
|
+
|
28
|
+
// }
|
29
|
+
|
30
|
+
// export const handleClick = ({ onClick }) => (event) => {
|
31
|
+
// onClick(event)
|
32
|
+
// }
|
33
|
+
|
34
|
+
// const handleChange = ({ onChange }) => () => {
|
35
|
+
// onChange()
|
36
|
+
// }
|
37
|
+
|
38
|
+
|
39
|
+
export const CheckList = ({ getStyles, options, onChange }) => {
|
40
|
+
|
41
|
+
// this.state = {};
|
42
|
+
|
43
|
+
return (
|
44
|
+
|
45
|
+
<div className={getStyles('check-list')}>
|
46
|
+
|
47
|
+
<ul id="platform" className={getStyles('boxul')}>
|
48
|
+
{options.data.map((item, index) => (
|
49
|
+
<li key={index} className={getStyles('boxlist')}>
|
50
|
+
|
51
|
+
<label className={getStyles('rad-label')}>
|
52
|
+
|
53
|
+
<input
|
54
|
+
className={getStyles('rad-input')}
|
55
|
+
id={item.id}
|
56
|
+
value={item.value}
|
57
|
+
name={item.name}
|
58
|
+
type="radio"
|
59
|
+
onChange={onChange}
|
60
|
+
/>
|
61
|
+
|
62
|
+
<div className={getStyles('rad-design')} ></div>
|
63
|
+
|
64
|
+
<div className={getStyles('rad-text')}>
|
65
|
+
<Paragraph
|
66
|
+
className={getStyles('title-list')}
|
67
|
+
color="primary"
|
68
|
+
isInline
|
69
|
+
size="sm"
|
70
|
+
>
|
71
|
+
{item.title}
|
72
|
+
</Paragraph>
|
73
|
+
|
74
|
+
<Paragraph
|
75
|
+
className={getStyles('subtitle-list')}
|
76
|
+
color="muted"
|
77
|
+
isInline
|
78
|
+
size="xs"
|
79
|
+
>
|
80
|
+
{item.subTitle}
|
81
|
+
</Paragraph>
|
82
|
+
</div>
|
83
|
+
|
84
|
+
</label>
|
85
|
+
|
86
|
+
|
87
|
+
</li>
|
88
|
+
))}
|
89
|
+
</ul>
|
90
|
+
|
91
|
+
{/* <div className="radio-buttons">
|
92
|
+
Windows
|
93
|
+
<input
|
94
|
+
id="windows"
|
95
|
+
value="windows"
|
96
|
+
name="platform"
|
97
|
+
type="radio"
|
98
|
+
onChange={handleChange}
|
99
|
+
/>
|
100
|
+
Mac
|
101
|
+
<input
|
102
|
+
id="mac"
|
103
|
+
value="mac"
|
104
|
+
name="platform"
|
105
|
+
type="radio"
|
106
|
+
onChange={handleChange}
|
107
|
+
/>
|
108
|
+
Linux
|
109
|
+
<input
|
110
|
+
id="linux"
|
111
|
+
value="linux"
|
112
|
+
name="platform"
|
113
|
+
type="radio"
|
114
|
+
onChange={handleChange}
|
115
|
+
/>
|
116
|
+
</div> */}
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
)
|
121
|
+
}
|
122
|
+
|
123
|
+
CheckList.propTypes = {
|
124
|
+
// children: PropTypes.node.isRequired,
|
125
|
+
getStyles: PropTypes.func.isRequired,
|
126
|
+
onChange: PropTypes.func.isRequired,
|
127
|
+
// type: PropTypes.oneOf(options.types),
|
128
|
+
}
|
129
|
+
|
130
|
+
CheckList.defaultProps = {
|
131
|
+
getStyles: () => { },
|
132
|
+
onChange: () => {},
|
133
|
+
}
|
134
|
+
|
135
|
+
export default withStyles(styles)(CheckList)
|
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
.boxul {
|
3
|
+
display: block;
|
4
|
+
list-style-type: disc;
|
5
|
+
margin-block-start: 0em;
|
6
|
+
margin-block-end: 0em;
|
7
|
+
margin-inline-start: 0px;
|
8
|
+
margin-inline-end: 0px;
|
9
|
+
padding-inline-start: 0px;
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
.check-list {
|
14
|
+
display: flex;
|
15
|
+
}
|
16
|
+
|
17
|
+
.boxlist {
|
18
|
+
list-style-type: none;
|
19
|
+
}
|
20
|
+
|
21
|
+
.title-list {
|
22
|
+
padding-left: 0px;
|
23
|
+
}
|
24
|
+
|
25
|
+
.subtitle-list {
|
26
|
+
display: flex;
|
27
|
+
}
|
28
|
+
|
29
|
+
.rad-label {
|
30
|
+
display: flex;
|
31
|
+
align-items: center;
|
32
|
+
|
33
|
+
border-radius: 100px;
|
34
|
+
padding: 12px 16px;
|
35
|
+
margin: 6px 0;
|
36
|
+
|
37
|
+
cursor: pointer;
|
38
|
+
transition: .3s;
|
39
|
+
}
|
40
|
+
|
41
|
+
.rad-label:hover,
|
42
|
+
.rad-label:focus-within {
|
43
|
+
background: hsla(0, 0%, 80%, .14);
|
44
|
+
}
|
45
|
+
|
46
|
+
.rad-input {
|
47
|
+
position: absolute;
|
48
|
+
left: 0;
|
49
|
+
top: 0;
|
50
|
+
width: 1px;
|
51
|
+
height: 1px;
|
52
|
+
opacity: 0;
|
53
|
+
z-index: -1;
|
54
|
+
}
|
55
|
+
|
56
|
+
.rad-design {
|
57
|
+
width: 22px;
|
58
|
+
height: 22px;
|
59
|
+
border-radius: 100px;
|
60
|
+
|
61
|
+
background: linear-gradient(to right bottom, hsl(154, 97%, 62%), hsl(225, 97%, 62%));
|
62
|
+
position: relative;
|
63
|
+
}
|
64
|
+
|
65
|
+
.rad-design::before {
|
66
|
+
content: '';
|
67
|
+
|
68
|
+
display: inline-block;
|
69
|
+
width: inherit;
|
70
|
+
height: inherit;
|
71
|
+
border-radius: inherit;
|
72
|
+
|
73
|
+
background: hsl(0, 0%, 90%);
|
74
|
+
transform: scale(1.1);
|
75
|
+
transition: .3s;
|
76
|
+
}
|
77
|
+
|
78
|
+
.rad-input:checked+.rad-design::before {
|
79
|
+
transform: scale(0);
|
80
|
+
}
|
81
|
+
|
82
|
+
.rad-text {
|
83
|
+
/* color: hsl(0, 0%, 60%); */
|
84
|
+
margin-left: 14px;
|
85
|
+
/* letter-spacing: 3px;
|
86
|
+
text-transform: uppercase;
|
87
|
+
font-size: 18px;
|
88
|
+
font-weight: 900; */
|
89
|
+
transition: .3s;
|
90
|
+
}
|
91
|
+
|
92
|
+
.rad-input:checked~.rad-text {
|
93
|
+
color: hsl(0, 0%, 40%);
|
94
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { CheckList, styles, options } from '.'
|
2
|
+
|
3
|
+
import {
|
4
|
+
getTemplate,
|
5
|
+
getListTemplate,
|
6
|
+
getOptionsArgTypes,
|
7
|
+
} from '../../helpers/storybook'
|
8
|
+
|
9
|
+
const Template = getTemplate(CheckList, styles)
|
10
|
+
const ListTemplate = getListTemplate(CheckList, styles)
|
11
|
+
|
12
|
+
export default {
|
13
|
+
title: 'Molecules/CheckList',
|
14
|
+
component: CheckList,
|
15
|
+
args: {
|
16
|
+
options: options,
|
17
|
+
},
|
18
|
+
argTypes: {
|
19
|
+
// types: getOptionsArgTypes(options.types),
|
20
|
+
},
|
21
|
+
}
|
22
|
+
|
23
|
+
export const Default = Template.bind({})
|
24
|
+
// export const List = ListTemplate.bind({})
|
25
|
+
// List.args = { items: options.types.map((type) => ({ type })) }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
export const options = {
|
2
|
+
data: [
|
3
|
+
{
|
4
|
+
id: 'idEmail',
|
5
|
+
active: false,
|
6
|
+
icon: 'home',
|
7
|
+
title: 'Email',
|
8
|
+
subTitle: 'recibir un código en mi email ',
|
9
|
+
value: 'Email',
|
10
|
+
name: 'platform',
|
11
|
+
},
|
12
|
+
{
|
13
|
+
id: 'idGoogle2FA',
|
14
|
+
active: false,
|
15
|
+
icon: 'home',
|
16
|
+
title: 'Google Auth',
|
17
|
+
subTitle: 'obtener un código en la app de autenticador de Google',
|
18
|
+
value: 'Google Auth',
|
19
|
+
name: 'platform',
|
20
|
+
},
|
21
|
+
]
|
22
|
+
|
23
|
+
}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { useState } from "react";
|
3
|
+
import PropTypes from 'prop-types'
|
4
|
+
import styles from './ColumnTable.module.css'
|
5
|
+
import { options } from './constants'
|
6
|
+
import withStyles from '../../hocs/withStyles'
|
7
|
+
import Paragraph from '../../atoms/Paragraph'
|
8
|
+
import Input from '../../atoms/Input'
|
9
|
+
import Icon from '../../atoms/Icon'
|
10
|
+
import { Horizontal, Vertical } from '../../layout/Spacer/components'
|
11
|
+
|
12
|
+
|
13
|
+
export const ColumnTable = ({ getStyles, children, sortable, accessor, handleSorting, isFilter, columnUppercase, idInput, typeInput, nameInput, placeholder, value, onChange }) => {
|
14
|
+
|
15
|
+
const [sortField, setSortField] = useState("");
|
16
|
+
const [order, setOrder] = useState("asc");
|
17
|
+
|
18
|
+
const handleSortingChange = (accessor) => {
|
19
|
+
const sortOrder =
|
20
|
+
accessor === sortField && order === "asc" ? "desc" : "asc";
|
21
|
+
setSortField(accessor);
|
22
|
+
setOrder(sortOrder);
|
23
|
+
handleSorting(accessor, sortOrder);
|
24
|
+
};
|
25
|
+
|
26
|
+
const cl = sortable
|
27
|
+
? sortField && sortField === accessor && order === "asc"
|
28
|
+
? "angleUp"
|
29
|
+
: sortField && sortField === accessor && order === "desc"
|
30
|
+
? "angleDown"
|
31
|
+
: "default"
|
32
|
+
: "";
|
33
|
+
|
34
|
+
|
35
|
+
return (
|
36
|
+
<th
|
37
|
+
onClick={sortable ? () => handleSortingChange(accessor) : null}
|
38
|
+
className={getStyles('column-table', {
|
39
|
+
'column-uppercase': columnUppercase,
|
40
|
+
})}>
|
41
|
+
|
42
|
+
|
43
|
+
<Paragraph
|
44
|
+
size="xs"
|
45
|
+
isInline
|
46
|
+
>
|
47
|
+
{children}
|
48
|
+
</Paragraph>
|
49
|
+
|
50
|
+
<Horizontal size="xs" />
|
51
|
+
|
52
|
+
{cl === 'default' ?
|
53
|
+
(<Icon
|
54
|
+
className=""
|
55
|
+
name="angleUpDown"
|
56
|
+
size="xs"
|
57
|
+
/>
|
58
|
+
) : cl === '' ? null
|
59
|
+
|
60
|
+
: cl === 'angleDown'
|
61
|
+
? (<Icon
|
62
|
+
className=""
|
63
|
+
name="angleDown"
|
64
|
+
size="xs"
|
65
|
+
/>
|
66
|
+
)
|
67
|
+
: (<Icon
|
68
|
+
className=""
|
69
|
+
name="angleUp"
|
70
|
+
size="xs"
|
71
|
+
/>
|
72
|
+
)
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
<Vertical size="xs" />
|
77
|
+
|
78
|
+
{isFilter ? (
|
79
|
+
|
80
|
+
<Input
|
81
|
+
isInputFilter
|
82
|
+
id={idInput}
|
83
|
+
value={''}
|
84
|
+
type={typeInput}
|
85
|
+
name={nameInput}
|
86
|
+
onChange={onChange}
|
87
|
+
placeholder={placeholder}
|
88
|
+
/>) : null
|
89
|
+
}
|
90
|
+
|
91
|
+
</th>
|
92
|
+
)
|
93
|
+
}
|
94
|
+
|
95
|
+
ColumnTable.propTypes = {
|
96
|
+
sortable: PropTypes.bool.isRequired,
|
97
|
+
accessor: PropTypes.string.isRequired,
|
98
|
+
handleSorting: PropTypes.func.isRequired,
|
99
|
+
children: PropTypes.string.isRequired,
|
100
|
+
getStyles: PropTypes.func.isRequired,
|
101
|
+
isFilter: PropTypes.bool,
|
102
|
+
columnUppercase: PropTypes.bool,
|
103
|
+
idInput: PropTypes.string,
|
104
|
+
typeInput: PropTypes.oneOf(options.typeInput),
|
105
|
+
nameInput: PropTypes.string,
|
106
|
+
placeholder: PropTypes.string,
|
107
|
+
}
|
108
|
+
|
109
|
+
ColumnTable.defaultProps = {
|
110
|
+
getStyles: () => { },
|
111
|
+
children: 'NameTh',
|
112
|
+
sortable: true,
|
113
|
+
accessor: 'prueba',
|
114
|
+
handleSorting: () => { },
|
115
|
+
columnUppercase: false,
|
116
|
+
isFilter: true,
|
117
|
+
idInput: 'prueba',
|
118
|
+
typeInput: 'text',
|
119
|
+
nameInput: 'prueba',
|
120
|
+
placeholder: 'placeholder'
|
121
|
+
}
|
122
|
+
|
123
|
+
export default withStyles(styles)(ColumnTable)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { ColumnTable, styles, options } from '.'
|
2
|
+
|
3
|
+
import {
|
4
|
+
getTemplate,
|
5
|
+
getListTemplate,
|
6
|
+
getOptionsArgTypes,
|
7
|
+
} from '../../helpers/storybook'
|
8
|
+
|
9
|
+
const Template = getTemplate(ColumnTable, styles)
|
10
|
+
const ListTemplate = getListTemplate(ColumnTable, styles)
|
11
|
+
|
12
|
+
export default {
|
13
|
+
title: 'Molecules/ColumnTable',
|
14
|
+
component: ColumnTable,
|
15
|
+
args: {
|
16
|
+
children: 'NameTh',
|
17
|
+
sortable: true,
|
18
|
+
accessor: 'prueba',
|
19
|
+
columnUppercase: false,
|
20
|
+
isFilter: true
|
21
|
+
},
|
22
|
+
argTypes: {
|
23
|
+
typeInput: getOptionsArgTypes(options.typeInput),
|
24
|
+
},
|
25
|
+
}
|
26
|
+
|
27
|
+
export const Default = Template.bind({})
|
28
|
+
// export const List = ListTemplate.bind({})
|
29
|
+
// List.args = { items: options.types.map((type) => ({ type })) }
|
@@ -0,0 +1 @@
|
|
1
|
+
export const options = { typeInput: ['text', 'password', 'date', 'number'], }
|
@@ -0,0 +1,223 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
import { useState } from 'react';
|
4
|
+
import styles from './DatePicker.module.css'
|
5
|
+
import { options } from './constants'
|
6
|
+
import withStyles from '../../hocs/withStyles'
|
7
|
+
import { Calendar, DateRangePicker, DateRange, DefinedRange, defaultStaticRanges, defaultInputRanges } from 'react-date-range';
|
8
|
+
import Input from '../../atoms/Input';
|
9
|
+
import * as locales from 'react-date-range/dist/locale';
|
10
|
+
import moment from 'moment'
|
11
|
+
import Label from '../../atoms/Label';
|
12
|
+
import { Horizontal, Vertical } from '../../layout/Spacer/components'
|
13
|
+
import Icon from '../../atoms/Icon';
|
14
|
+
|
15
|
+
// import 'react-date-range/dist/styles.css'; // main css file
|
16
|
+
// import 'react-date-range/dist/theme/default.css'; // theme css file
|
17
|
+
|
18
|
+
import {
|
19
|
+
addDays,
|
20
|
+
endOfDay,
|
21
|
+
startOfDay,
|
22
|
+
startOfYear,
|
23
|
+
startOfMonth,
|
24
|
+
endOfMonth,
|
25
|
+
endOfYear,
|
26
|
+
addMonths,
|
27
|
+
addYears,
|
28
|
+
startOfWeek,
|
29
|
+
endOfWeek,
|
30
|
+
isSameDay,
|
31
|
+
differenceInCalendarDays
|
32
|
+
} from "date-fns";
|
33
|
+
|
34
|
+
|
35
|
+
export const DatePicker = ({ getStyles, isLayoutDate }) => {
|
36
|
+
|
37
|
+
const [isShowCalendar, setShowCalendar] = useState(false);
|
38
|
+
|
39
|
+
const [state, setState] = useState([
|
40
|
+
{
|
41
|
+
startDate: addDays(new Date(), -59),
|
42
|
+
endDate: new Date(),
|
43
|
+
key: 'selection',
|
44
|
+
}
|
45
|
+
|
46
|
+
]);
|
47
|
+
|
48
|
+
moment.locale('es')
|
49
|
+
const format = "DD/MMMM/YYYY";
|
50
|
+
|
51
|
+
const handleSelect = (date) => {
|
52
|
+
console.log(date); // native Date object
|
53
|
+
console.log(state)
|
54
|
+
console.log(date)
|
55
|
+
}
|
56
|
+
|
57
|
+
const handleClickOpenCalendar = () => {
|
58
|
+
setShowCalendar(true)
|
59
|
+
}
|
60
|
+
|
61
|
+
const handleClickCloseCalendar = () => {
|
62
|
+
setShowCalendar(false)
|
63
|
+
};
|
64
|
+
|
65
|
+
|
66
|
+
return (
|
67
|
+
<div className={getStyles('date-picker')}>
|
68
|
+
|
69
|
+
{isLayoutDate === 'Calendar' ?
|
70
|
+
|
71
|
+
(<Calendar
|
72
|
+
date={new Date()}
|
73
|
+
onChange={handleSelect}
|
74
|
+
/>)
|
75
|
+
: isLayoutDate === 'DateRange' ?
|
76
|
+
|
77
|
+
(<DateRange
|
78
|
+
editableDateInputs={true}
|
79
|
+
onChange={item => setState([item.selection])}
|
80
|
+
moveRangeOnFirstSelection={false}
|
81
|
+
ranges={state}
|
82
|
+
/>)
|
83
|
+
:
|
84
|
+
|
85
|
+
!isShowCalendar ?
|
86
|
+
<div className={getStyles('date-picker-input')}>
|
87
|
+
<div>
|
88
|
+
<Label>Desde</Label>
|
89
|
+
<Input
|
90
|
+
isInline
|
91
|
+
id="startDate"
|
92
|
+
onClick={handleClickOpenCalendar}
|
93
|
+
placeholder="Et harum quidem"
|
94
|
+
value={moment(state[0].startDate).format(format).toString()}
|
95
|
+
/>
|
96
|
+
<Vertical size="xs" />
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<div>
|
100
|
+
<Label>Hasta</Label>
|
101
|
+
<Input
|
102
|
+
isInline
|
103
|
+
id="endDate"
|
104
|
+
onClick={handleClickOpenCalendar}
|
105
|
+
placeholder="Et harum quidem"
|
106
|
+
value={moment(state[0].endDate).format(format).toString()}
|
107
|
+
/>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
:
|
111
|
+
<div className={getStyles('modalDatePickerRange')}>
|
112
|
+
|
113
|
+
<DateRangePicker
|
114
|
+
locale={locales.es}
|
115
|
+
dateDisplayFormat='d MMMM yyyy'
|
116
|
+
onChange={item => setState([item.selection])}
|
117
|
+
showSelectionPreview={false}
|
118
|
+
moveRangeOnFirstSelection={false}
|
119
|
+
months={2}
|
120
|
+
ranges={state}
|
121
|
+
direction="horizontal"
|
122
|
+
inputRanges={[
|
123
|
+
{
|
124
|
+
...defaultInputRanges[0],
|
125
|
+
label: 'Dias hasta hoy'
|
126
|
+
},
|
127
|
+
{
|
128
|
+
...defaultInputRanges[1],
|
129
|
+
label: 'Dias desde hoy'
|
130
|
+
}
|
131
|
+
]}
|
132
|
+
staticRanges={[
|
133
|
+
// ...defaultStaticRanges,
|
134
|
+
{
|
135
|
+
label: "Mes pasado",
|
136
|
+
range: () => ({
|
137
|
+
startDate: startOfMonth(addMonths(new Date(), -1)),
|
138
|
+
endDate: endOfMonth(addMonths(new Date(), -1))
|
139
|
+
}),
|
140
|
+
isSelected(range) {
|
141
|
+
const definedRange = this.range();
|
142
|
+
return (
|
143
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
144
|
+
isSameDay(range.endDate, definedRange.endDate)
|
145
|
+
);
|
146
|
+
}
|
147
|
+
},
|
148
|
+
{
|
149
|
+
label: "Mes actual",
|
150
|
+
range: () => ({
|
151
|
+
startDate: startOfMonth(new Date()),
|
152
|
+
endDate: endOfDay(new Date())
|
153
|
+
}),
|
154
|
+
isSelected(range) {
|
155
|
+
const definedRange = this.range();
|
156
|
+
return (
|
157
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
158
|
+
isSameDay(range.endDate, definedRange.endDate)
|
159
|
+
);
|
160
|
+
}
|
161
|
+
},
|
162
|
+
{
|
163
|
+
label: "Año pasado",
|
164
|
+
range: () => ({
|
165
|
+
startDate: startOfYear(addYears(new Date(), -1)),
|
166
|
+
endDate: endOfYear(addYears(new Date(), -1))
|
167
|
+
}),
|
168
|
+
isSelected(range) {
|
169
|
+
const definedRange = this.range();
|
170
|
+
return (
|
171
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
172
|
+
isSameDay(range.endDate, definedRange.endDate)
|
173
|
+
);
|
174
|
+
}
|
175
|
+
},
|
176
|
+
{
|
177
|
+
label: "Año actual",
|
178
|
+
range: () => ({
|
179
|
+
startDate: startOfYear(new Date()),
|
180
|
+
endDate: endOfDay(new Date())
|
181
|
+
}),
|
182
|
+
isSelected(range) {
|
183
|
+
const definedRange = this.range();
|
184
|
+
return (
|
185
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
186
|
+
isSameDay(range.endDate, definedRange.endDate)
|
187
|
+
);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
]}
|
191
|
+
/>
|
192
|
+
|
193
|
+
<div className={getStyles('btnSave')} onClick={handleClickCloseCalendar}>
|
194
|
+
<Icon
|
195
|
+
name="checkCircle"
|
196
|
+
color="inverted"
|
197
|
+
onClick={function noRefCheck() { }}
|
198
|
+
/>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
{/* <DefinedRange
|
202
|
+
locale={locales.es}
|
203
|
+
onChange={item => setState([item.selection])}
|
204
|
+
ranges={state}
|
205
|
+
/> */}
|
206
|
+
</div>
|
207
|
+
|
208
|
+
}
|
209
|
+
</div>
|
210
|
+
)
|
211
|
+
}
|
212
|
+
|
213
|
+
DatePicker.propTypes = {
|
214
|
+
getStyles: PropTypes.func.isRequired,
|
215
|
+
isLayoutDate: PropTypes.oneOf(options.typeLayoutDate),
|
216
|
+
}
|
217
|
+
|
218
|
+
DatePicker.defaultProps = {
|
219
|
+
getStyles: () => { },
|
220
|
+
isLayoutDate: 'Calendar'
|
221
|
+
}
|
222
|
+
|
223
|
+
export default withStyles(styles)(DatePicker)
|