josenanodev-react-components-library 0.2.8 → 0.2.10
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.
|
@@ -62,8 +62,14 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
62
62
|
const [visibleListElementsIds, setVisibleListElementsIds] = (0, react_1.useState)([]);
|
|
63
63
|
const [updateList, setUpdateList] = (0, react_1.useState)(false);
|
|
64
64
|
const [origin, setOrigin] = (0, react_1.useState)({
|
|
65
|
-
x:
|
|
66
|
-
|
|
65
|
+
x: (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollLeftPosition)(multicalendarId)
|
|
66
|
+
? Number((0, MulticalendarStatesAndSettings_1.getMulticalendarScrollLeftPosition)(multicalendarId))
|
|
67
|
+
: pastDatesVisible
|
|
68
|
+
? Math.ceil(pastDaysInitialQuantity) * cellsWidth
|
|
69
|
+
: 0,
|
|
70
|
+
y: (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId)
|
|
71
|
+
? Number((0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId))
|
|
72
|
+
: 0,
|
|
67
73
|
});
|
|
68
74
|
const [xPosition, setXPosition] = (0, react_1.useState)(origin.x);
|
|
69
75
|
const [yPosition, setYPosition] = (0, react_1.useState)(origin.y);
|
|
@@ -86,23 +92,9 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
86
92
|
}, [pastDatesVisible, pastDaysInitialQuantity, cellsWidth]);
|
|
87
93
|
(0, react_1.useEffect)(() => {
|
|
88
94
|
//Cached positions
|
|
89
|
-
let newYPosition = (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId);
|
|
90
|
-
let newXPosition = (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollLeftPosition)(multicalendarId);
|
|
91
95
|
if (gridWrapperRef.current && initialPositioningDone === false) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
(0, MulticalendarStatesAndSettings_1.eraseMulticalendarScrollTopPosition)(multicalendarId);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
gridWrapperRef.current.scrollTop = origin.y;
|
|
98
|
-
}
|
|
99
|
-
if (newXPosition !== null && newXPosition !== String(origin.x)) {
|
|
100
|
-
gridWrapperRef.current.scrollLeft = Number(newXPosition);
|
|
101
|
-
(0, MulticalendarStatesAndSettings_1.eraseMulticalendarScrollLeftPosition)(multicalendarId);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
gridWrapperRef.current.scrollLeft = origin.x;
|
|
105
|
-
}
|
|
96
|
+
gridWrapperRef.current.scrollTop = origin.y;
|
|
97
|
+
gridWrapperRef.current.scrollLeft = origin.x;
|
|
106
98
|
setInitialPositioningDone(true);
|
|
107
99
|
}
|
|
108
100
|
}, [origin.y, origin.x, initialPositioningDone]);
|
|
@@ -261,7 +253,7 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
261
253
|
}
|
|
262
254
|
}, [draggingOverDateCells, clientXPositionOnGrid, clientYPositionOnGrid]);
|
|
263
255
|
//Render
|
|
264
|
-
return (react_1.default.createElement("div", { "data-testid":
|
|
256
|
+
return (react_1.default.createElement("div", { key: multicalendarId, id: multicalendarId, "data-testid": multicalendarId, className: "multicalendar", style: {
|
|
265
257
|
gridTemplateColumns: `${verticalAxisWidth}px`,
|
|
266
258
|
gridTemplateRows: `70px ${horizontalAxisHeight - 70}px calc(100% - ${horizontalAxisHeight}px`,
|
|
267
259
|
} },
|
|
@@ -13,7 +13,7 @@ import useWindowSize from "../../hooks/useWindowsSize";
|
|
|
13
13
|
//Utils
|
|
14
14
|
import sqlToJsDate from "../../utils/sqlToJsDate";
|
|
15
15
|
//Services
|
|
16
|
-
import {
|
|
16
|
+
import { getMulticalendarScrollLeftPosition, getMulticalendarScrollTopPosition, setMulticalendarScrollLeftPosition, setMulticalendarScrollTopPosition, } from "../../Services/MulticalendarStatesAndSettings";
|
|
17
17
|
const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChildren, listElementsIdsArray, language, pastDatesVisible = true, cellsWidth = 120, cellsHeight = 80, verticalAxisWidth = 280, horizontalAxisHeight = 148, pastDaysInitialQuantity = 365, futureDaysInitialQuantity = 365, chunkRenderX = 0, chunkRenderY = 0, dynamicDaysQuantity = false, draggingOverDateCells = false, waitTimeForCalls = 500, callsOnInitialView, callsOnScrollingStops, aditionalControlsComponents, upperLeftComponent, autoSavePosition, onScrollTopChanges, onScrollLeftChanges, }) => {
|
|
18
18
|
//Constantes del componente
|
|
19
19
|
const initialDateOffset = 1 + chunkRenderX;
|
|
@@ -34,8 +34,14 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
34
34
|
const [visibleListElementsIds, setVisibleListElementsIds] = useState([]);
|
|
35
35
|
const [updateList, setUpdateList] = useState(false);
|
|
36
36
|
const [origin, setOrigin] = useState({
|
|
37
|
-
x:
|
|
38
|
-
|
|
37
|
+
x: getMulticalendarScrollLeftPosition(multicalendarId)
|
|
38
|
+
? Number(getMulticalendarScrollLeftPosition(multicalendarId))
|
|
39
|
+
: pastDatesVisible
|
|
40
|
+
? Math.ceil(pastDaysInitialQuantity) * cellsWidth
|
|
41
|
+
: 0,
|
|
42
|
+
y: getMulticalendarScrollTopPosition(multicalendarId)
|
|
43
|
+
? Number(getMulticalendarScrollTopPosition(multicalendarId))
|
|
44
|
+
: 0,
|
|
39
45
|
});
|
|
40
46
|
const [xPosition, setXPosition] = useState(origin.x);
|
|
41
47
|
const [yPosition, setYPosition] = useState(origin.y);
|
|
@@ -58,23 +64,9 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
58
64
|
}, [pastDatesVisible, pastDaysInitialQuantity, cellsWidth]);
|
|
59
65
|
useEffect(() => {
|
|
60
66
|
//Cached positions
|
|
61
|
-
let newYPosition = getMulticalendarScrollTopPosition(multicalendarId);
|
|
62
|
-
let newXPosition = getMulticalendarScrollLeftPosition(multicalendarId);
|
|
63
67
|
if (gridWrapperRef.current && initialPositioningDone === false) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
eraseMulticalendarScrollTopPosition(multicalendarId);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
gridWrapperRef.current.scrollTop = origin.y;
|
|
70
|
-
}
|
|
71
|
-
if (newXPosition !== null && newXPosition !== String(origin.x)) {
|
|
72
|
-
gridWrapperRef.current.scrollLeft = Number(newXPosition);
|
|
73
|
-
eraseMulticalendarScrollLeftPosition(multicalendarId);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
gridWrapperRef.current.scrollLeft = origin.x;
|
|
77
|
-
}
|
|
68
|
+
gridWrapperRef.current.scrollTop = origin.y;
|
|
69
|
+
gridWrapperRef.current.scrollLeft = origin.x;
|
|
78
70
|
setInitialPositioningDone(true);
|
|
79
71
|
}
|
|
80
72
|
}, [origin.y, origin.x, initialPositioningDone]);
|
|
@@ -233,7 +225,7 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
233
225
|
}
|
|
234
226
|
}, [draggingOverDateCells, clientXPositionOnGrid, clientYPositionOnGrid]);
|
|
235
227
|
//Render
|
|
236
|
-
return (React.createElement("div", { "data-testid":
|
|
228
|
+
return (React.createElement("div", { key: multicalendarId, id: multicalendarId, "data-testid": multicalendarId, className: "multicalendar", style: {
|
|
237
229
|
gridTemplateColumns: `${verticalAxisWidth}px`,
|
|
238
230
|
gridTemplateRows: `70px ${horizontalAxisHeight - 70}px calc(100% - ${horizontalAxisHeight}px`,
|
|
239
231
|
} },
|