@ceed/ads 1.4.8 → 1.5.0-next.1
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
|
@@ -1118,7 +1118,7 @@ var useCalendar = (ownerState) => {
|
|
|
1118
1118
|
const today = /* @__PURE__ */ new Date();
|
|
1119
1119
|
today.setHours(0, 0, 0, 0);
|
|
1120
1120
|
return today;
|
|
1121
|
-
})(),
|
|
1121
|
+
})() || ownerState.shouldDisableDate && ownerState.shouldDisableDate(thisDay),
|
|
1122
1122
|
tabIndex: -1,
|
|
1123
1123
|
"aria-label": thisDay.toLocaleDateString(),
|
|
1124
1124
|
"aria-selected": isSelected ? "true" : void 0,
|
|
@@ -2329,6 +2329,7 @@ var DatePicker = (0, import_react19.forwardRef)(
|
|
|
2329
2329
|
inputReadOnly,
|
|
2330
2330
|
hideClearButton,
|
|
2331
2331
|
readOnly,
|
|
2332
|
+
shouldDisableDate,
|
|
2332
2333
|
...innerProps
|
|
2333
2334
|
} = props;
|
|
2334
2335
|
const innerRef = (0, import_react19.useRef)(null);
|
|
@@ -2373,7 +2374,9 @@ var DatePicker = (0, import_react19.forwardRef)(
|
|
|
2373
2374
|
const handleChange = (0, import_react19.useCallback)(
|
|
2374
2375
|
(event) => {
|
|
2375
2376
|
const value2 = event.target.value;
|
|
2376
|
-
setDisplayValue(
|
|
2377
|
+
setDisplayValue(
|
|
2378
|
+
value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2
|
|
2379
|
+
);
|
|
2377
2380
|
setValue(value2);
|
|
2378
2381
|
},
|
|
2379
2382
|
[displayFormat, format, setValue]
|
|
@@ -2505,7 +2508,8 @@ var DatePicker = (0, import_react19.forwardRef)(
|
|
|
2505
2508
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
2506
2509
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2507
2510
|
disableFuture,
|
|
2508
|
-
disablePast
|
|
2511
|
+
disablePast,
|
|
2512
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2509
2513
|
}
|
|
2510
2514
|
), !hideClearButton && /* @__PURE__ */ import_react19.default.createElement(
|
|
2511
2515
|
DialogActions_default,
|
package/dist/index.js
CHANGED
|
@@ -1038,7 +1038,7 @@ var useCalendar = (ownerState) => {
|
|
|
1038
1038
|
const today = /* @__PURE__ */ new Date();
|
|
1039
1039
|
today.setHours(0, 0, 0, 0);
|
|
1040
1040
|
return today;
|
|
1041
|
-
})(),
|
|
1041
|
+
})() || ownerState.shouldDisableDate && ownerState.shouldDisableDate(thisDay),
|
|
1042
1042
|
tabIndex: -1,
|
|
1043
1043
|
"aria-label": thisDay.toLocaleDateString(),
|
|
1044
1044
|
"aria-selected": isSelected ? "true" : void 0,
|
|
@@ -2273,6 +2273,7 @@ var DatePicker = forwardRef6(
|
|
|
2273
2273
|
inputReadOnly,
|
|
2274
2274
|
hideClearButton,
|
|
2275
2275
|
readOnly,
|
|
2276
|
+
shouldDisableDate,
|
|
2276
2277
|
...innerProps
|
|
2277
2278
|
} = props;
|
|
2278
2279
|
const innerRef = useRef3(null);
|
|
@@ -2317,7 +2318,9 @@ var DatePicker = forwardRef6(
|
|
|
2317
2318
|
const handleChange = useCallback7(
|
|
2318
2319
|
(event) => {
|
|
2319
2320
|
const value2 = event.target.value;
|
|
2320
|
-
setDisplayValue(
|
|
2321
|
+
setDisplayValue(
|
|
2322
|
+
value2 ? formatValueString(parseDate(value2, format), displayFormat) : value2
|
|
2323
|
+
);
|
|
2321
2324
|
setValue(value2);
|
|
2322
2325
|
},
|
|
2323
2326
|
[displayFormat, format, setValue]
|
|
@@ -2449,7 +2452,8 @@ var DatePicker = forwardRef6(
|
|
|
2449
2452
|
minDate: minDate ? new Date(minDate) : void 0,
|
|
2450
2453
|
maxDate: maxDate ? new Date(maxDate) : void 0,
|
|
2451
2454
|
disableFuture,
|
|
2452
|
-
disablePast
|
|
2455
|
+
disablePast,
|
|
2456
|
+
shouldDisableDate: shouldDisableDate ? (date) => shouldDisableDate(formatValueString(date, format)) : void 0
|
|
2453
2457
|
}
|
|
2454
2458
|
), !hideClearButton && /* @__PURE__ */ React17.createElement(
|
|
2455
2459
|
DialogActions_default,
|