funda-ui 4.7.740 → 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.
|
@@ -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) {
|
|
@@ -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) {
|
|
@@ -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,
|
|
@@ -324,6 +323,8 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
324
323
|
return tableCellMinWidth;
|
|
325
324
|
}, [tableCellMinWidth, appearanceMode, headerShowWeek]);
|
|
326
325
|
|
|
326
|
+
|
|
327
|
+
|
|
327
328
|
const findMondayAndTruncate = (dates: string[]) => {
|
|
328
329
|
const _res = dates.map((s: string) => new Date(s));
|
|
329
330
|
// Find the first Monday in the sequence
|
|
@@ -389,7 +390,45 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
389
390
|
//================================================================
|
|
390
391
|
// Weekly calendar
|
|
391
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
|
|
392
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
|
+
|
|
393
432
|
const handleNextWeek = () => {
|
|
394
433
|
setWeekOffset(weekOffset + 1);
|
|
395
434
|
return weekOffset + 1;
|
|
@@ -1169,7 +1208,7 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1169
1208
|
|
|
1170
1209
|
|
|
1171
1210
|
}
|
|
1172
|
-
function handleDayChange(e: React.MouseEvent, currentDay: number) {
|
|
1211
|
+
function handleDayChange(e: React.MouseEvent | null, currentDay: number) {
|
|
1173
1212
|
// Avoid triggering a full table re-render when the clicked cell is already
|
|
1174
1213
|
// the active day; this becomes expensive with large datasets.
|
|
1175
1214
|
if (
|
|
@@ -1260,14 +1299,14 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1260
1299
|
function handleAppearanceChange(e: React.MouseEvent) {
|
|
1261
1300
|
const _mode = (e.target as any).dataset.mode;
|
|
1262
1301
|
setAppearanceMode(_mode);
|
|
1263
|
-
|
|
1264
|
-
//
|
|
1302
|
+
|
|
1303
|
+
// The useEffect above will handle the weekOffset calculation
|
|
1304
|
+
// as soon as appearanceMode becomes 'week'
|
|
1265
1305
|
onChangeAppearanceMode?.(_mode);
|
|
1266
1306
|
}
|
|
1267
1307
|
|
|
1268
1308
|
|
|
1269
1309
|
|
|
1270
|
-
|
|
1271
1310
|
function handleShowWinYear() {
|
|
1272
1311
|
setWinYear((prevState: boolean) => !prevState);
|
|
1273
1312
|
}
|
|
@@ -1356,7 +1395,9 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
1356
1395
|
data-date={_dateShow}
|
|
1357
1396
|
data-day={_dateDayShow}
|
|
1358
1397
|
data-week={weekDay}
|
|
1359
|
-
|
|
1398
|
+
|
|
1399
|
+
// FIX: In 'week' mode, we don't want a hardcoded minWidth
|
|
1400
|
+
style={appearanceMode === 'week' ? undefined : { minWidth: CELL_MIN_W + 'px' }}
|
|
1360
1401
|
onMouseEnter={(e: React.MouseEvent) => {
|
|
1361
1402
|
onCellMouseEnter?.(e);
|
|
1362
1403
|
}}
|
|
@@ -2242,6 +2283,7 @@ const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
|
|
|
2242
2283
|
|
|
2243
2284
|
}
|
|
2244
2285
|
|
|
2286
|
+
|
|
2245
2287
|
// Dual RAF survival test
|
|
2246
2288
|
/*
|
|
2247
2289
|
A single RAF only guarantees "moving to the next frame."
|
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"}}
|