josenanodev-react-components-library 0.2.6 → 0.2.7
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.
|
@@ -44,10 +44,6 @@ const sqlToJsDate_1 = __importDefault(require("../../utils/sqlToJsDate"));
|
|
|
44
44
|
const MulticalendarStatesAndSettings_1 = require("../../Services/MulticalendarStatesAndSettings");
|
|
45
45
|
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, }) => {
|
|
46
46
|
//Constantes del componente
|
|
47
|
-
const origin = {
|
|
48
|
-
x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
|
|
49
|
-
y: 0,
|
|
50
|
-
};
|
|
51
47
|
const initialDateOffset = 1 + chunkRenderX;
|
|
52
48
|
//Refs
|
|
53
49
|
const datesRowRef = (0, react_1.useRef)(null);
|
|
@@ -65,6 +61,10 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
65
61
|
const [visibleDates, setVisibleDates] = (0, react_1.useState)([]);
|
|
66
62
|
const [visibleListElementsIds, setVisibleListElementsIds] = (0, react_1.useState)([]);
|
|
67
63
|
const [updateList, setUpdateList] = (0, react_1.useState)(false);
|
|
64
|
+
const [origin, setOrigin] = (0, react_1.useState)({
|
|
65
|
+
x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
|
|
66
|
+
y: 0,
|
|
67
|
+
});
|
|
68
68
|
const [xPosition, setXPosition] = (0, react_1.useState)(origin.x);
|
|
69
69
|
const [yPosition, setYPosition] = (0, react_1.useState)(origin.y);
|
|
70
70
|
const [renderCoordinates, setRenderCoordinates] = (0, react_1.useState)({
|
|
@@ -77,6 +77,12 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
77
77
|
const [clientYPositionOnGrid, setClientYPositionOnGrid] = (0, react_1.useState)(undefined);
|
|
78
78
|
const [scrollingOnCourse, setScrollingOnCourse] = (0, react_1.useState)(false);
|
|
79
79
|
//UseEffects
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
setOrigin({
|
|
82
|
+
x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
|
|
83
|
+
y: 0,
|
|
84
|
+
});
|
|
85
|
+
}, [pastDatesVisible, pastDaysInitialQuantity, cellsWidth]);
|
|
80
86
|
(0, react_1.useEffect)(() => {
|
|
81
87
|
//Cached positions
|
|
82
88
|
let newYPosition = (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId);
|
|
@@ -107,11 +113,15 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
107
113
|
}
|
|
108
114
|
return () => {
|
|
109
115
|
if (autoSavePosition) {
|
|
110
|
-
(
|
|
111
|
-
|
|
116
|
+
if (yPosition !== origin.y) {
|
|
117
|
+
(0, MulticalendarStatesAndSettings_1.setMulticalendarScrollTopPosition)(multicalendarId, String(yPosition));
|
|
118
|
+
}
|
|
119
|
+
if (xPosition !== origin.x) {
|
|
120
|
+
(0, MulticalendarStatesAndSettings_1.setMulticalendarScrollLeftPosition)(multicalendarId, String(xPosition));
|
|
121
|
+
}
|
|
112
122
|
}
|
|
113
123
|
};
|
|
114
|
-
}, [yPosition, xPosition]);
|
|
124
|
+
}, [autoSavePosition, yPosition, xPosition, origin.y, origin.x]);
|
|
115
125
|
(0, react_1.useEffect)(() => {
|
|
116
126
|
if (pastDatesVisible) {
|
|
117
127
|
setPastDaysQuantity(Math.ceil(pastDaysInitialQuantity));
|
|
@@ -16,10 +16,6 @@ import sqlToJsDate from "../../utils/sqlToJsDate";
|
|
|
16
16
|
import { eraseMulticalendarScrollLeftPosition, eraseMulticalendarScrollTopPosition, 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
|
-
const origin = {
|
|
20
|
-
x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
|
|
21
|
-
y: 0,
|
|
22
|
-
};
|
|
23
19
|
const initialDateOffset = 1 + chunkRenderX;
|
|
24
20
|
//Refs
|
|
25
21
|
const datesRowRef = useRef(null);
|
|
@@ -37,6 +33,10 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
37
33
|
const [visibleDates, setVisibleDates] = useState([]);
|
|
38
34
|
const [visibleListElementsIds, setVisibleListElementsIds] = useState([]);
|
|
39
35
|
const [updateList, setUpdateList] = useState(false);
|
|
36
|
+
const [origin, setOrigin] = useState({
|
|
37
|
+
x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
|
|
38
|
+
y: 0,
|
|
39
|
+
});
|
|
40
40
|
const [xPosition, setXPosition] = useState(origin.x);
|
|
41
41
|
const [yPosition, setYPosition] = useState(origin.y);
|
|
42
42
|
const [renderCoordinates, setRenderCoordinates] = useState({
|
|
@@ -49,6 +49,12 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
49
49
|
const [clientYPositionOnGrid, setClientYPositionOnGrid] = useState(undefined);
|
|
50
50
|
const [scrollingOnCourse, setScrollingOnCourse] = useState(false);
|
|
51
51
|
//UseEffects
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
setOrigin({
|
|
54
|
+
x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
|
|
55
|
+
y: 0,
|
|
56
|
+
});
|
|
57
|
+
}, [pastDatesVisible, pastDaysInitialQuantity, cellsWidth]);
|
|
52
58
|
useEffect(() => {
|
|
53
59
|
//Cached positions
|
|
54
60
|
let newYPosition = getMulticalendarScrollTopPosition(multicalendarId);
|
|
@@ -79,11 +85,15 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
|
|
|
79
85
|
}
|
|
80
86
|
return () => {
|
|
81
87
|
if (autoSavePosition) {
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
if (yPosition !== origin.y) {
|
|
89
|
+
setMulticalendarScrollTopPosition(multicalendarId, String(yPosition));
|
|
90
|
+
}
|
|
91
|
+
if (xPosition !== origin.x) {
|
|
92
|
+
setMulticalendarScrollLeftPosition(multicalendarId, String(xPosition));
|
|
93
|
+
}
|
|
84
94
|
}
|
|
85
95
|
};
|
|
86
|
-
}, [yPosition, xPosition]);
|
|
96
|
+
}, [autoSavePosition, yPosition, xPosition, origin.y, origin.x]);
|
|
87
97
|
useEffect(() => {
|
|
88
98
|
if (pastDatesVisible) {
|
|
89
99
|
setPastDaysQuantity(Math.ceil(pastDaysInitialQuantity));
|