1
1
import type { DateValue } from "@internationalized/date" ;
2
- import type { DateInputVariantProps } from "@nextui-org/theme" ;
3
2
import type { TimeInputProps } from "@nextui-org/date-input" ;
4
3
import type { ButtonProps } from "@nextui-org/button" ;
5
4
import type { RangeCalendarProps } from "@nextui-org/calendar" ;
@@ -14,7 +13,7 @@ import type {DateInputGroupProps} from "@nextui-org/date-input";
14
13
import type { DateRangePickerSlots , SlotsToClasses } from "@nextui-org/theme" ;
15
14
import type { DateInputProps } from "@nextui-org/date-input" ;
16
15
17
- import { useProviderContext } from "@nextui-org/system" ;
16
+ import { useLabelPlacement , useProviderContext } from "@nextui-org/system" ;
18
17
import { useMemo , useRef } from "react" ;
19
18
import { useDateRangePickerState } from "@react-stately/datepicker" ;
20
19
import { useDateRangePicker as useAriaDateRangePicker } from "@react-aria/datepicker" ;
@@ -144,16 +143,10 @@ export function useDateRangePicker<T extends DateValue>({
144
143
145
144
const showTimeField = ! ! timeGranularity ;
146
145
147
- const labelPlacement = useMemo < DateInputVariantProps [ "labelPlacement" ] > ( ( ) => {
148
- const labelPlacement =
149
- originalProps . labelPlacement ?? globalContext ?. labelPlacement ?? "inside" ;
150
-
151
- if ( labelPlacement === "inside" && ! label ) {
152
- return "outside" ;
153
- }
154
-
155
- return labelPlacement ;
156
- } , [ originalProps . labelPlacement , globalContext ?. labelPlacement , label ] ) ;
146
+ const labelPlacement = useLabelPlacement ( {
147
+ labelPlacement : originalProps . labelPlacement ,
148
+ label,
149
+ } ) ;
157
150
158
151
const shouldLabelBeOutside = labelPlacement === "outside" || labelPlacement === "outside-left" ;
159
152
0 commit comments