@ceed/cds 1.4.8 → 1.5.0
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.
|
@@ -15,6 +15,7 @@ export declare const useCalendarProps: (inProps: CalendarProps) => readonly [{
|
|
|
15
15
|
rangeSelection?: boolean | undefined;
|
|
16
16
|
disableFuture?: boolean | undefined;
|
|
17
17
|
disablePast?: boolean | undefined;
|
|
18
|
+
shouldDisableDate?: ((date: Date) => boolean) | undefined;
|
|
18
19
|
}, {
|
|
19
20
|
viewMonth: Date;
|
|
20
21
|
direction: number;
|
|
@@ -32,4 +33,5 @@ export declare const useCalendarProps: (inProps: CalendarProps) => readonly [{
|
|
|
32
33
|
rangeSelection?: boolean | undefined;
|
|
33
34
|
disableFuture?: boolean | undefined;
|
|
34
35
|
disablePast?: boolean | undefined;
|
|
36
|
+
shouldDisableDate?: ((date: Date) => boolean) | undefined;
|
|
35
37
|
}];
|
|
@@ -17,6 +17,13 @@ export interface CalendarProps {
|
|
|
17
17
|
maxDate?: DateValue;
|
|
18
18
|
disableFuture?: boolean;
|
|
19
19
|
disablePast?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Disable specific date.
|
|
22
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
23
|
+
* @param date
|
|
24
|
+
* @returns If `true` the date will be disabled
|
|
25
|
+
*/
|
|
26
|
+
shouldDisableDate?: (date: DateValue) => boolean;
|
|
20
27
|
}
|
|
21
28
|
export interface CalendarOwnerState extends CalendarProps {
|
|
22
29
|
viewMonth: Date;
|
|
@@ -32,6 +32,13 @@ interface BaseDatePickerProps {
|
|
|
32
32
|
displayFormat?: string;
|
|
33
33
|
inputReadOnly?: boolean;
|
|
34
34
|
hideClearButton?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Disable specific date.
|
|
37
|
+
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
|
|
38
|
+
* @param date
|
|
39
|
+
* @returns If `true` the date will be disabled
|
|
40
|
+
*/
|
|
41
|
+
shouldDisableDate?: (date: string) => boolean;
|
|
35
42
|
}
|
|
36
43
|
export type DatePickerProps = BaseDatePickerProps & Omit<React.ComponentProps<typeof Input>, "onChange" | "value" | "defaultValue">;
|
|
37
44
|
declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
package/dist/index.cjs
CHANGED
|
@@ -1104,7 +1104,7 @@ var useCalendar = (ownerState) => {
|
|
|
1104
1104
|
const today = /* @__PURE__ */ new Date();
|
|
1105
1105
|
today.setHours(0, 0, 0, 0);
|
|
1106
1106
|
return today;
|
|
1107
|
-
})(),
|
|
1107
|
+
})() || ownerState.shouldDisableDate && ownerState.shouldDisableDate(thisDay),
|
|
1108
1108
|
tabIndex: -1,
|
|
1109
1109
|
"aria-label": thisDay.toLocaleDateString(),
|
|
1110
1110
|
"aria-selected": isSelected ? "true" : void 0,
|
|
@@ -2315,6 +2315,7 @@ var DatePicker = (0, import_react19.forwardRef)(
|
|
|
2315
2315
|
inputReadOnly,
|
|
2316
2316
|
hideClearButton,
|
|
2317
2317
|
readOnly,
|
|
2318
|
+
shouldDisableDate,
|
|
2318
2319
|
...innerProps
|
|
2319
2320
|
} = props;
|
|
2320
2321
|
const innerRef = (0, import_react19.useRef)(null);
|
|
@@ -2359,7 +2360,9 @@ var DatePicker = (0, import_react19.forwardRef)(
|
|
|
2359
2360
|
const handleChange = (0, import_react19.useCallback)(
|
|
2360
2361
|
(event) => {
|
|
2361
2362
|
const value2 = event.target.value;
|
|
2362
|
-
setDisplayValue(
|
|
2363
|
+
setDisplayValue(
|
|
2364
|
+
value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2
|
|
2365
|
+
);
|
|
2363
2366
|
setValue(value2);
|
|
2364
2367
|
},
|
|
2365
2368
|
[displayFormat, format, setValue]
|
|
@@ -2491,7 +2494,8 @@ var DatePicker = (0, import_react19.forwardRef)(
|
|
|
2491
2494
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
2492
2495
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2493
2496
|
disableFuture,
|
|
2494
|
-
disablePast
|
|
2497
|
+
disablePast,
|
|
2498
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2495
2499
|
}
|
|
2496
2500
|
), !hideClearButton && /* @__PURE__ */ import_react19.default.createElement(
|
|
2497
2501
|
DialogActions_default,
|
package/dist/index.js
CHANGED
|
@@ -1035,7 +1035,7 @@ var useCalendar = (ownerState) => {
|
|
|
1035
1035
|
const today = /* @__PURE__ */ new Date();
|
|
1036
1036
|
today.setHours(0, 0, 0, 0);
|
|
1037
1037
|
return today;
|
|
1038
|
-
})(),
|
|
1038
|
+
})() || ownerState.shouldDisableDate && ownerState.shouldDisableDate(thisDay),
|
|
1039
1039
|
tabIndex: -1,
|
|
1040
1040
|
"aria-label": thisDay.toLocaleDateString(),
|
|
1041
1041
|
"aria-selected": isSelected ? "true" : void 0,
|
|
@@ -2270,6 +2270,7 @@ var DatePicker = forwardRef6(
|
|
|
2270
2270
|
inputReadOnly,
|
|
2271
2271
|
hideClearButton,
|
|
2272
2272
|
readOnly,
|
|
2273
|
+
shouldDisableDate,
|
|
2273
2274
|
...innerProps
|
|
2274
2275
|
} = props;
|
|
2275
2276
|
const innerRef = useRef3(null);
|
|
@@ -2314,7 +2315,9 @@ var DatePicker = forwardRef6(
|
|
|
2314
2315
|
const handleChange = useCallback7(
|
|
2315
2316
|
(event) => {
|
|
2316
2317
|
const value2 = event.target.value;
|
|
2317
|
-
setDisplayValue(
|
|
2318
|
+
setDisplayValue(
|
|
2319
|
+
value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2
|
|
2320
|
+
);
|
|
2318
2321
|
setValue(value2);
|
|
2319
2322
|
},
|
|
2320
2323
|
[displayFormat, format, setValue]
|
|
@@ -2446,7 +2449,8 @@ var DatePicker = forwardRef6(
|
|
|
2446
2449
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
2447
2450
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2448
2451
|
disableFuture,
|
|
2449
|
-
disablePast
|
|
2452
|
+
disablePast,
|
|
2453
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2450
2454
|
}
|
|
2451
2455
|
), !hideClearButton && /* @__PURE__ */ React17.createElement(
|
|
2452
2456
|
DialogActions_default,
|