cr-ui-lib 1.1.63 → 1.1.64
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1996,8 +1996,10 @@ var DateRangePicker = ({
|
|
|
1996
1996
|
setIsExporting,
|
|
1997
1997
|
isExporting = false,
|
|
1998
1998
|
className = "",
|
|
1999
|
-
hasLimit = false
|
|
1999
|
+
hasLimit = false,
|
|
2000
2000
|
// Default to false to maintain the 1-year limit
|
|
2001
|
+
allowFutureDate = false
|
|
2002
|
+
// Default to false
|
|
2001
2003
|
}) => {
|
|
2002
2004
|
const [isOpen, setIsOpen] = React.useState(autoOpen);
|
|
2003
2005
|
const [isApply, setIsApply] = React.useState(false);
|
|
@@ -2202,7 +2204,7 @@ var DateRangePicker = ({
|
|
|
2202
2204
|
return date >= new Date(Math.min(start.getTime(), end.getTime())) && date <= new Date(Math.max(start.getTime(), end.getTime()));
|
|
2203
2205
|
};
|
|
2204
2206
|
const isDisabledDate = (date) => {
|
|
2205
|
-
if (/* @__PURE__ */ new Date() < date) return true;
|
|
2207
|
+
if (!allowFutureDate && /* @__PURE__ */ new Date() < date) return true;
|
|
2206
2208
|
if ((label === "Custom Range" || endDate === null) && startDate !== null) {
|
|
2207
2209
|
const baseDate = new Date(startDate);
|
|
2208
2210
|
baseDate.setHours(23, 59, 59, 999);
|
|
@@ -2228,9 +2230,11 @@ var DateRangePicker = ({
|
|
|
2228
2230
|
}
|
|
2229
2231
|
return false;
|
|
2230
2232
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2233
|
+
if (!allowFutureDate) {
|
|
2234
|
+
const today = /* @__PURE__ */ new Date();
|
|
2235
|
+
today.setHours(23, 59, 59, 999);
|
|
2236
|
+
if (date > today) return true;
|
|
2237
|
+
}
|
|
2234
2238
|
const earliestDate = /* @__PURE__ */ new Date();
|
|
2235
2239
|
earliestDate.setFullYear(earliestDate.getFullYear() - yearsBack);
|
|
2236
2240
|
earliestDate.setHours(0, 0, 0, 0);
|
|
@@ -2238,11 +2242,13 @@ var DateRangePicker = ({
|
|
|
2238
2242
|
return false;
|
|
2239
2243
|
};
|
|
2240
2244
|
const isDisabledMonth = (year, month) => {
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2245
|
+
if (!allowFutureDate) {
|
|
2246
|
+
const today = /* @__PURE__ */ new Date();
|
|
2247
|
+
const currentYear = today.getFullYear();
|
|
2248
|
+
const currentMonth = today.getMonth();
|
|
2249
|
+
if (year > currentYear || year === currentYear && month > currentMonth) {
|
|
2250
|
+
return true;
|
|
2251
|
+
}
|
|
2246
2252
|
}
|
|
2247
2253
|
const earliestDate = /* @__PURE__ */ new Date();
|
|
2248
2254
|
earliestDate.setFullYear(earliestDate.getFullYear() - 50);
|
|
@@ -2254,12 +2260,14 @@ var DateRangePicker = ({
|
|
|
2254
2260
|
return false;
|
|
2255
2261
|
};
|
|
2256
2262
|
const isDisabledYear = (year) => {
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2263
|
+
if (!allowFutureDate) {
|
|
2264
|
+
const today = /* @__PURE__ */ new Date();
|
|
2265
|
+
const currentYear = today.getFullYear();
|
|
2266
|
+
if (year > currentYear) {
|
|
2267
|
+
return true;
|
|
2268
|
+
}
|
|
2261
2269
|
}
|
|
2262
|
-
const earliestYear =
|
|
2270
|
+
const earliestYear = (/* @__PURE__ */ new Date()).getFullYear() - 50;
|
|
2263
2271
|
if (year < earliestYear) {
|
|
2264
2272
|
return true;
|
|
2265
2273
|
}
|
|
@@ -2308,7 +2316,7 @@ var DateRangePicker = ({
|
|
|
2308
2316
|
setEndDate(date);
|
|
2309
2317
|
return;
|
|
2310
2318
|
}
|
|
2311
|
-
if (date > /* @__PURE__ */ new Date()) return;
|
|
2319
|
+
if (!allowFutureDate && date > /* @__PURE__ */ new Date()) return;
|
|
2312
2320
|
if (isDisabledDate(date)) return;
|
|
2313
2321
|
const isSameMonthView = isSameMonth(leftMonth, rightMonth);
|
|
2314
2322
|
if (!isSameMonthView) {
|
|
@@ -2685,7 +2693,7 @@ var DateRangePicker = ({
|
|
|
2685
2693
|
};
|
|
2686
2694
|
const validateCustomInput = (inputValue, isStartDate) => {
|
|
2687
2695
|
if (inputValue.length !== 10) return false;
|
|
2688
|
-
if (!validateDate(inputValue)) return false;
|
|
2696
|
+
if (!validateDate(inputValue, allowFutureDate)) return false;
|
|
2689
2697
|
const [month, day, year] = inputValue.split("/").map((num) => parseInt(num, 10));
|
|
2690
2698
|
const inputDate = new Date(year, month - 1, day);
|
|
2691
2699
|
if (isDisabledDate(inputDate)) return false;
|
|
@@ -2811,7 +2819,9 @@ var DateRangePicker = ({
|
|
|
2811
2819
|
{
|
|
2812
2820
|
enableYearRange: false,
|
|
2813
2821
|
yearsBack,
|
|
2814
|
-
hasLimit
|
|
2822
|
+
hasLimit,
|
|
2823
|
+
allowFutureDates: allowFutureDate
|
|
2824
|
+
// Pass prop
|
|
2815
2825
|
}
|
|
2816
2826
|
);
|
|
2817
2827
|
setStartInput(formattedValue);
|
|
@@ -2862,7 +2872,11 @@ var DateRangePicker = ({
|
|
|
2862
2872
|
{
|
|
2863
2873
|
enableYearRange: false,
|
|
2864
2874
|
yearsBack,
|
|
2865
|
-
hasLimit
|
|
2875
|
+
hasLimit,
|
|
2876
|
+
allowFutureDates: allowFutureDate,
|
|
2877
|
+
// Pass prop
|
|
2878
|
+
startDate
|
|
2879
|
+
// Pass start date for range validation
|
|
2866
2880
|
}
|
|
2867
2881
|
);
|
|
2868
2882
|
setEndInput(formattedValue);
|