imbric-theme 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.dockerignore +14 -0
- package/.eslintignore +1 -0
- package/.prettierignore +1 -0
- package/.storybook/main.js +6 -2
- package/.storybook/preview.js +21 -0
- package/.vscode/settings.json +3 -0
- package/Dockerfile +17 -0
- package/atoms/AlertModal/AlertModal.js +69 -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 +17 -2
- package/atoms/Button/Button.module.css +25 -3
- package/atoms/Button/Button.stories.js +1 -1
- package/atoms/Button/__snapshots__/Button.stories.js.snap +8 -8
- package/atoms/Check/Check.js +6 -4
- package/atoms/Checkbox/Checkbox.js +77 -0
- package/atoms/Checkbox/Checkbox.module.css +60 -0
- package/atoms/Checkbox/Checkbox.stories.js +30 -0
- package/atoms/Checkbox/constants.js +1 -0
- package/atoms/Checkbox/index.js +3 -0
- package/atoms/Divider/Divider.js +5 -2
- package/atoms/Divider/Divider.module.css +20 -0
- package/atoms/Divider/Divider.stories.js +13 -2
- package/atoms/Divider/constants.js +3 -0
- package/atoms/Divider/index.js +1 -0
- package/atoms/Heading/Heading.js +1 -1
- package/atoms/Heading/Heading.module.css +4 -0
- package/atoms/Heading/Heading.stories.js +2 -2
- package/atoms/Heading/__snapshots__/Heading.stories.js.snap +16 -16
- package/atoms/Heading/constants.js +1 -1
- package/atoms/Icon/Icon.js +1 -1
- package/atoms/Icon/Icon.module.css +30 -0
- package/atoms/Icon/constants.js +750 -145
- package/atoms/Input/Input.js +195 -15
- package/atoms/Input/Input.module.css +62 -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 +42 -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/LinkItem/LinkItem.js +38 -0
- package/atoms/{Link/Link.module.css → LinkItem/LinkItem.module.css} +6 -1
- package/atoms/{Link/Link.stories.js → LinkItem/LinkItem.stories.js} +5 -5
- package/atoms/LinkItem/index.js +3 -0
- package/atoms/Modal/Modal.js +27 -4
- package/atoms/Modal/Modal.module.css +63 -6
- package/atoms/Paragraph/Paragraph.module.css +4 -0
- package/atoms/Paragraph/Paragraph.stories.js +2 -2
- package/atoms/Paragraph/__snapshots__/Paragraph.stories.js.snap +16 -16
- package/atoms/Picture/Picture.js +9 -2
- package/atoms/Tab/Tab.js +41 -0
- package/atoms/Tab/Tab.module.css +17 -0
- package/atoms/Tab/Tab.stories.js +27 -0
- package/atoms/Tab/constants.js +1 -0
- package/atoms/Tab/index.js +3 -0
- package/atoms/Textarea/Textarea.js +106 -15
- package/atoms/Textarea/Textarea.module.css +31 -2
- package/atoms/Toggle/Toggle.js +56 -0
- package/atoms/Toggle/Toggle.module.css +41 -0
- package/atoms/Toggle/Toggle.stories.js +21 -0
- package/atoms/Toggle/constants.js +1 -0
- package/atoms/Toggle/index.js +3 -0
- package/helpers/storybook.js +2 -2
- package/hook/useAddColumn.js +40 -0
- package/hook/useStateDate.js +25 -0
- package/hook/useTable.js +54 -0
- package/index.js +41 -1
- package/jest.config.js +1 -1
- package/layout/DynamicTable/DynamicTable.js +372 -0
- package/layout/DynamicTable/DynamicTable.module.css +62 -0
- package/layout/DynamicTable/DynamicTable.stories.js +79 -0
- package/layout/DynamicTable/constants.js +323 -0
- package/layout/DynamicTable/index.js +3 -0
- package/layout/FlexColumnContent/FlexColumnContent.js +26 -0
- package/layout/FlexColumnContent/FlexColumnContent.module.css +5 -0
- package/layout/FlexColumnContent/FlexColumnContent.stories.js +28 -0
- package/layout/FlexColumnContent/constants.js +1 -0
- package/layout/FlexColumnContent/index.js +3 -0
- package/layout/Navbar/Navbar.js +247 -0
- package/layout/Navbar/Navbar.module.css +35 -0
- package/layout/Navbar/Navbar.stories.js +20 -0
- package/layout/Navbar/constants.js +35 -0
- package/layout/Navbar/index.js +2 -0
- package/layout/Sidebar/Sidebar.js +115 -0
- package/layout/Sidebar/Sidebar.module.css +387 -0
- package/layout/Sidebar/Sidebar.stories.js +28 -0
- package/layout/Sidebar/constants.js +228 -0
- package/layout/Sidebar/index.js +3 -0
- package/molecules/Accordion/Accordion.js +11 -11
- package/molecules/CardDefault/CardDefault.js +65 -0
- package/molecules/CardDefault/CardDefault.module.css +19 -0
- package/molecules/CardDefault/CardDefault.stories.js +23 -0
- package/molecules/CardDefault/constants.js +1 -0
- package/molecules/CardDefault/index.js +3 -0
- package/molecules/CardProductTypesBooking/CardProductTypesBooking.js +89 -0
- package/molecules/CardProductTypesBooking/CardProductTypesBooking.module.css +118 -0
- package/molecules/CardProductTypesBooking/CardProductTypesBooking.stories.js +25 -0
- package/molecules/CardProductTypesBooking/constants.js +1 -0
- package/molecules/CardProductTypesBooking/index.js +3 -0
- package/molecules/CardServiceDetail/CardServiceDetail.js +400 -0
- package/molecules/CardServiceDetail/CardServiceDetail.module.css +222 -0
- package/molecules/CardServiceDetail/CardServiceDetail.stories.js +23 -0
- package/molecules/CardServiceDetail/constants.js +1 -0
- package/molecules/CardServiceDetail/index.js +3 -0
- package/molecules/CardServices/CardServices.js +461 -0
- package/molecules/CardServices/CardServices.module.css +213 -0
- package/molecules/CardServices/CardServices.stories.js +41 -0
- package/molecules/CardServices/constants.js +5 -0
- package/molecules/CardServices/index.js +3 -0
- package/molecules/CardServicesFinalized/CardServicesFinalized.js +381 -0
- package/molecules/CardServicesFinalized/CardServicesFinalized.module.css +213 -0
- package/molecules/CardServicesFinalized/CardServicesFinalized.stories.js +23 -0
- package/molecules/CardServicesFinalized/constants.js +1 -0
- package/molecules/CardServicesFinalized/index.js +3 -0
- 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 +155 -0
- package/molecules/ColumnTable/ColumnTable.module.css +51 -0
- package/molecules/ColumnTable/ColumnTable.stories.js +26 -0
- package/molecules/ColumnTable/constants.js +117 -0
- package/molecules/ColumnTable/index.js +3 -0
- package/molecules/DatePicker/DatePicker.js +242 -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/DatePickerTime/DatePickerTime.js +133 -0
- package/molecules/DatePickerTime/DatePickerTime.module.css +3 -0
- package/molecules/DatePickerTime/DatePickerTime.stories.js +18 -0
- package/molecules/DatePickerTime/constants.js +1 -0
- package/molecules/DatePickerTime/index.js +3 -0
- package/molecules/Dropdown/Dropdown.js +26 -23
- package/molecules/Dropdown/Dropdown.module.css +21 -3
- package/molecules/DynamicSelect/DynamicSelect.js +186 -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 +166 -0
- package/molecules/FooterTable/FooterTable.module.css +63 -0
- package/molecules/FooterTable/FooterTable.stories.js +23 -0
- package/molecules/FooterTable/constants.js +9 -0
- package/molecules/FooterTable/index.js +3 -0
- package/molecules/InputAutocomplete/InputAutocomplete.js +221 -0
- package/molecules/InputAutocomplete/InputAutocomplete.module.css +55 -0
- package/molecules/InputAutocomplete/InputAutocomplete.stories.js +23 -0
- package/molecules/InputAutocomplete/constants.js +1 -0
- package/molecules/InputAutocomplete/index.js +3 -0
- package/molecules/ItemMenu/ItemMenu.js +134 -0
- package/molecules/ItemMenu/ItemMenu.module.css +363 -0
- package/molecules/ItemMenu/ItemMenu.stories.js +42 -0
- package/molecules/ItemMenu/constants.js +36 -0
- package/molecules/ItemMenu/index.js +3 -0
- package/molecules/RowTable/RowTable.js +928 -0
- package/molecules/RowTable/RowTable.module.css +63 -0
- package/molecules/RowTable/RowTable.stories.js +26 -0
- package/molecules/RowTable/constants.js +798 -0
- package/molecules/RowTable/index.js +3 -0
- package/molecules/Tabs/Tabs.js +59 -0
- package/molecules/Tabs/Tabs.module.css +13 -0
- package/molecules/Tabs/Tabs.stories.js +34 -0
- package/molecules/Tabs/constants.js +34 -0
- package/molecules/Tabs/index.js +3 -0
- package/package.json +33 -16
- 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/favicon.ico +0 -0
- package/public/static/google-maps.png +0 -0
- package/public/static/images/folders-folder.svg +26 -0
- package/public/static/images/permissions.svg +14 -0
- package/public/static/images/reports-results.svg +18 -0
- package/public/static/logo.svg +19 -0
- package/public/static/logologin.png +0 -0
- package/public/static/logologin.svg +16 -0
- package/public/static/logologintagos.svg +19 -0
- package/public/static/logotipo.svg +50 -0
- package/public/static/logotipoS.svg +26 -0
- package/public/static/taxisvalencia_logod.png +0 -0
- package/scripts/create-component.js +2 -1
- package/styles/GrupoMutua.css +391 -0
- package/styles/default.css +391 -0
- package/styles/globals.css +1514 -0
- package/styles/radiotaxiaragon.css +391 -0
- package/styles/spartan.css +391 -0
- package/styles/tagos.css +391 -0
- package/styles/taxisvalencia.css +391 -0
- package/styles/tokens.css +2 -1
- package/tokens/index.js +2 -1
- package/.eslintcache +0 -1
- package/atoms/Link/Link.js +0 -33
- package/atoms/Link/index.js +0 -3
- /package/atoms/{Link → LinkItem}/__snapshots__/Link.stories.js.snap +0 -0
- /package/atoms/{Link → LinkItem}/constants.js +0 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
.toggle {
|
2
|
+
display: flex;
|
3
|
+
}
|
4
|
+
|
5
|
+
.toggle-item {
|
6
|
+
opacity: 0;
|
7
|
+
width: 3em;
|
8
|
+
height: 1.4em;
|
9
|
+
position: absolute;
|
10
|
+
z-index: 1;
|
11
|
+
cursor: pointer;
|
12
|
+
}
|
13
|
+
.toggle-item + .checkbox-custom-label {
|
14
|
+
display: flex;
|
15
|
+
width: 4em;
|
16
|
+
height: 2em;
|
17
|
+
background: #aaa;
|
18
|
+
border-radius: 50px;
|
19
|
+
position: relative;
|
20
|
+
transition: all .3s ease;
|
21
|
+
cursor: pointer;
|
22
|
+
box-shadow: inset 0 0 5px #222;
|
23
|
+
}
|
24
|
+
.toggle-item + .checkbox-custom-label:after {
|
25
|
+
content: '';
|
26
|
+
position: absolute;
|
27
|
+
width: 1.5em;
|
28
|
+
height: 1.5em;
|
29
|
+
background: #fff;
|
30
|
+
border-radius: 50%;
|
31
|
+
top: .25em;
|
32
|
+
left: .25em;
|
33
|
+
transition: all .2s ease;
|
34
|
+
}
|
35
|
+
.toggle-item:checked + .checkbox-custom-label {
|
36
|
+
background: var(--color-tertiary);
|
37
|
+
box-shadow: inset 0 0 5px rgb(95, 95, 95);
|
38
|
+
}
|
39
|
+
.toggle-item:checked + .checkbox-custom-label:after {
|
40
|
+
left: 2.3em;
|
41
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Toggle, styles, options } from '.'
|
2
|
+
|
3
|
+
import {
|
4
|
+
getTemplate,
|
5
|
+
getListTemplate,
|
6
|
+
getOptionsArgTypes,
|
7
|
+
} from '../../helpers/storybook'
|
8
|
+
|
9
|
+
const Template = getTemplate(Toggle, styles)
|
10
|
+
const ListTemplate = getListTemplate(Toggle, styles)
|
11
|
+
|
12
|
+
export default {
|
13
|
+
title: 'Atoms/Toggle',
|
14
|
+
component: Toggle,
|
15
|
+
args: {},
|
16
|
+
argTypes: {
|
17
|
+
// types: getOptionsArgTypes(options.types),
|
18
|
+
},
|
19
|
+
}
|
20
|
+
|
21
|
+
export const Default = Template.bind({})
|
@@ -0,0 +1 @@
|
|
1
|
+
export const options = { types: [] }
|
package/helpers/storybook.js
CHANGED
@@ -20,8 +20,8 @@ export const getListTemplate = (Component, styles) => ({ items, ...args }) =>
|
|
20
20
|
)
|
21
21
|
})
|
22
22
|
|
23
|
-
export const getOptionsArgTypes = (options) => ({
|
24
|
-
description:
|
23
|
+
export const getOptionsArgTypes = (options, description = '**Options:**') => ({
|
24
|
+
description: description,
|
25
25
|
table: {
|
26
26
|
type: { summary: options.map((option) => `'${option}'`).join('|') },
|
27
27
|
},
|
@@ -0,0 +1,40 @@
|
|
1
|
+
const useAddColumn = (event) => {
|
2
|
+
|
3
|
+
let listKeyColumnOrder = []
|
4
|
+
|
5
|
+
event.forEach(element => {
|
6
|
+
listKeyColumnOrder[element.value] = true
|
7
|
+
});
|
8
|
+
|
9
|
+
for (const itemAddColumns of addColumsData) {
|
10
|
+
if (listKeyColumnOrder[itemAddColumns.value]) {
|
11
|
+
itemAddColumns.activeView = true
|
12
|
+
} else {
|
13
|
+
itemAddColumns.activeView = false
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
|
18
|
+
for (const itemEvent of addColumsData) {
|
19
|
+
|
20
|
+
for (const itemColumns of columnsData) {
|
21
|
+
|
22
|
+
if (itemColumns.accessor === itemEvent.value) {
|
23
|
+
|
24
|
+
if (itemEvent.activeView) {
|
25
|
+
itemColumns.activeView = true
|
26
|
+
} else {
|
27
|
+
itemColumns.activeView = false
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
setColumnsData([])
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
export default useAddColumn
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { useEffect, useState } from 'react'
|
2
|
+
import {
|
3
|
+
addDays,
|
4
|
+
} from "date-fns";
|
5
|
+
|
6
|
+
const useStateDate = () => {
|
7
|
+
|
8
|
+
const [state, setState] = useState([
|
9
|
+
{
|
10
|
+
startDate: addDays(new Date(), -59),
|
11
|
+
endDate: new Date(),
|
12
|
+
key: 'selection',
|
13
|
+
}
|
14
|
+
]);
|
15
|
+
|
16
|
+
|
17
|
+
useEffect(() => {
|
18
|
+
|
19
|
+
}, [state]);
|
20
|
+
|
21
|
+
|
22
|
+
return { state, setState }
|
23
|
+
}
|
24
|
+
|
25
|
+
export default useStateDate
|
package/hook/useTable.js
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
import { useState, useEffect } from 'react'
|
2
|
+
|
3
|
+
const calculateRange = (dataTotalQueryCount, data, rowsPerPage) => {
|
4
|
+
const range = []
|
5
|
+
if (!data) {
|
6
|
+
var num = Math.ceil(1)
|
7
|
+
} else {
|
8
|
+
// num = Math.ceil(data.length / rowsPerPage)
|
9
|
+
num = Math.ceil(dataTotalQueryCount / rowsPerPage)
|
10
|
+
}
|
11
|
+
|
12
|
+
// const num = Math.ceil(data.length / rowsPerPage);
|
13
|
+
|
14
|
+
// let i = 1;
|
15
|
+
for (let i = 1; i <= num; i++) {
|
16
|
+
range.push(i)
|
17
|
+
}
|
18
|
+
return range
|
19
|
+
}
|
20
|
+
|
21
|
+
// const sliceData = (data, page, rowsPerPage) => {
|
22
|
+
// if (!data) {
|
23
|
+
// return (data = [])
|
24
|
+
// } else {
|
25
|
+
// // return data.slice((page - 1) * rowsPerPage, page * rowsPerPage)
|
26
|
+
// return data
|
27
|
+
// }
|
28
|
+
// }
|
29
|
+
|
30
|
+
const sliceData = (data) => {
|
31
|
+
if (!data) {
|
32
|
+
return (data = [])
|
33
|
+
} else {
|
34
|
+
// return data.slice((page - 1) * rowsPerPage, page * rowsPerPage)
|
35
|
+
return data
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
const useTable = (dataTotalQueryCount, data, page, rowsPerPage) => {
|
40
|
+
const [tableRange, setTableRange] = useState([])
|
41
|
+
const [slice, setSlice] = useState([])
|
42
|
+
|
43
|
+
useEffect(() => {
|
44
|
+
const range = calculateRange(dataTotalQueryCount, data, rowsPerPage)
|
45
|
+
setTableRange([...range])
|
46
|
+
|
47
|
+
const slice = sliceData(data, page, rowsPerPage)
|
48
|
+
setSlice([...slice])
|
49
|
+
}, [dataTotalQueryCount, data, setTableRange, page, setSlice, rowsPerPage])
|
50
|
+
|
51
|
+
return { slice, range: tableRange }
|
52
|
+
}
|
53
|
+
|
54
|
+
export default useTable
|
package/index.js
CHANGED
@@ -1,31 +1,71 @@
|
|
1
|
+
// Pages
|
2
|
+
export { default as Login } from './pages/Login'
|
3
|
+
|
1
4
|
// Layout
|
2
5
|
export { default as CenteredContent } from './layout/CenteredContent'
|
3
6
|
export { default as Container } from './layout/Container'
|
4
7
|
export { default as FullHeightContent } from './layout/FullHeightContent'
|
8
|
+
export { default as FlexColumnContent } from './layout/FlexColumnContent'
|
5
9
|
export { default as Spacer } from './layout/Spacer'
|
10
|
+
export { default as Sidebar } from './layout/Sidebar'
|
11
|
+
export { default as Navbar } from './layout/Navbar'
|
12
|
+
export { default as DynamicTable } from './layout/DynamicTable'
|
13
|
+
|
6
14
|
|
7
15
|
// Atoms
|
16
|
+
export { default as AlertModal } from './atoms/AlertModal'
|
8
17
|
export { default as Avatar } from './atoms/Avatar'
|
9
18
|
export { default as Button } from './atoms/Button'
|
10
19
|
export { default as Card } from './atoms/Card'
|
11
20
|
export { default as Check } from './atoms/Check'
|
21
|
+
export { default as Checkbox } from './atoms/Checkbox'
|
12
22
|
export { default as Divider } from './atoms/Divider'
|
13
23
|
export { default as Heading } from './atoms/Heading'
|
14
24
|
export { default as Icon } from './atoms/Icon'
|
15
25
|
export { default as Input } from './atoms/Input'
|
16
|
-
export { default as
|
26
|
+
export { default as Label } from './atoms/Label'
|
27
|
+
export { default as LinkItem } from './atoms/LinkItem'
|
28
|
+
export { default as Loading } from './atoms/Loading'
|
17
29
|
export { default as Modal } from './atoms/Modal'
|
18
30
|
export { default as Paragraph } from './atoms/Paragraph'
|
19
31
|
export { default as Picture } from './atoms/Picture'
|
20
32
|
export { default as Textarea } from './atoms/Textarea'
|
33
|
+
export { default as Tab } from './atoms/Tab'
|
34
|
+
export { default as Toggle } from './atoms/Toggle'
|
35
|
+
|
36
|
+
|
21
37
|
|
22
38
|
// Molecules
|
23
39
|
export { default as Accordion } from './molecules/Accordion'
|
24
40
|
export { default as AddButton } from './molecules/AddButton'
|
25
41
|
export { default as ButtonIcon } from './molecules/ButtonIcon'
|
42
|
+
export { default as CardServiceDetail } from './molecules/CardServiceDetail'
|
43
|
+
export { default as CardServices } from './molecules/CardServices'
|
44
|
+
export { default as CardServicesFinalized } from './molecules/CardServicesFinalized'
|
45
|
+
export { default as CardProductTypesBooking } from './molecules/CardProductTypesBooking'
|
26
46
|
export { default as Dropdown } from './molecules/Dropdown'
|
27
47
|
export { default as LoadingError } from './molecules/LoadingError'
|
28
48
|
export { default as Score } from './molecules/Score'
|
29
49
|
export { default as Task } from './molecules/Task'
|
30
50
|
export { default as TaskCounter } from './molecules/TaskCounter'
|
31
51
|
export { default as IconLabel } from './molecules/IconLabel'
|
52
|
+
export { default as ItemMenu } from './molecules/ItemMenu'
|
53
|
+
export { default as InputAutocomplete } from './molecules/InputAutocomplete'
|
54
|
+
export { default as CheckList } from './molecules/CheckList'
|
55
|
+
export { default as ColumnTable } from './molecules/ColumnTable'
|
56
|
+
export { default as RowTable } from './molecules/RowTable'
|
57
|
+
export { default as FooterTable } from './molecules/FooterTable'
|
58
|
+
export { default as DynamicSelect } from './molecules/DynamicSelect'
|
59
|
+
export { default as DatePicker } from './molecules/DynamicSelect'
|
60
|
+
export { default as CardDefault } from './molecules/CardDefault'
|
61
|
+
export { default as Tabs } from './molecules/Tabs'
|
62
|
+
export { default as DatePickerTime } from './molecules/DatePickerTime'
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
export { default as useTable } from './hook/useTable'
|
68
|
+
export { default as useStateDate } from './hook/useStateDate'
|
69
|
+
|
70
|
+
|
71
|
+
|
package/jest.config.js
CHANGED
@@ -0,0 +1,372 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { useEffect, useState } from 'react'
|
3
|
+
import PropTypes from 'prop-types'
|
4
|
+
import styles from './DynamicTable.module.css'
|
5
|
+
import withStyles from '../../hocs/withStyles'
|
6
|
+
import DynamicSelect from '../../molecules/DynamicSelect'
|
7
|
+
import DatePicker from '../../molecules/DatePicker'
|
8
|
+
import Label from '../../atoms/Label'
|
9
|
+
import Icon from '../../atoms/Icon'
|
10
|
+
import Button from '../../atoms/Button'
|
11
|
+
import { Horizontal, Vertical } from '../../layout/Spacer/components'
|
12
|
+
import ReactTooltip from 'react-tooltip'
|
13
|
+
import Heading from '../../atoms/Heading/Heading'
|
14
|
+
|
15
|
+
|
16
|
+
export const DynamicTable = ({
|
17
|
+
getStyles,
|
18
|
+
optionsData,
|
19
|
+
opColumns,
|
20
|
+
opAddColumns,
|
21
|
+
opFilterTable,
|
22
|
+
isLayoutDate,
|
23
|
+
isViewRange,
|
24
|
+
isViewTitleTable,
|
25
|
+
isViewAddColumn,
|
26
|
+
isViewFilterTable,
|
27
|
+
isViewBtn,
|
28
|
+
isViewLeftBtn,
|
29
|
+
isViewLeftBtnSecondary,
|
30
|
+
isViewLeftBtnTertiary,
|
31
|
+
isViewDownloadDoc,
|
32
|
+
typeBtn,
|
33
|
+
typeBtnSecondary,
|
34
|
+
typeBtnTertiary,
|
35
|
+
titleBtn,
|
36
|
+
titleBtnSecondary,
|
37
|
+
titleBtnTertiary,
|
38
|
+
handleBtn,
|
39
|
+
handleBtnSecondary,
|
40
|
+
handleBtnTertiary,
|
41
|
+
handleAddColumn,
|
42
|
+
handleFilterTable,
|
43
|
+
handleSelectRange,
|
44
|
+
handleDownloadExcel,
|
45
|
+
handleDefaultValue,
|
46
|
+
handleDefaultValueFilter,
|
47
|
+
labelDinamicSelect,
|
48
|
+
placeholderDinamicSelect,
|
49
|
+
isLoadingDinamicSelect,
|
50
|
+
labelDinamicSelectFilter,
|
51
|
+
placeholderDinamicSelectFilter,
|
52
|
+
isLoadingDinamicSelectFilter,
|
53
|
+
labelSinceDateRange,
|
54
|
+
labelTillDateRange,
|
55
|
+
txtTootipFileDownload,
|
56
|
+
titleHeadingTable,
|
57
|
+
}) => {
|
58
|
+
|
59
|
+
const [tableData, setTableData] = useState(optionsData);
|
60
|
+
const [columnsData, setColumnsData] = useState(opColumns);
|
61
|
+
const [addColumsData, setAddColumsData] = useState(opAddColumns);
|
62
|
+
const [filterTableData, setFilterTableData] = useState(opFilterTable);
|
63
|
+
|
64
|
+
|
65
|
+
// STATE TOOLTIP
|
66
|
+
const [isToolTipMounted, setIsToolTipMounted] = useState(false)
|
67
|
+
|
68
|
+
// TOOLTIP
|
69
|
+
const handleMouseEnter = () => {
|
70
|
+
setIsToolTipMounted(true)
|
71
|
+
}
|
72
|
+
const handleMouseLeave = () => {
|
73
|
+
setIsToolTipMounted(false)
|
74
|
+
}
|
75
|
+
|
76
|
+
useEffect(() => {
|
77
|
+
setColumnsData(opColumns);
|
78
|
+
})
|
79
|
+
|
80
|
+
const handleSorting = (sortField, sortOrder) => {
|
81
|
+
if (sortField) {
|
82
|
+
const sorted = [...tableData].sort((a, b) => {
|
83
|
+
if (a[sortField] === null) return 1;
|
84
|
+
if (b[sortField] === null) return -1;
|
85
|
+
if (a[sortField] === null && b[sortField] === null) return 0;
|
86
|
+
return (
|
87
|
+
a[sortField].toString().localeCompare(b[sortField].toString(), "en", {
|
88
|
+
numeric: true,
|
89
|
+
}) * (sortOrder === "asc" ? 1 : -1)
|
90
|
+
);
|
91
|
+
});
|
92
|
+
setTableData(sorted);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
return (
|
97
|
+
|
98
|
+
|
99
|
+
<div className={getStyles('opFunction')}>
|
100
|
+
|
101
|
+
|
102
|
+
<div className={getStyles('opFunctionBoxTotal2')}>
|
103
|
+
|
104
|
+
{isViewTitleTable ? (
|
105
|
+
<div className={getStyles('opFunctionBox1')}>
|
106
|
+
<Heading
|
107
|
+
size="sm"
|
108
|
+
>
|
109
|
+
{titleHeadingTable}
|
110
|
+
</Heading>
|
111
|
+
</div>
|
112
|
+
) : null}
|
113
|
+
|
114
|
+
{isViewLeftBtn ? (
|
115
|
+
|
116
|
+
<>
|
117
|
+
|
118
|
+
<div className={getStyles('opFunctionBox3')}>
|
119
|
+
|
120
|
+
<Button
|
121
|
+
type={typeBtn}
|
122
|
+
isInline={true}
|
123
|
+
onClick={handleBtn}
|
124
|
+
>
|
125
|
+
{titleBtn}
|
126
|
+
</Button>
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</>
|
130
|
+
) : null}
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
{isViewLeftBtnSecondary ? (
|
135
|
+
|
136
|
+
<>
|
137
|
+
|
138
|
+
<div className={getStyles('opFunctionBox3')}>
|
139
|
+
|
140
|
+
<Button
|
141
|
+
type={typeBtnSecondary}
|
142
|
+
isInline={true}
|
143
|
+
onClick={handleBtnSecondary}
|
144
|
+
>
|
145
|
+
{titleBtnSecondary}
|
146
|
+
</Button>
|
147
|
+
|
148
|
+
</div>
|
149
|
+
</>
|
150
|
+
) : null}
|
151
|
+
|
152
|
+
{isViewLeftBtnTertiary ? (
|
153
|
+
|
154
|
+
<>
|
155
|
+
|
156
|
+
<div className={getStyles('opFunctionBox3')}>
|
157
|
+
|
158
|
+
<Button
|
159
|
+
type={typeBtnTertiary}
|
160
|
+
isInline={true}
|
161
|
+
onClick={handleBtnTertiary}
|
162
|
+
>
|
163
|
+
{titleBtnTertiary}
|
164
|
+
</Button>
|
165
|
+
|
166
|
+
</div>
|
167
|
+
</>
|
168
|
+
) : null}
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
{isViewRange ? (
|
173
|
+
<div className={getStyles('opFunctionBox1')}>
|
174
|
+
<DatePicker
|
175
|
+
isLayoutDate={isLayoutDate}
|
176
|
+
onChangeRange={handleSelectRange}
|
177
|
+
sinceDateRange={labelSinceDateRange}
|
178
|
+
tillDateRange={labelTillDateRange}
|
179
|
+
/>
|
180
|
+
</div>
|
181
|
+
) : null}
|
182
|
+
</div>
|
183
|
+
<div className={getStyles('opFunctionBox2')}>
|
184
|
+
|
185
|
+
|
186
|
+
{isViewFilterTable ? (
|
187
|
+
<div className={getStyles('opFunctionBox3')}>
|
188
|
+
<Label>{labelDinamicSelectFilter}</Label>
|
189
|
+
|
190
|
+
{isLoadingDinamicSelectFilter ?
|
191
|
+
<DynamicSelect
|
192
|
+
isInline
|
193
|
+
onChange={handleFilterTable}
|
194
|
+
optionsSelect={filterTableData}
|
195
|
+
placeholder={placeholderDinamicSelectFilter}
|
196
|
+
defaultValue={handleDefaultValueFilter}
|
197
|
+
closeMenuOnSelect={false}
|
198
|
+
isClearable={false}
|
199
|
+
instanceId={'idFilterTableAll'}
|
200
|
+
// defaultValue= { [{value: 'id', label: 'ID'}, {value: 'idService', label: 'ID Reserva'}] }
|
201
|
+
/> : null
|
202
|
+
}
|
203
|
+
|
204
|
+
</div>
|
205
|
+
) : null}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
{isViewAddColumn ? (
|
210
|
+
<div className={getStyles('opFunctionBox3')}>
|
211
|
+
<Label>{labelDinamicSelect}</Label>
|
212
|
+
|
213
|
+
{isLoadingDinamicSelect ?
|
214
|
+
<DynamicSelect
|
215
|
+
isMulti
|
216
|
+
isInline
|
217
|
+
onChange={handleAddColumn}
|
218
|
+
optionsSelect={addColumsData}
|
219
|
+
placeholder={placeholderDinamicSelect}
|
220
|
+
defaultValue={handleDefaultValue}
|
221
|
+
closeMenuOnSelect={false}
|
222
|
+
instanceId={'idAddColumsTable'}
|
223
|
+
// defaultValue= { [{value: 'id', label: 'ID'}, {value: 'idService', label: 'ID Reserva'}] }
|
224
|
+
/> : null
|
225
|
+
}
|
226
|
+
|
227
|
+
</div>
|
228
|
+
) : null}
|
229
|
+
|
230
|
+
|
231
|
+
{isViewBtn ? (
|
232
|
+
|
233
|
+
<>
|
234
|
+
|
235
|
+
<div className={getStyles('opFunctionBox3')}>
|
236
|
+
|
237
|
+
<Button
|
238
|
+
type={typeBtn}
|
239
|
+
isInline={true}
|
240
|
+
onClick={handleBtn}
|
241
|
+
>
|
242
|
+
{titleBtn}
|
243
|
+
</Button>
|
244
|
+
|
245
|
+
</div>
|
246
|
+
</>
|
247
|
+
) : null}
|
248
|
+
|
249
|
+
|
250
|
+
{isViewDownloadDoc ? (
|
251
|
+
<div id='boxFileDownload' className={getStyles('opFunctionBox3')}>
|
252
|
+
|
253
|
+
|
254
|
+
<span
|
255
|
+
data-tip
|
256
|
+
data-for='fileDownload'
|
257
|
+
onMouseEnter={handleMouseEnter}
|
258
|
+
onMouseLeave={handleMouseLeave}
|
259
|
+
>
|
260
|
+
<Icon
|
261
|
+
key="fileDownload"
|
262
|
+
background="inverted"
|
263
|
+
name="fileDownload"
|
264
|
+
onClick={handleDownloadExcel}
|
265
|
+
/>
|
266
|
+
|
267
|
+
</span>
|
268
|
+
|
269
|
+
{isToolTipMounted ? (
|
270
|
+
<ReactTooltip id='fileDownload' type='error'>
|
271
|
+
<span>{txtTootipFileDownload}</span>
|
272
|
+
</ReactTooltip>
|
273
|
+
) : null}
|
274
|
+
|
275
|
+
|
276
|
+
</div>
|
277
|
+
) : null}
|
278
|
+
|
279
|
+
</div>
|
280
|
+
|
281
|
+
</div>
|
282
|
+
|
283
|
+
// <ColumnTable
|
284
|
+
// handleSorting={handleSorting}
|
285
|
+
// onChangeInput={onChangeInput}
|
286
|
+
// columnsData={columnsData}
|
287
|
+
// >
|
288
|
+
// {item.title}
|
289
|
+
// </ColumnTable>
|
290
|
+
|
291
|
+
// <RowTable slice={slice} columnsData={columnsData}></RowTable>
|
292
|
+
|
293
|
+
// <FooterTable range={range} slice={slice} setPage={setPage} page={page} />
|
294
|
+
|
295
|
+
|
296
|
+
)
|
297
|
+
}
|
298
|
+
|
299
|
+
DynamicTable.propTypes = {
|
300
|
+
// children: PropTypes.node.isRequired,
|
301
|
+
getStyles: PropTypes.func.isRequired,
|
302
|
+
isViewRange: PropTypes.bool,
|
303
|
+
isViewTitleTable: PropTypes.bool,
|
304
|
+
isViewAddColumn: PropTypes.bool,
|
305
|
+
isViewFilterTable: PropTypes.bool,
|
306
|
+
isViewDownloadDoc: PropTypes.bool,
|
307
|
+
isViewBtn: PropTypes.bool,
|
308
|
+
isViewLeftBtn: PropTypes.bool,
|
309
|
+
onChangeInput: PropTypes.func,
|
310
|
+
handleAddColumn: PropTypes.func,
|
311
|
+
handleFilterTable: PropTypes.func,
|
312
|
+
isError: PropTypes.string,
|
313
|
+
isLayoutDate: PropTypes.string,
|
314
|
+
handleSelectRange: PropTypes.func,
|
315
|
+
handleDownloadExcel: PropTypes.func,
|
316
|
+
labelDinamicSelect: PropTypes.string,
|
317
|
+
placeholderDinamicSelect: PropTypes.string,
|
318
|
+
labelDinamicSelectFilter: PropTypes.string,
|
319
|
+
placeholderDinamicSelectFilter: PropTypes.string,
|
320
|
+
labelSinceDateRange: PropTypes.string,
|
321
|
+
labelTillDateRange: PropTypes.string,
|
322
|
+
typeBtn: PropTypes.string,
|
323
|
+
titleBtn: PropTypes.string,
|
324
|
+
handleBtn: PropTypes.func,
|
325
|
+
isViewLeftBtnSecondary: PropTypes.bool,
|
326
|
+
isViewLeftBtnTertiary: PropTypes.bool,
|
327
|
+
typeBtnSecondary: PropTypes.string,
|
328
|
+
typeBtnTertiary: PropTypes.string,
|
329
|
+
titleBtnSecondary: PropTypes.string,
|
330
|
+
titleBtnTertiary: PropTypes.string,
|
331
|
+
handleBtnSecondary: PropTypes.func,
|
332
|
+
handleBtnTertiary: PropTypes.func,
|
333
|
+
txtTootipFileDownload: PropTypes.string,
|
334
|
+
titleHeadingTable: PropTypes.string,
|
335
|
+
}
|
336
|
+
|
337
|
+
DynamicTable.defaultProps = {
|
338
|
+
getStyles: () => { },
|
339
|
+
handleAddColumn: () => { },
|
340
|
+
handleFilterTable: () => { },
|
341
|
+
isViewRange: true,
|
342
|
+
isViewTitleTable: false,
|
343
|
+
isViewAddColumn: true,
|
344
|
+
isViewFilterTable: false,
|
345
|
+
isViewDownloadDoc: true,
|
346
|
+
isViewBtn: false,
|
347
|
+
isViewLeftBtn: false,
|
348
|
+
isLayoutDate: 'Calendar',
|
349
|
+
handleSelectRange: () => { },
|
350
|
+
handleDownloadExcel: () => { },
|
351
|
+
labelDinamicSelect: 'Mostrar u ocultar columnas',
|
352
|
+
placeholderDinamicSelect: 'Seleccionar columnas',
|
353
|
+
labelDinamicSelectFilter: '',
|
354
|
+
placeholderDinamicSelectFilter: '',
|
355
|
+
labelSinceDateRange: 'Desde',
|
356
|
+
labelTillDateRange: 'Hasta',
|
357
|
+
typeBtn: 'primary',
|
358
|
+
titleBtn: '',
|
359
|
+
handleBtn: () => { },
|
360
|
+
isViewLeftBtnSecondary: false,
|
361
|
+
isViewLeftBtnTertiary: false,
|
362
|
+
typeBtnSecondary: 'primary',
|
363
|
+
typeBtnTertiary: 'primary',
|
364
|
+
titleBtnSecondary: '',
|
365
|
+
titleBtnTertiary: '',
|
366
|
+
handleBtnSecondary: () => { },
|
367
|
+
handleBtnTertiary: () => { },
|
368
|
+
txtTootipFileDownload: '',
|
369
|
+
titleHeadingTable: 'Total: 200',
|
370
|
+
}
|
371
|
+
|
372
|
+
export default withStyles(styles)(DynamicTable)
|