imbric-theme 0.3.2 → 0.3.5
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/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/hook/useAddColumn.js +40 -0
- package/hook/useStateDate.js +25 -0
- package/hook/useTable.js +45 -0
- package/index.js +22 -1
- package/jest.config.js +1 -1
- package/layout/DynamicTable/DynamicTable.js +172 -0
- package/layout/DynamicTable/DynamicTable.module.css +63 -0
- package/layout/DynamicTable/DynamicTable.stories.js +77 -0
- package/layout/DynamicTable/constants.js +323 -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 +6 -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 +124 -0
- package/molecules/ColumnTable/ColumnTable.module.css +22 -0
- package/molecules/ColumnTable/ColumnTable.stories.js +26 -0
- package/molecules/ColumnTable/constants.js +111 -0
- package/molecules/ColumnTable/index.js +3 -0
- package/molecules/DatePicker/DatePicker.js +236 -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/FooterTable/FooterTable.js +47 -0
- package/molecules/FooterTable/FooterTable.module.css +37 -0
- package/molecules/FooterTable/FooterTable.stories.js +23 -0
- package/molecules/FooterTable/constants.js +1 -0
- package/molecules/FooterTable/index.js +3 -0
- package/molecules/ItemMenu/ItemMenu.js +35 -24
- package/molecules/ItemMenu/ItemMenu.module.css +13 -4
- package/molecules/ItemMenu/ItemMenu.stories.js +2 -0
- package/molecules/ItemMenu/constants.js +3 -0
- package/molecules/RowTable/RowTable.js +68 -0
- package/molecules/RowTable/RowTable.module.css +22 -0
- package/molecules/RowTable/RowTable.stories.js +26 -0
- package/molecules/RowTable/constants.js +305 -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 +592 -0
- package/styles/tokens.css +2 -1
- package/tokens/index.js +2 -1
@@ -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,124 @@
|
|
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, handleSorting, columnUppercase, onChangeInput, columnsData }) => {
|
14
|
+
|
15
|
+
const [sortable, setSortable] = useState(true);
|
16
|
+
const [accessor, setAccessor] = useState("");
|
17
|
+
const [sortField, setSortField] = useState("");
|
18
|
+
const [order, setOrder] = useState("asc");
|
19
|
+
|
20
|
+
const handleSortingChange = (accessor) => {
|
21
|
+
const sortOrder =
|
22
|
+
accessor === sortField && order === "asc" ? "desc" : "asc";
|
23
|
+
setSortField(accessor);
|
24
|
+
setOrder(sortOrder);
|
25
|
+
handleSorting(accessor, sortOrder);
|
26
|
+
};
|
27
|
+
|
28
|
+
const cl = sortable
|
29
|
+
? sortField && sortField === accessor && order === "asc"
|
30
|
+
? "angleUp"
|
31
|
+
: sortField && sortField === accessor && order === "desc"
|
32
|
+
? "angleDown"
|
33
|
+
: "default"
|
34
|
+
: "";
|
35
|
+
|
36
|
+
|
37
|
+
return (
|
38
|
+
|
39
|
+
<div className={getStyles('tbl-header')}>
|
40
|
+
<table className={getStyles('table')} cellPadding="0" cellSpacing="0" border="0">
|
41
|
+
<thead>
|
42
|
+
<tr>
|
43
|
+
|
44
|
+
{columnsData.map((item) => (
|
45
|
+
item.activeView ?
|
46
|
+
// setSortable(item.sortable)
|
47
|
+
// setAccessor()
|
48
|
+
(<th
|
49
|
+
key={item.idInput}
|
50
|
+
className={getStyles('column-table', {
|
51
|
+
'column-uppercase': columnUppercase,
|
52
|
+
})}>
|
53
|
+
|
54
|
+
<span onClick={item.sortable ? () => handleSortingChange(item.accessor) : null}>
|
55
|
+
<Paragraph
|
56
|
+
size="xs"
|
57
|
+
isInline
|
58
|
+
>
|
59
|
+
{item.title}
|
60
|
+
</Paragraph>
|
61
|
+
|
62
|
+
<Horizontal size="xs" />
|
63
|
+
|
64
|
+
{cl === "default" ?
|
65
|
+
<Icon
|
66
|
+
name="angleUpDown"
|
67
|
+
size="xs"
|
68
|
+
/>
|
69
|
+
: cl === "" ? null
|
70
|
+
|
71
|
+
: cl === "angleDown"
|
72
|
+
? <Icon
|
73
|
+
name="angleDown"
|
74
|
+
size="xs"
|
75
|
+
/>
|
76
|
+
|
77
|
+
: <Icon
|
78
|
+
name="angleUp"
|
79
|
+
size="xs"
|
80
|
+
/>
|
81
|
+
|
82
|
+
}
|
83
|
+
</span>
|
84
|
+
|
85
|
+
|
86
|
+
<Vertical size="xs" />
|
87
|
+
|
88
|
+
{item.viewIsFilter ? (
|
89
|
+
|
90
|
+
<Input
|
91
|
+
isInputFilter
|
92
|
+
id={item.idInput}
|
93
|
+
type={item.typeFilter}
|
94
|
+
name={item.nameInput}
|
95
|
+
onChange={onChangeInput}
|
96
|
+
placeholder={item.placeholder}
|
97
|
+
/>) : null
|
98
|
+
}
|
99
|
+
|
100
|
+
</th>
|
101
|
+
) : null
|
102
|
+
))}
|
103
|
+
|
104
|
+
</tr>
|
105
|
+
</thead>
|
106
|
+
</table>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
)
|
110
|
+
}
|
111
|
+
|
112
|
+
ColumnTable.propTypes = {
|
113
|
+
handleSorting: PropTypes.func.isRequired,
|
114
|
+
getStyles: PropTypes.func.isRequired,
|
115
|
+
columnUppercase: PropTypes.bool,
|
116
|
+
}
|
117
|
+
|
118
|
+
ColumnTable.defaultProps = {
|
119
|
+
getStyles: () => { },
|
120
|
+
handleSorting: () => { },
|
121
|
+
columnUppercase: false,
|
122
|
+
}
|
123
|
+
|
124
|
+
export default withStyles(styles)(ColumnTable)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.column-table {
|
2
|
+
padding: 12px 15px;
|
3
|
+
text-align: left;
|
4
|
+
color: var(--color-font-base);
|
5
|
+
}
|
6
|
+
|
7
|
+
.column-uppercase {
|
8
|
+
text-transform: uppercase;
|
9
|
+
}
|
10
|
+
|
11
|
+
.table {
|
12
|
+
width: 100%;
|
13
|
+
table-layout: fixed;
|
14
|
+
|
15
|
+
}
|
16
|
+
|
17
|
+
.tbl-header {
|
18
|
+
/* background-color: rgba(255, 255, 255, 0.3); */
|
19
|
+
/* background-color: -webkit-linear-gradient(left, #25c481, #25b7c4);
|
20
|
+
background-color: linear-gradient(to right, #25c481, #25b7c4); */
|
21
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
22
|
+
}
|
@@ -0,0 +1,26 @@
|
|
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
|
+
columnUppercase: false,
|
17
|
+
columnsData: options.columns,
|
18
|
+
},
|
19
|
+
argTypes: {
|
20
|
+
// typeInput: getOptionsArgTypes(options.typeInput),
|
21
|
+
},
|
22
|
+
}
|
23
|
+
|
24
|
+
export const Default = Template.bind({})
|
25
|
+
// export const List = ListTemplate.bind({})
|
26
|
+
// List.args = { items: options.types.map((type) => ({ type })) }
|
@@ -0,0 +1,111 @@
|
|
1
|
+
export const options = {
|
2
|
+
typeInput: ['text', 'password', 'date', 'number'],
|
3
|
+
|
4
|
+
columns: [
|
5
|
+
{
|
6
|
+
activeView: true,
|
7
|
+
sortable: true,
|
8
|
+
accessor: 'timeBookingStartRealTimestamp',
|
9
|
+
subAccessor: '',
|
10
|
+
title: 'Fecha',
|
11
|
+
viewIsFilter: true,
|
12
|
+
typeFilter: 'date',
|
13
|
+
subTypeFilter: false,
|
14
|
+
idInput: 'fecha',
|
15
|
+
nameInput: 'Fecha',
|
16
|
+
placeholder: 'Fecha'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
activeView: true,
|
20
|
+
sortable: true,
|
21
|
+
accessor: 'passengerName',
|
22
|
+
subAccessor: '',
|
23
|
+
title: 'Pasajero',
|
24
|
+
viewIsFilter: true,
|
25
|
+
typeFilter: 'text',
|
26
|
+
subTypeFilter: false,
|
27
|
+
idInput: 'pasajero',
|
28
|
+
nameInput: 'Pasajero',
|
29
|
+
placeholder: 'Pasajero'
|
30
|
+
},
|
31
|
+
{
|
32
|
+
activeView: true,
|
33
|
+
sortable: true,
|
34
|
+
accessor: 'origin',
|
35
|
+
subAccessor: 'addressField',
|
36
|
+
title: 'Recogida',
|
37
|
+
viewIsFilter: true,
|
38
|
+
typeFilter: 'text',
|
39
|
+
subTypeFilter: false,
|
40
|
+
idInput: 'recogida',
|
41
|
+
nameInput: 'Recogida',
|
42
|
+
placeholder: 'Recogida'
|
43
|
+
},
|
44
|
+
{
|
45
|
+
activeView: true,
|
46
|
+
sortable: true,
|
47
|
+
accessor: 'destination',
|
48
|
+
subAccessor: 'addressField',
|
49
|
+
title: 'Destino',
|
50
|
+
viewIsFilter: true,
|
51
|
+
typeFilter: 'text',
|
52
|
+
subTypeFilter: false,
|
53
|
+
idInput: 'destino',
|
54
|
+
nameInput: 'Destino',
|
55
|
+
placeholder: 'Destino'
|
56
|
+
},
|
57
|
+
{
|
58
|
+
activeView: true,
|
59
|
+
sortable: true,
|
60
|
+
accessor: 'priceCustomer',
|
61
|
+
subAccessor: '',
|
62
|
+
title: 'Precio',
|
63
|
+
viewIsFilter: true,
|
64
|
+
typeFilter: 'text',
|
65
|
+
subTypeFilter: true,
|
66
|
+
idInput: 'precio',
|
67
|
+
nameInput: 'Precio',
|
68
|
+
placeholder: 'Precio'
|
69
|
+
},
|
70
|
+
{
|
71
|
+
activeView: false,
|
72
|
+
sortable: true,
|
73
|
+
accessor: 'id',
|
74
|
+
subAccessor: '',
|
75
|
+
title: 'ID',
|
76
|
+
viewIsFilter: true,
|
77
|
+
typeFilter: 'number',
|
78
|
+
subTypeFilter: false,
|
79
|
+
idInput: 'id',
|
80
|
+
nameInput: 'id',
|
81
|
+
placeholder: 'id'
|
82
|
+
},
|
83
|
+
{
|
84
|
+
activeView: false,
|
85
|
+
sortable: true,
|
86
|
+
accessor: 'idService',
|
87
|
+
subAccessor: '',
|
88
|
+
title: 'ID Reserva',
|
89
|
+
viewIsFilter: true,
|
90
|
+
typeFilter: 'number',
|
91
|
+
subTypeFilter: false,
|
92
|
+
idInput: 'IDReserva',
|
93
|
+
nameInput: 'ID Reserva',
|
94
|
+
placeholder: 'ID Reserva'
|
95
|
+
},
|
96
|
+
{
|
97
|
+
activeView: false,
|
98
|
+
sortable: true,
|
99
|
+
accessor: 'idSupplier',
|
100
|
+
subAccessor: '',
|
101
|
+
title: 'ID Proveedor',
|
102
|
+
viewIsFilter: true,
|
103
|
+
typeFilter: 'number',
|
104
|
+
subTypeFilter: false,
|
105
|
+
idInput: 'IDProveedor',
|
106
|
+
nameInput: 'ID Proveedor',
|
107
|
+
placeholder: 'ID Proveedor'
|
108
|
+
},
|
109
|
+
],
|
110
|
+
|
111
|
+
}
|
@@ -0,0 +1,236 @@
|
|
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
|
+
import useStateDate from '../../hook/useStateDate';
|
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
|
+
|
36
|
+
export const DatePicker = ({ getStyles, isLayoutDate, onChangeRange }) => {
|
37
|
+
|
38
|
+
const [isShowCalendar, setShowCalendar] = useState(false);
|
39
|
+
|
40
|
+
|
41
|
+
const { state, setState } = useStateDate();
|
42
|
+
|
43
|
+
|
44
|
+
// const [state, setState] = useState([
|
45
|
+
// {
|
46
|
+
// startDate: addDays(new Date(), -59),
|
47
|
+
// endDate: new Date(),
|
48
|
+
// key: 'selection',
|
49
|
+
// }
|
50
|
+
|
51
|
+
// ]);
|
52
|
+
|
53
|
+
moment.locale('es')
|
54
|
+
const format = "DD/MMMM/YYYY";
|
55
|
+
|
56
|
+
|
57
|
+
const handleSelectRange = (item) => {
|
58
|
+
setState([item.selection])
|
59
|
+
}
|
60
|
+
|
61
|
+
const handleSelect = (date) => {
|
62
|
+
console.log(date); // native Date object
|
63
|
+
console.log(state)
|
64
|
+
}
|
65
|
+
|
66
|
+
const handleClickOpenCalendar = () => {
|
67
|
+
setShowCalendar(true)
|
68
|
+
// console.log(state)
|
69
|
+
}
|
70
|
+
|
71
|
+
const handleClickCloseCalendar = () => {
|
72
|
+
setShowCalendar(false)
|
73
|
+
console.log(state)
|
74
|
+
};
|
75
|
+
|
76
|
+
|
77
|
+
return (
|
78
|
+
<div className={getStyles('date-picker')}>
|
79
|
+
|
80
|
+
{isLayoutDate === 'Calendar' ?
|
81
|
+
|
82
|
+
(<Calendar
|
83
|
+
date={new Date()}
|
84
|
+
onChange={handleSelect}
|
85
|
+
/>)
|
86
|
+
: isLayoutDate === 'DateRange' ?
|
87
|
+
|
88
|
+
(<DateRange
|
89
|
+
editableDateInputs={true}
|
90
|
+
onChange={item => useStateDate([item.selection])}
|
91
|
+
moveRangeOnFirstSelection={false}
|
92
|
+
ranges={state}
|
93
|
+
/>)
|
94
|
+
:
|
95
|
+
|
96
|
+
!isShowCalendar ?
|
97
|
+
<div className={getStyles('date-picker-input')}>
|
98
|
+
<div>
|
99
|
+
<Label>Desde</Label>
|
100
|
+
<Input
|
101
|
+
isInline
|
102
|
+
id="startDate"
|
103
|
+
onClick={handleClickOpenCalendar}
|
104
|
+
placeholder="Et harum quidem"
|
105
|
+
value={moment(state[0].startDate).format(format).toString()}
|
106
|
+
/>
|
107
|
+
<Vertical size="xs" />
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div>
|
111
|
+
<Label>Hasta</Label>
|
112
|
+
<Input
|
113
|
+
isInline
|
114
|
+
id="endDate"
|
115
|
+
onClick={handleClickOpenCalendar}
|
116
|
+
placeholder="Et harum quidem"
|
117
|
+
value={moment(state[0].endDate).format(format).toString()}
|
118
|
+
/>
|
119
|
+
</div>
|
120
|
+
</div>
|
121
|
+
:
|
122
|
+
<div className={getStyles('modalDatePickerRange')}>
|
123
|
+
|
124
|
+
<DateRangePicker
|
125
|
+
locale={locales.es}
|
126
|
+
dateDisplayFormat='d MMMM yyyy'
|
127
|
+
onChange={ item => {handleSelectRange(item); onChangeRange(item);}}
|
128
|
+
showSelectionPreview={false}
|
129
|
+
moveRangeOnFirstSelection={false}
|
130
|
+
months={2}
|
131
|
+
ranges={state}
|
132
|
+
direction="horizontal"
|
133
|
+
inputRanges={[
|
134
|
+
{
|
135
|
+
...defaultInputRanges[0],
|
136
|
+
label: 'Dias hasta hoy'
|
137
|
+
},
|
138
|
+
{
|
139
|
+
...defaultInputRanges[1],
|
140
|
+
label: 'Dias desde hoy'
|
141
|
+
}
|
142
|
+
]}
|
143
|
+
staticRanges={[
|
144
|
+
// ...defaultStaticRanges,
|
145
|
+
{
|
146
|
+
label: "Mes pasado",
|
147
|
+
range: () => ({
|
148
|
+
startDate: startOfMonth(addMonths(new Date(), -1)),
|
149
|
+
endDate: endOfMonth(addMonths(new Date(), -1))
|
150
|
+
}),
|
151
|
+
isSelected(range) {
|
152
|
+
const definedRange = this.range();
|
153
|
+
return (
|
154
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
155
|
+
isSameDay(range.endDate, definedRange.endDate)
|
156
|
+
);
|
157
|
+
}
|
158
|
+
},
|
159
|
+
{
|
160
|
+
label: "Mes actual",
|
161
|
+
range: () => ({
|
162
|
+
startDate: startOfMonth(new Date()),
|
163
|
+
endDate: endOfDay(new Date())
|
164
|
+
}),
|
165
|
+
isSelected(range) {
|
166
|
+
const definedRange = this.range();
|
167
|
+
return (
|
168
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
169
|
+
isSameDay(range.endDate, definedRange.endDate)
|
170
|
+
);
|
171
|
+
}
|
172
|
+
},
|
173
|
+
{
|
174
|
+
label: "Año pasado",
|
175
|
+
range: () => ({
|
176
|
+
startDate: startOfYear(addYears(new Date(), -1)),
|
177
|
+
endDate: endOfYear(addYears(new Date(), -1))
|
178
|
+
}),
|
179
|
+
isSelected(range) {
|
180
|
+
const definedRange = this.range();
|
181
|
+
return (
|
182
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
183
|
+
isSameDay(range.endDate, definedRange.endDate)
|
184
|
+
);
|
185
|
+
}
|
186
|
+
},
|
187
|
+
{
|
188
|
+
label: "Año actual",
|
189
|
+
range: () => ({
|
190
|
+
startDate: startOfYear(new Date()),
|
191
|
+
endDate: endOfDay(new Date())
|
192
|
+
}),
|
193
|
+
isSelected(range) {
|
194
|
+
const definedRange = this.range();
|
195
|
+
return (
|
196
|
+
isSameDay(range.startDate, definedRange.startDate) &&
|
197
|
+
isSameDay(range.endDate, definedRange.endDate)
|
198
|
+
);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
]}
|
202
|
+
/>
|
203
|
+
|
204
|
+
<div className={getStyles('btnSave')} onClick={handleClickCloseCalendar}>
|
205
|
+
<Icon
|
206
|
+
name="checkCircle"
|
207
|
+
color="inverted"
|
208
|
+
onClick={function noRefCheck() { }}
|
209
|
+
/>
|
210
|
+
</div>
|
211
|
+
|
212
|
+
{/* <DefinedRange
|
213
|
+
locale={locales.es}
|
214
|
+
onChange={item => useStateDate([item.selection])}
|
215
|
+
ranges={state}
|
216
|
+
/> */}
|
217
|
+
</div>
|
218
|
+
|
219
|
+
}
|
220
|
+
</div>
|
221
|
+
)
|
222
|
+
}
|
223
|
+
|
224
|
+
DatePicker.propTypes = {
|
225
|
+
getStyles: PropTypes.func.isRequired,
|
226
|
+
isLayoutDate: PropTypes.oneOf(options.typeLayoutDate),
|
227
|
+
onChangeRange: PropTypes.func
|
228
|
+
}
|
229
|
+
|
230
|
+
DatePicker.defaultProps = {
|
231
|
+
getStyles: () => { },
|
232
|
+
isLayoutDate: 'Calendar',
|
233
|
+
onChangeRange: () => { },
|
234
|
+
}
|
235
|
+
|
236
|
+
export default withStyles(styles)(DatePicker)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.date-picker {
|
2
|
+
display: block;
|
3
|
+
}
|
4
|
+
|
5
|
+
.date-picker-input {
|
6
|
+
display: flex;
|
7
|
+
/* width: 70%; */
|
8
|
+
}
|
9
|
+
|
10
|
+
.modalDatePickerRange {
|
11
|
+
display: flex;
|
12
|
+
position: absolute;
|
13
|
+
align-items: center;
|
14
|
+
justify-content: center;
|
15
|
+
width: 100%;
|
16
|
+
height: 100%;
|
17
|
+
top: 0;
|
18
|
+
left: 0;
|
19
|
+
background-color: rgb(0 0 0 / 60%);
|
20
|
+
z-index: 1;
|
21
|
+
}
|
22
|
+
|
23
|
+
.btnSave {
|
24
|
+
cursor: pointer;
|
25
|
+
width: 30px;
|
26
|
+
background-color: var(--color-tertiary-muted);
|
27
|
+
height: 420px;
|
28
|
+
align-items: center;
|
29
|
+
justify-content: center;
|
30
|
+
display: inline-flex;
|
31
|
+
height: inherit;
|
32
|
+
max-height: 383px;
|
33
|
+
height: 100%;
|
34
|
+
}
|
35
|
+
|
36
|
+
.btnSave:hover {
|
37
|
+
opacity: .8;
|
38
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { DatePicker, styles, options } from '.'
|
2
|
+
|
3
|
+
import {
|
4
|
+
getTemplate,
|
5
|
+
getListTemplate,
|
6
|
+
getOptionsArgTypes,
|
7
|
+
} from '../../helpers/storybook'
|
8
|
+
|
9
|
+
const Template = getTemplate(DatePicker, styles)
|
10
|
+
const ListTemplate = getListTemplate(DatePicker, styles)
|
11
|
+
|
12
|
+
export default {
|
13
|
+
title: 'Molecules/DatePicker',
|
14
|
+
component: DatePicker,
|
15
|
+
args: {},
|
16
|
+
argTypes: {
|
17
|
+
isLayoutDate: getOptionsArgTypes(options.typeLayoutDate),
|
18
|
+
},
|
19
|
+
}
|
20
|
+
|
21
|
+
export const Default = Template.bind({})
|
22
|
+
// export const List = ListTemplate.bind({})
|
23
|
+
// List.args = { items: options.types.map((type) => ({ type })) }
|
@@ -13,27 +13,30 @@ export const Dropdown = ({
|
|
13
13
|
value,
|
14
14
|
isInline,
|
15
15
|
onChange,
|
16
|
-
}) =>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
'
|
21
|
-
|
22
|
-
|
23
|
-
<Icon className="dropdown-icon" name="angleDown" background="highlight" />
|
24
|
-
<select
|
25
|
-
className={getStyles('dropdown-select')}
|
26
|
-
onChange={(event) => onChange(event?.currentTarget?.value)}
|
27
|
-
value={value}
|
16
|
+
}) => {
|
17
|
+
return (
|
18
|
+
<div
|
19
|
+
id={id}
|
20
|
+
className={getStyles('dropdown', {
|
21
|
+
'is-inline': isInline,
|
22
|
+
})}
|
28
23
|
>
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
24
|
+
<Icon className="dropdown-icon" name="angleDown" background="transparent" />
|
25
|
+
<select
|
26
|
+
className={getStyles('dropdown-select')}
|
27
|
+
onChange={(event) => onChange(event?.currentTarget?.value)}
|
28
|
+
value={value}
|
29
|
+
>
|
30
|
+
{options.map(({ text, value }) => (
|
31
|
+
<option key={value} value={value}>
|
32
|
+
{text}
|
33
|
+
</option>
|
34
|
+
))}
|
35
|
+
</select>
|
36
|
+
|
37
|
+
</div>
|
38
|
+
)
|
39
|
+
}
|
37
40
|
|
38
41
|
Dropdown.propTypes = {
|
39
42
|
onChange: PropTypes.func.isRequired,
|
@@ -52,8 +55,8 @@ Dropdown.propTypes = {
|
|
52
55
|
Dropdown.defaultProps = {
|
53
56
|
value: '',
|
54
57
|
isInline: false,
|
55
|
-
onChange: () => {},
|
56
|
-
getStyles: () => {},
|
58
|
+
onChange: () => { },
|
59
|
+
getStyles: () => { },
|
57
60
|
}
|
58
61
|
|
59
62
|
export default withStyles(styles)(Dropdown)
|