josenanodev-react-components-library 0.0.11 → 0.0.15
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/README.md +4 -4
- package/dist/cjs/Services/MulticalendarStatesAndSettings.d.ts +17 -17
- package/dist/cjs/Services/MulticalendarStatesAndSettings.js +29 -29
- package/dist/cjs/Services/accessToken.d.ts +3 -3
- package/dist/cjs/Services/accessToken.js +15 -15
- package/dist/cjs/common/constants.d.ts +5 -5
- package/dist/cjs/common/constants.js +8 -8
- package/dist/cjs/common/turboSuiteUrls.d.ts +7 -7
- package/dist/cjs/common/turboSuiteUrls.js +9 -9
- package/dist/cjs/common/types.d.ts +113 -113
- package/dist/cjs/components/Modal/Modal.css +43 -0
- package/dist/cjs/components/Modal/Modal.d.ts +5 -0
- package/dist/cjs/components/Modal/Modal.js +82 -0
- package/dist/cjs/components/Modal/types.d.ts +9 -0
- package/dist/cjs/components/Multicalendar/Multicalendar.css +191 -191
- package/dist/cjs/components/Multicalendar/Multicalendar.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/Multicalendar.js +302 -302
- package/dist/cjs/components/Multicalendar/MulticalendarOwnFunctions.d.ts +86 -86
- package/dist/cjs/components/Multicalendar/MulticalendarOwnFunctions.js +192 -192
- package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.css +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.js +20 -20
- package/dist/cjs/components/Multicalendar/subcomponents/composites/CellsRow/types.d.ts +11 -11
- package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.css +7 -7
- package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.js +20 -20
- package/dist/cjs/components/Multicalendar/subcomponents/composites/DatesGrid/types.d.ts +13 -13
- package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.css +3 -3
- package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.js +15 -15
- package/dist/cjs/components/Multicalendar/subcomponents/composites/ListElementsColumn/types.d.ts +9 -9
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/Cell.css +7 -7
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/Cell.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/Cell.js +12 -12
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/Cell/types.d.ts +10 -10
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.css +60 -60
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.js +56 -56
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DatesRow/types.d.ts +10 -10
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.css +13 -13
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.js +13 -13
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/types.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.css +14 -14
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.d.ts +5 -5
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.js +14 -14
- package/dist/cjs/components/Multicalendar/subcomponents/individuals/ListElement/types.d.ts +7 -7
- package/dist/cjs/components/Multicalendar/types.d.ts +45 -45
- package/dist/cjs/components/PopUp/PopUp.css +15 -0
- package/dist/cjs/components/PopUp/PopUp.d.ts +5 -0
- package/dist/cjs/components/PopUp/PopUp.js +50 -0
- package/dist/cjs/components/PopUp/types.d.ts +8 -0
- package/dist/cjs/components/SearchBar/SearchBar.css +35 -0
- package/dist/cjs/components/SearchBar/SearchBar.d.ts +5 -0
- package/dist/cjs/components/SearchBar/SearchBar.js +67 -0
- package/dist/cjs/components/SearchBar/types.d.ts +10 -0
- package/dist/cjs/components/SideBar/SideBar.css +50 -50
- package/dist/cjs/components/SideBar/SideBar.d.ts +8 -8
- package/dist/cjs/components/SideBar/SideBar.js +70 -70
- package/dist/cjs/components/SideBar/types.d.ts +8 -8
- package/dist/cjs/hooks/useOutsideClick.d.ts +6 -6
- package/dist/cjs/hooks/useOutsideClick.js +25 -25
- package/dist/cjs/hooks/useResizeObserver.d.ts +7 -7
- package/dist/cjs/hooks/useResizeObserver.js +30 -30
- package/dist/cjs/hooks/useWindowsSize.d.ts +6 -6
- package/dist/cjs/hooks/useWindowsSize.js +20 -20
- package/dist/cjs/index.css +77 -77
- package/dist/cjs/index.d.ts +7 -4
- package/dist/cjs/index.js +18 -12
- package/dist/cjs/languages/en-EN.d.ts +3 -3
- package/dist/cjs/languages/en-EN.js +25 -25
- package/dist/cjs/languages/es-ES.d.ts +3 -3
- package/dist/cjs/languages/es-ES.js +25 -25
- package/dist/cjs/languages/it-IT.d.ts +3 -3
- package/dist/cjs/languages/it-IT.js +25 -25
- package/dist/cjs/languages/types.d.ts +21 -21
- package/dist/cjs/mocks/ReactComponentMocksForTesting/CellChildrenMock.d.ts +4 -4
- package/dist/cjs/mocks/ReactComponentMocksForTesting/CellChildrenMock.js +13 -13
- package/dist/cjs/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.d.ts +4 -4
- package/dist/cjs/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.js +10 -10
- package/dist/cjs/react-app-env.d.ts +1 -1
- package/dist/cjs/setupTests.d.ts +2 -2
- package/dist/cjs/setupTests.js +8 -8
- package/dist/cjs/stories/css-presets.css +77 -77
- package/dist/cjs/utils/datesArray.d.ts +8 -8
- package/dist/cjs/utils/datesArray.js +23 -23
- package/dist/cjs/utils/jsToSqlDate.d.ts +7 -7
- package/dist/cjs/utils/jsToSqlDate.js +22 -22
- package/dist/cjs/utils/monthYearString.d.ts +3 -3
- package/dist/cjs/utils/monthYearString.js +27 -27
- package/dist/cjs/utils/numberOfDaysInAMonth.d.ts +6 -6
- package/dist/cjs/utils/numberOfDaysInAMonth.js +12 -12
- package/dist/cjs/utils/sqlToJsDate.d.ts +7 -7
- package/dist/cjs/utils/sqlToJsDate.js +14 -14
- package/dist/esm/Services/MulticalendarStatesAndSettings.d.ts +17 -17
- package/dist/esm/Services/MulticalendarStatesAndSettings.js +23 -23
- package/dist/esm/Services/accessToken.d.ts +3 -3
- package/dist/esm/Services/accessToken.js +9 -9
- package/dist/esm/common/constants.d.ts +5 -5
- package/dist/esm/common/constants.js +5 -5
- package/dist/esm/common/turboSuiteUrls.d.ts +7 -7
- package/dist/esm/common/turboSuiteUrls.js +7 -7
- package/dist/esm/common/types.d.ts +113 -113
- package/dist/esm/components/Modal/Modal.css +43 -0
- package/dist/esm/components/Modal/Modal.d.ts +5 -0
- package/dist/esm/components/Modal/Modal.js +54 -0
- package/dist/esm/components/Modal/types.d.ts +9 -0
- package/dist/esm/components/Multicalendar/Multicalendar.css +191 -191
- package/dist/esm/components/Multicalendar/Multicalendar.d.ts +5 -5
- package/dist/esm/components/Multicalendar/Multicalendar.js +274 -274
- package/dist/esm/components/Multicalendar/MulticalendarOwnFunctions.d.ts +86 -86
- package/dist/esm/components/Multicalendar/MulticalendarOwnFunctions.js +176 -176
- package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.css +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/CellsRow.js +15 -15
- package/dist/esm/components/Multicalendar/subcomponents/composites/CellsRow/types.d.ts +11 -11
- package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.css +7 -7
- package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/DatesGrid.js +15 -15
- package/dist/esm/components/Multicalendar/subcomponents/composites/DatesGrid/types.d.ts +13 -13
- package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.css +3 -3
- package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/ListElementsColumn.js +10 -10
- package/dist/esm/components/Multicalendar/subcomponents/composites/ListElementsColumn/types.d.ts +9 -9
- package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/Cell.css +7 -7
- package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/Cell.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/Cell.js +7 -7
- package/dist/esm/components/Multicalendar/subcomponents/individuals/Cell/types.d.ts +10 -10
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.css +60 -60
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/DatesRow.js +51 -51
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DatesRow/types.d.ts +10 -10
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.css +13 -13
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/DropdownMonthNavigation.js +8 -8
- package/dist/esm/components/Multicalendar/subcomponents/individuals/DropdownMonthNavigation/types.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.css +14 -14
- package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.d.ts +5 -5
- package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/ListElement.js +9 -9
- package/dist/esm/components/Multicalendar/subcomponents/individuals/ListElement/types.d.ts +7 -7
- package/dist/esm/components/Multicalendar/types.d.ts +45 -45
- package/dist/esm/components/PopUp/PopUp.css +15 -0
- package/dist/esm/components/PopUp/PopUp.d.ts +5 -0
- package/dist/esm/components/PopUp/PopUp.js +22 -0
- package/dist/esm/components/PopUp/types.d.ts +8 -0
- package/dist/esm/components/SearchBar/SearchBar.css +35 -0
- package/dist/esm/components/SearchBar/SearchBar.d.ts +5 -0
- package/dist/esm/components/SearchBar/SearchBar.js +42 -0
- package/dist/esm/components/SearchBar/types.d.ts +10 -0
- package/dist/esm/components/SideBar/SideBar.css +50 -50
- package/dist/esm/components/SideBar/SideBar.d.ts +8 -8
- package/dist/esm/components/SideBar/SideBar.js +42 -42
- package/dist/esm/components/SideBar/types.d.ts +8 -8
- package/dist/esm/hooks/useOutsideClick.d.ts +6 -6
- package/dist/esm/hooks/useOutsideClick.js +23 -23
- package/dist/esm/hooks/useResizeObserver.d.ts +7 -7
- package/dist/esm/hooks/useResizeObserver.js +28 -28
- package/dist/esm/hooks/useWindowsSize.d.ts +6 -6
- package/dist/esm/hooks/useWindowsSize.js +18 -18
- package/dist/esm/index.css +77 -77
- package/dist/esm/index.d.ts +7 -4
- package/dist/esm/index.js +7 -4
- package/dist/esm/languages/en-EN.d.ts +3 -3
- package/dist/esm/languages/en-EN.js +23 -23
- package/dist/esm/languages/es-ES.d.ts +3 -3
- package/dist/esm/languages/es-ES.js +23 -23
- package/dist/esm/languages/it-IT.d.ts +3 -3
- package/dist/esm/languages/it-IT.js +23 -23
- package/dist/esm/languages/types.d.ts +21 -21
- package/dist/esm/mocks/ReactComponentMocksForTesting/CellChildrenMock.d.ts +4 -4
- package/dist/esm/mocks/ReactComponentMocksForTesting/CellChildrenMock.js +8 -8
- package/dist/esm/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.d.ts +4 -4
- package/dist/esm/mocks/ReactComponentMocksForTesting/ListElementChildrenMock.js +5 -5
- package/dist/esm/react-app-env.d.ts +1 -1
- package/dist/esm/setupTests.d.ts +2 -2
- package/dist/esm/setupTests.js +6 -6
- package/dist/esm/stories/css-presets.css +77 -77
- package/dist/esm/utils/datesArray.d.ts +8 -8
- package/dist/esm/utils/datesArray.js +21 -21
- package/dist/esm/utils/jsToSqlDate.d.ts +7 -7
- package/dist/esm/utils/jsToSqlDate.js +20 -20
- package/dist/esm/utils/monthYearString.d.ts +3 -3
- package/dist/esm/utils/monthYearString.js +25 -25
- package/dist/esm/utils/numberOfDaysInAMonth.d.ts +6 -6
- package/dist/esm/utils/numberOfDaysInAMonth.js +8 -8
- package/dist/esm/utils/sqlToJsDate.d.ts +7 -7
- package/dist/esm/utils/sqlToJsDate.js +12 -12
- package/package.json +103 -93
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { languageType } from "../../languages/types";
|
|
2
|
-
|
|
3
|
-
export interface MulticalendarPropsType {
|
|
4
|
-
multicalendarId: string;
|
|
5
|
-
ReactCellChildren: ReactCellChildrenType;
|
|
6
|
-
ReactListElementChildren: ReactListElementChildrenType;
|
|
7
|
-
listElementsIdsArray: string[] | number[];
|
|
8
|
-
language: languageType;
|
|
9
|
-
pastDatesVisible?: boolean
|
|
10
|
-
cellsWidth?: number;
|
|
11
|
-
cellsHeight?: number;
|
|
12
|
-
verticalAxisWidth?: number;
|
|
13
|
-
horizontalAxisHeight?: number;
|
|
14
|
-
pastDaysInitialQuantity?: number;
|
|
15
|
-
futureDaysInitialQuantity?: number;
|
|
16
|
-
chunkRenderX?: number;
|
|
17
|
-
chunkRenderY?: number;
|
|
18
|
-
draggingOverDateCells?: boolean;
|
|
19
|
-
dynamicDaysQuantity?: boolean;
|
|
20
|
-
waitTimeForCalls?: number;
|
|
21
|
-
callsOnScrollingMoves?: Function;
|
|
22
|
-
callsOnScrollingStops?: Function;
|
|
23
|
-
aditionalControlsComponents?: JSX.Element | JSX.Element[]
|
|
24
|
-
upperLeftComponent?: JSX.Element
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface RenderCoordinatesType {
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type ReactCellChildrenType = React.ElementType<CellChildrenPropsType>;
|
|
33
|
-
|
|
34
|
-
export type ReactListElementChildrenType =
|
|
35
|
-
React.ElementType<ListElementChildrenPropsType>;
|
|
36
|
-
|
|
37
|
-
export type CellChildrenPropsType = { [key: string]: any } & {
|
|
38
|
-
/**Date in SQL format, i.e. 1993-03-29 */
|
|
39
|
-
date: string;
|
|
40
|
-
listElementId: string | number;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type ListElementChildrenPropsType = { [key: string]: any } & {
|
|
44
|
-
listElementId: string | number;
|
|
45
|
-
};
|
|
1
|
+
import { languageType } from "../../languages/types";
|
|
2
|
+
|
|
3
|
+
export interface MulticalendarPropsType {
|
|
4
|
+
multicalendarId: string;
|
|
5
|
+
ReactCellChildren: ReactCellChildrenType;
|
|
6
|
+
ReactListElementChildren: ReactListElementChildrenType;
|
|
7
|
+
listElementsIdsArray: string[] | number[];
|
|
8
|
+
language: languageType;
|
|
9
|
+
pastDatesVisible?: boolean
|
|
10
|
+
cellsWidth?: number;
|
|
11
|
+
cellsHeight?: number;
|
|
12
|
+
verticalAxisWidth?: number;
|
|
13
|
+
horizontalAxisHeight?: number;
|
|
14
|
+
pastDaysInitialQuantity?: number;
|
|
15
|
+
futureDaysInitialQuantity?: number;
|
|
16
|
+
chunkRenderX?: number;
|
|
17
|
+
chunkRenderY?: number;
|
|
18
|
+
draggingOverDateCells?: boolean;
|
|
19
|
+
dynamicDaysQuantity?: boolean;
|
|
20
|
+
waitTimeForCalls?: number;
|
|
21
|
+
callsOnScrollingMoves?: Function;
|
|
22
|
+
callsOnScrollingStops?: Function;
|
|
23
|
+
aditionalControlsComponents?: JSX.Element | JSX.Element[]
|
|
24
|
+
upperLeftComponent?: JSX.Element
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RenderCoordinatesType {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type ReactCellChildrenType = React.ElementType<CellChildrenPropsType>;
|
|
33
|
+
|
|
34
|
+
export type ReactListElementChildrenType =
|
|
35
|
+
React.ElementType<ListElementChildrenPropsType>;
|
|
36
|
+
|
|
37
|
+
export type CellChildrenPropsType = { [key: string]: any } & {
|
|
38
|
+
/**Date in SQL format, i.e. 1993-03-29 */
|
|
39
|
+
date: string;
|
|
40
|
+
listElementId: string | number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ListElementChildrenPropsType = { [key: string]: any } & {
|
|
44
|
+
listElementId: string | number;
|
|
45
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.pop-up {
|
|
2
|
+
background-color: rgb(255, 255, 255);
|
|
3
|
+
border-color: rgb(235, 235, 235);
|
|
4
|
+
border-style: solid;
|
|
5
|
+
border-width: 0px 1px 1px;
|
|
6
|
+
box-shadow: rgb(0 0 0 / 15%) 0px 14px 36px 2px;
|
|
7
|
+
padding: 0px;
|
|
8
|
+
position: relative;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.pop-up.pop-up-hidden {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useState, useRef } from "react";
|
|
2
|
+
import useOutsideClick from "../../hooks/useOutsideClick";
|
|
3
|
+
import "./PopUp.css";
|
|
4
|
+
const PopUp = ({ open = false, children, closeAction, outBoundClickClosesPopUp, aditionalInlineStyle = {}, aditionalClass, }) => {
|
|
5
|
+
//Refs
|
|
6
|
+
const popUpRef = useRef(null);
|
|
7
|
+
//Hooks
|
|
8
|
+
useOutsideClick(popUpRef, () => {
|
|
9
|
+
if (outBoundClickClosesPopUp) {
|
|
10
|
+
setOpenState(false);
|
|
11
|
+
if (closeAction)
|
|
12
|
+
closeAction();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//Estados
|
|
16
|
+
const [openState, setOpenState] = useState(open);
|
|
17
|
+
//useState
|
|
18
|
+
return (React.createElement("div", { ref: popUpRef, className: "pop-up" +
|
|
19
|
+
((closeAction && open) || (!closeAction && openState) ? "" : " pop-up-hidden") +
|
|
20
|
+
(aditionalClass ? " " + aditionalClass : ""), style: aditionalInlineStyle }, children));
|
|
21
|
+
};
|
|
22
|
+
export default PopUp;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.search-bar .div-search-bar {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
border: 1px solid rgb(185, 185, 185);
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
margin: 2px 10px;
|
|
8
|
+
padding: 5px 0px;
|
|
9
|
+
border-radius: 6px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.search-bar .div-search-bar input {
|
|
13
|
+
width: 100%;
|
|
14
|
+
border: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.search-bar .div-search-bar input:focus {
|
|
18
|
+
border: none;
|
|
19
|
+
outline: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.search-bar .div-search-bar svg {
|
|
23
|
+
width: 36px;
|
|
24
|
+
padding: 0px 10px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.search-bar .div-search-bar .icono-search-bar-opciones {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
transition: all 0.5s;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.search-bar .div-search-bar .icono-search-bar-opciones.icono-search-bar-opciones-desactivado {
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
color: rgb(184, 184, 184);
|
|
35
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./SearchBar.css";
|
|
3
|
+
import { SearchBarPropsType } from "./types";
|
|
4
|
+
declare const SearchBar: ({ actionOnEnter, actionOnAlteringText, actionOnEmptyText, optionsButtonVisible, actionOnClickOptionsButton, placeholder, initialValue, disabled, }: SearchBarPropsType) => JSX.Element;
|
|
5
|
+
export default SearchBar;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import "./SearchBar.css";
|
|
3
|
+
//Icons
|
|
4
|
+
import { BsSearch, BsSliders } from "react-icons/bs";
|
|
5
|
+
const SearchBar = ({ actionOnEnter = () => { }, actionOnAlteringText = () => { }, actionOnEmptyText = () => { }, optionsButtonVisible, actionOnClickOptionsButton = () => { }, placeholder = "", initialValue = "", disabled = false, }) => {
|
|
6
|
+
//Estados
|
|
7
|
+
const [searchValue, setSearchValue] = useState(initialValue);
|
|
8
|
+
const [cachedSearchValue, setCachedSearchValue] = useState(initialValue);
|
|
9
|
+
//useEffect
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (searchValue !== cachedSearchValue) {
|
|
12
|
+
if (searchValue !== "") {
|
|
13
|
+
actionOnAlteringText(searchValue);
|
|
14
|
+
}
|
|
15
|
+
else if (searchValue === "") {
|
|
16
|
+
actionOnEmptyText();
|
|
17
|
+
}
|
|
18
|
+
setCachedSearchValue(searchValue);
|
|
19
|
+
}
|
|
20
|
+
}, [searchValue, cachedSearchValue, actionOnAlteringText, actionOnEmptyText]);
|
|
21
|
+
return (React.createElement("form", { className: "search-bar", onSubmit: (e) => {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
let searchElement = e.target.elements.namedItem("search-bar-name");
|
|
24
|
+
if (searchElement !== null)
|
|
25
|
+
actionOnEnter(searchElement.value);
|
|
26
|
+
} },
|
|
27
|
+
React.createElement("div", { className: "div-search-bar" },
|
|
28
|
+
React.createElement("div", null,
|
|
29
|
+
React.createElement(BsSearch, null)),
|
|
30
|
+
React.createElement("input", { name: "search-bar-name", type: "text", placeholder: placeholder, disabled: disabled, onChange: (e) => {
|
|
31
|
+
setSearchValue(e.target.value);
|
|
32
|
+
if (e.target.value)
|
|
33
|
+
actionOnAlteringText();
|
|
34
|
+
if (!e.target.value)
|
|
35
|
+
actionOnEmptyText();
|
|
36
|
+
}, value: searchValue }),
|
|
37
|
+
optionsButtonVisible && (React.createElement("div", { className: disabled
|
|
38
|
+
? "icono-search-bar-opciones icono-search-bar-opciones-disabled"
|
|
39
|
+
: "icono-search-bar-opciones", onClick: () => actionOnClickOptionsButton() },
|
|
40
|
+
React.createElement(BsSliders, null))))));
|
|
41
|
+
};
|
|
42
|
+
export default SearchBar;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SearchBarPropsType {
|
|
2
|
+
actionOnEnter?: function;
|
|
3
|
+
actionOnAlteringText?: function;
|
|
4
|
+
actionOnEmptyText?: function;
|
|
5
|
+
optionsButtonVisible: boolean;
|
|
6
|
+
actionOnClickOptionsButton?: function;
|
|
7
|
+
placeholder: string;
|
|
8
|
+
initialValue?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
.side-bar {
|
|
2
|
-
position: absolute;
|
|
3
|
-
top: 0;
|
|
4
|
-
height: 100%;
|
|
5
|
-
z-index: 2;
|
|
6
|
-
background-color: rgb(253, 253, 253);
|
|
7
|
-
box-shadow: 5px 0px 15px 0px rgb(206 206 206);
|
|
8
|
-
transition: all 0.5s ease-in-out;
|
|
9
|
-
animation: fade-in-side-bar 1s ease-in;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.side-bar .sidebar-close-button {
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 0;
|
|
15
|
-
height: 30px;
|
|
16
|
-
width: 30px;
|
|
17
|
-
background-color: transparent;
|
|
18
|
-
border: none;
|
|
19
|
-
outline: none;
|
|
20
|
-
transition: all 0.3s;
|
|
21
|
-
color: dimgray;
|
|
22
|
-
font-size: 30px;
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.side-bar .sidebar-close-button:hover {
|
|
30
|
-
color: var(--primary-color);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.side-bar .sidebar-close-button svg.open{
|
|
34
|
-
transform: rotate(0deg);
|
|
35
|
-
transition: all 0.5s;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.side-bar .sidebar-close-button svg.close{
|
|
39
|
-
transform: rotate(180deg);
|
|
40
|
-
transition: all 0.5s;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@keyframes fade-in-side-bar {
|
|
44
|
-
from {
|
|
45
|
-
opacity: 0;
|
|
46
|
-
}
|
|
47
|
-
to {
|
|
48
|
-
opacity: 1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
.side-bar {
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 0;
|
|
4
|
+
height: 100%;
|
|
5
|
+
z-index: 2;
|
|
6
|
+
background-color: rgb(253, 253, 253);
|
|
7
|
+
box-shadow: 5px 0px 15px 0px rgb(206 206 206);
|
|
8
|
+
transition: all 0.5s ease-in-out;
|
|
9
|
+
animation: fade-in-side-bar 1s ease-in;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.side-bar .sidebar-close-button {
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: 0;
|
|
15
|
+
height: 30px;
|
|
16
|
+
width: 30px;
|
|
17
|
+
background-color: transparent;
|
|
18
|
+
border: none;
|
|
19
|
+
outline: none;
|
|
20
|
+
transition: all 0.3s;
|
|
21
|
+
color: dimgray;
|
|
22
|
+
font-size: 30px;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.side-bar .sidebar-close-button:hover {
|
|
30
|
+
color: var(--primary-color);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.side-bar .sidebar-close-button svg.open{
|
|
34
|
+
transform: rotate(0deg);
|
|
35
|
+
transition: all 0.5s;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.side-bar .sidebar-close-button svg.close{
|
|
39
|
+
transform: rotate(180deg);
|
|
40
|
+
transition: all 0.5s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@keyframes fade-in-side-bar {
|
|
44
|
+
from {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
to {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import "./SideBar.css";
|
|
3
|
-
import { SideBarPropsType } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* NOTE: Parent Node must have position: relative, to work correctly with the side bar
|
|
6
|
-
*/
|
|
7
|
-
declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle, }: SideBarPropsType) => JSX.Element;
|
|
8
|
-
export default SideBar;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./SideBar.css";
|
|
3
|
+
import { SideBarPropsType } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* NOTE: Parent Node must have position: relative, to work correctly with the side bar
|
|
6
|
+
*/
|
|
7
|
+
declare const SideBar: ({ side, open, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle, }: SideBarPropsType) => JSX.Element;
|
|
8
|
+
export default SideBar;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
import "./SideBar.css";
|
|
3
|
-
//Hooks
|
|
4
|
-
import useOutsideClick from "../../hooks/useOutsideClick";
|
|
5
|
-
import useResizeObserver from "../../hooks/useResizeObserver";
|
|
6
|
-
//Icons
|
|
7
|
-
import { BsChevronLeft, BsChevronRight } from "react-icons/bs";
|
|
8
|
-
/**
|
|
9
|
-
* NOTE: Parent Node must have position: relative, to work correctly with the side bar
|
|
10
|
-
*/
|
|
11
|
-
const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle = {}, }) => {
|
|
12
|
-
//Refs
|
|
13
|
-
const sideBarRef = useRef(null);
|
|
14
|
-
//Hooks
|
|
15
|
-
const [elementWidth] = useResizeObserver(sideBarRef);
|
|
16
|
-
useOutsideClick(sideBarRef, () => {
|
|
17
|
-
if (outBoundClickClosesSideBar)
|
|
18
|
-
if (closeAction) {
|
|
19
|
-
closeAction();
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
setOpenState(false);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
//useState
|
|
26
|
-
const [openState, setOpenState] = useState(open);
|
|
27
|
-
return (React.createElement("div", { ref: sideBarRef, className: "side-bar", style: Object.assign({ [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
|
|
28
|
-
? `calc(100% - ${elementWidth}px)`
|
|
29
|
-
: closeAction
|
|
30
|
-
? "100%"
|
|
31
|
-
: `calc(100% - 30px)` }, aditionalInlineStyle) },
|
|
32
|
-
React.createElement("button", { style: side === "left" ? { right: 0 } : { left: 0 }, className: "sidebar-close-button", onClick: () => {
|
|
33
|
-
if (closeAction) {
|
|
34
|
-
closeAction();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
setOpenState(!openState);
|
|
38
|
-
}
|
|
39
|
-
} }, side === "left" ? (React.createElement(BsChevronLeft, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" })) : (React.createElement(BsChevronRight, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" }))),
|
|
40
|
-
children));
|
|
41
|
-
};
|
|
42
|
-
export default SideBar;
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
import "./SideBar.css";
|
|
3
|
+
//Hooks
|
|
4
|
+
import useOutsideClick from "../../hooks/useOutsideClick";
|
|
5
|
+
import useResizeObserver from "../../hooks/useResizeObserver";
|
|
6
|
+
//Icons
|
|
7
|
+
import { BsChevronLeft, BsChevronRight } from "react-icons/bs";
|
|
8
|
+
/**
|
|
9
|
+
* NOTE: Parent Node must have position: relative, to work correctly with the side bar
|
|
10
|
+
*/
|
|
11
|
+
const SideBar = ({ side, open = false, children, closeAction, outBoundClickClosesSideBar, aditionalInlineStyle = {}, }) => {
|
|
12
|
+
//Refs
|
|
13
|
+
const sideBarRef = useRef(null);
|
|
14
|
+
//Hooks
|
|
15
|
+
const [elementWidth] = useResizeObserver(sideBarRef);
|
|
16
|
+
useOutsideClick(sideBarRef, () => {
|
|
17
|
+
if (outBoundClickClosesSideBar)
|
|
18
|
+
if (closeAction) {
|
|
19
|
+
closeAction();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
setOpenState(false);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//useState
|
|
26
|
+
const [openState, setOpenState] = useState(open);
|
|
27
|
+
return (React.createElement("div", { ref: sideBarRef, className: "side-bar", style: Object.assign({ [side === "left" ? "right" : "left"]: (closeAction && open) || (!closeAction && openState)
|
|
28
|
+
? `calc(100% - ${elementWidth}px)`
|
|
29
|
+
: closeAction
|
|
30
|
+
? "100%"
|
|
31
|
+
: `calc(100% - 30px)` }, aditionalInlineStyle) },
|
|
32
|
+
React.createElement("button", { style: side === "left" ? { right: 0 } : { left: 0 }, className: "sidebar-close-button", onClick: () => {
|
|
33
|
+
if (closeAction) {
|
|
34
|
+
closeAction();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
setOpenState(!openState);
|
|
38
|
+
}
|
|
39
|
+
} }, side === "left" ? (React.createElement(BsChevronLeft, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" })) : (React.createElement(BsChevronRight, { className: (closeAction && open) || (!closeAction && openState) ? "open" : "close" }))),
|
|
40
|
+
children));
|
|
41
|
+
};
|
|
42
|
+
export default SideBar;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface SideBarPropsType {
|
|
2
|
-
side: "left" | "right";
|
|
3
|
-
children: JSX.Element | JSX.Element[];
|
|
4
|
-
open: boolean;
|
|
5
|
-
closeAction?: Function;
|
|
6
|
-
outBoundClickClosesSideBar?: boolean;
|
|
7
|
-
aditionalInlineStyle?: React.CSSProperties;
|
|
8
|
-
}
|
|
1
|
+
export interface SideBarPropsType {
|
|
2
|
+
side: "left" | "right";
|
|
3
|
+
children: JSX.Element | JSX.Element[];
|
|
4
|
+
open: boolean;
|
|
5
|
+
closeAction?: Function;
|
|
6
|
+
outBoundClickClosesSideBar?: boolean;
|
|
7
|
+
aditionalInlineStyle?: React.CSSProperties;
|
|
8
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* Hook that alerts clicks outside of the passed ref
|
|
4
|
-
*/
|
|
5
|
-
declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function): void;
|
|
6
|
-
export default useOutsideClick;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* Hook that alerts clicks outside of the passed ref
|
|
4
|
+
*/
|
|
5
|
+
declare function useOutsideClick(elementRef: React.MutableRefObject<HTMLElement | null>, onOutsideClickAction: Function): void;
|
|
6
|
+
export default useOutsideClick;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Hook that alerts clicks outside of the passed ref
|
|
4
|
-
*/
|
|
5
|
-
function useOutsideClick(elementRef, onOutsideClickAction) {
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
/**
|
|
8
|
-
* Alert if clicked on outside of element
|
|
9
|
-
*/
|
|
10
|
-
function handleClickOutside(event) {
|
|
11
|
-
if (elementRef.current && !elementRef.current.contains(event.target)) {
|
|
12
|
-
onOutsideClickAction();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
// Bind the event listener
|
|
16
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
17
|
-
return () => {
|
|
18
|
-
// Unbind the event listener on clean up
|
|
19
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
20
|
-
};
|
|
21
|
-
}, [elementRef, onOutsideClickAction]);
|
|
22
|
-
}
|
|
23
|
-
export default useOutsideClick;
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that alerts clicks outside of the passed ref
|
|
4
|
+
*/
|
|
5
|
+
function useOutsideClick(elementRef, onOutsideClickAction) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
/**
|
|
8
|
+
* Alert if clicked on outside of element
|
|
9
|
+
*/
|
|
10
|
+
function handleClickOutside(event) {
|
|
11
|
+
if (elementRef.current && !elementRef.current.contains(event.target)) {
|
|
12
|
+
onOutsideClickAction();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Bind the event listener
|
|
16
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
17
|
+
return () => {
|
|
18
|
+
// Unbind the event listener on clean up
|
|
19
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
20
|
+
};
|
|
21
|
+
}, [elementRef, onOutsideClickAction]);
|
|
22
|
+
}
|
|
23
|
+
export default useOutsideClick;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* @returns Array [elementWidth, elementHeight], that represent the current
|
|
4
|
-
* values of width and height of elementRef
|
|
5
|
-
*/
|
|
6
|
-
declare function useResizeObserver(elementRef: React.MutableRefObject<HTMLElement | null>): number[];
|
|
7
|
-
export default useResizeObserver;
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @returns Array [elementWidth, elementHeight], that represent the current
|
|
4
|
+
* values of width and height of elementRef
|
|
5
|
+
*/
|
|
6
|
+
declare function useResizeObserver(elementRef: React.MutableRefObject<HTMLElement | null>): number[];
|
|
7
|
+
export default useResizeObserver;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { useState, useRef, useEffect } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* @returns Array [elementWidth, elementHeight], that represent the current
|
|
4
|
-
* values of width and height of elementRef
|
|
5
|
-
*/
|
|
6
|
-
function useResizeObserver(elementRef) {
|
|
7
|
-
const [elementWidth, setElementWidth] = useState(0);
|
|
8
|
-
const [elementHeight, setElementHeight] = useState(0);
|
|
9
|
-
const observer = useRef(new ResizeObserver((entries) => {
|
|
10
|
-
const { width, height } = entries[0].contentRect;
|
|
11
|
-
setElementWidth(width);
|
|
12
|
-
setElementHeight(height);
|
|
13
|
-
}));
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (elementRef.current !== null) {
|
|
16
|
-
observer.current.observe(elementRef.current);
|
|
17
|
-
}
|
|
18
|
-
const observerCurrentForCleanUp = observer.current;
|
|
19
|
-
const elementRefCurrentForCleanUp = elementRef.current;
|
|
20
|
-
return () => {
|
|
21
|
-
if (elementRefCurrentForCleanUp !== null) {
|
|
22
|
-
observerCurrentForCleanUp.unobserve(elementRefCurrentForCleanUp);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}, [elementRef, observer]);
|
|
26
|
-
return [elementWidth, elementHeight];
|
|
27
|
-
}
|
|
28
|
-
export default useResizeObserver;
|
|
1
|
+
import { useState, useRef, useEffect } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @returns Array [elementWidth, elementHeight], that represent the current
|
|
4
|
+
* values of width and height of elementRef
|
|
5
|
+
*/
|
|
6
|
+
function useResizeObserver(elementRef) {
|
|
7
|
+
const [elementWidth, setElementWidth] = useState(0);
|
|
8
|
+
const [elementHeight, setElementHeight] = useState(0);
|
|
9
|
+
const observer = useRef(new ResizeObserver((entries) => {
|
|
10
|
+
const { width, height } = entries[0].contentRect;
|
|
11
|
+
setElementWidth(width);
|
|
12
|
+
setElementHeight(height);
|
|
13
|
+
}));
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (elementRef.current !== null) {
|
|
16
|
+
observer.current.observe(elementRef.current);
|
|
17
|
+
}
|
|
18
|
+
const observerCurrentForCleanUp = observer.current;
|
|
19
|
+
const elementRefCurrentForCleanUp = elementRef.current;
|
|
20
|
+
return () => {
|
|
21
|
+
if (elementRefCurrentForCleanUp !== null) {
|
|
22
|
+
observerCurrentForCleanUp.unobserve(elementRefCurrentForCleanUp);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, [elementRef, observer]);
|
|
26
|
+
return [elementWidth, elementHeight];
|
|
27
|
+
}
|
|
28
|
+
export default useResizeObserver;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @returns Array [ancho, alto], de dichos valores refieren
|
|
3
|
-
* los valores de window.innerWidth y window.innerHeight
|
|
4
|
-
*/
|
|
5
|
-
declare function useWindowSize(): [number, number];
|
|
6
|
-
export default useWindowSize;
|
|
1
|
+
/**
|
|
2
|
+
* @returns Array [ancho, alto], de dichos valores refieren
|
|
3
|
+
* los valores de window.innerWidth y window.innerHeight
|
|
4
|
+
*/
|
|
5
|
+
declare function useWindowSize(): [number, number];
|
|
6
|
+
export default useWindowSize;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* @returns Array [ancho, alto], de dichos valores refieren
|
|
4
|
-
* los valores de window.innerWidth y window.innerHeight
|
|
5
|
-
*/
|
|
6
|
-
function useWindowSize() {
|
|
7
|
-
const [size, setSize] = useState([0, 0]);
|
|
8
|
-
useLayoutEffect(() => {
|
|
9
|
-
function updateSize() {
|
|
10
|
-
setSize([window.innerWidth, window.innerHeight]);
|
|
11
|
-
}
|
|
12
|
-
window.addEventListener("resize", updateSize);
|
|
13
|
-
updateSize();
|
|
14
|
-
return () => window.removeEventListener("resize", updateSize);
|
|
15
|
-
}, []);
|
|
16
|
-
return size;
|
|
17
|
-
}
|
|
18
|
-
export default useWindowSize;
|
|
1
|
+
import { useLayoutEffect, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* @returns Array [ancho, alto], de dichos valores refieren
|
|
4
|
+
* los valores de window.innerWidth y window.innerHeight
|
|
5
|
+
*/
|
|
6
|
+
function useWindowSize() {
|
|
7
|
+
const [size, setSize] = useState([0, 0]);
|
|
8
|
+
useLayoutEffect(() => {
|
|
9
|
+
function updateSize() {
|
|
10
|
+
setSize([window.innerWidth, window.innerHeight]);
|
|
11
|
+
}
|
|
12
|
+
window.addEventListener("resize", updateSize);
|
|
13
|
+
updateSize();
|
|
14
|
+
return () => window.removeEventListener("resize", updateSize);
|
|
15
|
+
}, []);
|
|
16
|
+
return size;
|
|
17
|
+
}
|
|
18
|
+
export default useWindowSize;
|