Skip to content

Commit

Permalink
chore(number-input): apply latest labelPlacement change
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Jan 30, 2025
1 parent a9df502 commit fb635e5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/components/number-input/src/use-number-input.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {NumberInputVariantProps, SlotsToClasses, NumberInputSlots} from "@heroui/theme";
import type {AriaNumberFieldProps} from "@react-types/numberfield";
import type {NumberFieldStateOptions} from "@react-stately/numberfield";
import type {HTMLHeroUIProps, PropGetter} from "@heroui/system";

import {HTMLHeroUIProps, mapPropsVariants, PropGetter, useProviderContext} from "@heroui/system";
import {useLabelPlacement, mapPropsVariants, useProviderContext} from "@heroui/system";
import {useSafeLayoutEffect} from "@heroui/use-safe-layout-effect";
import {useFocusRing} from "@react-aria/focus";
import {numberInput} from "@heroui/theme";
Expand Down Expand Up @@ -197,13 +198,10 @@ export function useNumberInput(originalProps: UseNumberInputProps) {
onPress: handleClear,
});

const labelPlacement = useMemo<NumberInputVariantProps["labelPlacement"]>(() => {
if ((!originalProps.labelPlacement || originalProps.labelPlacement === "inside") && !label) {
return "outside";
}

return originalProps.labelPlacement ?? "inside";
}, [originalProps.labelPlacement, label]);
const labelPlacement = useLabelPlacement({
labelPlacement: originalProps.labelPlacement,
label,
});

const errorMessage =
typeof props.errorMessage === "function"
Expand Down

0 comments on commit fb635e5

Please sign in to comment.