funda-ui 4.7.735 → 4.7.743
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/EventCalendarTimeline/index.css +3 -0
- package/EventCalendarTimeline/index.js +90 -6
- package/lib/cjs/EventCalendarTimeline/index.js +90 -6
- package/lib/css/EventCalendarTimeline/index.css +3 -0
- package/lib/esm/EventCalendarTimeline/index.scss +3 -0
- package/lib/esm/EventCalendarTimeline/index.tsx +103 -10
- package/lib/esm/ModalDialog/index.tsx +1 -0
- package/package.json +1 -1
|
@@ -4238,10 +4238,45 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
4238
4238
|
//================================================================
|
|
4239
4239
|
// Weekly calendar
|
|
4240
4240
|
//================================================================
|
|
4241
|
+
var hasInitializedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
4242
|
+
|
|
4243
|
+
// Helper function to calculate offset from a specific date
|
|
4244
|
+
var calculateWeekOffset = function calculateWeekOffset(targetDate) {
|
|
4245
|
+
var _curDate = typeof targetDate === 'undefined' ? date : targetDate;
|
|
4246
|
+
|
|
4247
|
+
// 1. Get the current selected date (from customTodayDate or user selection)
|
|
4248
|
+
var selected = new Date(_curDate.getFullYear(), _curDate.getMonth(), _curDate.getDate());
|
|
4249
|
+
|
|
4250
|
+
// 2. Get the reference Monday of the "actual current week" (offset 0)
|
|
4251
|
+
var currentWeekDates = (0,funda_utils_dist_cjs_date__WEBPACK_IMPORTED_MODULE_6__.getWeekDatesFromMon)(0);
|
|
4252
|
+
var currentMonday = new Date(currentWeekDates[0]);
|
|
4253
|
+
currentMonday.setHours(0, 0, 0, 0);
|
|
4254
|
+
|
|
4255
|
+
// 3. Calculate the difference in days
|
|
4256
|
+
var diffTime = selected.getTime() - currentMonday.getTime();
|
|
4257
|
+
var diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));
|
|
4258
|
+
|
|
4259
|
+
// 4. Update the week offset automatically
|
|
4260
|
+
var offset = Math.floor(diffDays / 7);
|
|
4261
|
+
setWeekOffset(offset);
|
|
4262
|
+
};
|
|
4263
|
+
// Initialize weekOffset based on customTodayDate instead of default 0
|
|
4241
4264
|
var _useState39 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
|
|
4242
4265
|
_useState40 = _slicedToArray(_useState39, 2),
|
|
4243
4266
|
weekOffset = _useState40[0],
|
|
4244
4267
|
setWeekOffset = _useState40[1];
|
|
4268
|
+
|
|
4269
|
+
// Sync weekOffset whenever date changes or mode switches to 'week'
|
|
4270
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
4271
|
+
if (!hasInitializedRef.current) {
|
|
4272
|
+
var customDateValid = (0,funda_utils_dist_cjs_date__WEBPACK_IMPORTED_MODULE_6__.isValidDate)(customTodayDate);
|
|
4273
|
+
if (customDateValid) {
|
|
4274
|
+
calculateWeekOffset(new Date(customTodayDate));
|
|
4275
|
+
setDate(new Date(customTodayDate));
|
|
4276
|
+
hasInitializedRef.current = true;
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
}, [date, appearanceMode, customTodayDate]);
|
|
4245
4280
|
var handleNextWeek = function handleNextWeek() {
|
|
4246
4281
|
setWeekOffset(weekOffset + 1);
|
|
4247
4282
|
return weekOffset + 1;
|
|
@@ -5071,7 +5106,8 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5071
5106
|
var _mode = e.target.dataset.mode;
|
|
5072
5107
|
setAppearanceMode(_mode);
|
|
5073
5108
|
|
|
5074
|
-
//
|
|
5109
|
+
// The useEffect above will handle the weekOffset calculation
|
|
5110
|
+
// as soon as appearanceMode becomes 'week'
|
|
5075
5111
|
onChangeAppearanceMode === null || onChangeAppearanceMode === void 0 ? void 0 : onChangeAppearanceMode(_mode);
|
|
5076
5112
|
}
|
|
5077
5113
|
function handleShowWinYear() {
|
|
@@ -5161,8 +5197,11 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5161
5197
|
colSpan: 1,
|
|
5162
5198
|
"data-date": _dateShow,
|
|
5163
5199
|
"data-day": _dateDayShow,
|
|
5164
|
-
"data-week": weekDay
|
|
5165
|
-
|
|
5200
|
+
"data-week": weekDay
|
|
5201
|
+
|
|
5202
|
+
// FIX: In 'week' mode, we don't want a hardcoded minWidth
|
|
5203
|
+
,
|
|
5204
|
+
style: appearanceMode === 'week' ? undefined : {
|
|
5166
5205
|
minWidth: CELL_MIN_W + 'px'
|
|
5167
5206
|
},
|
|
5168
5207
|
onMouseEnter: function onMouseEnter(e) {
|
|
@@ -5794,10 +5833,10 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5794
5833
|
//****************
|
|
5795
5834
|
// display wrapper
|
|
5796
5835
|
//--------------
|
|
5797
|
-
|
|
5836
|
+
setGridReady(true);
|
|
5798
5837
|
|
|
5799
5838
|
//****************
|
|
5800
|
-
// STEP
|
|
5839
|
+
// STEP 7-1:
|
|
5801
5840
|
//****************
|
|
5802
5841
|
// calculate min width (MODE: WEEK)
|
|
5803
5842
|
//--------------
|
|
@@ -5852,6 +5891,49 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5852
5891
|
}
|
|
5853
5892
|
}
|
|
5854
5893
|
|
|
5894
|
+
// Dual RAF survival test
|
|
5895
|
+
/*
|
|
5896
|
+
A single RAF only guarantees "moving to the next frame."
|
|
5897
|
+
Only dual RAFs can guarantee "DOM is mounted + layout is stable."
|
|
5898
|
+
*/
|
|
5899
|
+
var _useState51 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
5900
|
+
_useState52 = _slicedToArray(_useState51, 2),
|
|
5901
|
+
gridReady = _useState52[0],
|
|
5902
|
+
setGridReady = _useState52[1];
|
|
5903
|
+
var rafRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({});
|
|
5904
|
+
function safeShowGrid() {
|
|
5905
|
+
//
|
|
5906
|
+
setGridReady(false);
|
|
5907
|
+
rafRef.current.r1 = requestAnimationFrame(function () {
|
|
5908
|
+
rafRef.current.r2 = requestAnimationFrame(function () {
|
|
5909
|
+
var el = tableGridRef.current;
|
|
5910
|
+
if (!el) return;
|
|
5911
|
+
|
|
5912
|
+
//
|
|
5913
|
+
tableGridInit();
|
|
5914
|
+
|
|
5915
|
+
// Do only one thing: notify React that it’s ready to be displayed.
|
|
5916
|
+
setGridReady(true);
|
|
5917
|
+
});
|
|
5918
|
+
});
|
|
5919
|
+
}
|
|
5920
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5921
|
+
safeShowGrid();
|
|
5922
|
+
return function () {
|
|
5923
|
+
if (rafRef.current.r1) {
|
|
5924
|
+
cancelAnimationFrame(rafRef.current.r1);
|
|
5925
|
+
}
|
|
5926
|
+
if (rafRef.current.r2) {
|
|
5927
|
+
cancelAnimationFrame(rafRef.current.r2);
|
|
5928
|
+
}
|
|
5929
|
+
};
|
|
5930
|
+
}, [appearanceMode]);
|
|
5931
|
+
|
|
5932
|
+
// Make sure the left side is highly synchronized with the right side.
|
|
5933
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5934
|
+
tableGridInitHeadertitle();
|
|
5935
|
+
}, [orginalData, appearanceMode]);
|
|
5936
|
+
|
|
5855
5937
|
// if user change the selectedYear, then udate the years array that is displayed on year tab view
|
|
5856
5938
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5857
5939
|
var years = [];
|
|
@@ -6104,7 +6186,9 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
6104
6186
|
onClick: handleAppearanceChange
|
|
6105
6187
|
}, langAppearanceLabelWeek || 'Week')) : null)), orginalData.length === 0 ? null : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
6106
6188
|
ref: tableGridRef,
|
|
6107
|
-
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)("custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--".concat(appearanceMode
|
|
6189
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)("custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--".concat(appearanceMode), tableWrapperClassName, {
|
|
6190
|
+
'invisible': !gridReady
|
|
6191
|
+
}),
|
|
6108
6192
|
onKeyDown: function onKeyDown(e) {
|
|
6109
6193
|
onKeyPressed === null || onKeyPressed === void 0 ? void 0 : onKeyPressed(e, selectedCells);
|
|
6110
6194
|
|
|
@@ -4238,10 +4238,45 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
4238
4238
|
//================================================================
|
|
4239
4239
|
// Weekly calendar
|
|
4240
4240
|
//================================================================
|
|
4241
|
+
var hasInitializedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
4242
|
+
|
|
4243
|
+
// Helper function to calculate offset from a specific date
|
|
4244
|
+
var calculateWeekOffset = function calculateWeekOffset(targetDate) {
|
|
4245
|
+
var _curDate = typeof targetDate === 'undefined' ? date : targetDate;
|
|
4246
|
+
|
|
4247
|
+
// 1. Get the current selected date (from customTodayDate or user selection)
|
|
4248
|
+
var selected = new Date(_curDate.getFullYear(), _curDate.getMonth(), _curDate.getDate());
|
|
4249
|
+
|
|
4250
|
+
// 2. Get the reference Monday of the "actual current week" (offset 0)
|
|
4251
|
+
var currentWeekDates = (0,funda_utils_dist_cjs_date__WEBPACK_IMPORTED_MODULE_6__.getWeekDatesFromMon)(0);
|
|
4252
|
+
var currentMonday = new Date(currentWeekDates[0]);
|
|
4253
|
+
currentMonday.setHours(0, 0, 0, 0);
|
|
4254
|
+
|
|
4255
|
+
// 3. Calculate the difference in days
|
|
4256
|
+
var diffTime = selected.getTime() - currentMonday.getTime();
|
|
4257
|
+
var diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));
|
|
4258
|
+
|
|
4259
|
+
// 4. Update the week offset automatically
|
|
4260
|
+
var offset = Math.floor(diffDays / 7);
|
|
4261
|
+
setWeekOffset(offset);
|
|
4262
|
+
};
|
|
4263
|
+
// Initialize weekOffset based on customTodayDate instead of default 0
|
|
4241
4264
|
var _useState39 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0),
|
|
4242
4265
|
_useState40 = _slicedToArray(_useState39, 2),
|
|
4243
4266
|
weekOffset = _useState40[0],
|
|
4244
4267
|
setWeekOffset = _useState40[1];
|
|
4268
|
+
|
|
4269
|
+
// Sync weekOffset whenever date changes or mode switches to 'week'
|
|
4270
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
4271
|
+
if (!hasInitializedRef.current) {
|
|
4272
|
+
var customDateValid = (0,funda_utils_dist_cjs_date__WEBPACK_IMPORTED_MODULE_6__.isValidDate)(customTodayDate);
|
|
4273
|
+
if (customDateValid) {
|
|
4274
|
+
calculateWeekOffset(new Date(customTodayDate));
|
|
4275
|
+
setDate(new Date(customTodayDate));
|
|
4276
|
+
hasInitializedRef.current = true;
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
}, [date, appearanceMode, customTodayDate]);
|
|
4245
4280
|
var handleNextWeek = function handleNextWeek() {
|
|
4246
4281
|
setWeekOffset(weekOffset + 1);
|
|
4247
4282
|
return weekOffset + 1;
|
|
@@ -5071,7 +5106,8 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5071
5106
|
var _mode = e.target.dataset.mode;
|
|
5072
5107
|
setAppearanceMode(_mode);
|
|
5073
5108
|
|
|
5074
|
-
//
|
|
5109
|
+
// The useEffect above will handle the weekOffset calculation
|
|
5110
|
+
// as soon as appearanceMode becomes 'week'
|
|
5075
5111
|
onChangeAppearanceMode === null || onChangeAppearanceMode === void 0 ? void 0 : onChangeAppearanceMode(_mode);
|
|
5076
5112
|
}
|
|
5077
5113
|
function handleShowWinYear() {
|
|
@@ -5161,8 +5197,11 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5161
5197
|
colSpan: 1,
|
|
5162
5198
|
"data-date": _dateShow,
|
|
5163
5199
|
"data-day": _dateDayShow,
|
|
5164
|
-
"data-week": weekDay
|
|
5165
|
-
|
|
5200
|
+
"data-week": weekDay
|
|
5201
|
+
|
|
5202
|
+
// FIX: In 'week' mode, we don't want a hardcoded minWidth
|
|
5203
|
+
,
|
|
5204
|
+
style: appearanceMode === 'week' ? undefined : {
|
|
5166
5205
|
minWidth: CELL_MIN_W + 'px'
|
|
5167
5206
|
},
|
|
5168
5207
|
onMouseEnter: function onMouseEnter(e) {
|
|
@@ -5794,10 +5833,10 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5794
5833
|
//****************
|
|
5795
5834
|
// display wrapper
|
|
5796
5835
|
//--------------
|
|
5797
|
-
|
|
5836
|
+
setGridReady(true);
|
|
5798
5837
|
|
|
5799
5838
|
//****************
|
|
5800
|
-
// STEP
|
|
5839
|
+
// STEP 7-1:
|
|
5801
5840
|
//****************
|
|
5802
5841
|
// calculate min width (MODE: WEEK)
|
|
5803
5842
|
//--------------
|
|
@@ -5852,6 +5891,49 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5852
5891
|
}
|
|
5853
5892
|
}
|
|
5854
5893
|
|
|
5894
|
+
// Dual RAF survival test
|
|
5895
|
+
/*
|
|
5896
|
+
A single RAF only guarantees "moving to the next frame."
|
|
5897
|
+
Only dual RAFs can guarantee "DOM is mounted + layout is stable."
|
|
5898
|
+
*/
|
|
5899
|
+
var _useState51 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
5900
|
+
_useState52 = _slicedToArray(_useState51, 2),
|
|
5901
|
+
gridReady = _useState52[0],
|
|
5902
|
+
setGridReady = _useState52[1];
|
|
5903
|
+
var rafRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({});
|
|
5904
|
+
function safeShowGrid() {
|
|
5905
|
+
//
|
|
5906
|
+
setGridReady(false);
|
|
5907
|
+
rafRef.current.r1 = requestAnimationFrame(function () {
|
|
5908
|
+
rafRef.current.r2 = requestAnimationFrame(function () {
|
|
5909
|
+
var el = tableGridRef.current;
|
|
5910
|
+
if (!el) return;
|
|
5911
|
+
|
|
5912
|
+
//
|
|
5913
|
+
tableGridInit();
|
|
5914
|
+
|
|
5915
|
+
// Do only one thing: notify React that it’s ready to be displayed.
|
|
5916
|
+
setGridReady(true);
|
|
5917
|
+
});
|
|
5918
|
+
});
|
|
5919
|
+
}
|
|
5920
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5921
|
+
safeShowGrid();
|
|
5922
|
+
return function () {
|
|
5923
|
+
if (rafRef.current.r1) {
|
|
5924
|
+
cancelAnimationFrame(rafRef.current.r1);
|
|
5925
|
+
}
|
|
5926
|
+
if (rafRef.current.r2) {
|
|
5927
|
+
cancelAnimationFrame(rafRef.current.r2);
|
|
5928
|
+
}
|
|
5929
|
+
};
|
|
5930
|
+
}, [appearanceMode]);
|
|
5931
|
+
|
|
5932
|
+
// Make sure the left side is highly synchronized with the right side.
|
|
5933
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5934
|
+
tableGridInitHeadertitle();
|
|
5935
|
+
}, [orginalData, appearanceMode]);
|
|
5936
|
+
|
|
5855
5937
|
// if user change the selectedYear, then udate the years array that is displayed on year tab view
|
|
5856
5938
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5857
5939
|
var years = [];
|
|
@@ -6104,7 +6186,9 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
6104
6186
|
onClick: handleAppearanceChange
|
|
6105
6187
|
}, langAppearanceLabelWeek || 'Week')) : null)), orginalData.length === 0 ? null : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
6106
6188
|
ref: tableGridRef,
|
|
6107
|
-
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)("custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--".concat(appearanceMode
|
|
6189
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)("custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--".concat(appearanceMode), tableWrapperClassName, {
|
|
6190
|
+
'invisible': !gridReady
|
|
6191
|
+
}),
|
|
6108
6192
|
onKeyDown: function onKeyDown(e) {
|
|
6109
6193
|
onKeyPressed === null || onKeyPressed === void 0 ? void 0 : onKeyPressed(e, selectedCells);
|
|
6110
6194
|
|
|
@@ -14,7 +14,6 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
|
14
14
|
import getOs from 'funda-utils//dist/cjs/os';
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
export interface EventsValueConfig {
|
|
19
18
|
id: string | number;
|
|
20
19
|
date: string,
|
|
@@ -252,6 +251,7 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
252
251
|
const [month, setMonth] = useState<number>(date.getMonth());
|
|
253
252
|
const [year, setYear] = useState<number>(date.getFullYear());
|
|
254
253
|
const [startDay, setStartDay] = useState<number>(getStartDayOfMonth(date));
|
|
254
|
+
|
|
255
255
|
|
|
256
256
|
|
|
257
257
|
// selection tab
|
|
@@ -323,6 +323,8 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
323
323
|
return tableCellMinWidth;
|
|
324
324
|
}, [tableCellMinWidth, appearanceMode, headerShowWeek]);
|
|
325
325
|
|
|
326
|
+
|
|
327
|
+
|
|
326
328
|
const findMondayAndTruncate = (dates: string[]) => {
|
|
327
329
|
const _res = dates.map((s: string) => new Date(s));
|
|
328
330
|
// Find the first Monday in the sequence
|
|
@@ -388,7 +390,45 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
388
390
|
//================================================================
|
|
389
391
|
// Weekly calendar
|
|
390
392
|
//================================================================
|
|
393
|
+
const hasInitializedRef = useRef<boolean>(false);
|
|
394
|
+
|
|
395
|
+
// Helper function to calculate offset from a specific date
|
|
396
|
+
const calculateWeekOffset = (targetDate?: Date) => {
|
|
397
|
+
const _curDate = typeof targetDate === 'undefined' ? date : targetDate;
|
|
398
|
+
|
|
399
|
+
// 1. Get the current selected date (from customTodayDate or user selection)
|
|
400
|
+
const selected = new Date(_curDate.getFullYear(), _curDate.getMonth(), _curDate.getDate());
|
|
401
|
+
|
|
402
|
+
// 2. Get the reference Monday of the "actual current week" (offset 0)
|
|
403
|
+
const currentWeekDates = getWeekDatesFromMon(0);
|
|
404
|
+
const currentMonday = new Date(currentWeekDates[0]);
|
|
405
|
+
currentMonday.setHours(0, 0, 0, 0);
|
|
406
|
+
|
|
407
|
+
// 3. Calculate the difference in days
|
|
408
|
+
const diffTime = selected.getTime() - currentMonday.getTime();
|
|
409
|
+
const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));
|
|
410
|
+
|
|
411
|
+
// 4. Update the week offset automatically
|
|
412
|
+
const offset = Math.floor(diffDays / 7);
|
|
413
|
+
setWeekOffset(offset);
|
|
414
|
+
}
|
|
415
|
+
// Initialize weekOffset based on customTodayDate instead of default 0
|
|
391
416
|
const [weekOffset, setWeekOffset] = useState<number>(0);
|
|
417
|
+
|
|
418
|
+
// Sync weekOffset whenever date changes or mode switches to 'week'
|
|
419
|
+
useEffect(() => {
|
|
420
|
+
if (!hasInitializedRef.current) {
|
|
421
|
+
const customDateValid = isValidDate(customTodayDate as never);
|
|
422
|
+
if (customDateValid) {
|
|
423
|
+
calculateWeekOffset(new Date(customTodayDate as string));
|
|
424
|
+
setDate(new Date(customTodayDate as string));
|
|
425
|
+
hasInitializedRef.current = true;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}, [date, appearanceMode, customTodayDate]);
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
392
432
|
const handleNextWeek = () => {
|
|
393
433
|
setWeekOffset(weekOffset + 1);
|
|
394
434
|
return weekOffset + 1;
|
|
@@ -1168,7 +1208,7 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1168
1208
|
|
|
1169
1209
|
|
|
1170
1210
|
}
|
|
1171
|
-
function handleDayChange(e: React.MouseEvent, currentDay: number) {
|
|
1211
|
+
function handleDayChange(e: React.MouseEvent | null, currentDay: number) {
|
|
1172
1212
|
// Avoid triggering a full table re-render when the clicked cell is already
|
|
1173
1213
|
// the active day; this becomes expensive with large datasets.
|
|
1174
1214
|
if (
|
|
@@ -1259,14 +1299,14 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1259
1299
|
function handleAppearanceChange(e: React.MouseEvent) {
|
|
1260
1300
|
const _mode = (e.target as any).dataset.mode;
|
|
1261
1301
|
setAppearanceMode(_mode);
|
|
1262
|
-
|
|
1263
|
-
//
|
|
1302
|
+
|
|
1303
|
+
// The useEffect above will handle the weekOffset calculation
|
|
1304
|
+
// as soon as appearanceMode becomes 'week'
|
|
1264
1305
|
onChangeAppearanceMode?.(_mode);
|
|
1265
1306
|
}
|
|
1266
1307
|
|
|
1267
1308
|
|
|
1268
1309
|
|
|
1269
|
-
|
|
1270
1310
|
function handleShowWinYear() {
|
|
1271
1311
|
setWinYear((prevState: boolean) => !prevState);
|
|
1272
1312
|
}
|
|
@@ -1355,7 +1395,9 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1355
1395
|
data-date={_dateShow}
|
|
1356
1396
|
data-day={_dateDayShow}
|
|
1357
1397
|
data-week={weekDay}
|
|
1358
|
-
|
|
1398
|
+
|
|
1399
|
+
// FIX: In 'week' mode, we don't want a hardcoded minWidth
|
|
1400
|
+
style={appearanceMode === 'week' ? undefined : { minWidth: CELL_MIN_W + 'px' }}
|
|
1359
1401
|
onMouseEnter={(e: React.MouseEvent) => {
|
|
1360
1402
|
onCellMouseEnter?.(e);
|
|
1361
1403
|
}}
|
|
@@ -1922,6 +1964,7 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1922
1964
|
|
|
1923
1965
|
|
|
1924
1966
|
function tableGridInitHeadertitle() {
|
|
1967
|
+
|
|
1925
1968
|
//
|
|
1926
1969
|
if (tableGridRef.current === null) return;
|
|
1927
1970
|
|
|
@@ -2171,10 +2214,10 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
2171
2214
|
//****************
|
|
2172
2215
|
// display wrapper
|
|
2173
2216
|
//--------------
|
|
2174
|
-
|
|
2217
|
+
setGridReady(true);
|
|
2175
2218
|
|
|
2176
2219
|
//****************
|
|
2177
|
-
// STEP
|
|
2220
|
+
// STEP 7-1:
|
|
2178
2221
|
//****************
|
|
2179
2222
|
// calculate min width (MODE: WEEK)
|
|
2180
2223
|
//--------------
|
|
@@ -2240,6 +2283,53 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
2240
2283
|
|
|
2241
2284
|
}
|
|
2242
2285
|
|
|
2286
|
+
|
|
2287
|
+
// Dual RAF survival test
|
|
2288
|
+
/*
|
|
2289
|
+
A single RAF only guarantees "moving to the next frame."
|
|
2290
|
+
Only dual RAFs can guarantee "DOM is mounted + layout is stable."
|
|
2291
|
+
*/
|
|
2292
|
+
const [gridReady, setGridReady] = useState<boolean>(false);
|
|
2293
|
+
const rafRef = useRef<{ r1?: number; r2?: number }>({});
|
|
2294
|
+
|
|
2295
|
+
function safeShowGrid() {
|
|
2296
|
+
//
|
|
2297
|
+
setGridReady(false);
|
|
2298
|
+
|
|
2299
|
+
rafRef.current.r1 = requestAnimationFrame(() => {
|
|
2300
|
+
rafRef.current.r2 = requestAnimationFrame(() => {
|
|
2301
|
+
const el = tableGridRef.current;
|
|
2302
|
+
if (!el) return;
|
|
2303
|
+
|
|
2304
|
+
//
|
|
2305
|
+
tableGridInit();
|
|
2306
|
+
|
|
2307
|
+
// Do only one thing: notify React that it’s ready to be displayed.
|
|
2308
|
+
setGridReady(true);
|
|
2309
|
+
});
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
useEffect(() => {
|
|
2314
|
+
safeShowGrid();
|
|
2315
|
+
|
|
2316
|
+
return () => {
|
|
2317
|
+
if (rafRef.current.r1) {
|
|
2318
|
+
cancelAnimationFrame(rafRef.current.r1);
|
|
2319
|
+
}
|
|
2320
|
+
if (rafRef.current.r2) {
|
|
2321
|
+
cancelAnimationFrame(rafRef.current.r2);
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
}, [appearanceMode]);
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
// Make sure the left side is highly synchronized with the right side.
|
|
2328
|
+
useEffect(() => {
|
|
2329
|
+
tableGridInitHeadertitle();
|
|
2330
|
+
}, [orginalData, appearanceMode]);
|
|
2331
|
+
|
|
2332
|
+
|
|
2243
2333
|
// if user change the selectedYear, then udate the years array that is displayed on year tab view
|
|
2244
2334
|
useEffect(() => {
|
|
2245
2335
|
const years: number[] = [];
|
|
@@ -2567,8 +2657,11 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
2567
2657
|
<div
|
|
2568
2658
|
ref={tableGridRef}
|
|
2569
2659
|
className={combinedCls(
|
|
2570
|
-
`custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--${appearanceMode}
|
|
2571
|
-
tableWrapperClassName
|
|
2660
|
+
`custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--${appearanceMode}`,
|
|
2661
|
+
tableWrapperClassName,
|
|
2662
|
+
{
|
|
2663
|
+
'invisible': !gridReady
|
|
2664
|
+
}
|
|
2572
2665
|
)}
|
|
2573
2666
|
onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
2574
2667
|
onKeyPressed?.(e, selectedCells);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"UIUX Lab","email":"uiuxlab@gmail.com","name":"funda-ui","version":"4.7.
|
|
1
|
+
{"author":"UIUX Lab","email":"uiuxlab@gmail.com","name":"funda-ui","version":"4.7.743","description":"React components using pure Bootstrap 5+ which does not contain any external style and script libraries.","repository":{"type":"git","url":"git+https://github.com/xizon/funda-ui.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["bootstrap","react-bootstrap","react-components","components","components-react","react-bootstrap-components","react","funda-ui","fundaui","uikit","ui-kit","ui-components"],"bugs":{"url":"https://github.com/xizon/funda-ui/issues"},"homepage":"https://github.com/xizon/funda-ui#readme","main":"all.js","license":"MIT","dependencies":{"react":"^18.2.0","react-dom":"^18.2.0"},"types":"all.d.ts","publishConfig":{"directory":"lib"},"directories":{"lib":"lib"}}
|