@brightweblabs/ui 1.4.7 → 1.4.8
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/package.json +1 -1
- package/src/components/calendar.tsx +18 -0
package/package.json
CHANGED
|
@@ -16,6 +16,8 @@ import { cn } from "../lib/utils"
|
|
|
16
16
|
import { Button } from "./button"
|
|
17
17
|
import { buttonVariants, type ButtonVariantProps } from "./button-variants"
|
|
18
18
|
|
|
19
|
+
const DEFAULT_FUTURE_YEAR_RANGE = 25
|
|
20
|
+
|
|
19
21
|
function Calendar({
|
|
20
22
|
className,
|
|
21
23
|
classNames,
|
|
@@ -29,6 +31,21 @@ function Calendar({
|
|
|
29
31
|
buttonVariant?: ButtonVariantProps["variant"]
|
|
30
32
|
}) {
|
|
31
33
|
const defaultClassNames = getDefaultClassNames()
|
|
34
|
+
const hasYearDropdown =
|
|
35
|
+
captionLayout === "dropdown" || captionLayout === "dropdown-years"
|
|
36
|
+
const hasExplicitEndMonth =
|
|
37
|
+
props.endMonth !== undefined ||
|
|
38
|
+
props.toMonth !== undefined ||
|
|
39
|
+
props.toYear !== undefined
|
|
40
|
+
const defaultEndMonth =
|
|
41
|
+
hasYearDropdown && !hasExplicitEndMonth
|
|
42
|
+
? new Date(
|
|
43
|
+
(props.today ?? new Date()).getFullYear() +
|
|
44
|
+
DEFAULT_FUTURE_YEAR_RANGE,
|
|
45
|
+
11,
|
|
46
|
+
31
|
|
47
|
+
)
|
|
48
|
+
: undefined
|
|
32
49
|
|
|
33
50
|
return (
|
|
34
51
|
<DayPicker
|
|
@@ -176,6 +193,7 @@ function Calendar({
|
|
|
176
193
|
...components,
|
|
177
194
|
}}
|
|
178
195
|
{...props}
|
|
196
|
+
endMonth={props.endMonth ?? defaultEndMonth}
|
|
179
197
|
/>
|
|
180
198
|
)
|
|
181
199
|
}
|