funda-ui 4.7.743 → 4.7.750
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/Date/index.js +139 -12
- package/EventCalendar/index.js +139 -12
- package/EventCalendarTimeline/index.js +161 -19
- package/Utils/date.d.ts +35 -7
- package/Utils/date.js +133 -12
- package/lib/cjs/Date/index.js +139 -12
- package/lib/cjs/EventCalendar/index.js +139 -12
- package/lib/cjs/EventCalendarTimeline/index.js +161 -19
- package/lib/cjs/Utils/date.d.ts +35 -7
- package/lib/cjs/Utils/date.js +133 -12
- package/lib/esm/EventCalendarTimeline/index.tsx +22 -8
- package/lib/esm/Utils/libs/date.ts +152 -21
- package/package.json +1 -1
package/Date/index.js
CHANGED
|
@@ -2588,6 +2588,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2588
2588
|
return (/* binding */_getPrevYearDate
|
|
2589
2589
|
);
|
|
2590
2590
|
},
|
|
2591
|
+
/* harmony export */"getSpecialDateEnd": function getSpecialDateEnd() {
|
|
2592
|
+
return (/* binding */_getSpecialDateEnd
|
|
2593
|
+
);
|
|
2594
|
+
},
|
|
2591
2595
|
/* harmony export */"getSpecifiedDate": function getSpecifiedDate() {
|
|
2592
2596
|
return (/* binding */_getSpecifiedDate
|
|
2593
2597
|
);
|
|
@@ -2600,6 +2604,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2600
2604
|
return (/* binding */_getTomorrowDate
|
|
2601
2605
|
);
|
|
2602
2606
|
},
|
|
2607
|
+
/* harmony export */"getWeekDatesByDate": function getWeekDatesByDate() {
|
|
2608
|
+
return (/* binding */_getWeekDatesByDate
|
|
2609
|
+
);
|
|
2610
|
+
},
|
|
2603
2611
|
/* harmony export */"getWeekDatesFromMon": function getWeekDatesFromMon() {
|
|
2604
2612
|
return (/* binding */_getWeekDatesFromMon
|
|
2605
2613
|
);
|
|
@@ -2662,6 +2670,47 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2662
2670
|
}
|
|
2663
2671
|
/* harmony export */
|
|
2664
2672
|
});
|
|
2673
|
+
/**
|
|
2674
|
+
* Get the Sunday of the week of the specific date, and return to the
|
|
2675
|
+
* end of January next year if it is New Year's Eve
|
|
2676
|
+
* @param {Date | String} v
|
|
2677
|
+
* @returns {String} yyyy-MM-dd
|
|
2678
|
+
*
|
|
2679
|
+
* @example
|
|
2680
|
+
* getSpecialDateEnd('2025-12-29'); // 2026-01-31
|
|
2681
|
+
* getSpecialDateEnd('2025-12-17'); // 2025-12-31
|
|
2682
|
+
*/
|
|
2683
|
+
/**
|
|
2684
|
+
* Calculates a special end date based on the week and month logic.
|
|
2685
|
+
* @param v - The input date (Date object, string, or timestamp)
|
|
2686
|
+
* @returns A formatted date string (YYYY-MM-DD)
|
|
2687
|
+
*/
|
|
2688
|
+
function _getSpecialDateEnd(v) {
|
|
2689
|
+
// Assuming dateFormat returns a Date object based on your logic
|
|
2690
|
+
var date = new Date(v);
|
|
2691
|
+
|
|
2692
|
+
// getWeekDatesByDate should return Date[]
|
|
2693
|
+
var weekDates = _getWeekDatesByDate(v);
|
|
2694
|
+
var sunday = weekDates[6]; // Sunday of that week
|
|
2695
|
+
|
|
2696
|
+
// If Sunday of this week rolls into the next year
|
|
2697
|
+
if (sunday.getFullYear() > date.getFullYear()) {
|
|
2698
|
+
var year = sunday.getFullYear();
|
|
2699
|
+
|
|
2700
|
+
// Get the last day of January of that new year
|
|
2701
|
+
// Note: month 1 in 'new Date' is February, day 0 gives the last day of Jan
|
|
2702
|
+
var lastDay = new Date(year, 1, 0).getDate();
|
|
2703
|
+
|
|
2704
|
+
// Using template literals for the return string
|
|
2705
|
+
return "".concat(year, "-01-").concat(lastDay.toString().padStart(2, '0'));
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
// Default: Return the last day of the current month
|
|
2709
|
+
// We create a date for the "0th" day of the next month to get the end of current month
|
|
2710
|
+
var endOfCurrentMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
2711
|
+
return _getCalendarDate(endOfCurrentMonth);
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2665
2714
|
/**
|
|
2666
2715
|
* The check string contains only hours, minutes, and seconds
|
|
2667
2716
|
* @returns {Boolean}
|
|
@@ -3117,19 +3166,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3117
3166
|
}
|
|
3118
3167
|
|
|
3119
3168
|
/**
|
|
3120
|
-
* Get
|
|
3121
|
-
* @param {Number} weekOffset
|
|
3122
|
-
*
|
|
3169
|
+
* Get all 7 dates for a specific week starting from Sunday.
|
|
3170
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
3171
|
+
* 0: Current week
|
|
3172
|
+
* -1: Previous week
|
|
3173
|
+
* 1: Next week
|
|
3174
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Sunday to Saturday.
|
|
3123
3175
|
*/
|
|
3176
|
+
/*
|
|
3177
|
+
// Demo 1: Get dates for the current week (Sunday Start)
|
|
3178
|
+
const currentWeekSun = getWeekDatesFromSun(0);
|
|
3179
|
+
console.log('Sunday (Start):', currentWeekSun[0].toLocaleDateString());
|
|
3180
|
+
console.log('Saturday (End):', currentWeekSun[6].toLocaleDateString());
|
|
3181
|
+
|
|
3182
|
+
// Demo 2: Get the date range for the previous week
|
|
3183
|
+
const lastWeek = getWeekDatesFromSun(-1);
|
|
3184
|
+
const rangeStart = lastWeek[0].toISOString().split('T')[0];
|
|
3185
|
+
const rangeEnd = lastWeek[6].toISOString().split('T')[0];
|
|
3186
|
+
console.log(`Previous Week Range: ${rangeStart} to ${rangeEnd}`);
|
|
3187
|
+
|
|
3188
|
+
// Demo 3: Checking for Month/Year transitions
|
|
3189
|
+
const transitionWeek = getWeekDatesFromSun(0).map(d => d.toDateString());
|
|
3190
|
+
console.log('Transition Week Dates:', transitionWeek);
|
|
3191
|
+
|
|
3192
|
+
*/
|
|
3124
3193
|
function _getWeekDatesFromSun(weekOffset) {
|
|
3125
3194
|
var dates = [];
|
|
3195
|
+
// Start with a clean date (midnight) to avoid timezone/DST shifts during calculation
|
|
3126
3196
|
var currentDate = new Date();
|
|
3197
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
3198
|
+
var dayOfWeek = currentDate.getDay();
|
|
3127
3199
|
|
|
3128
|
-
//
|
|
3129
|
-
|
|
3200
|
+
// Move to the Sunday of the current week, then apply the week offset
|
|
3201
|
+
// Formula: Current Date - Current Day Index + (Offset * 7)
|
|
3130
3202
|
currentDate.setDate(currentDate.getDate() - dayOfWeek + weekOffset * 7);
|
|
3131
|
-
|
|
3132
|
-
// Get the date of the week
|
|
3133
3203
|
for (var i = 0; i < 7; i++) {
|
|
3134
3204
|
var date = new Date(currentDate);
|
|
3135
3205
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -3139,20 +3209,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3139
3209
|
}
|
|
3140
3210
|
|
|
3141
3211
|
/**
|
|
3142
|
-
* Get
|
|
3143
|
-
* @param {Number} weekOffset
|
|
3144
|
-
*
|
|
3212
|
+
* Get all 7 dates for a specific week starting from Monday.
|
|
3213
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
3214
|
+
* 0: Current week
|
|
3215
|
+
* -1: Previous week
|
|
3216
|
+
* 1: Next week
|
|
3217
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Monday to Sunday.
|
|
3145
3218
|
*/
|
|
3219
|
+
/*
|
|
3220
|
+
// Demo 1: Get dates for the current week
|
|
3221
|
+
const currentWeek = getWeekDatesFromMon(0);
|
|
3222
|
+
console.log('Monday of this week:', currentWeek[0].toLocaleDateString());
|
|
3223
|
+
console.log('Sunday of this week:', currentWeek[6].toLocaleDateString());
|
|
3224
|
+
|
|
3225
|
+
// Demo 2: Get dates for the next week
|
|
3226
|
+
const nextWeek = getWeekDatesFromMon(1);
|
|
3227
|
+
console.log('Monday of next week:', nextWeek[0].toLocaleDateString());
|
|
3228
|
+
|
|
3229
|
+
// Demo 3: Format the output as YYYY-MM-DD
|
|
3230
|
+
const formattedWeek = getWeekDatesFromMon(0).map(date => {
|
|
3231
|
+
const y = date.getFullYear();
|
|
3232
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
3233
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
3234
|
+
return `${y}-${m}-${d}`;
|
|
3235
|
+
});
|
|
3236
|
+
console.log('Formatted Week Array:', formattedWeek);
|
|
3237
|
+
// Result: ["2025-12-29", "2025-12-30", ..., "2026-01-04"]
|
|
3238
|
+
*/
|
|
3146
3239
|
function _getWeekDatesFromMon(weekOffset) {
|
|
3147
3240
|
var dates = [];
|
|
3148
3241
|
var currentDate = new Date();
|
|
3149
3242
|
|
|
3150
|
-
//
|
|
3243
|
+
// Calculate the difference to get to Monday of the current week
|
|
3244
|
+
// If today is Sunday (0), we go back 6 days. Otherwise, go to (1 - currentDay).
|
|
3151
3245
|
var dayOfWeek = currentDate.getDay();
|
|
3152
3246
|
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
3247
|
+
|
|
3248
|
+
// Apply the Monday offset and the week offset (7 days per week)
|
|
3153
3249
|
currentDate.setDate(currentDate.getDate() + diffToMonday + weekOffset * 7);
|
|
3154
3250
|
|
|
3155
|
-
//
|
|
3251
|
+
// Generate the 7 days of the week
|
|
3156
3252
|
for (var i = 0; i < 7; i++) {
|
|
3157
3253
|
var date = new Date(currentDate);
|
|
3158
3254
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -3161,6 +3257,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3161
3257
|
return dates;
|
|
3162
3258
|
}
|
|
3163
3259
|
|
|
3260
|
+
/**
|
|
3261
|
+
* Get the date list of the week for the specified date (starting from Monday)
|
|
3262
|
+
* @param {Date | String} v - The specified date
|
|
3263
|
+
* @returns {Array<Date>} - An array containing 7 Date objects
|
|
3264
|
+
*/
|
|
3265
|
+
function _getWeekDatesByDate(v) {
|
|
3266
|
+
var dates = [];
|
|
3267
|
+
|
|
3268
|
+
// Ensure we are working with a Date object.
|
|
3269
|
+
// If 'dateFormat' was a custom utility in your JS, replace 'new Date(v)' with that utility.
|
|
3270
|
+
var currentDate = new Date(v);
|
|
3271
|
+
|
|
3272
|
+
// Get the day of the week (0 for Sunday, 1 for Monday, ..., 6 for Saturday)
|
|
3273
|
+
var dayOfWeek = currentDate.getDay();
|
|
3274
|
+
|
|
3275
|
+
// Calculate difference to Monday: if Sunday (0) subtract 6 days, otherwise subtract (day - 1)
|
|
3276
|
+
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
3277
|
+
|
|
3278
|
+
// Create the Monday starting point
|
|
3279
|
+
var monday = new Date(currentDate);
|
|
3280
|
+
monday.setDate(currentDate.getDate() + diffToMonday);
|
|
3281
|
+
|
|
3282
|
+
// Generate the 7 days of the week
|
|
3283
|
+
for (var i = 0; i < 7; i++) {
|
|
3284
|
+
var date = new Date(monday);
|
|
3285
|
+
date.setDate(monday.getDate() + i);
|
|
3286
|
+
dates.push(date);
|
|
3287
|
+
}
|
|
3288
|
+
return dates;
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3164
3291
|
/******/
|
|
3165
3292
|
return __webpack_exports__;
|
|
3166
3293
|
/******/
|
package/EventCalendar/index.js
CHANGED
|
@@ -2216,6 +2216,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2216
2216
|
return (/* binding */_getPrevYearDate
|
|
2217
2217
|
);
|
|
2218
2218
|
},
|
|
2219
|
+
/* harmony export */"getSpecialDateEnd": function getSpecialDateEnd() {
|
|
2220
|
+
return (/* binding */_getSpecialDateEnd
|
|
2221
|
+
);
|
|
2222
|
+
},
|
|
2219
2223
|
/* harmony export */"getSpecifiedDate": function getSpecifiedDate() {
|
|
2220
2224
|
return (/* binding */_getSpecifiedDate
|
|
2221
2225
|
);
|
|
@@ -2228,6 +2232,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2228
2232
|
return (/* binding */_getTomorrowDate
|
|
2229
2233
|
);
|
|
2230
2234
|
},
|
|
2235
|
+
/* harmony export */"getWeekDatesByDate": function getWeekDatesByDate() {
|
|
2236
|
+
return (/* binding */_getWeekDatesByDate
|
|
2237
|
+
);
|
|
2238
|
+
},
|
|
2231
2239
|
/* harmony export */"getWeekDatesFromMon": function getWeekDatesFromMon() {
|
|
2232
2240
|
return (/* binding */_getWeekDatesFromMon
|
|
2233
2241
|
);
|
|
@@ -2290,6 +2298,47 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2290
2298
|
}
|
|
2291
2299
|
/* harmony export */
|
|
2292
2300
|
});
|
|
2301
|
+
/**
|
|
2302
|
+
* Get the Sunday of the week of the specific date, and return to the
|
|
2303
|
+
* end of January next year if it is New Year's Eve
|
|
2304
|
+
* @param {Date | String} v
|
|
2305
|
+
* @returns {String} yyyy-MM-dd
|
|
2306
|
+
*
|
|
2307
|
+
* @example
|
|
2308
|
+
* getSpecialDateEnd('2025-12-29'); // 2026-01-31
|
|
2309
|
+
* getSpecialDateEnd('2025-12-17'); // 2025-12-31
|
|
2310
|
+
*/
|
|
2311
|
+
/**
|
|
2312
|
+
* Calculates a special end date based on the week and month logic.
|
|
2313
|
+
* @param v - The input date (Date object, string, or timestamp)
|
|
2314
|
+
* @returns A formatted date string (YYYY-MM-DD)
|
|
2315
|
+
*/
|
|
2316
|
+
function _getSpecialDateEnd(v) {
|
|
2317
|
+
// Assuming dateFormat returns a Date object based on your logic
|
|
2318
|
+
var date = new Date(v);
|
|
2319
|
+
|
|
2320
|
+
// getWeekDatesByDate should return Date[]
|
|
2321
|
+
var weekDates = _getWeekDatesByDate(v);
|
|
2322
|
+
var sunday = weekDates[6]; // Sunday of that week
|
|
2323
|
+
|
|
2324
|
+
// If Sunday of this week rolls into the next year
|
|
2325
|
+
if (sunday.getFullYear() > date.getFullYear()) {
|
|
2326
|
+
var year = sunday.getFullYear();
|
|
2327
|
+
|
|
2328
|
+
// Get the last day of January of that new year
|
|
2329
|
+
// Note: month 1 in 'new Date' is February, day 0 gives the last day of Jan
|
|
2330
|
+
var lastDay = new Date(year, 1, 0).getDate();
|
|
2331
|
+
|
|
2332
|
+
// Using template literals for the return string
|
|
2333
|
+
return "".concat(year, "-01-").concat(lastDay.toString().padStart(2, '0'));
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
// Default: Return the last day of the current month
|
|
2337
|
+
// We create a date for the "0th" day of the next month to get the end of current month
|
|
2338
|
+
var endOfCurrentMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
2339
|
+
return _getCalendarDate(endOfCurrentMonth);
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2293
2342
|
/**
|
|
2294
2343
|
* The check string contains only hours, minutes, and seconds
|
|
2295
2344
|
* @returns {Boolean}
|
|
@@ -2745,19 +2794,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2745
2794
|
}
|
|
2746
2795
|
|
|
2747
2796
|
/**
|
|
2748
|
-
* Get
|
|
2749
|
-
* @param {Number} weekOffset
|
|
2750
|
-
*
|
|
2797
|
+
* Get all 7 dates for a specific week starting from Sunday.
|
|
2798
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
2799
|
+
* 0: Current week
|
|
2800
|
+
* -1: Previous week
|
|
2801
|
+
* 1: Next week
|
|
2802
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Sunday to Saturday.
|
|
2751
2803
|
*/
|
|
2804
|
+
/*
|
|
2805
|
+
// Demo 1: Get dates for the current week (Sunday Start)
|
|
2806
|
+
const currentWeekSun = getWeekDatesFromSun(0);
|
|
2807
|
+
console.log('Sunday (Start):', currentWeekSun[0].toLocaleDateString());
|
|
2808
|
+
console.log('Saturday (End):', currentWeekSun[6].toLocaleDateString());
|
|
2809
|
+
|
|
2810
|
+
// Demo 2: Get the date range for the previous week
|
|
2811
|
+
const lastWeek = getWeekDatesFromSun(-1);
|
|
2812
|
+
const rangeStart = lastWeek[0].toISOString().split('T')[0];
|
|
2813
|
+
const rangeEnd = lastWeek[6].toISOString().split('T')[0];
|
|
2814
|
+
console.log(`Previous Week Range: ${rangeStart} to ${rangeEnd}`);
|
|
2815
|
+
|
|
2816
|
+
// Demo 3: Checking for Month/Year transitions
|
|
2817
|
+
const transitionWeek = getWeekDatesFromSun(0).map(d => d.toDateString());
|
|
2818
|
+
console.log('Transition Week Dates:', transitionWeek);
|
|
2819
|
+
|
|
2820
|
+
*/
|
|
2752
2821
|
function _getWeekDatesFromSun(weekOffset) {
|
|
2753
2822
|
var dates = [];
|
|
2823
|
+
// Start with a clean date (midnight) to avoid timezone/DST shifts during calculation
|
|
2754
2824
|
var currentDate = new Date();
|
|
2825
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
2826
|
+
var dayOfWeek = currentDate.getDay();
|
|
2755
2827
|
|
|
2756
|
-
//
|
|
2757
|
-
|
|
2828
|
+
// Move to the Sunday of the current week, then apply the week offset
|
|
2829
|
+
// Formula: Current Date - Current Day Index + (Offset * 7)
|
|
2758
2830
|
currentDate.setDate(currentDate.getDate() - dayOfWeek + weekOffset * 7);
|
|
2759
|
-
|
|
2760
|
-
// Get the date of the week
|
|
2761
2831
|
for (var i = 0; i < 7; i++) {
|
|
2762
2832
|
var date = new Date(currentDate);
|
|
2763
2833
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -2767,20 +2837,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2767
2837
|
}
|
|
2768
2838
|
|
|
2769
2839
|
/**
|
|
2770
|
-
* Get
|
|
2771
|
-
* @param {Number} weekOffset
|
|
2772
|
-
*
|
|
2840
|
+
* Get all 7 dates for a specific week starting from Monday.
|
|
2841
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
2842
|
+
* 0: Current week
|
|
2843
|
+
* -1: Previous week
|
|
2844
|
+
* 1: Next week
|
|
2845
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Monday to Sunday.
|
|
2773
2846
|
*/
|
|
2847
|
+
/*
|
|
2848
|
+
// Demo 1: Get dates for the current week
|
|
2849
|
+
const currentWeek = getWeekDatesFromMon(0);
|
|
2850
|
+
console.log('Monday of this week:', currentWeek[0].toLocaleDateString());
|
|
2851
|
+
console.log('Sunday of this week:', currentWeek[6].toLocaleDateString());
|
|
2852
|
+
|
|
2853
|
+
// Demo 2: Get dates for the next week
|
|
2854
|
+
const nextWeek = getWeekDatesFromMon(1);
|
|
2855
|
+
console.log('Monday of next week:', nextWeek[0].toLocaleDateString());
|
|
2856
|
+
|
|
2857
|
+
// Demo 3: Format the output as YYYY-MM-DD
|
|
2858
|
+
const formattedWeek = getWeekDatesFromMon(0).map(date => {
|
|
2859
|
+
const y = date.getFullYear();
|
|
2860
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
2861
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
2862
|
+
return `${y}-${m}-${d}`;
|
|
2863
|
+
});
|
|
2864
|
+
console.log('Formatted Week Array:', formattedWeek);
|
|
2865
|
+
// Result: ["2025-12-29", "2025-12-30", ..., "2026-01-04"]
|
|
2866
|
+
*/
|
|
2774
2867
|
function _getWeekDatesFromMon(weekOffset) {
|
|
2775
2868
|
var dates = [];
|
|
2776
2869
|
var currentDate = new Date();
|
|
2777
2870
|
|
|
2778
|
-
//
|
|
2871
|
+
// Calculate the difference to get to Monday of the current week
|
|
2872
|
+
// If today is Sunday (0), we go back 6 days. Otherwise, go to (1 - currentDay).
|
|
2779
2873
|
var dayOfWeek = currentDate.getDay();
|
|
2780
2874
|
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
2875
|
+
|
|
2876
|
+
// Apply the Monday offset and the week offset (7 days per week)
|
|
2781
2877
|
currentDate.setDate(currentDate.getDate() + diffToMonday + weekOffset * 7);
|
|
2782
2878
|
|
|
2783
|
-
//
|
|
2879
|
+
// Generate the 7 days of the week
|
|
2784
2880
|
for (var i = 0; i < 7; i++) {
|
|
2785
2881
|
var date = new Date(currentDate);
|
|
2786
2882
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -2789,6 +2885,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2789
2885
|
return dates;
|
|
2790
2886
|
}
|
|
2791
2887
|
|
|
2888
|
+
/**
|
|
2889
|
+
* Get the date list of the week for the specified date (starting from Monday)
|
|
2890
|
+
* @param {Date | String} v - The specified date
|
|
2891
|
+
* @returns {Array<Date>} - An array containing 7 Date objects
|
|
2892
|
+
*/
|
|
2893
|
+
function _getWeekDatesByDate(v) {
|
|
2894
|
+
var dates = [];
|
|
2895
|
+
|
|
2896
|
+
// Ensure we are working with a Date object.
|
|
2897
|
+
// If 'dateFormat' was a custom utility in your JS, replace 'new Date(v)' with that utility.
|
|
2898
|
+
var currentDate = new Date(v);
|
|
2899
|
+
|
|
2900
|
+
// Get the day of the week (0 for Sunday, 1 for Monday, ..., 6 for Saturday)
|
|
2901
|
+
var dayOfWeek = currentDate.getDay();
|
|
2902
|
+
|
|
2903
|
+
// Calculate difference to Monday: if Sunday (0) subtract 6 days, otherwise subtract (day - 1)
|
|
2904
|
+
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
2905
|
+
|
|
2906
|
+
// Create the Monday starting point
|
|
2907
|
+
var monday = new Date(currentDate);
|
|
2908
|
+
monday.setDate(currentDate.getDate() + diffToMonday);
|
|
2909
|
+
|
|
2910
|
+
// Generate the 7 days of the week
|
|
2911
|
+
for (var i = 0; i < 7; i++) {
|
|
2912
|
+
var date = new Date(monday);
|
|
2913
|
+
date.setDate(monday.getDate() + i);
|
|
2914
|
+
dates.push(date);
|
|
2915
|
+
}
|
|
2916
|
+
return dates;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2792
2919
|
/******/
|
|
2793
2920
|
return __webpack_exports__;
|
|
2794
2921
|
/******/
|
|
@@ -2418,6 +2418,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2418
2418
|
return (/* binding */_getPrevYearDate
|
|
2419
2419
|
);
|
|
2420
2420
|
},
|
|
2421
|
+
/* harmony export */"getSpecialDateEnd": function getSpecialDateEnd() {
|
|
2422
|
+
return (/* binding */_getSpecialDateEnd
|
|
2423
|
+
);
|
|
2424
|
+
},
|
|
2421
2425
|
/* harmony export */"getSpecifiedDate": function getSpecifiedDate() {
|
|
2422
2426
|
return (/* binding */_getSpecifiedDate
|
|
2423
2427
|
);
|
|
@@ -2430,6 +2434,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2430
2434
|
return (/* binding */_getTomorrowDate
|
|
2431
2435
|
);
|
|
2432
2436
|
},
|
|
2437
|
+
/* harmony export */"getWeekDatesByDate": function getWeekDatesByDate() {
|
|
2438
|
+
return (/* binding */_getWeekDatesByDate
|
|
2439
|
+
);
|
|
2440
|
+
},
|
|
2433
2441
|
/* harmony export */"getWeekDatesFromMon": function getWeekDatesFromMon() {
|
|
2434
2442
|
return (/* binding */_getWeekDatesFromMon
|
|
2435
2443
|
);
|
|
@@ -2492,6 +2500,47 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2492
2500
|
}
|
|
2493
2501
|
/* harmony export */
|
|
2494
2502
|
});
|
|
2503
|
+
/**
|
|
2504
|
+
* Get the Sunday of the week of the specific date, and return to the
|
|
2505
|
+
* end of January next year if it is New Year's Eve
|
|
2506
|
+
* @param {Date | String} v
|
|
2507
|
+
* @returns {String} yyyy-MM-dd
|
|
2508
|
+
*
|
|
2509
|
+
* @example
|
|
2510
|
+
* getSpecialDateEnd('2025-12-29'); // 2026-01-31
|
|
2511
|
+
* getSpecialDateEnd('2025-12-17'); // 2025-12-31
|
|
2512
|
+
*/
|
|
2513
|
+
/**
|
|
2514
|
+
* Calculates a special end date based on the week and month logic.
|
|
2515
|
+
* @param v - The input date (Date object, string, or timestamp)
|
|
2516
|
+
* @returns A formatted date string (YYYY-MM-DD)
|
|
2517
|
+
*/
|
|
2518
|
+
function _getSpecialDateEnd(v) {
|
|
2519
|
+
// Assuming dateFormat returns a Date object based on your logic
|
|
2520
|
+
var date = new Date(v);
|
|
2521
|
+
|
|
2522
|
+
// getWeekDatesByDate should return Date[]
|
|
2523
|
+
var weekDates = _getWeekDatesByDate(v);
|
|
2524
|
+
var sunday = weekDates[6]; // Sunday of that week
|
|
2525
|
+
|
|
2526
|
+
// If Sunday of this week rolls into the next year
|
|
2527
|
+
if (sunday.getFullYear() > date.getFullYear()) {
|
|
2528
|
+
var year = sunday.getFullYear();
|
|
2529
|
+
|
|
2530
|
+
// Get the last day of January of that new year
|
|
2531
|
+
// Note: month 1 in 'new Date' is February, day 0 gives the last day of Jan
|
|
2532
|
+
var lastDay = new Date(year, 1, 0).getDate();
|
|
2533
|
+
|
|
2534
|
+
// Using template literals for the return string
|
|
2535
|
+
return "".concat(year, "-01-").concat(lastDay.toString().padStart(2, '0'));
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
// Default: Return the last day of the current month
|
|
2539
|
+
// We create a date for the "0th" day of the next month to get the end of current month
|
|
2540
|
+
var endOfCurrentMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
2541
|
+
return _getCalendarDate(endOfCurrentMonth);
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2495
2544
|
/**
|
|
2496
2545
|
* The check string contains only hours, minutes, and seconds
|
|
2497
2546
|
* @returns {Boolean}
|
|
@@ -2947,19 +2996,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2947
2996
|
}
|
|
2948
2997
|
|
|
2949
2998
|
/**
|
|
2950
|
-
* Get
|
|
2951
|
-
* @param {Number} weekOffset
|
|
2952
|
-
*
|
|
2999
|
+
* Get all 7 dates for a specific week starting from Sunday.
|
|
3000
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
3001
|
+
* 0: Current week
|
|
3002
|
+
* -1: Previous week
|
|
3003
|
+
* 1: Next week
|
|
3004
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Sunday to Saturday.
|
|
2953
3005
|
*/
|
|
3006
|
+
/*
|
|
3007
|
+
// Demo 1: Get dates for the current week (Sunday Start)
|
|
3008
|
+
const currentWeekSun = getWeekDatesFromSun(0);
|
|
3009
|
+
console.log('Sunday (Start):', currentWeekSun[0].toLocaleDateString());
|
|
3010
|
+
console.log('Saturday (End):', currentWeekSun[6].toLocaleDateString());
|
|
3011
|
+
|
|
3012
|
+
// Demo 2: Get the date range for the previous week
|
|
3013
|
+
const lastWeek = getWeekDatesFromSun(-1);
|
|
3014
|
+
const rangeStart = lastWeek[0].toISOString().split('T')[0];
|
|
3015
|
+
const rangeEnd = lastWeek[6].toISOString().split('T')[0];
|
|
3016
|
+
console.log(`Previous Week Range: ${rangeStart} to ${rangeEnd}`);
|
|
3017
|
+
|
|
3018
|
+
// Demo 3: Checking for Month/Year transitions
|
|
3019
|
+
const transitionWeek = getWeekDatesFromSun(0).map(d => d.toDateString());
|
|
3020
|
+
console.log('Transition Week Dates:', transitionWeek);
|
|
3021
|
+
|
|
3022
|
+
*/
|
|
2954
3023
|
function _getWeekDatesFromSun(weekOffset) {
|
|
2955
3024
|
var dates = [];
|
|
3025
|
+
// Start with a clean date (midnight) to avoid timezone/DST shifts during calculation
|
|
2956
3026
|
var currentDate = new Date();
|
|
3027
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
3028
|
+
var dayOfWeek = currentDate.getDay();
|
|
2957
3029
|
|
|
2958
|
-
//
|
|
2959
|
-
|
|
3030
|
+
// Move to the Sunday of the current week, then apply the week offset
|
|
3031
|
+
// Formula: Current Date - Current Day Index + (Offset * 7)
|
|
2960
3032
|
currentDate.setDate(currentDate.getDate() - dayOfWeek + weekOffset * 7);
|
|
2961
|
-
|
|
2962
|
-
// Get the date of the week
|
|
2963
3033
|
for (var i = 0; i < 7; i++) {
|
|
2964
3034
|
var date = new Date(currentDate);
|
|
2965
3035
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -2969,20 +3039,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2969
3039
|
}
|
|
2970
3040
|
|
|
2971
3041
|
/**
|
|
2972
|
-
* Get
|
|
2973
|
-
* @param {Number} weekOffset
|
|
2974
|
-
*
|
|
3042
|
+
* Get all 7 dates for a specific week starting from Monday.
|
|
3043
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
3044
|
+
* 0: Current week
|
|
3045
|
+
* -1: Previous week
|
|
3046
|
+
* 1: Next week
|
|
3047
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Monday to Sunday.
|
|
2975
3048
|
*/
|
|
3049
|
+
/*
|
|
3050
|
+
// Demo 1: Get dates for the current week
|
|
3051
|
+
const currentWeek = getWeekDatesFromMon(0);
|
|
3052
|
+
console.log('Monday of this week:', currentWeek[0].toLocaleDateString());
|
|
3053
|
+
console.log('Sunday of this week:', currentWeek[6].toLocaleDateString());
|
|
3054
|
+
|
|
3055
|
+
// Demo 2: Get dates for the next week
|
|
3056
|
+
const nextWeek = getWeekDatesFromMon(1);
|
|
3057
|
+
console.log('Monday of next week:', nextWeek[0].toLocaleDateString());
|
|
3058
|
+
|
|
3059
|
+
// Demo 3: Format the output as YYYY-MM-DD
|
|
3060
|
+
const formattedWeek = getWeekDatesFromMon(0).map(date => {
|
|
3061
|
+
const y = date.getFullYear();
|
|
3062
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
3063
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
3064
|
+
return `${y}-${m}-${d}`;
|
|
3065
|
+
});
|
|
3066
|
+
console.log('Formatted Week Array:', formattedWeek);
|
|
3067
|
+
// Result: ["2025-12-29", "2025-12-30", ..., "2026-01-04"]
|
|
3068
|
+
*/
|
|
2976
3069
|
function _getWeekDatesFromMon(weekOffset) {
|
|
2977
3070
|
var dates = [];
|
|
2978
3071
|
var currentDate = new Date();
|
|
2979
3072
|
|
|
2980
|
-
//
|
|
3073
|
+
// Calculate the difference to get to Monday of the current week
|
|
3074
|
+
// If today is Sunday (0), we go back 6 days. Otherwise, go to (1 - currentDay).
|
|
2981
3075
|
var dayOfWeek = currentDate.getDay();
|
|
2982
3076
|
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
3077
|
+
|
|
3078
|
+
// Apply the Monday offset and the week offset (7 days per week)
|
|
2983
3079
|
currentDate.setDate(currentDate.getDate() + diffToMonday + weekOffset * 7);
|
|
2984
3080
|
|
|
2985
|
-
//
|
|
3081
|
+
// Generate the 7 days of the week
|
|
2986
3082
|
for (var i = 0; i < 7; i++) {
|
|
2987
3083
|
var date = new Date(currentDate);
|
|
2988
3084
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -2991,6 +3087,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2991
3087
|
return dates;
|
|
2992
3088
|
}
|
|
2993
3089
|
|
|
3090
|
+
/**
|
|
3091
|
+
* Get the date list of the week for the specified date (starting from Monday)
|
|
3092
|
+
* @param {Date | String} v - The specified date
|
|
3093
|
+
* @returns {Array<Date>} - An array containing 7 Date objects
|
|
3094
|
+
*/
|
|
3095
|
+
function _getWeekDatesByDate(v) {
|
|
3096
|
+
var dates = [];
|
|
3097
|
+
|
|
3098
|
+
// Ensure we are working with a Date object.
|
|
3099
|
+
// If 'dateFormat' was a custom utility in your JS, replace 'new Date(v)' with that utility.
|
|
3100
|
+
var currentDate = new Date(v);
|
|
3101
|
+
|
|
3102
|
+
// Get the day of the week (0 for Sunday, 1 for Monday, ..., 6 for Saturday)
|
|
3103
|
+
var dayOfWeek = currentDate.getDay();
|
|
3104
|
+
|
|
3105
|
+
// Calculate difference to Monday: if Sunday (0) subtract 6 days, otherwise subtract (day - 1)
|
|
3106
|
+
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
3107
|
+
|
|
3108
|
+
// Create the Monday starting point
|
|
3109
|
+
var monday = new Date(currentDate);
|
|
3110
|
+
monday.setDate(currentDate.getDate() + diffToMonday);
|
|
3111
|
+
|
|
3112
|
+
// Generate the 7 days of the week
|
|
3113
|
+
for (var i = 0; i < 7; i++) {
|
|
3114
|
+
var date = new Date(monday);
|
|
3115
|
+
date.setDate(monday.getDate() + i);
|
|
3116
|
+
dates.push(date);
|
|
3117
|
+
}
|
|
3118
|
+
return dates;
|
|
3119
|
+
}
|
|
3120
|
+
|
|
2994
3121
|
/******/
|
|
2995
3122
|
return __webpack_exports__;
|
|
2996
3123
|
/******/
|
|
@@ -5945,14 +6072,29 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
|
|
|
5945
6072
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5946
6073
|
updateTodayDate(date, prevDateRef.current);
|
|
5947
6074
|
}, [date]);
|
|
6075
|
+
|
|
6076
|
+
// Guaranteed year change triggered by the next/prev buttons
|
|
6077
|
+
var isFirstRenderRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(true);
|
|
6078
|
+
var prevYearRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(year); // Record the year of the last occurrence.
|
|
5948
6079
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5949
|
-
//
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
6080
|
+
// 1. Intercept the first render (Mount)
|
|
6081
|
+
if (isFirstRenderRef.current) {
|
|
6082
|
+
isFirstRenderRef.current = false;
|
|
6083
|
+
return;
|
|
6084
|
+
}
|
|
6085
|
+
|
|
6086
|
+
// 2. It only triggers when the year actually changes
|
|
6087
|
+
if (year !== prevYearRef.current) {
|
|
6088
|
+
onChangeYear === null || onChangeYear === void 0 ? void 0 : onChangeYear({
|
|
6089
|
+
day: (0,funda_utils_dist_cjs_date__WEBPACK_IMPORTED_MODULE_6__.padZero)(day),
|
|
6090
|
+
month: (0,funda_utils_dist_cjs_date__WEBPACK_IMPORTED_MODULE_6__.padZero)(month + 1),
|
|
6091
|
+
year: year.toString()
|
|
6092
|
+
});
|
|
6093
|
+
|
|
6094
|
+
// Update the old year ref for next comparison
|
|
6095
|
+
prevYearRef.current = year;
|
|
6096
|
+
}
|
|
6097
|
+
}, [year, month, day, onChangeYear]);
|
|
5956
6098
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
5957
6099
|
var _getCells5 = getCells(),
|
|
5958
6100
|
forwardFillTotal = _getCells5.forwardFillTotal,
|